Duplicate :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : C:\home\projects\squirrel-sql\sql12\test\src>c:\tools\jdk1.6.0\bin\java -version java version "1.6.0-beta2" Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86) Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : WinXP Pro SP2 A DESCRIPTION OF THE PROBLEM : This test code works fine in 1.5.0_06, but fails in 1.6.0 beta 2. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Compile the code and run it. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Expecting the program to exit without error. ACTUAL - I see the following stack trace: Attempting to load class [Ljava.lang.String; Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: [Ljava.lang.String; at squirrel_sql.test.SerializationTest.cloneObject(SerializationTest.java:66) at squirrel_sql.test.SerializationTest.main(SerializationTest.java:24) Caused by: java.lang.ClassNotFoundException: [Ljava.lang.String; at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at squirrel_sql.test.SerializationTest$1.resolveClass(SerializationTest.java:55) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496) at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1624) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at squirrel_sql.test.SerializationTest.cloneObject(SerializationTest.java:59) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamClass; public class SerializeTest { public static void main(String[] args) throws Exception { String[] objs = new String[10]; objs[0] = new String(); String[] objs2 = (String[])cloneObject(objs, SerializeTest.class.getClassLoader()); } public static Object cloneObject(Object toClone, final ClassLoader classLoader) throws Exception { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ObjectOutputStream oOut = new ObjectOutputStream(bOut); oOut.writeObject(toClone); oOut.close(); ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray()); bOut.close(); ObjectInputStream oIn = new ObjectInputStream(bIn) { protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { System.out.println("Attempting to load class "+desc.getName()); return classLoader.loadClass(desc.getName()); } }; bIn.close(); Object copy = oIn.readObject(); oIn.close(); return copy; } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Don't serialize classes that have arrays of objects as member variables. Release Regression From : 5.0u7 The above release value was the last known release where this bug was not reproducible. Since then there has been a regression.
|