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

javaws does not work the same as java when user defined classloader is coded

XMLWordPrintable

    • x86_64
    • linux

      FULL PRODUCT VERSION :
      OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
      OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux walter-Precision-Tower-3620 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Program runs as standard java app but when downloaded via java web start the jnlp bundle bombs out
      with the following dump

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:574)
      ... 1 more
      Caused by: java.lang.NoClassDefFoundError: com/brookgreenconsulting/API/FormInterface
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
      at com.brookgreenconsulting.API.BinaryClassLoader.findClass(BinaryClassLoader.java:30)
      at com.brookgreenconsulting.API.API.LoadForm(API.java:174)
      at com.brookgreenconsulting.FormsApplet.Applet.main(Applet.java:82)
      ... 6 more
      Caused by: java.lang.ClassNotFoundException: com.brookgreenconsulting.API.FormInterface
      at java.lang.ClassLoader.findClass(ClassLoader.java:530)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      ... 12 more

      The same program with the same jars runs fine from the command line with straight java (not javaws)

      The following code snippit shows the code in question:

      12public class BinaryClassLoader extends java.lang.ClassLoader
      {
         
          
      16 public BinaryClassLoader(ClassLoader parent)
          {
              super(parent);
          }
          
          protected Class findClass(String name, byte[] binary)
          {
              try
              {
                  Class foundClass = Class.forName(name);
                  return foundClass;
              }
              catch (ClassNotFoundException e)
              {
       30 Class c =defineClass(name, binary, 0, binary.length);
                  resolveClass(c);
                  return c;
              }
          }
          
         
      }


      clearly the dump indicates that the required class ~API.FormInterface was not found but it is clearly
      within a loaded jar, since it is the same jar as the class com.brookgreenconsulting.API, from which
      the call was executed as per the dump

      The contents of this jar is as follows:

      META-INF/MANIFEST.MF
      META-INF/APPLET.SF
      META-INF/APPLET.DSA
      META-INF/
      com/
      com/brookgreenconsulting/
      com/brookgreenconsulting/API/
      com/brookgreenconsulting/API/API.class
      com/brookgreenconsulting/API/BinaryClassLoader.class
      com/brookgreenconsulting/API/FormInterface.class
      com/brookgreenconsulting/API/HttpClient.class
      com/brookgreenconsulting/API/Utility.class

      clearly the javaws should have properly loaded my user defined binary class, as standard java does

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      java program under javaws should have run without exception
      ACTUAL -
      class not found exception thrown while user defined binary class is loaded

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class BinaryClassLoader extends java.lang.ClassLoader
      {
         
          
          public BinaryClassLoader(ClassLoader parent)
          {
              super(parent);
          }
          
          protected Class findClass(String name, byte[] binary)
          {
              try
              {
                  Class foundClass = Class.forName(name);
                  return foundClass;
              }
              catch (ClassNotFoundException e)
              {
                  Class c =defineClass(name, binary, 0, binary.length);
                  resolveClass(c);
                  return c;
              }
          }
          
         
      }

      Note required jar files e-mailed upon request
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known can't try on version 9 since executable is self signed

            pardesha Pardeep Sharma
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: