This is an automated email from the ASF dual-hosted git repository. garydgregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
commit f13557365043f1cb6aaa3a3e71f0d326fe934a9c Author: Gary Gregory <[email protected]> AuthorDate: Fri Oct 30 07:22:05 2026 -0400 Clean up comments for spelling, grammar, and readability Paragraph tags on their own lines. --- src/changes/changes.xml | 1 + src/examples/ClassDumper.java | 2 +- src/examples/Mini/ASTExpr.java | 2 +- src/examples/Mini/ASTFunDecl.java | 2 +- src/examples/Mini/ASTIfExpr.java | 6 ++-- src/examples/Mini/Variable.java | 2 +- src/examples/Package.java | 10 +++---- .../java/org/apache/bcel/classfile/JavaClass.java | 2 +- .../apache/bcel/generic/AnnotationEntryGen.java | 4 +-- .../org/apache/bcel/generic/BranchInstruction.java | 2 +- .../java/org/apache/bcel/generic/FieldGen.java | 2 +- src/main/java/org/apache/bcel/generic/ICONST.java | 2 +- .../java/org/apache/bcel/generic/MethodGen.java | 6 ++-- src/main/java/org/apache/bcel/generic/Select.java | 2 +- .../bcel/verifier/statics/Pass1Verifier.java | 2 +- .../bcel/verifier/statics/Pass2Verifier.java | 32 +++++++++++----------- .../bcel/verifier/statics/Pass3aVerifier.java | 32 +++++++++++----------- .../verifier/structurals/ControlFlowGraph.java | 2 +- .../structurals/InstConstraintVisitor.java | 26 +++++++++--------- .../bcel/verifier/structurals/LocalVariables.java | 8 +++--- .../bcel/verifier/structurals/OperandStack.java | 6 ++-- .../bcel/verifier/structurals/Pass3bVerifier.java | 4 +-- .../bcel/verifier/structurals/Subroutines.java | 2 +- .../org/apache/bcel/AnnotationAccessFlagTest.java | 4 +-- .../java/org/apache/bcel/ElementValueGenTest.java | 20 +++++++------- .../java/org/apache/bcel/EnumAccessFlagTest.java | 4 +-- .../java/org/apache/bcel/classfile/RecordTest.java | 6 ++-- .../org/apache/bcel/classfile/UtilityTest.java | 2 +- .../apache/bcel/generic/FieldAnnotationsTest.java | 6 ++-- .../generic/GeneratingAnnotatedClassesTest.java | 2 +- .../apache/bcel/verifier/VerifierInvokeTest.java | 12 ++++---- .../apache/bcel/verifier/VerifierReturnTest.java | 12 ++++---- .../apache/bcel/verifier/VerifierThrowTest.java | 2 +- .../apache/bcel/verifier/VerifyBadClassesTest.java | 2 +- 34 files changed, 116 insertions(+), 115 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index d8f65537..9c0e4611 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -67,6 +67,7 @@ The <action> type attribute can be add,update,fix,remove. <action issue="BCEL-379" type="fix" dev="ggregory" due-to="Gary Gregory, Aryan Ganjoo">BCELifier emits boolean literals for boolean ConstantValue fields so generated creator classes run. FieldGen preserves explicit false initial values (#536).</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Update ECJ versions and generate the SWAP fixture with BCEL (#537).</action> <action type="fix" dev="ggregory" due-to="Mohd Irshad">Fix typo 'preceeding' in ConstantPool exception message (#541).</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Clean up comments for spelling, grammar, and readability.</action> <!-- ADD --> <action type="add" dev="ggregory" due-to="Gary Gregory">Add and use ClassFormatException.ClassFormatException(String, Object...).</action> <action type="add" dev="ggregory" due-to="Nicolas Baumann, Gary Gregory">Add support for the RuntimeVisibleTypeAnnotations and RuntimeInvisibleTypeAnnotations attributes.</action> diff --git a/src/examples/ClassDumper.java b/src/examples/ClassDumper.java index 53a9f647..18c84ed2 100644 --- a/src/examples/ClassDumper.java +++ b/src/examples/ClassDumper.java @@ -333,7 +333,7 @@ final class DumpClass { public static void main(final String[] args) throws IOException { if (args.length != 1) { - throw new IllegalArgumentException("Require file name as only argument"); + throw new IllegalArgumentException("A file name is required as the only argument"); } try (FileImageInputStream file = new FileImageInputStream(new File(args[0]))) { new ClassDumper(file, args[0]).dump(); diff --git a/src/examples/Mini/ASTExpr.java b/src/examples/Mini/ASTExpr.java index 73f55425..24f89ab6 100644 --- a/src/examples/Mini/ASTExpr.java +++ b/src/examples/Mini/ASTExpr.java @@ -324,7 +324,7 @@ public class ASTExpr extends SimpleNode implements MiniParserConstants, MiniPars if (t != childType) { MiniC.addError(expr.getLine(), expr.getColumn(), - "Expression has not expected type " + Const.getTypeName(childType) + " but " + Const.getTypeName(t) + "."); + "Expression does not have the expected type " + Const.getTypeName(childType) + " but " + Const.getTypeName(t) + "."); } is_simple = is_simple && expr.isSimple(); diff --git a/src/examples/Mini/ASTFunDecl.java b/src/examples/Mini/ASTFunDecl.java index 8519698c..2826caa5 100644 --- a/src/examples/Mini/ASTFunDecl.java +++ b/src/examples/Mini/ASTFunDecl.java @@ -368,7 +368,7 @@ public class ASTFunDecl extends SimpleNode implements MiniParserTreeConstants { if (expected != Const.T_UNKNOWN && type != expected) { MiniC.addError(line, column, - "Function f ist not of type " + Const.getTypeName(expected) + " as previously assumed, but " + Const.getTypeName(type)); + "Function f is not of type " + Const.getTypeName(expected) + " as previously assumed, but " + Const.getTypeName(type)); } name.setType(type); diff --git a/src/examples/Mini/ASTIfExpr.java b/src/examples/Mini/ASTIfExpr.java index 38cb951f..3df06ee9 100644 --- a/src/examples/Mini/ASTIfExpr.java +++ b/src/examples/Mini/ASTIfExpr.java @@ -133,7 +133,7 @@ public class ASTIfExpr extends ASTExpr { if (expected != Const.T_UNKNOWN && thenType != expected) { MiniC.addError(then_expr.getLine(), then_expr.getColumn(), - "THEN expression is not of expected type " + Const.getTypeName(expected) + " but " + Const.getTypeName(thenType) + "."); + "THEN expression is not of the expected type " + Const.getTypeName(expected) + " but " + Const.getTypeName(thenType) + "."); } if (else_expr != null) { @@ -141,7 +141,7 @@ public class ASTIfExpr extends ASTExpr { if (expected != Const.T_UNKNOWN && elseType != expected) { MiniC.addError(else_expr.getLine(), else_expr.getColumn(), - "ELSE expression is not of expected type " + Const.getTypeName(expected) + " but " + Const.getTypeName(elseType) + "."); + "ELSE expression is not of the expected type " + Const.getTypeName(expected) + " but " + Const.getTypeName(elseType) + "."); } else if (thenType == Const.T_UNKNOWN) { thenType = elseType; then_expr.setType(elseType); @@ -152,7 +152,7 @@ public class ASTIfExpr extends ASTExpr { } if (thenType != elseType) { - MiniC.addError(line, column, "Type mismatch in THEN-ELSE: " + Const.getTypeName(thenType) + " vs. " + Const.getTypeName(elseType) + "."); + MiniC.addError(line, column, "Type mismatch in THEN-ELSE: " + Const.getTypeName(thenType) + " versus " + Const.getTypeName(elseType) + "."); } type = thenType; diff --git a/src/examples/Mini/Variable.java b/src/examples/Mini/Variable.java index 4a530443..98f5892a 100644 --- a/src/examples/Mini/Variable.java +++ b/src/examples/Mini/Variable.java @@ -80,6 +80,6 @@ public class Variable implements EnvEntry { if (!reserved) { return var_name + " declared at line " + line + ", column " + column; } - return var_name + " <reserved key word>"; + return var_name + " <reserved keyword>"; } } diff --git a/src/examples/Package.java b/src/examples/Package.java index ef009b82..af8e9eac 100644 --- a/src/examples/Package.java +++ b/src/examples/Package.java @@ -259,17 +259,17 @@ public class Package { public void usage() { System.out.println(" This program packages classes and all their dependents"); System.out.println(" into one jar. Give all starting classes (your main)"); - System.out.println(" on the command line. Use / as separator, the .class is"); - System.out.println(" optional. We use the environments CLASSPATH to resolve"); - System.out.println(" classes. Anything but java.* packages are packaged."); + System.out.println(" on the command line. Use / as the separator; the .class extension is"); + System.out.println(" optional. We use the CLASSPATH environment variable to resolve"); + System.out.println(" classes. All classes except those in java.* packages are packaged."); System.out.println(" If you use Class.forName (or similar), be sure to"); System.out.println(" include the classes that you load dynamically on the"); System.out.println(" command line.\n"); System.out.println(" These options are recognized:"); System.out.println(" -e -error Show errors, meaning classes that could not "); - System.out.println(" resolved + the classes that referenced them."); + System.out.println(" be resolved, plus the classes that referenced them."); System.out.println(" -l -log Show classes as they are processed. This will"); - System.out.println(" include doubles, java classes and is difficult to"); + System.out.println(" include duplicates and Java classes and may be difficult to"); System.out.println(" read. I use it as a sort of progress monitor"); System.out.println(" -s -show Prints all the classes that were packaged"); System.out.println(" in alphabetical order, which is ordered by package"); diff --git a/src/main/java/org/apache/bcel/classfile/JavaClass.java b/src/main/java/org/apache/bcel/classfile/JavaClass.java index 825496a2..94f1e566 100644 --- a/src/main/java/org/apache/bcel/classfile/JavaClass.java +++ b/src/main/java/org/apache/bcel/classfile/JavaClass.java @@ -803,7 +803,7 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl */ public boolean implementationOf(final JavaClass inter) throws ClassNotFoundException { if (!inter.isInterface()) { - throw new IllegalArgumentException(inter.getClassName() + " is no interface"); + throw new IllegalArgumentException(inter.getClassName() + " is not an interface"); } if (equals(inter)) { return true; diff --git a/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java b/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java index 560d90f0..94de96ca 100644 --- a/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java +++ b/src/main/java/org/apache/bcel/generic/AnnotationEntryGen.java @@ -115,7 +115,7 @@ public class AnnotationEntryGen { return newAttributes.toArray(Attribute.EMPTY_ARRAY); } catch (final IOException e) { - System.err.println("IOException whilst processing annotations"); + System.err.println("IOException while processing annotations"); e.printStackTrace(); } return null; @@ -195,7 +195,7 @@ public class AnnotationEntryGen { } return newAttributes.toArray(Attribute.EMPTY_ARRAY); } catch (final IOException e) { - System.err.println("IOException whilst processing parameter annotations"); + System.err.println("IOException while processing parameter annotations"); e.printStackTrace(); } return null; diff --git a/src/main/java/org/apache/bcel/generic/BranchInstruction.java b/src/main/java/org/apache/bcel/generic/BranchInstruction.java index 916b1ac4..204a8cf6 100644 --- a/src/main/java/org/apache/bcel/generic/BranchInstruction.java +++ b/src/main/java/org/apache/bcel/generic/BranchInstruction.java @@ -156,7 +156,7 @@ public abstract class BranchInstruction extends Instruction implements Instructi */ protected int getTargetOffset(final InstructionHandle target) { if (target == null) { - throw new ClassGenException("Target of " + super.toString(true) + " is invalid null handle"); + throw new ClassGenException("Target of " + super.toString(true) + " is an invalid null handle"); } final int t = target.getPosition(); if (t < 0) { diff --git a/src/main/java/org/apache/bcel/generic/FieldGen.java b/src/main/java/org/apache/bcel/generic/FieldGen.java index 3a3f73e3..c59ebdae 100644 --- a/src/main/java/org/apache/bcel/generic/FieldGen.java +++ b/src/main/java/org/apache/bcel/generic/FieldGen.java @@ -167,7 +167,7 @@ public class FieldGen extends FieldGenOrMethodGen { throw new ClassGenException("Only final fields may have an initial value."); } if (!superType.equals(atype)) { - throw new ClassGenException("Types are not compatible: " + superType + " vs. " + atype); + throw new ClassGenException("Types are not compatible: " + superType + " versus " + atype); } } diff --git a/src/main/java/org/apache/bcel/generic/ICONST.java b/src/main/java/org/apache/bcel/generic/ICONST.java index ba739805..45e143c1 100644 --- a/src/main/java/org/apache/bcel/generic/ICONST.java +++ b/src/main/java/org/apache/bcel/generic/ICONST.java @@ -44,7 +44,7 @@ public class ICONST extends Instruction implements ConstantPushInstruction { public ICONST(final int i) { super(org.apache.bcel.Const.ICONST_0, (short) 1); if (i < -1 || i > 5) { - throw new ClassGenException("ICONST can be used only for value between -1 and 5: " + i); + throw new ClassGenException("ICONST can be used only for values between -1 and 5: " + i); } super.setOpcode((short) (org.apache.bcel.Const.ICONST_0 + i)); // Even works for i == -1 value = i; diff --git a/src/main/java/org/apache/bcel/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java index c7bc6237..0e0e4aeb 100644 --- a/src/main/java/org/apache/bcel/generic/MethodGen.java +++ b/src/main/java/org/apache/bcel/generic/MethodGen.java @@ -293,7 +293,7 @@ public class MethodGen extends FieldGenOrMethodGen { } if (argNames != null) { // Names for variables provided? if (size != argNames.length) { - throw new ClassGenException("Mismatch in argument array lengths: " + size + " vs. " + argNames.length); + throw new ClassGenException("Mismatch in argument array lengths: " + size + " versus " + argNames.length); } } else { // Give them dummy names argNames = new String[size]; @@ -422,7 +422,7 @@ public class MethodGen extends FieldGenOrMethodGen { public CodeExceptionGen addExceptionHandler(final InstructionHandle startPc, final InstructionHandle endPc, final InstructionHandle handlerPc, final ObjectType catchType) { if (startPc == null || endPc == null || handlerPc == null) { - throw new ClassGenException("Exception handler target is null instruction"); + throw new ClassGenException("Exception handler target is a null instruction"); } final CodeExceptionGen c = new CodeExceptionGen(startPc, endPc, handlerPc, catchType); exceptionList.add(c); @@ -501,7 +501,7 @@ public class MethodGen extends FieldGenOrMethodGen { } return l; } - throw new IllegalArgumentException("Can not use " + type + " as type for local variable"); + throw new IllegalArgumentException("Cannot use " + type + " as the type of a local variable"); } /** diff --git a/src/main/java/org/apache/bcel/generic/Select.java b/src/main/java/org/apache/bcel/generic/Select.java index 0a20baa4..ba608c94 100644 --- a/src/main/java/org/apache/bcel/generic/Select.java +++ b/src/main/java/org/apache/bcel/generic/Select.java @@ -95,7 +95,7 @@ public abstract class Select extends BranchInstruction implements VariableLength notifyTarget(null, target2, this); } if ((match_length = match.length) != targets.length) { - throw new ClassGenException("Match and target array have not the same length: Match length: " + match.length + " Target length: " + targets.length); + throw new ClassGenException("Match and target arrays do not have the same length: Match length: " + match.length + " Target length: " + targets.length); } indices = new int[match_length]; } diff --git a/src/main/java/org/apache/bcel/verifier/statics/Pass1Verifier.java b/src/main/java/org/apache/bcel/verifier/statics/Pass1Verifier.java index 37e1ff0c..238938fe 100644 --- a/src/main/java/org/apache/bcel/verifier/statics/Pass1Verifier.java +++ b/src/main/java/org/apache/bcel/verifier/statics/Pass1Verifier.java @@ -147,7 +147,7 @@ public final class Pass1Verifier extends PassVerifier { } catch (final RuntimeException e) { // BCEL does not catch every possible RuntimeException; for example if // a constant pool index is referenced that does not exist. - return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Parsing via BCEL did not succeed. exception occurred:\n" + e.toString()); + return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Parsing via BCEL did not succeed. An exception occurred:\n" + e.toString()); // Don't think we want to dump a stack trace unless we have some sort of a debug option. // e.getClass().getName()+" occurred:\n"+Utility.getStackTrace(e)); } 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 791c3bb9..de6e9d75 100644 --- a/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java +++ b/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java @@ -215,7 +215,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 '" + e.getSuperclassName() - + "' in the ancestor hierachy does not pass verification pass 1: " + vr); + + "' in the ancestor hierarchy does not pass verification pass 1: " + vr); } e = Repository.lookupClass(e.getSuperclassName()); } @@ -548,7 +548,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { vr = v.doPass1(); if (vr != VerificationResult.VR_OK) { throw new ClassConstraintException("Exceptions attribute '" + tostring(obj) + "' references '" + cname + "' as an Exception but '" - + e.getSuperclassName() + "' in the ancestor hierachy does not pass verification pass 1: " + vr); + + e.getSuperclassName() + "' in the ancestor hierarchy does not pass verification pass 1: " + vr); } e = Repository.lookupClass(e.getSuperclassName()); } @@ -583,12 +583,12 @@ public final class Pass2Verifier extends PassVerifier implements Constants { } if (maxone > 1) { throw new ClassConstraintException( - "Field '" + tostring(obj) + "' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set."); + "Field '" + tostring(obj) + "' must have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set."); } if (obj.isFinal() && obj.isVolatile()) { throw new ClassConstraintException( - "Field '" + tostring(obj) + "' must only have at most one of its ACC_FINAL, ACC_VOLATILE modifiers set."); + "Field '" + tostring(obj) + "' must have at most one of its ACC_FINAL, ACC_VOLATILE modifiers set."); } } else { // isInterface! if (!obj.isPublic()) { @@ -612,7 +612,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { final String name = obj.getName(); if (!validFieldName(name)) { - throw new ClassConstraintException("Field '" + tostring(obj) + "' has illegal name '" + obj.getName() + "'."); + throw new ClassConstraintException("Field '" + tostring(obj) + "' has an illegal name '" + obj.getName() + "'."); } // A descriptor is often named signature in BCEL @@ -628,7 +628,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { final String nameanddesc = name + sig; if (fieldNamesAndDesc.contains(nameanddesc)) { - throw new ClassConstraintException("No two fields (like '" + tostring(obj) + "') are allowed have same names and descriptors."); + throw new ClassConstraintException("No two fields (like '" + tostring(obj) + "') are allowed to have the same name and descriptor."); } if (fieldNames.contains(name)) { addMessage("More than one field of name '" + name + "' detected (but with different type descriptors). This is very unusual."); @@ -798,7 +798,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { final String name = obj.getName(); if (!validMethodName(name, true)) { - throw new ClassConstraintException("Method '" + tostring(obj) + "' has illegal name '" + name + "'."); + throw new ClassConstraintException("Method '" + tostring(obj) + "' has an illegal name '" + name + "'."); } // A descriptor is often named signature in BCEL @@ -847,7 +847,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { // Nearly forgot this! Funny return values are allowed, but a non-empty arguments list makes a different method out of // it! if (name.equals(Const.STATIC_INITIALIZER_NAME) && ts.length != 0) { - throw new ClassConstraintException("Method '" + tostring(obj) + "' has illegal name '" + name + "'." + throw new ClassConstraintException("Method '" + tostring(obj) + "' has an illegal name '" + name + "'." + " Its name resembles the class or interface initialization method which it isn't because of its arguments (==descriptor)."); } @@ -864,7 +864,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { } if (maxone > 1) { throw new ClassConstraintException( - "Method '" + tostring(obj) + "' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set."); + "Method '" + tostring(obj) + "' must have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set."); } if (obj.isAbstract()) { @@ -929,7 +929,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { final String nameanddesc = name + sig; if (methodNamesAndDesc.contains(nameanddesc)) { - throw new ClassConstraintException("No two methods (like '" + tostring(obj) + "') are allowed have same names and desciptors."); + throw new ClassConstraintException("No two methods (like '" + tostring(obj) + "') are allowed to have the same name and descriptor."); } methodNamesAndDesc.add(nameanddesc); @@ -1026,7 +1026,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { @Override public void visitConstantFieldref(final ConstantFieldref obj) { if (obj.getTag() != Const.CONSTANT_Fieldref) { - throw new ClassConstraintException("ConstantFieldref '" + tostring(obj) + "' has wrong tag."); + throw new ClassConstraintException("ConstantFieldref '" + tostring(obj) + "' has the wrong tag."); } final int nameAndTypeIndex = obj.getNameAndTypeIndex(); final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(nameAndTypeIndex); @@ -1054,7 +1054,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { @Override public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref obj) { if (obj.getTag() != Const.CONSTANT_InterfaceMethodref) { - throw new ClassConstraintException("ConstantInterfaceMethodref '" + tostring(obj) + "' has wrong tag."); + throw new ClassConstraintException("ConstantInterfaceMethodref '" + tostring(obj) + "' has the wrong tag."); } final int nameAndTypeIndex = obj.getNameAndTypeIndex(); final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(nameAndTypeIndex); @@ -1087,7 +1087,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { @Override public void visitConstantMethodref(final ConstantMethodref obj) { if (obj.getTag() != Const.CONSTANT_Methodref) { - throw new ClassConstraintException("ConstantMethodref '" + tostring(obj) + "' has wrong tag."); + throw new ClassConstraintException("ConstantMethodref '" + tostring(obj) + "' has the wrong tag."); } final int nameAndTypeIndex = obj.getNameAndTypeIndex(); final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(nameAndTypeIndex); @@ -1432,11 +1432,11 @@ public final class Pass2Verifier extends PassVerifier implements Constants { if (map.containsKey(nameAndSig) && method.isFinal()) { if (!method.isPrivate()) { throw new ClassConstraintException("Method '" + nameAndSig + "' in class '" + map.get(nameAndSig) - + "' overrides the final (not-overridable) definition in class '" + jc.getClassName() + "'."); + + "' overrides the final (non-overridable) definition in class '" + jc.getClassName() + "'."); } addMessage("Method '" + nameAndSig + "' in class '" + map.get(nameAndSig) - + "' overrides the final (not-overridable) definition in class '" + jc.getClassName() - + "'. This is okay, as the original definition was private; however this constraint leverage" + + "' overrides the final (non-overridable) definition in class '" + jc.getClassName() + + "'. This is okay, as the original definition was private; however, this relaxation of the constraint" + " was introduced by JLS 8.4.6 (not vmspec2) and the behavior of the Sun verifiers."); } else if (!method.isStatic()) { // static methods don't inherit map.put(nameAndSig, jc.getClassName()); 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 3489eb73..946a4f28 100644 --- a/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java +++ b/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java @@ -294,7 +294,7 @@ public final class Pass3aVerifier extends PassVerifier { final int idx = o.getIndex(); if (idx < 0) { constraintViolated(o, "Index '" + idx + "' must be non-negative." - + " [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); + + " [Constraint imposed by JustIce by analogy with the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); } else { final int maxminus2 = maxLocals() - 2; if (idx > maxminus2) { @@ -309,7 +309,7 @@ public final class Pass3aVerifier extends PassVerifier { final int idx = o.getIndex(); if (idx < 0) { constraintViolated(o, "Index '" + idx + "' must be non-negative." - + " [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); + + " [Constraint imposed by JustIce by analogy with the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); } else { final int maxminus2 = maxLocals() - 2; if (idx > maxminus2) { @@ -639,7 +639,7 @@ public final class Pass3aVerifier extends PassVerifier { } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this // throw new AssertionViolatedException("Missing class: " + e, e); - addMessage("Unable to verify INVOKEVITUAL as cannot load target class: " + e.getCause()); + addMessage("Unable to verify INVOKEVIRTUAL because the target class cannot be loaded: " + e.getCause()); } } @@ -684,7 +684,7 @@ public final class Pass3aVerifier extends PassVerifier { try { indexValid(o, o.getIndex() + 1); } catch (final StaticCodeInstructionOperandConstraintException e) { - throw new AssertionViolatedException("Does not BCEL handle that? LDC2_W operand has a problem.", e); + throw new AssertionViolatedException("Does BCEL not handle that? LDC2_W operand has a problem.", e); } } @@ -694,7 +694,7 @@ public final class Pass3aVerifier extends PassVerifier { final int idx = o.getIndex(); if (idx < 0) { constraintViolated(o, "Index '" + idx + "' must be non-negative." - + " [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); + + " [Constraint imposed by JustIce by analogy with the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); } else { final int maxminus2 = maxLocals() - 2; if (idx > maxminus2) { @@ -756,7 +756,7 @@ public final class Pass3aVerifier extends PassVerifier { final int idx = o.getIndex(); if (idx < 0) { constraintViolated(o, "Index '" + idx + "' must be non-negative." - + " [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); + + " [Constraint imposed by JustIce by analogy with the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); } else { final int maxminus2 = maxLocals() - 2; if (idx > maxminus2) { @@ -781,7 +781,7 @@ public final class Pass3aVerifier extends PassVerifier { if (t instanceof ArrayType) { final int dimensions = ((ArrayType) t).getDimensions(); if (dimensions < dimensions2create) { - constraintViolated(o, "Not allowed to create array with more dimensions ('" + dimensions2create + constraintViolated(o, "Not allowed to create an array with more dimensions ('" + dimensions2create + "') than the one referenced by the CONSTANT_Class '" + t + "'."); } } else { @@ -940,7 +940,7 @@ public final class Pass3aVerifier extends PassVerifier { } if (offsets.contains(offset)) { addMessage("LineNumberTable attribute '" + code.getLineNumberTable() + "' refers to the same code offset ('" + offset - + "') more than once which is violating the semantics [but is sometimes produced by IBM's 'jikes' compiler]."); + + "') more than once, which violates the semantics [but is sometimes produced by IBM's 'jikes' compiler]."); } else { offsets.add(offset); } @@ -990,16 +990,16 @@ public final class Pass3aVerifier extends PassVerifier { } if (!instructionPositionSet.contains(Integer.valueOf(startpc))) { throw new ClassConstraintException("Code attribute '" + tostring(code) + "' has an exception_table entry '" + element - + "' that has a non-existant bytecode offset as its start_pc ('" + startpc + "')."); + + "' that has a nonexistent bytecode offset as its start_pc ('" + startpc + "')."); } if (!instructionPositionSet.contains(Integer.valueOf(endpc)) && endpc != codeLength) { throw new ClassConstraintException("Code attribute '" + tostring(code) + "' has an exception_table entry '" + element - + "' that has a non-existant bytecode offset as its end_pc ('" + startpc + "') [that is also not equal to code_length ('" + codeLength + + "' that has a nonexistent bytecode offset as its end_pc ('" + startpc + "') [that is also not equal to code_length ('" + codeLength + "')]."); } if (!instructionPositionSet.contains(Integer.valueOf(handlerpc))) { throw new ClassConstraintException("Code attribute '" + tostring(code) + "' has an exception_table entry '" + element - + "' that has a non-existant bytecode offset as its handler_pc ('" + handlerpc + "')."); + + "' that has a nonexistent bytecode offset as its handler_pc ('" + handlerpc + "')."); } } } @@ -1122,13 +1122,13 @@ public final class Pass3aVerifier extends PassVerifier { while (ih != null) { final Instruction i = ih.getInstruction(); if (i instanceof IMPDEP1) { - throw new StaticCodeInstructionConstraintException("IMPDEP1 must not be in the code, it is an illegal instruction for _internal_ JVM use."); + throw new StaticCodeInstructionConstraintException("IMPDEP1 must not be in the code; it is an illegal instruction for _internal_ JVM use."); } if (i instanceof IMPDEP2) { - throw new StaticCodeInstructionConstraintException("IMPDEP2 must not be in the code, it is an illegal instruction for _internal_ JVM use."); + throw new StaticCodeInstructionConstraintException("IMPDEP2 must not be in the code; it is an illegal instruction for _internal_ JVM use."); } if (i instanceof BREAKPOINT) { - throw new StaticCodeInstructionConstraintException("BREAKPOINT must not be in the code, it is an illegal instruction for _internal_ JVM use."); + throw new StaticCodeInstructionConstraintException("BREAKPOINT must not be in the code; it is an illegal instruction for _internal_ JVM use."); } ih = ih.getNext(); } @@ -1184,8 +1184,8 @@ public final class Pass3aVerifier extends PassVerifier { } if (!(target.getInstruction() instanceof ASTORE)) { throw new StaticCodeInstructionOperandConstraintException( - "Due to JustIce's clear definition of subroutines, no JSR or JSR_W may target anything else" - + " than an ASTORE instruction. Instruction '" + tostring(ih) + "' targets '" + tostring(target) + "'."); + "Due to JustIce's clear definition of subroutines, no JSR or JSR_W may target anything" + + " other than an ASTORE instruction. Instruction '" + tostring(ih) + "' targets '" + tostring(target) + "'."); } } 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 7302914f..0f6c6e8d 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java @@ -104,7 +104,7 @@ public class ControlFlowGraph { final Subroutine s = subroutines.subroutineOf(getInstruction()); if (s == null) { // return empty; // RET in dead code. "empty" would be the correct answer, but we know something about the surrounding project... - throw new AssertionViolatedException("Asking for successors of a RET in dead code?."); + throw new AssertionViolatedException("Asking for successors of a RET in dead code?"); } //TODO: remove. Only JustIce must not use it, but foreign users of the ControlFlowGraph 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 bb6a941a..580e16c1 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java @@ -600,7 +600,7 @@ public class InstConstraintVisitor extends EmptyVisitor { */ @Override public void visitBREAKPOINT(final BREAKPOINT o) { - throw new AssertionViolatedException("In this JustIce verification pass there should not occur an illegal instruction such as BREAKPOINT."); + throw new AssertionViolatedException("This JustIce verification pass should not encounter an illegal instruction such as BREAKPOINT."); } /** @@ -1498,7 +1498,7 @@ public class InstConstraintVisitor extends EmptyVisitor { */ @Override public void visitIMPDEP1(final IMPDEP1 o) { - throw new AssertionViolatedException("In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP1."); + throw new AssertionViolatedException("This JustIce verification pass should not encounter an illegal instruction such as IMPDEP1."); } /** @@ -1508,7 +1508,7 @@ public class InstConstraintVisitor extends EmptyVisitor { */ @Override public void visitIMPDEP2(final IMPDEP2 o) { - throw new AssertionViolatedException("In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP2."); + throw new AssertionViolatedException("This JustIce verification pass should not encounter an illegal instruction such as IMPDEP2."); } /** @@ -1697,9 +1697,9 @@ public class InstConstraintVisitor extends EmptyVisitor { // Don't init an object twice. if (o.getMethodName(cpg).equals(Const.CONSTRUCTOR_NAME) && !(stack().peek(o.getArgumentTypes(cpg).length) instanceof UninitializedObjectType)) { constraintViolated(o, - "Possibly initializing object twice." + "Possibly initializing an object twice." + " A valid instruction sequence must not have an uninitialized object on the operand stack or in a local variable" - + " during a backwards branch, or in a local variable in code protected by an exception handler." + + " during a backward branch, or in a local variable in code protected by an exception handler." + " Please see The Java Virtual Machine Specification, Second Edition, 4.9.4 (pages 147 and 148) for details."); } // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o). @@ -2081,17 +2081,17 @@ public class InstConstraintVisitor extends EmptyVisitor { // [suppose some instruction put an int at N+1--- our double at N is defective] if (o.getType(cpg).getSize() == 2 && locals().get(o.getIndex() + 1) != Type.UNKNOWN) { constraintViolated(o, - "Reading a two-locals value from local variables " + o.getIndex() + " and " + (o.getIndex() + 1) + " where the latter one is destroyed."); + "Reading a two-slot value from local variables " + o.getIndex() + " and " + (o.getIndex() + 1) + " where the latter one is destroyed."); } // LOAD instructions must read the correct type. if (!(o instanceof ALOAD)) { if (locals().get(o.getIndex()) != o.getType(cpg)) { - constraintViolated(o, "Local Variable type and LOADing Instruction type mismatch: Local Variable: '" + locals().get(o.getIndex()) + constraintViolated(o, "Local Variable type and load instruction type mismatch: Local Variable: '" + locals().get(o.getIndex()) + "'; Instruction type: '" + o.getType(cpg) + "'."); } } else if (!(locals().get(o.getIndex()) instanceof ReferenceType)) { - constraintViolated(o, "Local Variable type and LOADing Instruction type mismatch: Local Variable: '" + locals().get(o.getIndex()) + constraintViolated(o, "Local Variable type and load instruction type mismatch: Local Variable: '" + locals().get(o.getIndex()) + "'; Instruction expects a ReferenceType."); } // ALOAD __IS ALLOWED__ to put uninitialized objects onto the stack! @@ -2252,7 +2252,7 @@ public class InstConstraintVisitor extends EmptyVisitor { final Type t = o.getType(cpg); if (!(t instanceof ReferenceType)) { - throw new AssertionViolatedException("NEW.getType() returning a non-reference type?."); + throw new AssertionViolatedException("NEW.getType() returning a non-reference type?"); } if (!(t instanceof ObjectType)) { constraintViolated(o, "Expecting a class type (ObjectType) to work on. Found: '" + t + "'."); @@ -2265,7 +2265,7 @@ public class InstConstraintVisitor extends EmptyVisitor { constraintViolated(o, "Expecting a class type (ObjectType) to work on. Found: '" + obj + "'."); } } catch (final ClassNotFoundException e) { - constraintViolated(o, "Expecting a class type (ObjectType) to work on. Found: '" + obj + "'. which threw " + e); + constraintViolated(o, "Expecting a class type (ObjectType) to work on. Found: '" + obj + "', which threw " + e); } } @@ -2520,13 +2520,13 @@ public class InstConstraintVisitor extends EmptyVisitor { if (!(o instanceof ASTORE)) { 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) + "'."); + "Stack top type and store instruction type mismatch: Stack top: '" + stack().peek() + "'; Instruction type: '" + o.getType(cpg) + "'."); } } else { // we deal with ASTORE final Type stacktop = stack().peek(); if (!(stacktop instanceof ReferenceType) && !(stacktop instanceof ReturnaddressType)) { - constraintViolated(o, "Stack top type and STOREing Instruction type mismatch: Stack top: '" + stack().peek() - + "'; Instruction expects a ReferenceType or a ReturnadressType."); + constraintViolated(o, "Stack top type and store instruction type mismatch: Stack top: '" + stack().peek() + + "'; Instruction expects a ReferenceType or a ReturnaddressType."); } // if (stacktop instanceof ReferenceType) { // referenceTypeIsInitialized(o, (ReferenceType) stacktop); diff --git a/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java b/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java index 2279aa2c..88bb3e77 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java @@ -132,7 +132,7 @@ public class LocalVariables implements Cloneable { public void merge(final LocalVariables localVariable) { if (this.locals.length != localVariable.locals.length) { - throw new AssertionViolatedException("Merging LocalVariables of different size?!? From different methods or what?!?"); + throw new AssertionViolatedException("Merging LocalVariables of different sizes?!? From different methods or what?!?"); } for (int i = 0; i < locals.length; i++) { @@ -151,11 +151,11 @@ public class LocalVariables implements Cloneable { // We won't accept an uninitialized object if we know it was initialized; // compare vmspec2, 4.9.4, last paragraph. if (!(locals[i] instanceof UninitializedObjectType) && lv.locals[i] instanceof UninitializedObjectType) { - throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object in the local variables detected."); + throw new StructuralCodeConstraintException("Backward branch with an uninitialized object in the local variables detected."); } // Even harder, what about _different_ uninitialized object types?! if (!locals[i].equals(lv.locals[i]) && locals[i] instanceof UninitializedObjectType && lv.locals[i] instanceof UninitializedObjectType) { - throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object in the local variables detected."); + throw new StructuralCodeConstraintException("Backward branch with an uninitialized object in the local variables detected."); } // If we just didn't know that it was initialized, we have now learned. if (locals[i] instanceof UninitializedObjectType && !(lv.locals[i] instanceof UninitializedObjectType)) { @@ -167,7 +167,7 @@ public class LocalVariables implements Cloneable { if (sup == null) { // We should have checked this in Pass2! - throw new AssertionViolatedException("Could not load all the super classes of '" + locals[i] + "' and '" + lv.locals[i] + "'."); + throw new AssertionViolatedException("Could not load all the superclasses of '" + locals[i] + "' and '" + lv.locals[i] + "'."); } locals[i] = sup; } diff --git a/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java b/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java index 09198578..821a9e2d 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java @@ -150,20 +150,20 @@ public class OperandStack implements Cloneable { public void merge(final OperandStack s) { try { if (slotsUsed() != s.slotsUsed() || size() != s.size()) { - throw new StructuralCodeConstraintException("Cannot merge stacks of different size:\nOperandStack A:\n" + this + "\nOperandStack B:\n" + s); + throw new StructuralCodeConstraintException("Cannot merge stacks of different sizes:\nOperandStack A:\n" + this + "\nOperandStack B:\n" + s); } for (int i = 0; i < size(); i++) { // If the object _was_ initialized and we're supposed to merge // in some uninitialized object, we reject the code (see vmspec2, 4.9.4, last paragraph). if (!(stack.get(i) instanceof UninitializedObjectType) && s.stack.get(i) instanceof UninitializedObjectType) { - throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object on the stack detected."); + throw new StructuralCodeConstraintException("Backward branch with an uninitialized object on the stack detected."); } // Even harder, we're not initialized but are supposed to broaden // the known object type if (!stack.get(i).equals(s.stack.get(i)) && stack.get(i) instanceof UninitializedObjectType && !(s.stack.get(i) instanceof UninitializedObjectType)) { - throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object on the stack detected."); + throw new StructuralCodeConstraintException("Backward branch with an uninitialized object on the stack detected."); } // on the other hand... if (stack.get(i) instanceof UninitializedObjectType && !(s.stack.get(i) instanceof UninitializedObjectType)) { // that has been initialized by 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 672c1263..6cfaecd8 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java @@ -218,7 +218,7 @@ public final class Pass3bVerifier extends PassVerifier { int skipJsr = 0; for (int ss = oldchain.size() - 1; ss >= 0; ss--) { if (skipJsr < 0) { - throw new AssertionViolatedException("More RET than JSR in execution chain?."); + throw new AssertionViolatedException("More RET instructions than JSR instructions in the execution chain?"); } //System.err.println("+"+oldchain.get(ss)); if (oldchain.get(ss).getInstruction().getInstruction() instanceof JsrInstruction) { @@ -427,7 +427,7 @@ public final class Pass3bVerifier extends PassVerifier { final PrintWriter pw = new PrintWriter(sw); re.printStackTrace(pw); - throw new AssertionViolatedException("Some RuntimeException occurred while verify()ing class '" + jc.getClassName() + "', method '" + throw new AssertionViolatedException("Some RuntimeException occurred while verifying class '" + jc.getClassName() + "', method '" + methods[methodNo] + "'. Original RuntimeException's stack trace:\n---\n" + sw + "---\n", re); } return VerificationResult.VR_OK; 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 ad77d37f..26122801 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java @@ -272,7 +272,7 @@ public class Subroutines { for (final InstructionHandle actual : instructions) { if (actual.getInstruction() instanceof RET) { if (ret != null) { - throw new StructuralCodeConstraintException("Subroutine with more then one RET detected: '" + ret + "' and '" + actual + "'."); + throw new StructuralCodeConstraintException("Subroutine with more than one RET detected: '" + ret + "' and '" + actual + "'."); } ret = actual; } diff --git a/src/test/java/org/apache/bcel/AnnotationAccessFlagTest.java b/src/test/java/org/apache/bcel/AnnotationAccessFlagTest.java index 3655751d..af2477fd 100644 --- a/src/test/java/org/apache/bcel/AnnotationAccessFlagTest.java +++ b/src/test/java/org/apache/bcel/AnnotationAccessFlagTest.java @@ -34,8 +34,8 @@ class AnnotationAccessFlagTest extends AbstractTest { @Test void testAnnotationClassSaysItIs() throws ClassNotFoundException { JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.SimpleAnnotation"); - assertTrue(clazz.isAnnotation(), "Expected SimpleAnnotation class to say it was an annotation - but it didn't !"); + assertTrue(clazz.isAnnotation(), "Expected SimpleAnnotation class to say it was an annotation - but it didn't!"); clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.SimpleClass"); - assertFalse(clazz.isAnnotation(), "Expected SimpleClass class to say it was not an annotation - but it didn't !"); + assertFalse(clazz.isAnnotation(), "Expected SimpleClass class to say it was not an annotation - but it didn't!"); } } diff --git a/src/test/java/org/apache/bcel/ElementValueGenTest.java b/src/test/java/org/apache/bcel/ElementValueGenTest.java index 1c2c3273..cbb9e34f 100644 --- a/src/test/java/org/apache/bcel/ElementValueGenTest.java +++ b/src/test/java/org/apache/bcel/ElementValueGenTest.java @@ -65,7 +65,7 @@ class ElementValueGenTest extends AbstractTest { // Creation of an element like that should leave a new entry in the // cpool final int idx = cp.lookupInteger(1); // 1 == true - assertEquals(idx, evg.getIndex(), "Should have the same index in the constantpool"); + assertEquals(idx, evg.getIndex(), "Should have the same index in the constant pool"); checkSerialize(evg, cp); } @@ -77,7 +77,7 @@ class ElementValueGenTest extends AbstractTest { // Creation of an element like that should leave a new entry in the // cpool final int idx = cp.lookupInteger((byte) 'z'); - assertEquals(idx, evg.getIndex(), "Should have the same index in the constantpool"); + assertEquals(idx, evg.getIndex(), "Should have the same index in the constant pool"); checkSerialize(evg, cp); } @@ -89,7 +89,7 @@ class ElementValueGenTest extends AbstractTest { // Creation of an element like that should leave a new entry in the // cpool final int idx = cp.lookupInteger('t'); - assertEquals(idx, evg.getIndex(), "Should have the same index in the constantpool"); + assertEquals(idx, evg.getIndex(), "Should have the same index in the constant pool"); checkSerialize(evg, cp); } @@ -113,7 +113,7 @@ class ElementValueGenTest extends AbstractTest { // Creation of an element like that should leave a new entry in the // cpool final int idx = cp.lookupDouble(333.44); - assertEquals(idx, evg.getIndex(), "Should have the same index in the constantpool"); + assertEquals(idx, evg.getIndex(), "Should have the same index in the constant pool"); checkSerialize(evg, cp); } @@ -128,7 +128,7 @@ class ElementValueGenTest extends AbstractTest { final EnumElementValueGen evg = new EnumElementValueGen(enumType, "Red", cp); // Creation of an element like that should leave a new entry in the // cpool - assertEquals(cp.lookupUtf8("Red"), evg.getValueIndex(), "The new ElementValue value index should match the contents of the constantpool"); + assertEquals(cp.lookupUtf8("Red"), evg.getValueIndex(), "The new ElementValue value index should match the contents of the constant pool"); // BCELBUG: Should the class signature or class name be in the constant // pool? (see note in ConstantPool) // assertTrue("The new ElementValue type index should match the contents @@ -145,7 +145,7 @@ class ElementValueGenTest extends AbstractTest { final SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_FLOAT, cp, 111.222f); // Creation of an element like that should leave a new entry in the // cpool - assertEquals(cp.lookupFloat(111.222f), evg.getIndex(), "Should have the same index in the constantpool"); + assertEquals(cp.lookupFloat(111.222f), evg.getIndex(), "Should have the same index in the constant pool"); checkSerialize(evg, cp); } @@ -159,7 +159,7 @@ class ElementValueGenTest extends AbstractTest { final SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_INT, cp, 555); // Creation of an element like that should leave a new entry in the // cpool - assertEquals(cp.lookupInteger(555), evg.getIndex(), "Should have the same index in the constantpool"); + assertEquals(cp.lookupInteger(555), evg.getIndex(), "Should have the same index in the constant pool"); checkSerialize(evg, cp); } @@ -171,7 +171,7 @@ class ElementValueGenTest extends AbstractTest { // Creation of an element like that should leave a new entry in the // cpool final int idx = cp.lookupLong(3334455L); - assertEquals(idx, evg.getIndex(), "Should have the same index in the constantpool"); + assertEquals(idx, evg.getIndex(), "Should have the same index in the constant pool"); checkSerialize(evg, cp); } @@ -183,7 +183,7 @@ class ElementValueGenTest extends AbstractTest { // Creation of an element like that should leave a new entry in the // cpool final int idx = cp.lookupInteger(42); - assertEquals(idx, evg.getIndex(), "Should have the same index in the constantpool"); + assertEquals(idx, evg.getIndex(), "Should have the same index in the constant pool"); checkSerialize(evg, cp); } @@ -197,7 +197,7 @@ class ElementValueGenTest extends AbstractTest { final SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.STRING, cp, "hello"); // Creation of an element like that should leave a new entry in the // cpool - assertEquals(cp.lookupUtf8("hello"), evg.getIndex(), "Should have the same index in the constantpool"); + assertEquals(cp.lookupUtf8("hello"), evg.getIndex(), "Should have the same index in the constant pool"); checkSerialize(evg, cp); } } diff --git a/src/test/java/org/apache/bcel/EnumAccessFlagTest.java b/src/test/java/org/apache/bcel/EnumAccessFlagTest.java index 13710e93..8816c91e 100644 --- a/src/test/java/org/apache/bcel/EnumAccessFlagTest.java +++ b/src/test/java/org/apache/bcel/EnumAccessFlagTest.java @@ -34,8 +34,8 @@ class EnumAccessFlagTest extends AbstractTest { @Test void testEnumClassSaysItIs() throws ClassNotFoundException { JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.SimpleEnum"); - assertTrue(clazz.isEnum(), "Expected SimpleEnum class to say it was an enum - but it didn't !"); + assertTrue(clazz.isEnum(), "Expected SimpleEnum class to say it was an enum - but it didn't!"); clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.SimpleClass"); - assertFalse(clazz.isEnum(), "Expected SimpleClass class to say it was not an enum - but it didn't !"); + assertFalse(clazz.isEnum(), "Expected SimpleClass class to say it was not an enum - but it didn't!"); } } diff --git a/src/test/java/org/apache/bcel/classfile/RecordTest.java b/src/test/java/org/apache/bcel/classfile/RecordTest.java index 39d1134d..120fb16a 100644 --- a/src/test/java/org/apache/bcel/classfile/RecordTest.java +++ b/src/test/java/org/apache/bcel/classfile/RecordTest.java @@ -72,7 +72,7 @@ class RecordTest extends AbstractTest { final JavaClass clazzFromRepo = repos2.loadClass("SimpleRecord"); assertNotNull(clazzFromRepo); // Use the variable to avoid a warning final Record recordAttributeFromRepo = (Record) findAttribute("Record", clazzFromRepo)[0]; - assertEquals(recordAttribute.toString(), recordAttributeFromRepo.toString(), "Both attributes needs to be equal"); + assertEquals(recordAttribute.toString(), recordAttributeFromRepo.toString(), "Both attributes need to be equal"); tfile.deleteOnExit(); } @@ -87,9 +87,9 @@ class RecordTest extends AbstractTest { @Test void testRecordClassSaysItIs() throws ClassNotFoundException, ClassFormatException, IOException { final JavaClass clazz = new ClassParser("src/test/resources/record/SimpleRecord.class").parse(); - assertTrue(clazz.isRecord(), "Expected SimpleRecord class to say it was a record - but it didn't !"); + assertTrue(clazz.isRecord(), "Expected SimpleRecord class to say it was a record - but it didn't!"); final JavaClass simpleClazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.SimpleClass"); - assertFalse(simpleClazz.isRecord(), "Expected SimpleClass class to say it was not a record - but it didn't !"); + assertFalse(simpleClazz.isRecord(), "Expected SimpleClass class to say it was not a record - but it didn't!"); } @Test diff --git a/src/test/java/org/apache/bcel/classfile/UtilityTest.java b/src/test/java/org/apache/bcel/classfile/UtilityTest.java index a7c7e22d..244c7842 100644 --- a/src/test/java/org/apache/bcel/classfile/UtilityTest.java +++ b/src/test/java/org/apache/bcel/classfile/UtilityTest.java @@ -46,7 +46,7 @@ class UtilityTest { assertEquals(0, Utility.clearBit(0, 0)); assertEquals(0, Utility.clearBit(1, 0), "1 bit 0 set to 0 -> 0"); assertEquals(1, Utility.clearBit(1, 1), "1 bit 1 is 0 hence no change"); - assertEquals(8, Utility.clearBit(8, 4), "1000 only has 4 bit hence no change"); + assertEquals(8, Utility.clearBit(8, 4), "1000 only has 4 bits, hence no change"); assertEquals(1, Utility.clearBit(9, 3), "1001 bit 3 set to 0 -> 0001"); assertEquals(-2, Utility.clearBit(-1, 0), "111...11 set bit 0 to 0 -> 111..10"); assertEquals(0, Utility.clearBit(Integer.MIN_VALUE, 31), "100...00 set bit 31 to 0 -> 000..00"); diff --git a/src/test/java/org/apache/bcel/generic/FieldAnnotationsTest.java b/src/test/java/org/apache/bcel/generic/FieldAnnotationsTest.java index bd20037d..48e5efb1 100644 --- a/src/test/java/org/apache/bcel/generic/FieldAnnotationsTest.java +++ b/src/test/java/org/apache/bcel/generic/FieldAnnotationsTest.java @@ -103,7 +103,7 @@ class FieldAnnotationsTest extends AbstractTest { } assertEquals("[@Lorg/apache/bcel/data/SimpleAnnotation;(id=1)]", dumpAnnotationEntries(f.getAnnotationEntries())); if (dbg) { - System.err.println("AnnotationEntrys on field are: " + dumpAnnotationEntries(f.getAnnotationEntries())); + System.err.println("AnnotationEntries on field are: " + dumpAnnotationEntries(f.getAnnotationEntries())); } final AnnotationEntryGen fruitBasedAnnotationEntry = createFruitAnnotationEntry(clg.getConstantPool(), "Tomato", false); final FieldGen fg = new FieldGen(f, clg.getConstantPool()); @@ -115,7 +115,7 @@ class FieldAnnotationsTest extends AbstractTest { System.err.println("FieldGen (mutable field) is " + fg); } if (dbg) { - System.err.println("with AnnotationEntrys: " + dumpAnnotationEntries(fg.getAnnotationEntries())); + System.err.println("with AnnotationEntries: " + dumpAnnotationEntries(fg.getAnnotationEntries())); } if (dbg) { System.err.println("Replacing original field with new field that has extra AnnotationEntry"); @@ -129,7 +129,7 @@ class FieldAnnotationsTest extends AbstractTest { System.err.println("Field now looks like this: " + f); } if (dbg) { - System.err.println("With AnnotationEntrys: " + dumpAnnotationEntries(f.getAnnotationEntries())); + System.err.println("With AnnotationEntries: " + dumpAnnotationEntries(f.getAnnotationEntries())); } assertEquals(2, f.getAnnotationEntries().length, "Wrong number of AnnotationEntries"); } diff --git a/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTest.java b/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTest.java index ddcd7ca5..f09b50ed 100644 --- a/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTest.java +++ b/src/test/java/org/apache/bcel/generic/GeneratingAnnotatedClassesTest.java @@ -384,7 +384,7 @@ class GeneratingAnnotatedClassesTest extends AbstractTest { final JavaClass jc2 = getClassFrom("temp1", "HelloWorld"); // Check annotation is OK i = jc2.getMethods()[0].getAnnotationEntries().length; - assertEquals(1, i, "Wrong number of annotation on JavaClass"); + assertEquals(1, i, "Wrong number of annotations on JavaClass"); final ClassGen cg2 = new ClassGen(jc2); // Check it now it is a ClassGen final Method[] m = cg2.getMethods(); diff --git a/src/test/java/org/apache/bcel/verifier/VerifierInvokeTest.java b/src/test/java/org/apache/bcel/verifier/VerifierInvokeTest.java index aab220ab..7ed56b8e 100644 --- a/src/test/java/org/apache/bcel/verifier/VerifierInvokeTest.java +++ b/src/test/java/org/apache/bcel/verifier/VerifierInvokeTest.java @@ -25,23 +25,23 @@ class VerifierInvokeTest extends AbstractVerifierTest { @Test void testLegalInvokeInterface() throws ClassNotFoundException { - assertVerifyOK("TestLegalInvokeInterface01", "Verification of invokeinterface on method defined in superinterface must pass."); + assertVerifyOK("TestLegalInvokeInterface01", "Verification of invokeinterface on a method defined in a superinterface must pass."); } @Test void testLegalInvokeSpecial() throws ClassNotFoundException { - assertVerifyOK("TestLegalInvokeSpecial01", "Verification of invokespecial on method defined in superclass must pass."); - assertVerifyOK("TestLegalInvokeSpecial02", "Verification of invokespecial on method defined in superclass must pass."); + assertVerifyOK("TestLegalInvokeSpecial01", "Verification of invokespecial on a method defined in a superclass must pass."); + assertVerifyOK("TestLegalInvokeSpecial02", "Verification of invokespecial on a method defined in a superclass must pass."); } @Test void testLegalInvokeStatic() throws ClassNotFoundException { - assertVerifyOK("TestLegalInvokeStatic01", "Verification of invokestatic on method defined in superclass must pass."); + assertVerifyOK("TestLegalInvokeStatic01", "Verification of invokestatic on a method defined in a superclass must pass."); } @Test void testLegalInvokeVirtual() throws ClassNotFoundException { - assertVerifyOK("TestLegalInvokeVirtual01", "Verification of invokevirtual on method defined in superclass must pass."); - assertVerifyOK("TestLegalInvokeVirtual02", "Verification of invokevirtual on method defined in superinterface must pass."); + assertVerifyOK("TestLegalInvokeVirtual01", "Verification of invokevirtual on a method defined in a superclass must pass."); + assertVerifyOK("TestLegalInvokeVirtual02", "Verification of invokevirtual on a method defined in a superinterface must pass."); } } diff --git a/src/test/java/org/apache/bcel/verifier/VerifierReturnTest.java b/src/test/java/org/apache/bcel/verifier/VerifierReturnTest.java index 2ea4ed54..e1d320ea 100644 --- a/src/test/java/org/apache/bcel/verifier/VerifierReturnTest.java +++ b/src/test/java/org/apache/bcel/verifier/VerifierReturnTest.java @@ -43,17 +43,17 @@ class VerifierReturnTest extends AbstractVerifierTest { new TestReturn03IntCreator().create(); assertVerifyRejected("TestReturn03Int", "Verification of an int method that returns null int must fail."); new TestReturn03FloatCreator().create(); - assertVerifyRejected("TestReturn03Float", "Verification of a int method that returns null float must fail."); + assertVerifyRejected("TestReturn03Float", "Verification of an int method that returns null float must fail."); new TestReturn03DoubleCreator().create(); - assertVerifyRejected("TestReturn03Double", "Verification of a int method that returns null double must fail."); + assertVerifyRejected("TestReturn03Double", "Verification of an int method that returns null double must fail."); new TestReturn03LongCreator().create(); - assertVerifyRejected("TestReturn03Long", "Verification of a int method that returns null long must fail."); + assertVerifyRejected("TestReturn03Long", "Verification of an int method that returns null long must fail."); new TestReturn03ByteCreator().create(); - assertVerifyRejected("TestReturn03Byte", "Verification of a int method that returns null byte must fail."); + assertVerifyRejected("TestReturn03Byte", "Verification of an int method that returns null byte must fail."); new TestReturn03BooleanCreator().create(); - assertVerifyRejected("TestReturn03Boolean", "Verification of a int method that returns null boolean must fail."); + assertVerifyRejected("TestReturn03Boolean", "Verification of an int method that returns null boolean must fail."); new TestReturn03ObjectCreator().create(); - assertVerifyRejected("TestReturn03Object", "Verification of a int method that returns null Object must fail."); + assertVerifyRejected("TestReturn03Object", "Verification of an int method that returns null Object must fail."); final TestReturn03UnknownCreator testReturn03UnknownCreator = new TestReturn03UnknownCreator(); assertThrowsExactly(IllegalArgumentException.class, testReturn03UnknownCreator::create, "Invalid type <unknown object>"); } diff --git a/src/test/java/org/apache/bcel/verifier/VerifierThrowTest.java b/src/test/java/org/apache/bcel/verifier/VerifierThrowTest.java index 921aa19e..f149296a 100644 --- a/src/test/java/org/apache/bcel/verifier/VerifierThrowTest.java +++ b/src/test/java/org/apache/bcel/verifier/VerifierThrowTest.java @@ -28,6 +28,6 @@ class VerifierThrowTest extends AbstractVerifierTest { @Test void testThrowEmptyStack() throws IOException, ClassNotFoundException { new TestThrow01Creator().create(); - assertVerifyRejected("TestThrow01", "Verification of a method with ATHROW instruction on an empty stack must fail."); + assertVerifyRejected("TestThrow01", "Verification of a method with an ATHROW instruction on an empty stack must fail."); } } diff --git a/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTest.java b/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTest.java index c340b04c..a1f86603 100644 --- a/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTest.java +++ b/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTest.java @@ -195,7 +195,7 @@ class VerifyBadClassesTest { final File testFile = new File(testDir, className + JavaClass.EXTENSION); if (!origFile.renameTo(testFile)) { - fail("Failed to rename orig file"); + fail("Failed to rename original file"); } String result;
