--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java Thu Jul 09 16:38:22 2015 -0700
@@ -39,7 +39,7 @@
*/
public final class MemberInfo implements Cloneable {
// class loader of this class
- private static ClassLoader myLoader = MemberInfo.class.getClassLoader();
+ private static final ClassLoader MY_LOADER = MemberInfo.class.getClassLoader();
/**
* The different kinds of available class annotations
@@ -493,7 +493,7 @@
if (type.getSort() == Type.OBJECT) {
try {
- final Class<?> clazz = Class.forName(type.getClassName(), false, myLoader);
+ final Class<?> clazz = Class.forName(type.getClassName(), false, MY_LOADER);
return ScriptObject.class.isAssignableFrom(clazz);
} catch (final ClassNotFoundException cnfe) {
return false;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/BeanLinker.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/BeanLinker.java Thu Jul 09 16:38:22 2015 -0700
@@ -156,14 +156,14 @@
return null;
}
- private static MethodHandle GET_LIST_ELEMENT = Lookup.PUBLIC.findVirtual(List.class, "get",
+ private static final MethodHandle GET_LIST_ELEMENT = Lookup.PUBLIC.findVirtual(List.class, "get",
MethodType.methodType(Object.class, int.class));
- private static MethodHandle GET_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "get",
+ private static final MethodHandle GET_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "get",
MethodType.methodType(Object.class, Object.class));
- private static MethodHandle LIST_GUARD = Guards.getInstanceOfGuard(List.class);
- private static MethodHandle MAP_GUARD = Guards.getInstanceOfGuard(Map.class);
+ private static final MethodHandle LIST_GUARD = Guards.getInstanceOfGuard(List.class);
+ private static final MethodHandle MAP_GUARD = Guards.getInstanceOfGuard(Map.class);
private enum CollectionType {
ARRAY, LIST, MAP
@@ -287,7 +287,7 @@
if(intIndex != doubleValue && !Double.isInfinite(doubleValue)) { // let infinites trigger IOOBE
return null; // not an exact integer
}
- return Integer.valueOf(intIndex);
+ return intIndex;
} catch(Exception|Error e) {
throw e;
} catch(final Throwable t) {
@@ -343,9 +343,9 @@
}
}
- private static MethodHandle RANGE_CHECK_ARRAY = findRangeCheck(Object.class);
- private static MethodHandle RANGE_CHECK_LIST = findRangeCheck(List.class);
- private static MethodHandle CONTAINS_MAP = Lookup.PUBLIC.findVirtual(Map.class, "containsKey",
+ private static final MethodHandle RANGE_CHECK_ARRAY = findRangeCheck(Object.class);
+ private static final MethodHandle RANGE_CHECK_LIST = findRangeCheck(List.class);
+ private static final MethodHandle CONTAINS_MAP = Lookup.PUBLIC.findVirtual(Map.class, "containsKey",
MethodType.methodType(boolean.class, Object.class));
private static MethodHandle findRangeCheck(final Class<?> collectionType) {
@@ -353,7 +353,7 @@
}
@SuppressWarnings("unused")
- private static final boolean rangeCheck(final Object array, final Object index) {
+ private static boolean rangeCheck(final Object array, final Object index) {
if(!(index instanceof Number)) {
return false;
}
@@ -370,7 +370,7 @@
}
@SuppressWarnings("unused")
- private static final boolean rangeCheck(final List<?> list, final Object index) {
+ private static boolean rangeCheck(final List<?> list, final Object index) {
if(!(index instanceof Number)) {
return false;
}
@@ -386,10 +386,10 @@
throw new IndexOutOfBoundsException("Index: " + n + ", Size: " + list.size());
}
- private static MethodHandle SET_LIST_ELEMENT = Lookup.PUBLIC.findVirtual(List.class, "set",
+ private static final MethodHandle SET_LIST_ELEMENT = Lookup.PUBLIC.findVirtual(List.class, "set",
MethodType.methodType(Object.class, int.class, Object.class));
- private static MethodHandle PUT_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "put",
+ private static final MethodHandle PUT_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "put",
MethodType.methodType(Object.class, Object.class, Object.class));
private GuardedInvocationComponent getElementSetter(final CallSiteDescriptor callSiteDescriptor,
@@ -471,16 +471,16 @@
gic.getValidatorClass(), gic.getValidationType());
}
- private static MethodHandle GET_ARRAY_LENGTH = Lookup.PUBLIC.findStatic(Array.class, "getLength",
+ private static final MethodHandle GET_ARRAY_LENGTH = Lookup.PUBLIC.findStatic(Array.class, "getLength",
MethodType.methodType(int.class, Object.class));
- private static MethodHandle GET_COLLECTION_LENGTH = Lookup.PUBLIC.findVirtual(Collection.class, "size",
+ private static final MethodHandle GET_COLLECTION_LENGTH = Lookup.PUBLIC.findVirtual(Collection.class, "size",
MethodType.methodType(int.class));
- private static MethodHandle GET_MAP_LENGTH = Lookup.PUBLIC.findVirtual(Map.class, "size",
+ private static final MethodHandle GET_MAP_LENGTH = Lookup.PUBLIC.findVirtual(Map.class, "size",
MethodType.methodType(int.class));
- private static MethodHandle COLLECTION_GUARD = Guards.getInstanceOfGuard(Collection.class);
+ private static final MethodHandle COLLECTION_GUARD = Guards.getInstanceOfGuard(Collection.class);
private GuardedInvocationComponent getLengthGetter(final CallSiteDescriptor callSiteDescriptor) {
assertParameterCount(callSiteDescriptor, 1);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/NameCodec.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/NameCodec.java Thu Jul 09 16:38:22 2015 -0700
@@ -164,7 +164,7 @@
}
}
if(b == null) {
- return name.toString();
+ return name;
}
assert lastEscape != -1;
b.append(name, lastEscape + 1, l);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/TypeConverterFactory.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/TypeConverterFactory.java Thu Jul 09 16:38:22 2015 -0700
@@ -166,7 +166,7 @@
}
};
- private static final ClassLoader getClassLoader(final Class<?> clazz) {
+ private static ClassLoader getClassLoader(final Class<?> clazz) {
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
@@ -298,7 +298,7 @@
* @return true if there can be a conversion, false if there can not.
*/
public boolean canConvert(final Class<?> from, final Class<?> to) {
- return canAutoConvert(from, to) || canConvert.get(from).get(to).booleanValue();
+ return canAutoConvert(from, to) || canConvert.get(from).get(to);
}
/**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/Formatter.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/Formatter.java Thu Jul 09 16:38:22 2015 -0700
@@ -170,7 +170,7 @@
* @return true if '<' is in the string, else false
*/
private static boolean isPreviousArgument(final String s) {
- return (s != null && s.indexOf('<') >= 0) ? true : false;
+ return (s != null && s.indexOf('<') >= 0);
}
// %[argument_index$][flags][width][.precision][t]conversion
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ClassEmitter.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ClassEmitter.java Thu Jul 09 16:38:22 2015 -0700
@@ -705,7 +705,7 @@
/** private access */
PRIVATE(ACC_PRIVATE);
- private int value;
+ private final int value;
private Flag(final int value) {
this.value = value;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java Thu Jul 09 16:38:22 2015 -0700
@@ -213,7 +213,7 @@
private static final Type ITERATOR_TYPE = Type.typeFor(ITERATOR_CLASS);
private static final Type EXCEPTION_TYPE = Type.typeFor(CompilerConstants.EXCEPTION_PREFIX.type());
- private static final Integer INT_ZERO = Integer.valueOf(0);
+ private static final Integer INT_ZERO = 0;
/** Constant data & installation. The only reason the compiler keeps this is because it is assigned
* by reflection in class installation */
@@ -742,7 +742,7 @@
method.convert(Type.NUMBER);
}
- private static final Type undefinedToNumber(final Type type) {
+ private static Type undefinedToNumber(final Type type) {
return type == Type.UNDEFINED ? Type.NUMBER : type;
}
@@ -4877,7 +4877,7 @@
if(propertyValue instanceof String || propertyValue == null) {
method.load((String)propertyValue);
} else if(propertyValue instanceof Integer) {
- method.load(((Integer)propertyValue).intValue());
+ method.load(((Integer)propertyValue));
method.convert(Type.OBJECT);
} else {
throw new AssertionError();
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CompileUnit.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CompileUnit.java Thu Jul 09 16:38:22 2015 -0700
@@ -56,7 +56,7 @@
private transient Class<?> clazz;
- private transient Map<FunctionNode, RecompilableScriptFunctionData> functions = new IdentityHashMap<>();
+ private final transient Map<FunctionNode, RecompilableScriptFunctionData> functions = new IdentityHashMap<>();
private transient boolean isUsed;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Compiler.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Compiler.java Thu Jul 09 16:38:22 2015 -0700
@@ -437,7 +437,7 @@
baseName = baseName.replace('.', '_').replace('-', '_');
if (!env._loader_per_compile) {
- baseName = baseName + installer.getUniqueScriptId();
+ baseName += installer.getUniqueScriptId();
}
// ASM's bytecode verifier does not allow JVM allowed safe escapes using '\' as escape char.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ConstantData.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ConstantData.java Thu Jul 09 16:38:22 2015 -0700
@@ -162,7 +162,7 @@
final Integer value = stringMap.get(string);
if (value != null) {
- return value.intValue();
+ return value;
}
constants.add(string);
@@ -191,7 +191,7 @@
final Integer value = objectMap.get(entry);
if (value != null) {
- return value.intValue();
+ return value;
}
constants.add(object);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/DumpBytecode.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/DumpBytecode.java Thu Jul 09 16:38:22 2015 -0700
@@ -51,7 +51,7 @@
if (env._print_code) {
final StringBuilder sb = new StringBuilder();
- sb.append("class: " + className).
+ sb.append("class: ").append(className).
append('\n').
append(ClassEmitter.disassemble(bytecode)).
append("=====");
@@ -88,7 +88,7 @@
}
- // should code be dumped to disk - only valid in compile_only mode?
+ // should code be dumped to disk
if (env._dest_dir != null) {
final String fileName = className.replace('.', File.separatorChar) + ".class";
final int index = fileName.lastIndexOf(File.separatorChar);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FindScopeDepths.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FindScopeDepths.java Thu Jul 09 16:38:22 2015 -0700
@@ -121,11 +121,9 @@
private static boolean definedInBlock(final Block block, final Symbol symbol) {
if (symbol.isGlobal()) {
- if (block.isGlobalScope()) {
- return true;
- }
//globals cannot be defined anywhere else
- return false;
+
+ return block.isGlobalScope();
}
return block.getExistingSymbol(symbol.getName()) == symbol;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java Thu Jul 09 16:38:22 2015 -0700
@@ -272,12 +272,12 @@
}
private static class SymbolConversions {
- private static byte I2L = 1 << 0;
- private static byte I2D = 1 << 1;
- private static byte I2O = 1 << 2;
- private static byte L2D = 1 << 3;
- private static byte L2O = 1 << 4;
- private static byte D2O = 1 << 5;
+ private static final byte I2L = 1 << 0;
+ private static final byte I2D = 1 << 1;
+ private static final byte I2O = 1 << 2;
+ private static final byte L2D = 1 << 3;
+ private static final byte L2O = 1 << 4;
+ private static final byte D2O = 1 << 5;
private byte conversions;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java Thu Jul 09 16:38:22 2015 -0700
@@ -101,7 +101,7 @@
// Conservative pattern to test if element names consist of characters valid for identifiers.
// This matches any non-zero length alphanumeric string including _ and $ and not starting with a digit.
- private static Pattern SAFE_PROPERTY_NAME = Pattern.compile("[a-zA-Z_$][\\w$]*");
+ private static final Pattern SAFE_PROPERTY_NAME = Pattern.compile("[a-zA-Z_$][\\w$]*");
/**
* Constructor.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Thu Jul 09 16:38:22 2015 -0700
@@ -69,7 +69,6 @@
import jdk.nashorn.internal.runtime.logging.DebugLogger;
import jdk.nashorn.internal.runtime.logging.Loggable;
import jdk.nashorn.internal.runtime.logging.Logger;
-import jdk.nashorn.internal.runtime.options.Options;
/**
* Generates the ScriptObject subclass structure with fields for a user objects.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/IntType.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/IntType.java Thu Jul 09 16:38:22 2015 -0700
@@ -89,7 +89,7 @@
public Type ldc(final MethodVisitor method, final Object c) {
assert c instanceof Integer;
- final int value = ((Integer) c).intValue();
+ final int value = ((Integer) c);
switch (value) {
case -1:
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/NashornClassReader.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/NashornClassReader.java Thu Jul 09 16:38:22 2015 -0700
@@ -88,7 +88,7 @@
c = bytecode[i++];
switch (st) {
case 0:
- c = c & 0xFF;
+ c &= 0xFF;
if (c < 0x80) { // 0xxxxxxx
buf[strLen++] = (char) c;
} else if (c < 0xE0 && c > 0xBF) { // 110x xxxx 10xx xxxx
@@ -457,7 +457,7 @@
@SuppressWarnings("unused")
final String getType() {
- String str = type[tag];
+ String str = TYPE[tag];
while (str.length() < 16) {
str += " ";
}
@@ -507,7 +507,7 @@
}
}
- private static String type[] = {
+ private static final String[] TYPE = {
//0
"<error>",
//1
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/NashornTextifier.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/NashornTextifier.java Thu Jul 09 16:38:22 2015 -0700
@@ -535,7 +535,7 @@
addText(sb);
}
- private static final boolean noFallThru(final int opcode) {
+ private static boolean noFallThru(final int opcode) {
switch (opcode) {
case Opcodes.GOTO:
case Opcodes.ATHROW:
@@ -901,7 +901,7 @@
appendDescriptor(sb, INTERNAL_NAME, desc);
}
} else if (o[i] instanceof Integer) {
- switch (((Integer)o[i]).intValue()) {
+ switch (((Integer)o[i])) {
case 0:
appendDescriptor(sb, FIELD_DESCRIPTOR, "T");
break;
@@ -1090,7 +1090,7 @@
public String toString() {
final StringBuilder sb = new StringBuilder();
- sb.append("digraph " + dottyFriendly(name) + " {");
+ sb.append("digraph ").append(dottyFriendly(name)).append(" {");
sb.append("\n");
sb.append("\tgraph [fontname=courier]\n");
sb.append("\tnode [style=filled,color="+COLOR_DEFAULT+",fontname=courier]\n");
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java Thu Jul 09 16:38:22 2015 -0700
@@ -450,7 +450,7 @@
for (final Object mp : memoryPoolMXBeans) {
final Object usage = getUsage.invoke(mp);
final Object max = getMax.invoke(usage);
- maxMemory += ((Long)max).longValue();
+ maxMemory += ((Long)max);
}
} catch (IllegalAccessException |
IllegalArgumentException |
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Thu Jul 09 16:38:22 2015 -0700
@@ -88,14 +88,14 @@
*/
@ScriptClass("Global")
public final class Global extends Scope {
- // Placeholder value used in place of a location property (__FILE__, __DIR__, __LINE__)
- private static final Object LOCATION_PROPERTY_PLACEHOLDER = new Object();
+ // This special value is used to flag a lazily initialized global property.
+ // This also serves as placeholder value used in place of a location property
+ // (__FILE__, __DIR__, __LINE__)
+ private static final Object LAZY_SENTINEL = new Object();
+
private final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class);
private final InvokeByName VALUE_OF = new InvokeByName("valueOf", ScriptObject.class);
- // placeholder value for lazily initialized global objects
- private static final Object LAZY_SENTINEL = new Object();
-
/**
* Optimistic builtin names that require switchpoint invalidation
* upon assignment. Overly conservative, but works for now, to avoid
@@ -182,15 +182,15 @@
/** Value property NaN of the Global Object - ECMA 15.1.1.1 NaN */
@Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT)
- public final double NaN = Double.NaN;
+ public static final double NaN = Double.NaN;
/** Value property Infinity of the Global Object - ECMA 15.1.1.2 Infinity */
@Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT)
- public final double Infinity = Double.POSITIVE_INFINITY;
+ public static final double Infinity = Double.POSITIVE_INFINITY;
/** Value property Undefined of the Global Object - ECMA 15.1.1.3 Undefined */
@Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT)
- public final Object undefined = UNDEFINED;
+ public static final Object undefined = UNDEFINED;
/** ECMA 15.1.2.1 eval(x) */
@Property(attributes = Attribute.NOT_ENUMERABLE)
@@ -830,15 +830,15 @@
/** Nashorn extension: current script's file name */
@Property(name = "__FILE__", attributes = Attribute.NON_ENUMERABLE_CONSTANT)
- public final Object __FILE__ = LOCATION_PROPERTY_PLACEHOLDER;
+ public static final Object __FILE__ = LAZY_SENTINEL;
/** Nashorn extension: current script's directory */
@Property(name = "__DIR__", attributes = Attribute.NON_ENUMERABLE_CONSTANT)
- public final Object __DIR__ = LOCATION_PROPERTY_PLACEHOLDER;
+ public static final Object __DIR__ = LAZY_SENTINEL;
/** Nashorn extension: current source line number being executed */
@Property(name = "__LINE__", attributes = Attribute.NON_ENUMERABLE_CONSTANT)
- public final Object __LINE__ = LOCATION_PROPERTY_PLACEHOLDER;
+ public static final Object __LINE__ = LAZY_SENTINEL;
private volatile NativeDate DEFAULT_DATE;
@@ -1768,38 +1768,10 @@
return ScriptFunction.getPrototype(getBuiltinFloat64Array());
}
- private ScriptFunction getBuiltinArray() {
- return builtinArray;
- }
-
ScriptFunction getTypeErrorThrower() {
return typeErrorThrower;
}
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin array has not been overridden
- */
- public static boolean isBuiltinArray() {
- final Global instance = Global.instance();
- return instance.array == instance.getBuiltinArray();
- }
-
- private ScriptFunction getBuiltinBoolean() {
- return builtinBoolean;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin boolean has not been overridden
- */
- public static boolean isBuiltinBoolean() {
- final Global instance = Global.instance();
- return instance._boolean == instance.getBuiltinBoolean();
- }
-
private synchronized ScriptFunction getBuiltinDate() {
if (this.builtinDate == null) {
this.builtinDate = initConstructorAndSwitchPoint("Date", ScriptFunction.class);
@@ -1810,30 +1782,6 @@
return this.builtinDate;
}
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin date has not been overridden
- */
- public static boolean isBuiltinDate() {
- final Global instance = Global.instance();
- return instance.date == LAZY_SENTINEL || instance.date == instance.getBuiltinDate();
- }
-
- private ScriptFunction getBuiltinError() {
- return builtinError;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin error has not been overridden
- */
- public static boolean isBuiltinError() {
- final Global instance = Global.instance();
- return instance.error == instance.getBuiltinError();
- }
-
private synchronized ScriptFunction getBuiltinEvalError() {
if (this.builtinEvalError == null) {
this.builtinEvalError = initErrorSubtype("EvalError", getErrorPrototype());
@@ -1841,31 +1789,11 @@
return this.builtinEvalError;
}
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin eval error has not been overridden
- */
- public static boolean isBuiltinEvalError() {
- final Global instance = Global.instance();
- return instance.evalError == LAZY_SENTINEL || instance.evalError == instance.getBuiltinEvalError();
- }
-
private ScriptFunction getBuiltinFunction() {
return builtinFunction;
}
/**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin function has not been overridden
- */
- public static boolean isBuiltinFunction() {
- final Global instance = Global.instance();
- return instance.function == instance.getBuiltinFunction();
- }
-
- /**
* Get the switchpoint used to check property changes for Function.prototype.apply
* @return the switchpoint guarding apply (same as guarding call, and everything else in function)
*/
@@ -1906,16 +1834,6 @@
return builtinJSAdapter;
}
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin JSAdapter has not been overridden
- */
- public static boolean isBuiltinJSAdapter() {
- final Global instance = Global.instance();
- return instance.jsadapter == LAZY_SENTINEL || instance.jsadapter == instance.getBuiltinJSAdapter();
- }
-
private synchronized ScriptObject getBuiltinJSON() {
if (this.builtinJSON == null) {
this.builtinJSON = initConstructorAndSwitchPoint("JSON", ScriptObject.class);
@@ -1923,44 +1841,6 @@
return this.builtinJSON;
}
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin JSON has has not been overridden
- */
- public static boolean isBuiltinJSON() {
- final Global instance = Global.instance();
- return instance.json == LAZY_SENTINEL || instance.json == instance.getBuiltinJSON();
- }
-
- private ScriptObject getBuiltinJava() {
- return builtinJava;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin Java has not been overridden
- */
- public static boolean isBuiltinJava() {
- final Global instance = Global.instance();
- return instance.java == instance.getBuiltinJava();
- }
-
- private ScriptObject getBuiltinJavax() {
- return builtinJavax;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin Javax has not been overridden
- */
- public static boolean isBuiltinJavax() {
- final Global instance = Global.instance();
- return instance.javax == instance.getBuiltinJavax();
- }
-
private synchronized ScriptFunction getBuiltinJavaImporter() {
if (this.builtinJavaImporter == null) {
this.builtinJavaImporter = initConstructor("JavaImporter", ScriptFunction.class);
@@ -1975,68 +1855,6 @@
return this.builtinJavaApi;
}
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin Java importer has not been overridden
- */
- public static boolean isBuiltinJavaImporter() {
- final Global instance = Global.instance();
- return instance.javaImporter == LAZY_SENTINEL || instance.javaImporter == instance.getBuiltinJavaImporter();
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin math has not been overridden
- */
- public static boolean isBuiltinMath() {
- final Global instance = Global.instance();
- return instance.math == instance.builtinMath;
- }
-
- private ScriptFunction getBuiltinNumber() {
- return builtinNumber;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin number has not been overridden
- */
- public static boolean isBuiltinNumber() {
- final Global instance = Global.instance();
- return instance.number == instance.getBuiltinNumber();
- }
-
- private ScriptFunction getBuiltinObject() {
- return builtinObject;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin object has not been overridden
- */
- public static boolean isBuiltinObject() {
- final Global instance = Global.instance();
- return instance.object == instance.getBuiltinObject();
- }
-
- private ScriptObject getBuiltinPackages() {
- return builtinPackages;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin package has not been overridden
- */
- public static boolean isBuiltinPackages() {
- final Global instance = Global.instance();
- return instance.packages == instance.getBuiltinPackages();
- }
-
private synchronized ScriptFunction getBuiltinRangeError() {
if (this.builtinRangeError == null) {
this.builtinRangeError = initErrorSubtype("RangeError", getErrorPrototype());
@@ -2044,30 +1862,6 @@
return builtinRangeError;
}
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin range error has not been overridden
- */
- public static boolean isBuiltinRangeError() {
- final Global instance = Global.instance();
- return instance.rangeError == LAZY_SENTINEL || instance.rangeError == instance.getBuiltinRangeError();
- }
-
- private synchronized ScriptFunction getBuiltinReferenceError() {
- return builtinReferenceError;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin reference error has not been overridden
- */
- public static boolean isBuiltinReferenceError() {
- final Global instance = Global.instance();
- return instance.referenceError == instance.getBuiltinReferenceError();
- }
-
private synchronized ScriptFunction getBuiltinRegExp() {
if (this.builtinRegExp == null) {
this.builtinRegExp = initConstructorAndSwitchPoint("RegExp", ScriptFunction.class);
@@ -2081,58 +1875,6 @@
return builtinRegExp;
}
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin regexp has not been overridden
- */
- public static boolean isBuiltinRegExp() {
- final Global instance = Global.instance();
- return instance.regexp == LAZY_SENTINEL || instance.regexp == instance.getBuiltinRegExp();
- }
-
- private ScriptFunction getBuiltinString() {
- return builtinString;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin Java has not been overridden
- */
- public static boolean isBuiltinString() {
- final Global instance = Global.instance();
- return instance.string == instance.getBuiltinString();
- }
-
- private ScriptFunction getBuiltinSyntaxError() {
- return builtinSyntaxError;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin syntax error has not been overridden
- */
- public static boolean isBuiltinSyntaxError() {
- final Global instance = Global.instance();
- return instance.syntaxError == instance.getBuiltinSyntaxError();
- }
-
- private ScriptFunction getBuiltinTypeError() {
- return builtinTypeError;
- }
-
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin type error has not been overridden
- */
- public static boolean isBuiltinTypeError() {
- final Global instance = Global.instance();
- return instance.typeError == instance.getBuiltinTypeError();
- }
-
private synchronized ScriptFunction getBuiltinURIError() {
if (this.builtinURIError == null) {
this.builtinURIError = initErrorSubtype("URIError", getErrorPrototype());
@@ -2140,16 +1882,6 @@
return this.builtinURIError;
}
- /**
- * Called from compiled script code to test if builtin has been overridden
- *
- * @return true if builtin URI error has not been overridden
- */
- public static boolean isBuiltinURIError() {
- final Global instance = Global.instance();
- return instance.uriError == LAZY_SENTINEL || instance.uriError == instance.getBuiltinURIError();
- }
-
@Override
public String getClassName() {
return "global";
@@ -2288,7 +2020,7 @@
* @return true if the value is a placeholder, false otherwise.
*/
public static boolean isLocationPropertyPlaceholder(final Object placeholder) {
- return placeholder == LOCATION_PROPERTY_PLACEHOLDER;
+ return placeholder == LAZY_SENTINEL;
}
/**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java Thu Jul 09 16:38:22 2015 -0700
@@ -1874,7 +1874,7 @@
//TODO - fold these into the Link logics, but I'll do that as a later step, as I want to do a checkin
//where everything works first
- private static final <T> ContinuousArrayData getContinuousNonEmptyArrayDataCCE(final Object self, final Class<T> clazz) {
+ private static <T> ContinuousArrayData getContinuousNonEmptyArrayDataCCE(final Object self, final Class<T> clazz) {
try {
@SuppressWarnings("unchecked")
final ContinuousArrayData data = (ContinuousArrayData)(T)((NativeArray)self).getArray();
@@ -1887,7 +1887,7 @@
throw new ClassCastException();
}
- private static final ContinuousArrayData getContinuousArrayDataCCE(final Object self) {
+ private static ContinuousArrayData getContinuousArrayDataCCE(final Object self) {
try {
return (ContinuousArrayData)((NativeArray)self).getArray();
} catch (final NullPointerException e) {
@@ -1895,7 +1895,7 @@
}
}
- private static final ContinuousArrayData getContinuousArrayDataCCE(final Object self, final Class<?> elementType) {
+ private static ContinuousArrayData getContinuousArrayDataCCE(final Object self, final Class<?> elementType) {
try {
return (ContinuousArrayData)((NativeArray)self).getArray(elementType); //ensure element type can fit "elementType"
} catch (final NullPointerException e) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDate.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDate.java Thu Jul 09 16:38:22 2015 -0700
@@ -218,7 +218,7 @@
@Override
public String toString() {
- return isValidDate() ? toString(this).toString() : INVALID_DATE;
+ return isValidDate() ? toString(this) : INVALID_DATE;
}
/**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeRegExp.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeRegExp.java Thu Jul 09 16:38:22 2015 -0700
@@ -803,7 +803,7 @@
private static final Object REPLACE_VALUE = new Object();
- private static final MethodHandle getReplaceValueInvoker() {
+ private static MethodHandle getReplaceValueInvoker() {
return Global.instance().getDynamicInvoker(REPLACE_VALUE,
new Callable<MethodHandle>() {
@Override
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java Thu Jul 09 16:38:22 2015 -0700
@@ -1044,9 +1044,9 @@
try {
final long value = Long.parseLong(valueString, radix);
if(value >= MIN_INT_L && value <= MAX_INT_L) {
- return Integer.valueOf((int)value);
+ return (int)value;
}
- return Long.valueOf(value);
+ return value;
} catch (final NumberFormatException e) {
if (radix == 10) {
return Double.valueOf(valueString);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CompiledFunction.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CompiledFunction.java Thu Jul 09 16:38:22 2015 -0700
@@ -907,7 +907,7 @@
OptimismInfo(final RecompilableScriptFunctionData data, final Map<Integer, Type> invalidatedProgramPoints) {
this.data = data;
this.log = data.getLogger();
- this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new TreeMap<Integer, Type>() : invalidatedProgramPoints;
+ this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new TreeMap<>() : invalidatedProgramPoints;
newOptimisticAssumptions();
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java Thu Jul 09 16:38:22 2015 -0700
@@ -994,7 +994,7 @@
* @return a long
*/
public static long toLong(final Object obj) {
- return obj instanceof Long ? ((Long)obj).longValue() : toLong(toNumber(obj));
+ return obj instanceof Long ? ((Long)obj) : toLong(toNumber(obj));
}
/**
@@ -1056,7 +1056,7 @@
*/
public static int toInt32Optimistic(final Object obj, final int programPoint) {
if (obj != null && obj.getClass() == Integer.class) {
- return ((Integer)obj).intValue();
+ return ((Integer)obj);
}
throw new UnwarrantedOptimismException(obj, programPoint);
}
@@ -1954,11 +1954,11 @@
public static MethodHandle unboxConstant(final Object o) {
if (o != null) {
if (o.getClass() == Integer.class) {
- return MH.constant(int.class, ((Integer)o).intValue());
+ return MH.constant(int.class, ((Integer)o));
} else if (o.getClass() == Long.class) {
- return MH.constant(long.class, ((Long)o).longValue());
+ return MH.constant(long.class, ((Long)o));
} else if (o.getClass() == Double.class) {
- return MH.constant(double.class, ((Double)o).doubleValue());
+ return MH.constant(double.class, ((Double)o));
}
}
return MH.constant(Object.class, o);
@@ -1983,7 +1983,7 @@
}
}
- private static final List<MethodHandle> toUnmodifiableList(final MethodHandle... methodHandles) {
+ private static List<MethodHandle> toUnmodifiableList(final MethodHandle... methodHandles) {
return Collections.unmodifiableList(Arrays.asList(methodHandles));
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java Thu Jul 09 16:38:22 2015 -0700
@@ -156,7 +156,7 @@
}
// If the file does not exist, then assume that it's a directory
if (!file.isFile()) {
- name = name + "/";
+ name += "/";
}
try {
return new URL("file", "", name);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/OptimisticReturnFilters.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/OptimisticReturnFilters.java Thu Jul 09 16:38:22 2015 -0700
@@ -260,7 +260,7 @@
final Class<?> c = arg.getClass();
if (c == Long.class) {
// Must check for Long separately, as Long.doubleValue() isn't precise.
- return ((Long)arg).longValue();
+ return ((Long)arg);
} else if (c == Integer.class || c == Double.class || c == Float.class || c == Short.class ||
c == Byte.class) {
return ensureLong(((Number)arg).doubleValue(), programPoint);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java Thu Jul 09 16:38:22 2015 -0700
@@ -562,8 +562,8 @@
@Override
public int hashCode() {
- final Class<?> type = getLocalType();
- return Objects.hashCode(this.key) ^ flags ^ getSlot() ^ (type == null ? 0 : type.hashCode());
+ final Class<?> t = getLocalType();
+ return Objects.hashCode(this.key) ^ flags ^ getSlot() ^ (t == null ? 0 : t.hashCode());
}
@Override
@@ -588,7 +588,7 @@
getKey().equals(otherProperty.getKey());
}
- private static final String type(final Class<?> type) {
+ private static String type(final Class<?> type) {
if (type == null) {
return "undef";
} else if (type == int.class) {
@@ -608,8 +608,8 @@
*/
public final String toStringShort() {
final StringBuilder sb = new StringBuilder();
- final Class<?> type = getLocalType();
- sb.append(getKey()).append(" (").append(type(type)).append(')');
+ final Class<?> t = getLocalType();
+ sb.append(getKey()).append(" (").append(type(t)).append(')');
return sb.toString();
}
@@ -625,7 +625,7 @@
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
- final Class<?> type = getLocalType();
+ final Class<?> t = getLocalType();
sb.append(indent(getKey(), 20)).
append(" id=").
@@ -635,7 +635,7 @@
append(") ").
append(getClass().getSimpleName()).
append(" {").
- append(indent(type(type), 5)).
+ append(indent(type(t), 5)).
append('}');
if (slot != -1) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java Thu Jul 09 16:38:22 2015 -0700
@@ -999,10 +999,10 @@
for (final Property p : map0.getProperties()) {
final Property p2 = map1.findProperty(p.getKey());
if (p2 == null) {
- sb.append("FIRST ONLY : [" + p + "]");
+ sb.append("FIRST ONLY : [").append(p).append("]");
found = true;
} else if (p2 != p) {
- sb.append("DIFFERENT : [" + p + "] != [" + p2 + "]");
+ sb.append("DIFFERENT : [").append(p).append("] != [").append(p2).append("]");
found = true;
}
}
@@ -1010,7 +1010,7 @@
for (final Property p2 : map1.getProperties()) {
final Property p1 = map0.findProperty(p2.getKey());
if (p1 == null) {
- sb.append("SECOND ONLY: [" + p2 + "]");
+ sb.append("SECOND ONLY: [").append(p2).append("]");
found = true;
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/RewriteException.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/RewriteException.java Thu Jul 09 16:38:22 2015 -0700
@@ -359,9 +359,9 @@
if (returnValue instanceof String) {
str = '\'' + str + '\'';
} else if (returnValue instanceof Double) {
- str = str + 'd';
+ str += 'd';
} else if (returnValue instanceof Long) {
- str = str + 'l';
+ str += 'l';
}
return str;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java Thu Jul 09 16:38:22 2015 -0700
@@ -611,7 +611,7 @@
obj = ((ScriptObject)obj).get(property);
if(Global.isLocationPropertyPlaceholder(obj)) {
if(CompilerConstants.__LINE__.name().equals(property)) {
- obj = Integer.valueOf(0);
+ obj = 0;
} else {
obj = "";
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Source.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Source.java Thu Jul 09 16:38:22 2015 -0700
@@ -995,7 +995,7 @@
return initLogger(Context.getContextTrusted());
}
- private File dumpFile(final String dir) {
+ private File dumpFile(final File dirFile) {
final URL u = getURL();
final StringBuilder buf = new StringBuilder();
// make it unique by prefixing current date & time
@@ -1010,11 +1010,17 @@
buf.append(getName());
}
- return new File(dir, buf.toString());
+ return new File(dirFile, buf.toString());
}
void dump(final String dir) {
- final File file = dumpFile(dir);
+ final File dirFile = new File(dir);
+ final File file = dumpFile(dirFile);
+ if (!dirFile.exists() && !dirFile.mkdirs()) {
+ debug("Skipping source dump for " + name);
+ return;
+ }
+
try (final FileOutputStream fos = new FileOutputStream(file)) {
final PrintWriter pw = new PrintWriter(fos);
pw.print(data.toString());
@@ -1025,7 +1031,7 @@
": " +
ECMAErrors.getMessage(
"io.error.cant.write",
- dir.toString() +
+ dir +
" : " + ioExp.toString()));
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java Thu Jul 09 16:38:22 2015 -0700
@@ -215,11 +215,8 @@
int.class);
@SuppressWarnings("unused")
- private static final boolean guard(final Class<? extends ContinuousArrayData> clazz, final ScriptObject sobj) {
- if (sobj != null && sobj.getArray().getClass() == clazz) {
- return true;
- }
- return false;
+ private static boolean guard(final Class<? extends ContinuousArrayData> clazz, final ScriptObject sobj) {
+ return sobj != null && sobj.getArray().getClass() == clazz;
}
/**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/IntArrayData.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/IntArrayData.java Thu Jul 09 16:38:22 2015 -0700
@@ -138,7 +138,7 @@
final Object[] oarray = new Object[trim ? len : array.length];
for (int index = 0; index < len; index++) {
- oarray[index] = Integer.valueOf(array[index]);
+ oarray[index] = array[index];
}
return oarray;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Thu Jul 09 16:38:22 2015 -0700
@@ -91,7 +91,7 @@
final Object[] oarray = new Object[trim ? len : array.length];
for (int index = 0; index < len; index++) {
- oarray[index] = Long.valueOf(array[index]);
+ oarray[index] = array[index];
}
return oarray;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java Thu Jul 09 16:38:22 2015 -0700
@@ -91,7 +91,7 @@
final Object[] oarray = new Object[trim ? len : array.length];
for (int index = 0; index < len; index++) {
- oarray[index] = Double.valueOf(array[index]);
+ oarray[index] = array[index];
}
return oarray;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java Thu Jul 09 16:38:22 2015 -0700
@@ -95,11 +95,11 @@
final TreeMap<Long, Object> newSparseMap = new TreeMap<>();
for (final Map.Entry<Long, Object> entry : sparseMap.entrySet()) {
- final long newIndex = entry.getKey().longValue() - by;
+ final long newIndex = entry.getKey() - by;
if (newIndex < maxDenseLength) {
underlying = underlying.set((int) newIndex, entry.getValue(), false);
} else if (newIndex >= 0) {
- newSparseMap.put(Long.valueOf(newIndex), entry.getValue());
+ newSparseMap.put(newIndex, entry.getValue());
}
}
@@ -114,7 +114,7 @@
if (len + by > maxDenseLength) {
for (long i = maxDenseLength - by; i < len; i++) {
if (underlying.has((int) i)) {
- newSparseMap.put(Long.valueOf(i + by), underlying.getObject((int) i));
+ newSparseMap.put(i + by, underlying.getObject((int) i));
}
}
underlying = underlying.shrink((int) (maxDenseLength - by));
@@ -123,8 +123,8 @@
underlying.shiftRight(by);
for (final Map.Entry<Long, Object> entry : sparseMap.entrySet()) {
- final long newIndex = entry.getKey().longValue() + by;
- newSparseMap.put(Long.valueOf(newIndex), entry.getValue());
+ final long newIndex = entry.getKey() + by;
+ newSparseMap.put(newIndex, entry.getValue());
}
sparseMap = newSparseMap;
@@ -158,7 +158,7 @@
setLength(newLength);
}
- sparseMap.subMap(Long.valueOf(newLength), Long.MAX_VALUE).clear();
+ sparseMap.subMap(newLength, Long.MAX_VALUE).clear();
setLength(newLength);
return this;
}
@@ -333,7 +333,7 @@
}
private static Long indexToKey(final int index) {
- return Long.valueOf(ArrayIndex.toLongIndex(index));
+ return ArrayIndex.toLongIndex(index);
}
@Override
@@ -355,7 +355,7 @@
return result;
}
setLength(len - 1);
- final Long key = Long.valueOf(len - 1);
+ final Long key = len - 1;
return sparseMap.containsKey(key) ? sparseMap.remove(key) : ScriptRuntime.UNDEFINED;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Thu Jul 09 16:38:22 2015 -0700
@@ -47,7 +47,6 @@
import jdk.internal.dynalink.support.TypeUtilities;
import jdk.nashorn.api.scripting.JSObject;
import jdk.nashorn.internal.codegen.CompilerConstants.Call;
-import jdk.nashorn.internal.codegen.ObjectClassGenerator;
import jdk.nashorn.internal.lookup.MethodHandleFactory;
import jdk.nashorn.internal.lookup.MethodHandleFunctionality;
import jdk.nashorn.internal.objects.ScriptFunctionImpl;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaArgumentConverters.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaArgumentConverters.java Thu Jul 09 16:38:22 2015 -0700
@@ -107,7 +107,7 @@
if (o instanceof Number) {
final int ival = ((Number)o).intValue();
if (ival >= Character.MIN_VALUE && ival <= Character.MAX_VALUE) {
- return Character.valueOf((char) ival);
+ return (char) ival;
}
throw typeError("cant.convert.number.to.char");
@@ -196,13 +196,13 @@
return ((Integer)obj).longValue();
} else if (obj instanceof Double) {
final Double d = (Double)obj;
- if(Double.isInfinite(d.doubleValue())) {
+ if(Double.isInfinite(d)) {
return 0L;
}
return d.longValue();
} else if (obj instanceof Float) {
final Float f = (Float)obj;
- if(Float.isInfinite(f.floatValue())) {
+ if(Float.isInfinite(f)) {
return 0L;
}
return f.longValue();
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java Thu Jul 09 16:38:22 2015 -0700
@@ -101,9 +101,7 @@
}
public void copy(final BitSet other) {
- for (int i=0; i<BITSET_SIZE; i++) {
- bits[i] = other.bits[i];
- }
+ System.arraycopy(other.bits, 0, bits, 0, BITSET_SIZE);
}
public int numOn() {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/Region.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/Region.java Thu Jul 09 16:38:22 2015 -0700
@@ -38,7 +38,7 @@
final StringBuilder sb = new StringBuilder();
sb.append("Region: \n");
for (int i=0; i<beg.length; i++) {
- sb.append(" " + i + ": (" + beg[i] + "-" + end[i] + ")");
+ sb.append(" ").append(i).append(": (").append(beg[i]).append("-").append(end[i]).append(")");
}
return sb.toString();
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/AnchorNode.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/AnchorNode.java Thu Jul 09 16:38:22 2015 -0700
@@ -60,8 +60,8 @@
@Override
public String toString(final int level) {
final StringBuilder value = new StringBuilder();
- value.append("\n type: " + typeToString());
- value.append("\n target: " + pad(target, level + 1));
+ value.append("\n type: ").append(typeToString());
+ value.append("\n target: ").append(pad(target, level + 1));
return value.toString();
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/CClassNode.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/CClassNode.java Thu Jul 09 16:38:22 2015 -0700
@@ -124,9 +124,9 @@
@Override
public String toString(final int level) {
final StringBuilder value = new StringBuilder();
- value.append("\n flags: " + flagsToString());
- value.append("\n bs: " + pad(bs, level + 1));
- value.append("\n mbuf: " + pad(mbuf, level + 1));
+ value.append("\n flags: ").append(flagsToString());
+ value.append("\n bs: ").append(pad(bs, level + 1));
+ value.append("\n mbuf: ").append(pad(mbuf, level + 1));
return value.toString();
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/ConsAltNode.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/ConsAltNode.java Thu Jul 09 16:38:22 2015 -0700
@@ -148,8 +148,8 @@
@Override
public String toString(final int level) {
final StringBuilder value = new StringBuilder();
- value.append("\n car: " + pad(car, level + 1));
- value.append("\n cdr: " + (cdr == null ? "NULL" : cdr.toString()));
+ value.append("\n car: ").append(pad(car, level + 1));
+ value.append("\n cdr: ").append(cdr == null ? "NULL" : cdr.toString());
return value.toString();
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java Thu Jul 09 16:38:22 2015 -0700
@@ -80,15 +80,15 @@
@Override
public String toString(final int level) {
final StringBuilder value = new StringBuilder(super.toString(level));
- value.append("\n type: " + typeToString());
- value.append("\n regNum: " + regNum);
- value.append("\n option: " + Option.toString(option));
- value.append("\n target: " + pad(target, level + 1));
- value.append("\n callAddr: " + callAddr);
- value.append("\n minLength: " + minLength);
- value.append("\n maxLength: " + maxLength);
- value.append("\n charLength: " + charLength);
- value.append("\n optCount: " + optCount);
+ value.append("\n type: ").append(typeToString());
+ value.append("\n regNum: ").append(regNum);
+ value.append("\n option: ").append(Option.toString(option));
+ value.append("\n target: ").append(pad(target, level + 1));
+ value.append("\n callAddr: ").append(callAddr);
+ value.append("\n minLength: ").append(minLength);
+ value.append("\n maxLength: ").append(maxLength);
+ value.append("\n charLength: ").append(charLength);
+ value.append("\n optCount: ").append(optCount);
return value.toString();
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/Node.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/Node.java Thu Jul 09 16:38:22 2015 -0700
@@ -85,7 +85,7 @@
@Override
public final String toString() {
final StringBuilder s = new StringBuilder();
- s.append("<" + getAddressName() + " (" + (parent == null ? "NULL" : parent.getAddressName()) + ")>");
+ s.append("<").append(getAddressName()).append(" (").append(parent == null ? "NULL" : parent.getAddressName()).append(")>");
return s + toString(0);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java Thu Jul 09 16:38:22 2015 -0700
@@ -118,14 +118,14 @@
@Override
public String toString(final int level) {
final StringBuilder value = new StringBuilder(super.toString(level));
- value.append("\n target: " + pad(target, level + 1));
- value.append("\n lower: " + lower);
- value.append("\n upper: " + upper);
- value.append("\n greedy: " + greedy);
- value.append("\n targetEmptyInfo: " + targetEmptyInfo);
- value.append("\n headExact: " + pad(headExact, level + 1));
- value.append("\n nextHeadExact: " + pad(nextHeadExact, level + 1));
- value.append("\n isRefered: " + isRefered);
+ value.append("\n target: ").append(pad(target, level + 1));
+ value.append("\n lower: ").append(lower);
+ value.append("\n upper: ").append(upper);
+ value.append("\n greedy: ").append(greedy);
+ value.append("\n targetEmptyInfo: ").append(targetEmptyInfo);
+ value.append("\n headExact: ").append(pad(headExact, level + 1));
+ value.append("\n nextHeadExact: ").append(pad(nextHeadExact, level + 1));
+ value.append("\n isRefered: ").append(isRefered);
return value.toString();
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/StringNode.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/StringNode.java Thu Jul 09 16:38:22 2015 -0700
@@ -71,7 +71,7 @@
final char[] tmp = new char[len + NODE_STR_MARGIN];
System.arraycopy(chars, p, tmp, 0, end - p);
chars = tmp;
- end = end - p;
+ end -= p;
p = 0;
clearShared();
} else {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/Shell.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/Shell.java Thu Jul 09 16:38:22 2015 -0700
@@ -54,7 +54,6 @@
import jdk.nashorn.internal.runtime.ScriptEnvironment;
import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptRuntime;
-import jdk.nashorn.internal.runtime.Source;
import jdk.nashorn.internal.runtime.options.Options;
/**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/ShellFunctions.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/ShellFunctions.java Thu Jul 09 16:38:22 2015 -0700
@@ -29,10 +29,8 @@
import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
import java.io.BufferedReader;
-import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import jdk.nashorn.internal.runtime.JSType;
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/test/SharedObject.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/SharedObject.java Thu Jul 09 16:38:22 2015 -0700
@@ -176,7 +176,7 @@
}
public Boolean booleanBoxingMethod(final Boolean arg) {
- return !arg.booleanValue();
+ return !arg;
}
public boolean[] booleanArrayMethod(final boolean arg[]) {
--- a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java Thu Jul 09 16:38:22 2015 -0700
@@ -573,7 +573,7 @@
}
// properties that can be read by any code
- private static String[] propNames = {
+ private static final String[] PROP_NAMES = {
"java.version",
"java.vendor",
"java.vendor.url",
@@ -601,7 +601,7 @@
final ScriptEngineManager m = new ScriptEngineManager();
final ScriptEngine e = m.getEngineByName("nashorn");
- for (final String name : propNames) {
+ for (final String name : PROP_NAMES) {
checkProperty(e, name);
}
}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java Thu Jul 09 16:38:22 2015 -0700
@@ -278,7 +278,7 @@
ScriptObjectMirror obj = (ScriptObjectMirror)e.eval(
"({ valueOf: function() { return 42 } })");
- assertEquals(Double.valueOf(42.0), obj.to(Double.class));
+ assertEquals(42.0, obj.to(Double.class));
obj = (ScriptObjectMirror)e.eval(
"({ toString: function() { return 'foo' } })");
--- a/nashorn/test/src/jdk/nashorn/api/tree/test/ParseAPITest.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/test/src/jdk/nashorn/api/tree/test/ParseAPITest.java Thu Jul 09 16:38:22 2015 -0700
@@ -67,7 +67,7 @@
parseTestSet(TEST262_SUITE_DIR, new TestFilter() {
@Override
public boolean exclude(final File file, final String content) {
- return content.indexOf("@negative") != -1;
+ return content.contains("@negative");
}
});
}
--- a/nashorn/test/src/jdk/nashorn/internal/performance/OctaneTest.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/test/src/jdk/nashorn/internal/performance/OctaneTest.java Thu Jul 09 16:38:22 2015 -0700
@@ -272,10 +272,10 @@
Double nashornToRhino = null;
Double nashornToV8 = null;
if (rhino != null && rhino != 0) {
- nashornToRhino = nashorn.doubleValue() / rhino.doubleValue();
+ nashornToRhino = nashorn / rhino;
}
if (v8 != null && rhino != 0) {
- nashornToV8 = nashorn.doubleValue() / v8.doubleValue();
+ nashornToV8 = nashorn / v8;
}
final String normalizedBenchmark=benchmark.replace("-", "");
System.out.println("benchmark-" + normalizedBenchmark + "-nashorn=" + nashorn);
@@ -300,20 +300,12 @@
boolean checkRhinoPresence() {
final String rhinojar = System.getProperty("rhino.jar");
- if (rhinojar != null) {
- // System.out.println("Rhino jar found; performing comparison testing");
- return true;
- }
- return false;
+ return rhinojar != null;
}
boolean checkV8Presence() {
final String v8shell = System.getProperty("v8.shell.full.path");
- if (v8shell != null) {
- // System.out.println("d8 found; performing comparison testing");
- return true;
- }
- return false;
+ return v8shell != null;
}
}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/test/ExceptionsNotSerializable.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ExceptionsNotSerializable.java Thu Jul 09 16:38:22 2015 -0700
@@ -62,7 +62,7 @@
@Test
public void unwarrantedOptimismExceptionNotSerializable() {
- tryToSerialize(new UnwarrantedOptimismException(new Double(1.0), 128));
+ tryToSerialize(new UnwarrantedOptimismException(1.0, 128));
}
private static void tryToSerialize(final Object obj) {
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/AbstractScriptRunnable.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/AbstractScriptRunnable.java Thu Jul 09 16:38:22 2015 -0700
@@ -159,7 +159,7 @@
forkJVMOptions = (vmOptions != null)? vmOptions.split(" ") : new String[0];
}
- private static ThreadLocal<ScriptEvaluator> evaluators = new ThreadLocal<>();
+ private static final ThreadLocal<ScriptEvaluator> EVALUATORS = new ThreadLocal<>();
/**
* Create a script evaluator or return from cache
@@ -167,7 +167,7 @@
*/
protected ScriptEvaluator getEvaluator() {
synchronized (AbstractScriptRunnable.class) {
- ScriptEvaluator evaluator = evaluators.get();
+ ScriptEvaluator evaluator = EVALUATORS.get();
if (evaluator == null) {
if (sharedContext) {
final String[] args;
@@ -177,10 +177,10 @@
args = new String[] { framework };
}
evaluator = new SharedContextEvaluator(args);
- evaluators.set(evaluator);
+ EVALUATORS.set(evaluator);
} else {
evaluator = new SeparateContextEvaluator();
- evaluators.set(evaluator);
+ EVALUATORS.set(evaluator);
}
}
return evaluator;
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Thu Jul 09 16:38:22 2015 -0700
@@ -378,7 +378,7 @@
* @return true if optimistic type override has been set by test suite
*/
public static boolean hasOptimisticOverride() {
- return Boolean.valueOf(OPTIMISTIC_OVERRIDE).toString().equals(System.getProperty("optimistic.override"));
+ return Boolean.toString(OPTIMISTIC_OVERRIDE).equals(System.getProperty("optimistic.override"));
}
/**
@@ -391,8 +391,8 @@
public static String[] addExplicitOptimisticTypes(final String[] args) {
if (hasOptimisticOverride()) {
final List<String> newList = new ArrayList<>(Arrays.asList(args));
- newList.add("--optimistic-types=" + Boolean.valueOf(OPTIMISTIC_OVERRIDE));
- return newList.toArray(new String[0]);
+ newList.add("--optimistic-types=" + OPTIMISTIC_OVERRIDE);
+ return newList.toArray(new String[newList.size()]);
}
return args;
}
@@ -405,7 +405,7 @@
*/
public static void addExplicitOptimisticTypes(final List<String> args) {
if (hasOptimisticOverride()) {
- args.add("--optimistic-types=" + Boolean.valueOf(OPTIMISTIC_OVERRIDE));
+ args.add("--optimistic-types=" + OPTIMISTIC_OVERRIDE);
}
}
--- a/nashorn/test/src/jdk/nashorn/test/models/JDK_8081015_TestModel.java Thu Jul 09 13:49:41 2015 -0700
+++ b/nashorn/test/src/jdk/nashorn/test/models/JDK_8081015_TestModel.java Thu Jul 09 16:38:22 2015 -0700
@@ -64,9 +64,9 @@
private static void walkCollection(final Collection<Object> c) {
final Iterator<Object> it = c.iterator();
- assertEquals(it.next(), Integer.valueOf(1));
- assertEquals(it.next(), Integer.valueOf(2));
- assertEquals(it.next(), Double.valueOf(3.3));
+ assertEquals(it.next(), 1);
+ assertEquals(it.next(), 2);
+ assertEquals(it.next(), 3.3);
assertEquals(it.next(), "foo");
assertFalse(it.hasNext());
}