JDK-6356571 : (rb) REGRESSION: Spurious java.lang.NoClassDefFoundError: Could not initialize class
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,linux,windows_xp
  • CPU: generic,x86
  • Submitted: 2005-11-29
  • Updated: 2011-02-16
  • Resolved: 2006-02-14
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
6 b72Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b61)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b61, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Linux ip173 2.6.13-15-default #1 Tue Sep 13 14:56:15 UTC 2005 i686 i686 i386 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
The attached test case shows that a spurious ClassNotFoundException can be provoked for a class that references another missing class. The test case involves a dummy ResourceBundle, which is needed for the bug to appear, but I'm not sure that it's the root cause. FYI, I've filed another related bug regarding a possible bug with ResourceBundle and class literals, named "Endless loop on nonexistens ResourceBundle involving class literal", Bug ID 6355009.

Do note that even though a class is missing on purpose (NonExistent.class), the ClassNotFoundException involves an existing class (Aux1.class).

  Interestingly, the problem also shows itself when the missing class is not really missing, but just somewhere else than in the current path. For example, I tried packaging NonExistent.class in a jar file and run the test with the jar added to the class path. The result was the same CNFE as if NonExistent.class was simply missing.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the test case. (make sure you delete NonExistent.class before running Main)
2. Create a "Main.properties" file - it just has to exist to 
make the bundle loading successful. ("touch Main.properties" will create the file)
3. Execute the main class.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No output should be shown if the test runs correctly. I have verified that this is the case with a 1.5.0_05 VM.
ACTUAL -
On Mustang build 61 -
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class Aux1
        at Main.<init>(Main.java:6)
        at Main.main(Main.java:9)


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class Aux1
        at Main.<init>(Main.java:6)
        at Main.main(Main.java:9)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
run.sh run script:
-----------------------------

#!/bin/bash

javac *java
rm NonExistent.class
java Main


(Note the deletion of NonExistent.class after compilation)

Main.java:
------------------

import java.util.ResourceBundle;

public class Main {
    private ResourceBundle bundle = ResourceBundle.getBundle("Main");

    private Aux1 cursor = new Aux1();

    public final static void main(String[] args) {
        new Main();
    }
}

Aux1.java:
------------------

public class Aux1 {
    static {
        new Aux1();
    }

    public Aux1() {
        NonExistent.class.getClassLoader();
    }
}

NonExistent.java:
-------------------------------

public class NonExistent {
}


---------- END SOURCE ----------

Release Regression From : 5.0u5
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

Comments
EVALUATION The fix went to Mustang b72.
24-02-2006

EVALUATION ResourceBundle.Control.newBundle should perform type-checking to see if the specified class is a ResourceBundle subclass.
01-12-2005