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

REGRESSION: ClassLoader policy causes crash

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

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

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Professional (SP1)

      A DESCRIPTION OF THE PROBLEM :
      We've developed multiple applications that are compiled and linked with a package that may or may not actually exist at runtime. When the package isn't present then a particular object in the missing package (which extends Thread incidentally) is never instantiated. However, it is still a data member of a class that is instantiated. This never caused a problem before Web Start 1.5 and still does work in JDK 1.5 if run from the command line. However, in the new Web Start version the program crashes with a NoClassDefFoundError exception.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the following short example. The Apache XMLSerializer is the pre-compiled class that is linked in at compile time, but which is missing at runtime. However, the exact class used is not really important.

      Next, put these these two classes into a jar named ClassLoaderTest.jar. Then use the provided JNLP to run the program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      This program should show 2 message dialogs, one before the Controller object is instantiated and one after. However, the exception prevents the 2nd dialog from being shown.
      ACTUAL -
      A NoClassDefFoundError exception is thrown for XMLSerializer even though this object is never actually instantiated or used.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.sun.javaws.Launcher.executeApplication(Unknown Source)
      at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
      at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
      at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
      at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
      at com.sun.javaws.Launcher.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.NoClassDefFoundError: org/apache/xml/serialize/XMLSerializer
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
      at java.lang.Class.getDeclaredMethod(Unknown Source)
      at java.lang.Thread$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.lang.Thread.auditSubclass(Unknown Source)
      at java.lang.Thread.isCCLOverridden(Unknown Source)
      at java.lang.Thread.init(Unknown Source)
      at java.lang.Thread.<init>(Unknown Source)
      at Controller.<init>(ClassLoaderTest.java:22)
      at ClassLoaderTest.main(ClassLoaderTest.java:13)
      ... 11 more


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.event.*;
      import javax.swing.*;
      import org.apache.xml.serialize.XMLSerializer;

      public class ClassLoaderTest
      {
          public static void main(String[] args)
          {
            JOptionPane.showMessageDialog(null, "Ready?", "Alert",
                                      JOptionPane.INFORMATION_MESSAGE);

            new Controller();

            JOptionPane.showMessageDialog(null, "Controller Obj Created", "Alert",
                                      JOptionPane.INFORMATION_MESSAGE);
          }

          public Controller controller;
      }

      class Controller extends Thread
      {
          public void setSerializer(XMLSerializer ser)
          {
             serializer = ser;
          }

          public XMLSerializer getSerializer()
          {
             return serializer;
          }

          private XMLSerializer serializer = null;
      }

      Here's the JNLP:

      <?xml version="1.0"?>
      <jnlp
        codebase="http://www.econlab.arizona.edu" href="ws15Test.jnlp">
        <information>
          <title>WebStart 1.5rc Test</title>
          <vendor>ESL</vendor>
          <homepage href="http://www.econlab.arizona.edu"/>
          <description>To help verify that Java Webstart is installed and working.</description>
        </information>
        <resources>
          <j2se version="1.5+"/>
          <jar href="ClassLoaderTest.jar"/>
        </resources>
        <application-desc main-class="ClassLoaderTest"/>
      </jnlp>

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

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 10/15/04 23:06 GMT

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: