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 be1cf066aca8aa94d7863536859b3224a2592d06 Author: Gary David Gregory (Code signing key) <[email protected]> AuthorDate: Wed Nov 16 09:17:34 2022 -0500 Better internal name --- .../bcel/verifier/statics/Pass1Verifier.java | 18 +++++++++--------- .../bcel/verifier/statics/Pass2Verifier.java | 20 ++++++++++---------- .../bcel/verifier/statics/Pass3aVerifier.java | 22 +++++++++++----------- 3 files changed, 30 insertions(+), 30 deletions(-) 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 3cfaec3d..a2edcd1f 100644 --- a/src/main/java/org/apache/bcel/verifier/statics/Pass1Verifier.java +++ b/src/main/java/org/apache/bcel/verifier/statics/Pass1Verifier.java @@ -37,20 +37,20 @@ public final class Pass1Verifier extends PassVerifier { * * @see #getJavaClass() */ - private JavaClass jc; + private JavaClass javaClass; /** * The Verifier that created this. */ - private final Verifier myOwner; + private final Verifier verifier; /** * Should only be instantiated by a Verifier. * * @see Verifier */ - public Pass1Verifier(final Verifier owner) { - myOwner = owner; + public Pass1Verifier(final Verifier verifier) { + this.verifier = verifier; } /** @@ -131,9 +131,9 @@ public final class Pass1Verifier extends PassVerifier { // This test should be much more complicated. It needs to take the class name, remove any portion at the // end that matches the file name and then see if the remainder matches anything on the class path. // Dumb test for now, see if the class name ends with the file name. - if (jc != null && !myOwner.getClassName().equals(jc.getClassName()) && !jc.getClassName().endsWith(myOwner.getClassName())) { + if (jc != null && !verifier.getClassName().equals(jc.getClassName()) && !jc.getClassName().endsWith(verifier.getClassName())) { throw new LoadingException("Wrong name: the internal name of the .class file '" + jc.getClassName() + "' does not match the file's name '" - + myOwner.getClassName() + "'."); + + verifier.getClassName() + "'."); } } catch (final LoadingException | ClassFormatException e) { return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage()); @@ -158,9 +158,9 @@ public final class Pass1Verifier extends PassVerifier { * it's not really needed! */ private JavaClass getJavaClass() { - if (jc == null) { + if (javaClass == null) { try { - jc = Repository.lookupClass(myOwner.getClassName()); + javaClass = Repository.lookupClass(verifier.getClassName()); } catch (final ClassNotFoundException ignored) { // FIXME: currently, Pass1Verifier treats jc == null as a special // case, so we don't need to do anything here. A better solution @@ -168,7 +168,7 @@ public final class Pass1Verifier extends PassVerifier { // out of this method. } } - return jc; + return javaClass; } /** 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 004c01fa..17a964c8 100644 --- a/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java +++ b/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java @@ -223,7 +223,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { // This is highly unelegant due to usage of the Visitor pattern. // TODO: rework it. int methodNumber = -1; - final Method[] ms = Repository.lookupClass(myOwner.getClassName()).getMethods(); + final Method[] ms = Repository.lookupClass(verifier.getClassName()).getMethods(); for (int mn = 0; mn < ms.length; mn++) { if (m == ms[mn]) { methodNumber = mn; @@ -1246,15 +1246,15 @@ public final class Pass2Verifier extends PassVerifier implements Constants { */ private LocalVariablesInfo[] localVariablesInfos; /** The Verifier that created this. */ - private final Verifier myOwner; + private final Verifier verifier; /** * Should only be instantiated by a Verifier. * * @see Verifier */ - public Pass2Verifier(final Verifier owner) { - myOwner = owner; + public Pass2Verifier(final Verifier verifier) { + this.verifier = verifier; } /** @@ -1268,7 +1268,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { // Most of the consistency is handled internally by BCEL; here // we only have to verify if the indices of the constants point // to constants of the appropriate type and such. - final JavaClass jc = Repository.lookupClass(myOwner.getClassName()); + final JavaClass jc = Repository.lookupClass(verifier.getClassName()); new CPESSC_Visitor(jc); // constructor implicitly traverses jc } catch (final ClassNotFoundException e) { @@ -1293,12 +1293,12 @@ public final class Pass2Verifier extends PassVerifier implements Constants { @Override public VerificationResult do_verify() { try { - final VerificationResult vr1 = myOwner.doPass1(); + final VerificationResult vr1 = verifier.doPass1(); if (vr1.equals(VerificationResult.VR_OK)) { // For every method, we could have information about the local variables out of LocalVariableTable attributes of // the Code attributes. - localVariablesInfos = new LocalVariablesInfo[Repository.lookupClass(myOwner.getClassName()).getMethods().length]; + localVariablesInfos = new LocalVariablesInfo[Repository.lookupClass(verifier.getClassName()).getMethods().length]; VerificationResult vr = VerificationResult.VR_OK; // default. try { @@ -1330,7 +1330,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { private void everyClassHasAnAccessibleSuperclass() { try { final Set<String> hs = new HashSet<>(); // save class names to detect circular inheritance - JavaClass jc = Repository.lookupClass(myOwner.getClassName()); + JavaClass jc = Repository.lookupClass(verifier.getClassName()); int supidx = -1; while (supidx != 0) { @@ -1379,7 +1379,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { */ private void fieldAndMethodRefsAreValid() { try { - final JavaClass jc = Repository.lookupClass(myOwner.getClassName()); + final JavaClass jc = Repository.lookupClass(verifier.getClassName()); final DescendingVisitor v = new DescendingVisitor(jc, new FAMRAV_Visitor(jc)); v.visit(); @@ -1401,7 +1401,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants { private void finalMethodsAreNotOverridden() { try { final Map<String, String> map = new HashMap<>(); - JavaClass jc = Repository.lookupClass(myOwner.getClassName()); + JavaClass jc = Repository.lookupClass(verifier.getClassName()); int supidx = -1; while (supidx != 0) { 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 34bf80fd..f03914e6 100644 --- a/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java +++ b/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java @@ -213,7 +213,7 @@ public final class Pass3aVerifier extends PassVerifier { */ private int maxLocals() { try { - return Repository.lookupClass(myOwner.getClassName()).getMethods()[methodNo].getCode().getMaxLocals(); + return Repository.lookupClass(verifier.getClassName()).getMethods()[methodNo].getCode().getMaxLocals(); } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); @@ -591,7 +591,7 @@ public final class Pass3aVerifier extends PassVerifier { + o.getSignature(constantPoolGen) + "' not found in class '" + jc.getClassName() + "'."); } - JavaClass current = Repository.lookupClass(myOwner.getClassName()); + JavaClass current = Repository.lookupClass(verifier.getClassName()); if (current.isSuper() && Repository.instanceOf(current, jc) && !current.equals(jc) && !o.getMethodName(constantPoolGen).equals(Const.CONSTRUCTOR_NAME)) { // Special lookup procedure for ACC_SUPER classes. @@ -869,8 +869,8 @@ public final class Pass3aVerifier extends PassVerifier { throw new AssertionViolatedException("Field '" + fieldName + "' not found in " + jc.getClassName()); } - if (f.isFinal() && !myOwner.getClassName().equals(getObjectType(o).getClassName())) { - constraintViolated(o, "Referenced field '" + f + "' is final and must therefore be declared in the current class '" + myOwner.getClassName() + if (f.isFinal() && !verifier.getClassName().equals(getObjectType(o).getClassName())) { + constraintViolated(o, "Referenced field '" + f + "' is final and must therefore be declared in the current class '" + verifier.getClassName() + "' which is not the case: it is declared in '" + o.getReferenceType(constantPoolGen) + "'."); } @@ -878,7 +878,7 @@ public final class Pass3aVerifier extends PassVerifier { constraintViolated(o, "Referenced field '" + f + "' is not static which it should be."); } - final String methName = Repository.lookupClass(myOwner.getClassName()).getMethods()[methodNo].getName(); + final String methName = Repository.lookupClass(verifier.getClassName()).getMethods()[methodNo].getName(); // If it's an interface, it can be set only in <clinit>. if (!jc.isClass() && !methName.equals(Const.STATIC_INITIALIZER_NAME)) { @@ -925,7 +925,7 @@ public final class Pass3aVerifier extends PassVerifier { } /** The Verifier that created this. */ - private final Verifier myOwner; + private final Verifier verifier; /** * The method number to verify. This is the index in the array returned by JavaClass.getMethods(). @@ -945,8 +945,8 @@ public final class Pass3aVerifier extends PassVerifier { private Code code; /** Should only be instantiated by a Verifier. */ - public Pass3aVerifier(final Verifier owner, final int methodNo) { - myOwner = owner; + public Pass3aVerifier(final Verifier verifier, final int methodNo) { + this.verifier = verifier; this.methodNo = methodNo; } @@ -1059,10 +1059,10 @@ public final class Pass3aVerifier extends PassVerifier { @Override public VerificationResult do_verify() { try { - if (myOwner.doPass2().equals(VerificationResult.VR_OK)) { + if (verifier.doPass2().equals(VerificationResult.VR_OK)) { // Okay, class file was loaded correctly by Pass 1 // and satisfies static constraints of Pass 2. - final JavaClass jc = Repository.lookupClass(myOwner.getClassName()); + final JavaClass jc = Repository.lookupClass(verifier.getClassName()); final Method[] methods = jc.getMethods(); if (methodNo >= methods.length) { throw new InvalidMethodException("METHOD DOES NOT EXIST!"); @@ -1205,7 +1205,7 @@ public final class Pass3aVerifier extends PassVerifier { // TODO: Implement as much as possible here. BCEL does _not_ check everything. - final ConstantPoolGen cpg = new ConstantPoolGen(Repository.lookupClass(myOwner.getClassName()).getConstantPool()); + final ConstantPoolGen cpg = new ConstantPoolGen(Repository.lookupClass(verifier.getClassName()).getConstantPool()); final InstOperandConstraintVisitor v = new InstOperandConstraintVisitor(cpg); // Checks for the things BCEL does _not_ handle itself.
