8066683: nashorn test failures after modular image changes

Reviewed-by: attila, jlaskey
This commit is contained in:
Athijegannathan Sundararajan 2014-12-04 20:40:48 +05:30
parent 2dbed37b5e
commit 949112fab2
5 changed files with 30 additions and 12 deletions

View File

@ -36,9 +36,9 @@
<pathelement location="${dist.dir}"/>
</path>
<path id="nashorn.boot.prefix.path">
<pathelement location="${dist.dir}"/>
<pathelement location="${dist.jar}"/>
</path>
<property name="boot.class.path" value="-Xbootclasspath/a:=&quot;${toString:nashorn.boot.prefix.path}&quot;"/>
<property name="boot.class.path" value="-Xbootclasspath/p:&quot;${toString:nashorn.boot.prefix.path}&quot;"/>
<condition property="svn.executable" value="/usr/local/bin/svn" else="svn">
<available file="/usr/local/bin/svn"/>
</condition>

View File

@ -27,6 +27,8 @@ package jdk.nashorn.internal.runtime;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.zip.InflaterInputStream;
import jdk.nashorn.internal.ir.FunctionNode;
@ -36,12 +38,18 @@ import jdk.nashorn.internal.ir.FunctionNode;
*/
final class AstDeserializer {
static FunctionNode deserialize(final byte[] serializedAst) {
try {
return (FunctionNode)new ObjectInputStream(new InflaterInputStream(new ByteArrayInputStream(
serializedAst))).readObject();
} catch (final ClassNotFoundException | IOException e) {
// This is internal, can't happen
throw new AssertionError("Unexpected exception deserializing function", e);
}
// FIXME: do we need this doPrivileged block at all?
return AccessController.doPrivileged(new PrivilegedAction<FunctionNode>() {
@Override
public FunctionNode run() {
try {
return (FunctionNode)new ObjectInputStream(new InflaterInputStream(
new ByteArrayInputStream(serializedAst))).readObject();
} catch (final ClassNotFoundException | IOException e) {
// This is internal, can't happen
throw new AssertionError("Unexpected exception deserializing function", e);
}
}
});
}
}

View File

@ -45,7 +45,15 @@ import jdk.nashorn.internal.runtime.JSType;
* A Dynalink linker to handle web browser built-in JS (DOM etc.) objects.
*/
final class BrowserJSObjectLinker implements TypeBasedGuardingDynamicLinker {
private static final ClassLoader myLoader = BrowserJSObjectLinker.class.getClassLoader();
private static ClassLoader extLoader;
static {
extLoader = BrowserJSObjectLinker.class.getClassLoader();
// in case nashorn is loaded as bootstrap!
if (extLoader == null) {
extLoader = ClassLoader.getSystemClassLoader().getParent();
}
}
private static final String JSOBJECT_CLASS = "netscape.javascript.JSObject";
// not final because this is lazily initialized
// when we hit a subclass for the first time.
@ -69,7 +77,7 @@ final class BrowserJSObjectLinker implements TypeBasedGuardingDynamicLinker {
// check if this class is a subclass of JSObject
Class<?> clazz = type;
while (clazz != null) {
if (clazz.getClassLoader() == myLoader &&
if (clazz.getClassLoader() == extLoader &&
clazz.getName().equals(JSOBJECT_CLASS)) {
jsObjectClass = clazz;
return true;

View File

@ -104,7 +104,7 @@ final class JavaAdapterClassLoader {
// SecurityException for nashorn's classes!. For adapter's to work, we
// should be able to refer to the few classes it needs in its implementation.
if(VISIBLE_INTERNAL_CLASS_NAMES.contains(name)) {
return myLoader.loadClass(name);
return myLoader != null? myLoader.loadClass(name) : Class.forName(name, false, myLoader);
}
throw se;
}

View File

@ -34,3 +34,5 @@
} catch(e if 1) {
}
})()
print("SUCCESS");