Uploaded image for project: 'Javassist'
  1. Javassist
  2. JASSIST-18

ProxyFactory.getClassLoader should map null superclass class loader to something

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      org.jboss.test.javassist.test.DynProxyTestCase.testAbstractJDKClassProxy

      Description

      The javassist.util.proxy.ProxyFactory.getClassLoader method:

      protected ClassLoader getClassLoader()

      { if (superClass != null && !superClass.getName().equals("java.lang.Object")) return superClass.getClassLoader(); else if (interfaces != null && interfaces.length > 0) return interfaces[0].getClassLoader(); else return this.getClass().getClassLoader(); // return Thread.currentThread().getContextClassLoader(); }

      is not dealing with null class loaders which are seen for system classes. This results in an NPE when defineClass is called via reflection on the getClassLoader result:

      java.lang.NullPointerException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:117)
      at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:169)
      at javassist.util.proxy.ProxyFactory.create(ProxyFactory.java:199)
      at org.jboss.test.javassist.test.DynProxyTestCase.testAbstractJDKClassProxy(DynProxyTestCase.java:121)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                starksm64 Scott Stark
                Reporter:
                starksm64 Scott Stark
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: