United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4470034 NoClassDefFoundError could benefit from exception chaining
JDK-4470034 : NoClassDefFoundError could benefit from exception chaining

Details
Type:
Enhancement
Submit Date:
2001-06-14
Status:
Closed
Updated Date:
2013-05-01
Project Name:
JDK
Resolved Date:
2007-01-17
Component:
hotspot
OS:
generic
Sub-Component:
runtime
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
hs10 (b06)

Related Reports
Backport:
Backport:
Duplicate:

Sub Tasks

Description
Currently, when the VM throws a NoClassDefFoundError, the details of the causative ClassNotFoundException are lost (only the detail message is preserved).  NoClassDefFoundError should be retrofitted with a new constructor that takes a cause (Throwable) and passes it up to Error(Throwable).  The VM should use this constructor when it throws a NoClassDefFoundError as a result of a ClassNotFoundException.  This will provide a more informative stack trace.  In particular, it will indicate which ClassLoader failed to find the class.

                                    

Comments
EVALUATION

JDC comment...
For a demonstration of this bug, compile both classes 
below, then delete Bar.class before executing Foo.

class Foo {
  public static void main(String[] args) {
    System.out.println(Bar.class);
  }
}
class Bar {}


When I run the test this is what it returns.
rm Bar.class
curious-george 96 =>java Foo
Exception in thread "main" java.lang.NoClassDefFoundError: Bar
        at Foo.class$(Foo.java:3)
        at Foo.main(Foo.java:3)



###@###.### 2002-11-01
                                     
2002-11-01
EVALUATION

Best fix would be to add a constructor for NoClassDefFoundError that
took a cause so the VM could call that.

Initial fix is to first call out to the NoClassDefFoundError constructor
and then to call initCause(). This works, but takes extra overhead.
                                     
2006-12-21



Hardware and Software, Engineered to Work Together