8167117: insert missing final keywords

Reviewed-by: jlaskey, sundar
This commit is contained in:
Attila Szegedi 2016-10-06 16:27:47 +02:00
parent 9bf4e700fc
commit c86ac94029
58 changed files with 398 additions and 405 deletions

View file

@ -574,7 +574,7 @@ public final class MemberInfo implements Cloneable {
String getDocumentationKey(final String objName) { String getDocumentationKey(final String objName) {
if (kind == Kind.FUNCTION) { if (kind == Kind.FUNCTION) {
StringBuilder buf = new StringBuilder(objName); final StringBuilder buf = new StringBuilder(objName);
switch (where) { switch (where) {
case CONSTRUCTOR: case CONSTRUCTOR:
break; break;

View file

@ -42,7 +42,7 @@ import static jdk.nashorn.internal.tools.nasgen.StringConstants.RUNTIME_PKG;
* *
*/ */
public final class ScriptClassInfo { public final class ScriptClassInfo {
private static String getTypeDescriptor(String pkg, String name) { private static String getTypeDescriptor(final String pkg, final String name) {
return "L" + pkg + name + ";"; return "L" + pkg + name + ";";
} }

View file

@ -30,7 +30,6 @@
*/ */
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType; import java.lang.invoke.MethodType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -43,12 +42,12 @@ import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation; import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation; import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation; import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker; import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter; import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.LinkRequest; import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices; import jdk.dynalink.linker.LinkerServices;
import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.support.Guards; import jdk.dynalink.linker.support.Guards;
import jdk.dynalink.linker.support.Lookup; import jdk.dynalink.linker.support.Lookup;
@ -65,7 +64,7 @@ public final class ArrayStreamLinkerExporter extends GuardingDynamicLinkerExport
System.out.println("pluggable dynalink array stream linker loaded"); System.out.println("pluggable dynalink array stream linker loaded");
} }
public static Object arrayToStream(Object array) { public static Object arrayToStream(final Object array) {
if (array instanceof int[]) { if (array instanceof int[]) {
return IntStream.of((int[])array); return IntStream.of((int[])array);
} else if (array instanceof long[]) { } else if (array instanceof long[]) {
@ -95,17 +94,17 @@ public final class ArrayStreamLinkerExporter extends GuardingDynamicLinkerExport
} }
@Override @Override
public GuardedInvocation getGuardedInvocation(LinkRequest request, public GuardedInvocation getGuardedInvocation(final LinkRequest request,
LinkerServices linkerServices) throws Exception { final LinkerServices linkerServices) throws Exception {
final Object self = request.getReceiver(); final Object self = request.getReceiver();
if (self == null || !canLinkType(self.getClass())) { if (self == null || !canLinkType(self.getClass())) {
return null; return null;
} }
CallSiteDescriptor desc = request.getCallSiteDescriptor(); final CallSiteDescriptor desc = request.getCallSiteDescriptor();
Operation op = desc.getOperation(); final Operation op = desc.getOperation();
Object name = NamedOperation.getName(op); final Object name = NamedOperation.getName(op);
boolean getProp = CompositeOperation.contains( final boolean getProp = CompositeOperation.contains(
NamedOperation.getBaseOperation(op), NamedOperation.getBaseOperation(op),
StandardOperation.GET_PROPERTY); StandardOperation.GET_PROPERTY);
if (getProp && "stream".equals(name)) { if (getProp && "stream".equals(name)) {

View file

@ -30,10 +30,7 @@
*/ */
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType; import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.List;
import java.nio.Buffer; import java.nio.Buffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.CharBuffer; import java.nio.CharBuffer;
@ -42,17 +39,19 @@ import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.nio.LongBuffer; import java.nio.LongBuffer;
import java.nio.ShortBuffer; import java.nio.ShortBuffer;
import java.util.ArrayList;
import java.util.List;
import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.CompositeOperation; import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation; import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation; import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation; import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker; import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter; import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.LinkRequest; import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices; import jdk.dynalink.linker.LinkerServices;
import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.support.Guards; import jdk.dynalink.linker.support.Guards;
import jdk.dynalink.linker.support.Lookup; import jdk.dynalink.linker.support.Lookup;
@ -94,7 +93,7 @@ public final class BufferIndexingLinkerExporter extends GuardingDynamicLinkerExp
private static final MethodType GUARD_TYPE; private static final MethodType GUARD_TYPE;
static { static {
Lookup look = Lookup.PUBLIC; final Lookup look = Lookup.PUBLIC;
BUFFER_LIMIT = look.findVirtual(Buffer.class, "limit", MethodType.methodType(int.class)); BUFFER_LIMIT = look.findVirtual(Buffer.class, "limit", MethodType.methodType(int.class));
BYTEBUFFER_GET = look.findVirtual(ByteBuffer.class, "get", BYTEBUFFER_GET = look.findVirtual(ByteBuffer.class, "get",
MethodType.methodType(byte.class, int.class)); MethodType.methodType(byte.class, int.class));
@ -163,15 +162,15 @@ public final class BufferIndexingLinkerExporter extends GuardingDynamicLinkerExp
} }
@Override @Override
public GuardedInvocation getGuardedInvocation(LinkRequest request, public GuardedInvocation getGuardedInvocation(final LinkRequest request,
LinkerServices linkerServices) throws Exception { final LinkerServices linkerServices) throws Exception {
final Object self = request.getReceiver(); final Object self = request.getReceiver();
if (self == null || !canLinkType(self.getClass())) { if (self == null || !canLinkType(self.getClass())) {
return null; return null;
} }
CallSiteDescriptor desc = request.getCallSiteDescriptor(); final CallSiteDescriptor desc = request.getCallSiteDescriptor();
StandardOperation op = getFirstStandardOperation(desc); final StandardOperation op = getFirstStandardOperation(desc);
if (op == null) { if (op == null) {
return null; return null;
} }
@ -182,7 +181,7 @@ public final class BufferIndexingLinkerExporter extends GuardingDynamicLinkerExp
case SET_ELEMENT: case SET_ELEMENT:
return linkSetElement(self); return linkSetElement(self);
case GET_PROPERTY: { case GET_PROPERTY: {
Object name = NamedOperation.getName(desc.getOperation()); final Object name = NamedOperation.getName(desc.getOperation());
if ("length".equals(name)) { if ("length".equals(name)) {
return linkLength(); return linkLength();
} }
@ -195,7 +194,7 @@ public final class BufferIndexingLinkerExporter extends GuardingDynamicLinkerExp
return linkers; return linkers;
} }
private static GuardedInvocation linkGetElement(Object self) { private static GuardedInvocation linkGetElement(final Object self) {
MethodHandle method = null; MethodHandle method = null;
MethodHandle guard = null; MethodHandle guard = null;
if (self instanceof ByteBuffer) { if (self instanceof ByteBuffer) {
@ -224,7 +223,7 @@ public final class BufferIndexingLinkerExporter extends GuardingDynamicLinkerExp
return method != null? new GuardedInvocation(method, guard) : null; return method != null? new GuardedInvocation(method, guard) : null;
} }
private static GuardedInvocation linkSetElement(Object self) { private static GuardedInvocation linkSetElement(final Object self) {
MethodHandle method = null; MethodHandle method = null;
MethodHandle guard = null; MethodHandle guard = null;
if (self instanceof ByteBuffer) { if (self instanceof ByteBuffer) {

View file

@ -39,18 +39,17 @@ import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation; import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation; import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation; import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker; import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter; import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.LinkRequest; import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices; import jdk.dynalink.linker.LinkerServices;
import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.support.Guards; import jdk.dynalink.linker.support.Guards;
import jdk.dynalink.linker.support.Lookup; import jdk.dynalink.linker.support.Lookup;
import org.w3c.dom.Attr; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
/** /**
* This is a dynalink pluggable linker (see http://openjdk.java.net/jeps/276). * This is a dynalink pluggable linker (see http://openjdk.java.net/jeps/276).
@ -65,12 +64,12 @@ public final class DOMLinkerExporter extends GuardingDynamicLinkerExporter {
} }
// return List of child Elements of the given Element matching the given name. // return List of child Elements of the given Element matching the given name.
private static List<Element> getChildElements(Element elem, String name) { private static List<Element> getChildElements(final Element elem, final String name) {
NodeList nodeList = elem.getChildNodes(); final NodeList nodeList = elem.getChildNodes();
List<Element> childElems = new ArrayList<>(); final List<Element> childElems = new ArrayList<>();
int len = nodeList.getLength(); final int len = nodeList.getLength();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
Node node = nodeList.item(i); final Node node = nodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE && if (node.getNodeType() == Node.ELEMENT_NODE &&
((Element)node).getTagName().equals(name)) { ((Element)node).getTagName().equals(name)) {
childElems.add((Element)node); childElems.add((Element)node);
@ -81,18 +80,18 @@ public final class DOMLinkerExporter extends GuardingDynamicLinkerExporter {
// method that returns either unique child element matching given name // method that returns either unique child element matching given name
// or a list of child elements of that name (if there are more than one matches). // or a list of child elements of that name (if there are more than one matches).
public static Object getElementsByName(Object elem, final String name) { public static Object getElementsByName(final Object elem, final String name) {
List<Element> elems = getChildElements((Element)elem, name); final List<Element> elems = getChildElements((Element)elem, name);
return elems.size() == 1? elems.get(0) : elems; return elems.size() == 1? elems.get(0) : elems;
} }
// method to extract text context under a given DOM Element // method to extract text context under a given DOM Element
public static Object getElementText(Object elem) { public static Object getElementText(final Object elem) {
NodeList nodeList = ((Element)elem).getChildNodes(); final NodeList nodeList = ((Element)elem).getChildNodes();
int len = nodeList.getLength(); final int len = nodeList.getLength();
StringBuilder text = new StringBuilder(); final StringBuilder text = new StringBuilder();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
Node node = nodeList.item(i); final Node node = nodeList.item(i);
if (node.getNodeType() == Node.TEXT_NODE) { if (node.getNodeType() == Node.TEXT_NODE) {
text.append(node.getNodeValue()); text.append(node.getNodeValue());
} }
@ -123,21 +122,21 @@ public final class DOMLinkerExporter extends GuardingDynamicLinkerExporter {
} }
@Override @Override
public GuardedInvocation getGuardedInvocation(LinkRequest request, public GuardedInvocation getGuardedInvocation(final LinkRequest request,
LinkerServices linkerServices) throws Exception { final LinkerServices linkerServices) throws Exception {
final Object self = request.getReceiver(); final Object self = request.getReceiver();
if (! (self instanceof Element)) { if (! (self instanceof Element)) {
return null; return null;
} }
CallSiteDescriptor desc = request.getCallSiteDescriptor(); final CallSiteDescriptor desc = request.getCallSiteDescriptor();
Operation op = desc.getOperation(); final Operation op = desc.getOperation();
Object name = NamedOperation.getName(op); final Object name = NamedOperation.getName(op);
boolean getProp = CompositeOperation.contains( final boolean getProp = CompositeOperation.contains(
NamedOperation.getBaseOperation(op), NamedOperation.getBaseOperation(op),
StandardOperation.GET_PROPERTY); StandardOperation.GET_PROPERTY);
if (getProp && name instanceof String) { if (getProp && name instanceof String) {
String nameStr = (String)name; final String nameStr = (String)name;
// Treat names starting with "_" as special names. // Treat names starting with "_" as special names.
// Everything else is linked other dynalink bean linker! // Everything else is linked other dynalink bean linker!

View file

@ -37,13 +37,13 @@ public class MissingMethodExample extends ArrayList
implements MissingMethodHandler { implements MissingMethodHandler {
@Override @Override
public Object doesNotUnderstand(String name, Object... args) { public Object doesNotUnderstand(final String name, final Object... args) {
// This simple doesNotUnderstand just prints method name and args. // This simple doesNotUnderstand just prints method name and args.
// You can put useful method routing logic here. // You can put useful method routing logic here.
System.out.println("you called " + name); System.out.println("you called " + name);
if (args.length != 0) { if (args.length != 0) {
System.out.println("arguments are: "); System.out.println("arguments are: ");
for (Object arg : args) { for (final Object arg : args) {
System.out.println(" " + arg); System.out.println(" " + arg);
} }
} }

View file

@ -40,12 +40,12 @@ import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation; import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation; import jdk.dynalink.StandardOperation;
import jdk.dynalink.beans.BeansLinker; import jdk.dynalink.beans.BeansLinker;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker; import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter; import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.LinkRequest; import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices; import jdk.dynalink.linker.LinkerServices;
import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker;
import jdk.dynalink.linker.support.Guards; import jdk.dynalink.linker.support.Guards;
import jdk.dynalink.linker.support.Lookup; import jdk.dynalink.linker.support.Lookup;
@ -65,7 +65,7 @@ public final class MissingMethodLinkerExporter extends GuardingDynamicLinkerExpo
public static class MissingMethod { public static class MissingMethod {
private final String name; private final String name;
public MissingMethod(String name) { public MissingMethod(final String name) {
this.name = name; this.name = name;
} }
@ -130,20 +130,20 @@ public final class MissingMethodLinkerExporter extends GuardingDynamicLinkerExpo
} }
@Override @Override
public GuardedInvocation getGuardedInvocation(LinkRequest request, public GuardedInvocation getGuardedInvocation(final LinkRequest request,
LinkerServices linkerServices) throws Exception { final LinkerServices linkerServices) throws Exception {
final Object self = request.getReceiver(); final Object self = request.getReceiver();
CallSiteDescriptor desc = request.getCallSiteDescriptor(); final CallSiteDescriptor desc = request.getCallSiteDescriptor();
// any method call is done by two steps. Step (1) GET_METHOD and (2) is CALL // any method call is done by two steps. Step (1) GET_METHOD and (2) is CALL
// For step (1), we check if GET_METHOD can succeed by Java linker, if so // For step (1), we check if GET_METHOD can succeed by Java linker, if so
// we return that method object. If not, we return a MissingMethod object. // we return that method object. If not, we return a MissingMethod object.
if (self instanceof MissingMethodHandler) { if (self instanceof MissingMethodHandler) {
// Check if this is a named GET_METHOD first. // Check if this is a named GET_METHOD first.
boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD; final boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
Object name = NamedOperation.getName(desc.getOperation()); final Object name = NamedOperation.getName(desc.getOperation());
if (isGetMethod && name instanceof String) { if (isGetMethod && name instanceof String) {
GuardingDynamicLinker javaLinker = beansLinker.getLinkerForClass(self.getClass()); final GuardingDynamicLinker javaLinker = beansLinker.getLinkerForClass(self.getClass());
GuardedInvocation inv; GuardedInvocation inv;
try { try {
inv = javaLinker.getGuardedInvocation(request, linkerServices); inv = javaLinker.getGuardedInvocation(request, linkerServices);
@ -151,11 +151,11 @@ public final class MissingMethodLinkerExporter extends GuardingDynamicLinkerExpo
inv = null; inv = null;
} }
String nameStr = name.toString(); final String nameStr = name.toString();
if (inv == null) { if (inv == null) {
// use "this" for just guard and drop it -- return a constant Method handle // use "this" for just guard and drop it -- return a constant Method handle
// that returns a newly created MissingMethod object // that returns a newly created MissingMethod object
MethodHandle mh = MethodHandles.constant(Object.class, new MissingMethod(nameStr)); final MethodHandle mh = MethodHandles.constant(Object.class, new MissingMethod(nameStr));
inv = new GuardedInvocation( inv = new GuardedInvocation(
MethodHandles.dropArguments(mh, 0, Object.class), MethodHandles.dropArguments(mh, 0, Object.class),
Guards.isOfClass(self.getClass(), MethodType.methodType(Boolean.TYPE, Object.class))); Guards.isOfClass(self.getClass(), MethodType.methodType(Boolean.TYPE, Object.class)));
@ -166,7 +166,7 @@ public final class MissingMethodLinkerExporter extends GuardingDynamicLinkerExpo
} else if (self instanceof MissingMethod) { } else if (self instanceof MissingMethod) {
// This is step (2). We call MissingMethodHandler.doesNotUnderstand here // This is step (2). We call MissingMethodHandler.doesNotUnderstand here
// Check if this is this a CALL first. // Check if this is this a CALL first.
boolean isCall = getFirstStandardOperation(desc) == StandardOperation.CALL; final boolean isCall = getFirstStandardOperation(desc) == StandardOperation.CALL;
if (isCall) { if (isCall) {
MethodHandle mh = DOES_NOT_UNDERSTAND; MethodHandle mh = DOES_NOT_UNDERSTAND;

View file

@ -29,22 +29,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.CompositeOperation; import jdk.dynalink.CompositeOperation;
import jdk.dynalink.NamedOperation; import jdk.dynalink.NamedOperation;
import jdk.dynalink.Operation; import jdk.dynalink.Operation;
import jdk.dynalink.CompositeOperation;
import jdk.dynalink.StandardOperation; import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker; import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.GuardingDynamicLinkerExporter; import jdk.dynalink.linker.GuardingDynamicLinkerExporter;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.LinkRequest; import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices; import jdk.dynalink.linker.LinkerServices;
import jdk.dynalink.linker.support.SimpleLinkRequest; import jdk.dynalink.linker.support.SimpleLinkRequest;
@ -62,9 +58,9 @@ public final class UnderscoreNameLinkerExporter extends GuardingDynamicLinkerExp
private static final Pattern UNDERSCORE_NAME = Pattern.compile("_(.)"); private static final Pattern UNDERSCORE_NAME = Pattern.compile("_(.)");
// translate underscore_separated name as a CamelCase name // translate underscore_separated name as a CamelCase name
private static String translateToCamelCase(String name) { private static String translateToCamelCase(final String name) {
Matcher m = UNDERSCORE_NAME.matcher(name); final Matcher m = UNDERSCORE_NAME.matcher(name);
StringBuilder buf = new StringBuilder(); final StringBuilder buf = new StringBuilder();
while (m.find()) { while (m.find()) {
m.appendReplacement(buf, m.group(1).toUpperCase()); m.appendReplacement(buf, m.group(1).toUpperCase());
} }
@ -94,28 +90,28 @@ public final class UnderscoreNameLinkerExporter extends GuardingDynamicLinkerExp
final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>(); final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>();
linkers.add(new GuardingDynamicLinker() { linkers.add(new GuardingDynamicLinker() {
@Override @Override
public GuardedInvocation getGuardedInvocation(LinkRequest request, public GuardedInvocation getGuardedInvocation(final LinkRequest request,
LinkerServices linkerServices) throws Exception { final LinkerServices linkerServices) throws Exception {
final Object self = request.getReceiver(); final Object self = request.getReceiver();
CallSiteDescriptor desc = request.getCallSiteDescriptor(); final CallSiteDescriptor desc = request.getCallSiteDescriptor();
Operation op = desc.getOperation(); final Operation op = desc.getOperation();
Object name = NamedOperation.getName(op); final Object name = NamedOperation.getName(op);
// is this a named GET_METHOD? // is this a named GET_METHOD?
boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD; final boolean isGetMethod = getFirstStandardOperation(desc) == StandardOperation.GET_METHOD;
if (isGetMethod && name instanceof String) { if (isGetMethod && name instanceof String) {
String str = (String)name; final String str = (String)name;
if (str.indexOf('_') == -1) { if (str.indexOf('_') == -1) {
return null; return null;
} }
String nameStr = translateToCamelCase(str); final String nameStr = translateToCamelCase(str);
// create a new call descriptor to use translated name // create a new call descriptor to use translated name
CallSiteDescriptor newDesc = new CallSiteDescriptor( final CallSiteDescriptor newDesc = new CallSiteDescriptor(
desc.getLookup(), desc.getLookup(),
new NamedOperation(NamedOperation.getBaseOperation(op), nameStr), new NamedOperation(NamedOperation.getBaseOperation(op), nameStr),
desc.getMethodType()); desc.getMethodType());
// create a new Link request to link the call site with translated name // create a new Link request to link the call site with translated name
LinkRequest newRequest = new SimpleLinkRequest(newDesc, final LinkRequest newRequest = new SimpleLinkRequest(newDesc,
request.isCallSiteUnstable(), request.getArguments()); request.isCallSiteUnstable(), request.getArguments());
// return guarded invocation linking the translated request // return guarded invocation linking the translated request
return linkerServices.getGuardedInvocation(newRequest); return linkerServices.getGuardedInvocation(newRequest);

View file

@ -36,7 +36,7 @@ final class DestructuringDeclTreeImpl extends StatementTreeImpl
private final ExpressionTree lhs; private final ExpressionTree lhs;
private final ExpressionTree init; private final ExpressionTree init;
DestructuringDeclTreeImpl(ExpressionStatement exprStat, final ExpressionTree lhs, final ExpressionTree init) { DestructuringDeclTreeImpl(final ExpressionStatement exprStat, final ExpressionTree lhs, final ExpressionTree init) {
super(exprStat); super(exprStat);
assert exprStat.destructuringDeclarationType() != null : "expecting a destructuring decl. statement"; assert exprStat.destructuringDeclarationType() != null : "expecting a destructuring decl. statement";

View file

@ -39,10 +39,10 @@ final class ExportEntryTreeImpl extends TreeImpl implements ExportEntryTree {
private final IdentifierTree localName; private final IdentifierTree localName;
private ExportEntryTreeImpl(final long startPos, final long endPos, private ExportEntryTreeImpl(final long startPos, final long endPos,
IdentifierTree exportName, final IdentifierTree exportName,
IdentifierTree moduleRequest, final IdentifierTree moduleRequest,
IdentifierTree importName, final IdentifierTree importName,
IdentifierTree localName) { final IdentifierTree localName) {
super(null); // no underlying Node! super(null); // no underlying Node!
this.startPos = startPos; this.startPos = startPos;
this.endPos = endPos; this.endPos = endPos;
@ -52,7 +52,7 @@ final class ExportEntryTreeImpl extends TreeImpl implements ExportEntryTree {
this.localName = localName; this.localName = localName;
} }
private static ExportEntryTreeImpl createExportEntry(Module.ExportEntry entry) { private static ExportEntryTreeImpl createExportEntry(final Module.ExportEntry entry) {
return new ExportEntryTreeImpl(entry.getStartPosition(), return new ExportEntryTreeImpl(entry.getStartPosition(),
entry.getEndPosition(), entry.getEndPosition(),
identOrNull(entry.getExportName()), identOrNull(entry.getExportName()),
@ -61,7 +61,7 @@ final class ExportEntryTreeImpl extends TreeImpl implements ExportEntryTree {
identOrNull(entry.getLocalName())); identOrNull(entry.getLocalName()));
} }
static List<ExportEntryTreeImpl> createExportList(List<Module.ExportEntry> exportList) { static List<ExportEntryTreeImpl> createExportList(final List<Module.ExportEntry> exportList) {
return exportList.stream(). return exportList.stream().
map(ExportEntryTreeImpl::createExportEntry). map(ExportEntryTreeImpl::createExportEntry).
collect(Collectors.toList()); collect(Collectors.toList());

View file

@ -51,7 +51,7 @@ final class FunctionExpressionTreeImpl extends ExpressionTreeImpl
this.params = params; this.params = params;
if (node.getFlag(FunctionNode.HAS_EXPRESSION_BODY)) { if (node.getFlag(FunctionNode.HAS_EXPRESSION_BODY)) {
StatementTree first = body.getStatements().get(0); final StatementTree first = body.getStatements().get(0);
assert first instanceof ReturnTree : "consise func. expression should have a return statement"; assert first instanceof ReturnTree : "consise func. expression should have a return statement";
this.body = ((ReturnTree)first).getExpression(); this.body = ((ReturnTree)first).getExpression();
} else { } else {

View file

@ -191,9 +191,9 @@ final class IRTranslator extends SimpleNodeVisitor {
@Override @Override
public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) { public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) {
if (expressionStatement.destructuringDeclarationType() != null) { if (expressionStatement.destructuringDeclarationType() != null) {
ExpressionTree expr = translateExpr(expressionStatement.getExpression()); final ExpressionTree expr = translateExpr(expressionStatement.getExpression());
assert expr instanceof AssignmentTree : "destructuring decl. statement does not have assignment"; assert expr instanceof AssignmentTree : "destructuring decl. statement does not have assignment";
AssignmentTree assign = (AssignmentTree)expr; final AssignmentTree assign = (AssignmentTree)expr;
curStat = new DestructuringDeclTreeImpl(expressionStatement, assign.getVariable(), assign.getExpression()); curStat = new DestructuringDeclTreeImpl(expressionStatement, assign.getVariable(), assign.getExpression());
} else { } else {
curStat = new ExpressionStatementTreeImpl(expressionStatement, curStat = new ExpressionStatementTreeImpl(expressionStatement,
@ -544,12 +544,12 @@ final class IRTranslator extends SimpleNodeVisitor {
} }
private List<? extends ExpressionTree> translateParameters(final FunctionNode func) { private List<? extends ExpressionTree> translateParameters(final FunctionNode func) {
Map<IdentNode, Expression> paramExprs = func.getParameterExpressions(); final Map<IdentNode, Expression> paramExprs = func.getParameterExpressions();
if (paramExprs != null) { if (paramExprs != null) {
List<IdentNode> params = func.getParameters(); final List<IdentNode> params = func.getParameters();
final List<ExpressionTreeImpl> exprTrees = new ArrayList<>(params.size()); final List<ExpressionTreeImpl> exprTrees = new ArrayList<>(params.size());
for (final IdentNode ident : params) { for (final IdentNode ident : params) {
Expression expr = paramExprs.containsKey(ident)? paramExprs.get(ident) : ident; final Expression expr = paramExprs.containsKey(ident)? paramExprs.get(ident) : ident;
curExpr = null; curExpr = null;
expr.accept(this); expr.accept(this);
assert curExpr != null; assert curExpr != null;

View file

@ -38,9 +38,9 @@ final class ImportEntryTreeImpl extends TreeImpl implements ImportEntryTree {
private final IdentifierTree localName; private final IdentifierTree localName;
private ImportEntryTreeImpl(final long startPos, final long endPos, private ImportEntryTreeImpl(final long startPos, final long endPos,
IdentifierTree moduleRequest, final IdentifierTree moduleRequest,
IdentifierTree importName, final IdentifierTree importName,
IdentifierTree localName) { final IdentifierTree localName) {
super(null); // No underlying Node! super(null); // No underlying Node!
this.startPos = startPos; this.startPos = startPos;
this.endPos = endPos; this.endPos = endPos;
@ -49,7 +49,7 @@ final class ImportEntryTreeImpl extends TreeImpl implements ImportEntryTree {
this.localName = localName; this.localName = localName;
} }
private static ImportEntryTreeImpl createImportEntry(Module.ImportEntry entry) { private static ImportEntryTreeImpl createImportEntry(final Module.ImportEntry entry) {
return new ImportEntryTreeImpl(entry.getStartPosition(), return new ImportEntryTreeImpl(entry.getStartPosition(),
entry.getEndPosition(), entry.getEndPosition(),
identOrNull(entry.getModuleRequest()), identOrNull(entry.getModuleRequest()),
@ -57,7 +57,7 @@ final class ImportEntryTreeImpl extends TreeImpl implements ImportEntryTree {
identOrNull(entry.getLocalName())); identOrNull(entry.getLocalName()));
} }
static List<ImportEntryTreeImpl> createImportList(List<Module.ImportEntry> importList) { static List<ImportEntryTreeImpl> createImportList(final List<Module.ImportEntry> importList) {
return importList.stream(). return importList.stream().
map(ImportEntryTreeImpl::createImportEntry). map(ImportEntryTreeImpl::createImportEntry).
collect(Collectors.toList()); collect(Collectors.toList());

View file

@ -140,7 +140,7 @@ public interface Parser {
*/ */
public static Parser create(final String... options) throws IllegalArgumentException { public static Parser create(final String... options) throws IllegalArgumentException {
options.getClass(); options.getClass();
for (String opt : options) { for (final String opt : options) {
switch (opt) { switch (opt) {
case "--const-as-var": case "--const-as-var":
case "-dump-on-error": case "-dump-on-error":

View file

@ -73,9 +73,9 @@ final class ParserImpl implements Parser {
// append "--parse-only to signal to the Nashorn that it // append "--parse-only to signal to the Nashorn that it
// is being used in "parse only" mode. // is being used in "parse only" mode.
String[] newArgs = Arrays.copyOf(args, args.length + 1, String[].class); final String[] newArgs = Arrays.copyOf(args, args.length + 1, String[].class);
newArgs[args.length] = "--parse-only"; newArgs[args.length] = "--parse-only";
Options options = new Options("nashorn"); final Options options = new Options("nashorn");
options.process(newArgs); options.process(newArgs);
this.env = new ScriptEnvironment(options, this.env = new ScriptEnvironment(options,
new PrintWriter(System.out), new PrintWriter(System.err)); new PrintWriter(System.out), new PrintWriter(System.err));
@ -142,32 +142,32 @@ final class ParserImpl implements Parser {
} }
} }
private CompilationUnitTree parseModule(File file, DiagnosticListener listener) throws IOException, NashornException { private CompilationUnitTree parseModule(final File file, final DiagnosticListener listener) throws IOException, NashornException {
final Source src = Source.sourceFor(Objects.requireNonNull(file).getName(), file); final Source src = Source.sourceFor(Objects.requireNonNull(file).getName(), file);
return makeModule(src, listener); return makeModule(src, listener);
} }
private CompilationUnitTree parseModule(Path path, DiagnosticListener listener) throws IOException, NashornException { private CompilationUnitTree parseModule(final Path path, final DiagnosticListener listener) throws IOException, NashornException {
final Source src = Source.sourceFor(Objects.requireNonNull(path).toString(), path); final Source src = Source.sourceFor(Objects.requireNonNull(path).toString(), path);
return makeModule(src, listener); return makeModule(src, listener);
} }
private CompilationUnitTree parseModule(URL url, DiagnosticListener listener) throws IOException, NashornException { private CompilationUnitTree parseModule(final URL url, final DiagnosticListener listener) throws IOException, NashornException {
final Source src = Source.sourceFor(url.toString(), url); final Source src = Source.sourceFor(url.toString(), url);
return makeModule(src, listener); return makeModule(src, listener);
} }
private CompilationUnitTree parseModule(String name, Reader reader, DiagnosticListener listener) throws IOException, NashornException { private CompilationUnitTree parseModule(final String name, final Reader reader, final DiagnosticListener listener) throws IOException, NashornException {
final Source src = Source.sourceFor(Objects.requireNonNull(name), Objects.requireNonNull(reader)); final Source src = Source.sourceFor(Objects.requireNonNull(name), Objects.requireNonNull(reader));
return makeModule(src, listener); return makeModule(src, listener);
} }
private CompilationUnitTree parseModule(String name, String code, DiagnosticListener listener) throws NashornException { private CompilationUnitTree parseModule(final String name, final String code, final DiagnosticListener listener) throws NashornException {
final Source src = Source.sourceFor(name, code); final Source src = Source.sourceFor(name, code);
return makeModule(src, listener); return makeModule(src, listener);
} }
private CompilationUnitTree parseModule(ScriptObjectMirror scriptObj, DiagnosticListener listener) throws NashornException { private CompilationUnitTree parseModule(final ScriptObjectMirror scriptObj, final DiagnosticListener listener) throws NashornException {
final Map<?, ?> map = Objects.requireNonNull(scriptObj); final Map<?, ?> map = Objects.requireNonNull(scriptObj);
if (map.containsKey("script") && map.containsKey("name")) { if (map.containsKey("script") && map.containsKey("name")) {
final String script = JSType.toString(map.get("script")); final String script = JSType.toString(map.get("script"));
@ -179,7 +179,7 @@ final class ParserImpl implements Parser {
} }
} }
private CompilationUnitTree makeModule(Source src, DiagnosticListener listener) { private CompilationUnitTree makeModule(final Source src, final DiagnosticListener listener) {
final FunctionNode modFunc = makeParser(src, listener).parseModule(src.getName()); final FunctionNode modFunc = makeParser(src, listener).parseModule(src.getName());
return new IRTranslator().translate(modFunc); return new IRTranslator().translate(modFunc);
} }

View file

@ -70,7 +70,7 @@ public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
* @return the result of {@code visitUnknown} * @return the result of {@code visitUnknown}
*/ */
@Override @Override
public R visitModule(ModuleTree node, P p) { public R visitModule(final ModuleTree node, final P p) {
return visitUnknown(node, p); return visitUnknown(node, p);
} }
@ -83,7 +83,7 @@ public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
* @return the result of {@code visitUnknown} * @return the result of {@code visitUnknown}
*/ */
@Override @Override
public R visitExportEntry(ExportEntryTree node, P p) { public R visitExportEntry(final ExportEntryTree node, final P p) {
return visitUnknown(node, p); return visitUnknown(node, p);
} }
@ -96,7 +96,7 @@ public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
* @return the result of {@code visitUnknown} * @return the result of {@code visitUnknown}
*/ */
@Override @Override
public R visitImportEntry(ImportEntryTree node, P p) { public R visitImportEntry(final ImportEntryTree node, final P p) {
return visitUnknown(node, p); return visitUnknown(node, p);
} }
@ -153,7 +153,7 @@ public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
* @return the result of {@code visitUnknown} * @return the result of {@code visitUnknown}
*/ */
@Override @Override
public R visitClassDeclaration(ClassDeclarationTree node, P p) { public R visitClassDeclaration(final ClassDeclarationTree node, final P p) {
return visitUnknown(node, p); return visitUnknown(node, p);
} }
@ -166,7 +166,7 @@ public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
* @return the result of {@code visitUnknown} * @return the result of {@code visitUnknown}
*/ */
@Override @Override
public R visitClassExpression(ClassExpressionTree node, P p) { public R visitClassExpression(final ClassExpressionTree node, final P p) {
return visitUnknown(node, p); return visitUnknown(node, p);
} }
@ -247,7 +247,7 @@ public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
* @return the result of {@code visitUnknown} * @return the result of {@code visitUnknown}
*/ */
@Override @Override
public R visitForOfLoop(ForOfLoopTree node, P p) { public R visitForOfLoop(final ForOfLoopTree node, final P p) {
return visitUnknown(node, p); return visitUnknown(node, p);
} }
@ -357,21 +357,21 @@ public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
@Override @Override
public R visitProperty(final PropertyTree node, final P r) { public R visitProperty(final PropertyTree node, final P r) {
FunctionExpressionTree getter = node.getGetter(); final FunctionExpressionTree getter = node.getGetter();
if (getter != null) { if (getter != null) {
getter.accept(this, r); getter.accept(this, r);
} }
ExpressionTree key = node.getKey(); final ExpressionTree key = node.getKey();
if (key != null) { if (key != null) {
key.accept(this, r); key.accept(this, r);
} }
FunctionExpressionTree setter = node.getSetter(); final FunctionExpressionTree setter = node.getSetter();
if (setter != null) { if (setter != null) {
setter.accept(this, r); setter.accept(this, r);
} }
ExpressionTree value = node.getValue(); final ExpressionTree value = node.getValue();
if (value != null) { if (value != null) {
value.accept(this, r); value.accept(this, r);
} }
@ -392,7 +392,7 @@ public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
* @return the result of {@code visitUnknown} * @return the result of {@code visitUnknown}
*/ */
@Override @Override
public R visitTemplateLiteral(TemplateLiteralTree node, P p) { public R visitTemplateLiteral(final TemplateLiteralTree node, final P p) {
return visitUnknown(node, p); return visitUnknown(node, p);
} }
@ -410,7 +410,7 @@ public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
* @return the result of {@code visitUnknown} * @return the result of {@code visitUnknown}
*/ */
@Override @Override
public R visitSpread(SpreadTree node, P p) { public R visitSpread(final SpreadTree node, final P p) {
return visitUnknown(node, p); return visitUnknown(node, p);
} }
@ -495,7 +495,7 @@ public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
* @return the result of {@code visitUnknown} * @return the result of {@code visitUnknown}
*/ */
@Override @Override
public R visitYield(YieldTree node, P p) { public R visitYield(final YieldTree node, final P p) {
return visitUnknown(node, p); return visitUnknown(node, p);
} }

View file

@ -66,7 +66,7 @@ public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
* @return value from the visitor * @return value from the visitor
*/ */
@Override @Override
public R visitModule(ModuleTree node, P p) { public R visitModule(final ModuleTree node, final P p) {
node.getImportEntries().forEach(e -> visitImportEntry(e, p)); node.getImportEntries().forEach(e -> visitImportEntry(e, p));
node.getLocalExportEntries().forEach(e -> visitExportEntry(e, p)); node.getLocalExportEntries().forEach(e -> visitExportEntry(e, p));
node.getIndirectExportEntries().forEach(e -> visitExportEntry(e, p)); node.getIndirectExportEntries().forEach(e -> visitExportEntry(e, p));
@ -82,7 +82,7 @@ public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
* @return value from the visitor * @return value from the visitor
*/ */
@Override @Override
public R visitExportEntry(ExportEntryTree node, P p) { public R visitExportEntry(final ExportEntryTree node, final P p) {
return null; return null;
} }
@ -94,7 +94,7 @@ public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
* @return value from the visitor * @return value from the visitor
*/ */
@Override @Override
public R visitImportEntry(ImportEntryTree node, P p) { public R visitImportEntry(final ImportEntryTree node, final P p) {
return null; return null;
} }
@ -106,7 +106,7 @@ public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
* @return value from the visitor * @return value from the visitor
*/ */
@Override @Override
public R visitClassDeclaration(ClassDeclarationTree node, P p) { public R visitClassDeclaration(final ClassDeclarationTree node, final P p) {
node.getName().accept(this, p); node.getName().accept(this, p);
final ExpressionTree heritage = node.getClassHeritage(); final ExpressionTree heritage = node.getClassHeritage();
if (heritage != null) { if (heritage != null) {
@ -118,7 +118,7 @@ public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
} }
final List<? extends PropertyTree> elements = node.getClassElements(); final List<? extends PropertyTree> elements = node.getClassElements();
if (elements != null) { if (elements != null) {
for (PropertyTree prop : elements) { for (final PropertyTree prop : elements) {
prop.accept(this, p); prop.accept(this, p);
} }
} }
@ -134,7 +134,7 @@ public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
* @return value from the visitor * @return value from the visitor
*/ */
@Override @Override
public R visitClassExpression(ClassExpressionTree node, P p) { public R visitClassExpression(final ClassExpressionTree node, final P p) {
node.getName().accept(this, p); node.getName().accept(this, p);
final ExpressionTree heritage = node.getClassHeritage(); final ExpressionTree heritage = node.getClassHeritage();
if (heritage != null) { if (heritage != null) {
@ -146,7 +146,7 @@ public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
} }
final List<? extends PropertyTree> elements = node.getClassElements(); final List<? extends PropertyTree> elements = node.getClassElements();
if (elements != null) { if (elements != null) {
for (PropertyTree prop : elements) { for (final PropertyTree prop : elements) {
prop.accept(this, p); prop.accept(this, p);
} }
} }
@ -180,7 +180,7 @@ public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
* @return value from the visitor * @return value from the visitor
*/ */
@Override @Override
public R visitYield(YieldTree node, P p) { public R visitYield(final YieldTree node, final P p) {
node.getExpression().accept(this, p); node.getExpression().accept(this, p);
return null; return null;
} }
@ -193,7 +193,7 @@ public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
* @return value from the visitor * @return value from the visitor
*/ */
@Override @Override
public R visitSpread(SpreadTree node, P p) { public R visitSpread(final SpreadTree node, final P p) {
node.getExpression().accept(this, p); node.getExpression().accept(this, p);
return null; return null;
} }
@ -206,9 +206,9 @@ public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
* @return value from the visitor * @return value from the visitor
*/ */
@Override @Override
public R visitTemplateLiteral(TemplateLiteralTree node, P p) { public R visitTemplateLiteral(final TemplateLiteralTree node, final P p) {
final List<? extends ExpressionTree> expressions = node.getExpressions(); final List<? extends ExpressionTree> expressions = node.getExpressions();
for (ExpressionTree expr : expressions) { for (final ExpressionTree expr : expressions) {
expr.accept(this, p); expr.accept(this, p);
} }
return null; return null;

View file

@ -33,7 +33,7 @@ final class SwitchTreeImpl extends StatementTreeImpl implements SwitchTree {
private final List<? extends CaseTree> cases; private final List<? extends CaseTree> cases;
SwitchTreeImpl(final SwitchNode node, SwitchTreeImpl(final SwitchNode node,
final ExpressionTree expr, final ExpressionTree expr,
List<? extends CaseTree> cases) { final List<? extends CaseTree> cases) {
super(node); super(node);
this.expr = expr; this.expr = expr;
this.cases = cases; this.cases = cases;

View file

@ -33,7 +33,7 @@ final class TemplateLiteralTreeImpl extends ExpressionTreeImpl
private final List<? extends ExpressionTree> expressions; private final List<? extends ExpressionTree> expressions;
TemplateLiteralTreeImpl(Expression node, List<? extends ExpressionTree> expressions) { TemplateLiteralTreeImpl(final Expression node, final List<? extends ExpressionTree> expressions) {
super(node); super(node);
this.expressions = expressions; this.expressions = expressions;
} }

View file

@ -566,7 +566,7 @@ public interface Tree {
*/ */
OTHER(null); OTHER(null);
Kind(Class<? extends Tree> intf) { Kind(final Class<? extends Tree> intf) {
associatedInterface = intf; associatedInterface = intf;
} }

View file

@ -52,7 +52,7 @@ public class UnknownTreeException extends RuntimeException {
* @param t the unknown tree, may be {@code null} * @param t the unknown tree, may be {@code null}
* @param p an additional parameter, may be {@code null} * @param p an additional parameter, may be {@code null}
*/ */
public UnknownTreeException(Tree t, Object p) { public UnknownTreeException(final Tree t, final Object p) {
super("Unknown tree: " + t); super("Unknown tree: " + t);
this.tree = t; this.tree = t;
this.parameter = p; this.parameter = p;

View file

@ -258,7 +258,7 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
private final int[] continuationEntryPoints; private final int[] continuationEntryPoints;
// Scope object creators needed for for-of and for-in loops // Scope object creators needed for for-of and for-in loops
private Deque<FieldObjectCreator<?>> scopeObjectCreators = new ArrayDeque<>(); private final Deque<FieldObjectCreator<?>> scopeObjectCreators = new ArrayDeque<>();
/** /**
* Constructor. * Constructor.

View file

@ -102,7 +102,7 @@ final class SplitIntoFunctions extends NodeVisitor<BlockLexicalContext> {
super(new BlockLexicalContext() { super(new BlockLexicalContext() {
@Override @Override
protected Block afterSetStatements(final Block block) { protected Block afterSetStatements(final Block block) {
for(Statement stmt: block.getStatements()) { for(final Statement stmt: block.getStatements()) {
assert !(stmt instanceof SplitNode); assert !(stmt instanceof SplitNode);
} }
return block; return block;
@ -145,7 +145,7 @@ final class SplitIntoFunctions extends NodeVisitor<BlockLexicalContext> {
final FunctionState fnState = getCurrentFunctionState(); final FunctionState fnState = getCurrentFunctionState();
final String name = splitNode.getName(); final String name = splitNode.getName();
Block body = splitNode.getBody(); final Block body = splitNode.getBody();
final int firstLineNumber = body.getFirstStatementLineNumber(); final int firstLineNumber = body.getFirstStatementLineNumber();
final long token = body.getToken(); final long token = body.getToken();
final int finish = body.getFinish(); final int finish = body.getFinish();

View file

@ -71,10 +71,10 @@ public final class ExpressionList extends Expression {
} }
@Override @Override
public void toString(StringBuilder sb, boolean printType) { public void toString(final StringBuilder sb, final boolean printType) {
sb.append("("); sb.append("(");
boolean first = true; boolean first = true;
for (Expression expression : expressions) { for (final Expression expression : expressions) {
if (first) { if (first) {
first = false; first = false;
} else { } else {

View file

@ -51,7 +51,7 @@ public final class TemplateLiteral extends Expression {
} }
@Override @Override
public Node accept(NodeVisitor<? extends LexicalContext> visitor) { public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterTemplateLiteral(this)) { if (visitor.enterTemplateLiteral(this)) {
return visitor.leaveTemplateLiteral(this); return visitor.leaveTemplateLiteral(this);
} }
@ -60,8 +60,8 @@ public final class TemplateLiteral extends Expression {
} }
@Override @Override
public void toString(StringBuilder sb, boolean printType) { public void toString(final StringBuilder sb, final boolean printType) {
for (Expression expr : exprs) { for (final Expression expr : exprs) {
sb.append(expr); sb.append(expr);
} }
} }

View file

@ -2474,7 +2474,7 @@ public final class Global extends Scope {
} }
@Override @Override
protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) { protected FindProperty findProperty(final Object key, final boolean deep, final boolean isScope, final ScriptObject start) {
if (lexicalScope != null && isScope) { if (lexicalScope != null && isScope) {
final FindProperty find = lexicalScope.findProperty(key, false); final FindProperty find = lexicalScope.findProperty(key, false);
if (find != null) { if (find != null) {

View file

@ -473,7 +473,7 @@ public final class NativeJSON extends ScriptObject {
if (holder instanceof ScriptObject) { if (holder instanceof ScriptObject) {
return ((ScriptObject)holder).get(key); return ((ScriptObject)holder).get(key);
} else if (holder instanceof JSObject) { } else if (holder instanceof JSObject) {
JSObject jsObj = (JSObject)holder; final JSObject jsObj = (JSObject)holder;
if (key instanceof Integer) { if (key instanceof Integer) {
return jsObj.getSlot((Integer)key); return jsObj.getSlot((Integer)key);
} else { } else {

View file

@ -408,7 +408,7 @@ public class Lexer extends Scanner {
/** /**
* Test if char is a template literal delimiter ('`'). * Test if char is a template literal delimiter ('`').
*/ */
private static boolean isTemplateDelimiter(char ch) { private static boolean isTemplateDelimiter(final char ch) {
return ch == '`'; return ch == '`';
} }
@ -1077,7 +1077,7 @@ public class Lexer extends Scanner {
add(type == TEMPLATE ? TEMPLATE_HEAD : type, stringState.position, stringState.limit); add(type == TEMPLATE ? TEMPLATE_HEAD : type, stringState.position, stringState.limit);
// scan to RBRACE // scan to RBRACE
Lexer expressionLexer = new Lexer(this, saveState()); final Lexer expressionLexer = new Lexer(this, saveState());
expressionLexer.templateExpressionOpenBraces = 1; expressionLexer.templateExpressionOpenBraces = 1;
expressionLexer.lexify(); expressionLexer.lexify();
restoreState(expressionLexer.saveState()); restoreState(expressionLexer.saveState());

View file

@ -632,7 +632,7 @@ public class Parser extends AbstractParser implements Loggable {
return getStatement(false); return getStatement(false);
} }
private Block getStatement(boolean labelledStatement) { private Block getStatement(final boolean labelledStatement) {
if (type == LBRACE) { if (type == LBRACE) {
return getBlock(true); return getBlock(true);
} }
@ -746,28 +746,28 @@ public class Parser extends AbstractParser implements Loggable {
return new BinaryNode(op, lhs, rhs); return new BinaryNode(op, lhs, rhs);
} }
private boolean isDestructuringLhs(Expression lhs) { private boolean isDestructuringLhs(final Expression lhs) {
if (lhs instanceof ObjectNode || lhs instanceof LiteralNode.ArrayLiteralNode) { if (lhs instanceof ObjectNode || lhs instanceof LiteralNode.ArrayLiteralNode) {
return isES6(); return isES6();
} }
return false; return false;
} }
private void verifyDestructuringAssignmentPattern(Expression pattern, String contextString) { private void verifyDestructuringAssignmentPattern(final Expression pattern, final String contextString) {
assert pattern instanceof ObjectNode || pattern instanceof LiteralNode.ArrayLiteralNode; assert pattern instanceof ObjectNode || pattern instanceof LiteralNode.ArrayLiteralNode;
pattern.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { pattern.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
@Override @Override
public boolean enterLiteralNode(LiteralNode<?> literalNode) { public boolean enterLiteralNode(final LiteralNode<?> literalNode) {
if (literalNode.isArray()) { if (literalNode.isArray()) {
boolean restElement = false; boolean restElement = false;
for (Expression element : literalNode.getElementExpressions()) { for (final Expression element : literalNode.getElementExpressions()) {
if (element != null) { if (element != null) {
if (restElement) { if (restElement) {
throw error(String.format("Unexpected element after rest element"), element.getToken()); throw error(String.format("Unexpected element after rest element"), element.getToken());
} }
if (element.isTokenType(SPREAD_ARRAY)) { if (element.isTokenType(SPREAD_ARRAY)) {
restElement = true; restElement = true;
Expression lvalue = ((UnaryNode) element).getExpression(); final Expression lvalue = ((UnaryNode) element).getExpression();
if (!checkValidLValue(lvalue, contextString)) { if (!checkValidLValue(lvalue, contextString)) {
throw error(AbstractParser.message("invalid.lvalue"), lvalue.getToken()); throw error(AbstractParser.message("invalid.lvalue"), lvalue.getToken());
} }
@ -782,12 +782,12 @@ public class Parser extends AbstractParser implements Loggable {
} }
@Override @Override
public boolean enterObjectNode(ObjectNode objectNode) { public boolean enterObjectNode(final ObjectNode objectNode) {
return true; return true;
} }
@Override @Override
public boolean enterPropertyNode(PropertyNode propertyNode) { public boolean enterPropertyNode(final PropertyNode propertyNode) {
if (propertyNode.getValue() != null) { if (propertyNode.getValue() != null) {
propertyNode.getValue().accept(this); propertyNode.getValue().accept(this);
return false; return false;
@ -797,7 +797,7 @@ public class Parser extends AbstractParser implements Loggable {
} }
@Override @Override
public boolean enterIdentNode(IdentNode identNode) { public boolean enterIdentNode(final IdentNode identNode) {
verifyIdent(identNode, contextString); verifyIdent(identNode, contextString);
if (!checkIdentLValue(identNode)) { if (!checkIdentLValue(identNode)) {
referenceError(identNode, null, true); referenceError(identNode, null, true);
@ -807,17 +807,17 @@ public class Parser extends AbstractParser implements Loggable {
} }
@Override @Override
public boolean enterAccessNode(AccessNode accessNode) { public boolean enterAccessNode(final AccessNode accessNode) {
return false; return false;
} }
@Override @Override
public boolean enterIndexNode(IndexNode indexNode) { public boolean enterIndexNode(final IndexNode indexNode) {
return false; return false;
} }
@Override @Override
public boolean enterBinaryNode(BinaryNode binaryNode) { public boolean enterBinaryNode(final BinaryNode binaryNode) {
if (binaryNode.isTokenType(ASSIGN)) { if (binaryNode.isTokenType(ASSIGN)) {
binaryNode.lhs().accept(this); binaryNode.lhs().accept(this);
// Initializer(rhs) can be any AssignmentExpression // Initializer(rhs) can be any AssignmentExpression
@ -828,7 +828,7 @@ public class Parser extends AbstractParser implements Loggable {
} }
@Override @Override
public boolean enterUnaryNode(UnaryNode unaryNode) { public boolean enterUnaryNode(final UnaryNode unaryNode) {
if (unaryNode.isTokenType(SPREAD_ARRAY)) { if (unaryNode.isTokenType(SPREAD_ARRAY)) {
// rest element // rest element
return true; return true;
@ -838,7 +838,7 @@ public class Parser extends AbstractParser implements Loggable {
} }
@Override @Override
protected boolean enterDefault(Node node) { protected boolean enterDefault(final Node node) {
throw error(String.format("unexpected node in AssignmentPattern: %s", node)); throw error(String.format("unexpected node in AssignmentPattern: %s", node));
} }
}); });
@ -1221,13 +1221,13 @@ public class Parser extends AbstractParser implements Loggable {
* class BindingIdentifier[?Yield] ClassTail[?Yield] * class BindingIdentifier[?Yield] ClassTail[?Yield]
* [+Default] class ClassTail[?Yield] * [+Default] class ClassTail[?Yield]
*/ */
private ClassNode classDeclaration(boolean isDefault) { private ClassNode classDeclaration(final boolean isDefault) {
int classLineNumber = line; final int classLineNumber = line;
ClassNode classExpression = classExpression(!isDefault); final ClassNode classExpression = classExpression(!isDefault);
if (!isDefault) { if (!isDefault) {
VarNode classVar = new VarNode(classLineNumber, classExpression.getToken(), classExpression.getIdent().getFinish(), classExpression.getIdent(), classExpression, VarNode.IS_CONST); final VarNode classVar = new VarNode(classLineNumber, classExpression.getToken(), classExpression.getIdent().getFinish(), classExpression.getIdent(), classExpression, VarNode.IS_CONST);
appendStatement(classVar); appendStatement(classVar);
} }
return classExpression; return classExpression;
@ -1237,10 +1237,10 @@ public class Parser extends AbstractParser implements Loggable {
* ClassExpression[Yield] : * ClassExpression[Yield] :
* class BindingIdentifier[?Yield]opt ClassTail[?Yield] * class BindingIdentifier[?Yield]opt ClassTail[?Yield]
*/ */
private ClassNode classExpression(boolean isStatement) { private ClassNode classExpression(final boolean isStatement) {
assert type == CLASS; assert type == CLASS;
int classLineNumber = line; final int classLineNumber = line;
long classToken = token; final long classToken = token;
next(); next();
IdentNode className = null; IdentNode className = null;
@ -1255,7 +1255,7 @@ public class Parser extends AbstractParser implements Loggable {
private final boolean isStatic; private final boolean isStatic;
private final String propertyName; private final String propertyName;
private ClassElementKey(boolean isStatic, String propertyName) { private ClassElementKey(final boolean isStatic, final String propertyName) {
this.isStatic = isStatic; this.isStatic = isStatic;
this.propertyName = propertyName; this.propertyName = propertyName;
} }
@ -1270,9 +1270,9 @@ public class Parser extends AbstractParser implements Loggable {
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(final Object obj) {
if (obj instanceof ClassElementKey) { if (obj instanceof ClassElementKey) {
ClassElementKey other = (ClassElementKey) obj; final ClassElementKey other = (ClassElementKey) obj;
return this.isStatic == other.isStatic && Objects.equals(this.propertyName, other.propertyName); return this.isStatic == other.isStatic && Objects.equals(this.propertyName, other.propertyName);
} }
return false; return false;
@ -1386,7 +1386,7 @@ public class Parser extends AbstractParser implements Loggable {
} }
} }
private PropertyNode createDefaultClassConstructor(int classLineNumber, long classToken, long lastToken, IdentNode className, boolean subclass) { private PropertyNode createDefaultClassConstructor(final int classLineNumber, final long classToken, final long lastToken, final IdentNode className, final boolean subclass) {
final int ctorFinish = finish; final int ctorFinish = finish;
final List<Statement> statements; final List<Statement> statements;
final List<IdentNode> parameters; final List<IdentNode> parameters;
@ -1844,7 +1844,7 @@ public class Parser extends AbstractParser implements Loggable {
final Expression expression = expression(); final Expression expression = expression();
if (expression != null) { if (expression != null) {
ExpressionStatement expressionStatement = new ExpressionStatement(expressionLine, expressionToken, finish, expression); final ExpressionStatement expressionStatement = new ExpressionStatement(expressionLine, expressionToken, finish, expression);
appendStatement(expressionStatement); appendStatement(expressionStatement);
} else { } else {
expect(null); expect(null);
@ -2075,7 +2075,7 @@ public class Parser extends AbstractParser implements Loggable {
private boolean lookaheadIsLetDeclaration(final boolean ofContextualKeyword) { private boolean lookaheadIsLetDeclaration(final boolean ofContextualKeyword) {
assert type == LET; assert type == LET;
for (int i = 1;; i++) { for (int i = 1;; i++) {
TokenType t = T(k + i); final TokenType t = T(k + i);
switch (t) { switch (t) {
case EOL: case EOL:
case COMMENT: case COMMENT:
@ -3076,7 +3076,7 @@ public class Parser extends AbstractParser implements Loggable {
*/ */
private Expression computedPropertyName() { private Expression computedPropertyName() {
expect(LBRACKET); expect(LBRACKET);
Expression expression = assignmentExpression(false); final Expression expression = assignmentExpression(false);
expect(RBRACKET); expect(RBRACKET);
return expression; return expression;
} }
@ -3285,11 +3285,11 @@ public class Parser extends AbstractParser implements Loggable {
return new PropertyFunction(propertyName, function, computed); return new PropertyFunction(propertyName, function, computed);
} }
private PropertyFunction propertyMethodFunction(Expression key, final long methodToken, final int methodLine, final boolean generator, final int flags, boolean computed) { private PropertyFunction propertyMethodFunction(final Expression key, final long methodToken, final int methodLine, final boolean generator, final int flags, final boolean computed) {
final String methodName = key instanceof PropertyKey ? ((PropertyKey) key).getPropertyName() : getDefaultValidFunctionName(methodLine, false); final String methodName = key instanceof PropertyKey ? ((PropertyKey) key).getPropertyName() : getDefaultValidFunctionName(methodLine, false);
final IdentNode methodNameNode = createIdentNode(((Node)key).getToken(), finish, methodName); final IdentNode methodNameNode = createIdentNode(((Node)key).getToken(), finish, methodName);
FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL; final FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL;
final ParserContextFunctionNode functionNode = createParserContextFunctionNode(methodNameNode, methodToken, functionKind, methodLine, null); final ParserContextFunctionNode functionNode = createParserContextFunctionNode(methodNameNode, methodToken, functionKind, methodLine, null);
functionNode.setFlag(flags); functionNode.setFlag(flags);
if (computed) { if (computed) {
@ -3548,7 +3548,7 @@ public class Parser extends AbstractParser implements Loggable {
if (isES6()) { if (isES6()) {
final ParserContextFunctionNode currentFunction = getCurrentNonArrowFunction(); final ParserContextFunctionNode currentFunction = getCurrentNonArrowFunction();
if (currentFunction.isMethod()) { if (currentFunction.isMethod()) {
long identToken = Token.recast(token, IDENT); final long identToken = Token.recast(token, IDENT);
next(); next();
lhs = createIdentNode(identToken, finish, SUPER.getName()); lhs = createIdentNode(identToken, finish, SUPER.getName());
@ -3766,7 +3766,7 @@ public class Parser extends AbstractParser implements Loggable {
isAnonymous = true; isAnonymous = true;
} }
FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL; final FunctionNode.Kind functionKind = generator ? FunctionNode.Kind.GENERATOR : FunctionNode.Kind.NORMAL;
List<IdentNode> parameters = Collections.emptyList(); List<IdentNode> parameters = Collections.emptyList();
final ParserContextFunctionNode functionNode = createParserContextFunctionNode(name, functionToken, functionKind, functionLine, parameters); final ParserContextFunctionNode functionNode = createParserContextFunctionNode(name, functionToken, functionKind, functionLine, parameters);
lc.push(functionNode); lc.push(functionNode);
@ -3870,7 +3870,7 @@ public class Parser extends AbstractParser implements Loggable {
} }
} }
private static Block maybeWrapBodyInParameterBlock(Block functionBody, ParserContextBlockNode parameterBlock) { private static Block maybeWrapBodyInParameterBlock(final Block functionBody, final ParserContextBlockNode parameterBlock) {
assert functionBody.isFunctionBody(); assert functionBody.isFunctionBody();
if (!parameterBlock.getStatements().isEmpty()) { if (!parameterBlock.getStatements().isEmpty()) {
parameterBlock.appendStatement(new BlockStatement(functionBody)); parameterBlock.appendStatement(new BlockStatement(functionBody));
@ -4006,26 +4006,26 @@ public class Parser extends AbstractParser implements Loggable {
} }
// default parameter // default parameter
Expression initializer = assignmentExpression(false); final Expression initializer = assignmentExpression(false);
ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) { if (currentFunction != null) {
if (env._parse_only) { if (env._parse_only) {
// keep what is seen in source "as is" and save it as parameter expression // keep what is seen in source "as is" and save it as parameter expression
BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, initializer); final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, initializer);
currentFunction.addParameterExpression(ident, assignment); currentFunction.addParameterExpression(ident, assignment);
} else { } else {
// desugar to: param = (param === undefined) ? initializer : param; // desugar to: param = (param === undefined) ? initializer : param;
// possible alternative: if (param === undefined) param = initializer; // possible alternative: if (param === undefined) param = initializer;
BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); final TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value); final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value);
lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
} }
} }
} }
ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) { if (currentFunction != null) {
currentFunction.addParameterBinding(ident); currentFunction.addParameterBinding(ident);
if (ident.isRestParameter() || ident.isDefaultParameter()) { if (ident.isRestParameter() || ident.isDefaultParameter()) {
@ -4044,22 +4044,22 @@ public class Parser extends AbstractParser implements Loggable {
ident = ident.setIsDefaultParameter(); ident = ident.setIsDefaultParameter();
// binding pattern with initializer. desugar to: (param === undefined) ? initializer : param // binding pattern with initializer. desugar to: (param === undefined) ? initializer : param
Expression initializer = assignmentExpression(false); final Expression initializer = assignmentExpression(false);
if (env._parse_only) { if (env._parse_only) {
// we don't want the synthetic identifier in parse only mode // we don't want the synthetic identifier in parse only mode
value = initializer; value = initializer;
} else { } else {
// TODO initializer must not contain yield expression if yield=true (i.e. this is generator function's parameter list) // TODO initializer must not contain yield expression if yield=true (i.e. this is generator function's parameter list)
BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
} }
} }
ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) { if (currentFunction != null) {
// destructuring assignment // destructuring assignment
BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), pattern, value); final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), pattern, value);
if (env._parse_only) { if (env._parse_only) {
// in parse-only mode, represent source tree "as is" // in parse-only mode, represent source tree "as is"
if (ident.isDefaultParameter()) { if (ident.isDefaultParameter()) {
@ -4081,10 +4081,10 @@ public class Parser extends AbstractParser implements Loggable {
private void verifyDestructuringParameterBindingPattern(final Expression pattern, final long paramToken, final int paramLine, final String contextString) { private void verifyDestructuringParameterBindingPattern(final Expression pattern, final long paramToken, final int paramLine, final String contextString) {
verifyDestructuringBindingPattern(pattern, new Consumer<IdentNode>() { verifyDestructuringBindingPattern(pattern, new Consumer<IdentNode>() {
public void accept(IdentNode identNode) { public void accept(final IdentNode identNode) {
verifyIdent(identNode, contextString); verifyIdent(identNode, contextString);
ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) { if (currentFunction != null) {
// declare function-scope variables for destructuring bindings // declare function-scope variables for destructuring bindings
if (!env._parse_only) { if (!env._parse_only) {
@ -4398,7 +4398,7 @@ public class Parser extends AbstractParser implements Loggable {
break; break;
} }
Expression expression = leftHandSideExpression(); final Expression expression = leftHandSideExpression();
if (last != EOL) { if (last != EOL) {
switch (type) { switch (type) {
@ -4549,7 +4549,7 @@ public class Parser extends AbstractParser implements Loggable {
private Expression expression(final boolean noIn) { private Expression expression(final boolean noIn) {
Expression assignmentExpression = assignmentExpression(noIn); Expression assignmentExpression = assignmentExpression(noIn);
while (type == COMMARIGHT) { while (type == COMMARIGHT) {
long commaToken = token; final long commaToken = token;
next(); next();
boolean rhsRestParameter = false; boolean rhsRestParameter = false;
@ -4707,7 +4707,7 @@ public class Parser extends AbstractParser implements Loggable {
/** /**
* Is type one of {@code = *= /= %= += -= <<= >>= >>>= &= ^= |=}? * Is type one of {@code = *= /= %= += -= <<= >>= >>>= &= ^= |=}?
*/ */
private static boolean isAssignmentOperator(TokenType type) { private static boolean isAssignmentOperator(final TokenType type) {
switch (type) { switch (type) {
case ASSIGN: case ASSIGN:
case ASSIGN_ADD: case ASSIGN_ADD:
@ -4729,7 +4729,7 @@ public class Parser extends AbstractParser implements Loggable {
/** /**
* ConditionalExpression. * ConditionalExpression.
*/ */
private Expression conditionalExpression(boolean noIn) { private Expression conditionalExpression(final boolean noIn) {
return expression(TERNARY.getPrecedence(), noIn); return expression(TERNARY.getPrecedence(), noIn);
} }
@ -4752,7 +4752,7 @@ public class Parser extends AbstractParser implements Loggable {
lc.push(functionNode); lc.push(functionNode);
try { try {
ParserContextBlockNode parameterBlock = newBlock(); final ParserContextBlockNode parameterBlock = newBlock();
final List<IdentNode> parameters; final List<IdentNode> parameters;
try { try {
parameters = convertArrowFunctionParameterList(paramListExpr, functionLine); parameters = convertArrowFunctionParameterList(paramListExpr, functionLine);
@ -4829,12 +4829,12 @@ public class Parser extends AbstractParser implements Loggable {
return parameters; return parameters;
} }
private IdentNode verifyArrowParameter(Expression param, int index, int paramLine) { private IdentNode verifyArrowParameter(final Expression param, final int index, final int paramLine) {
final String contextString = "function parameter"; final String contextString = "function parameter";
if (param instanceof IdentNode) { if (param instanceof IdentNode) {
IdentNode ident = (IdentNode)param; final IdentNode ident = (IdentNode)param;
verifyStrictIdent(ident, contextString); verifyStrictIdent(ident, contextString);
ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) { if (currentFunction != null) {
currentFunction.addParameterBinding(ident); currentFunction.addParameterBinding(ident);
} }
@ -4842,21 +4842,21 @@ public class Parser extends AbstractParser implements Loggable {
} }
if (param.isTokenType(ASSIGN)) { if (param.isTokenType(ASSIGN)) {
Expression lhs = ((BinaryNode) param).lhs(); final Expression lhs = ((BinaryNode) param).lhs();
long paramToken = lhs.getToken(); final long paramToken = lhs.getToken();
Expression initializer = ((BinaryNode) param).rhs(); final Expression initializer = ((BinaryNode) param).rhs();
if (lhs instanceof IdentNode) { if (lhs instanceof IdentNode) {
// default parameter // default parameter
IdentNode ident = (IdentNode) lhs; final IdentNode ident = (IdentNode) lhs;
ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) { if (currentFunction != null) {
if (env._parse_only) { if (env._parse_only) {
currentFunction.addParameterExpression(ident, param); currentFunction.addParameterExpression(ident, param);
} else { } else {
BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); final TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value); final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), ident, value);
lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
} }
@ -4867,17 +4867,17 @@ public class Parser extends AbstractParser implements Loggable {
} else if (isDestructuringLhs(lhs)) { } else if (isDestructuringLhs(lhs)) {
// binding pattern with initializer // binding pattern with initializer
// Introduce synthetic temporary parameter to capture the object to be destructured. // Introduce synthetic temporary parameter to capture the object to be destructured.
IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter().setIsDefaultParameter(); final IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter().setIsDefaultParameter();
verifyDestructuringParameterBindingPattern(param, paramToken, paramLine, contextString); verifyDestructuringParameterBindingPattern(param, paramToken, paramLine, contextString);
ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) { if (currentFunction != null) {
if (env._parse_only) { if (env._parse_only) {
currentFunction.addParameterExpression(ident, param); currentFunction.addParameterExpression(ident, param);
} else { } else {
BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish)); final BinaryNode test = new BinaryNode(Token.recast(paramToken, EQ_STRICT), ident, newUndefinedLiteral(paramToken, finish));
TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident)); final TernaryNode value = new TernaryNode(Token.recast(paramToken, TERNARY), test, new JoinPredecessorExpression(initializer), new JoinPredecessorExpression(ident));
BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, value); final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, value);
lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
} }
} }
@ -4885,18 +4885,18 @@ public class Parser extends AbstractParser implements Loggable {
} }
} else if (isDestructuringLhs(param)) { } else if (isDestructuringLhs(param)) {
// binding pattern // binding pattern
long paramToken = param.getToken(); final long paramToken = param.getToken();
// Introduce synthetic temporary parameter to capture the object to be destructured. // Introduce synthetic temporary parameter to capture the object to be destructured.
IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter(); final IdentNode ident = createIdentNode(paramToken, param.getFinish(), String.format("arguments[%d]", index)).setIsDestructuredParameter();
verifyDestructuringParameterBindingPattern(param, paramToken, paramLine, contextString); verifyDestructuringParameterBindingPattern(param, paramToken, paramLine, contextString);
ParserContextFunctionNode currentFunction = lc.getCurrentFunction(); final ParserContextFunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction != null) { if (currentFunction != null) {
if (env._parse_only) { if (env._parse_only) {
currentFunction.addParameterExpression(ident, param); currentFunction.addParameterExpression(ident, param);
} else { } else {
BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, ident); final BinaryNode assignment = new BinaryNode(Token.recast(paramToken, ASSIGN), param, ident);
lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment)); lc.getFunctionBody(currentFunction).appendStatement(new ExpressionStatement(paramLine, assignment.getToken(), assignment.getFinish(), assignment));
} }
} }
@ -4913,7 +4913,7 @@ public class Parser extends AbstractParser implements Loggable {
return true; return true;
} }
for (int i = k - 1; i >= 0; i--) { for (int i = k - 1; i >= 0; i--) {
TokenType t = T(i); final TokenType t = T(i);
switch (t) { switch (t) {
case RPAREN: case RPAREN:
case IDENT: case IDENT:
@ -4941,7 +4941,7 @@ public class Parser extends AbstractParser implements Loggable {
// find IDENT, RPAREN, ARROW, in that order, skipping over EOL (where allowed) and COMMENT // find IDENT, RPAREN, ARROW, in that order, skipping over EOL (where allowed) and COMMENT
int i = 1; int i = 1;
for (;;) { for (;;) {
TokenType t = T(k + i++); final TokenType t = T(k + i++);
if (t == IDENT) { if (t == IDENT) {
break; break;
} else if (t == EOL || t == COMMENT) { } else if (t == EOL || t == COMMENT) {
@ -4951,7 +4951,7 @@ public class Parser extends AbstractParser implements Loggable {
} }
} }
for (;;) { for (;;) {
TokenType t = T(k + i++); final TokenType t = T(k + i++);
if (t == RPAREN) { if (t == RPAREN) {
break; break;
} else if (t == EOL || t == COMMENT) { } else if (t == EOL || t == COMMENT) {
@ -4961,7 +4961,7 @@ public class Parser extends AbstractParser implements Loggable {
} }
} }
for (;;) { for (;;) {
TokenType t = T(k + i++); final TokenType t = T(k + i++);
if (t == ARROW) { if (t == ARROW) {
break; break;
} else if (t == COMMENT) { } else if (t == COMMENT) {
@ -5008,7 +5008,7 @@ public class Parser extends AbstractParser implements Loggable {
} }
if (env._parse_only) { if (env._parse_only) {
List<Expression> exprs = new ArrayList<>(); final List<Expression> exprs = new ArrayList<>();
exprs.add(literal); exprs.add(literal);
TokenType lastLiteralType; TokenType lastLiteralType;
do { do {
@ -5096,12 +5096,12 @@ public class Parser extends AbstractParser implements Loggable {
* ModuleItemList * ModuleItemList
*/ */
private FunctionNode module(final String moduleName) { private FunctionNode module(final String moduleName) {
boolean oldStrictMode = isStrictMode; final boolean oldStrictMode = isStrictMode;
try { try {
isStrictMode = true; // Module code is always strict mode code. (ES6 10.2.1) isStrictMode = true; // Module code is always strict mode code. (ES6 10.2.1)
// Make a pseudo-token for the script holding its start and length. // Make a pseudo-token for the script holding its start and length.
int functionStart = Math.min(Token.descPosition(Token.withDelimiter(token)), finish); final int functionStart = Math.min(Token.descPosition(Token.withDelimiter(token)), finish);
final long functionToken = Token.toDesc(FUNCTION, functionStart, source.getLength() - functionStart); final long functionToken = Token.toDesc(FUNCTION, functionStart, source.getLength() - functionStart);
final int functionLine = line; final int functionLine = line;
@ -5214,7 +5214,7 @@ public class Parser extends AbstractParser implements Loggable {
} else if (isBindingIdentifier()) { } else if (isBindingIdentifier()) {
// ImportedDefaultBinding // ImportedDefaultBinding
final IdentNode importedDefaultBinding = bindingIdentifier("ImportedBinding"); final IdentNode importedDefaultBinding = bindingIdentifier("ImportedBinding");
Module.ImportEntry defaultImport = Module.ImportEntry.importSpecifier(importedDefaultBinding, startPosition, finish); final Module.ImportEntry defaultImport = Module.ImportEntry.importSpecifier(importedDefaultBinding, startPosition, finish);
if (type == COMMARIGHT) { if (type == COMMARIGHT) {
next(); next();
@ -5279,7 +5279,7 @@ public class Parser extends AbstractParser implements Loggable {
private List<Module.ImportEntry> namedImports(final int startPosition) { private List<Module.ImportEntry> namedImports(final int startPosition) {
assert type == LBRACE; assert type == LBRACE;
next(); next();
List<Module.ImportEntry> importEntries = new ArrayList<>(); final List<Module.ImportEntry> importEntries = new ArrayList<>();
while (type != RBRACE) { while (type != RBRACE) {
final boolean bindingIdentifier = isBindingIdentifier(); final boolean bindingIdentifier = isBindingIdentifier();
final long nameToken = token; final long nameToken = token;
@ -5354,11 +5354,11 @@ public class Parser extends AbstractParser implements Loggable {
if (type == IDENT && "from".equals(getValue())) { if (type == IDENT && "from".equals(getValue())) {
final IdentNode moduleRequest = fromClause(); final IdentNode moduleRequest = fromClause();
module.addModuleRequest(moduleRequest); module.addModuleRequest(moduleRequest);
for (Module.ExportEntry exportEntry : exportEntries) { for (final Module.ExportEntry exportEntry : exportEntries) {
module.addIndirectExportEntry(exportEntry.withFrom(moduleRequest, finish)); module.addIndirectExportEntry(exportEntry.withFrom(moduleRequest, finish));
} }
} else { } else {
for (Module.ExportEntry exportEntry : exportEntries) { for (final Module.ExportEntry exportEntry : exportEntries) {
module.addLocalExportEntry(exportEntry); module.addLocalExportEntry(exportEntry);
} }
} }
@ -5445,7 +5445,7 @@ public class Parser extends AbstractParser implements Loggable {
private List<Module.ExportEntry> exportClause(final int startPosition) { private List<Module.ExportEntry> exportClause(final int startPosition) {
assert type == LBRACE; assert type == LBRACE;
next(); next();
List<Module.ExportEntry> exports = new ArrayList<>(); final List<Module.ExportEntry> exports = new ArrayList<>();
while (type != RBRACE) { while (type != RBRACE) {
final IdentNode localName = getIdentifierName(); final IdentNode localName = getIdentifierName();
if (type == IDENT && "as".equals(getValue())) { if (type == IDENT && "as".equals(getValue())) {

View file

@ -169,7 +169,7 @@ class ParserContextFunctionNode extends ParserContextBaseNode {
return parameters; return parameters;
} }
void setParameters(List<IdentNode> parameters) { void setParameters(final List<IdentNode> parameters) {
this.parameters = parameters; this.parameters = parameters;
} }
@ -182,7 +182,7 @@ class ParserContextFunctionNode extends ParserContextBaseNode {
return parameterExpressions; return parameterExpressions;
} }
void addParameterExpression(IdentNode ident, Expression node) { void addParameterExpression(final IdentNode ident, final Expression node) {
if (parameterExpressions == null) { if (parameterExpressions == null) {
parameterExpressions = new HashMap<>(); parameterExpressions = new HashMap<>();
} }

View file

@ -41,11 +41,11 @@ class ParserContextModuleNode extends ParserContextBaseNode {
/** Module name. */ /** Module name. */
private final String name; private final String name;
private List<String> requestedModules = new ArrayList<>(); private final List<String> requestedModules = new ArrayList<>();
private List<ImportEntry> importEntries = new ArrayList<>(); private final List<ImportEntry> importEntries = new ArrayList<>();
private List<ExportEntry> localExportEntries = new ArrayList<>(); private final List<ExportEntry> localExportEntries = new ArrayList<>();
private List<ExportEntry> indirectExportEntries = new ArrayList<>(); private final List<ExportEntry> indirectExportEntries = new ArrayList<>();
private List<ExportEntry> starExportEntries = new ArrayList<>(); private final List<ExportEntry> starExportEntries = new ArrayList<>();
/** /**
* Constructor. * Constructor.

View file

@ -141,7 +141,7 @@ final public class AllocationStrategy implements Serializable {
final private WeakReference<ScriptObject> prototype; final private WeakReference<ScriptObject> prototype;
final private WeakReference<PropertyMap> prototypeMap; final private WeakReference<PropertyMap> prototypeMap;
private PropertyMap allocatorMap; private final PropertyMap allocatorMap;
AllocatorMap(final ScriptObject prototype, final PropertyMap protoMap, final PropertyMap allocMap) { AllocatorMap(final ScriptObject prototype, final PropertyMap protoMap, final PropertyMap allocMap) {
this.prototype = new WeakReference<>(prototype); this.prototype = new WeakReference<>(prototype);

View file

@ -148,14 +148,14 @@ class CommandExecutor {
boolean check(String token, final Iterator<String> iterator, final String cwd) { boolean check(String token, final Iterator<String> iterator, final String cwd) {
// Iterate through redirect prefixes to file a match. // Iterate through redirect prefixes to file a match.
for (int i = 0; i < redirectPrefixes.length; i++) { for (int i = 0; i < redirectPrefixes.length; i++) {
String prefix = redirectPrefixes[i]; final String prefix = redirectPrefixes[i];
// If a match is found. // If a match is found.
if (token.startsWith(prefix)) { if (token.startsWith(prefix)) {
// Indicate we have at least one redirect (efficiency.) // Indicate we have at least one redirect (efficiency.)
hasRedirects = true; hasRedirects = true;
// Map prefix to RedirectType. // Map prefix to RedirectType.
RedirectType redirect = redirects[i]; final RedirectType redirect = redirects[i];
// Strip prefix from token // Strip prefix from token
token = token.substring(prefix.length()); token = token.substring(prefix.length());
@ -223,8 +223,8 @@ class CommandExecutor {
// Only if there was redirects (saves new structure in ProcessBuilder.) // Only if there was redirects (saves new structure in ProcessBuilder.)
if (hasRedirects) { if (hasRedirects) {
// If output and error are the same file then merge. // If output and error are the same file then merge.
File outputFile = outputRedirect.file(); final File outputFile = outputRedirect.file();
File errorFile = errorRedirect.file(); final File errorFile = errorRedirect.file();
if (outputFile != null && outputFile.equals(errorFile)) { if (outputFile != null && outputFile.equals(errorFile)) {
mergeError = true; mergeError = true;
@ -274,26 +274,26 @@ class CommandExecutor {
public void run() { public void run() {
try { try {
// Buffer for copying. // Buffer for copying.
byte[] b = new byte[BUFFER_SIZE]; final byte[] b = new byte[BUFFER_SIZE];
// Read from the InputStream until EOF. // Read from the InputStream until EOF.
int read; int read;
while (-1 < (read = input.read(b, 0, b.length))) { while (-1 < (read = input.read(b, 0, b.length))) {
// Write available date to OutputStream. // Write available date to OutputStream.
output.write(b, 0, read); output.write(b, 0, read);
} }
} catch (Exception e) { } catch (final Exception e) {
// Assume the worst. // Assume the worst.
throw new RuntimeException("Broken pipe", e); throw new RuntimeException("Broken pipe", e);
} finally { } finally {
// Make sure the streams are closed. // Make sure the streams are closed.
try { try {
input.close(); input.close();
} catch (IOException e) { } catch (final IOException e) {
// Don't care. // Don't care.
} }
try { try {
output.close(); output.close();
} catch (IOException e) { } catch (final IOException e) {
// Don't care. // Don't care.
} }
} }
@ -363,7 +363,7 @@ class CommandExecutor {
private long envVarLongValue(final String key) { private long envVarLongValue(final String key) {
try { try {
return Long.parseLong(envVarValue(key, "0")); return Long.parseLong(envVarValue(key, "0"));
} catch (NumberFormatException ex) { } catch (final NumberFormatException ex) {
return 0L; return 0L;
} }
} }
@ -478,7 +478,7 @@ class CommandExecutor {
// iterate through all tokens. // iterate through all tokens.
final Iterator<String> iterator = tokens.iterator(); final Iterator<String> iterator = tokens.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
String token = iterator.next(); final String token = iterator.next();
// Check if is a redirect. // Check if is a redirect.
if (redirectInfo.check(token, iterator, cwd)) { if (redirectInfo.check(token, iterator, cwd)) {
@ -551,7 +551,7 @@ class CommandExecutor {
* @param tokens tokens of the command * @param tokens tokens of the command
* @param isPiped true if the output of this command should be piped to the next * @param isPiped true if the output of this command should be piped to the next
*/ */
private void command(final List<String> tokens, boolean isPiped) { private void command(final List<String> tokens, final boolean isPiped) {
// Test to see if we should echo the command to output. // Test to see if we should echo the command to output.
if (envVarBooleanValue("JJS_ECHO")) { if (envVarBooleanValue("JJS_ECHO")) {
System.out.println(String.join(" ", tokens)); System.out.println(String.join(" ", tokens));
@ -584,7 +584,7 @@ class CommandExecutor {
boolean inputIsPipe = firstProcessBuilder.redirectInput() == Redirect.PIPE; boolean inputIsPipe = firstProcessBuilder.redirectInput() == Redirect.PIPE;
boolean outputIsPipe = lastProcessBuilder.redirectOutput() == Redirect.PIPE; boolean outputIsPipe = lastProcessBuilder.redirectOutput() == Redirect.PIPE;
boolean errorIsPipe = lastProcessBuilder.redirectError() == Redirect.PIPE; boolean errorIsPipe = lastProcessBuilder.redirectError() == Redirect.PIPE;
boolean inheritIO = envVarBooleanValue("JJS_INHERIT_IO"); final boolean inheritIO = envVarBooleanValue("JJS_INHERIT_IO");
// If not redirected and inputStream is current processes' input. // If not redirected and inputStream is current processes' input.
if (inputIsPipe && (inheritIO || inputStream == System.in)) { if (inputIsPipe && (inheritIO || inputStream == System.in)) {
@ -609,10 +609,10 @@ class CommandExecutor {
// Start the processes. // Start the processes.
final List<Process> processes = new ArrayList<>(); final List<Process> processes = new ArrayList<>();
for (ProcessBuilder pb : processBuilders) { for (final ProcessBuilder pb : processBuilders) {
try { try {
processes.add(pb.start()); processes.add(pb.start());
} catch (IOException ex) { } catch (final IOException ex) {
reportError("unknown.command", String.join(" ", pb.command())); reportError("unknown.command", String.join(" ", pb.command()));
return; return;
} }
@ -701,7 +701,7 @@ class CommandExecutor {
// Accumulate the output and error streams. // Accumulate the output and error streams.
outputString += byteOutputStream != null ? byteOutputStream.toString() : ""; outputString += byteOutputStream != null ? byteOutputStream.toString() : "";
errorString += byteErrorStream != null ? byteErrorStream.toString() : ""; errorString += byteErrorStream != null ? byteErrorStream.toString() : "";
} catch (InterruptedException ex) { } catch (final InterruptedException ex) {
// Kill any living processes. // Kill any living processes.
processes.stream().forEach(p -> { processes.stream().forEach(p -> {
if (p.isAlive()) { if (p.isAlive()) {
@ -829,7 +829,7 @@ class CommandExecutor {
final Iterator<String> iterator = tokens.iterator(); final Iterator<String> iterator = tokens.iterator();
while (iterator.hasNext() && exitCode == EXIT_SUCCESS) { while (iterator.hasNext() && exitCode == EXIT_SUCCESS) {
// Next word token. // Next word token.
String token = iterator.next(); final String token = iterator.next();
if (token == null) { if (token == null) {
continue; continue;
@ -876,23 +876,23 @@ class CommandExecutor {
return exitCode; return exitCode;
} }
void setEnvironment(Map<String, String> environment) { void setEnvironment(final Map<String, String> environment) {
this.environment = environment; this.environment = environment;
} }
void setInputStream(InputStream inputStream) { void setInputStream(final InputStream inputStream) {
this.inputStream = inputStream; this.inputStream = inputStream;
} }
void setInputString(String inputString) { void setInputString(final String inputString) {
this.inputString = inputString; this.inputString = inputString;
} }
void setOutputStream(OutputStream outputStream) { void setOutputStream(final OutputStream outputStream) {
this.outputStream = outputStream; this.outputStream = outputStream;
} }
void setErrorStream(OutputStream errorStream) { void setErrorStream(final OutputStream errorStream) {
this.errorStream = errorStream; this.errorStream = errorStream;
} }
} }

View file

@ -1339,7 +1339,7 @@ public final class Context {
final ModuleFinder finder = new ModuleFinder() { final ModuleFinder finder = new ModuleFinder() {
@Override @Override
public Optional<ModuleReference> find(String name) { public Optional<ModuleReference> find(final String name) {
if (name.equals(mn)) { if (name.equals(mn)) {
return Optional.of(mref); return Optional.of(mref);
} else { } else {
@ -1387,7 +1387,7 @@ public final class Context {
ClassLoader loader = null; ClassLoader loader = null;
try { try {
loader = clazz.getClassLoader(); loader = clazz.getClassLoader();
} catch (SecurityException ignored) { } catch (final SecurityException ignored) {
// This could fail because of anonymous classes being used. // This could fail because of anonymous classes being used.
// Accessing loader of anonymous class fails (for extension // Accessing loader of anonymous class fails (for extension
// loader class too?). In any case, for us fetching Context // loader class too?). In any case, for us fetching Context

View file

@ -87,7 +87,7 @@ final class FinalScriptFunctionData extends ScriptFunctionData {
@Override @Override
String getDocumentation() { String getDocumentation() {
String doc = docKey != null? final String doc = docKey != null?
FunctionDocumentation.getDoc(docKey) : null; FunctionDocumentation.getDoc(docKey) : null;
return doc != null? doc : super.getDocumentation(); return doc != null? doc : super.getDocumentation();
} }
@ -109,7 +109,7 @@ final class FinalScriptFunctionData extends ScriptFunctionData {
} }
@Override @Override
CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, boolean linkLogicOkay) { CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, final boolean linkLogicOkay) {
assert isValidCallSite(callSiteType) : callSiteType; assert isValidCallSite(callSiteType) : callSiteType;
CompiledFunction best = null; CompiledFunction best = null;

View file

@ -155,7 +155,7 @@ public final class JSONListAdapter extends ListAdapter implements JSObject {
} }
@Override @Override
public Object getDefaultValue(Class<?> hint) throws UnsupportedOperationException { public Object getDefaultValue(final Class<?> hint) throws UnsupportedOperationException {
return obj.getDefaultValue(hint); return obj.getDefaultValue(hint);
} }
} }

View file

@ -221,7 +221,7 @@ abstract class NashornLoader extends SecureClassLoader {
final String res = "/"+ MODULE_MANIPULATOR_NAME.replace('.', '/') + ".class"; final String res = "/"+ MODULE_MANIPULATOR_NAME.replace('.', '/') + ".class";
try (InputStream in = NashornLoader.class.getResourceAsStream(res)) { try (InputStream in = NashornLoader.class.getResourceAsStream(res)) {
return in.readAllBytes(); return in.readAllBytes();
} catch (IOException exp) { } catch (final IOException exp) {
throw new UncheckedIOException(exp); throw new UncheckedIOException(exp);
} }
}; };

View file

@ -95,7 +95,7 @@ final class ScriptLoader extends NashornLoader {
} }
@Override @Override
protected Class<?> findClass(String name) throws ClassNotFoundException { protected Class<?> findClass(final String name) throws ClassNotFoundException {
final ClassLoader appLoader = context.getAppLoader(); final ClassLoader appLoader = context.getAppLoader();
/* /*

View file

@ -149,7 +149,7 @@ public final class ScriptingFunctions {
String inputString = null; String inputString = null;
if (arg0 instanceof NativeArray) { if (arg0 instanceof NativeArray) {
String[] array = (String[])JSType.toJavaArray(arg0, String.class); final String[] array = (String[])JSType.toJavaArray(arg0, String.class);
tokens = new ArrayList<>(); tokens = new ArrayList<>();
tokens.addAll(Arrays.asList(array)); tokens.addAll(Arrays.asList(array));
} else { } else {
@ -206,7 +206,7 @@ public final class ScriptingFunctions {
final String outString = executor.getOutputString(); final String outString = executor.getOutputString();
final String errString = executor.getErrorString(); final String errString = executor.getErrorString();
int exitCode = executor.getExitCode(); final int exitCode = executor.getExitCode();
// Set globals for secondary results. // Set globals for secondary results.
global.set(OUT_NAME, outString, 0); global.set(OUT_NAME, outString, 0);
@ -222,7 +222,7 @@ public final class ScriptingFunctions {
private static Function<String, String> readLineHelper; private static Function<String, String> readLineHelper;
public static void setReadLineHelper(Function<String, String> func) { public static void setReadLineHelper(final Function<String, String> func) {
readLineHelper = Objects.requireNonNull(func); readLineHelper = Objects.requireNonNull(func);
} }

View file

@ -183,7 +183,7 @@ public final class WithObject extends Scope {
* @return FindPropertyData or null if not found. * @return FindPropertyData or null if not found.
*/ */
@Override @Override
protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) { protected FindProperty findProperty(final Object key, final boolean deep, final boolean isScope, final ScriptObject start) {
// We call findProperty on 'expression' with 'expression' itself as start parameter. // We call findProperty on 'expression' with 'expression' itself as start parameter.
// This way in ScriptObject.setObject we can tell the property is from a 'with' expression // This way in ScriptObject.setObject we can tell the property is from a 'with' expression
// (as opposed from another non-scope object in the proto chain such as Object.prototype). // (as opposed from another non-scope object in the proto chain such as Object.prototype).

View file

@ -76,7 +76,7 @@ class Bignum {
// grow. There are no checks if the stack-allocated space is sufficient. // grow. There are no checks if the stack-allocated space is sufficient.
static final int kBigitCapacity = kMaxSignificantBits / kBigitSize; static final int kBigitCapacity = kMaxSignificantBits / kBigitSize;
private int[] bigits_ = new int[kBigitCapacity]; private final int[] bigits_ = new int[kBigitCapacity];
// A vector backed by bigits_buffer_. This way accesses to the array are // A vector backed by bigits_buffer_. This way accesses to the array are
// checked for out-of-bounds errors. // checked for out-of-bounds errors.
// Vector<int> bigits_; // Vector<int> bigits_;

View file

@ -214,7 +214,7 @@ public class LinkerCallSite extends ChainedCallSite {
// new target uses a more precise 'self' type than Object.class. We need to // new target uses a more precise 'self' type than Object.class. We need to
// convert the filter type. Note that the profileEntry method returns "self" // convert the filter type. Note that the profileEntry method returns "self"
// argument "as is" and so the cast introduced will succeed for any type. // argument "as is" and so the cast introduced will succeed for any type.
MethodType selfFilterType = MethodType.methodType(newSelfType, newSelfType); final MethodType selfFilterType = MethodType.methodType(newSelfType, newSelfType);
selfFilter = selfFilter.asType(selfFilterType); selfFilter = selfFilter.asType(selfFilterType);
} }

View file

@ -283,7 +283,7 @@ public final class NameCodec {
* @return the mangled form of the symbolic name. * @return the mangled form of the symbolic name.
*/ */
public static String encode(final String name) { public static String encode(final String name) {
String bn = mangle(name); final String bn = mangle(name);
assert((Object)bn == name || looksMangled(bn)) : bn; assert((Object)bn == name || looksMangled(bn)) : bn;
assert(name.equals(decode(bn))) : name; assert(name.equals(decode(bn))) : name;
return bn; return bn;
@ -303,11 +303,11 @@ public final class NameCodec {
return sn; return sn;
} }
private static boolean looksMangled(String s) { private static boolean looksMangled(final String s) {
return s.charAt(0) == ESCAPE_C; return s.charAt(0) == ESCAPE_C;
} }
private static String mangle(String s) { private static String mangle(final String s) {
if (s.length() == 0) if (s.length() == 0)
return NULL_ESCAPE; return NULL_ESCAPE;
@ -315,12 +315,12 @@ public final class NameCodec {
StringBuilder sb = null; StringBuilder sb = null;
for (int i = 0, slen = s.length(); i < slen; i++) { for (int i = 0, slen = s.length(); i < slen; i++) {
char c = s.charAt(i); final char c = s.charAt(i);
boolean needEscape = false; boolean needEscape = false;
if (c == ESCAPE_C) { if (c == ESCAPE_C) {
if (i+1 < slen) { if (i+1 < slen) {
char c1 = s.charAt(i+1); final char c1 = s.charAt(i+1);
if ((i == 0 && c1 == NULL_ESCAPE_C) if ((i == 0 && c1 == NULL_ESCAPE_C)
|| c1 != originalOfReplacement(c1)) { || c1 != originalOfReplacement(c1)) {
// an accidental escape // an accidental escape
@ -356,7 +356,7 @@ public final class NameCodec {
return s; return s;
} }
private static String demangle(String s) { private static String demangle(final String s) {
// build this lazily, when we first meet an escape: // build this lazily, when we first meet an escape:
StringBuilder sb = null; StringBuilder sb = null;
@ -369,8 +369,8 @@ public final class NameCodec {
if (c == ESCAPE_C && i+1 < slen) { if (c == ESCAPE_C && i+1 < slen) {
// might be an escape sequence // might be an escape sequence
char rc = s.charAt(i+1); final char rc = s.charAt(i+1);
char oc = originalOfReplacement(rc); final char oc = originalOfReplacement(rc);
if (oc != rc) { if (oc != rc) {
// build sb if this is the first escape // build sb if this is the first escape
if (sb == null) { if (sb == null) {
@ -398,34 +398,34 @@ public final class NameCodec {
private static final long[] SPECIAL_BITMAP = new long[2]; // 128 bits private static final long[] SPECIAL_BITMAP = new long[2]; // 128 bits
static { static {
String SPECIAL = DANGEROUS_CHARS + REPLACEMENT_CHARS; final String SPECIAL = DANGEROUS_CHARS + REPLACEMENT_CHARS;
for (char c : SPECIAL.toCharArray()) { for (final char c : SPECIAL.toCharArray()) {
SPECIAL_BITMAP[c >>> 6] |= 1L << c; SPECIAL_BITMAP[c >>> 6] |= 1L << c;
} }
} }
private static boolean isSpecial(char c) { private static boolean isSpecial(final char c) {
if ((c >>> 6) < SPECIAL_BITMAP.length) if ((c >>> 6) < SPECIAL_BITMAP.length)
return ((SPECIAL_BITMAP[c >>> 6] >> c) & 1) != 0; return ((SPECIAL_BITMAP[c >>> 6] >> c) & 1) != 0;
else else
return false; return false;
} }
private static char replacementOf(char c) { private static char replacementOf(final char c) {
if (!isSpecial(c)) return c; if (!isSpecial(c)) return c;
int i = DANGEROUS_CHARS.indexOf(c); final int i = DANGEROUS_CHARS.indexOf(c);
if (i < 0) return c; if (i < 0) return c;
return REPLACEMENT_CHARS.charAt(i); return REPLACEMENT_CHARS.charAt(i);
} }
private static char originalOfReplacement(char c) { private static char originalOfReplacement(final char c) {
if (!isSpecial(c)) return c; if (!isSpecial(c)) return c;
int i = REPLACEMENT_CHARS.indexOf(c); final int i = REPLACEMENT_CHARS.indexOf(c);
if (i < 0) return c; if (i < 0) return c;
return DANGEROUS_CHARS.charAt(i); return DANGEROUS_CHARS.charAt(i);
} }
private static boolean isDangerous(char c) { private static boolean isDangerous(final char c) {
if (!isSpecial(c)) return false; if (!isSpecial(c)) return false;
return (DANGEROUS_CHARS.indexOf(c) >= DANGEROUS_CHAR_FIRST_INDEX); return (DANGEROUS_CHARS.indexOf(c) >= DANGEROUS_CHAR_FIRST_INDEX);
} }

View file

@ -292,7 +292,7 @@ public class Shell implements PartialParser {
String l = ""; String l = "";
try (final BufferedReader r = Files.newBufferedReader(p)) { try (final BufferedReader r = Files.newBufferedReader(p)) {
l = r.readLine(); l = r.readLine();
} catch (IOException ioe) { } catch (final IOException ioe) {
// ignore // ignore
} }
if (l.startsWith("#!")) { if (l.startsWith("#!")) {

View file

@ -59,7 +59,7 @@ public class LookupTest {
private static void privateStaticFunc() {} private static void privateStaticFunc() {}
@SuppressWarnings("unused") @SuppressWarnings("unused")
private int myIntField = 0; private final int myIntField = 0;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@DataProvider @DataProvider
@ -72,26 +72,26 @@ public class LookupTest {
@Test(dataProvider = "flags") @Test(dataProvider = "flags")
public void unreflectTest(final boolean publicLookup) throws NoSuchMethodException { public void unreflectTest(final boolean publicLookup) throws NoSuchMethodException {
MethodHandle mh = Lookup.unreflect(getLookup(publicLookup), LookupTest.class.getMethod("unreflectTest", Boolean.TYPE)); final MethodHandle mh = Lookup.unreflect(getLookup(publicLookup), LookupTest.class.getMethod("unreflectTest", Boolean.TYPE));
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} }
@Test @Test
public void unreflectTest2() throws NoSuchMethodException { public void unreflectTest2() throws NoSuchMethodException {
MethodHandle mh = Lookup.PUBLIC.unreflect(LookupTest.class.getMethod("unreflectTest", Boolean.TYPE)); final MethodHandle mh = Lookup.PUBLIC.unreflect(LookupTest.class.getMethod("unreflectTest", Boolean.TYPE));
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} }
@Test(dataProvider = "flags") @Test(dataProvider = "flags")
public void unreflectNegativeTest(final boolean publicLookup) throws NoSuchMethodException { public void unreflectNegativeTest(final boolean publicLookup) throws NoSuchMethodException {
try { try {
MethodHandle mh = Lookup.unreflect(getLookup(publicLookup), final MethodHandle mh = Lookup.unreflect(getLookup(publicLookup),
LookupTest.class.getDeclaredMethod("privateFunc")); LookupTest.class.getDeclaredMethod("privateFunc"));
if (publicLookup) { if (publicLookup) {
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} }
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(publicLookup); Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
@ -102,33 +102,33 @@ public class LookupTest {
try { try {
Lookup.PUBLIC.unreflect(LookupTest.class.getDeclaredMethod("privateFunc")); Lookup.PUBLIC.unreflect(LookupTest.class.getDeclaredMethod("privateFunc"));
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
} }
@Test(dataProvider = "flags") @Test(dataProvider = "flags")
public void unreflectConstructorTest(final boolean publicLookup) throws NoSuchMethodException { public void unreflectConstructorTest(final boolean publicLookup) throws NoSuchMethodException {
MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup), LookupTest.class.getConstructor()); final MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup), LookupTest.class.getConstructor());
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} }
@Test @Test
public void unreflectConstructorTest2() throws NoSuchMethodException { public void unreflectConstructorTest2() throws NoSuchMethodException {
MethodHandle mh = Lookup.PUBLIC.unreflectConstructor(LookupTest.class.getConstructor()); final MethodHandle mh = Lookup.PUBLIC.unreflectConstructor(LookupTest.class.getConstructor());
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} }
@Test(dataProvider = "flags") @Test(dataProvider = "flags")
public void unreflectConstructorNegativeTest(final boolean publicLookup) throws NoSuchMethodException { public void unreflectConstructorNegativeTest(final boolean publicLookup) throws NoSuchMethodException {
try { try {
MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup), final MethodHandle mh = Lookup.unreflectConstructor(getLookup(publicLookup),
LookupTest.class.getDeclaredConstructor(Integer.TYPE)); LookupTest.class.getDeclaredConstructor(Integer.TYPE));
if (publicLookup) { if (publicLookup) {
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} }
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(publicLookup); Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
@ -140,7 +140,7 @@ public class LookupTest {
Lookup.PUBLIC.unreflectConstructor( Lookup.PUBLIC.unreflectConstructor(
LookupTest.class.getDeclaredConstructor(Integer.TYPE)); LookupTest.class.getDeclaredConstructor(Integer.TYPE));
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
} }
@ -148,13 +148,13 @@ public class LookupTest {
@Test(dataProvider = "flags") @Test(dataProvider = "flags")
public void findOwnStaticTest(final boolean publicLookup) { public void findOwnStaticTest(final boolean publicLookup) {
try { try {
MethodHandle mh = Lookup.findOwnStatic(getLookup(publicLookup), "getLookup", final MethodHandle mh = Lookup.findOwnStatic(getLookup(publicLookup), "getLookup",
MethodHandles.Lookup.class, Boolean.TYPE); MethodHandles.Lookup.class, Boolean.TYPE);
if (publicLookup) { if (publicLookup) {
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} }
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(publicLookup); Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
@ -166,7 +166,7 @@ public class LookupTest {
Lookup.PUBLIC.findStatic(LookupTest.class, "getLookup", Lookup.PUBLIC.findStatic(LookupTest.class, "getLookup",
MethodType.methodType(MethodHandles.Lookup.class, Boolean.TYPE)); MethodType.methodType(MethodHandles.Lookup.class, Boolean.TYPE));
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
} }
@ -174,12 +174,12 @@ public class LookupTest {
@Test(dataProvider = "flags") @Test(dataProvider = "flags")
public void findOwnSepcialTest(final boolean publicLookup) { public void findOwnSepcialTest(final boolean publicLookup) {
try { try {
MethodHandle mh = Lookup.findOwnSpecial(getLookup(publicLookup), "privateFunc", Void.TYPE); final MethodHandle mh = Lookup.findOwnSpecial(getLookup(publicLookup), "privateFunc", Void.TYPE);
if (publicLookup) { if (publicLookup) {
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} }
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(publicLookup); Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
@ -190,7 +190,7 @@ public class LookupTest {
try { try {
Lookup.PUBLIC.findOwnSpecial("privateFunc", Void.TYPE); Lookup.PUBLIC.findOwnSpecial("privateFunc", Void.TYPE);
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
} }
@ -198,12 +198,12 @@ public class LookupTest {
@Test(dataProvider = "flags") @Test(dataProvider = "flags")
public void findGetterTest(final boolean publicLookup) { public void findGetterTest(final boolean publicLookup) {
try { try {
MethodHandle mh = new Lookup(getLookup(publicLookup)).findGetter(LookupTest.class, "myIntField", Integer.TYPE); final MethodHandle mh = new Lookup(getLookup(publicLookup)).findGetter(LookupTest.class, "myIntField", Integer.TYPE);
if (publicLookup) { if (publicLookup) {
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} }
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(publicLookup); Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
@ -214,7 +214,7 @@ public class LookupTest {
try { try {
Lookup.PUBLIC.findGetter(LookupTest.class, "myIntField", Integer.TYPE); Lookup.PUBLIC.findGetter(LookupTest.class, "myIntField", Integer.TYPE);
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
} }
@ -222,13 +222,13 @@ public class LookupTest {
@Test(dataProvider = "flags") @Test(dataProvider = "flags")
public void findVirtualTest(final boolean publicLookup) { public void findVirtualTest(final boolean publicLookup) {
try { try {
MethodHandle mh = new Lookup(getLookup(publicLookup)).findVirtual(LookupTest.class, "protectedFunc", final MethodHandle mh = new Lookup(getLookup(publicLookup)).findVirtual(LookupTest.class, "protectedFunc",
MethodType.methodType(Void.TYPE)); MethodType.methodType(Void.TYPE));
if (publicLookup) { if (publicLookup) {
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} }
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(publicLookup); Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
@ -240,7 +240,7 @@ public class LookupTest {
Lookup.PUBLIC.findVirtual(LookupTest.class, "protectedFunc", Lookup.PUBLIC.findVirtual(LookupTest.class, "protectedFunc",
MethodType.methodType(Void.TYPE)); MethodType.methodType(Void.TYPE));
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
} }
@ -248,13 +248,13 @@ public class LookupTest {
@Test(dataProvider = "flags") @Test(dataProvider = "flags")
public void findStaticTest(final boolean publicLookup) { public void findStaticTest(final boolean publicLookup) {
try { try {
MethodHandle mh = new Lookup(getLookup(publicLookup)).findStatic(LookupTest.class, "privateStaticFunc", final MethodHandle mh = new Lookup(getLookup(publicLookup)).findStatic(LookupTest.class, "privateStaticFunc",
MethodType.methodType(Void.TYPE)); MethodType.methodType(Void.TYPE));
if (publicLookup) { if (publicLookup) {
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} }
Assert.assertNotNull(mh); Assert.assertNotNull(mh);
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(publicLookup); Assert.assertTrue(publicLookup);
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
@ -266,7 +266,7 @@ public class LookupTest {
Lookup.PUBLIC.findStatic(LookupTest.class, "privateStaticFunc", Lookup.PUBLIC.findStatic(LookupTest.class, "privateStaticFunc",
MethodType.methodType(Void.TYPE)); MethodType.methodType(Void.TYPE));
throw new RuntimeException("should have thrown Error"); throw new RuntimeException("should have thrown Error");
} catch (Error err) { } catch (final Error err) {
Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError); Assert.assertTrue(err instanceof NoSuchMethodError || err instanceof IllegalAccessError);
} }
} }

View file

@ -35,15 +35,15 @@ import javax.script.ScriptEngineManager;
import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.CallSiteDescriptor;
import jdk.dynalink.DynamicLinker; import jdk.dynalink.DynamicLinker;
import jdk.dynalink.DynamicLinkerFactory; import jdk.dynalink.DynamicLinkerFactory;
import jdk.dynalink.NoSuchDynamicMethodException;
import jdk.dynalink.NamedOperation; import jdk.dynalink.NamedOperation;
import jdk.dynalink.NoSuchDynamicMethodException;
import jdk.dynalink.Operation; import jdk.dynalink.Operation;
import jdk.dynalink.StandardOperation; import jdk.dynalink.StandardOperation;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.dynalink.linker.GuardingDynamicLinker; import jdk.dynalink.linker.GuardingDynamicLinker;
import jdk.dynalink.linker.LinkRequest; import jdk.dynalink.linker.LinkRequest;
import jdk.dynalink.linker.LinkerServices; import jdk.dynalink.linker.LinkerServices;
import jdk.dynalink.support.SimpleRelinkableCallSite; import jdk.dynalink.support.SimpleRelinkableCallSite;
import jdk.dynalink.linker.GuardedInvocation;
import jdk.nashorn.api.scripting.AbstractJSObject; import jdk.nashorn.api.scripting.AbstractJSObject;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -80,7 +80,7 @@ public class DynamicLinkerFactoryTest {
final Operation myOperation = new Operation() { final Operation myOperation = new Operation() {
}; };
final boolean[] reachedFallback = { false }; final boolean[] reachedFallback = { false };
factory.setFallbackLinkers((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> { factory.setFallbackLinkers((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation); Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
reachedFallback[0] = true; reachedFallback[0] = true;
return null; return null;
@ -95,10 +95,10 @@ public class DynamicLinkerFactoryTest {
Assert.assertFalse(reachedFallback[0]); Assert.assertFalse(reachedFallback[0]);
try { try {
cs.getTarget().invoke(); cs.getTarget().invoke();
} catch (NoSuchDynamicMethodException nsdm) { } catch (final NoSuchDynamicMethodException nsdm) {
// we do expect NoSuchDynamicMethod! // we do expect NoSuchDynamicMethod!
// because our dummy fallback linker returns null! // because our dummy fallback linker returns null!
} catch (Throwable th) { } catch (final Throwable th) {
throw new RuntimeException("should not reach here with: " + th); throw new RuntimeException("should not reach here with: " + th);
} }
@ -112,7 +112,7 @@ public class DynamicLinkerFactoryTest {
final Operation myOperation = new Operation() { final Operation myOperation = new Operation() {
}; };
final boolean[] reachedProrityLinker = { false }; final boolean[] reachedProrityLinker = { false };
factory.setPrioritizedLinker((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> { factory.setPrioritizedLinker((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation); Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
reachedProrityLinker[0] = true; reachedProrityLinker[0] = true;
return null; return null;
@ -127,10 +127,10 @@ public class DynamicLinkerFactoryTest {
Assert.assertFalse(reachedProrityLinker[0]); Assert.assertFalse(reachedProrityLinker[0]);
try { try {
cs.getTarget().invoke(); cs.getTarget().invoke();
} catch (NoSuchDynamicMethodException nsdm) { } catch (final NoSuchDynamicMethodException nsdm) {
// we do expect NoSuchDynamicMethod! // we do expect NoSuchDynamicMethod!
// because our dummy priority linker returns null! // because our dummy priority linker returns null!
} catch (Throwable th) { } catch (final Throwable th) {
throw new RuntimeException("should not reach here with: " + th); throw new RuntimeException("should not reach here with: " + th);
} }
@ -144,12 +144,12 @@ public class DynamicLinkerFactoryTest {
final Operation myOperation = new Operation() { final Operation myOperation = new Operation() {
}; };
final int[] linkerReachCounter = { 0 }; final int[] linkerReachCounter = { 0 };
factory.setPrioritizedLinker((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> { factory.setPrioritizedLinker((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation); Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
linkerReachCounter[0]++; linkerReachCounter[0]++;
return null; return null;
}); });
factory.setFallbackLinkers((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> { factory.setFallbackLinkers((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation); Assert.assertEquals(linkRequest.getCallSiteDescriptor().getOperation(), myOperation);
Assert.assertEquals(linkerReachCounter[0], 1); Assert.assertEquals(linkerReachCounter[0], 1);
linkerReachCounter[0]++; linkerReachCounter[0]++;
@ -166,9 +166,9 @@ public class DynamicLinkerFactoryTest {
try { try {
cs.getTarget().invoke(); cs.getTarget().invoke();
} catch (NoSuchDynamicMethodException nsdm) { } catch (final NoSuchDynamicMethodException nsdm) {
// we do expect NoSuchDynamicMethod! // we do expect NoSuchDynamicMethod!
} catch (Throwable th) { } catch (final Throwable th) {
throw new RuntimeException("should not reach here with: " + th); throw new RuntimeException("should not reach here with: " + th);
} }
@ -180,7 +180,7 @@ public class DynamicLinkerFactoryTest {
final DynamicLinkerFactory factory = newDynamicLinkerFactory(true); final DynamicLinkerFactory factory = newDynamicLinkerFactory(true);
final boolean[] reachedPrelinkTransformer = { false }; final boolean[] reachedPrelinkTransformer = { false };
factory.setPrelinkTransformer((GuardedInvocation inv, LinkRequest linkRequest, LinkerServices linkerServices) -> { factory.setPrelinkTransformer((final GuardedInvocation inv, final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
reachedPrelinkTransformer[0] = true; reachedPrelinkTransformer[0] = true;
// just identity transformer! // just identity transformer!
return inv; return inv;
@ -200,7 +200,7 @@ public class DynamicLinkerFactoryTest {
final DynamicLinkerFactory factory = newDynamicLinkerFactory(true); final DynamicLinkerFactory factory = newDynamicLinkerFactory(true);
final boolean[] reachedInternalObjectsFilter = { false }; final boolean[] reachedInternalObjectsFilter = { false };
factory.setInternalObjectsFilter((MethodHandle mh) -> { factory.setInternalObjectsFilter((final MethodHandle mh) -> {
reachedInternalObjectsFilter[0] = true; reachedInternalObjectsFilter[0] = true;
return mh; return mh;
}); });
@ -249,10 +249,10 @@ public class DynamicLinkerFactoryTest {
try { try {
cs.getTarget().invoke(new Object()); cs.getTarget().invoke(new Object());
} catch (ReachedAutoLoadedDynamicLinkerException e) { } catch (final ReachedAutoLoadedDynamicLinkerException e) {
// TrustedGuardingDynamicLinkerExporter threw exception on TestLinkerOperation as expected! // TrustedGuardingDynamicLinkerExporter threw exception on TestLinkerOperation as expected!
reachedAutoLinker = true; reachedAutoLinker = true;
} catch (Throwable th) { } catch (final Throwable th) {
throw new RuntimeException(th); throw new RuntimeException(th);
} }
@ -270,9 +270,9 @@ public class DynamicLinkerFactoryTest {
MethodHandles.publicLookup(), op, mt))); MethodHandles.publicLookup(), op, mt)));
final boolean[] reachedGetMember = new boolean[1]; final boolean[] reachedGetMember = new boolean[1];
// check that the nashorn exported linker can be used for user defined JSObject // check that the nashorn exported linker can be used for user defined JSObject
Object obj = new AbstractJSObject() { final Object obj = new AbstractJSObject() {
@Override @Override
public Object getMember(String name) { public Object getMember(final String name) {
reachedGetMember[0] = true; reachedGetMember[0] = true;
return name.equals("foo")? "bar" : "<unknown>"; return name.equals("foo")? "bar" : "<unknown>";
} }
@ -281,7 +281,7 @@ public class DynamicLinkerFactoryTest {
Object value = null; Object value = null;
try { try {
value = cs.getTarget().invoke(obj); value = cs.getTarget().invoke(obj);
} catch (Throwable th) { } catch (final Throwable th) {
throw new RuntimeException(th); throw new RuntimeException(th);
} }
@ -304,7 +304,7 @@ public class DynamicLinkerFactoryTest {
try { try {
final Object obj = engine.eval("({ foo: 'hello' })"); final Object obj = engine.eval("({ foo: 'hello' })");
value = cs.getTarget().invoke(obj); value = cs.getTarget().invoke(obj);
} catch (Throwable th) { } catch (final Throwable th) {
throw new RuntimeException(th); throw new RuntimeException(th);
} }
Assert.assertEquals(value, "hello"); Assert.assertEquals(value, "hello");

View file

@ -40,7 +40,7 @@ public final class TrustedGuardingDynamicLinkerExporter extends GuardingDynamicL
@Override @Override
public List<GuardingDynamicLinker> get() { public List<GuardingDynamicLinker> get() {
final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>(); final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>();
linkers.add((GuardingDynamicLinker) (LinkRequest linkRequest, LinkerServices linkerServices) -> { linkers.add((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
// handle only the TestLinkerOperation instances // handle only the TestLinkerOperation instances
if (linkRequest.getCallSiteDescriptor().getOperation() instanceof TestLinkerOperation) { if (linkRequest.getCallSiteDescriptor().getOperation() instanceof TestLinkerOperation) {
System.out.println("inside " + this.getClass().getName()); System.out.println("inside " + this.getClass().getName());

View file

@ -54,7 +54,7 @@ public class JDK_8148140_Test {
return true; return true;
} }
@Override @Override
public Object call(Object thiz, Object... args) { public Object call(final Object thiz, final Object... args) {
return Arrays.deepToString(args); return Arrays.deepToString(args);
} }
}); });

View file

@ -737,52 +737,52 @@ public class ScopeTest {
try { try {
c.getAttribute(""); c.getAttribute("");
throw new AssertionError("should have thrown IAE"); throw new AssertionError("should have thrown IAE");
} catch (IllegalArgumentException iae1) {} } catch (final IllegalArgumentException iae1) {}
try { try {
c.getAttribute(null); c.getAttribute(null);
throw new AssertionError("should have thrown NPE"); throw new AssertionError("should have thrown NPE");
} catch (NullPointerException npe1) {} } catch (final NullPointerException npe1) {}
try { try {
c.getAttribute("", ScriptContext.ENGINE_SCOPE); c.getAttribute("", ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown IAE"); throw new AssertionError("should have thrown IAE");
} catch (IllegalArgumentException iae2) {} } catch (final IllegalArgumentException iae2) {}
try { try {
c.getAttribute(null, ScriptContext.ENGINE_SCOPE); c.getAttribute(null, ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown NPE"); throw new AssertionError("should have thrown NPE");
} catch (NullPointerException npe2) {} } catch (final NullPointerException npe2) {}
try { try {
c.removeAttribute("", ScriptContext.ENGINE_SCOPE); c.removeAttribute("", ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown IAE"); throw new AssertionError("should have thrown IAE");
} catch (IllegalArgumentException iae3) {} } catch (final IllegalArgumentException iae3) {}
try { try {
c.removeAttribute(null, ScriptContext.ENGINE_SCOPE); c.removeAttribute(null, ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown NPE"); throw new AssertionError("should have thrown NPE");
} catch (NullPointerException npe3) {} } catch (final NullPointerException npe3) {}
try { try {
c.setAttribute("", "value", ScriptContext.ENGINE_SCOPE); c.setAttribute("", "value", ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown IAE"); throw new AssertionError("should have thrown IAE");
} catch (IllegalArgumentException iae4) {} } catch (final IllegalArgumentException iae4) {}
try { try {
c.setAttribute(null, "value", ScriptContext.ENGINE_SCOPE); c.setAttribute(null, "value", ScriptContext.ENGINE_SCOPE);
throw new AssertionError("should have thrown NPE"); throw new AssertionError("should have thrown NPE");
} catch (NullPointerException npe4) {} } catch (final NullPointerException npe4) {}
try { try {
c.getAttributesScope(""); c.getAttributesScope("");
throw new AssertionError("should have thrown IAE"); throw new AssertionError("should have thrown IAE");
} catch (IllegalArgumentException iae5) {} } catch (final IllegalArgumentException iae5) {}
try { try {
c.getAttributesScope(null); c.getAttributesScope(null);
throw new AssertionError("should have thrown NPE"); throw new AssertionError("should have thrown NPE");
} catch (NullPointerException npe5) {} } catch (final NullPointerException npe5) {}
} }
public static class RecursiveEval { public static class RecursiveEval {
@ -791,8 +791,8 @@ public class ScopeTest {
private final Bindings engineBindings = engine.getBindings(ScriptContext.ENGINE_SCOPE); private final Bindings engineBindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
public void program() throws ScriptException { public void program() throws ScriptException {
ScriptContext sc = new SimpleScriptContext(); final ScriptContext sc = new SimpleScriptContext();
Bindings global = new SimpleBindings(); final Bindings global = new SimpleBindings();
sc.setBindings(global, ScriptContext.GLOBAL_SCOPE); sc.setBindings(global, ScriptContext.GLOBAL_SCOPE);
sc.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE); sc.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
global.put("text", "programText"); global.put("text", "programText");
@ -812,7 +812,7 @@ public class ScopeTest {
sc.setBindings(global, ScriptContext.GLOBAL_SCOPE); sc.setBindings(global, ScriptContext.GLOBAL_SCOPE);
sc.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE); sc.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
global.put("text", "methodText"); global.put("text", "methodText");
String value = engine.eval("text", sc).toString(); final String value = engine.eval("text", sc).toString();
Assert.assertEquals(value, "methodText"); Assert.assertEquals(value, "methodText");
} }
} }
@ -878,7 +878,7 @@ public class ScopeTest {
engine.eval("newfunc = function() { return func() }"); engine.eval("newfunc = function() { return func() }");
// call "newfunc" and check the return value // call "newfunc" and check the return value
Object value = ((Invocable)engine).invokeFunction("newfunc"); final Object value = ((Invocable)engine).invokeFunction("newfunc");
assertTrue(((Number)value).intValue() == 42); assertTrue(((Number)value).intValue() == 42);
} }
@ -910,7 +910,7 @@ public class ScopeTest {
engine.eval("newfunc = function() { return func() }"); engine.eval("newfunc = function() { return func() }");
// call "newfunc" and check the return value // call "newfunc" and check the return value
Object value = ((Invocable)engine).invokeFunction("newfunc"); final Object value = ((Invocable)engine).invokeFunction("newfunc");
assertTrue(((Number)value).intValue() == 42); assertTrue(((Number)value).intValue() == 42);
} }
@ -922,18 +922,18 @@ public class ScopeTest {
final ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn"); final ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
// create an engine and a ScriptContext, but don't set it as default // create an engine and a ScriptContext, but don't set it as default
ScriptContext scriptContext = new SimpleScriptContext(); final ScriptContext scriptContext = new SimpleScriptContext();
// Set some value in the context // Set some value in the context
scriptContext.setAttribute("myString", "foo", ScriptContext.ENGINE_SCOPE); scriptContext.setAttribute("myString", "foo", ScriptContext.ENGINE_SCOPE);
// Evaluate script with custom context and get back a function // Evaluate script with custom context and get back a function
final String script = "function (c) { return myString.indexOf(c); }"; final String script = "function (c) { return myString.indexOf(c); }";
CompiledScript compiledScript = ((Compilable)engine).compile(script); final CompiledScript compiledScript = ((Compilable)engine).compile(script);
Object func = compiledScript.eval(scriptContext); final Object func = compiledScript.eval(scriptContext);
// Invoked function should be able to see context it was evaluated with // Invoked function should be able to see context it was evaluated with
Object result = ((Invocable) engine).invokeMethod(func, "call", func, "o", null); final Object result = ((Invocable) engine).invokeMethod(func, "call", func, "o", null);
assertTrue(((Number)result).intValue() == 1); assertTrue(((Number)result).intValue() == 1);
} }
} }

View file

@ -683,7 +683,7 @@ public class ScriptEngineTest {
final ScriptEngineManager manager = new ScriptEngineManager(); final ScriptEngineManager manager = new ScriptEngineManager();
final ScriptEngine e = manager.getEngineByName("nashorn"); final ScriptEngine e = manager.getEngineByName("nashorn");
// no exception expected here! // no exception expected here!
Object value = e.getFactory().getParameter("no value assigned to this key"); final Object value = e.getFactory().getParameter("no value assigned to this key");
assertNull(value); assertNull(value);
} }
@ -695,7 +695,7 @@ public class ScriptEngineTest {
final AtomicBoolean invoked = new AtomicBoolean(false); final AtomicBoolean invoked = new AtomicBoolean(false);
e.put("f", new Function<String, String>() { e.put("f", new Function<String, String>() {
@Override @Override
public String apply(String t) { public String apply(final String t) {
invoked.set(true); invoked.set(true);
return t; return t;
} }
@ -712,7 +712,7 @@ public class ScriptEngineTest {
final AtomicBoolean invoked = new AtomicBoolean(false); final AtomicBoolean invoked = new AtomicBoolean(false);
e.put("c", new Consumer<Object>() { e.put("c", new Consumer<Object>() {
@Override @Override
public void accept(Object t) { public void accept(final Object t) {
assertTrue(t instanceof ScriptObjectMirror); assertTrue(t instanceof ScriptObjectMirror);
assertEquals(((ScriptObjectMirror)t).get("a"), "xyz"); assertEquals(((ScriptObjectMirror)t).get("a"), "xyz");
invoked.set(true); invoked.set(true);
@ -740,14 +740,14 @@ public class ScriptEngineTest {
try { try {
e.put(null, "null-value"); e.put(null, "null-value");
fail(); fail();
} catch (NullPointerException x) { } catch (final NullPointerException x) {
// expected // expected
} }
try { try {
e.put("", "empty-value"); e.put("", "empty-value");
fail(); fail();
} catch (IllegalArgumentException x) { } catch (final IllegalArgumentException x) {
// expected // expected
} }
@ -757,98 +757,98 @@ public class ScriptEngineTest {
try { try {
b.put(null, "null-value"); b.put(null, "null-value");
fail(); fail();
} catch (NullPointerException x) { } catch (final NullPointerException x) {
// expected // expected
} }
try { try {
b.put("", "empty-value"); b.put("", "empty-value");
fail(); fail();
} catch (IllegalArgumentException x) { } catch (final IllegalArgumentException x) {
// expected // expected
} }
try { try {
b.get(null); b.get(null);
fail(); fail();
} catch (NullPointerException x) { } catch (final NullPointerException x) {
// expected // expected
} }
try { try {
b.get(""); b.get("");
fail(); fail();
} catch (IllegalArgumentException x) { } catch (final IllegalArgumentException x) {
// expected // expected
} }
try { try {
b.get(1); b.get(1);
fail(); fail();
} catch (ClassCastException x) { } catch (final ClassCastException x) {
// expected // expected
} }
try { try {
b.remove(null); b.remove(null);
fail(); fail();
} catch (NullPointerException x) { } catch (final NullPointerException x) {
// expected // expected
} }
try { try {
b.remove(""); b.remove("");
fail(); fail();
} catch (IllegalArgumentException x) { } catch (final IllegalArgumentException x) {
// expected // expected
} }
try { try {
b.remove(1); b.remove(1);
fail(); fail();
} catch (ClassCastException x) { } catch (final ClassCastException x) {
// expected // expected
} }
try { try {
b.containsKey(null); b.containsKey(null);
fail(); fail();
} catch (NullPointerException x) { } catch (final NullPointerException x) {
// expected // expected
} }
try { try {
b.containsKey(""); b.containsKey("");
fail(); fail();
} catch (IllegalArgumentException x) { } catch (final IllegalArgumentException x) {
// expected // expected
} }
try { try {
b.containsKey(1); b.containsKey(1);
fail(); fail();
} catch (ClassCastException x) { } catch (final ClassCastException x) {
// expected // expected
} }
try { try {
b.putAll(null); b.putAll(null);
fail(); fail();
} catch (NullPointerException x) { } catch (final NullPointerException x) {
// expected // expected
} }
try { try {
b.putAll(Collections.singletonMap((String)null, "null-value")); b.putAll(Collections.singletonMap((String)null, "null-value"));
fail(); fail();
} catch (NullPointerException x) { } catch (final NullPointerException x) {
// expected // expected
} }
try { try {
b.putAll(Collections.singletonMap("", "empty-value")); b.putAll(Collections.singletonMap("", "empty-value"));
fail(); fail();
} catch (IllegalArgumentException x) { } catch (final IllegalArgumentException x) {
// expected // expected
} }
} }

View file

@ -53,9 +53,9 @@ public class ParseAPITest {
private static final String TEST262_SUITE_DIR; private static final String TEST262_SUITE_DIR;
static { static {
String testSrc = System.getProperty("test.src"); final String testSrc = System.getProperty("test.src");
if (testSrc != null) { if (testSrc != null) {
String testScriptDir = testSrc + "/../../../../../../script/"; final String testScriptDir = testSrc + "/../../../../../../script/";
TEST_BASIC_DIR = testScriptDir + "basic"; TEST_BASIC_DIR = testScriptDir + "basic";
TEST_MAPTESTS_DIR = testScriptDir + "maptests"; TEST_MAPTESTS_DIR = testScriptDir + "maptests";
TEST_SANDBOX_DIR = testScriptDir + "sandbox"; TEST_SANDBOX_DIR = testScriptDir + "sandbox";
@ -74,7 +74,7 @@ public class ParseAPITest {
public boolean exclude(File file, String content); public boolean exclude(File file, String content);
} }
private void log(String msg) { private void log(final String msg) {
org.testng.Reporter.log(msg, true); org.testng.Reporter.log(msg, true);
} }

View file

@ -97,8 +97,8 @@ public class BignumTest {
@Test @Test
public void testAssign() throws Exception { public void testAssign() throws Exception {
Object bignum = ctor.newInstance(); final Object bignum = ctor.newInstance();
Object bignum2 = ctor.newInstance(); final Object bignum2 = ctor.newInstance();
final Method assignUInt16 = method("assignUInt16", char.class); final Method assignUInt16 = method("assignUInt16", char.class);
final Method assignUInt64 = method("assignUInt64", long.class); final Method assignUInt64 = method("assignUInt64", long.class);

View file

@ -228,8 +228,8 @@ public class IeeeDoubleTest {
@Test @Test
public void testNormalizedBoundaries() throws Exception { public void testNormalizedBoundaries() throws Exception {
Object boundary_plus = DiyFpCtor.newInstance(); final Object boundary_plus = DiyFpCtor.newInstance();
Object boundary_minus = DiyFpCtor.newInstance(); final Object boundary_minus = DiyFpCtor.newInstance();
Object diy_fp = asNormalizedDiyFp.invoke(null, doubleToLong.invoke(null, 1.5)); Object diy_fp = asNormalizedDiyFp.invoke(null, doubleToLong.invoke(null, 1.5));
normalizedBoundaries.invoke(null, doubleToLong.invoke(null, 1.5), boundary_minus, boundary_plus); normalizedBoundaries.invoke(null, doubleToLong.invoke(null, 1.5), boundary_minus, boundary_plus);
assertEquals(e.invoke(diy_fp), e.invoke(boundary_minus)); assertEquals(e.invoke(diy_fp), e.invoke(boundary_minus));

View file

@ -60,11 +60,11 @@ public class NameCodecTest {
static final String REPLACEMENT_CHARS = "-|,?!%{}^_"; static final String REPLACEMENT_CHARS = "-|,?!%{}^_";
static String[][] canonicalSamples() { static String[][] canonicalSamples() {
int ndc = DANGEROUS_CHARS.length(); final int ndc = DANGEROUS_CHARS.length();
String[][] res = new String[2 * ndc][]; final String[][] res = new String[2 * ndc][];
for (int i = 0; i < ndc; i++) { for (int i = 0; i < ndc; i++) {
char dc = DANGEROUS_CHARS.charAt(i); final char dc = DANGEROUS_CHARS.charAt(i);
char rc = REPLACEMENT_CHARS.charAt(i); final char rc = REPLACEMENT_CHARS.charAt(i);
if (dc == '\\') { if (dc == '\\') {
res[2 * i + 0] = new String[]{"\\-%", "\\%"}; res[2 * i + 0] = new String[]{"\\-%", "\\%"};
} else { } else {
@ -82,11 +82,11 @@ public class NameCodecTest {
testEncode(canonicalSamples()); testEncode(canonicalSamples());
} }
private void testEncode(String[][] samples) { private void testEncode(final String[][] samples) {
for (String[] sample : samples) { for (final String[] sample : samples) {
String s = sample[1]; final String s = sample[1];
String expResult = sample[0]; final String expResult = sample[0];
String result = NameCodec.encode(s); final String result = NameCodec.encode(s);
if (!result.equals(expResult)) { if (!result.equals(expResult)) {
System.out.println(s + " => " + result + " != " + expResult); System.out.println(s + " => " + result + " != " + expResult);
} }
@ -101,11 +101,11 @@ public class NameCodecTest {
testDecode(canonicalSamples()); testDecode(canonicalSamples());
} }
private void testDecode(String[][] samples) { private void testDecode(final String[][] samples) {
for (String[] sample : samples) { for (final String[] sample : samples) {
String s = sample[0]; final String s = sample[0];
String expResult = sample[1]; final String expResult = sample[1];
String result = NameCodec.decode(s); final String result = NameCodec.decode(s);
assertEquals(expResult, result); assertEquals(expResult, result);
} }
} }

View file

@ -224,8 +224,8 @@ public final class TestFinder {
boolean explicitOptimistic = false; boolean explicitOptimistic = false;
String allContent = new String(Files.readAllBytes(testFile)); final String allContent = new String(Files.readAllBytes(testFile));
Iterator<String> scanner = Shell.tokenizeString(allContent).iterator(); final Iterator<String> scanner = Shell.tokenizeString(allContent).iterator();
while (scanner.hasNext()) { while (scanner.hasNext()) {
// TODO: Scan for /ref=file qualifiers, etc, to determine run // TODO: Scan for /ref=file qualifiers, etc, to determine run
// behavior // behavior

View file

@ -26,7 +26,7 @@
package jdk.nashorn.test.models; package jdk.nashorn.test.models;
public abstract class BigAbstract { public abstract class BigAbstract {
public static void accept(BigAbstract ba) { public static void accept(final BigAbstract ba) {
} }
public abstract void f0(); public abstract void f0();

View file

@ -49,7 +49,7 @@ public class Jdk8072596TestSubject {
} }
// Test having to wrap some arguments but not others, and a vararg array // Test having to wrap some arguments but not others, and a vararg array
public void test2(String x, final Object y, final ScriptObject w, final Object... z) { public void test2(final String x, final Object y, final ScriptObject w, final Object... z) {
test1(x, y, w); test1(x, y, w);
Assert.assertEquals(z.length, 2); Assert.assertEquals(z.length, 2);

View file

@ -42,7 +42,7 @@ public final class Reflector {
private Reflector() {} private Reflector() {}
private static final Module NASHORN_MOD = Context.class.getModule(); private static final Module NASHORN_MOD = Context.class.getModule();
public static Object invoke(Method m, Object self, Object...args) { public static Object invoke(final Method m, final Object self, final Object...args) {
if (m.getDeclaringClass().getModule() != NASHORN_MOD) { if (m.getDeclaringClass().getModule() != NASHORN_MOD) {
throw new RuntimeException(m + " is not from Nashorn module"); throw new RuntimeException(m + " is not from Nashorn module");
} }
@ -58,7 +58,7 @@ public final class Reflector {
} }
} }
public static Object newInstance(Constructor c, Object...args) { public static Object newInstance(final Constructor c, final Object...args) {
if (c.getDeclaringClass().getModule() != NASHORN_MOD) { if (c.getDeclaringClass().getModule() != NASHORN_MOD) {
throw new RuntimeException(c + " is not from Nashorn module"); throw new RuntimeException(c + " is not from Nashorn module");
} }
@ -74,7 +74,7 @@ public final class Reflector {
} }
} }
public static Object get(Field f, Object self) { public static Object get(final Field f, final Object self) {
if (f.getDeclaringClass().getModule() != NASHORN_MOD) { if (f.getDeclaringClass().getModule() != NASHORN_MOD) {
throw new RuntimeException(f + " is not from Nashorn module"); throw new RuntimeException(f + " is not from Nashorn module");
} }