bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/23377] New: Classloading failures with dynamically define


From: WBaer at gmx dot de
Subject: [Bug classpath/23377] New: Classloading failures with dynamically defined classes
Date: 13 Aug 2005 16:17:03 -0000

Hi all,

beanshell exposes a problem with classloading.

With beanshell its possible to define new classes which are interpreted
by beanshell during runtime. In the testsuite that comes with beanshell
there are four serialization testcases. The normal serialization testcases
pass - but the serialization testcase with a new defined class in beanshell
fails during loading the serialized object with ClassNotFoundExceptions.

The failure can be observed with kaffe (CVS today) and jamvm 1.3.2 with 
classpath (CVS today). And well it works with SUN JDK.

This is the relevant part of the beanshell script:

class SerTest1 implements java.io.Serializable { 
        int i;
        SerTest1() { }
        SerTest1(int i ) {
                this.i = i;
        }
}

f=new SerTest1(2);
save( f, "classser.ser" );  // works
f2=load("classser.ser"); // fails

The failure is in the beanshell load command which in effect calls
in a subclassed ObjectInputStream class in the 
resolveClass(ObjectStreamClass cls) method only 
super.resolveClass(ObjectStreamClass cls).

Basically the Class cannot be resolved (at least debug output in kaffe
shows that) because it is not found in the classpath.

I attach a little modified beanshell source with the needed testclasses for
tests. The modified sources includes a simple debug output in the
resolveClass method. Type ant in the extracted directory to compile
and jar the sources and invoke the test as below.

jamvm -cp bsh_test.jar bsh.Interpreter classser.bsh

Class class BshObjectInputStream extends class java.io.ObjectInputStream
public bsh.This BshObjectInputStream._bshThisBshObjectInputStream
public static bsh.This BshObjectInputStream._bshStaticBshObjectInputStream
DEBUG: Cannot resolve class by call to ObjectInputStream.resolveClass() - 
SerTest1
java.lang.ClassNotFoundException: SerTest1
   at java.lang.VMClass.forName (Native Method)
   at java.lang.Class.forName (Class.java:205)
   at java.io.ObjectInputStream.resolveClass (ObjectInputStream.java:753)

[...]

DEBUG: Class resolved by ObjectInputStream.resolveClass() - bsh.XThis
[...]
DEBUG: Class resolved by ObjectInputStream.resolveClass() - bsh.BSHType
DEBUG: Class resolved by ObjectInputStream.resolveClass() - bsh.BSHPrimitiveType
DEBUG: Cannot resolve class by call to ObjectInputStream.resolveClass() - int
java.lang.ClassNotFoundException: int
   at java.lang.VMClass.forName (Native Method)
   at java.lang.Class.forName (Class.java:205)
   at java.io.ObjectInputStream.resolveClass (ObjectInputStream.java:753)

[...]

With kaffe:

kaffe -cp bsh_test.jar:. bsh.Interpreter classser.bsh

Class class BshObjectInputStream extends class java.io.ObjectInputStream
public bsh.This BshObjectInputStream._bshThisBshObjectInputStream
public static bsh.This BshObjectInputStream._bshStaticBshObjectInputStream
DEBUG: Cannot resolve class by call to ObjectInputStream.resolveClass() - 
SerTest1
java.lang.ClassNotFoundException: SerTest1 not found in
java.lang.ClassLoader$1{urls=[file:/test/bsh-2.0b4.jar,file:/test/./],parent=null}
   at java.net.URLClassLoader.findClass (URLClassLoader.java:816)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:349)
   at java.lang.ClassLoader$1.loadClass (ClassLoader.java:1089)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:301)
   at java.lang.Class.forName (Class.java:219)
   at java.io.ObjectInputStream.resolveClass (ObjectInputStream.java:753)

[...]

DEBUG: Class resolved by ObjectInputStream.resolveClass() - bsh.XThis
DEBUG: Class resolved by ObjectInputStream.resolveClass() - bsh.This
[...]
DEBUG: Class resolved by ObjectInputStream.resolveClass() - bsh.BSHPrimitiveType
DEBUG: Cannot resolve class by call to ObjectInputStream.resolveClass() - int
java.lang.ClassNotFoundException: int not found in
java.lang.ClassLoader$1{urls=[file:/test/bsh-2.0b4.jar,file:/test/./],parent=null}
   at java.net.URLClassLoader.findClass (URLClassLoader.java:816)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:349)
   at java.lang.ClassLoader$1.loadClass (ClassLoader.java:1089)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:301)
   at java.lang.Class.forName (Class.java:219)
   at java.io.ObjectInputStream.resolveClass (ObjectInputStream.java:753)
   
[...]

Wolfgang

-- 
           Summary: Classloading failures with dynamically defined classes
           Product: classpath
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: classpath
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: WBaer at gmx dot de
                CC: bug-classpath at gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23377




reply via email to

[Prev in Thread] Current Thread [Next in Thread]