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

URLClassLoader: NoClassDefFoundError thrown when not using rt.jar

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0, 1.4.0
    • core-libs
    • None
    • x86, sparc
    • solaris_7, windows_nt

      We are seeing a NoClassDefFoundError when we run a test case.
      We only saw this error on Solaris-sparc, not on Linux.
      I'm sort of perplexed as to why it is happening.

      I did a fresh bringover and a clean build. I can see the classfile
      in my workspace. The permissions are -rw-rw-rw- just like all the
      other files.

      This isn't reproducible in the promoted build: java_g -verbose:class
      shows that the class is loaded correctly. The reason is that the
      promoted build loads classes from rt.jar. The bug is only reproducible
      when classes are loaded from the build directory.

      We tested this using the 2D integration build for Merlin build 89.
      Dmitri built images. When using rt.jar, the class is loaded. When loading
      from the build directory of the same build, we get the NoClassDefFoundError.

      I've reproduced this in several builds, on different machines, dating back
      several weeks.

      /net/jano/export/disk03/awt/echawkes/jdk14-87/build/solaris-sparc/bin/java Test
      java.lang.NoClassDefFoundError: sun/awt/datatransfer/ClipboardTransferable
              at sun.awt.datatransfer.SunClipboard.getContents(SunClipboard.java:83)
              at Test$1.run(Test.java:13)
              at java.lang.Thread.run(Thread.java:539)
      echawkes@gradgrind:/home/bchristi/work/4532299( 204 )%

      Here are the last few lines from a run of java_g -verbose:class

      [Loaded java.awt.datatransfer.Transferable from
      /net/jano/export/disk03/awt/echawkes/jdk14-87/build/solaris-sparc/classes]
      [Loaded java.util.ListIterator from
      /net/jano/export/disk03/awt/echawkes/jdk14-87/build/solaris-sparc/classes]
      [Loaded java.util.LinkedList$ListItr from
      /net/jano/export/disk03/awt/echawkes/jdk14-87/build/solaris-sparc/classes]
      [Loaded sun.reflect.NativeMethodAccessorImpl from
      /net/jano/export/disk03/awt/echawkes/jdk14-87/build/solaris-sparc/classes]
      [Loaded sun.reflect.DelegatingMethodAccessorImpl from
      /net/jano/export/disk03/awt/echawkes/jdk14-87/build/solaris-sparc/classes]
      [Loaded sun.awt.motif.X11Selection from
      /net/jano/export/disk03/awt/echawkes/jdk14-87/build/solaris-sparc/classes]
      java.lang.NoClassDefFoundError: sun/awt/datatransfer/ClipboardTransferable
              at sun.awt.datatransfer.SunClipboard.getContents(SunClipboard.java:83)
              at Test$1.run(Test.java:13)
              at java.lang.Thread.run(Thread.java:539)


      Test case is:

      import java.awt.Toolkit;
      import java.awt.datatransfer.*;

      public class Test {
          public static void main(String[] args) {
              final Object o = new Object();
              final Runnable r = new Runnable() {
                      public void run() {
                          Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemSelection();
                          synchronized (o) {
                              o.notifyAll();
                          }
                          Transferable t = clipboard.getContents(null);
                      }
                  };
              final Thread t = new Thread(r);
              synchronized (o) {
                  t.start();
                  try {
                      o.wait();
                  } catch (InterruptedException ie) {
                      ie.printStackTrace();
                  }
              }
              t.interrupt();
          }

      }


      Please note: the test case above will hang if the class is loaded correctly.
      We discovered the classloader problem while trying to verify the fix for
      4532299. The diffs that fix that hang are in the Suggested Fix section of
      4532299.

      ###@###.### 2001-12-05

      Update: test works correctly when using -server -Xcomp
      NoClassDefFoundError thrown when using -client
      NoClassDefFoundError thrown when using -Xint
       
      ###@###.### 2001-12-05

            yuwangsunw Yujiang Wang (Inactive)
            ehawkessunw Eric Hawkes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: