diff --git a/buildSrc/src/main/groovy/rhino.library-conventions.gradle b/buildSrc/src/main/groovy/rhino.library-conventions.gradle index f4c5f13619..3f98be524e 100644 --- a/buildSrc/src/main/groovy/rhino.library-conventions.gradle +++ b/buildSrc/src/main/groovy/rhino.library-conventions.gradle @@ -47,8 +47,8 @@ tasks.withType(JavaCompile).configureEach { "JavaUtilDate", // Less important for now, more stylistic than bug "InlineMeSuggester", - "NonApiType", - "UnnecessaryParentheses", + // This one either alerts for parameters that we don't use, + // or spuriously for local variables in my opinion. "UnusedVariable") options.errorprone.excludedPaths = '.+/src/test/java/.+' } diff --git a/rhino-tools/src/main/java/org/mozilla/javascript/tools/debugger/Dim.java b/rhino-tools/src/main/java/org/mozilla/javascript/tools/debugger/Dim.java index 87d7d74a54..a1ec46c3b3 100644 --- a/rhino-tools/src/main/java/org/mozilla/javascript/tools/debugger/Dim.java +++ b/rhino-tools/src/main/java/org/mozilla/javascript/tools/debugger/Dim.java @@ -255,7 +255,7 @@ private String loadSource(String sourceUrl) { } } - is = (new URL(sourceUrl)).openStream(); + is = new URL(sourceUrl).openStream(); } try { diff --git a/rhino-tools/src/main/java/org/mozilla/javascript/tools/jsc/Main.java b/rhino-tools/src/main/java/org/mozilla/javascript/tools/jsc/Main.java index 058065e414..a34e18f747 100644 --- a/rhino-tools/src/main/java/org/mozilla/javascript/tools/jsc/Main.java +++ b/rhino-tools/src/main/java/org/mozilla/javascript/tools/jsc/Main.java @@ -304,7 +304,7 @@ String getClassName(String name) { s[j] = '_'; } } - return (new String(s)).trim(); + return new String(s).trim(); } private static void p(String s) { diff --git a/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XMLName.java b/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XMLName.java index 9e6ccd4228..c4649e4ac1 100644 --- a/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XMLName.java +++ b/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XMLName.java @@ -409,7 +409,7 @@ final boolean matches(XML node) { return false; } } else { - if (this.uri() == null || ((node.isElement()) && this.uri().equals(nodeUri))) { + if (this.uri() == null || (node.isElement() && this.uri().equals(nodeUri))) { if (localName().equals("*")) return true; if (node.isElement()) { if (localName().equals(qname.getLocalName())) return true; diff --git a/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XMLWithScope.java b/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XMLWithScope.java index bc907b8e9e..aebbc9fbc8 100644 --- a/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XMLWithScope.java +++ b/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XMLWithScope.java @@ -37,7 +37,7 @@ void initAsDotQuery() { if (prototype instanceof XMLList) { XMLList xl = (XMLList) prototype; if (xl.length() > 0) { - setPrototype((Scriptable) (xl.get(0, null))); + setPrototype((Scriptable) xl.get(0, null)); } } // Always return the outer-most type of XML lValue of @@ -70,7 +70,7 @@ protected Object updateDotQuery(boolean value) { // reset the expression to run with this object as // the WITH selector. _currIndex = idx; - setPrototype((Scriptable) (orgXmlL.get(idx, null))); + setPrototype((Scriptable) orgXmlL.get(idx, null)); // continue looping return null; diff --git a/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XmlNode.java b/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XmlNode.java index 43c8618c9e..d3c109bd57 100644 --- a/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XmlNode.java +++ b/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XmlNode.java @@ -501,7 +501,7 @@ final void setLocalName(String localName) { } final QName getQname() { - String uri = (dom.getNamespaceURI()) == null ? "" : dom.getNamespaceURI(); + String uri = dom.getNamespaceURI() == null ? "" : dom.getNamespaceURI(); String prefix = (dom.getPrefix() == null) ? "" : dom.getPrefix(); return QName.create(uri, dom.getLocalName(), prefix); } @@ -830,10 +830,10 @@ void addToList(Object toAdd) { if (toAdd instanceof XMLList) { XMLList xmlSrc = (XMLList) toAdd; for (int i = 0; i < xmlSrc.length(); i++) { - this._add((xmlSrc.item(i)).getAnnotation()); + this._add(xmlSrc.item(i).getAnnotation()); } } else if (toAdd instanceof XML) { - this._add(((XML) (toAdd)).getAnnotation()); + this._add(((XML) toAdd).getAnnotation()); } else if (toAdd instanceof XmlNode) { this._add((XmlNode) toAdd); } diff --git a/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XmlProcessor.java b/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XmlProcessor.java index 0d0bf2d66c..ee67ac1815 100644 --- a/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XmlProcessor.java +++ b/rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XmlProcessor.java @@ -461,7 +461,7 @@ final String ecmaToXmlString(Node node) { if (node instanceof Text) { String data = ((Text) node).getData(); // TODO Does Java trim() work same as XMLWhitespace? - String v = (prettyPrint) ? data.trim() : data; + String v = prettyPrint ? data.trim() : data; s.append(escapeElementValue(v)); return s.toString(); } diff --git a/rhino/src/main/java/org/mozilla/classfile/ClassFileWriter.java b/rhino/src/main/java/org/mozilla/classfile/ClassFileWriter.java index e27549504f..de78d70194 100644 --- a/rhino/src/main/java/org/mozilla/classfile/ClassFileWriter.java +++ b/rhino/src/main/java/org/mozilla/classfile/ClassFileWriter.java @@ -2719,12 +2719,12 @@ private int getWriteSize() { size += 2; // writeShort(itsFields.size()); for (int i = 0; i < itsFields.size(); i++) { - size += ((ClassFileField) (itsFields.get(i))).getWriteSize(); + size += ((ClassFileField) itsFields.get(i)).getWriteSize(); } size += 2; // writeShort(itsMethods.size()); for (int i = 0; i < itsMethods.size(); i++) { - size += ((ClassFileMethod) (itsMethods.get(i))).getWriteSize(); + size += ((ClassFileMethod) itsMethods.get(i)).getWriteSize(); } size += 2; // writeShort(1); attributes count, could be zero @@ -2774,7 +2774,7 @@ public byte[] toByteArray() { offset = putInt16(itsSuperClassIndex, data, offset); offset = putInt16(itsInterfaces.size(), data, offset); for (int i = 0; i < itsInterfaces.size(); i++) { - int interfaceIndex = ((Short) (itsInterfaces.get(i))).shortValue(); + int interfaceIndex = ((Short) itsInterfaces.get(i)).shortValue(); offset = putInt16(interfaceIndex, data, offset); } offset = putInt16(itsFields.size(), data, offset); diff --git a/rhino/src/main/java/org/mozilla/classfile/ConstantPool.java b/rhino/src/main/java/org/mozilla/classfile/ConstantPool.java index 22f9ddb5db..85fe05651f 100644 --- a/rhino/src/main/java/org/mozilla/classfile/ConstantPool.java +++ b/rhino/src/main/java/org/mozilla/classfile/ConstantPool.java @@ -49,7 +49,7 @@ int addConstant(int k) { itsPool[itsTop++] = CONSTANT_Integer; itsTop = ClassFileWriter.putInt32(k, itsPool, itsTop); itsPoolTypes.put(itsTopIndex, CONSTANT_Integer); - return (short) (itsTopIndex++); + return (short) itsTopIndex++; } int addConstant(long k) { @@ -219,7 +219,7 @@ private short addNameAndType(String name, String type) { itsTop = ClassFileWriter.putInt16(nameIndex, itsPool, itsTop); itsTop = ClassFileWriter.putInt16(typeIndex, itsPool, itsTop); itsPoolTypes.put(itsTopIndex, CONSTANT_NameAndType); - return (short) (itsTopIndex++); + return (short) itsTopIndex++; } short addClass(String className) { @@ -298,7 +298,7 @@ short addInterfaceMethodRef(String className, String methodName, String methodTy FieldOrMethodRef r = new FieldOrMethodRef(className, methodName, methodType); setConstantData(itsTopIndex, r); itsPoolTypes.put(itsTopIndex, CONSTANT_InterfaceMethodref); - return (short) (itsTopIndex++); + return (short) itsTopIndex++; } short addInvokeDynamic(String methodName, String methodType, int bootstrapIndex) { @@ -317,7 +317,7 @@ short addInvokeDynamic(String methodName, String methodType, int bootstrapIndex) setConstantData(theIndex, methodType); itsPoolTypes.put(theIndex, CONSTANT_InvokeDynamic); } - return (short) (theIndex); + return (short) theIndex; } short addMethodHandle(ClassFileWriter.MHandle mh) { @@ -341,7 +341,7 @@ short addMethodHandle(ClassFileWriter.MHandle mh) { itsConstantHash.put(mh, theIndex); itsPoolTypes.put(theIndex, CONSTANT_MethodHandle); } - return (short) (theIndex); + return (short) theIndex; } Object getConstantData(int index) { diff --git a/rhino/src/main/java/org/mozilla/javascript/DToA.java b/rhino/src/main/java/org/mozilla/javascript/DToA.java index 3c9d4de64e..3b968d9843 100644 --- a/rhino/src/main/java/org/mozilla/javascript/DToA.java +++ b/rhino/src/main/java/org/mozilla/javascript/DToA.java @@ -142,7 +142,7 @@ private static void stuffBits(byte[] bits, int offset, int val) { bits[offset] = (byte) (val >> 24); bits[offset + 1] = (byte) (val >> 16); bits[offset + 2] = (byte) (val >> 8); - bits[offset + 3] = (byte) (val); + bits[offset + 3] = (byte) val; } /* Convert d into the form b*2^e, where b is an odd integer. b is the returned @@ -153,7 +153,7 @@ private static BigInteger d2b(double d, int[] e, int[] bits) { int i, k, y, z, de; long dBits = Double.doubleToLongBits(d); int d0 = (int) (dBits >>> 32); - int d1 = (int) (dBits); + int d1 = (int) dBits; z = d0 & Frac_mask; d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ @@ -217,7 +217,7 @@ static String JS_dtobasestr(int base, double d) { long lfloor = (long) dfloor; if (lfloor == dfloor) { // int part fits long - intDigits = Long.toString((negative) ? -lfloor : lfloor, base); + intDigits = Long.toString(negative ? -lfloor : lfloor, base); } else { // BigInteger should be used long floorBits = Double.doubleToLongBits(dfloor); @@ -258,7 +258,7 @@ static String JS_dtobasestr(int base, double d) { long dBits = Double.doubleToLongBits(d); int word0 = (int) (dBits >> 32); - int word1 = (int) (dBits); + int word1 = (int) dBits; int[] e = new int[1]; int[] bbits = new int[1]; @@ -298,7 +298,7 @@ static String JS_dtobasestr(int base, double d) { b = b.multiply(bigBase); BigInteger[] divResult = b.divideAndRemainder(s); b = divResult[1]; - digit = (char) (divResult[0].intValue()); + digit = (char) divResult[0].intValue(); if (Objects.equals(mlo, mhi)) mlo = mhi = mlo.multiply(bigBase); else { mlo = mlo.multiply(bigBase); @@ -384,7 +384,7 @@ static double setWord0(double d, int i) { static int word1(double d) { long dBits = Double.doubleToLongBits(d); - return (int) (dBits); + return (int) dBits; } /* Return b * 5^k. k must be nonnegative. */ @@ -782,7 +782,7 @@ static int JS_dtoa( mhi = mlo = null; if (leftright) { if (mode < 2) { - i = (denorm) ? be[0] + (Bias + (P - 1) - 1 + 1) : 1 + P - bbits[0]; + i = denorm ? be[0] + (Bias + (P - 1) - 1 + 1) : 1 + P - bbits[0]; /* i is 1 plus the number of trailing zero bits in d's significand. Thus, (2^m2 * 5^m5) / (2^(s2+i) * 5^s5) = (1/2 lsb of d)/10^k. */ } else { @@ -893,7 +893,7 @@ static int JS_dtoa( Output either zero or the minimum nonzero output depending on which is closer to d. */ if ((ilim < 0) || ((i = b.compareTo(S = S.multiply(BigInteger.valueOf(5)))) < 0) - || ((i == 0 && !biasUp))) { + || (i == 0 && !biasUp)) { /* Always emit at least one digit. If the number appears to be zero using the current mode, then emit one '0' digit and set decpt to 1. */ /*no_digits: diff --git a/rhino/src/main/java/org/mozilla/javascript/FunctionObject.java b/rhino/src/main/java/org/mozilla/javascript/FunctionObject.java index 43db67d23a..e3b73a2ff0 100644 --- a/rhino/src/main/java/org/mozilla/javascript/FunctionObject.java +++ b/rhino/src/main/java/org/mozilla/javascript/FunctionObject.java @@ -363,7 +363,7 @@ public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] ar Boolean b = inNewExpr ? Boolean.TRUE : Boolean.FALSE; Object[] invokeArgs = {cx, args, this, b}; result = - (member.isCtor()) + member.isCtor() ? member.newInstance(invokeArgs) : member.invoke(null, invokeArgs); } diff --git a/rhino/src/main/java/org/mozilla/javascript/ImporterTopLevel.java b/rhino/src/main/java/org/mozilla/javascript/ImporterTopLevel.java index 9baa40071b..fffd2e15a3 100644 --- a/rhino/src/main/java/org/mozilla/javascript/ImporterTopLevel.java +++ b/rhino/src/main/java/org/mozilla/javascript/ImporterTopLevel.java @@ -59,7 +59,7 @@ public ImporterTopLevel(Context cx, boolean sealed) { @Override public String getClassName() { - return (topScopeFlag) ? "global" : "JavaImporter"; + return topScopeFlag ? "global" : "JavaImporter"; } public static void init(Context cx, Scriptable scope, boolean sealed) { diff --git a/rhino/src/main/java/org/mozilla/javascript/JavaAdapter.java b/rhino/src/main/java/org/mozilla/javascript/JavaAdapter.java index e9937fca97..b7dd74adad 100644 --- a/rhino/src/main/java/org/mozilla/javascript/JavaAdapter.java +++ b/rhino/src/main/java/org/mozilla/javascript/JavaAdapter.java @@ -19,7 +19,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Map; +import java.util.Set; import org.mozilla.classfile.ByteCode; import org.mozilla.classfile.ClassFileWriter; @@ -460,8 +462,7 @@ static Method[] getOverridableMethods(Class clazz) { return list.toArray(new Method[0]); } - private static void appendOverridableMethods( - Class c, ArrayList list, HashSet skip) { + private static void appendOverridableMethods(Class c, List list, Set skip) { Method[] methods = c.isInterface() ? c.getMethods() : c.getDeclaredMethods(); for (Method method : methods) { diff --git a/rhino/src/main/java/org/mozilla/javascript/NativeCallSite.java b/rhino/src/main/java/org/mozilla/javascript/NativeCallSite.java index 1647e13d40..05cb18591b 100644 --- a/rhino/src/main/java/org/mozilla/javascript/NativeCallSite.java +++ b/rhino/src/main/java/org/mozilla/javascript/NativeCallSite.java @@ -22,7 +22,7 @@ static void init(Scriptable scope, boolean sealed) { static NativeCallSite make(Scriptable scope, Scriptable ctorObj) { NativeCallSite cs = new NativeCallSite(); - Scriptable proto = (Scriptable) (ctorObj.get("prototype", ctorObj)); + Scriptable proto = (Scriptable) ctorObj.get("prototype", ctorObj); cs.setParentScope(scope); cs.setPrototype(proto); return cs; diff --git a/rhino/src/main/java/org/mozilla/javascript/NativeDate.java b/rhino/src/main/java/org/mozilla/javascript/NativeDate.java index c28b216e2d..805c4685bf 100644 --- a/rhino/src/main/java/org/mozilla/javascript/NativeDate.java +++ b/rhino/src/main/java/org/mozilla/javascript/NativeDate.java @@ -529,10 +529,10 @@ private static boolean IsLeapYear(int year) { * floor((1968 - 1969) / 4) == -1 */ private static double DayFromYear(double y) { - return ((365 * ((y) - 1970) - + Math.floor(((y) - 1969) / 4.0) - - Math.floor(((y) - 1901) / 100.0) - + Math.floor(((y) - 1601) / 400.0))); + return (365 * (y - 1970) + + Math.floor((y - 1969) / 4.0) + - Math.floor((y - 1901) / 100.0) + + Math.floor((y - 1601) / 400.0)); } private static double TimeFromYear(double y) { diff --git a/rhino/src/main/java/org/mozilla/javascript/NativeError.java b/rhino/src/main/java/org/mozilla/javascript/NativeError.java index 01a85cc9db..f766ebf454 100644 --- a/rhino/src/main/java/org/mozilla/javascript/NativeError.java +++ b/rhino/src/main/java/org/mozilla/javascript/NativeError.java @@ -41,7 +41,7 @@ static void init(Scriptable scope, boolean sealed) { } static NativeError make(Context cx, Scriptable scope, IdFunctionObject ctorObj, Object[] args) { - Scriptable proto = (Scriptable) (ctorObj.get("prototype", ctorObj)); + Scriptable proto = (Scriptable) ctorObj.get("prototype", ctorObj); NativeError obj = new NativeError(); obj.setPrototype(proto); diff --git a/rhino/src/main/java/org/mozilla/javascript/NativeJSON.java b/rhino/src/main/java/org/mozilla/javascript/NativeJSON.java index b496ef99d0..1711c33e61 100644 --- a/rhino/src/main/java/org/mozilla/javascript/NativeJSON.java +++ b/rhino/src/main/java/org/mozilla/javascript/NativeJSON.java @@ -579,7 +579,7 @@ private static boolean isObjectArrayLike(Object o) { } if (o instanceof NativeJavaObject) { Object unwrapped = ((NativeJavaObject) o).unwrap(); - return (unwrapped instanceof Collection) || (unwrapped.getClass().isArray()); + return (unwrapped instanceof Collection) || unwrapped.getClass().isArray(); } return false; } diff --git a/rhino/src/main/java/org/mozilla/javascript/ObjToIntMap.java b/rhino/src/main/java/org/mozilla/javascript/ObjToIntMap.java index 9adf9f79b6..afaf1c7167 100644 --- a/rhino/src/main/java/org/mozilla/javascript/ObjToIntMap.java +++ b/rhino/src/main/java/org/mozilla/javascript/ObjToIntMap.java @@ -172,7 +172,7 @@ public Object intern(Object keyArg) { } int index = ensureIndex(keyArg); values[index] = 0; - return (nullKey) ? null : keys[index]; + return nullKey ? null : keys[index]; } public void remove(Object key) { diff --git a/rhino/src/main/java/org/mozilla/javascript/ScriptRuntime.java b/rhino/src/main/java/org/mozilla/javascript/ScriptRuntime.java index fbc7ae1948..468727e16a 100644 --- a/rhino/src/main/java/org/mozilla/javascript/ScriptRuntime.java +++ b/rhino/src/main/java/org/mozilla/javascript/ScriptRuntime.java @@ -147,7 +147,7 @@ public static ScriptableObject initSafeStandardObjects( } scope.associateValue(LIBRARY_SCOPE_KEY, scope); - (new ClassCache()).associate(scope); + new ClassCache().associate(scope); BaseFunction.init(cx, scope, sealed); NativeObject.init(scope, sealed); @@ -2965,7 +2965,7 @@ public static boolean isObject(Object value) { return "object".equals(type) || "function".equals(type); } if (value instanceof Scriptable) { - return (!(value instanceof Callable)); + return !(value instanceof Callable); } return false; } @@ -4982,7 +4982,7 @@ static boolean isGeneratedScript(String sourceUrl) { * just by using an "instanceof" check. */ static boolean isSymbol(Object obj) { - return (((obj instanceof NativeSymbol) && ((NativeSymbol) obj).isSymbol())) + return ((obj instanceof NativeSymbol) && ((NativeSymbol) obj).isSymbol()) || (obj instanceof SymbolKey); } diff --git a/rhino/src/main/java/org/mozilla/javascript/ThreadSafeSlotMapContainer.java b/rhino/src/main/java/org/mozilla/javascript/ThreadSafeSlotMapContainer.java index f0ced5ec06..6d744b4fe5 100644 --- a/rhino/src/main/java/org/mozilla/javascript/ThreadSafeSlotMapContainer.java +++ b/rhino/src/main/java/org/mozilla/javascript/ThreadSafeSlotMapContainer.java @@ -41,7 +41,7 @@ public int size() { @Override public int dirtySize() { - assert (lock.isReadLocked()); + assert lock.isReadLocked(); return map.size(); } @@ -140,7 +140,7 @@ public void unlockRead(long stamp) { @Override public Iterator iterator() { - assert (lock.isReadLocked()); + assert lock.isReadLocked(); return map.iterator(); } @@ -150,7 +150,7 @@ public Iterator iterator() { */ @Override protected void checkMapSize() { - assert (lock.isWriteLocked()); + assert lock.isWriteLocked(); super.checkMapSize(); } } diff --git a/rhino/src/main/java/org/mozilla/javascript/optimizer/Block.java b/rhino/src/main/java/org/mozilla/javascript/optimizer/Block.java index 363a52f12d..e5f5e710d8 100644 --- a/rhino/src/main/java/org/mozilla/javascript/optimizer/Block.java +++ b/rhino/src/main/java/org/mozilla/javascript/optimizer/Block.java @@ -26,7 +26,7 @@ private static Block[] reduceToArray(ObjToIntMap map) { int i = 0; ObjToIntMap.Iterator iter = map.newIterator(); for (iter.start(); !iter.done(); iter.next()) { - FatBlock fb = (FatBlock) (iter.getKey()); + FatBlock fb = (FatBlock) iter.getKey(); result[i++] = fb.realBlock; } } @@ -161,13 +161,13 @@ private static Block[] buildBlocks(Node[] statementNodes) { // build successor and predecessor links for (int i = 0; i < theBlocks.size(); i++) { - FatBlock fb = (FatBlock) (theBlocks.get(i)); + FatBlock fb = (FatBlock) theBlocks.get(i); Node blockEndNode = statementNodes[fb.realBlock.itsEndNodeIndex]; int blockEndNodeType = blockEndNode.getType(); if ((blockEndNodeType != Token.GOTO) && (i < (theBlocks.size() - 1))) { - FatBlock fallThruTarget = (FatBlock) (theBlocks.get(i + 1)); + FatBlock fallThruTarget = (FatBlock) theBlocks.get(i + 1); fb.addSuccessor(fallThruTarget); fallThruTarget.addPredecessor(fb); } @@ -186,7 +186,7 @@ private static Block[] buildBlocks(Node[] statementNodes) { Block[] result = new Block[theBlocks.size()]; for (int i = 0; i < theBlocks.size(); i++) { - FatBlock fb = (FatBlock) (theBlocks.get(i)); + FatBlock fb = (FatBlock) theBlocks.get(i); Block b = fb.realBlock; b.itsSuccessors = fb.getSuccessors(); b.itsPredecessors = fb.getPredecessors(); diff --git a/rhino/src/main/java/org/mozilla/javascript/optimizer/Codegen.java b/rhino/src/main/java/org/mozilla/javascript/optimizer/Codegen.java index bddfb32778..02b51031e8 100644 --- a/rhino/src/main/java/org/mozilla/javascript/optimizer/Codegen.java +++ b/rhino/src/main/java/org/mozilla/javascript/optimizer/Codegen.java @@ -212,7 +212,7 @@ private void transform(ScriptNode tree) { ot.transform(tree, compilerEnv); if (optLevel > 0) { - (new Optimizer()).optimize(tree); + new Optimizer().optimize(tree); } } diff --git a/rhino/src/main/java/org/mozilla/javascript/regexp/NativeRegExp.java b/rhino/src/main/java/org/mozilla/javascript/regexp/NativeRegExp.java index b87de979f2..887b73ed99 100644 --- a/rhino/src/main/java/org/mozilla/javascript/regexp/NativeRegExp.java +++ b/rhino/src/main/java/org/mozilla/javascript/regexp/NativeRegExp.java @@ -813,7 +813,7 @@ private static boolean parseTerm(CompilerState state) { num = 8 * num + (c - '0'); } else break; } - c = (char) (num); + c = (char) num; doFlat(state, c); break; case '1': @@ -851,7 +851,7 @@ private static boolean parseTerm(CompilerState state) { num = 8 * num + (c - '0'); } else break; } - c = (char) (num); + c = (char) num; doFlat(state, c); break; } @@ -913,7 +913,7 @@ private static boolean parseTerm(CompilerState state) { break; } } - c = (char) (n); + c = (char) n; } doFlat(state, c); break; @@ -1150,7 +1150,7 @@ private static int addIndex(byte[] array, int pc, int index) { if (index < 0) throw Kit.codeBug(); if (index > 0xFFFF) throw Context.reportRuntimeError("Too complex regexp"); array[pc] = (byte) (index >> 8); - array[pc + 1] = (byte) (index); + array[pc + 1] = (byte) index; return pc + 2; } @@ -1219,7 +1219,7 @@ private static int emitREBytecode(CompilerState state, RECompiled re, int pc, RE if (t.chr < 256) { if ((state.flags & JSREG_FOLD) != 0) program[pc - 1] = REOP_FLAT1i; else program[pc - 1] = REOP_FLAT1; - program[pc++] = (byte) (t.chr); + program[pc++] = (byte) t.chr; } else { if ((state.flags & JSREG_FOLD) != 0) program[pc - 1] = REOP_UCFLAT1i; else program[pc - 1] = REOP_UCFLAT1; @@ -1252,11 +1252,11 @@ private static int emitREBytecode(CompilerState state, RECompiled re, int pc, RE break; case REOP_QUANT: if ((t.min == 0) && (t.max == -1)) - program[pc - 1] = (t.greedy) ? REOP_STAR : REOP_MINIMALSTAR; + program[pc - 1] = t.greedy ? REOP_STAR : REOP_MINIMALSTAR; else if ((t.min == 0) && (t.max == 1)) - program[pc - 1] = (t.greedy) ? REOP_OPT : REOP_MINIMALOPT; + program[pc - 1] = t.greedy ? REOP_OPT : REOP_MINIMALOPT; else if ((t.min == 1) && (t.max == -1)) - program[pc - 1] = (t.greedy) ? REOP_PLUS : REOP_MINIMALPLUS; + program[pc - 1] = t.greedy ? REOP_PLUS : REOP_MINIMALPLUS; else { if (!t.greedy) program[pc - 1] = REOP_MINIMALQUANT; pc = addIndex(program, pc, t.min); @@ -1426,11 +1426,11 @@ private static void addCharacterRangeToCharSet(RECharSet cs, char c1, char c2) { c2 = (char) (c2 & 0x7); if (byteIndex1 == byteIndex2) { - cs.bits[byteIndex1] |= (byte) (((0xFF) >> (7 - (c2 - c1))) << c1); + cs.bits[byteIndex1] |= (byte) ((0xFF >> (7 - (c2 - c1))) << c1); } else { cs.bits[byteIndex1] |= (byte) (0xFF << c1); for (i = byteIndex1 + 1; i < byteIndex2; i++) cs.bits[i] = (byte) 0xFF; - cs.bits[byteIndex2] |= (byte) ((0xFF) >> (7 - c2)); + cs.bits[byteIndex2] |= (byte) (0xFF >> (7 - c2)); } } @@ -1462,10 +1462,10 @@ private static void processCharSetImpl(REGlobalData gData, RECharSet charSet) { if (src == end) return; if (gData.regexp.source[src] == '^') { - assert (!charSet.sense); + assert !charSet.sense; ++src; } else { - assert (charSet.sense); + assert charSet.sense; } while (src != end) { @@ -1518,7 +1518,7 @@ private static void processCharSetImpl(REGlobalData gData, RECharSet charSet) { } n = (n << 4) | digit; } - thisCh = (char) (n); + thisCh = (char) n; break; case '0': case '1': @@ -1547,7 +1547,7 @@ private static void processCharSetImpl(REGlobalData gData, RECharSet charSet) { else src--; } } - thisCh = (char) (n); + thisCh = (char) n; break; case 'd': @@ -1572,7 +1572,7 @@ private static void processCharSetImpl(REGlobalData gData, RECharSet charSet) { inRange = false; } for (i = (charSet.length - 1); i >= 0; i--) - if (isREWhiteSpace(i)) addCharacterToCharSet(charSet, (char) (i)); + if (isREWhiteSpace(i)) addCharacterToCharSet(charSet, (char) i); continue; case 'S': if (inRange) { @@ -1580,7 +1580,7 @@ private static void processCharSetImpl(REGlobalData gData, RECharSet charSet) { inRange = false; } for (i = (charSet.length - 1); i >= 0; i--) - if (!isREWhiteSpace(i)) addCharacterToCharSet(charSet, (char) (i)); + if (!isREWhiteSpace(i)) addCharacterToCharSet(charSet, (char) i); continue; case 'w': if (inRange) { @@ -1588,7 +1588,7 @@ private static void processCharSetImpl(REGlobalData gData, RECharSet charSet) { inRange = false; } for (i = (charSet.length - 1); i >= 0; i--) - if (isWord((char) i)) addCharacterToCharSet(charSet, (char) (i)); + if (isWord((char) i)) addCharacterToCharSet(charSet, (char) i); continue; case 'W': if (inRange) { @@ -1596,7 +1596,7 @@ private static void processCharSetImpl(REGlobalData gData, RECharSet charSet) { inRange = false; } for (i = (charSet.length - 1); i >= 0; i--) - if (!isWord((char) i)) addCharacterToCharSet(charSet, (char) (i)); + if (!isWord((char) i)) addCharacterToCharSet(charSet, (char) i); continue; default: thisCh = c; @@ -2971,7 +2971,7 @@ class REGlobalData { /** Get start of parenthesis capture contents, -1 for empty. */ int parensIndex(int i) { - return (int) (parens[i]); + return (int) parens[i]; } /** Get length of parenthesis capture contents. */ diff --git a/rhino/src/main/java/org/mozilla/javascript/v8dtoa/DoubleHelper.java b/rhino/src/main/java/org/mozilla/javascript/v8dtoa/DoubleHelper.java index cfe94b7a7f..9a2e9dbd8e 100644 --- a/rhino/src/main/java/org/mozilla/javascript/v8dtoa/DoubleHelper.java +++ b/rhino/src/main/java/org/mozilla/javascript/v8dtoa/DoubleHelper.java @@ -39,7 +39,7 @@ public class DoubleHelper { static final long kHiddenBit = 0x0010000000000000L; static DiyFp asDiyFp(long d64) { - assert (!isSpecial(d64)); + assert !isSpecial(d64); return new DiyFp(significand(d64), exponent(d64)); } diff --git a/rhino/src/main/java/org/mozilla/javascript/v8dtoa/FastDtoa.java b/rhino/src/main/java/org/mozilla/javascript/v8dtoa/FastDtoa.java index b0da31ee5e..4db5985ca0 100644 --- a/rhino/src/main/java/org/mozilla/javascript/v8dtoa/FastDtoa.java +++ b/rhino/src/main/java/org/mozilla/javascript/v8dtoa/FastDtoa.java @@ -355,7 +355,7 @@ static boolean digitGen(DiyFp low, DiyFp w, DiyFp high, FastDtoaBuilder buffer, int integrals = (int) ((too_high.f() >>> -one.e()) & 0xffffffffL); // Modulo by one is an and. long fractionals = too_high.f() & (one.f() - 1); - long result = biggestPowerTen(integrals, DiyFp.kSignificandSize - (-one.e())); + long result = biggestPowerTen(integrals, DiyFp.kSignificandSize - -one.e()); int divider = (int) ((result >>> 32) & 0xffffffffL); int divider_exponent = (int) (result & 0xffffffffL); int kappa = divider_exponent + 1; @@ -487,8 +487,8 @@ static boolean grisu3(double v, FastDtoaBuilder buffer) { public static boolean dtoa(double v, FastDtoaBuilder buffer) { assert (v > 0); - assert (!Double.isNaN(v)); - assert (!Double.isInfinite(v)); + assert !Double.isNaN(v); + assert !Double.isInfinite(v); return grisu3(v, buffer); }