You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Alexei Zakharov (JIRA)" <ji...@apache.org> on 2006/12/15 17:48:24 UTC

[jira] Resolved: (HARMONY-1967) [classlib][rmi] RMI runtime could not load class with null thread context classloader

     [ http://issues.apache.org/jira/browse/HARMONY-1967?page=all ]

Alexei Zakharov resolved HARMONY-1967.
--------------------------------------

    Resolution: Fixed

Thanks Mikhail! Patches were applied at the revision r487594. Please verify.

> [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
>         Assigned To: Alexei Zakharov
>         Attachments: MarshalledObjectTest.patch, RMIObjectInputStream.patch, UnicastRef.patch, UnicastServerRef.patch
>
>
> 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