Skip to content

Commit

Permalink
All the changes required for a formatter upgrade
Browse files Browse the repository at this point in the history
These are the changes driven by spotless when we upgrade
google-java-format from 1.10.0, which is very old, to 1.23.0, which is
the latest.
  • Loading branch information
gbrail committed Sep 22, 2024
1 parent 459f933 commit 82bcf45
Show file tree
Hide file tree
Showing 84 changed files with 641 additions and 263 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/rhino.java-conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spotless {
// This will have to be changed when Java 11 support is removed.
if (JavaVersion.current() == JavaVersion.VERSION_21) {
java {
googleJavaFormat('1.17.0').aosp()
googleJavaFormat('1.23.0').aosp()
}
} else {
System.out.println("Not running Spotless: Java language version is " + JavaVersion.current())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,35 +242,47 @@ private static Main mainEmbeddedImpl(

// Deprecated methods

/** @deprecated Use {@link #setSize(int, int)} instead. */
/**
* @deprecated Use {@link #setSize(int, int)} instead.
*/
@Deprecated
public void setSize(java.awt.Dimension dimension) {
debugGui.setSize(dimension.width, dimension.height);
}

/** @deprecated The method does nothing and is only present for compatibility. */
/**
* @deprecated The method does nothing and is only present for compatibility.
*/
@Deprecated
public void setOptimizationLevel(int level) {}

/** @deprecated The method is only present for compatibility and should not be called. */
/**
* @deprecated The method is only present for compatibility and should not be called.
*/
@Deprecated
public void contextEntered(Context cx) {
throw new IllegalStateException();
}

/** @deprecated The method is only present for compatibility and should not be called. */
/**
* @deprecated The method is only present for compatibility and should not be called.
*/
@Deprecated
public void contextExited(Context cx) {
throw new IllegalStateException();
}

/** @deprecated The method is only present for compatibility and should not be called. */
/**
* @deprecated The method is only present for compatibility and should not be called.
*/
@Deprecated
public void contextCreated(Context cx) {
throw new IllegalStateException();
}

/** @deprecated The method is only present for compatibility and should not be called. */
/**
* @deprecated The method is only present for compatibility and should not be called.
*/
@Deprecated
public void contextReleased(Context cx) {
throw new IllegalStateException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import org.mozilla.javascript.tools.SourceReader;
import org.mozilla.javascript.tools.ToolErrorReporter;

/** @author Norris Boyd */
/**
* @author Norris Boyd
*/
public class Main {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ public static void defineClass(Context cx, Scriptable thisObj, Object[] args, Fu
* @exception InstantiationException if unable to instantiate the named class
*/
public static void loadClass(Context cx, Scriptable thisObj, Object[] args, Function funObj)
throws IllegalAccessException, InstantiationException, NoSuchMethodException,
throws IllegalAccessException,
InstantiationException,
NoSuchMethodException,
InvocationTargetException {
Class<?> clazz = getClass(args);
if (!Script.class.isAssignableFrom(clazz)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;

/** @author André Bargull */
/**
* @author André Bargull
*/
public abstract class ShellConsole {

private static final Class[] NO_ARG = {};
Expand Down Expand Up @@ -336,7 +338,9 @@ public static ShellConsole getConsole(Scriptable scope, Charset cs) {

private static JLineShellConsoleV1 getJLineShellConsoleV1(
ClassLoader classLoader, Class<?> readerClass, Scriptable scope, Charset cs)
throws NoSuchMethodException, InstantiationException, IllegalAccessException,
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException {
// ConsoleReader reader = new ConsoleReader();
Constructor<?> c = readerClass.getConstructor();
Expand All @@ -359,7 +363,9 @@ private static JLineShellConsoleV1 getJLineShellConsoleV1(

private static JLineShellConsoleV2 getJLineShellConsoleV2(
ClassLoader classLoader, Class<?> readerClass, Scriptable scope, Charset cs)
throws NoSuchMethodException, InstantiationException, IllegalAccessException,
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException {
// ConsoleReader reader = new ConsoleReader();
Constructor<?> c = readerClass.getConstructor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ String uri() {
return delegate.getNamespace().getUri();
}

/** @deprecated */
/**
* @deprecated
*/
@Deprecated
final XmlNode.QName toNodeQname() {
return delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,17 @@ private XMLLibImpl(Scriptable globalScope) {
this.globalScope = globalScope;
}

/** @deprecated */
/**
* @deprecated
*/
@Deprecated
QName qnamePrototype() {
return qnamePrototype;
}

/** @deprecated */
/**
* @deprecated
*/
@Deprecated
Scriptable globalScope() {
return globalScope;
Expand All @@ -142,7 +146,9 @@ private void exportToScope(boolean sealed) {
qnamePrototype.exportAsJSClass(sealed);
}

/** @deprecated */
/**
* @deprecated
*/
@Deprecated
XMLName toAttributeName(Context cx, Object nameValue) {
if (nameValue instanceof XMLName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ static XMLName formStar() {
return rv;
}

/** @deprecated */
/**
* @deprecated
*/
@Deprecated
static XMLName formProperty(XmlNode.Namespace namespace, String localName) {
if (localName != null && localName.equals("*")) localName = null;
Expand Down Expand Up @@ -149,7 +151,9 @@ static XMLName create(XmlNode.QName qname, boolean attribute, boolean descendant
return rv;
}

/** @deprecated */
/**
* @deprecated
*/
@Deprecated
static XMLName create(XmlNode.QName qname) {
return create(qname, false, false);
Expand Down Expand Up @@ -437,7 +441,9 @@ boolean isDescendants() {
}

// TODO Fix whether this is an descendant XMLName at construction?
/** @deprecated */
/**
* @deprecated
*/
@Deprecated
void setIsDescendants() {
// if (isDescendants) throw new IllegalStateException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,9 @@ static QName create(Namespace namespace, String localName) {
return rv;
}

/** @deprecated */
/**
* @deprecated
*/
@Deprecated
static QName create(String uri, String localName, String prefix) {
return create(Namespace.create(prefix, uri), localName);
Expand Down
34 changes: 17 additions & 17 deletions rhino/src/main/java/org/mozilla/classfile/ClassFileWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public void add(int theOpCode, int theOperand) {
// generated and Sun's verifier is expecting type state to be
// placed even at dead blocks of code.
addSuperBlockStart(itsCodeBufferTop + 3);
// fall through...
// fall through...
case ByteCode.IFEQ:
case ByteCode.IFNE:
case ByteCode.IFLT:
Expand Down Expand Up @@ -1861,7 +1861,7 @@ private int execute(int bci) {
case ByteCode.CASTORE:
case ByteCode.SASTORE:
pop();
// fall through
// fall through
case ByteCode.PUTFIELD: // pop; pop
case ByteCode.IF_ICMPEQ:
case ByteCode.IF_ICMPNE:
Expand All @@ -1872,7 +1872,7 @@ private int execute(int bci) {
case ByteCode.IF_ACMPEQ:
case ByteCode.IF_ACMPNE:
pop();
// fall through
// fall through
case ByteCode.IFEQ: // pop
case ByteCode.IFNE:
case ByteCode.IFLT:
Expand Down Expand Up @@ -1914,7 +1914,7 @@ private int execute(int bci) {
case ByteCode.DCMPL:
case ByteCode.DCMPG:
pop();
// fall through
// fall through
case ByteCode.INEG: // pop; push(INTEGER)
case ByteCode.L2I:
case ByteCode.F2I:
Expand All @@ -1925,7 +1925,7 @@ private int execute(int bci) {
case ByteCode.ARRAYLENGTH:
case ByteCode.INSTANCEOF:
pop();
// fall through
// fall through
case ByteCode.ICONST_M1: // push(INTEGER)
case ByteCode.ICONST_0:
case ByteCode.ICONST_1:
Expand Down Expand Up @@ -1955,13 +1955,13 @@ private int execute(int bci) {
case ByteCode.LOR:
case ByteCode.LXOR:
pop();
// fall through
// fall through
case ByteCode.LNEG: // pop; push(LONG)
case ByteCode.I2L:
case ByteCode.F2L:
case ByteCode.D2L:
pop();
// fall through
// fall through
case ByteCode.LCONST_0: // push(LONG)
case ByteCode.LCONST_1:
case ByteCode.LLOAD:
Expand All @@ -1978,13 +1978,13 @@ private int execute(int bci) {
case ByteCode.FDIV:
case ByteCode.FREM:
pop();
// fall through
// fall through
case ByteCode.FNEG: // pop; push(FLOAT)
case ByteCode.I2F:
case ByteCode.L2F:
case ByteCode.D2F:
pop();
// fall through
// fall through
case ByteCode.FCONST_0: // push(FLOAT)
case ByteCode.FCONST_1:
case ByteCode.FCONST_2:
Expand All @@ -2002,13 +2002,13 @@ private int execute(int bci) {
case ByteCode.DDIV:
case ByteCode.DREM:
pop();
// fall through
// fall through
case ByteCode.DNEG: // pop; push(DOUBLE)
case ByteCode.I2D:
case ByteCode.L2D:
case ByteCode.F2D:
pop();
// fall through
// fall through
case ByteCode.DCONST_0: // push(DOUBLE)
case ByteCode.DCONST_1:
case ByteCode.DLOAD:
Expand Down Expand Up @@ -2188,7 +2188,7 @@ private int execute(int bci) {
break;
case ByteCode.GETFIELD:
pop();
// fall through
// fall through
case ByteCode.GETSTATIC:
index = getOperand(bci + 1, 2);
FieldOrMethodRef f = (FieldOrMethodRef) itsConstantPool.getConstantData(index);
Expand Down Expand Up @@ -2259,7 +2259,7 @@ private int execute(int bci) {
break;
case ByteCode.MULTIANEWARRAY:
case ByteCode.LOOKUPSWITCH:
// Currently not used in any part of Rhino, so ignore it
// Currently not used in any part of Rhino, so ignore it
case ByteCode.JSR: // TODO: JSR is deprecated
case ByteCode.RET:
case ByteCode.JSR_W:
Expand Down Expand Up @@ -2855,7 +2855,7 @@ private static int sizeOfParameters(String pString) {
case 'J':
case 'D':
--stackDiff;
// fall through
// fall through
case 'B':
case 'S':
case 'C':
Expand Down Expand Up @@ -2892,7 +2892,7 @@ private static int sizeOfParameters(String pString) {
case 'L':
// fall through
}
// fall through
// fall through
case 'L':
{
--stackDiff;
Expand All @@ -2916,7 +2916,7 @@ private static int sizeOfParameters(String pString) {
case 'J':
case 'D':
++stackDiff;
// fall through
// fall through
case 'B':
case 'S':
case 'C':
Expand All @@ -2926,7 +2926,7 @@ private static int sizeOfParameters(String pString) {
case 'L':
case '[':
++stackDiff;
// fall through
// fall through
case 'V':
break;
}
Expand Down
4 changes: 3 additions & 1 deletion rhino/src/main/java/org/mozilla/javascript/BaseFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ static void init(Context cx, Scriptable scope, boolean sealed) {
obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
}

/** @deprecated Use {@link #init(Context, Scriptable, boolean)} instead */
/**
* @deprecated Use {@link #init(Context, Scriptable, boolean)} instead
*/
@Deprecated
static void init(Scriptable scope, boolean sealed) {
init(Context.getContext(), scope, sealed);
Expand Down
4 changes: 3 additions & 1 deletion rhino/src/main/java/org/mozilla/javascript/ClassCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ public synchronized void setCachingEnabled(boolean enabled) {
cachingIsEnabled = enabled;
}

/** @return a map from classes to associated JavaMembers objects */
/**
* @return a map from classes to associated JavaMembers objects
*/
Map<CacheKey, JavaMembers> getClassCacheMap() {
if (classTable == null) {
// Use 1 as concurrency level here and for other concurrent hash maps
Expand Down
4 changes: 2 additions & 2 deletions rhino/src/main/java/org/mozilla/javascript/CodeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private void visitStatement(Node node, int initialStackDepth) {
case Token.EMPTY:
case Token.WITH:
updateLineNumber(node);
// fall through
// fall through
case Token.SCRIPT:
while (child != null) {
visitStatement(child, initialStackDepth);
Expand Down Expand Up @@ -1443,7 +1443,7 @@ private void addVarOp(int op, int varIndex) {
addUint8(varIndex);
return;
}
// fallthrough
// fallthrough
case Icode_VAR_INC_DEC:
addIndexOp(op, varIndex);
return;
Expand Down
Loading

0 comments on commit 82bcf45

Please sign in to comment.