提交 bf489ae9 编写于 作者: M malenkov

8019617: Better view of objects

Reviewed-by: art, skoivu
上级 19cf8765
...@@ -31,6 +31,9 @@ import javax.swing.text.*; ...@@ -31,6 +31,9 @@ import javax.swing.text.*;
import java.beans.*; import java.beans.*;
import java.lang.reflect.*; import java.lang.reflect.*;
import sun.reflect.misc.MethodUtil;
import sun.reflect.misc.ReflectUtil;
/** /**
* Component decorator that implements the view interface * Component decorator that implements the view interface
* for <object> elements. * for <object> elements.
...@@ -87,6 +90,7 @@ public class ObjectView extends ComponentView { ...@@ -87,6 +90,7 @@ public class ObjectView extends ComponentView {
AttributeSet attr = getElement().getAttributes(); AttributeSet attr = getElement().getAttributes();
String classname = (String) attr.getAttribute(HTML.Attribute.CLASSID); String classname = (String) attr.getAttribute(HTML.Attribute.CLASSID);
try { try {
ReflectUtil.checkPackageAccess(classname);
Class c = Class.forName(classname, true,Thread.currentThread(). Class c = Class.forName(classname, true,Thread.currentThread().
getContextClassLoader()); getContextClassLoader());
Object o = c.newInstance(); Object o = c.newInstance();
...@@ -115,28 +119,6 @@ public class ObjectView extends ComponentView { ...@@ -115,28 +119,6 @@ public class ObjectView extends ComponentView {
return comp; return comp;
} }
/**
* Get a Class object to use for loading the
* classid. If possible, the Classloader
* used to load the associated Document is used.
* This would typically be the same as the ClassLoader
* used to load the EditorKit. If the documents
* ClassLoader is null,
* <code>Class.forName</code> is used.
*/
private Class getClass(String classname) throws ClassNotFoundException {
Class klass;
Class docClass = getDocument().getClass();
ClassLoader loader = docClass.getClassLoader();
if (loader != null) {
klass = loader.loadClass(classname);
} else {
klass = Class.forName(classname);
}
return klass;
}
/** /**
* Initialize this component according the KEY/VALUEs passed in * Initialize this component according the KEY/VALUEs passed in
* via the &lt;param&gt; elements in the corresponding * via the &lt;param&gt; elements in the corresponding
...@@ -170,7 +152,7 @@ public class ObjectView extends ComponentView { ...@@ -170,7 +152,7 @@ public class ObjectView extends ComponentView {
} }
Object [] args = { value }; Object [] args = { value };
try { try {
writer.invoke(comp, args); MethodUtil.invoke(writer, comp, args);
} catch (Exception ex) { } catch (Exception ex) {
System.err.println("Invocation failed"); System.err.println("Invocation failed");
// invocation code // invocation code
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册