8055199: Tidy up Nashorn codebase for code standards (August 2014)
Reviewed-by: hannesw, lagergren
This commit is contained in:
parent
983051a456
commit
9227b18d8a
@ -40,7 +40,6 @@ import java.security.ProtectionDomain;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.script.AbstractScriptEngine;
|
||||
import javax.script.Bindings;
|
||||
import javax.script.Compilable;
|
||||
@ -51,7 +50,6 @@ import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineFactory;
|
||||
import javax.script.ScriptException;
|
||||
import javax.script.SimpleBindings;
|
||||
|
||||
import jdk.nashorn.internal.objects.Global;
|
||||
import jdk.nashorn.internal.runtime.Context;
|
||||
import jdk.nashorn.internal.runtime.ErrorManager;
|
||||
|
@ -56,7 +56,6 @@ import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALL
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_OPTIMISTIC;
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_PROGRAM_POINT_SHIFT;
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_SCOPE;
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_STRICT;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayDeque;
|
||||
|
@ -333,7 +333,7 @@ enum CompilationPhase {
|
||||
if (phases.isRestOfCompilation()) {
|
||||
sb.append("$restOf");
|
||||
}
|
||||
CompileUnit newUnit = compiler.createCompileUnit(sb.toString(), oldUnit.getWeight());
|
||||
final CompileUnit newUnit = compiler.createCompileUnit(sb.toString(), oldUnit.getWeight());
|
||||
log.fine("Creating new compile unit ", oldUnit, " => ", newUnit);
|
||||
map.put(oldUnit, newUnit);
|
||||
assert newUnit != null;
|
||||
|
@ -25,12 +25,8 @@
|
||||
|
||||
package jdk.nashorn.internal.codegen;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import jdk.nashorn.internal.ir.FunctionNode;
|
||||
import jdk.nashorn.internal.runtime.RecompilableScriptFunctionData;
|
||||
|
||||
/**
|
||||
* Used to track split class compilation.
|
||||
|
@ -34,7 +34,6 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import jdk.nashorn.internal.ir.BaseNode;
|
||||
import jdk.nashorn.internal.ir.BinaryNode;
|
||||
import jdk.nashorn.internal.ir.Block;
|
||||
|
@ -40,8 +40,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.runtime.Context;
|
||||
import jdk.nashorn.internal.runtime.RecompilableScriptFunctionData;
|
||||
|
@ -301,12 +301,12 @@ public abstract class Type implements Comparable<Type>, BytecodeOps {
|
||||
* @param output data output
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void writeTypeMap(Map<Integer, Type> typeMap, final DataOutput output) throws IOException {
|
||||
public static void writeTypeMap(final Map<Integer, Type> typeMap, final DataOutput output) throws IOException {
|
||||
if (typeMap == null) {
|
||||
output.writeInt(0);
|
||||
} else {
|
||||
output.writeInt(typeMap.size());
|
||||
for(Map.Entry<Integer, Type> e: typeMap.entrySet()) {
|
||||
for(final Map.Entry<Integer, Type> e: typeMap.entrySet()) {
|
||||
output.writeInt(e.getKey());
|
||||
final byte typeChar;
|
||||
final Type type = e.getValue();
|
||||
@ -331,7 +331,7 @@ public abstract class Type implements Comparable<Type>, BytecodeOps {
|
||||
* @return type map
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Map<Integer, Type> readTypeMap(DataInput input) throws IOException {
|
||||
public static Map<Integer, Type> readTypeMap(final DataInput input) throws IOException {
|
||||
final int size = input.readInt();
|
||||
if (size == 0) {
|
||||
return null;
|
||||
|
@ -30,7 +30,6 @@ import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.annotations.Ignore;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
|
@ -25,7 +25,12 @@
|
||||
|
||||
package jdk.nashorn.internal.ir;
|
||||
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.*;
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_PROFILE;
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_STRICT;
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_TRACE;
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_TRACE_ENTEREXIT;
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_TRACE_MISSES;
|
||||
import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_TRACE_VALUES;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
|
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import jdk.nashorn.internal.runtime.Debug;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
|
@ -29,7 +29,6 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import jdk.nashorn.internal.codegen.CompileUnit;
|
||||
import jdk.nashorn.internal.codegen.types.ArrayType;
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
|
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.parser.Token;
|
||||
import jdk.nashorn.internal.parser.TokenType;
|
||||
|
@ -39,7 +39,6 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import jdk.internal.org.objectweb.asm.Attribute;
|
||||
import jdk.internal.org.objectweb.asm.Handle;
|
||||
import jdk.internal.org.objectweb.asm.Label;
|
||||
|
@ -46,10 +46,8 @@ import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.script.ScriptContext;
|
||||
import javax.script.ScriptEngine;
|
||||
|
||||
import jdk.internal.dynalink.linker.GuardedInvocation;
|
||||
import jdk.internal.dynalink.linker.LinkRequest;
|
||||
import jdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||
|
@ -45,8 +45,8 @@ import jdk.nashorn.internal.runtime.Context;
|
||||
import jdk.nashorn.internal.runtime.JSType;
|
||||
import jdk.nashorn.internal.runtime.ListAdapter;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
import jdk.nashorn.internal.runtime.ScriptFunction;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
import jdk.nashorn.internal.runtime.ScriptRuntime;
|
||||
import jdk.nashorn.internal.runtime.linker.Bootstrap;
|
||||
import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory;
|
||||
|
@ -39,7 +39,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import jdk.internal.dynalink.beans.BeansLinker;
|
||||
import jdk.internal.dynalink.beans.StaticClass;
|
||||
import jdk.internal.dynalink.linker.GuardedInvocation;
|
||||
|
@ -25,11 +25,6 @@
|
||||
|
||||
package jdk.nashorn.internal.runtime;
|
||||
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.runtime.logging.DebugLogger;
|
||||
import jdk.nashorn.internal.runtime.logging.Loggable;
|
||||
import jdk.nashorn.internal.runtime.logging.Logger;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
@ -43,6 +38,10 @@ import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Map;
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.runtime.logging.DebugLogger;
|
||||
import jdk.nashorn.internal.runtime.logging.Loggable;
|
||||
import jdk.nashorn.internal.runtime.logging.Logger;
|
||||
|
||||
/**
|
||||
* A code cache for persistent caching of compiled scripts.
|
||||
@ -78,7 +77,7 @@ final class CodeStore implements Loggable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DebugLogger initLogger(Context context) {
|
||||
public DebugLogger initLogger(final Context context) {
|
||||
return context.getLogger(getClass());
|
||||
}
|
||||
|
||||
|
@ -532,7 +532,7 @@ final class CompiledFunction {
|
||||
// after we grabbed it here, in which case we'll indeed do one busy relink immediately.
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
// Intentionally ignored. There's nothing meaningful we can do if we're interrupted
|
||||
}
|
||||
} else {
|
||||
|
@ -91,14 +91,14 @@ public final class ConsString implements CharSequence {
|
||||
return new CharSequence[] { left, right };
|
||||
}
|
||||
|
||||
private CharSequence flattened(boolean flattenNested) {
|
||||
private CharSequence flattened(final boolean flattenNested) {
|
||||
if (state != STATE_FLATTENED) {
|
||||
flatten(flattenNested);
|
||||
}
|
||||
return left;
|
||||
}
|
||||
|
||||
private synchronized void flatten(boolean flattenNested) {
|
||||
private synchronized void flatten(final boolean flattenNested) {
|
||||
// We use iterative traversal as recursion may exceed the stack size limit.
|
||||
final char[] chars = new char[length];
|
||||
int pos = length;
|
||||
|
@ -214,7 +214,7 @@ public final class Context {
|
||||
|
||||
@Override
|
||||
public void storeScript(final String classInfoFile, final Source source, final String mainClassName,
|
||||
final Map<String,byte[]> classBytes, Map<Integer, FunctionInitializer> initializers,
|
||||
final Map<String,byte[]> classBytes, final Map<Integer, FunctionInitializer> initializers,
|
||||
final Object[] constants, final int compilationId) {
|
||||
if (context.codeStore != null) {
|
||||
context.codeStore.storeScript(classInfoFile, source, mainClassName, classBytes, initializers, constants, compilationId);
|
||||
|
@ -28,7 +28,6 @@ package jdk.nashorn.internal.runtime;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import jdk.nashorn.internal.codegen.CompilerConstants;
|
||||
import jdk.nashorn.internal.objects.Global;
|
||||
import jdk.nashorn.internal.scripts.JS;
|
||||
|
@ -25,18 +25,16 @@
|
||||
|
||||
package jdk.nashorn.internal.runtime;
|
||||
|
||||
import jdk.nashorn.internal.codegen.CompileUnit;
|
||||
import jdk.nashorn.internal.codegen.FunctionSignature;
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.FunctionNode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import jdk.nashorn.internal.codegen.CompileUnit;
|
||||
import jdk.nashorn.internal.codegen.FunctionSignature;
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.FunctionNode;
|
||||
|
||||
/**
|
||||
* Class that contains information allowing us to look up a method handle implementing a JavaScript function
|
||||
@ -121,7 +119,7 @@ public final class FunctionInitializer implements Serializable {
|
||||
* Set the class implementing the function
|
||||
* @param code the class
|
||||
*/
|
||||
public void setCode(Class<?> code) {
|
||||
public void setCode(final Class<?> code) {
|
||||
// Make sure code has not been set and has expected class name
|
||||
if (this.code != null) {
|
||||
throw new IllegalStateException("code already set");
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
package jdk.nashorn.internal.runtime;
|
||||
|
||||
import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.isValid;
|
||||
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
|
||||
import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.isValid;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
@ -37,7 +37,6 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import jdk.internal.dynalink.support.NameCodec;
|
||||
import jdk.nashorn.internal.codegen.Compiler;
|
||||
import jdk.nashorn.internal.codegen.Compiler.CompilationPhases;
|
||||
@ -489,7 +488,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp
|
||||
assert initializers.size() == 1;
|
||||
final FunctionInitializer initializer = initializers.values().iterator().next();
|
||||
|
||||
Object[] constants = script.getConstants();
|
||||
final Object[] constants = script.getConstants();
|
||||
for (int i = 0; i < constants.length; i++) {
|
||||
if (constants[i] instanceof RecompilableScriptFunctionData) {
|
||||
// replace deserialized function data with the ones we already have
|
||||
|
@ -738,7 +738,7 @@ public abstract class ScriptFunction extends ScriptObject {
|
||||
final Object[] varArgs = (Object[])args[paramCount - 1];
|
||||
// -1 'cause we're not passing the vararg array itself
|
||||
final int copiedArgCount = args.length - 1;
|
||||
int varArgCount = varArgs.length;
|
||||
final int varArgCount = varArgs.length;
|
||||
|
||||
// Spread arguments for the delegate createApplyOrCallCall invocation.
|
||||
final Object[] spreadArgs = new Object[copiedArgCount + varArgCount];
|
||||
|
@ -37,7 +37,6 @@ import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
|
||||
|
||||
|
||||
|
@ -611,7 +611,7 @@ public final class Source implements Loggable {
|
||||
* Set explicit source URL.
|
||||
* @param explicitURL URL set via sourceURL directive
|
||||
*/
|
||||
public void setExplicitURL(String explicitURL) {
|
||||
public void setExplicitURL(final String explicitURL) {
|
||||
this.explicitURL = explicitURL;
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class SpillProperty extends AccessorProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
void initMethodHandles(Class<?> structure) {
|
||||
void initMethodHandles(final Class<?> structure) {
|
||||
final int slot = getSlot();
|
||||
primitiveGetter = primitiveGetter(slot);
|
||||
primitiveSetter = primitiveSetter(slot);
|
||||
|
@ -31,7 +31,6 @@ import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.invoke.SwitchPoint;
|
||||
|
||||
import jdk.internal.dynalink.CallSiteDescriptor;
|
||||
import jdk.internal.dynalink.linker.GuardedInvocation;
|
||||
import jdk.internal.dynalink.linker.LinkRequest;
|
||||
|
@ -60,13 +60,13 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import jdk.nashorn.api.scripting.ScriptUtils;
|
||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||
import jdk.internal.org.objectweb.asm.Handle;
|
||||
import jdk.internal.org.objectweb.asm.Label;
|
||||
import jdk.internal.org.objectweb.asm.Opcodes;
|
||||
import jdk.internal.org.objectweb.asm.Type;
|
||||
import jdk.internal.org.objectweb.asm.commons.InstructionAdapter;
|
||||
import jdk.nashorn.api.scripting.ScriptUtils;
|
||||
import jdk.nashorn.internal.runtime.Context;
|
||||
import jdk.nashorn.internal.runtime.JSType;
|
||||
import jdk.nashorn.internal.runtime.ScriptFunction;
|
||||
|
@ -48,7 +48,6 @@ import jdk.internal.org.objectweb.asm.Opcodes;
|
||||
import jdk.internal.org.objectweb.asm.Type;
|
||||
import jdk.internal.org.objectweb.asm.commons.InstructionAdapter;
|
||||
import jdk.nashorn.api.scripting.ScriptUtils;
|
||||
import jdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||
import jdk.nashorn.internal.runtime.Context;
|
||||
import jdk.nashorn.internal.runtime.ScriptFunction;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
|
@ -623,7 +623,7 @@ public class ScriptEngineTest {
|
||||
final ScriptEngine e = m.getEngineByName("nashorn");
|
||||
|
||||
e.put(ScriptEngine.FILENAME, "test");
|
||||
Object enumerable = e.eval(
|
||||
final Object enumerable = e.eval(
|
||||
"Object.getOwnPropertyDescriptor(this, " +
|
||||
" 'javax.script.filename').enumerable");
|
||||
assertEquals(enumerable, Boolean.FALSE);
|
||||
|
@ -31,10 +31,10 @@ import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.function.Function;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import javax.script.Bindings;
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptContext;
|
||||
@ -358,7 +358,7 @@ public class ScriptObjectMirrorTest {
|
||||
engine.eval("function apply(obj) { " +
|
||||
" return obj instanceof Packages.jdk.nashorn.api.scripting.ScriptObjectMirror; " +
|
||||
"}");
|
||||
Function<Object,Object> func = invocable.getInterface(Function.class);
|
||||
final Function<Object,Object> func = invocable.getInterface(Function.class);
|
||||
assertFalse((boolean)func.apply(engine.eval("({ x: 2 })")));
|
||||
}
|
||||
}
|
||||
|
@ -26,11 +26,7 @@
|
||||
package jdk.nashorn.internal.runtime;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import jdk.nashorn.internal.runtime.JSType;
|
||||
import jdk.nashorn.internal.runtime.ScriptRuntime;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user