Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4649144

Class name missing from NoClassDefFoundError

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 6
    • hotspot
    • mustang
    • x86
    • linux

      Name: jl125535 Date: 03/07/2002


      FULL PRODUCT VERSION :
      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      Reproduced on Solaris 8 with both 1.3.1 and 1.4.

      FULL OPERATING SYSTEM VERSION :

      Linux niall.rococosoft.com 2.4.17 #4 SMP Tue Jan 29 15:28:00
      GMT 2002 i686 unknown

      A DESCRIPTION OF THE PROBLEM :

      The error NoClassDefFoundError is usually created with the
      name of the class which was not found specified as the
      detail message. This makes it easy to see what class is
      missing by simply printing a stacktrace.

      Under a set of conditions (example code demonstrated below)
      the exception is thrown without the class name - making it
      very difficult to debug the root cause of the problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Copy the code below into test.java
      2. javac test.java
      3. java -cp . test

      EXPECTED VERSUS ACTUAL BEHAVIOR :

      Expected to see class name specified in back trace.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.NoClassDefFoundError
              at test.main(test.java:21)


      (note - class name is missing)


      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Foo
      {
          // Allows the class to compile but fail during loading
          static {
              if (System.getProperty("foo") == null)
                  throw new RuntimeException("no system property foo");
          }
      }


      public class Test
      {

          public static void main(String[] args)
                  throws Throwable
          {
              try {
                  Class.forName("Foo");
              } catch (Throwable t) {
                  t.printStackTrace();
              }
              Foo f = new Foo();
          }
      }


      ---------- END SOURCE ----------
      (Review ID: 143862)
      ======================================================================
      ###@###.### 10/4/04 15:38 GMT

            kamg Keith Mcguigan (Inactive)
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: