This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
commit 1daf81931797180d6ca309ca5fab35b91cafb770 Author: Gary David Gregory (Code signing key) <ggreg...@apache.org> AuthorDate: Fri Sep 15 17:36:46 2023 -0400 Re-enabled and fix Checkstyle WhitespaceAround "(whitespace) WhitespaceAround: '}' is not followed by whitespace." --- src/conf/checkstyle.xml | 3 +- .../apache/bcel/generic/InstructionConstants.java | 4 +- src/main/java/org/apache/bcel/util/BCELifier.java | 2 +- .../bcel/verifier/statics/Pass2Verifier.java | 64 +++++++++++----------- .../bcel/verifier/statics/Pass3aVerifier.java | 2 +- .../verifier/structurals/ControlFlowGraph.java | 2 +- .../structurals/InstConstraintVisitor.java | 4 +- .../bcel/verifier/structurals/Pass3bVerifier.java | 2 +- .../bcel/verifier/structurals/Subroutines.java | 4 +- 9 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/conf/checkstyle.xml b/src/conf/checkstyle.xml index 325fbdc8..04c7bcb9 100644 --- a/src/conf/checkstyle.xml +++ b/src/conf/checkstyle.xml @@ -112,9 +112,8 @@ limitations under the License. <!-- Too many to fix at present <module name="ParenPad"/> <module name="WhitespaceAfter"/> - <module name="WhitespaceAround"/> --> - + <module name="WhitespaceAround"/> <!-- Modifier Checks --> <!-- See http://checkstyle.sf.net/config_modifiers.html --> <module name="ModifierOrder"/> diff --git a/src/main/java/org/apache/bcel/generic/InstructionConstants.java b/src/main/java/org/apache/bcel/generic/InstructionConstants.java index 56d3dee6..afdaccd2 100644 --- a/src/main/java/org/apache/bcel/generic/InstructionConstants.java +++ b/src/main/java/org/apache/bcel/generic/InstructionConstants.java @@ -37,7 +37,9 @@ public interface InstructionConstants { /** * Deprecated, consider private and ignore. */ - class Clinit {} + class Clinit { + // empty + } /* * NOTE these are not currently immutable, because Instruction has mutable protected fields opcode and length. diff --git a/src/main/java/org/apache/bcel/util/BCELifier.java b/src/main/java/org/apache/bcel/util/BCELifier.java index bdf8d57e..ea253951 100644 --- a/src/main/java/org/apache/bcel/util/BCELifier.java +++ b/src/main/java/org/apache/bcel/util/BCELifier.java @@ -392,7 +392,7 @@ public class BCELifier extends org.apache.bcel.classfile.EmptyVisitor { printWriter.print("new StackMapType[] {"); for (int i = 0; i < types.length; i++) { types[i].accept(this); - if (i < types.length -1) { + if (i < types.length - 1) { printWriter.print(", "); } else { printWriter.print(" }"); diff --git a/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java b/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java index b7228403..d9df124c 100644 --- a/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java +++ b/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java @@ -150,7 +150,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { // method_info-structure-ATTRIBUTES (vmspec2 4.6, 4.7) // ///////////////////////////////////////////////////////// @Override - public void visitCode(final Code obj) {// vmspec2 4.7.3 + public void visitCode(final Code obj) { // vmspec2 4.7.3 try { // No code attribute allowed for native or abstract methods: see visitMethod(Method). // Code array constraints are checked in Pass3 (3a and 3b). @@ -163,8 +163,8 @@ public final class Pass2Verifier extends PassVerifier implements Constants { } if (!(carrier.predecessor() instanceof Method)) { - addMessage( - "Code attribute '" + tostring(obj) + "' is not declared in a method_info structure but in '" + carrier.predecessor() + "'. Ignored."); + addMessage("Code attribute '" + tostring(obj) + "' is not declared in a method_info structure but in '" + carrier.predecessor() + + "'. Ignored."); return; } final Method m = (Method) carrier.predecessor(); // we can assume this method was visited before; @@ -190,7 +190,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { if (vr != VerificationResult.VR_OK) { throw new ClassConstraintException("Code attribute '" + tostring(obj) + "' (method '" + m + "') has an exception_table entry '" - + tostring(element) + "' that references '" + cname + "' as an Exception but it does not pass verification pass 1: " + vr); + + tostring(element) + "' that references '" + cname + "' as an Exception but it does not pass verification pass 1: " + vr); } // We cannot safely trust any other "instanceof" mechanism. We need to transitively verify // the ancestor hierarchy. @@ -206,15 +206,15 @@ public final class Pass2Verifier extends PassVerifier implements Constants { vr = v.doPass1(); if (vr != VerificationResult.VR_OK) { throw new ClassConstraintException("Code attribute '" + tostring(obj) + "' (method '" + m + "') has an exception_table entry '" - + tostring(element) + "' that references '" + cname + "' as an Exception but '" + e.getSuperclassName() - + "' in the ancestor hierachy does not pass verification pass 1: " + vr); + + tostring(element) + "' that references '" + cname + "' as an Exception but '" + e.getSuperclassName() + + "' in the ancestor hierachy does not pass verification pass 1: " + vr); } e = Repository.lookupClass(e.getSuperclassName()); } if (e != t) { throw new ClassConstraintException( - "Code attribute '" + tostring(obj) + "' (method '" + m + "') has an exception_table entry '" + tostring(element) - + "' that references '" + cname + "' as an Exception but it is not a subclass of '" + t.getClassName() + "'."); + "Code attribute '" + tostring(obj) + "' (method '" + m + "') has an exception_table entry '" + tostring(element) + + "' that references '" + cname + "' as an Exception but it is not a subclass of '" + t.getClassName() + "'."); } } } @@ -252,10 +252,10 @@ public final class Pass2Verifier extends PassVerifier implements Constants { for (final Attribute att : atts) { if (!(att instanceof LineNumberTable) && !(att instanceof LocalVariableTable)) { addMessage("Attribute '" + tostring(att) + "' as an attribute of Code attribute '" + tostring(obj) + "' (method '" + m - + "') is unknown and will therefore be ignored."); - } else {// LineNumberTable or LocalVariableTable + + "') is unknown and will therefore be ignored."); + } else { // LineNumberTable or LocalVariableTable addMessage("Attribute '" + tostring(att) + "' as an attribute of Code attribute '" + tostring(obj) + "' (method '" + m - + "') will effectively be ignored and is only useful for debuggers and such."); + + "') will effectively be ignored and is only useful for debuggers and such."); } // LocalVariableTable check (partially delayed to Pass3a). @@ -270,8 +270,8 @@ public final class Pass2Verifier extends PassVerifier implements Constants { final String lvtname = ((ConstantUtf8) cp.getConstant(lvt.getNameIndex())).getBytes(); if (!lvtname.equals("LocalVariableTable")) { - throw new ClassConstraintException( - "The LocalVariableTable attribute '" + tostring(lvt) + "' is not correctly named 'LocalVariableTable' but '" + lvtname + "'."); + throw new ClassConstraintException("The LocalVariableTable attribute '" + tostring(lvt) + + "' is not correctly named 'LocalVariableTable' but '" + lvtname + "'."); } // In JustIce, the check for correct offsets into the code array is delayed to Pass 3a. @@ -280,7 +280,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { final String localname = ((ConstantUtf8) cp.getConstant(localvariable.getNameIndex())).getBytes(); if (!validJavaIdentifier(localname)) { throw new ClassConstraintException("LocalVariableTable '" + tostring(lvt) + "' references a local variable by the name '" - + localname + "' which is not a legal Java simple name."); + + localname + "' which is not a legal Java simple name."); } checkIndex(lvt, localvariable.getSignatureIndex(), CONST_Utf8); @@ -290,28 +290,28 @@ public final class Pass2Verifier extends PassVerifier implements Constants { t = Type.getType(localsig); } catch (final ClassFormatException cfe) { throw new ClassConstraintException("Illegal descriptor (==signature) '" + localsig + "' used by LocalVariable '" - + tostring(localvariable) + "' referenced by '" + tostring(lvt) + "'.", cfe); + + tostring(localvariable) + "' referenced by '" + tostring(lvt) + "'.", cfe); } final int localindex = localvariable.getIndex(); if ((t == Type.LONG || t == Type.DOUBLE ? localindex + 1 : localindex) >= obj.getMaxLocals()) { - throw new ClassConstraintException( - "LocalVariableTable attribute '" + tostring(lvt) + "' references a LocalVariable '" + tostring(localvariable) - + "' with an index that exceeds the surrounding Code attribute's max_locals value of '" + obj.getMaxLocals() + "'."); + throw new ClassConstraintException("LocalVariableTable attribute '" + tostring(lvt) + "' references a LocalVariable '" + + tostring(localvariable) + "' with an index that exceeds the surrounding Code attribute's max_locals value of '" + + obj.getMaxLocals() + "'."); } try { localVariablesInfos[methodNumber].add(localindex, localname, localvariable.getStartPC(), localvariable.getLength(), t); } catch (final LocalVariableInfoInconsistentException lviie) { throw new ClassConstraintException("Conflicting information in LocalVariableTable '" + tostring(lvt) - + "' found in Code attribute '" + tostring(obj) + "' (method '" + tostring(m) + "'). " + lviie.getMessage(), lviie); + + "' found in Code attribute '" + tostring(obj) + "' (method '" + tostring(m) + "'). " + lviie.getMessage(), lviie); } } // for all local variables localvariables[i] in the LocalVariableTable attribute atts[a] END numOfLvtAttribs++; if (!m.isStatic() && numOfLvtAttribs > obj.getMaxLocals()) { throw new ClassConstraintException("Number of LocalVariableTable attributes of Code attribute '" + tostring(obj) + "' (method '" - + tostring(m) + "') exceeds number of local variable slots '" + obj.getMaxLocals() - + "' ('There may be at most one LocalVariableTable attribute per local variable in the Code attribute.')."); + + tostring(m) + "') exceeds number of local variable slots '" + obj.getMaxLocals() + + "' ('There may be at most one LocalVariableTable attribute per local variable in the Code attribute.')."); } } // if atts[a] instanceof LocalVariableTable END } // for all attributes atts[a] END @@ -321,7 +321,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { throw new AssertionViolatedException("Missing class: " + e, e); } - }// visitCode(Code) END + } // visitCode(Code) END @Override public void visitCodeException(final CodeException obj) { @@ -440,7 +440,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { // field_info-structure-ATTRIBUTES (vmspec2 4.5, 4.7) // //////////////////////////////////////////////////////// @Override - public void visitConstantValue(final ConstantValue obj) {// vmspec2 4.7.2 + public void visitConstantValue(final ConstantValue obj) { // vmspec2 4.7.2 // Despite its name, this really is an Attribute, // not a constant! checkIndex(obj, obj.getNameIndex(), CONST_Utf8); @@ -483,7 +483,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { } @Override - public void visitDeprecated(final Deprecated obj) {// vmspec2 4.7.10 + public void visitDeprecated(final Deprecated obj) { // vmspec2 4.7.10 checkIndex(obj, obj.getNameIndex(), CONST_Utf8); final String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes(); @@ -493,7 +493,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { } @Override - public void visitExceptionTable(final ExceptionTable obj) {// vmspec2 4.7.4 + public void visitExceptionTable(final ExceptionTable obj) { // vmspec2 4.7.4 try { // incorrectly named, it's the Exceptions attribute (vmspec2 4.7.4) checkIndex(obj, obj.getNameIndex(), CONST_Utf8); @@ -642,7 +642,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { } @Override - public void visitInnerClasses(final InnerClasses innerClasses) {// vmspec2 4.7.5 + public void visitInnerClasses(final InnerClasses innerClasses) { // vmspec2 4.7.5 // exactly one InnerClasses attr per ClassFile if some inner class is refernced: see visitJavaClass() @@ -743,7 +743,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { // code_attribute-structure-ATTRIBUTES (vmspec2 4.7.3, 4.7) // ////////////////////////////////////////////////////////////// @Override - public void visitLineNumberTable(final LineNumberTable obj) {// vmspec2 4.7.8 + public void visitLineNumberTable(final LineNumberTable obj) { // vmspec2 4.7.8 checkIndex(obj, obj.getNameIndex(), CONST_Utf8); final String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes(); @@ -770,7 +770,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { } @Override - public void visitLocalVariableTable(final LocalVariableTable obj) {// vmspec2 4.7.9 + public void visitLocalVariableTable(final LocalVariableTable obj) { // vmspec2 4.7.9 // In JustIce, this check is partially delayed to Pass 3a. // The other part can be found in the visitCode(Code) method. } @@ -882,7 +882,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { throw new ClassConstraintException("Instance initialization method '" + tostring(obj) + "' must not have" + " any of the ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT modifiers set."); } - } else if (!name.equals(Const.STATIC_INITIALIZER_NAME)) {// vmspec2, p.116, 2nd paragraph + } else if (!name.equals(Const.STATIC_INITIALIZER_NAME)) { // vmspec2, p.116, 2nd paragraph if (jc.getMajor() >= Const.MAJOR_1_8) { if (obj.isPublic() == obj.isPrivate()) { throw new ClassConstraintException( @@ -950,7 +950,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { // ClassFile-structure-ATTRIBUTES (vmspec2 4.1, 4.7) // /////////////////////////////////////////////////////// @Override - public void visitSourceFile(final SourceFile obj) {// vmspec2 4.7.7 + public void visitSourceFile(final SourceFile obj) { // vmspec2 4.7.7 // zero or one SourceFile attr per ClassFile: see visitJavaClass() @@ -975,7 +975,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { } @Override - public void visitSynthetic(final Synthetic obj) {// vmspec2 4.7.6 + public void visitSynthetic(final Synthetic obj) { // vmspec2 4.7.6 checkIndex(obj, obj.getNameIndex(), CONST_Utf8); final String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes(); if (!name.equals("Synthetic")) { @@ -987,7 +987,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { // MISC-structure-ATTRIBUTES (vmspec2 4.7.1, 4.7) // //////////////////////////////////////////////////// @Override - public void visitUnknown(final Unknown obj) {// vmspec2 4.7.1 + public void visitUnknown(final Unknown obj) { // vmspec2 4.7.1 // Represents an unknown attribute. checkIndex(obj, obj.getNameIndex(), CONST_Utf8); diff --git a/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java b/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java index 61e555d7..081126ef 100644 --- a/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java +++ b/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java @@ -1080,7 +1080,7 @@ public final class Pass3aVerifier extends PassVerifier { // array in vmspec2), together with pass 1 (reading code_length bytes and // interpreting them as code[]). So this must not be checked again here. - if (code.getCode().length >= Const.MAX_CODE_SIZE) {// length must be LESS than the max + if (code.getCode().length >= Const.MAX_CODE_SIZE) { // length must be LESS than the max throw new StaticCodeInstructionConstraintException( "Code array in code attribute '" + tostring(code) + "' too big: must be smaller than " + Const.MAX_CODE_SIZE + "65536 bytes."); } diff --git a/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java b/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java index f630683b..0207e755 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java @@ -178,7 +178,7 @@ public class ControlFlowGraph { } Frame inF = inFrames.get(lastExecutionJSR()); - if (inF == null) {// no incoming frame was set, so set it. + if (inF == null) { // no incoming frame was set, so set it. inFrames.put(lastExecutionJSR(), inFrame); inF = inFrame; } else if (inF.equals(inFrame) || !mergeInFrames(inFrame)) { // if there was an "old" inFrame diff --git a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java index 9be313c7..df6ebe83 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java @@ -2114,7 +2114,7 @@ public class InstConstraintVisitor extends EmptyVisitor { @Override public void visitLoadClass(final LoadClass o) { final ObjectType t = o.getLoadClassType(cpg); - if (t != null) {// null means "no class is loaded" + if (t != null) { // null means "no class is loaded" final Verifier v = VerifierFactory.getVerifier(t.getClassName()); final VerificationResult vr = v.doPass2(); if (vr.getStatus() != VerificationResult.VERIFIED_OK) { @@ -2635,7 +2635,7 @@ public class InstConstraintVisitor extends EmptyVisitor { } if (!(o instanceof ASTORE)) { - if (!(stack().peek() == o.getType(cpg))) {// the other xSTORE types are singletons in BCEL. + if (!(stack().peek() == o.getType(cpg))) { // the other xSTORE types are singletons in BCEL. constraintViolated(o, "Stack top type and STOREing Instruction type mismatch: Stack top: '" + stack().peek() + "'; Instruction type: '" + o.getType(cpg) + "'."); } diff --git a/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java b/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java index 7a10e3e1..7e3413b5 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java @@ -228,7 +228,7 @@ public final class Pass3bVerifier extends PassVerifier { final ArrayList<InstructionContext> newchainClone = (ArrayList<InstructionContext>) newchain.clone(); icq.add(theSuccessor, newchainClone); } - } else {// "not a ret" + } else { // "not a ret" // Normal successors. Add them to the queue of successors. final InstructionContext[] succs = u.getSuccessors(); diff --git a/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java b/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java index 56711fe4..27c58dda 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java @@ -332,7 +332,7 @@ public class Subroutines { return ret.toString(); } - }// end Inner Class SubrouteImpl + } // end Inner Class SubrouteImpl /** * A utility method that calculates the successors of a given InstructionHandle <B>in the same subroutine</B>. That @@ -510,7 +510,7 @@ public class Subroutines { instructionsAssigned.add(element); } } - if (actual != all[0]) {// If we don't deal with the top-level 'subroutine' + if (actual != all[0]) { // If we don't deal with the top-level 'subroutine' ((SubroutineImpl) getSubroutine(actual)).setLeavingRET(); } }