-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.3.0
-
generic
-
generic
Name: yyT116575 Date: 11/14/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
Short Description:
Construction of a LazyValue failed.
Present in:
jdk-1.3.0-c
Repeat by:
Compile the files T02.java and YText.java.
Run T02.
Output (indented for readability):
Problem creating YText with method null and args { :
java.lang.ClassNotFoundException: YText
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:993)
at javax.swing.UIDefaults$ProxyLazyValue.createValue(UIDefaults.java:670)
at javax.swing.UIDefaults.get(UIDefaults.java:145)
at javax.swing.MultiUIDefaults.get(MultiUIDefaults.java:39)
at javax.swing.UIManager.get(UIManager.java:536)
at T02.init(T02.java:18)
at T02.main(T02.java:26)
y-text=null
Comment:
The method to construct a LazyValue in jdk-1.3.0-c looks like this:
public Object createValue(UIDefaults table) {
Object instance = null;
try {
Class c = Class.forName(className);
if (methodName !=null) {
Class[] types = getClassArray(args);
Method m = c.getMethod(methodName, types);
instance = m.invoke(c, args);
} else {
Class[] types = getClassArray(args);
try {
Constructor constructor = c.getConstructor(types);
instance = constructor.newInstance(args);
} catch(Exception e) {
System.out.println("Problem with constructor " + className +
" and args " + printArgs(args) + " : " +
" and types " + printArgs(types) + " : " + e);
Thread.dumpStack();
}
}
} catch(Exception e) {
One of the calls "c.getConstructor(types)" or "constructor.newInstance(args)"
seems to produce the exception.
(Interestingly, if you set "-Xbootclasspath" the exception is not raised.)
The exeption is not raised, if you change getClassArray() from:
private Class[] getClassArray(Object[] args) {
Class[] types = null;
if (args!=null) {
types = new Class[args.length];
for (int i = 0; i< args.length; i++) {
...
to
private Class[] getClassArray(Object[] args) {
Class[] types = new Class[];
if (args!=null) {
types = new Class[args.length];
for (int i = 0; i< args.length; i++) {
...
Programs:: T02.java
===================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class T02
extends JFrame
{
void init()
{
Container cont = getContentPane();
cont.setLayout(new FlowLayout());
cont.add(new JButton("Hello"));
System.out.println("y-text="+UIManager.get("y-text"));
}
public static void main(String[] av)
{
UIManager.put("y-text", new UIDefaults.ProxyLazyValue("YText"));
T02 t = new T02();
t.init();
t.pack();
t.setVisible(true);
}
}
YText.java
==========
public class YText
{
public String s;
public YText(String s)
{
this.s = s;
}
}
(Review ID: 112018)
======================================================================
- duplicates
-
JDK-4275705 swing.UIDefaults.ProxyLazyValue.createValue prints too much
-
- Resolved
-