8130734: Apply transformations found by netbeans Refactor->Inspect and transform menu
Reviewed-by: hannesw, jlaskey, mhaupt
This commit is contained in:
parent
39ea286002
commit
4a2aab156b
@ -39,7 +39,7 @@ import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
*/
|
||||
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 @@ public final class MemberInfo implements Cloneable {
|
||||
|
||||
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;
|
||||
|
@ -156,14 +156,14 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
|
||||
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 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
|
||||
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 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
|
||||
}
|
||||
|
||||
@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 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
|
||||
}
|
||||
|
||||
@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 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
|
||||
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 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
|
||||
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);
|
||||
|
@ -164,7 +164,7 @@ public class NameCodec {
|
||||
}
|
||||
}
|
||||
if(b == null) {
|
||||
return name.toString();
|
||||
return name;
|
||||
}
|
||||
assert lastEscape != -1;
|
||||
b.append(name, lastEscape + 1, l);
|
||||
|
@ -166,7 +166,7 @@ public class TypeConverterFactory {
|
||||
}
|
||||
};
|
||||
|
||||
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 @@ public class TypeConverterFactory {
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,7 +170,7 @@ final class Formatter {
|
||||
* @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
|
||||
|
@ -705,7 +705,7 @@ public class ClassEmitter {
|
||||
/** private access */
|
||||
PRIVATE(ACC_PRIVATE);
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
private Flag(final int value) {
|
||||
this.value = value;
|
||||
|
@ -213,7 +213,7 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
|
||||
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 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
|
||||
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 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
|
||||
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();
|
||||
|
@ -56,7 +56,7 @@ public final class CompileUnit implements Comparable<CompileUnit>, Serializable
|
||||
|
||||
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;
|
||||
|
||||
|
@ -437,7 +437,7 @@ public final class Compiler implements Loggable {
|
||||
|
||||
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.
|
||||
|
@ -162,7 +162,7 @@ final class ConstantData {
|
||||
final Integer value = stringMap.get(string);
|
||||
|
||||
if (value != null) {
|
||||
return value.intValue();
|
||||
return value;
|
||||
}
|
||||
|
||||
constants.add(string);
|
||||
@ -191,7 +191,7 @@ final class ConstantData {
|
||||
final Integer value = objectMap.get(entry);
|
||||
|
||||
if (value != null) {
|
||||
return value.intValue();
|
||||
return value;
|
||||
}
|
||||
|
||||
constants.add(object);
|
||||
|
@ -51,7 +51,7 @@ public final class DumpBytecode {
|
||||
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("=====");
|
||||
|
@ -121,11 +121,9 @@ final class FindScopeDepths extends NodeVisitor<LexicalContext> implements Logga
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -272,12 +272,12 @@ final class LocalVariableTypesCalculator extends NodeVisitor<LexicalContext>{
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -101,7 +101,7 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Lo
|
||||
|
||||
// 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.
|
||||
|
@ -89,7 +89,7 @@ class IntType extends BitwiseType {
|
||||
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:
|
||||
|
@ -88,7 +88,7 @@ public class NashornClassReader extends ClassReader {
|
||||
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 @@ public class NashornClassReader extends ClassReader {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
final String getType() {
|
||||
String str = type[tag];
|
||||
String str = TYPE[tag];
|
||||
while (str.length() < 16) {
|
||||
str += " ";
|
||||
}
|
||||
@ -507,7 +507,7 @@ public class NashornClassReader extends ClassReader {
|
||||
}
|
||||
}
|
||||
|
||||
private static String type[] = {
|
||||
private static final String[] TYPE = {
|
||||
//0
|
||||
"<error>",
|
||||
//1
|
||||
|
@ -535,7 +535,7 @@ public final class NashornTextifier extends Printer {
|
||||
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 @@ public final class NashornTextifier extends Printer {
|
||||
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 final class NashornTextifier extends Printer {
|
||||
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");
|
||||
|
@ -450,7 +450,7 @@ public final class ObjectSizeCalculator {
|
||||
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 |
|
||||
|
@ -1874,7 +1874,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin
|
||||
//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 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin
|
||||
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 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -218,7 +218,7 @@ public final class NativeDate extends ScriptObject {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return isValidDate() ? toString(this).toString() : INVALID_DATE;
|
||||
return isValidDate() ? toString(this) : INVALID_DATE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -803,7 +803,7 @@ public final class NativeRegExp extends ScriptObject {
|
||||
|
||||
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
|
||||
|
@ -1044,9 +1044,9 @@ public class Lexer extends Scanner {
|
||||
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);
|
||||
|
@ -994,7 +994,7 @@ public enum JSType {
|
||||
* @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 enum JSType {
|
||||
*/
|
||||
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 enum JSType {
|
||||
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 @@ public enum JSType {
|
||||
}
|
||||
}
|
||||
|
||||
private static final List<MethodHandle> toUnmodifiableList(final MethodHandle... methodHandles) {
|
||||
private static List<MethodHandle> toUnmodifiableList(final MethodHandle... methodHandles) {
|
||||
return Collections.unmodifiableList(Arrays.asList(methodHandles));
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ abstract class NashornLoader extends SecureClassLoader {
|
||||
}
|
||||
// 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);
|
||||
|
@ -260,7 +260,7 @@ public final class OptimisticReturnFilters {
|
||||
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);
|
||||
|
@ -359,9 +359,9 @@ public final class RewriteException extends Exception {
|
||||
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;
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ public final class ScriptRuntime {
|
||||
obj = ((ScriptObject)obj).get(property);
|
||||
if(Global.isLocationPropertyPlaceholder(obj)) {
|
||||
if(CompilerConstants.__LINE__.name().equals(property)) {
|
||||
obj = Integer.valueOf(0);
|
||||
obj = 0;
|
||||
} else {
|
||||
obj = "";
|
||||
}
|
||||
|
@ -1031,7 +1031,7 @@ public final class Source implements Loggable {
|
||||
": " +
|
||||
ECMAErrors.getMessage(
|
||||
"io.error.cant.write",
|
||||
dir.toString() +
|
||||
dir +
|
||||
" : " + ioExp.toString()));
|
||||
}
|
||||
}
|
||||
|
@ -215,11 +215,8 @@ public abstract class ContinuousArrayData extends ArrayData {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,7 +138,7 @@ final class IntArrayData extends ContinuousArrayData implements IntElements {
|
||||
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;
|
||||
|
@ -91,7 +91,7 @@ final class LongArrayData extends ContinuousArrayData implements IntOrLongElemen
|
||||
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;
|
||||
|
@ -91,7 +91,7 @@ final class NumberArrayData extends ContinuousArrayData implements NumericElemen
|
||||
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;
|
||||
}
|
||||
|
@ -95,11 +95,11 @@ class SparseArrayData extends ArrayData {
|
||||
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 @@ class SparseArrayData extends ArrayData {
|
||||
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 @@ class SparseArrayData extends ArrayData {
|
||||
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 @@ class SparseArrayData extends ArrayData {
|
||||
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 @@ class SparseArrayData extends ArrayData {
|
||||
}
|
||||
|
||||
private static Long indexToKey(final int index) {
|
||||
return Long.valueOf(ArrayIndex.toLongIndex(index));
|
||||
return ArrayIndex.toLongIndex(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -355,7 +355,7 @@ class SparseArrayData extends ArrayData {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,6 @@ import jdk.internal.dynalink.linker.MethodTypeConversionStrategy;
|
||||
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;
|
||||
|
@ -107,7 +107,7 @@ final class JavaArgumentConverters {
|
||||
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 @@ final class JavaArgumentConverters {
|
||||
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();
|
||||
|
@ -101,9 +101,7 @@ public final class BitSet {
|
||||
}
|
||||
|
||||
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() {
|
||||
|
@ -38,7 +38,7 @@ public final class Region {
|
||||
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();
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ public final class AnchorNode extends Node implements AnchorType {
|
||||
@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();
|
||||
}
|
||||
|
||||
|
@ -124,9 +124,9 @@ public final class CClassNode extends Node {
|
||||
@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();
|
||||
}
|
||||
|
@ -148,8 +148,8 @@ public final class ConsAltNode extends Node {
|
||||
@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();
|
||||
}
|
||||
|
@ -80,15 +80,15 @@ public final class EncloseNode extends StateNode implements EncloseType {
|
||||
@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();
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public abstract class Node implements NodeType {
|
||||
@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);
|
||||
}
|
||||
|
||||
|
@ -118,14 +118,14 @@ public final class QuantifierNode extends StateNode {
|
||||
@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();
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public final class StringNode extends Node implements StringType {
|
||||
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 {
|
||||
|
@ -54,7 +54,6 @@ import jdk.nashorn.internal.runtime.Property;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -29,10 +29,8 @@ import static jdk.nashorn.internal.lookup.Lookup.MH;
|
||||
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;
|
||||
|
@ -176,7 +176,7 @@ public class SharedObject {
|
||||
}
|
||||
|
||||
public Boolean booleanBoxingMethod(final Boolean arg) {
|
||||
return !arg.booleanValue();
|
||||
return !arg;
|
||||
}
|
||||
|
||||
public boolean[] booleanArrayMethod(final boolean arg[]) {
|
||||
|
@ -573,7 +573,7 @@ public class ScriptEngineTest {
|
||||
}
|
||||
|
||||
// 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 @@ public class ScriptEngineTest {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ public class ScriptObjectMirrorTest {
|
||||
|
||||
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' } })");
|
||||
|
@ -67,7 +67,7 @@ public class ParseAPITest {
|
||||
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");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -272,10 +272,10 @@ public class OctaneTest {
|
||||
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 @@ public class OctaneTest {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class ExceptionsNotSerializable {
|
||||
|
||||
@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) {
|
||||
|
@ -159,7 +159,7 @@ public abstract class AbstractScriptRunnable {
|
||||
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 @@ public abstract class AbstractScriptRunnable {
|
||||
*/
|
||||
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 @@ public abstract class AbstractScriptRunnable {
|
||||
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;
|
||||
|
@ -378,7 +378,7 @@ public final class TestFinder {
|
||||
* @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 final class TestFinder {
|
||||
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 final class TestFinder {
|
||||
*/
|
||||
public static void addExplicitOptimisticTypes(final List<String> args) {
|
||||
if (hasOptimisticOverride()) {
|
||||
args.add("--optimistic-types=" + Boolean.valueOf(OPTIMISTIC_OVERRIDE));
|
||||
args.add("--optimistic-types=" + OPTIMISTIC_OVERRIDE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,9 +64,9 @@ public class JDK_8081015_TestModel {
|
||||
|
||||
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());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user