harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-1967) [classlib][rmi] RMI runtime could not load class with null thread context classloader
Date Wed, 25 Oct 2006 17:46:16 GMT
[classlib][rmi] RMI runtime could not load class with null thread context classloader
-------------------------------------------------------------------------------------

                 Key: HARMONY-1967
                 URL: http://issues.apache.org/jira/browse/HARMONY-1967
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
         Environment: IA32, WinXP
            Reporter: Mikhail Markov


The test is doing the following steps:
1) tries to restore the serialized object with thread context classloader equal to system
classloader
2) tries to restore the serialized object with thread context classloader equal to null
It is expected that both cases should pass because RMI internal ObjectInputStream should be
able to access non-null classloader up in the execution stack (as normal java.io.ObjectInputStream
does).

Output on RI:
1-st get passed.
2-nd get passed.

Output on Harmony:
1-st get passed.
2-nd get failed:
java.lang.ClassNotFoundException: Test$TestClass
        at java.lang.Class.forName(Unknown Source)
        at org.apache.harmony.rmi.DefaultRMIClassLoaderSpi.loadClass(DefaultRMIClassLoaderSpi.java:325)
        at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:91)
        at org.apache.harmony.rmi.transport.RMIObjectInputStream.resolveClass(RMIObjectInputStream.java:122)
        at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1668)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:701)
        at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1986)
        at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:805)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2096)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2051)
        at java.rmi.MarshalledObject.get(MarshalledObject.java:68)
        at Test.main(Test.java:26)

-----------------Test.java-------------------------
import java.rmi.MarshalledObject;
import java.io.Serializable;

public class Test {
    public static void main(String[] args) throws Exception {
        ClassLoader cl = ClassLoader.getSystemClassLoader();
        MarshalledObject mo = new MarshalledObject(new TestClass());
        Object obj = null;

        // 1-st get: thread context classloader is equal to system classloader
        try {
            obj = mo.get();

            if (obj.getClass().getClassLoader() != cl) {
                System.out.println("1-st get failed: loaded through: "
                        + obj.getClass().getClassLoader() + ", expected: " + cl);
            } else {
                System.out.println("1-st get passed.");
            }
        } catch (Exception ex) {
            System.out.println("1-st get failed:");
            ex.printStackTrace();
        }

        // 2-nd get: thread context classloader is equal to null
        Thread.currentThread().setContextClassLoader(null);

        try {
            obj = mo.get();

            if (obj.getClass().getClassLoader() != cl) {
                System.out.println("2-nd get failed: loaded through: "
                       + obj.getClass().getClassLoader() + ", expected: " + cl);
            } else {
                System.out.println("2-nd get passed.");
            }
        } catch (Exception ex) {
            System.out.println("2-nd get failed:");
            ex.printStackTrace();
        }
    }

    static class TestClass implements Serializable {
    }
}
-------------------------------------------


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message