From 174afde97013d9d22dfdbc62470199dcd689e9c7 Mon Sep 17 00:00:00 2001 From: "igor%mir2.org" Date: Sun, 12 Sep 2004 16:41:04 +0000 Subject: [PATCH] My take on the patch from Attila Szegedi to resolve 258959. --- .../serialize/ScriptableInputStream.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/js/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java b/js/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java index d3a79f72ad2..349c6417f5a 100644 --- a/js/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java +++ b/js/rhino/src/org/mozilla/javascript/serialize/ScriptableInputStream.java @@ -17,6 +17,8 @@ * * Contributor(s): * Norris Boyd + * Igor Bukanov + * Attila Szegedi * * Alternatively, the contents of this file may be used under the * terms of the GNU Public License (the "GPL"), in which case the @@ -61,6 +63,24 @@ public class ScriptableInputStream extends ObjectInputStream { super(in); this.scope = scope; enableResolveObject(true); + Context cx = Context.getCurrentContext(); + if (cx != null) { + this.classLoader = cx.getApplicationClassLoader(); + } + } + + protected Class resolveClass(ObjectStreamClass desc) + throws IOException, ClassNotFoundException + { + String name = desc.getName(); + if (classLoader != null) { + try { + return classLoader.loadClass(name); + } catch (ClassNotFoundException ex) { + // fall through to default loading + } + } + return super.resolveClass(desc); } protected Object resolveObject(Object obj) @@ -82,4 +102,5 @@ public class ScriptableInputStream extends ObjectInputStream { } private Scriptable scope; + private ClassLoader classLoader; }