harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mohanraj Loganathan (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-6297) Harmony tries to load outerclass while loading innerclass through reflection which is different from RI
Date Thu, 06 Aug 2009 07:22:15 GMT
Harmony tries to load outerclass while loading innerclass through reflection which is different
from RI
-------------------------------------------------------------------------------------------------------

                 Key: HARMONY-6297
                 URL: https://issues.apache.org/jira/browse/HARMONY-6297
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
    Affects Versions: 5.0M11
         Environment: Windows XP IA32
            Reporter: Mohanraj Loganathan
            Priority: Minor


Harmony VM attempts to load outer class while loading the innerclass. But RI does not do the
same.

Consider the scenario below:
Step1: Compile TestInnerClass.java [1]  by including junit.jar in the classpath.
Step2: Through reflection call the inner class TestInnerClass$ExceptingEntryPoint  main method
(refer [2]) without including the junit.jar in the classpath

HDK: throws NoClassDefFoundError: junit/framework/TestCase
RI:  prints "I am printing from TestInnerClass$ExceptingEntryPoint"

Throws Exception[3] with DRLVM+Harmony CL. 
But J9VM + Harmony CL / RI not throws any exception


[1] TestInnerClass .java

{code}
import junit.framework.TestCase;
public class TestInnerClass extends TestCase{
    public static class ExceptingEntryPoint {
        public static void main(String[] argv) {
            System.out.println("I am printing from TestInnerClass$ExceptingEntryPoint");
        }
    }
}
{code}

[2] Testcase: ClassLoadTest.java
{code}
import java.lang.reflect.Method;
public class ClassLoadTest {
    public void callMain() throws Exception{
        String classname = "TestInnerClass$ExceptingEntryPoint";     
        Class target = Class.forName(classname, true, this.getClass().getClassLoader());
        Method main = target.getMethod("main", new Class[] {String[].class});
        main.invoke(null, (Object[])new String[] {null});
    }
   
    public static void main(String[] args) throws Exception{
        new ClassLoadTest().callMain();
    }
}
{code}

[3] Exception

{noformat}
Uncaught exception in main:
java.lang.NoClassDefFoundError: junit/framework/TestCase
        at java.lang.ClassLoader.defineClass0(ClassLoader.java)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:367)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:110)
        at java.net.URLClassLoader.access$3(URLClassLoader.java:1)
        at java.net.URLClassLoader$URLHandler.createClass(URLClassLoader.java:263)
        at java.net.URLClassLoader$URLFileHandler.findClass(URLClassLoader.java:565)
        at java.net.URLClassLoader.findClassImpl(URLClassLoader.java:1216)
        at java.net.URLClassLoader$4.run(URLClassLoader.java:901)
        at java.net.URLClassLoader$4.run(URLClassLoader.java:1)
        at java.security.AccessController.doPrivilegedImpl(AccessController.java:171)
        at java.security.AccessController.doPrivileged(AccessController.java:64)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:903)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:489)
        at java.lang.ClassLoader$SystemClassLoader.loadClass(ClassLoader.java:871)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
        at java.lang.VMClassRegistry.getEnclosingClass(VMClassRegistry.java)
        at java.lang.Class.getEnclosingClass(Class.java:851)
        at java.lang.reflect.ReflectExporter.hasSameTopLevelClass(ReflectExporter.java:176)
        at java.lang.reflect.ReflectExporter.allowAccess(ReflectExporter.java:103)
        at java.lang.reflect.ReflectExporter.checkMemberAccess(ReflectExporter.java:86)
        at java.lang.reflect.Method.invoke(Method.java:311)
        at ClassLoadTest.callMain(ClassLoadTest.java:7)
        at ClassLoadTest.main(ClassLoadTest.java:12)
Caused by: java.lang.ClassNotFoundException: junit.framework.TestCase
        at java.net.URLClassLoader.findClass(URLClassLoader.java:907)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:489)
        at java.lang.ClassLoader$SystemClassLoader.loadClass(ClassLoader.java:871)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
        at java.lang.ClassLoader.defineClass0(ClassLoader.java)
        ... 22 more
{noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message