Merge
This commit is contained in:
commit
b077dc9ae5
@ -83,6 +83,6 @@
|
||||
|
||||
/**
|
||||
* Contains the linker for ordinary Java objects.
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
package jdk.dynalink.beans;
|
||||
|
@ -111,6 +111,6 @@
|
||||
* implement the {@link jdk.dynalink.linker.GuardingTypeConverterFactory}
|
||||
* interface to provide the logic for these conversions.
|
||||
* </p>
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
package jdk.dynalink.linker;
|
||||
|
@ -87,6 +87,6 @@
|
||||
* by providing basic implementations of some classes as well as various
|
||||
* utilities.
|
||||
* </p>
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
package jdk.dynalink.linker.support;
|
||||
|
@ -85,6 +85,6 @@
|
||||
* <p>Contains classes that make using Dynalink more convenient by providing
|
||||
* basic implementations of some classes as well as various utilities.
|
||||
* </p>
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
package jdk.dynalink.support;
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>expression</em> [ <em>index</em> ]
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ArrayAccessTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||
/**
|
||||
* Represents ECMAScript array literal expression.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ArrayLiteralTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>variable</em> = <em>expression</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface AssignmentTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>leftOperand</em> <em>operator</em> <em>rightOperand</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface BinaryTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ import java.util.List;
|
||||
* { <em>statements</em> }
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface BlockTree extends StatementTree {
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ package jdk.nashorn.api.tree;
|
||||
* break <em>label</em> ;
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface BreakTree extends GotoTree {
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ import java.util.List;
|
||||
* <em>statements</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface CaseTree extends Tree {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>block</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface CatchTree extends Tree {
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ import java.util.List;
|
||||
* Represents the abstract syntax tree for compilation units (source
|
||||
* files)
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface CompilationUnitTree extends Tree {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>variable</em> <em>operator</em> <em>expression</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface CompoundAssignmentTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>condition</em> ? <em>trueExpression</em> : <em>falseExpression</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ConditionalExpressionTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ package jdk.nashorn.api.tree;
|
||||
/**
|
||||
* A mixin for conditional "loop" statements.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ConditionalLoopTree extends LoopTree {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* continue <em>label</em> ;
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ContinueTree extends GotoTree {
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>debugger;</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface DebuggerTree extends StatementTree {
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ package jdk.nashorn.api.tree;
|
||||
* <p>Line terminator is as defined in ECMAScript specification which is one
|
||||
* of { \u000A, \u000B, \u2028, \u2029 }.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface Diagnostic {
|
||||
|
||||
|
@ -28,7 +28,7 @@ package jdk.nashorn.api.tree;
|
||||
/**
|
||||
* Interface for receiving diagnostics from Nashorn parser.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface DiagnosticListener {
|
||||
|
@ -35,7 +35,7 @@ package jdk.nashorn.api.tree;
|
||||
* while ( <em>expression</em> );
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface DoWhileLoopTree extends ConditionalLoopTree {
|
||||
/**
|
||||
|
@ -33,6 +33,6 @@ package jdk.nashorn.api.tree;
|
||||
* ;
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface EmptyStatementTree extends StatementTree {}
|
||||
|
@ -28,7 +28,7 @@ package jdk.nashorn.api.tree;
|
||||
/**
|
||||
* A tree node to stand in for a malformed expression.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ErroneousTree extends ExpressionTree {
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>expression</em> ;
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ExpressionStatementTree extends StatementTree {
|
||||
/**
|
||||
|
@ -29,6 +29,6 @@ package jdk.nashorn.api.tree;
|
||||
* A tree node used as the base class for the different types of
|
||||
* expressions.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ExpressionTree extends Tree {}
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>statement</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ForInLoopTree extends LoopTree {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>statement</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ForLoopTree extends ConditionalLoopTree {
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ import java.util.List;
|
||||
* this . <em>identifier</em> ( <em>arguments</em> )
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface FunctionCallTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ import java.util.List;
|
||||
* <em>body</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface FunctionDeclarationTree extends StatementTree {
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ import java.util.List;
|
||||
* <em>body</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface FunctionExpressionTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ package jdk.nashorn.api.tree;
|
||||
* type serves as a super interface for {@link BreakTree} and
|
||||
* {@link ContinueTree}.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface GotoTree extends StatementTree {
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>name</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface IdentifierTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>elseStatement</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface IfTree extends StatementTree {
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>expression</em> instanceof <em>type</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface InstanceOfTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>label</em> : <em>statement</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface LabeledStatementTree extends StatementTree {
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ package jdk.nashorn.api.tree;
|
||||
* Provides methods to convert between character positions and line numbers
|
||||
* for a compilation unit.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface LineMap {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>value</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface LiteralTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ package jdk.nashorn.api.tree;
|
||||
/**
|
||||
* A mixin for "loop" statements.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface LoopTree extends StatementTree {
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>expression</em> . <em>identifier</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface MemberSelectTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ package jdk.nashorn.api.tree;
|
||||
* new <em>identifier</em> ( <em>arguments</em> )
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface NewTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||
/**
|
||||
* Represents ECMAScript object literal expression.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ObjectLiteralTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* ( <em>expression</em> )
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ParenthesizedTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ import jdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||
/**
|
||||
* Represents nashorn ECMAScript parser instance.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface Parser {
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ package jdk.nashorn.api.tree;
|
||||
/**
|
||||
* To represent property setting in an object literal tree.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface PropertyTree extends Tree {
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ package jdk.nashorn.api.tree;
|
||||
/**
|
||||
* Represents regular expression literal in the source code.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface RegExpLiteralTree extends Tree {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* return <em>expression</em>;
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ReturnTree extends StatementTree {
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ package jdk.nashorn.api.tree;
|
||||
* A tree node used as the base class for the different kinds of
|
||||
* statements.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface StatementTree extends Tree {
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import java.util.List;
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface SwitchTree extends StatementTree {
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* throw <em>expression</em>;
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface ThrowTree extends StatementTree {
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ package jdk.nashorn.api.tree;
|
||||
* <p><b>WARNING:</b> This interface and its sub-interfaces are
|
||||
* subject to change as the ECMAScript programming language evolves.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface Tree {
|
||||
|
||||
|
@ -51,7 +51,7 @@ package jdk.nashorn.api.tree;
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface TreeVisitor<R,P> {
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ import java.util.List;
|
||||
* <em>finallyBlock</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface TryTree extends StatementTree {
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>expression</em> <em>operator</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface UnaryTree extends ExpressionTree {
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* {@linkplain TreeVisitor tree visitor} to indicate that the
|
||||
* visitor was created for a prior version of the language.
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public class UnknownTreeException extends RuntimeException {
|
||||
|
||||
|
@ -33,7 +33,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>var</em> <em>name</em> <em>initializer</em> ;
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface VariableTree extends StatementTree {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>statement</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface WhileLoopTree extends ConditionalLoopTree {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ package jdk.nashorn.api.tree;
|
||||
* <em>statement</em>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
public interface WithTree extends StatementTree {
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.9
|
||||
* @since 9
|
||||
*/
|
||||
package jdk.nashorn.api.tree;
|
||||
|
||||
|
@ -335,7 +335,7 @@ final class FoldConstants extends SimpleNodeVisitor implements Loggable {
|
||||
break;
|
||||
case SHR:
|
||||
final long result = JSType.toUint32(lhs.getInt32() >>> rhs.getInt32());
|
||||
return LiteralNode.newInstance(token, finish, JSType.isRepresentableAsInt(result) ? (int) result : (double) result);
|
||||
return LiteralNode.newInstance(token, finish, JSType.toNarrowestNumber(result));
|
||||
case SAR:
|
||||
return LiteralNode.newInstance(token, finish, lhs.getInt32() >> rhs.getInt32());
|
||||
case SHL:
|
||||
|
@ -70,7 +70,6 @@ import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
|
||||
import jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator;
|
||||
import jdk.nashorn.internal.runtime.arrays.ContinuousArrayData;
|
||||
import jdk.nashorn.internal.runtime.arrays.IntElements;
|
||||
import jdk.nashorn.internal.runtime.arrays.IntOrLongElements;
|
||||
import jdk.nashorn.internal.runtime.arrays.IteratorAction;
|
||||
import jdk.nashorn.internal.runtime.arrays.NumericElements;
|
||||
import jdk.nashorn.internal.runtime.linker.Bootstrap;
|
||||
@ -285,7 +284,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin
|
||||
final long newLen = NativeArray.validLength(newLenDesc.getValue());
|
||||
|
||||
// Step 3e - note that we need to convert to int or double as long is not considered a JS number type anymore
|
||||
newLenDesc.setValue(JSType.isRepresentableAsInt(newLen) ? Integer.valueOf((int) newLen) : Double.valueOf((double) newLen));
|
||||
newLenDesc.setValue(JSType.toNarrowestNumber(newLen));
|
||||
|
||||
// Step 3f
|
||||
// increasing array length - just need to set new length value (and attributes if any) and return
|
||||
@ -1043,7 +1042,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin
|
||||
if (bulkable(sobj) && sobj.getArray().length() + args.length <= JSType.MAX_UINT) {
|
||||
final ArrayData newData = sobj.getArray().push(true, args);
|
||||
sobj.setArray(newData);
|
||||
return newData.length();
|
||||
return JSType.toNarrowestNumber(newData.length());
|
||||
}
|
||||
|
||||
long len = JSType.toUint32(sobj.getLength());
|
||||
@ -1052,7 +1051,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin
|
||||
}
|
||||
sobj.set("length", len, CALLSITE_STRICT);
|
||||
|
||||
return len;
|
||||
return JSType.toNarrowestNumber(len);
|
||||
} catch (final ClassCastException | NullPointerException e) {
|
||||
throw typeError(Context.getGlobal(), e, "not.an.object", ScriptRuntime.safeToString(self));
|
||||
}
|
||||
@ -1471,7 +1470,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin
|
||||
final long newLength = len + items.length;
|
||||
sobj.set("length", newLength, CALLSITE_STRICT);
|
||||
|
||||
return newLength;
|
||||
return JSType.toNarrowestNumber(newLength);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -791,6 +791,15 @@ public enum JSType {
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a long to the narrowest JavaScript Number type. This returns either a
|
||||
* {@link Integer} or {@link Double} depending on the magnitude of {@code l}.
|
||||
* @param l a long value
|
||||
* @return the value converted to Integer or Double
|
||||
*/
|
||||
public static Number toNarrowestNumber(final long l) {
|
||||
return isRepresentableAsInt(l) ? Integer.valueOf((int) l) : Double.valueOf((double) l);
|
||||
}
|
||||
|
||||
/**
|
||||
* JavaScript compliant conversion of Boolean to number
|
||||
@ -1726,21 +1735,6 @@ public enum JSType {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the boxed version of a primitive class
|
||||
* @param clazz the class
|
||||
* @return the boxed type of clazz, or unchanged if not primitive
|
||||
*/
|
||||
public static Class<?> getBoxedClass(final Class<?> clazz) {
|
||||
if (clazz == int.class) {
|
||||
return Integer.class;
|
||||
} else if (clazz == double.class) {
|
||||
return Double.class;
|
||||
}
|
||||
assert !clazz.isPrimitive();
|
||||
return clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a method handle constant of the correct primitive type
|
||||
* for a constant object
|
||||
|
@ -54,7 +54,13 @@ public class PropertyListeners {
|
||||
*/
|
||||
PropertyListeners(final PropertyListeners listener) {
|
||||
if (listener != null && listener.listeners != null) {
|
||||
this.listeners = new WeakHashMap<>(listener.listeners);
|
||||
this.listeners = new WeakHashMap<>();
|
||||
// We need to copy the nested weak sets in order to avoid concurrent modification issues, see JDK-8146274
|
||||
synchronized (listener) {
|
||||
for (final Map.Entry<Object, WeakPropertyMapSet> entry : listener.listeners.entrySet()) {
|
||||
this.listeners.put(entry.getKey(), new WeakPropertyMapSet(entry.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,7 +234,15 @@ public class PropertyListeners {
|
||||
|
||||
private static class WeakPropertyMapSet {
|
||||
|
||||
private final WeakHashMap<PropertyMap, Boolean> map = new WeakHashMap<>();
|
||||
private final WeakHashMap<PropertyMap, Boolean> map;
|
||||
|
||||
WeakPropertyMapSet() {
|
||||
this.map = new WeakHashMap<>();
|
||||
}
|
||||
|
||||
WeakPropertyMapSet(final WeakPropertyMapSet set) {
|
||||
this.map = new WeakHashMap<>(set.map);
|
||||
}
|
||||
|
||||
void add(final PropertyMap propertyMap) {
|
||||
map.put(propertyMap, Boolean.TRUE);
|
||||
|
@ -24,7 +24,7 @@ Object.preventExtensions=prevents new properties from ever being added to the gi
|
||||
|
||||
Object.isSealed=tells if an object is sealed or not
|
||||
|
||||
Object.isFrozen=tells if an object is fronzen or not
|
||||
Object.isFrozen=tells if an object is frozen or not
|
||||
|
||||
Object.isExtensible=tells if an object is extensible or not
|
||||
|
||||
@ -32,7 +32,7 @@ Object.keys=returns an array of the given object's own enumerable properties
|
||||
|
||||
Object=creates a new script object or converts given value as a script object
|
||||
|
||||
Object.prototype.toString=returns a string representing of this object
|
||||
Object.prototype.toString=returns a string representation of this object
|
||||
|
||||
Object.prototype.hasOwnProperty=tells whether this object has the specified property or not
|
||||
|
||||
@ -42,3 +42,60 @@ Object.prototype.propertyIsEnumerable=tells whether the given property is enumer
|
||||
|
||||
Object.bindProperties=binds the source object's properties to the target object (nashorn extension)
|
||||
|
||||
Array.isArray=tells whether the argument is an array
|
||||
|
||||
Array.prototype.toString=returns a string representation of this array
|
||||
|
||||
Array.prototype.assertNumeric=asserts that the array is numeric, throws a type error if this is not the case
|
||||
|
||||
Array.prototype.toLocaleString=returns a locale-specific string representation of this array
|
||||
|
||||
Array=creates a new array
|
||||
|
||||
Array.prototype.concat=concatenates arrays
|
||||
|
||||
Array.prototype.join=returns a string representation of the array, with a separator placed between elements
|
||||
|
||||
Array.prototype.pop=returns the element from the end of the array, or undefined
|
||||
|
||||
Array.prototype.push=appends an element to the end of the array
|
||||
|
||||
Array.prototype.reverse=reverses the array
|
||||
|
||||
Array.prototype.shift=removes the first element from the array and returns that element
|
||||
|
||||
Array.prototype.slice=returns a shallow copy of a slice of the array
|
||||
|
||||
Array.prototype.sort=sorts the array
|
||||
|
||||
Array.prototype.splice=changes the content of the array by removing and/or adding elements
|
||||
|
||||
Array.prototype.unshift=adds one or more elements to the beginning of the array
|
||||
|
||||
Array.prototype.indexOf=retrieves the first index of an element in the array, or -1 if the element is not found
|
||||
|
||||
Array.prototype.lastIndexOf=retrieves the last index of an element in the array, or -1 if the element is not found
|
||||
|
||||
Array.prototype.every=applies a predicate to all elements of the array, returns true if the predicate evaluates to true for all
|
||||
|
||||
Array.prototype.some=tests whether a predicate evaluates to true for some element in the array
|
||||
|
||||
Array.prototype.forEach=applies a function to all elements in the array
|
||||
|
||||
Array.prototype.map=applies a function to all elements in the array, returns the array of results
|
||||
|
||||
Array.prototype.filter=returns an array with those elements from this array that match a filter function
|
||||
|
||||
Array.prototype.reduce=applies a left-fold to the array and returns the result
|
||||
|
||||
Array.prototype.reduceRight=applies a right-fold to the array and returns the result
|
||||
|
||||
Function=creates a new function with the given parameters and function body
|
||||
|
||||
Function.prototype.toString=returns a string representation of this function
|
||||
|
||||
Function.prototype.apply=invokes the function with the given this-reference and arguments array
|
||||
|
||||
Function.prototype.call=invokes the function with the given this-reference and arguments
|
||||
|
||||
Function.prototype.bind=returns a new function with bound this-reference and arguments
|
||||
|
44
nashorn/test/script/basic/JDK-8147845.js
Normal file
44
nashorn/test/script/basic/JDK-8147845.js
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8147845: Varargs Array functions still leaking longs
|
||||
*
|
||||
* @test
|
||||
* @run
|
||||
*/
|
||||
|
||||
Assert.assertTrue([].push() === 0);
|
||||
Assert.assertTrue([].unshift() === 0);
|
||||
Assert.assertTrue(typeof [].push() === 'number');
|
||||
Assert.assertTrue(typeof [].unshift() === 'number');
|
||||
|
||||
Assert.assertTrue([].push(1, 2, 3) === 3);
|
||||
Assert.assertTrue([].unshift(1, 2, 3) === 3);
|
||||
Assert.assertTrue(typeof [].push(1, 2, 3) === 'number');
|
||||
Assert.assertTrue(typeof [].unshift(1, 2, 3) === 'number');
|
||||
|
||||
Assert.assertTrue([].push(1) === 1);
|
||||
Assert.assertTrue([].unshift(1) === 1);
|
||||
Assert.assertTrue(typeof [].push(1) === 'number');
|
||||
Assert.assertTrue(typeof [].unshift(1) === 'number');
|
34
nashorn/test/script/nosecurity/Hello.java
Normal file
34
nashorn/test/script/nosecurity/Hello.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a test program used in the test jjs-option-cp.js
|
||||
*/
|
||||
public class Hello {
|
||||
public Hello() {
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return "hello";
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,6 @@
|
||||
* Test that shebang handling works properly.
|
||||
*
|
||||
* @test
|
||||
* @runif os.not.windows
|
||||
* @option -scripting
|
||||
* @run
|
||||
*/
|
||||
@ -126,8 +125,9 @@ function insn(name) {
|
||||
}
|
||||
|
||||
function run(viajjs, name, arg1, arg2) {
|
||||
var prefix = viajjs ? "${jjs} -scripting " : ''
|
||||
$EXEC("${prefix}./shebang.js ${arg1} ${arg2}")
|
||||
var prefix = viajjs ? "${jjs} -scripting " : win ? 'sh -c "' : '',
|
||||
suffix = viajjs ? '' : win ? '"' : ''
|
||||
$EXEC("${prefix}./shebang.js ${arg1} ${arg2}${suffix}")
|
||||
print("* ${name} via ${viajjs ? 'jjs' : 'shebang'}")
|
||||
print($OUT.trim())
|
||||
print($ERR.trim())
|
||||
@ -143,8 +143,8 @@ shebs.forEach(function(sheb) {
|
||||
$EXEC('chmod +x shebang.js')
|
||||
run(false, 'noargs', '', '')
|
||||
run(true, 'noargs', '', '')
|
||||
run(false, 'withargs', 'a.js', '"hello world"')
|
||||
run(true, 'withargs', 'a.js', '"hello world"')
|
||||
run(false, 'withargs', 'a.js', "'hello world'")
|
||||
run(true, 'withargs', 'a.js', "'hello world'")
|
||||
$EXEC('rm shebang.js')
|
||||
})
|
||||
|
||||
|
190
nashorn/test/script/nosecurity/jjs-common.js
Normal file
190
nashorn/test/script/nosecurity/jjs-common.js
Normal file
@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* @subtest
|
||||
* @summary test used by all other jjs-option* test cases
|
||||
*/
|
||||
var javaHome = $ENV.JAVA_HOME,
|
||||
homeJjs = "${javaHome}/bin/jjs",
|
||||
altJjs = $EXEC('which jjs').trim(),
|
||||
homejavac = "${javaHome}/bin/javac",
|
||||
altjavac = $EXEC('which javac').trim()
|
||||
|
||||
var Files = Java.type('java.nio.file.Files'),
|
||||
Paths = Java.type('java.nio.file.Paths'),
|
||||
System = Java.type('java.lang.System')
|
||||
|
||||
// Initialize default values for variables used in different functions
|
||||
var func_cond_p = <<EOD
|
||||
$EXIT == 0
|
||||
EOD
|
||||
|
||||
var func_cond_n = <<EOD
|
||||
$EXIT != 0
|
||||
EOD
|
||||
|
||||
var flag_cond_p = <<EOD
|
||||
out == e_outp
|
||||
EOD
|
||||
|
||||
var flag_cond_n = <<EOD
|
||||
out == e_outn
|
||||
EOD
|
||||
|
||||
var e_outp = "true"
|
||||
var e_outn = "false"
|
||||
|
||||
// special cases in which arguments used for negative testing also
|
||||
var args_p = "-scripting"
|
||||
var args_n = "-scripting"
|
||||
|
||||
// create file to check -flag passing
|
||||
var path_f = Paths.get("temp-flag.js")
|
||||
var testflag_file = path_f.toAbsolutePath()
|
||||
|
||||
// create file to check -flag functionality
|
||||
var path_func = Paths.get("temp-func.js")
|
||||
var testfunc_file = path_func.toAbsolutePath()
|
||||
|
||||
|
||||
function exists(f) {
|
||||
return Files.exists(Paths.get(f))
|
||||
}
|
||||
|
||||
var jjs = exists(homeJjs) ? homeJjs : altJjs
|
||||
var javac = exists(homejavac) ? homejavac : altjavac
|
||||
|
||||
if (!exists(jjs)) {
|
||||
throw "no jjs executable found; tried ${homeJjs} and ${altJjs}"
|
||||
}
|
||||
|
||||
// write code to testflag_file
|
||||
function write_testflag_file() {
|
||||
Files.write(testflag_file, msg_flag.getBytes())
|
||||
}
|
||||
|
||||
// write code to testfunc_file
|
||||
function write_testfunc_file() {
|
||||
Files.write(testfunc_file, msg_func.getBytes())
|
||||
}
|
||||
|
||||
function flag_test_pass() {
|
||||
print("flag test PASSED")
|
||||
}
|
||||
|
||||
function flag_test_fail(e_out, out) {
|
||||
print("flag test FAILED expected out:${e_out} found:${out}")
|
||||
}
|
||||
|
||||
// check functionality of flag,cover both positive and negative cases
|
||||
function testjjs_opt_func(args, positive) {
|
||||
$EXEC("${jjs} ${args}")
|
||||
var out = $OUT.trim(),
|
||||
err = $ERR.trim()
|
||||
if (positive) {
|
||||
if (eval(func_cond_p))
|
||||
print("functionality test PASSED")
|
||||
else
|
||||
print("functionality test FAILED. stdout: ${out} -- stderr: ${err}")
|
||||
}
|
||||
else {
|
||||
if (eval(func_cond_n))
|
||||
print("functionality test PASSED")
|
||||
else
|
||||
print("functionality test FAILED. stdout: ${out} -- stderr: ${err}")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// check if corresponding $OPTIONS._XXX is set for given flag
|
||||
function testjjs_opt(args, type, func) {
|
||||
$EXEC("${jjs} ${args}")
|
||||
var out = $OUT.trim(),
|
||||
err = $ERR.trim()
|
||||
if (type) {
|
||||
if (eval(flag_cond_p)) {
|
||||
flag_test_pass()
|
||||
if (func)
|
||||
testjjs_opt_func(arg_p, type)
|
||||
}
|
||||
else {
|
||||
flag_test_fail(e_outp, out)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (eval(flag_cond_n)) {
|
||||
flag_test_pass()
|
||||
if (func)
|
||||
testjjs_opt_func(arg_n, type)
|
||||
}
|
||||
else {
|
||||
flag_test_fail(e_outn, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Main entry point to test both flag and its functionality
|
||||
function testjjs_flag_and_func(flag, param) {
|
||||
try {
|
||||
var args = "${flag}" + "${param}"
|
||||
write_testflag_file()
|
||||
write_testfunc_file()
|
||||
print("${flag} flag positive test:")
|
||||
testjjs_opt("${args_p} ${args} ${testflag_file}", true, true) // positive test
|
||||
print("${flag} flag negative test:")
|
||||
testjjs_opt("${args_n} ${testflag_file}", false, true) // negative test
|
||||
} finally {
|
||||
$EXEC("rm ${testflag_file}")
|
||||
$EXEC("rm ${testfunc_file}")
|
||||
}
|
||||
}
|
||||
|
||||
// Main entry point to check only functionality of given -flag
|
||||
function testjjs_functionality(flag, param) {
|
||||
try {
|
||||
var args = "${flag}" + "${param}"
|
||||
write_testfunc_file()
|
||||
print("${flag} flag positive test:")
|
||||
testjjs_opt_func("${args_p} ${args} ${testfunc_file}", true) // positive test
|
||||
print("${flag} flag negative test:")
|
||||
testjjs_opt_func("${args_n} ${testfunc_file}", false) // negative test
|
||||
} finally {
|
||||
$EXEC("rm ${testfunc_file}")
|
||||
}
|
||||
}
|
||||
|
||||
// Main entry point to check only -flag settings for given flag
|
||||
function testjjs_flag(flag, param) {
|
||||
try {
|
||||
var args = "${flag}" + "${param}"
|
||||
write_testflag_file()
|
||||
print("${flag} flag positive test:")
|
||||
testjjs_opt("${args_p} ${args} ${testflag_file}", true, false) // positive test
|
||||
print("${flag} flag negative test:")
|
||||
testjjs_opt("${args_n} ${testflag_file}", false, false) // negative test
|
||||
} finally {
|
||||
$EXEC("rm ${testflag_file}")
|
||||
}
|
||||
}
|
61
nashorn/test/script/nosecurity/jjs-option-cp.js
Normal file
61
nashorn/test/script/nosecurity/jjs-option-cp.js
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* @test
|
||||
* @option -scripting
|
||||
* @runif os.not.windows
|
||||
* @run
|
||||
* @summary Test to check if -cp flag and its basic functionality
|
||||
*/
|
||||
|
||||
load(__DIR__ + "jjs-common.js")
|
||||
|
||||
var hello = __DIR__ + "Hello.class";
|
||||
var helloj = __DIR__ + "Hello.java";
|
||||
|
||||
// code to check -flag
|
||||
var msg_flag = "print($OPTIONS._classpath)"
|
||||
|
||||
// code to check basic functionality
|
||||
var msg_func = <<EOD
|
||||
$EXEC("rm -f ${hello}")
|
||||
$EXEC("${javac} ${helloj}")
|
||||
var v = new Packages.Hello();
|
||||
if (v.string != 'hello') {
|
||||
throw new Error("Unexpected property value");
|
||||
}
|
||||
EOD
|
||||
|
||||
// flag test expected output variables
|
||||
var e_outp = "__DIR__"
|
||||
var e_outn = "null"
|
||||
|
||||
// functionality test arguments
|
||||
var arg_p = "-scripting -cp ${__DIR__} ${testfunc_file}"
|
||||
var arg_n = "-scripting ${testfunc_file}"
|
||||
|
||||
// Testing starts here
|
||||
testjjs_flag_and_func("-cp", " __DIR__")
|
||||
$EXEC("rm -f ${hello}")
|
6
nashorn/test/script/nosecurity/jjs-option-cp.js.EXPECTED
Normal file
6
nashorn/test/script/nosecurity/jjs-option-cp.js.EXPECTED
Normal file
@ -0,0 +1,6 @@
|
||||
-cp flag positive test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
||||
-cp flag negative test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
50
nashorn/test/script/nosecurity/jjs-option-define.js
Normal file
50
nashorn/test/script/nosecurity/jjs-option-define.js
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* @test
|
||||
* @option -scripting
|
||||
* @runif os.not.windows
|
||||
* @run
|
||||
* @summary Test to check -D flag basic functionality
|
||||
*/
|
||||
|
||||
load(__DIR__ + "jjs-common.js")
|
||||
|
||||
var path_func = Paths.get("temp-property-func.js")
|
||||
var testfunc_file = path_func.toAbsolutePath()
|
||||
|
||||
// code to check basic functionality
|
||||
var msg_func = <<EOD
|
||||
try {
|
||||
var System = Java.type('java.lang.System');
|
||||
print(System.getProperty('user.name'))
|
||||
if (System.getProperty('user.name') != "nashorn9")
|
||||
throw new Error("un expected system property user.name value")
|
||||
} finally {
|
||||
}
|
||||
EOD
|
||||
|
||||
// Testing starts here
|
||||
testjjs_functionality("-D", "user.name=nashorn9")
|
@ -0,0 +1,4 @@
|
||||
-D flag positive test:
|
||||
functionality test PASSED
|
||||
-D flag negative test:
|
||||
functionality test PASSED
|
61
nashorn/test/script/nosecurity/jjs-option-doe.js
Normal file
61
nashorn/test/script/nosecurity/jjs-option-doe.js
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* @test
|
||||
* @option -scripting
|
||||
* @runif os.not.windows
|
||||
* @run
|
||||
* @summary Test -doe flag and its basic functionality
|
||||
*/
|
||||
|
||||
load(__DIR__ + "jjs-common.js")
|
||||
|
||||
// code to check -flag
|
||||
var msg_flag = "print($OPTIONS._dump_on_error)"
|
||||
|
||||
// code to check basic functionality
|
||||
var msg_func = <<EOD
|
||||
print("Hello Nashorn)
|
||||
EOD
|
||||
|
||||
// flag test expected output variables
|
||||
var e_outp = "true"
|
||||
var e_outn = "false"
|
||||
|
||||
// functionality test arguments
|
||||
var arg_p = "-scripting -doe ${testfunc_file}"
|
||||
var arg_n = "-scripting ${testfunc_file}"
|
||||
|
||||
// functionality condition checks used.
|
||||
var func_cond_p = <<'EOD'
|
||||
err.indexOf("internal") > -1
|
||||
EOD
|
||||
|
||||
var func_cond_n = <<'EOD'
|
||||
err.indexOf("internal") <= -1
|
||||
EOD
|
||||
|
||||
// one particular test starts here
|
||||
testjjs_flag_and_func("-doe", "")
|
@ -0,0 +1,6 @@
|
||||
-doe flag positive test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
||||
-doe flag negative test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
60
nashorn/test/script/nosecurity/jjs-option-fv.js
Normal file
60
nashorn/test/script/nosecurity/jjs-option-fv.js
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* @test
|
||||
* @option -scripting
|
||||
* @runif os.not.windows
|
||||
* @run
|
||||
* @summary Test if -fv flag its basic funnctionality
|
||||
*/
|
||||
|
||||
load(__DIR__ + "jjs-common.js")
|
||||
|
||||
// code to check -flag
|
||||
var msg_flag = "print($OPTIONS._fullversion)"
|
||||
|
||||
// code to check basic functionality
|
||||
var msg_func = <<EOD
|
||||
var x = "Hello Nashorn"
|
||||
EOD
|
||||
|
||||
// flag test expected output variables
|
||||
var e_outp = "true"
|
||||
var e_outn = "false"
|
||||
|
||||
// functionality test arguments
|
||||
var arg_p = "-scripting -fv ${testfunc_file}"
|
||||
var arg_n = "-scripting ${testfunc_file}"
|
||||
|
||||
var func_cond_p = <<'EOD'
|
||||
err.indexOf("full") > -1
|
||||
EOD
|
||||
|
||||
var func_cond_n = <<'EOD'
|
||||
err.indexOf("full") <= -1
|
||||
EOD
|
||||
|
||||
// one particular test starts here
|
||||
testjjs_flag_and_func("-fv", "")
|
6
nashorn/test/script/nosecurity/jjs-option-fv.js.EXPECTED
Normal file
6
nashorn/test/script/nosecurity/jjs-option-fv.js.EXPECTED
Normal file
@ -0,0 +1,6 @@
|
||||
-fv flag positive test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
||||
-fv flag negative test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
49
nashorn/test/script/nosecurity/jjs-option-fx.js
Normal file
49
nashorn/test/script/nosecurity/jjs-option-fx.js
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* check -fx option.
|
||||
* @test
|
||||
* @option -scripting
|
||||
* @runif os.not.windows
|
||||
* @run
|
||||
* @summary Test -fx flag and its basic functionality
|
||||
* the JavaFX primary stage is available to Nashorn as a global property $STAGE with -fx
|
||||
* used this to check with and without -fx
|
||||
*/
|
||||
|
||||
load(__DIR__ + "jjs-common.js")
|
||||
|
||||
var msg_flag = "print(typeof($STAGE));";
|
||||
|
||||
// flag test expected output variables
|
||||
var e_outn = "undefined"
|
||||
|
||||
// positive flag test condition expression string other than the default
|
||||
var flag_cond_p = <<'EOD'
|
||||
out != "undefined"
|
||||
EOD
|
||||
|
||||
// Testing starts here
|
||||
testjjs_flag("-fx","")
|
4
nashorn/test/script/nosecurity/jjs-option-fx.js.EXPECTED
Normal file
4
nashorn/test/script/nosecurity/jjs-option-fx.js.EXPECTED
Normal file
@ -0,0 +1,4 @@
|
||||
-fx flag positive test:
|
||||
flag test PASSED
|
||||
-fx flag negative test:
|
||||
flag test PASSED
|
60
nashorn/test/script/nosecurity/jjs-option-lang.js
Normal file
60
nashorn/test/script/nosecurity/jjs-option-lang.js
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* @test
|
||||
* @option -scripting
|
||||
* @runif os.not.windows
|
||||
* @run
|
||||
* @summary Test -lang flag and its basic functionality
|
||||
*/
|
||||
|
||||
load(__DIR__ + "jjs-common.js")
|
||||
|
||||
// code to check -flag
|
||||
var msg_flag = "print($OPTIONS._es6)"
|
||||
|
||||
// code to check basic functionality
|
||||
var msg_func = <<EOD
|
||||
const X = 4
|
||||
try {
|
||||
X = 55
|
||||
throw new Error("should have thrown TypeError")
|
||||
} catch (e) {
|
||||
if (!(e instanceof TypeError)) {
|
||||
throw new Error("TypeError expected, got " + e)
|
||||
}
|
||||
}
|
||||
EOD
|
||||
|
||||
// flag test expected output variables
|
||||
var e_outp = "true"
|
||||
var e_outn = "false"
|
||||
|
||||
// functionality test arguments
|
||||
var arg_p = "-scripting --language=es6 ${testfunc_file}"
|
||||
var arg_n = "-scripting ${testfunc_file}"
|
||||
|
||||
// Testing starts here
|
||||
testjjs_flag_and_func("--language", "=es6")
|
@ -0,0 +1,6 @@
|
||||
--language flag positive test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
||||
--language flag negative test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
43
nashorn/test/script/nosecurity/jjs-option-ot.js
Normal file
43
nashorn/test/script/nosecurity/jjs-option-ot.js
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* @test
|
||||
* @option -scripting
|
||||
* @runif os.not.windows
|
||||
* @run
|
||||
* @summary Test -ot flag
|
||||
*/
|
||||
|
||||
load(__DIR__ + "jjs-common.js")
|
||||
|
||||
var args_n = "-scripting -ot=false"
|
||||
var msg_flag = "print($OPTIONS._optimistic_types);";
|
||||
|
||||
// flag test expected output variables
|
||||
var e_outp = "true"
|
||||
var e_outn = "false"
|
||||
|
||||
// Testing starts here
|
||||
testjjs_flag("-ot","")
|
4
nashorn/test/script/nosecurity/jjs-option-ot.js.EXPECTED
Normal file
4
nashorn/test/script/nosecurity/jjs-option-ot.js.EXPECTED
Normal file
@ -0,0 +1,4 @@
|
||||
-ot flag positive test:
|
||||
flag test PASSED
|
||||
-ot flag negative test:
|
||||
flag test PASSED
|
60
nashorn/test/script/nosecurity/jjs-option-scripting.js
Normal file
60
nashorn/test/script/nosecurity/jjs-option-scripting.js
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* @test
|
||||
* @option -scripting
|
||||
* @runif os.not.windows
|
||||
* @run
|
||||
* @summary Test -scripting flag and its basic functionality
|
||||
*/
|
||||
|
||||
load(__DIR__ + "jjs-common.js")
|
||||
|
||||
// code to check -flag
|
||||
var msg_flag = "print($OPTIONS._scripting)"
|
||||
|
||||
// code to check basic functionality
|
||||
var msg_func = <<'EOD'
|
||||
var x = "Nashorn"
|
||||
var hello = "Hello ${x}"
|
||||
if (hello != "Hello Nashorn") {
|
||||
throw new Error("string interploation not working");
|
||||
}
|
||||
EOD
|
||||
|
||||
// flag test expected output variables
|
||||
var e_outn = 'ReferenceErrorr: "$OPTIONS" is not defined'
|
||||
// negative flag test condition
|
||||
var flag_cond_n = 'err.indexOf("$OPTIONS") > -1'
|
||||
|
||||
// functionality test arguments
|
||||
var arg_p = "-scripting ${testfunc_file}"
|
||||
var arg_n = "${testfunc_file}"
|
||||
|
||||
var args_p = "",
|
||||
args_n = ""
|
||||
|
||||
// Testing starts here
|
||||
testjjs_flag_and_func("-scripting", "")
|
@ -0,0 +1,6 @@
|
||||
-scripting flag positive test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
||||
-scripting flag negative test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
55
nashorn/test/script/nosecurity/jjs-option-strict.js
Normal file
55
nashorn/test/script/nosecurity/jjs-option-strict.js
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* @test
|
||||
* @option -scripting
|
||||
* @runif os.not.windows
|
||||
* @run
|
||||
* @summary Test -strict flag and its basic functionality
|
||||
*/
|
||||
|
||||
load(__DIR__ + "jjs-common.js")
|
||||
|
||||
// code to check -flag
|
||||
var msg_flag = "print($OPTIONS._strict)"
|
||||
|
||||
// code to check basic functionality
|
||||
var msg_func = <<EOD
|
||||
try {
|
||||
v = "nashorn"
|
||||
throw new Error("should have thrown reference error")
|
||||
} catch (e) {
|
||||
if (!(e instanceof ReferenceError)) {
|
||||
throw new Error("ReferenceError expected, got " + e)
|
||||
}
|
||||
}
|
||||
EOD
|
||||
|
||||
// functionality test arguments
|
||||
var arg_p = "-scripting -strict ${testfunc_file}"
|
||||
var arg_n = "-scripting ${testfunc_file}"
|
||||
|
||||
// Testing starts here
|
||||
testjjs_flag_and_func("-strict","")
|
@ -0,0 +1,6 @@
|
||||
-strict flag positive test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
||||
-strict flag negative test:
|
||||
flag test PASSED
|
||||
functionality test PASSED
|
50
nashorn/test/script/nosecurity/jjs-option-version.js
Normal file
50
nashorn/test/script/nosecurity/jjs-option-version.js
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8144113: Nashorn: enable jjs testing.
|
||||
* check if jjs version is same as of java.
|
||||
* @test
|
||||
* @option -scripting
|
||||
* @runif os.not.windows
|
||||
* @run
|
||||
* @summary Test -version flag and its functionality
|
||||
*/
|
||||
|
||||
|
||||
load(__DIR__ + "jjs-common.js")
|
||||
|
||||
var javaVersion = System.getProperty('java.version')
|
||||
|
||||
// code to check -flag
|
||||
var msg_flag = 'var x = "Hello Nashorn"'
|
||||
|
||||
// flag test expected output variables
|
||||
var e_outp = "nashorn ${javaVersion}"
|
||||
var e_outn = "Hello Nashorn"
|
||||
|
||||
// not sure why version info is found in error stream not in out stream.??
|
||||
flag_cond_p = "err.indexOf(e_outp)> -1"
|
||||
flag_cond_n = "err.indexOf(e_outp)<= -1"
|
||||
|
||||
testjjs_flag("-version","")
|
@ -0,0 +1,4 @@
|
||||
-version flag positive test:
|
||||
flag test PASSED
|
||||
-version flag negative test:
|
||||
flag test PASSED
|
Loading…
Reference in New Issue
Block a user