JDK-4470034 : NoClassDefFoundError could benefit from exception chaining
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2001-06-14
  • Updated: 2013-05-01
  • Resolved: 2007-01-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u4Fixed 7Fixed hs10Fixed
Related Reports
Duplicate :  
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.

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.

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