8021571: @fork tests should use VM options passed from project.properties
Reviewed-by: lagergren, hannesw, jlaskey
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java Fri Jul 26 20:10:47 2013 +0530
@@ -152,14 +152,14 @@
}
static MethodGenerator makeStaticInitializer(final ClassVisitor cv, final String name) {
- final int access = ACC_PUBLIC | ACC_STATIC;
+ final int access = ACC_PUBLIC | ACC_STATIC;
final String desc = DEFAULT_INIT_DESC;
final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
return new MethodGenerator(mv, access, name, desc);
}
static MethodGenerator makeConstructor(final ClassVisitor cv) {
- final int access = ACC_PUBLIC;
+ final int access = 0;
final String name = INIT;
final String desc = DEFAULT_INIT_DESC;
final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java Fri Jul 26 20:10:47 2013 +0530
@@ -25,6 +25,7 @@
package jdk.nashorn.internal.tools.nasgen;
+import static jdk.internal.org.objectweb.asm.Opcodes.ACC_FINAL;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC;
@@ -80,7 +81,7 @@
byte[] getClassBytes() {
// new class extensing from ScriptObject
final String superClass = (constructor != null)? SCRIPTFUNCTIONIMPL_TYPE : SCRIPTOBJECT_TYPE;
- cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, className, null, superClass, null);
+ cw.visit(V1_7, ACC_FINAL, className, null, superClass, null);
if (memberCount > 0) {
// add fields
emitFields();
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java Fri Jul 26 20:10:47 2013 +0530
@@ -25,6 +25,7 @@
package jdk.nashorn.internal.tools.nasgen;
+import static jdk.internal.org.objectweb.asm.Opcodes.ACC_FINAL;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
import static jdk.internal.org.objectweb.asm.Opcodes.V1_7;
@@ -60,7 +61,7 @@
byte[] getClassBytes() {
// new class extensing from ScriptObject
- cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, className, null, PROTOTYPEOBJECT_TYPE, null);
+ cw.visit(V1_7, ACC_FINAL | ACC_SUPER, className, null, PROTOTYPEOBJECT_TYPE, null);
if (memberCount > 0) {
// add fields
emitFields();
--- a/nashorn/make/project.properties Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/make/project.properties Fri Jul 26 20:10:47 2013 +0530
@@ -230,6 +230,9 @@
run.test.jvmsecurityargs=-Xverify:all -Djava.security.properties=${basedir}/make/java.security.override -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
+# VM options for script tests with @fork option
+test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} ${run.test.jvmsecurityargs}
+
# path of rhino.jar for benchmarks
rhino.jar=
--- a/nashorn/src/jdk/nashorn/internal/objects/BoundScriptFunctionImpl.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/BoundScriptFunctionImpl.java Fri Jul 26 20:10:47 2013 +0530
@@ -35,7 +35,7 @@
* must track their {@code [[TargetFunction]]} property for purposes of correctly implementing {@code [[HasInstance]]};
* see {@link ScriptFunction#isInstance(ScriptObject)}.
*/
-class BoundScriptFunctionImpl extends ScriptFunctionImpl {
+final class BoundScriptFunctionImpl extends ScriptFunctionImpl {
private final ScriptFunction targetFunction;
BoundScriptFunctionImpl(ScriptFunctionData data, ScriptFunction targetFunction) {
--- a/nashorn/src/jdk/nashorn/internal/objects/PrototypeObject.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/PrototypeObject.java Fri Jul 26 20:10:47 2013 +0530
@@ -75,7 +75,7 @@
*
* @param map property map
*/
- public PrototypeObject(final PropertyMap map) {
+ PrototypeObject(final PropertyMap map) {
this(Global.instance(), map);
}
@@ -89,7 +89,7 @@
* @param self self reference
* @return constructor, probably, but not necessarily, a {@link ScriptFunction}
*/
- public static Object getConstructor(final Object self) {
+ static Object getConstructor(final Object self) {
return (self instanceof PrototypeObject) ?
((PrototypeObject)self).getConstructor() :
UNDEFINED;
@@ -100,7 +100,7 @@
* @param self self reference
* @param constructor constructor, probably, but not necessarily, a {@link ScriptFunction}
*/
- public static void setConstructor(final Object self, final Object constructor) {
+ static void setConstructor(final Object self, final Object constructor) {
if (self instanceof PrototypeObject) {
((PrototypeObject)self).setConstructor(constructor);
}
--- a/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java Fri Jul 26 20:10:47 2013 +0530
@@ -51,7 +51,7 @@
* An AccessorProperty is the most generic property type. An AccessorProperty is
* represented as fields in a ScriptObject class.
*/
-public class AccessorProperty extends Property {
+public final class AccessorProperty extends Property {
private static final MethodHandles.Lookup lookup = MethodHandles.lookup();
private static final MethodHandle REPLACE_MAP = findOwnMH("replaceMap", Object.class, Object.class, PropertyMap.class, String.class, Class.class, Class.class);
@@ -149,7 +149,7 @@
* @param property accessor property to rebind
* @param delegate delegate object to rebind receiver to
*/
- public AccessorProperty(final AccessorProperty property, final Object delegate) {
+ AccessorProperty(final AccessorProperty property, final Object delegate) {
super(property);
this.primitiveGetter = bindTo(property.primitiveGetter, delegate);
@@ -185,7 +185,7 @@
* @param getter the property getter
* @param setter the property setter or null if non writable, non configurable
*/
- public AccessorProperty(final String key, final int flags, final int slot, final MethodHandle getter, final MethodHandle setter) {
+ AccessorProperty(final String key, final int flags, final int slot, final MethodHandle getter, final MethodHandle setter) {
super(key, flags, slot);
// we don't need to prep the setters these will never be invalidated as this is a nasgen
--- a/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java Fri Jul 26 20:10:47 2013 +0530
@@ -33,7 +33,7 @@
* This is a subclass that represents a script function that may not be regenerated.
* This is used for example for bound functions and builtins.
*/
-public final class FinalScriptFunctionData extends ScriptFunctionData {
+final class FinalScriptFunctionData extends ScriptFunctionData {
/**
* Constructor - used for bind
--- a/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ListAdapter.java Fri Jul 26 20:10:47 2013 +0530
@@ -47,7 +47,7 @@
* operations respectively, while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and
* {@code pop}.
*/
-public class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> {
+public final class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> {
// These add to the back and front of the list
private static final InvokeByName PUSH = new InvokeByName("push", ScriptObject.class, void.class, Object.class);
private static final InvokeByName UNSHIFT = new InvokeByName("unshift", ScriptObject.class, void.class, Object.class);
--- a/nashorn/src/jdk/nashorn/internal/runtime/Property.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/Property.java Fri Jul 26 20:10:47 2013 +0530
@@ -100,7 +100,7 @@
* @param flags property flags
* @param slot property field number or spill slot
*/
- public Property(final String key, final int flags, final int slot) {
+ Property(final String key, final int flags, final int slot) {
assert key != null;
this.key = key;
this.flags = flags;
@@ -112,7 +112,7 @@
*
* @param property source property
*/
- protected Property(final Property property) {
+ Property(final Property property) {
this.key = property.key;
this.flags = property.flags;
this.slot = property.slot;
@@ -123,7 +123,7 @@
*
* @return cloned property
*/
- protected abstract Property copy();
+ abstract Property copy();
/**
* Property flag utility method for {@link PropertyDescriptor}s. Given two property descriptors,
--- a/nashorn/src/jdk/nashorn/internal/runtime/PropertyListenerManager.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/PropertyListenerManager.java Fri Jul 26 20:10:47 2013 +0530
@@ -32,6 +32,7 @@
* Helper class to manage property listeners and notification.
*/
public class PropertyListenerManager implements PropertyListener {
+ PropertyListenerManager() {}
/** property listeners for this object. */
private Map<PropertyListener,Boolean> listeners;
--- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java Fri Jul 26 20:10:47 2013 +0530
@@ -67,7 +67,7 @@
* @param isBuiltin is the function built in
* @param isConstructor is the function a constructor
*/
- protected ScriptFunctionData(final String name, final int arity, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor) {
+ ScriptFunctionData(final String name, final int arity, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor) {
this.name = name;
this.arity = arity;
this.code = new CompiledFunctions();
--- a/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java Fri Jul 26 20:10:47 2013 +0530
@@ -83,7 +83,7 @@
* @param getterSlot getter slot, starting at first embed
* @param setterSlot setter slot, starting at first embed
*/
- public UserAccessorProperty(final String key, final int flags, final int getterSlot, final int setterSlot) {
+ UserAccessorProperty(final String key, final int flags, final int getterSlot, final int setterSlot) {
super(key, flags, -1);
this.getterSlot = getterSlot;
this.setterSlot = setterSlot;
--- a/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java Fri Jul 26 20:10:47 2013 +0530
@@ -57,7 +57,7 @@
* @param scope scope object
* @param expression with expression
*/
- public WithObject(final ScriptObject scope, final Object expression) {
+ WithObject(final ScriptObject scope, final Object expression) {
super(scope, null);
setIsScope();
this.expression = expression;
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/AdaptationException.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/AdaptationException.java Fri Jul 26 20:10:47 2013 +0530
@@ -26,7 +26,7 @@
package jdk.nashorn.internal.runtime.linker;
@SuppressWarnings("serial")
-class AdaptationException extends Exception {
+final class AdaptationException extends Exception {
private final AdaptationResult adaptationResult;
AdaptationException(final AdaptationResult.Outcome outcome, final String classList) {
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/AdaptationResult.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/AdaptationResult.java Fri Jul 26 20:10:47 2013 +0530
@@ -32,7 +32,7 @@
* A result of generating an adapter for a class. A tuple of an outcome and - in case of an error outcome - a list of
* classes that caused the error.
*/
-class AdaptationResult {
+final class AdaptationResult {
/**
* Contains various outcomes for attempting to generate an adapter class. These are stored in AdapterInfo instances.
* We have a successful outcome (adapter class was generated) and four possible error outcomes: superclass is final,
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java Fri Jul 26 20:10:47 2013 +0530
@@ -58,7 +58,7 @@
* you dynamically invoke a function with the same name from multiple places in your code, it is advisable to create a
* separate instance of this class for every place.
*/
-public class InvokeByName {
+public final class InvokeByName {
private final String name;
private final MethodHandle getter;
private final MethodHandle invoker;
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Fri Jul 26 20:10:47 2013 +0530
@@ -56,7 +56,6 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Random;
import java.util.Set;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Label;
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterServices.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterServices.java Fri Jul 26 20:10:47 2013 +0530
@@ -37,7 +37,7 @@
/**
* Provides static utility services to generated Java adapter classes.
*/
-public class JavaAdapterServices {
+public final class JavaAdapterServices {
private static final ThreadLocal<ScriptObject> classOverrides = new ThreadLocal<>();
private JavaAdapterServices() {
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaArgumentConverters.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaArgumentConverters.java Fri Jul 26 20:10:47 2013 +0530
@@ -42,7 +42,7 @@
* Utility class shared by {@code NashornLinker} and {@code NashornPrimitiveLinker} for converting JS values to Java
* types.
*/
-public class JavaArgumentConverters {
+final class JavaArgumentConverters {
private static final MethodHandle TO_BOOLEAN = findOwnMH("toBoolean", Boolean.class, Object.class);
private static final MethodHandle TO_STRING = findOwnMH("toString", String.class, Object.class);
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornCallSiteDescriptor.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornCallSiteDescriptor.java Fri Jul 26 20:10:47 2013 +0530
@@ -39,7 +39,7 @@
* we can have a more compact representation, as we know that we're always only using {@code "dyn:*"} operations; also
* we're storing flags in an additional primitive field.
*/
-public class NashornCallSiteDescriptor extends AbstractCallSiteDescriptor {
+public final class NashornCallSiteDescriptor extends AbstractCallSiteDescriptor {
/** Flags that the call site references a scope variable (it's an identifier reference or a var declaration, not a
* property access expression. */
public static final int CALLSITE_SCOPE = 0x01;
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornLinker.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornLinker.java Fri Jul 26 20:10:47 2013 +0530
@@ -46,7 +46,7 @@
* This is the main dynamic linker for Nashorn. It is used for linking all {@link ScriptObject} and its subclasses (this
* includes {@link ScriptFunction} and its subclasses) as well as {@link Undefined}.
*/
-public final class NashornLinker implements TypeBasedGuardingDynamicLinker, GuardingTypeConverterFactory, ConversionComparator {
+final class NashornLinker implements TypeBasedGuardingDynamicLinker, GuardingTypeConverterFactory, ConversionComparator {
/**
* Returns true if {@code ScriptObject} is assignable from {@code type}, or it is {@code Undefined}.
*/
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java Fri Jul 26 20:10:47 2013 +0530
@@ -25,7 +25,6 @@
package jdk.nashorn.internal.runtime.linker;
-import jdk.nashorn.internal.lookup.Lookup;
import static jdk.nashorn.internal.lookup.Lookup.MH;
import java.lang.invoke.MethodHandle;
@@ -35,6 +34,7 @@
import jdk.internal.dynalink.linker.LinkRequest;
import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
import jdk.internal.dynalink.support.Guards;
+import jdk.nashorn.internal.lookup.Lookup;
import jdk.nashorn.internal.runtime.ScriptObject;
/**
@@ -42,7 +42,7 @@
* numbers). This class is only public so it can be accessed by classes in the {@code jdk.nashorn.internal.objects}
* package.
*/
-public class PrimitiveLookup {
+public final class PrimitiveLookup {
private PrimitiveLookup() {
}
--- a/nashorn/src/jdk/nashorn/internal/runtime/options/KeyValueOption.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/options/KeyValueOption.java Fri Jul 26 20:10:47 2013 +0530
@@ -36,7 +36,7 @@
*
* {@code --log=module1:level1,module2:level2... }
*/
-public class KeyValueOption extends Option<String> {
+public final class KeyValueOption extends Option<String> {
/**
* Map of keys given
*/
--- a/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java Fri Jul 26 20:10:47 2013 +0530
@@ -34,7 +34,7 @@
* bundle file. Metainfo such as parameters and description is here as well
* for context sensitive help generation.
*/
-public class OptionTemplate implements Comparable<OptionTemplate> {
+public final class OptionTemplate implements Comparable<OptionTemplate> {
/** Resource, e.g. "nashorn" for this option */
private final String resource;
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/AbstractScriptRunnable.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/AbstractScriptRunnable.java Fri Jul 26 20:10:47 2013 +0530
@@ -109,7 +109,6 @@
this.copyExpectedFileName = buildDir + File.separator + testName + ".EXPECTED";
this.expectedFileName = testFile.getPath() + ".EXPECTED";
- final String failListString = System.getProperty(TEST_JS_FAIL_LIST);
if (failListString != null) {
final String[] failedTests = failListString.split(" ");
for (final String failedTest : failedTests) {
@@ -151,10 +150,15 @@
}
// shared context or not?
- protected static final boolean sharedContext;
+ protected static final boolean sharedContext = Boolean.getBoolean(TEST_JS_SHARED_CONTEXT);
+ protected static final String failListString = System.getProperty(TEST_JS_FAIL_LIST);
+ // VM options when a @fork test is executed by a separate process
+ protected static final String[] forkJVMOptions;
static {
- sharedContext = Boolean.getBoolean(TEST_JS_SHARED_CONTEXT);
+ String vmOptions = System.getProperty(TestConfig.TEST_FORK_JVM_OPTIONS);
+ forkJVMOptions = (vmOptions != null)? vmOptions.split(" ") : new String[0];
}
+
private static ThreadLocal<ScriptEvaluator> evaluators = new ThreadLocal<>();
/**
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/ScriptRunnable.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/ScriptRunnable.java Fri Jul 26 20:10:47 2013 +0530
@@ -174,6 +174,9 @@
cmd.add(System.getProperty("java.home") + separator + "bin" + separator + "java");
cmd.add("-Djava.ext.dirs=dist");
+ for (String str : forkJVMOptions) {
+ cmd.add(str);
+ }
cmd.add(Shell.class.getName());
// now add the rest of the "in process" runtime arguments
cmd.addAll(getRuntimeArgs());
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestConfig.java Fri Jul 26 09:17:54 2013 -0300
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestConfig.java Fri Jul 26 20:10:47 2013 +0530
@@ -74,6 +74,8 @@
// shared context mode or not
static final String TEST_JS_SHARED_CONTEXT = "test.js.shared.context";
+ static final String TEST_FORK_JVM_OPTIONS = "test.fork.jvm.options";
+
// file for storing last run's failed tests
static final String TEST_FAILED_LIST_FILE = "test.failed.list.file";
}