FULL PRODUCT VERSION :
javac 1.6.0_16
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)
java version "1.5.0_21"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_21-b01)
Java HotSpot(TM) Client VM (build 1.5.0_21-b01, mixed mode, sharing)
(Mac OS X 10.6)
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03-219)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02-90, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.0.6002]
Darwin dn0a16674e.sunet 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_I386 i386
A DESCRIPTION OF THE PROBLEM :
Java 5 executes just fine [no thrown exceptions] when instantiating a class [that extends
java.awt.Component] even if it contains a method that returns an interface class [in the
same package], as long as that method is not invoked.
On the other hand, Java 6 throws a NoClassDefFoundError.
Did not look into whether the return type is an interface is a factor, nor if a constructor
other than the no-argument is used.
Works in 1.4.2.
What.class extending javax.swing.JFrame or java.awt.Frame gives the same result.
If What.class extends java.util.Properties instead, both Java 5 and Java 6 produce
the expected result.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile What.java and SomeInterface.java:
javac -target 1.4 -source 1.4 What.java SomeInterface.java
2. Remove SomeInterface.class.
3. Using 1.5.0:
java -cp . What
produces expected result. (No exception thrown.)
4. Using 1.6.0:
java -cp . What
produces actual result. (Exception thrown.)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
BEFORE new What()
AFTER new What()
ACTUAL -
BEFORE new What()
Exception in thread "main" java.lang.NoClassDefFoundError: SomeInterface
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethod(Class.java:1935)
at java.awt.Component.isCoalesceEventsOverriden(Component.java:5948)
at java.awt.Component.access$500(Component.java:169)
at java.awt.Component$3.run(Component.java:5902)
at java.awt.Component$3.run(Component.java:5900)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Component.checkCoalescing(Component.java:5899)
at java.awt.Component.<init>(Component.java:5868)
at What.<init>(What.java:1)
at What.main(What.java:5)
Caused by: java.lang.ClassNotFoundException: SomeInterface
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 12 more
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NoClassDefFoundError: SomeInterface
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethod(Class.java:1935)
at java.awt.Component.isCoalesceEventsOverriden(Component.java:5948)
at java.awt.Component.access$500(Component.java:169)
at java.awt.Component$3.run(Component.java:5902)
at java.awt.Component$3.run(Component.java:5900)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Component.checkCoalescing(Component.java:5899)
at java.awt.Component.<init>(Component.java:5868)
at What.<init>(What.java:1)
at What.main(What.java:5)
Caused by: java.lang.ClassNotFoundException: SomeInterface
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 12 more
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
What.java:
public class What extends java.awt.Component {
public SomeInterface returnSomeInterface() { return null; }
public static void main(String[] args) {
System.out.println("BEFORE new What()");
new What();
System.out.println(" AFTER new What()");
}
}
SomeInterface.java:
interface SomeInterface {
}
---------- END SOURCE ----------
Release Regression From : 5.0u18
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.