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

(cl) Behaviour difference in 1.3.1/ 1.4.1 on a dynamic loaded class

XMLWordPrintable

      FULL PRODUCT VERSION :
      For JRE 1.4
         java version "1.4.2_07"
         Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-b05)
         Java HotSpot(TM) Client VM (build 1.4.2_07-b05, mixed mode)

      For JRE 1.3 /
          java version "1.3.1_09"
         Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_09-b03)
         Java HotSpot(TM) Client VM (build 1.3.1_09-b03, mixed mode)



      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Pro SP2

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Idem if 1.5 is used.

      A DESCRIPTION OF THE PROBLEM :
      When the getMethod is called using 1.3.1 no error

      But with 1.4.1 the following error occur :

      java.lang.NoClassDefFoundError: sans_titre3_lib1/Sans_titre3
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:1655)
        at java.lang.Class.getMethod0(Class.java:1901)
        at java.lang.Class.getMethod(Class.java:984)
        ...


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

      Create "lib3.jar" which contain class "Class3" (using 1.3 or 1.4)
       
      Create "lib2.jar" which contain class "Class2" having method (using 1.3 or 1.4):
         * getString
         * getClass3
          

      Creation application "Application" which:
         * create a ClassLoader containing "lib2.jar"
         * get Class Class2
         * call method "getMethod" for "getString" on Class2

      Put lib2.jar into d:\temp folder

      Build and execute application "Application" using 1.3 or 1.4:
       Error or no error !!!!


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Using 1.3.1 ==> No Error

      Uding 1.4 ==> Error
      java.lang.NoClassDefFoundError: lib3/Class3
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:1655)
        at java.lang.Class.getMethod0(Class.java:1901)
        at java.lang.Class.getMethod(Class.java:984)
        at application.Application1.main(Application1.java:28)

       
          
      ACTUAL -
      No error with 1.3.1.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      The error message is, using 1.4.1:
      java.lang.NoClassDefFoundError: lib3/Class3
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:1655)
        at java.lang.Class.getMethod0(Class.java:1901)
        at java.lang.Class.getMethod(Class.java:984)
        at application.Application1.main(Application1.java:28)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      ======================================================
      Class3
      ======================================================

      package lib3;
      public class Class3 {
          public Class3() {
          }
      }


      ======================================================
      Class2
      ======================================================
      package lib2;
      import lib3.Class3;
      public class Class2 {
          private Class3 myClass3 = null ;
          public Class2() {
          }
          public String getValue(String myValue) {
              return myValue;
          }
          public Class3 getClass3() {
              return myClass3;
          }
      }

      ======================================================
      Main Application
      ======================================================
      package application;

      import java.net.URL;
      import java.net.URLClassLoader;

      public class Application1 {

          public Application1() {
          }

          public static void main(String[] args) {
              try {
                  // Cration of Class Loader
                  URL url1 = new URL("file:///D:\\temp\\lib2.jar");
                  URL[] lu = new URL[1];
                  lu[0] = url1;
                  URLClassLoader ucl = URLClassLoader.newInstance(lu,null);

                  // Load the Class
                  Class myClass = ucl.loadClass("lib2.Class2");

      // get Method
      // !!!!!!!!!!!!!!!!!! ERROR at this line using 1.4.1 !!!!!!!!!!!!!!!!!!!!!
                  java.lang.reflect.Method m = myClass.getMethod("getValue",new Class[] {String.class});

                  // Display the method name
                  System.out.print("Method Name = " + m.getName());

              } catch (Exception ex) {
                  ex.printStackTrace();
              } catch (Throwable ww ) {
                  ww.printStackTrace();
              } finally {
              }
          }
      }


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

      CUSTOMER SUBMITTED WORKAROUND :
      No identify workaround except include lib3.jar into the URL but for our application, using a dynamic loader process, lib3.jar is unknown.

      Release Regression From : 1.4.1
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 2005-05-18 05:57:19 GMT
      ###@###.### 2005-06-23 18:46:17 GMT

            Unassigned Unassigned
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: