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
The following commit(s) were added to refs/heads/master by this push: new 9110fe5 Normalize private names to camel-case. 9110fe5 is described below commit 9110fe54c23dc96f56d42a1027d6e39ad6917e97 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu Jun 4 08:51:20 2020 -0400 Normalize private names to camel-case. --- .../java/org/apache/bcel/generic/ArrayType.java | 18 +- .../java/org/apache/bcel/generic/ClassGen.java | 148 +++++++------- .../org/apache/bcel/generic/CodeExceptionGen.java | 66 +++---- .../org/apache/bcel/generic/ConstantPoolGen.java | 72 +++---- .../apache/bcel/generic/ElementValuePairGen.java | 18 +- .../apache/bcel/generic/FieldGenOrMethodGen.java | 24 +-- .../org/apache/bcel/generic/InstructionList.java | 14 +- .../org/apache/bcel/generic/LineNumberGen.java | 8 +- .../org/apache/bcel/generic/LocalVariableGen.java | 24 +-- .../bcel/generic/LocalVariableInstruction.java | 24 +-- .../java/org/apache/bcel/generic/MethodGen.java | 218 ++++++++++----------- .../java/org/apache/bcel/generic/ObjectType.java | 26 +-- src/main/java/org/apache/bcel/generic/SWITCH.java | 12 +- src/main/java/org/apache/bcel/util/CodeHTML.java | 92 ++++----- .../java/org/apache/bcel/util/ConstantHTML.java | 74 +++---- .../org/apache/bcel/util/InstructionFinder.java | 8 +- .../util/MemorySensitiveClassPathRepository.java | 10 +- src/main/java/org/apache/bcel/util/MethodHTML.java | 14 +- .../org/apache/bcel/verifier/VerifyDialog.java | 8 +- .../bcel/verifier/statics/Pass3aVerifier.java | 14 +- .../verifier/structurals/ExceptionHandler.java | 12 +- .../verifier/structurals/ExceptionHandlers.java | 10 +- .../bcel/verifier/structurals/Pass3bVerifier.java | 16 +- 23 files changed, 465 insertions(+), 465 deletions(-) diff --git a/src/main/java/org/apache/bcel/generic/ArrayType.java b/src/main/java/org/apache/bcel/generic/ArrayType.java index 240308f..7c0ea09 100644 --- a/src/main/java/org/apache/bcel/generic/ArrayType.java +++ b/src/main/java/org/apache/bcel/generic/ArrayType.java @@ -26,7 +26,7 @@ import org.apache.bcel.Const; public final class ArrayType extends ReferenceType { private int dimensions; - private Type basic_type; + private Type basicType; /** @@ -63,20 +63,20 @@ public final class ArrayType extends ReferenceType { case Const.T_ARRAY: final ArrayType array = (ArrayType) type; this.dimensions = dimensions + array.dimensions; - basic_type = array.basic_type; + basicType = array.basicType; break; case Const.T_VOID: throw new ClassGenException("Invalid type: void[]"); default: // Basic type or reference this.dimensions = dimensions; - basic_type = type; + basicType = type; break; } final StringBuilder buf = new StringBuilder(); for (int i = 0; i < this.dimensions; i++) { buf.append('['); } - buf.append(basic_type.getSignature()); + buf.append(basicType.getSignature()); super.setSignature(buf.toString()); } @@ -85,7 +85,7 @@ public final class ArrayType extends ReferenceType { * @return basic type of array, i.e., for int[][][] the basic type is int */ public Type getBasicType() { - return basic_type; + return basicType; } @@ -94,9 +94,9 @@ public final class ArrayType extends ReferenceType { */ public Type getElementType() { if (dimensions == 1) { - return basic_type; + return basicType; } - return new ArrayType(basic_type, dimensions - 1); + return new ArrayType(basicType, dimensions - 1); } @@ -111,7 +111,7 @@ public final class ArrayType extends ReferenceType { */ @Override public int hashCode() { - return basic_type.hashCode() ^ dimensions; + return basicType.hashCode() ^ dimensions; } @@ -121,7 +121,7 @@ public final class ArrayType extends ReferenceType { public boolean equals( final Object _type ) { if (_type instanceof ArrayType) { final ArrayType array = (ArrayType) _type; - return (array.dimensions == dimensions) && array.basic_type.equals(basic_type); + return (array.dimensions == dimensions) && array.basicType.equals(basicType); } return false; } diff --git a/src/main/java/org/apache/bcel/generic/ClassGen.java b/src/main/java/org/apache/bcel/generic/ClassGen.java index b3f63b9..e4e049a 100644 --- a/src/main/java/org/apache/bcel/generic/ClassGen.java +++ b/src/main/java/org/apache/bcel/generic/ClassGen.java @@ -45,22 +45,22 @@ public class ClassGen extends AccessFlags implements Cloneable { /* Corresponds to the fields found in a JavaClass object. */ - private String class_name; - private String super_class_name; - private final String file_name; - private int class_name_index = -1; + private String className; + private String superClassName; + private final String fileName; + private int classNameIndex = -1; private int superclass_name_index = -1; private int major = Const.MAJOR_1_1; private int minor = Const.MINOR_1_1; private ConstantPoolGen cp; // Template for building up constant pool // ArrayLists instead of arrays to gather fields, methods, etc. - private final List<Field> field_vec = new ArrayList<>(); - private final List<Method> method_vec = new ArrayList<>(); - private final List<Attribute> attribute_vec = new ArrayList<>(); - private final List<String> interface_vec = new ArrayList<>(); - private final List<AnnotationEntryGen> annotation_vec = new ArrayList<>(); + private final List<Field> fieldList = new ArrayList<>(); + private final List<Method> methodList = new ArrayList<>(); + private final List<Attribute> attributeList = new ArrayList<>(); + private final List<String> interfaceList = new ArrayList<>(); + private final List<AnnotationEntryGen> annotationList = new ArrayList<>(); - private static BCELComparator _cmp = new BCELComparator() { + private static BCELComparator bcelComparator = new BCELComparator() { @Override public boolean equals( final Object o1, final Object o2 ) { @@ -80,9 +80,9 @@ public class ClassGen extends AccessFlags implements Cloneable { /** Convenience constructor to set up some important values initially. * - * @param class_name fully qualified class name - * @param super_class_name fully qualified superclass name - * @param file_name source file name + * @param className fully qualified class name + * @param superClassName fully qualified superclass name + * @param fileName source file name * @param access_flags access qualifiers * @param interfaces implemented interfaces * @param cp constant pool to use @@ -90,16 +90,16 @@ public class ClassGen extends AccessFlags implements Cloneable { public ClassGen(final String class_name, final String super_class_name, final String file_name, final int access_flags, final String[] interfaces, final ConstantPoolGen cp) { super(access_flags); - this.class_name = class_name; - this.super_class_name = super_class_name; - this.file_name = file_name; + this.className = class_name; + this.superClassName = super_class_name; + this.fileName = file_name; this.cp = cp; // Put everything needed by default into the constant pool and the vectors if (file_name != null) { addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2, cp.addUtf8(file_name), cp .getConstantPool())); } - class_name_index = cp.addClass(class_name); + classNameIndex = cp.addClass(class_name); superclass_name_index = cp.addClass(super_class_name); if (interfaces != null) { for (final String interface1 : interfaces) { @@ -111,9 +111,9 @@ public class ClassGen extends AccessFlags implements Cloneable { /** Convenience constructor to set up some important values initially. * - * @param class_name fully qualified class name - * @param super_class_name fully qualified superclass name - * @param file_name source file name + * @param className fully qualified class name + * @param superClassName fully qualified superclass name + * @param fileName source file name * @param access_flags access qualifiers * @param interfaces implemented interfaces */ @@ -130,11 +130,11 @@ public class ClassGen extends AccessFlags implements Cloneable { */ public ClassGen(final JavaClass clazz) { super(clazz.getAccessFlags()); - class_name_index = clazz.getClassNameIndex(); + classNameIndex = clazz.getClassNameIndex(); superclass_name_index = clazz.getSuperclassNameIndex(); - class_name = clazz.getClassName(); - super_class_name = clazz.getSuperclassName(); - file_name = clazz.getSourceFileName(); + className = clazz.getClassName(); + superClassName = clazz.getSuperclassName(); + fileName = clazz.getSourceFileName(); cp = new ConstantPoolGen(clazz.getConstantPool()); major = clazz.getMajor(); minor = clazz.getMinor(); @@ -202,18 +202,18 @@ public class ClassGen extends AccessFlags implements Cloneable { final Field[] fields = getFields(); final Method[] methods = getMethods(); Attribute[] attributes = null; - if (annotation_vec.isEmpty()) { + if (annotationList.isEmpty()) { attributes = getAttributes(); } else { // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations' final Attribute[] annAttributes = AnnotationEntryGen.getAnnotationAttributes(cp, getAnnotationEntries()); - attributes = new Attribute[attribute_vec.size()+annAttributes.length]; - attribute_vec.toArray(attributes); - System.arraycopy(annAttributes,0,attributes,attribute_vec.size(),annAttributes.length); + attributes = new Attribute[attributeList.size()+annAttributes.length]; + attributeList.toArray(attributes); + System.arraycopy(annAttributes,0,attributes,attributeList.size(),annAttributes.length); } // Must be last since the above calls may still add something to it final ConstantPool _cp = this.cp.getFinalConstantPool(); - return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor, + return new JavaClass(classNameIndex, superclass_name_index, fileName, major, minor, super.getAccessFlags(), _cp, interfaces, fields, methods, attributes); } @@ -223,7 +223,7 @@ public class ClassGen extends AccessFlags implements Cloneable { * @param name interface to implement (fully qualified class name) */ public void addInterface( final String name ) { - interface_vec.add(name); + interfaceList.add(name); } @@ -232,7 +232,7 @@ public class ClassGen extends AccessFlags implements Cloneable { * @param name interface to remove (fully qualified name) */ public void removeInterface( final String name ) { - interface_vec.remove(name); + interfaceList.remove(name); } @@ -272,11 +272,11 @@ public class ClassGen extends AccessFlags implements Cloneable { * @param a attribute to add */ public void addAttribute( final Attribute a ) { - attribute_vec.add(a); + attributeList.add(a); } public void addAnnotationEntry(final AnnotationEntryGen a) { - annotation_vec.add(a); + annotationList.add(a); } @@ -285,7 +285,7 @@ public class ClassGen extends AccessFlags implements Cloneable { * @param m method to add */ public void addMethod( final Method m ) { - method_vec.add(m); + methodList.add(m); } @@ -298,10 +298,10 @@ public class ClassGen extends AccessFlags implements Cloneable { public void addEmptyConstructor( final int access_flags ) { final InstructionList il = new InstructionList(); il.append(InstructionConst.THIS); // Push `this' - il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name, "<init>", "()V"))); + il.append(new INVOKESPECIAL(cp.addMethodref(superClassName, "<init>", "()V"))); il.append(InstructionConst.RETURN); final MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, "<init>", - class_name, il, cp); + className, il, cp); mg.setMaxStack(1); addMethod(mg.getMethod()); } @@ -312,19 +312,19 @@ public class ClassGen extends AccessFlags implements Cloneable { * @param f field to add */ public void addField( final Field f ) { - field_vec.add(f); + fieldList.add(f); } public boolean containsField( final Field f ) { - return field_vec.contains(f); + return fieldList.contains(f); } /** @return field object with given name, or null */ public Field containsField( final String name ) { - for (final Field f : field_vec) { + for (final Field f : fieldList) { if (f.getName().equals(name)) { return f; } @@ -336,7 +336,7 @@ public class ClassGen extends AccessFlags implements Cloneable { /** @return method object with given name and signature, or null */ public Method containsMethod( final String name, final String signature ) { - for (final Method m : method_vec) { + for (final Method m : methodList) { if (m.getName().equals(name) && m.getSignature().equals(signature)) { return m; } @@ -350,7 +350,7 @@ public class ClassGen extends AccessFlags implements Cloneable { * @param a attribute to remove */ public void removeAttribute( final Attribute a ) { - attribute_vec.remove(a); + attributeList.remove(a); } @@ -359,7 +359,7 @@ public class ClassGen extends AccessFlags implements Cloneable { * @param m method to remove */ public void removeMethod( final Method m ) { - method_vec.remove(m); + methodList.remove(m); } @@ -370,11 +370,11 @@ public class ClassGen extends AccessFlags implements Cloneable { if (new_ == null) { throw new ClassGenException("Replacement method must not be null"); } - final int i = method_vec.indexOf(old); + final int i = methodList.indexOf(old); if (i < 0) { - method_vec.add(new_); + methodList.add(new_); } else { - method_vec.set(i, new_); + methodList.set(i, new_); } } @@ -386,11 +386,11 @@ public class ClassGen extends AccessFlags implements Cloneable { if (new_ == null) { throw new ClassGenException("Replacement method must not be null"); } - final int i = field_vec.indexOf(old); + final int i = fieldList.indexOf(old); if (i < 0) { - field_vec.add(new_); + fieldList.add(new_); } else { - field_vec.set(i, new_); + fieldList.set(i, new_); } } @@ -400,44 +400,44 @@ public class ClassGen extends AccessFlags implements Cloneable { * @param f field to remove */ public void removeField( final Field f ) { - field_vec.remove(f); + fieldList.remove(f); } public String getClassName() { - return class_name; + return className; } public String getSuperclassName() { - return super_class_name; + return superClassName; } public String getFileName() { - return file_name; + return fileName; } public void setClassName( final String name ) { - class_name = name.replace('/', '.'); - class_name_index = cp.addClass(name); + className = name.replace('/', '.'); + classNameIndex = cp.addClass(name); } public void setSuperclassName( final String name ) { - super_class_name = name.replace('/', '.'); + superClassName = name.replace('/', '.'); superclass_name_index = cp.addClass(name); } public Method[] getMethods() { - return method_vec.toArray(new Method[method_vec.size()]); + return methodList.toArray(new Method[methodList.size()]); } public void setMethods( final Method[] methods ) { - method_vec.clear(); + methodList.clear(); for (final Method method : methods) { addMethod(method); } @@ -445,45 +445,45 @@ public class ClassGen extends AccessFlags implements Cloneable { public void setMethodAt( final Method method, final int pos ) { - method_vec.set(pos, method); + methodList.set(pos, method); } public Method getMethodAt( final int pos ) { - return method_vec.get(pos); + return methodList.get(pos); } public String[] getInterfaceNames() { - final int size = interface_vec.size(); + final int size = interfaceList.size(); final String[] interfaces = new String[size]; - interface_vec.toArray(interfaces); + interfaceList.toArray(interfaces); return interfaces; } public int[] getInterfaces() { - final int size = interface_vec.size(); + final int size = interfaceList.size(); final int[] interfaces = new int[size]; for (int i = 0; i < size; i++) { - interfaces[i] = cp.addClass(interface_vec.get(i)); + interfaces[i] = cp.addClass(interfaceList.get(i)); } return interfaces; } public Field[] getFields() { - return field_vec.toArray(new Field[field_vec.size()]); + return fieldList.toArray(new Field[fieldList.size()]); } public Attribute[] getAttributes() { - return attribute_vec.toArray(new Attribute[attribute_vec.size()]); + return attributeList.toArray(new Attribute[attributeList.size()]); } // J5TODO: Should we make calling unpackAnnotations() lazy and put it in here? public AnnotationEntryGen[] getAnnotationEntries() { - return annotation_vec.toArray(new AnnotationEntryGen[annotation_vec.size()]); + return annotationList.toArray(new AnnotationEntryGen[annotationList.size()]); } @@ -498,15 +498,15 @@ public class ClassGen extends AccessFlags implements Cloneable { public void setClassNameIndex( final int class_name_index ) { - this.class_name_index = class_name_index; - class_name = cp.getConstantPool().getConstantString(class_name_index, + this.classNameIndex = class_name_index; + className = cp.getConstantPool().getConstantString(class_name_index, Const.CONSTANT_Class).replace('/', '.'); } public void setSuperclassNameIndex( final int superclass_name_index ) { this.superclass_name_index = superclass_name_index; - super_class_name = cp.getConstantPool().getConstantString(superclass_name_index, + superClassName = cp.getConstantPool().getConstantString(superclass_name_index, Const.CONSTANT_Class).replace('/', '.'); } @@ -517,7 +517,7 @@ public class ClassGen extends AccessFlags implements Cloneable { public int getClassNameIndex() { - return class_name_index; + return classNameIndex; } private List<ClassObserver> observers; @@ -569,7 +569,7 @@ public class ClassGen extends AccessFlags implements Cloneable { * @return Comparison strategy object */ public static BCELComparator getComparator() { - return _cmp; + return bcelComparator; } @@ -577,7 +577,7 @@ public class ClassGen extends AccessFlags implements Cloneable { * @param comparator Comparison strategy object */ public static void setComparator( final BCELComparator comparator ) { - _cmp = comparator; + bcelComparator = comparator; } @@ -590,7 +590,7 @@ public class ClassGen extends AccessFlags implements Cloneable { */ @Override public boolean equals( final Object obj ) { - return _cmp.equals(this, obj); + return bcelComparator.equals(this, obj); } @@ -602,6 +602,6 @@ public class ClassGen extends AccessFlags implements Cloneable { */ @Override public int hashCode() { - return _cmp.hashCode(this); + return bcelComparator.hashCode(this); } } diff --git a/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java b/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java index 5b6c3d2..025c1b4 100644 --- a/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java +++ b/src/main/java/org/apache/bcel/generic/CodeExceptionGen.java @@ -34,27 +34,27 @@ import org.apache.bcel.classfile.CodeException; */ public final class CodeExceptionGen implements InstructionTargeter, Cloneable { - private InstructionHandle start_pc; - private InstructionHandle end_pc; - private InstructionHandle handler_pc; - private ObjectType catch_type; + private InstructionHandle startPc; + private InstructionHandle endPc; + private InstructionHandle handlerPc; + private ObjectType catchType; /** * Add an exception handler, i.e., specify region where a handler is active and an * instruction where the actual handling is done. * - * @param start_pc Start of handled region (inclusive) - * @param end_pc End of handled region (inclusive) - * @param handler_pc Where handling is done - * @param catch_type which exception is handled, null for ANY + * @param startPc Start of handled region (inclusive) + * @param endPc End of handled region (inclusive) + * @param handlerPc Where handling is done + * @param catchType which exception is handled, null for ANY */ public CodeExceptionGen(final InstructionHandle start_pc, final InstructionHandle end_pc, final InstructionHandle handler_pc, final ObjectType catch_type) { setStartPC(start_pc); setEndPC(end_pc); setHandlerPC(handler_pc); - this.catch_type = catch_type; + this.catchType = catch_type; } @@ -68,36 +68,36 @@ public final class CodeExceptionGen implements InstructionTargeter, Cloneable { * @param cp constant pool */ public CodeException getCodeException( final ConstantPoolGen cp ) { - return new CodeException(start_pc.getPosition(), end_pc.getPosition() - + end_pc.getInstruction().getLength(), handler_pc.getPosition(), - (catch_type == null) ? 0 : cp.addClass(catch_type)); + return new CodeException(startPc.getPosition(), endPc.getPosition() + + endPc.getInstruction().getLength(), handlerPc.getPosition(), + (catchType == null) ? 0 : cp.addClass(catchType)); } /* Set start of handler - * @param start_pc Start of handled region (inclusive) + * @param startPc Start of handled region (inclusive) */ public void setStartPC( final InstructionHandle start_pc ) { // TODO could be package-protected? - BranchInstruction.notifyTarget(this.start_pc, start_pc, this); - this.start_pc = start_pc; + BranchInstruction.notifyTarget(this.startPc, start_pc, this); + this.startPc = start_pc; } /* Set end of handler - * @param end_pc End of handled region (inclusive) + * @param endPc End of handled region (inclusive) */ public void setEndPC( final InstructionHandle end_pc ) { // TODO could be package-protected? - BranchInstruction.notifyTarget(this.end_pc, end_pc, this); - this.end_pc = end_pc; + BranchInstruction.notifyTarget(this.endPc, end_pc, this); + this.endPc = end_pc; } /* Set handler code - * @param handler_pc Start of handler + * @param handlerPc Start of handler */ public void setHandlerPC( final InstructionHandle handler_pc ) { // TODO could be package-protected? - BranchInstruction.notifyTarget(this.handler_pc, handler_pc, this); - this.handler_pc = handler_pc; + BranchInstruction.notifyTarget(this.handlerPc, handler_pc, this); + this.handlerPc = handler_pc; } @@ -108,21 +108,21 @@ public final class CodeExceptionGen implements InstructionTargeter, Cloneable { @Override public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) { boolean targeted = false; - if (start_pc == old_ih) { + if (startPc == old_ih) { targeted = true; setStartPC(new_ih); } - if (end_pc == old_ih) { + if (endPc == old_ih) { targeted = true; setEndPC(new_ih); } - if (handler_pc == old_ih) { + if (handlerPc == old_ih) { targeted = true; setHandlerPC(new_ih); } if (!targeted) { - throw new ClassGenException("Not targeting " + old_ih + ", but {" + start_pc + ", " - + end_pc + ", " + handler_pc + "}"); + throw new ClassGenException("Not targeting " + old_ih + ", but {" + startPc + ", " + + endPc + ", " + handlerPc + "}"); } } @@ -132,46 +132,46 @@ public final class CodeExceptionGen implements InstructionTargeter, Cloneable { */ @Override public boolean containsTarget( final InstructionHandle ih ) { - return (start_pc == ih) || (end_pc == ih) || (handler_pc == ih); + return (startPc == ih) || (endPc == ih) || (handlerPc == ih); } /** Sets the type of the Exception to catch. Set 'null' for ANY. */ public void setCatchType( final ObjectType catch_type ) { - this.catch_type = catch_type; + this.catchType = catch_type; } /** Gets the type of the Exception to catch, 'null' for ANY. */ public ObjectType getCatchType() { - return catch_type; + return catchType; } /** @return start of handled region (inclusive) */ public InstructionHandle getStartPC() { - return start_pc; + return startPc; } /** @return end of handled region (inclusive) */ public InstructionHandle getEndPC() { - return end_pc; + return endPc; } /** @return start of handler */ public InstructionHandle getHandlerPC() { - return handler_pc; + return handlerPc; } @Override public String toString() { - return "CodeExceptionGen(" + start_pc + ", " + end_pc + ", " + handler_pc + ")"; + return "CodeExceptionGen(" + startPc + ", " + endPc + ", " + handlerPc + ")"; } diff --git a/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java b/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java index 35f46cd..5a09e0d 100644 --- a/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java +++ b/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java @@ -110,15 +110,15 @@ public class ConstantPoolGen { final ConstantString s = (ConstantString) c; final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; final String key = u8.getBytes(); - if (!string_table.containsKey(key)) { - string_table.put(key, new Index(i)); + if (!stringTable.containsKey(key)) { + stringTable.put(key, new Index(i)); } } else if (c instanceof ConstantClass) { final ConstantClass s = (ConstantClass) c; final ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; final String key = u8.getBytes(); - if (!class_table.containsKey(key)) { - class_table.put(key, new Index(i)); + if (!classTable.containsKey(key)) { + classTable.put(key, new Index(i)); } } else if (c instanceof ConstantNameAndType) { final ConstantNameAndType n = (ConstantNameAndType) c; @@ -131,14 +131,14 @@ public class ConstantPoolGen { final String key = sb.toString(); sb.delete(0, sb.length()); - if (!n_a_t_table.containsKey(key)) { - n_a_t_table.put(key, new Index(i)); + if (!natTable.containsKey(key)) { + natTable.put(key, new Index(i)); } } else if (c instanceof ConstantUtf8) { final ConstantUtf8 u = (ConstantUtf8) c; final String key = u.getBytes(); - if (!utf8_table.containsKey(key)) { - utf8_table.put(key, new Index(i)); + if (!utf8Table.containsKey(key)) { + utf8Table.put(key, new Index(i)); } } else if (c instanceof ConstantCP) { final ConstantCP m = (ConstantCP) c; @@ -176,8 +176,8 @@ public class ConstantPoolGen { final String key = sb.toString(); sb.delete(0, sb.length()); - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(i)); + if (!cpTable.containsKey(key)) { + cpTable.put(key, new Index(i)); } } else if (c == null) { // entries may be null // nothing to do @@ -232,7 +232,7 @@ public class ConstantPoolGen { } } - private final Map<String, Index> string_table = new HashMap<>(); + private final Map<String, Index> stringTable = new HashMap<>(); /** @@ -242,7 +242,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupString( final String str ) { - final Index index = string_table.get(str); + final Index index = stringTable.get(str); return (index != null) ? index.index : -1; } @@ -263,13 +263,13 @@ public class ConstantPoolGen { final ConstantString s = new ConstantString(utf8); ret = index; constants[index++] = s; - if (!string_table.containsKey(str)) { - string_table.put(str, new Index(ret)); + if (!stringTable.containsKey(str)) { + stringTable.put(str, new Index(ret)); } return ret; } - private final Map<String, Index> class_table = new HashMap<>(); + private final Map<String, Index> classTable = new HashMap<>(); /** @@ -279,7 +279,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupClass( final String str ) { - final Index index = class_table.get(str.replace('.', '/')); + final Index index = classTable.get(str.replace('.', '/')); return (index != null) ? index.index : -1; } @@ -293,8 +293,8 @@ public class ConstantPoolGen { final ConstantClass c = new ConstantClass(addUtf8(clazz)); ret = index; constants[index++] = c; - if (!class_table.containsKey(clazz)) { - class_table.put(clazz, new Index(ret)); + if (!classTable.containsKey(clazz)) { + classTable.put(clazz, new Index(ret)); } return ret; } @@ -408,7 +408,7 @@ public class ConstantPoolGen { return ret; } - private final Map<String, Index> utf8_table = new HashMap<>(); + private final Map<String, Index> utf8Table = new HashMap<>(); /** @@ -418,7 +418,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupUtf8( final String n ) { - final Index index = utf8_table.get(n); + final Index index = utf8Table.get(n); return (index != null) ? index.index : -1; } @@ -437,8 +437,8 @@ public class ConstantPoolGen { adjustSize(); ret = index; constants[index++] = new ConstantUtf8(n); - if (!utf8_table.containsKey(n)) { - utf8_table.put(n, new Index(ret)); + if (!utf8Table.containsKey(n)) { + utf8Table.put(n, new Index(ret)); } return ret; } @@ -520,7 +520,7 @@ public class ConstantPoolGen { return ret; } - private final Map<String, Index> n_a_t_table = new HashMap<>(); + private final Map<String, Index> natTable = new HashMap<>(); /** @@ -531,7 +531,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupNameAndType( final String name, final String signature ) { - final Index _index = n_a_t_table.get(name + NAT_DELIM + signature); + final Index _index = natTable.get(name + NAT_DELIM + signature); return (_index != null) ? _index.index : -1; } @@ -557,13 +557,13 @@ public class ConstantPoolGen { ret = index; constants[index++] = new ConstantNameAndType(name_index, signature_index); final String key = name + NAT_DELIM + signature; - if (!n_a_t_table.containsKey(key)) { - n_a_t_table.put(key, new Index(ret)); + if (!natTable.containsKey(key)) { + natTable.put(key, new Index(ret)); } return ret; } - private final Map<String, Index> cp_table = new HashMap<>(); + private final Map<String, Index> cpTable = new HashMap<>(); /** @@ -575,7 +575,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupMethodref( final String class_name, final String method_name, final String signature ) { - final Index index = cp_table.get(class_name + METHODREF_DELIM + method_name + final Index index = cpTable.get(class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature); return (index != null) ? index.index : -1; } @@ -608,8 +608,8 @@ public class ConstantPoolGen { ret = index; constants[index++] = new ConstantMethodref(class_index, name_and_type_index); final String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(ret)); + if (!cpTable.containsKey(key)) { + cpTable.put(key, new Index(ret)); } return ret; } @@ -629,7 +629,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupInterfaceMethodref( final String class_name, final String method_name, final String signature ) { - final Index index = cp_table.get(class_name + IMETHODREF_DELIM + method_name + final Index index = cpTable.get(class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature); return (index != null) ? index.index : -1; } @@ -663,8 +663,8 @@ public class ConstantPoolGen { ret = index; constants[index++] = new ConstantInterfaceMethodref(class_index, name_and_type_index); final String key = class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(ret)); + if (!cpTable.containsKey(key)) { + cpTable.put(key, new Index(ret)); } return ret; } @@ -684,7 +684,7 @@ public class ConstantPoolGen { * @return index on success, -1 otherwise */ public int lookupFieldref( final String class_name, final String field_name, final String signature ) { - final Index index = cp_table.get(class_name + FIELDREF_DELIM + field_name + final Index index = cpTable.get(class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature); return (index != null) ? index.index : -1; } @@ -712,8 +712,8 @@ public class ConstantPoolGen { ret = index; constants[index++] = new ConstantFieldref(class_index, name_and_type_index); final String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature; - if (!cp_table.containsKey(key)) { - cp_table.put(key, new Index(ret)); + if (!cpTable.containsKey(key)) { + cpTable.put(key, new Index(ret)); } return ret; } diff --git a/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java b/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java index 54d0686..3bb047b 100644 --- a/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java +++ b/src/main/java/org/apache/bcel/generic/ElementValuePairGen.java @@ -33,17 +33,17 @@ public class ElementValuePairGen private final ElementValueGen value; - private final ConstantPoolGen cpool; + private final ConstantPoolGen constantPoolGen; public ElementValuePairGen(final ElementValuePair nvp, final ConstantPoolGen cpool, final boolean copyPoolEntries) { - this.cpool = cpool; + this.constantPoolGen = cpool; // J5ASSERT: // Could assert nvp.getNameString() points to the same thing as - // cpool.getConstant(nvp.getNameIndex()) + // constantPoolGen.getConstant(nvp.getNameIndex()) // if - // (!nvp.getNameString().equals(((ConstantUtf8)cpool.getConstant(nvp.getNameIndex())).getBytes())) + // (!nvp.getNameString().equals(((ConstantUtf8)constantPoolGen.getConstant(nvp.getNameIndex())).getBytes())) // { // throw new IllegalArgumentException("envp buggered"); // } @@ -64,7 +64,7 @@ public class ElementValuePairGen public ElementValuePair getElementNameValuePair() { final ElementValue immutableValue = value.getElementValue(); - return new ElementValuePair(nameIdx, immutableValue, cpool + return new ElementValuePair(nameIdx, immutableValue, constantPoolGen .getConstantPool()); } @@ -73,7 +73,7 @@ public class ElementValuePairGen { this.nameIdx = idx; this.value = value; - this.cpool = cpool; + this.constantPoolGen = cpool; } public ElementValuePairGen(final String name, final ElementValueGen value, @@ -81,7 +81,7 @@ public class ElementValuePairGen { this.nameIdx = cpool.addUtf8(name); this.value = value; - this.cpool = cpool; + this.constantPoolGen = cpool; } protected void dump(final DataOutputStream dos) throws IOException @@ -97,8 +97,8 @@ public class ElementValuePairGen public final String getNameString() { - // ConstantString cu8 = (ConstantString)cpool.getConstant(nameIdx); - return ((ConstantUtf8) cpool.getConstant(nameIdx)).getBytes(); + // ConstantString cu8 = (ConstantString)constantPoolGen.getConstant(nameIdx); + return ((ConstantUtf8) constantPoolGen.getConstant(nameIdx)).getBytes(); } public final ElementValueGen getValue() diff --git a/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java b/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java index 3c1cf27..56a0d24 100644 --- a/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java +++ b/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java @@ -49,10 +49,10 @@ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAn @Deprecated protected ConstantPoolGen cp; - private final List<Attribute> attribute_vec = new ArrayList<>(); + private final List<Attribute> attributeList = new ArrayList<>(); // @since 6.0 - private final List<AnnotationEntryGen> annotation_vec= new ArrayList<>(); + private final List<AnnotationEntryGen> annotationList= new ArrayList<>(); protected FieldGenOrMethodGen() { @@ -114,7 +114,7 @@ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAn * @param a attribute to be added */ public void addAttribute( final Attribute a ) { - attribute_vec.add(a); + attributeList.add(a); } /** @@ -122,7 +122,7 @@ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAn */ public void addAnnotationEntry(final AnnotationEntryGen ag) { - annotation_vec.add(ag); + annotationList.add(ag); } @@ -130,7 +130,7 @@ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAn * Remove an attribute. */ public void removeAttribute( final Attribute a ) { - attribute_vec.remove(a); + attributeList.remove(a); } /** @@ -138,7 +138,7 @@ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAn */ public void removeAnnotationEntry(final AnnotationEntryGen ag) { - annotation_vec.remove(ag); + annotationList.remove(ag); } @@ -146,7 +146,7 @@ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAn * Remove all attributes. */ public void removeAttributes() { - attribute_vec.clear(); + attributeList.clear(); } /** @@ -154,7 +154,7 @@ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAn */ public void removeAnnotationEntries() { - annotation_vec.clear(); + annotationList.clear(); } @@ -162,14 +162,14 @@ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAn * @return all attributes of this method. */ public Attribute[] getAttributes() { - final Attribute[] attributes = new Attribute[attribute_vec.size()]; - attribute_vec.toArray(attributes); + final Attribute[] attributes = new Attribute[attributeList.size()]; + attributeList.toArray(attributes); return attributes; } public AnnotationEntryGen[] getAnnotationEntries() { - final AnnotationEntryGen[] annotations = new AnnotationEntryGen[annotation_vec.size()]; - annotation_vec.toArray(annotations); + final AnnotationEntryGen[] annotations = new AnnotationEntryGen[annotationList.size()]; + annotationList.toArray(annotations); return annotations; } diff --git a/src/main/java/org/apache/bcel/generic/InstructionList.java b/src/main/java/org/apache/bcel/generic/InstructionList.java index 2727d3e..9e591bf 100644 --- a/src/main/java/org/apache/bcel/generic/InstructionList.java +++ b/src/main/java/org/apache/bcel/generic/InstructionList.java @@ -47,7 +47,7 @@ public class InstructionList implements Iterable<InstructionHandle> { private InstructionHandle start = null; private InstructionHandle end = null; private int length = 0; // number of elements in list - private int[] byte_positions; // byte code offsets corresponding to instructions + private int[] bytePositions; // byte code offsets corresponding to instructions /** * Create (empty) instruction list. @@ -134,7 +134,7 @@ public class InstructionList implements Iterable<InstructionHandle> { * @return target position's instruction handle if available */ public InstructionHandle findHandle(final int pos) { - final int[] positions = byte_positions; + final int[] positions = bytePositions; InstructionHandle ih = start; for (int i = 0; i < length; i++) { if (positions[i] == pos) { @@ -182,8 +182,8 @@ public class InstructionList implements Iterable<InstructionHandle> { } catch (final IOException e) { throw new ClassGenException(e.toString(), e); } - byte_positions = new int[count]; // Trim to proper size - System.arraycopy(pos, 0, byte_positions, 0, count); + bytePositions = new int[count]; // Trim to proper size + System.arraycopy(pos, 0, bytePositions, 0, count); /* * Pass 2: Look for BranchInstruction and update their targets, i.e., convert offsets to instruction handles. */ @@ -923,8 +923,8 @@ public class InstructionList implements Iterable<InstructionHandle> { pos[count++] = index; index += i.getLength(); } - byte_positions = new int[count]; // Trim to proper size - System.arraycopy(pos, 0, byte_positions, 0, count); + bytePositions = new int[count]; // Trim to proper size + System.arraycopy(pos, 0, bytePositions, 0, count); } /** @@ -1034,7 +1034,7 @@ public class InstructionList implements Iterable<InstructionHandle> { * @return array containing all instruction's offset in byte code */ public int[] getInstructionPositions() { - return byte_positions; + return bytePositions; } /** diff --git a/src/main/java/org/apache/bcel/generic/LineNumberGen.java b/src/main/java/org/apache/bcel/generic/LineNumberGen.java index e8a5668..ff40ced 100644 --- a/src/main/java/org/apache/bcel/generic/LineNumberGen.java +++ b/src/main/java/org/apache/bcel/generic/LineNumberGen.java @@ -31,7 +31,7 @@ import org.apache.bcel.classfile.LineNumber; public class LineNumberGen implements InstructionTargeter, Cloneable { private InstructionHandle ih; - private int src_line; + private int srcLine; /** * Create a line number. @@ -73,7 +73,7 @@ public class LineNumberGen implements InstructionTargeter, Cloneable { * or that the `setPositions' methods has been called for the instruction list. */ public LineNumber getLineNumber() { - return new LineNumber(ih.getPosition(), src_line); + return new LineNumber(ih.getPosition(), srcLine); } @@ -100,11 +100,11 @@ public class LineNumberGen implements InstructionTargeter, Cloneable { public void setSourceLine( final int src_line ) { // TODO could be package-protected? - this.src_line = src_line; + this.srcLine = src_line; } public int getSourceLine() { - return src_line; + return srcLine; } } diff --git a/src/main/java/org/apache/bcel/generic/LocalVariableGen.java b/src/main/java/org/apache/bcel/generic/LocalVariableGen.java index d2316df..c7d6de5 100644 --- a/src/main/java/org/apache/bcel/generic/LocalVariableGen.java +++ b/src/main/java/org/apache/bcel/generic/LocalVariableGen.java @@ -36,8 +36,8 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo private Type type; private InstructionHandle start; private InstructionHandle end; - private int orig_index; // never changes; used to match up with LocalVariableTypeTable entries - private boolean live_to_end; + private int origIndex; // never changes; used to match up with LocalVariableTypeTable entries + private boolean liveToEnd; /** @@ -60,8 +60,8 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo this.index = index; setStart(start); setEnd(end); - this.orig_index = index; - this.live_to_end = end == null; + this.origIndex = index; + this.liveToEnd = end == null; } @@ -74,12 +74,12 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo * @param type its type * @param start from where the instruction is valid (null means from the start) * @param end until where the instruction is valid (null means to the end) - * @param orig_index index of local variable prior to any changes to index + * @param origIndex index of local variable prior to any changes to index */ public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start, final InstructionHandle end, final int orig_index) { this(index, name, type, start, end); - this.orig_index = orig_index; + this.origIndex = orig_index; } @@ -92,7 +92,7 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo * Note that due to the conversion from byte code offset to InstructionHandle, * it is impossible to tell the difference between a live range that ends BEFORE * the last insturction of the method or a live range that ends AFTER the last - * instruction of the method. Hence the live_to_end flag to differentiate + * instruction of the method. Hence the liveToEnd flag to differentiate * between these two cases. * * @param cp constant pool @@ -103,14 +103,14 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo if ((start != null) && (end != null)) { start_pc = start.getPosition(); length = end.getPosition() - start_pc; - if ((end.getNext() == null) && live_to_end) { + if ((end.getNext() == null) && liveToEnd) { length += end.getInstruction().getLength(); } } final int name_index = cp.addUtf8(name); final int signature_index = cp.addUtf8(type.getSignature()); return new LocalVariable(start_pc, length, name_index, signature_index, index, cp - .getConstantPool(), orig_index); + .getConstantPool(), origIndex); } @@ -125,17 +125,17 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo public int getOrigIndex() { - return orig_index; + return origIndex; } public void setLiveToEnd( final boolean live_to_end) { - this.live_to_end = live_to_end; + this.liveToEnd = live_to_end; } public boolean getLiveToEnd() { - return live_to_end; + return liveToEnd; } diff --git a/src/main/java/org/apache/bcel/generic/LocalVariableInstruction.java b/src/main/java/org/apache/bcel/generic/LocalVariableInstruction.java index ec567b2..8a9c933 100644 --- a/src/main/java/org/apache/bcel/generic/LocalVariableInstruction.java +++ b/src/main/java/org/apache/bcel/generic/LocalVariableInstruction.java @@ -36,8 +36,8 @@ public abstract class LocalVariableInstruction extends Instruction implements Ty @Deprecated protected int n = -1; // index of referenced variable - private short c_tag = -1; // compact version, such as ILOAD_0 - private short canon_tag = -1; // canonical tag such as ILOAD + private short cTag = -1; // compact version, such as ILOAD_0 + private short canonTag = -1; // canonical tag such as ILOAD private boolean wide() { @@ -52,8 +52,8 @@ public abstract class LocalVariableInstruction extends Instruction implements Ty */ LocalVariableInstruction(final short canon_tag, final short c_tag) { super(); - this.canon_tag = canon_tag; - this.c_tag = c_tag; + this.canonTag = canon_tag; + this.cTag = c_tag; } @@ -67,13 +67,13 @@ public abstract class LocalVariableInstruction extends Instruction implements Ty /** * @param opcode Instruction opcode - * @param c_tag Instruction number for compact version, ALOAD_0, e.g. + * @param cTag Instruction number for compact version, ALOAD_0, e.g. * @param n local variable index (unsigned short) */ protected LocalVariableInstruction(final short opcode, final short c_tag, final int n) { super(opcode, (short) 2); - this.c_tag = c_tag; - canon_tag = opcode; + this.cTag = c_tag; + canonTag = opcode; setIndex(n); } @@ -169,10 +169,10 @@ public abstract class LocalVariableInstruction extends Instruction implements Ty this.n = n; // Cannot be < 0 as this is checked above if (n <= 3) { // Use more compact instruction xLOAD_n - super.setOpcode((short) (c_tag + n)); + super.setOpcode((short) (cTag + n)); super.setLength(1); } else { - super.setOpcode(canon_tag); + super.setOpcode(canonTag); if (wide()) { super.setLength(4); } else { @@ -185,7 +185,7 @@ public abstract class LocalVariableInstruction extends Instruction implements Ty /** @return canonical tag for instruction, e.g., ALOAD for ALOAD_0 */ public short getCanonicalTag() { - return canon_tag; + return canonTag; } @@ -199,7 +199,7 @@ public abstract class LocalVariableInstruction extends Instruction implements Ty */ @Override public Type getType( final ConstantPoolGen cp ) { - switch (canon_tag) { + switch (canonTag) { case Const.ILOAD: case Const.ISTORE: return Type.INT; @@ -216,7 +216,7 @@ public abstract class LocalVariableInstruction extends Instruction implements Ty case Const.ASTORE: return Type.OBJECT; default: - throw new ClassGenException("Unknown case in switch" + canon_tag); + throw new ClassGenException("Unknown case in switch" + canonTag); } } diff --git a/src/main/java/org/apache/bcel/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java index 915a23c..87e9e0f 100644 --- a/src/main/java/org/apache/bcel/generic/MethodGen.java +++ b/src/main/java/org/apache/bcel/generic/MethodGen.java @@ -58,21 +58,21 @@ import org.apache.bcel.util.BCELComparator; */ public class MethodGen extends FieldGenOrMethodGen { - private String class_name; - private Type[] arg_types; - private String[] arg_names; - private int max_locals; - private int max_stack; + private String className; + private Type[] argTypes; + private String[] argNames; + private int maxLocals; + private int maxStack; private InstructionList il; - private boolean strip_attributes; - private LocalVariableTypeTable local_variable_type_table = null; - private final List<LocalVariableGen> variable_vec = new ArrayList<>(); - private final List<LineNumberGen> line_number_vec = new ArrayList<>(); - private final List<CodeExceptionGen> exception_vec = new ArrayList<>(); - private final List<String> throws_vec = new ArrayList<>(); - private final List<Attribute> code_attrs_vec = new ArrayList<>(); - - private List<AnnotationEntryGen>[] param_annotations; // Array of lists containing AnnotationGen objects + private boolean stripAttributes; + private LocalVariableTypeTable localVariableTypeTable = null; + private final List<LocalVariableGen> variableList = new ArrayList<>(); + private final List<LineNumberGen> lineNumberList = new ArrayList<>(); + private final List<CodeExceptionGen> exceptionList = new ArrayList<>(); + private final List<String> throwsList = new ArrayList<>(); + private final List<Attribute> codeAttrsList = new ArrayList<>(); + + private List<AnnotationEntryGen>[] paramAnnotations; // Array of lists containing AnnotationGen objects private boolean hasParameterAnnotations = false; private boolean haveUnpackedParameterAnnotations = false; @@ -108,11 +108,11 @@ public class MethodGen extends FieldGenOrMethodGen { * * @param access_flags access qualifiers * @param return_type method type - * @param arg_types argument types - * @param arg_names argument names (if this is null, default names will be provided + * @param argTypes argument types + * @param argNames argument names (if this is null, default names will be provided * for them) * @param method_name name of method - * @param class_name class name containing this method (may be null, if you don't care) + * @param className class name containing this method (may be null, if you don't care) * @param il instruction list associated with this method, may be null only for * abstract or native methods * @param cp constant pool @@ -171,7 +171,7 @@ public class MethodGen extends FieldGenOrMethodGen { * Instantiate from existing method. * * @param method method - * @param class_name class name containing this method + * @param className class name containing this method * @param cp constant pool */ public MethodGen(final Method method, final String class_name, final ConstantPoolGen cp) { @@ -225,7 +225,7 @@ public class MethodGen extends FieldGenOrMethodGen { } else if (a instanceof LocalVariableTable) { updateLocalVariableTable((LocalVariableTable) a); } else if (a instanceof LocalVariableTypeTable) { - this.local_variable_type_table = (LocalVariableTypeTable) a.copy(cp.getConstantPool()); + this.localVariableTypeTable = (LocalVariableTypeTable) a.copy(cp.getConstantPool()); } else { addCodeAttribute(a); } @@ -274,15 +274,15 @@ public class MethodGen extends FieldGenOrMethodGen { final byte t = type.getType(); if (t != Const.T_ADDRESS) { final int add = type.getSize(); - if (slot + add > max_locals) { - max_locals = slot + add; + if (slot + add > maxLocals) { + maxLocals = slot + add; } final LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end, orig_index); int i; - if ((i = variable_vec.indexOf(l)) >= 0) { - variable_vec.set(i, l); + if ((i = variableList.indexOf(l)) >= 0) { + variableList.set(i, l); } else { - variable_vec.add(l); + variableList.add(l); } return l; } @@ -322,7 +322,7 @@ public class MethodGen extends FieldGenOrMethodGen { */ public LocalVariableGen addLocalVariable( final String name, final Type type, final InstructionHandle start, final InstructionHandle end ) { - return addLocalVariable(name, type, max_locals, start, end); + return addLocalVariable(name, type, maxLocals, start, end); } @@ -332,7 +332,7 @@ public class MethodGen extends FieldGenOrMethodGen { */ public void removeLocalVariable( final LocalVariableGen l ) { l.dispose(); - variable_vec.remove(l); + variableList.remove(l); } @@ -340,10 +340,10 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove all local variables. */ public void removeLocalVariables() { - for (final LocalVariableGen lv : variable_vec) { + for (final LocalVariableGen lv : variableList) { lv.dispose(); } - variable_vec.clear(); + variableList.clear(); } @@ -354,9 +354,9 @@ public class MethodGen extends FieldGenOrMethodGen { * @return array of declared local variables sorted by index */ public LocalVariableGen[] getLocalVariables() { - final int size = variable_vec.size(); + final int size = variableList.size(); final LocalVariableGen[] lg = new LocalVariableGen[size]; - variable_vec.toArray(lg); + variableList.toArray(lg); for (int i = 0; i < size; i++) { if ((lg[i].getStart() == null) && (il != null)) { lg[i].setStart(il.getStart()); @@ -390,7 +390,7 @@ public class MethodGen extends FieldGenOrMethodGen { * @return `LocalVariableTypeTable' attribute of this method. */ public LocalVariableTypeTable getLocalVariableTypeTable() { - return local_variable_type_table; + return localVariableTypeTable; } /** @@ -402,7 +402,7 @@ public class MethodGen extends FieldGenOrMethodGen { */ public LineNumberGen addLineNumber( final InstructionHandle ih, final int src_line ) { final LineNumberGen l = new LineNumberGen(ih, src_line); - line_number_vec.add(l); + lineNumberList.add(l); return l; } @@ -411,7 +411,7 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove a line number. */ public void removeLineNumber( final LineNumberGen l ) { - line_number_vec.remove(l); + lineNumberList.remove(l); } @@ -419,7 +419,7 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove all line numbers. */ public void removeLineNumbers() { - line_number_vec.clear(); + lineNumberList.clear(); } @@ -427,8 +427,8 @@ public class MethodGen extends FieldGenOrMethodGen { * @return array of line numbers */ public LineNumberGen[] getLineNumbers() { - final LineNumberGen[] lg = new LineNumberGen[line_number_vec.size()]; - line_number_vec.toArray(lg); + final LineNumberGen[] lg = new LineNumberGen[lineNumberList.size()]; + lineNumberList.toArray(lg); return lg; } @@ -437,10 +437,10 @@ public class MethodGen extends FieldGenOrMethodGen { * @return `LineNumberTable' attribute of all the local variables of this method. */ public LineNumberTable getLineNumberTable( final ConstantPoolGen cp ) { - final int size = line_number_vec.size(); + final int size = lineNumberList.size(); final LineNumber[] ln = new LineNumber[size]; for (int i = 0; i < size; i++) { - ln[i] = line_number_vec.get(i).getLineNumber(); + ln[i] = lineNumberList.get(i).getLineNumber(); } return new LineNumberTable(cp.addUtf8("LineNumberTable"), 2 + ln.length * 4, ln, cp .getConstantPool()); @@ -464,7 +464,7 @@ public class MethodGen extends FieldGenOrMethodGen { throw new ClassGenException("Exception handler target is null instruction"); } final CodeExceptionGen c = new CodeExceptionGen(start_pc, end_pc, handler_pc, catch_type); - exception_vec.add(c); + exceptionList.add(c); return c; } @@ -473,7 +473,7 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove an exception handler. */ public void removeExceptionHandler( final CodeExceptionGen c ) { - exception_vec.remove(c); + exceptionList.remove(c); } @@ -481,7 +481,7 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove all line numbers. */ public void removeExceptionHandlers() { - exception_vec.clear(); + exceptionList.clear(); } @@ -489,8 +489,8 @@ public class MethodGen extends FieldGenOrMethodGen { * @return array of declared exception handlers */ public CodeExceptionGen[] getExceptionHandlers() { - final CodeExceptionGen[] cg = new CodeExceptionGen[exception_vec.size()]; - exception_vec.toArray(cg); + final CodeExceptionGen[] cg = new CodeExceptionGen[exceptionList.size()]; + exceptionList.toArray(cg); return cg; } @@ -499,10 +499,10 @@ public class MethodGen extends FieldGenOrMethodGen { * @return code exceptions for `Code' attribute */ private CodeException[] getCodeExceptions() { - final int size = exception_vec.size(); + final int size = exceptionList.size(); final CodeException[] c_exc = new CodeException[size]; for (int i = 0; i < size; i++) { - final CodeExceptionGen c = exception_vec.get(i); + final CodeExceptionGen c = exceptionList.get(i); c_exc[i] = c.getCodeException(super.getConstantPool()); } return c_exc; @@ -512,10 +512,10 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Add an exception possibly thrown by this method. * - * @param class_name (fully qualified) name of exception + * @param className (fully qualified) name of exception */ public void addException( final String class_name ) { - throws_vec.add(class_name); + throwsList.add(class_name); } @@ -523,7 +523,7 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove an exception. */ public void removeException( final String c ) { - throws_vec.remove(c); + throwsList.remove(c); } @@ -531,7 +531,7 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove all exceptions. */ public void removeExceptions() { - throws_vec.clear(); + throwsList.clear(); } @@ -539,8 +539,8 @@ public class MethodGen extends FieldGenOrMethodGen { * @return array of thrown exceptions */ public String[] getExceptions() { - final String[] e = new String[throws_vec.size()]; - throws_vec.toArray(e); + final String[] e = new String[throwsList.size()]; + throwsList.toArray(e); return e; } @@ -549,10 +549,10 @@ public class MethodGen extends FieldGenOrMethodGen { * @return `Exceptions' attribute of all the exceptions thrown by this method. */ private ExceptionTable getExceptionTable( final ConstantPoolGen cp ) { - final int size = throws_vec.size(); + final int size = throwsList.size(); final int[] ex = new int[size]; for (int i = 0; i < size; i++) { - ex[i] = cp.addClass(throws_vec.get(i)); + ex[i] = cp.addClass(throwsList.get(i)); } return new ExceptionTable(cp.addUtf8("Exceptions"), 2 + 2 * size, ex, cp.getConstantPool()); } @@ -568,7 +568,7 @@ public class MethodGen extends FieldGenOrMethodGen { * @param a attribute to be added */ public void addCodeAttribute( final Attribute a ) { - code_attrs_vec.add(a); + codeAttrsList.add(a); } @@ -576,14 +576,14 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove the LocalVariableTypeTable */ public void removeLocalVariableTypeTable( ) { - local_variable_type_table = null; + localVariableTypeTable = null; } /** * Remove a code attribute. */ public void removeCodeAttribute( final Attribute a ) { - code_attrs_vec.remove(a); + codeAttrsList.remove(a); } @@ -591,8 +591,8 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove all code attributes. */ public void removeCodeAttributes() { - local_variable_type_table = null; - code_attrs_vec.clear(); + localVariableTypeTable = null; + codeAttrsList.clear(); } @@ -600,8 +600,8 @@ public class MethodGen extends FieldGenOrMethodGen { * @return all attributes of this method. */ public Attribute[] getCodeAttributes() { - final Attribute[] attributes = new Attribute[code_attrs_vec.size()]; - code_attrs_vec.toArray(attributes); + final Attribute[] attributes = new Attribute[codeAttrsList.size()]; + codeAttrsList.toArray(attributes); return attributes; } @@ -622,7 +622,7 @@ public class MethodGen extends FieldGenOrMethodGen { if (!hasParameterAnnotations) { return; } - final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, param_annotations); + final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations); if (attrs != null) { for (final Attribute attr : attrs) { addAttribute(attr); @@ -642,7 +642,7 @@ public class MethodGen extends FieldGenOrMethodGen { if (!hasParameterAnnotations) { return new Attribute[0]; } - final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, param_annotations); + final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, paramAnnotations); for (final Attribute attr : attrs) { addAttribute(attr); } @@ -682,18 +682,18 @@ public class MethodGen extends FieldGenOrMethodGen { LocalVariableTable lvt = null; /* Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.) */ - if ((variable_vec.size() > 0) && !strip_attributes) { + if ((variableList.size() > 0) && !stripAttributes) { updateLocalVariableTable(getLocalVariableTable(_cp)); addCodeAttribute(lvt = getLocalVariableTable(_cp)); } - if (local_variable_type_table != null) { + if (localVariableTypeTable != null) { // LocalVariable length in LocalVariableTypeTable is not updated automatically. It's a difference with LocalVariableTable. if (lvt != null) { adjustLocalVariableTypeTable(lvt); } - addCodeAttribute(local_variable_type_table); + addCodeAttribute(localVariableTypeTable); } - if ((line_number_vec.size() > 0) && !strip_attributes) { + if ((lineNumberList.size() > 0) && !stripAttributes) { addCodeAttribute(lnt = getLineNumberTable(_cp)); } final Attribute[] code_attrs = getCodeAttributes(); @@ -717,13 +717,13 @@ public class MethodGen extends FieldGenOrMethodGen { code = new Code(_cp.addUtf8("Code"), 8 + byte_code.length + // prologue byte code 2 + exc_len + // exceptions 2 + attrs_len, // attributes - max_stack, max_locals, byte_code, c_exc, code_attrs, _cp.getConstantPool()); + maxStack, maxLocals, byte_code, c_exc, code_attrs, _cp.getConstantPool()); addAttribute(code); } final Attribute[] annotations = addRuntimeAnnotationsAsAttribute(_cp); final Attribute[] parameterAnnotations = addRuntimeParameterAnnotationsAsAttribute(_cp); ExceptionTable et = null; - if (throws_vec.size() > 0) { + if (throwsList.size() > 0) { addAttribute(et = getExceptionTable(_cp)); // Add `Exceptions' if there are "throws" clauses } @@ -733,8 +733,8 @@ public class MethodGen extends FieldGenOrMethodGen { if (lvt != null) { removeCodeAttribute(lvt); } - if (local_variable_type_table != null) { - removeCodeAttribute(local_variable_type_table); + if (localVariableTypeTable != null) { + removeCodeAttribute(localVariableTypeTable); } if (lnt != null) { removeCodeAttribute(lnt); @@ -770,7 +770,7 @@ public class MethodGen extends FieldGenOrMethodGen { private void adjustLocalVariableTypeTable(final LocalVariableTable lvt) { final LocalVariable[] lv = lvt.getLocalVariableTable(); - final LocalVariable[] lvg = local_variable_type_table.getLocalVariableTypeTable(); + final LocalVariable[] lvg = localVariableTypeTable.getLocalVariableTypeTable(); for (final LocalVariable element : lvg) { for (final LocalVariable l : lv) { @@ -817,12 +817,12 @@ public class MethodGen extends FieldGenOrMethodGen { * Set maximum number of local variables. */ public void setMaxLocals( final int m ) { - max_locals = m; + maxLocals = m; } public int getMaxLocals() { - return max_locals; + return maxLocals; } @@ -830,24 +830,24 @@ public class MethodGen extends FieldGenOrMethodGen { * Set maximum stack size for this method. */ public void setMaxStack( final int m ) { // TODO could be package-protected? - max_stack = m; + maxStack = m; } public int getMaxStack() { - return max_stack; + return maxStack; } /** @return class that contains this method */ public String getClassName() { - return class_name; + return className; } public void setClassName( final String class_name ) { // TODO could be package-protected? - this.class_name = class_name; + this.className = class_name; } @@ -862,42 +862,42 @@ public class MethodGen extends FieldGenOrMethodGen { public void setArgumentTypes( final Type[] arg_types ) { - this.arg_types = arg_types; + this.argTypes = arg_types; } public Type[] getArgumentTypes() { - return arg_types.clone(); + return argTypes.clone(); } public void setArgumentType( final int i, final Type type ) { - arg_types[i] = type; + argTypes[i] = type; } public Type getArgumentType( final int i ) { - return arg_types[i]; + return argTypes[i]; } public void setArgumentNames( final String[] arg_names ) { - this.arg_names = arg_names; + this.argNames = arg_names; } public String[] getArgumentNames() { - return arg_names.clone(); + return argNames.clone(); } public void setArgumentName( final int i, final String name ) { - arg_names[i] = name; + argNames[i] = name; } public String getArgumentName( final int i ) { - return arg_names[i]; + return argNames[i]; } @@ -913,7 +913,7 @@ public class MethodGen extends FieldGenOrMethodGen { @Override public String getSignature() { - return Type.getMethodSignature(super.getType(), arg_types); + return Type.getMethodSignature(super.getType(), argTypes); } @@ -922,9 +922,9 @@ public class MethodGen extends FieldGenOrMethodGen { */ public void setMaxStack() { // TODO could be package-protected? (some tests would need repackaging) if (il != null) { - max_stack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers()); + maxStack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers()); } else { - max_stack = 0; + maxStack = 0; } } @@ -935,8 +935,8 @@ public class MethodGen extends FieldGenOrMethodGen { public void setMaxLocals() { // TODO could be package-protected? (some tests would need repackaging) if (il != null) { int max = isStatic() ? 0 : 1; - if (arg_types != null) { - for (final Type arg_type : arg_types) { + if (argTypes != null) { + for (final Type arg_type : argTypes) { max += arg_type.getSize(); } } @@ -951,9 +951,9 @@ public class MethodGen extends FieldGenOrMethodGen { } } } - max_locals = max; + maxLocals = max; } else { - max_locals = 0; + maxLocals = 0; } } @@ -962,7 +962,7 @@ public class MethodGen extends FieldGenOrMethodGen { * LocalVariableTable, like javac -O */ public void stripAttributes( final boolean flag ) { - strip_attributes = flag; + stripAttributes = flag; } static final class BranchTarget { @@ -1133,7 +1133,7 @@ public class MethodGen extends FieldGenOrMethodGen { @Override public final String toString() { final String access = Utility.accessToString(super.getAccessFlags()); - String signature = Type.getMethodSignature(super.getType(), arg_types); + String signature = Type.getMethodSignature(super.getType(), argTypes); signature = Utility.methodSignatureToString(signature, super.getName(), access, true, getLocalVariableTable(super.getConstantPool())); final StringBuilder buf = new StringBuilder(signature); @@ -1143,8 +1143,8 @@ public class MethodGen extends FieldGenOrMethodGen { } } - if (throws_vec.size() > 0) { - for (final String throwsDescriptor : throws_vec) { + if (throwsList.size() > 0) { + for (final String throwsDescriptor : throwsList) { buf.append("\n\t\tthrows ").append(throwsDescriptor); } } @@ -1164,7 +1164,7 @@ public class MethodGen extends FieldGenOrMethodGen { return mg; } - //J5TODO: Should param_annotations be an array of arrays? Rather than an array of lists, this + //J5TODO: Should paramAnnotations be an array of arrays? Rather than an array of lists, this // is more likely to suggest to the caller it is readonly (which a List does not). /** * Return a list of AnnotationGen objects representing parameter annotations @@ -1172,10 +1172,10 @@ public class MethodGen extends FieldGenOrMethodGen { */ public List<AnnotationEntryGen> getAnnotationsOnParameter(final int i) { ensureExistingParameterAnnotationsUnpacked(); - if (!hasParameterAnnotations || i>arg_types.length) { + if (!hasParameterAnnotations || i>argTypes.length) { return null; } - return param_annotations[i]; + return paramAnnotations[i]; } /** @@ -1198,14 +1198,14 @@ public class MethodGen extends FieldGenOrMethodGen { for (final Attribute attribute : attrs) { if (attribute instanceof ParameterAnnotations) { - // Initialize param_annotations + // Initialize paramAnnotations if (!hasParameterAnnotations) { @SuppressWarnings("unchecked") // OK - final List<AnnotationEntryGen>[] parmList = new List[arg_types.length]; - param_annotations = parmList; - for (int j = 0; j < arg_types.length; j++) { - param_annotations[j] = new ArrayList<>(); + final List<AnnotationEntryGen>[] parmList = new List[argTypes.length]; + paramAnnotations = parmList; + for (int j = 0; j < argTypes.length; j++) { + paramAnnotations[j] = new ArrayList<>(); } } hasParameterAnnotations = true; @@ -1223,7 +1223,7 @@ public class MethodGen extends FieldGenOrMethodGen { // ... which needs transforming into an AnnotationGen[] ... final List<AnnotationEntryGen> mutable = makeMutableVersion(immutableArray.getAnnotationEntries()); // ... then add these to any we already know about - param_annotations[j].addAll(mutable); + paramAnnotations[j].addAll(mutable); } } } @@ -1253,11 +1253,11 @@ public class MethodGen extends FieldGenOrMethodGen { if (!hasParameterAnnotations) { @SuppressWarnings("unchecked") // OK - final List<AnnotationEntryGen>[] parmList = new List[arg_types.length]; - param_annotations = parmList; + final List<AnnotationEntryGen>[] parmList = new List[argTypes.length]; + paramAnnotations = parmList; hasParameterAnnotations = true; } - final List<AnnotationEntryGen> existingAnnotations = param_annotations[parameterIndex]; + final List<AnnotationEntryGen> existingAnnotations = paramAnnotations[parameterIndex]; if (existingAnnotations != null) { existingAnnotations.add(annotation); @@ -1266,7 +1266,7 @@ public class MethodGen extends FieldGenOrMethodGen { { final List<AnnotationEntryGen> l = new ArrayList<>(); l.add(annotation); - param_annotations[parameterIndex] = l; + paramAnnotations[parameterIndex] = l; } } diff --git a/src/main/java/org/apache/bcel/generic/ObjectType.java b/src/main/java/org/apache/bcel/generic/ObjectType.java index 52e3a4b..af495a7 100644 --- a/src/main/java/org/apache/bcel/generic/ObjectType.java +++ b/src/main/java/org/apache/bcel/generic/ObjectType.java @@ -27,7 +27,7 @@ import org.apache.bcel.classfile.JavaClass; */ public class ObjectType extends ReferenceType { - private final String class_name; // Class name of type + private final String className; // Class name of type /** * @since 6.0 @@ -37,18 +37,18 @@ public class ObjectType extends ReferenceType { } /** - * @param class_name fully qualified class name, e.g. java.lang.String + * @param className fully qualified class name, e.g. java.lang.String */ public ObjectType(final String class_name) { super(Const.T_REFERENCE, "L" + class_name.replace('.', '/') + ";"); - this.class_name = class_name.replace('/', '.'); + this.className = class_name.replace('/', '.'); } /** @return name of referenced class */ public String getClassName() { - return class_name; + return className; } @@ -56,7 +56,7 @@ public class ObjectType extends ReferenceType { */ @Override public int hashCode() { - return class_name.hashCode(); + return className.hashCode(); } @@ -65,7 +65,7 @@ public class ObjectType extends ReferenceType { @Override public boolean equals( final Object type ) { return (type instanceof ObjectType) - ? ((ObjectType) type).class_name.equals(class_name) + ? ((ObjectType) type).className.equals(className) : false; } @@ -80,7 +80,7 @@ public class ObjectType extends ReferenceType { @Deprecated public boolean referencesClass() { try { - final JavaClass jc = Repository.lookupClass(class_name); + final JavaClass jc = Repository.lookupClass(className); return jc.isClass(); } catch (final ClassNotFoundException e) { return false; @@ -98,7 +98,7 @@ public class ObjectType extends ReferenceType { @Deprecated public boolean referencesInterface() { try { - final JavaClass jc = Repository.lookupClass(class_name); + final JavaClass jc = Repository.lookupClass(className); return !jc.isClass(); } catch (final ClassNotFoundException e) { return false; @@ -115,7 +115,7 @@ public class ObjectType extends ReferenceType { * referenced by this type can't be found */ public boolean referencesClassExact() throws ClassNotFoundException { - final JavaClass jc = Repository.lookupClass(class_name); + final JavaClass jc = Repository.lookupClass(className); return jc.isClass(); } @@ -129,7 +129,7 @@ public class ObjectType extends ReferenceType { * referenced by this type can't be found */ public boolean referencesInterfaceExact() throws ClassNotFoundException { - final JavaClass jc = Repository.lookupClass(class_name); + final JavaClass jc = Repository.lookupClass(className); return !jc.isClass(); } @@ -143,7 +143,7 @@ public class ObjectType extends ReferenceType { if (this.referencesInterfaceExact() || superclass.referencesInterfaceExact()) { return false; } - return Repository.instanceOf(this.class_name, superclass.class_name); + return Repository.instanceOf(this.className, superclass.className); } @@ -153,11 +153,11 @@ public class ObjectType extends ReferenceType { * can't be found */ public boolean accessibleTo( final ObjectType accessor ) throws ClassNotFoundException { - final JavaClass jc = Repository.lookupClass(class_name); + final JavaClass jc = Repository.lookupClass(className); if (jc.isPublic()) { return true; } - final JavaClass acc = Repository.lookupClass(accessor.class_name); + final JavaClass acc = Repository.lookupClass(accessor.className); return acc.getPackageName().equals(jc.getPackageName()); } } diff --git a/src/main/java/org/apache/bcel/generic/SWITCH.java b/src/main/java/org/apache/bcel/generic/SWITCH.java index 390b3b9..5172ed1 100644 --- a/src/main/java/org/apache/bcel/generic/SWITCH.java +++ b/src/main/java/org/apache/bcel/generic/SWITCH.java @@ -28,7 +28,7 @@ public final class SWITCH implements CompoundInstruction { private int[] match; private InstructionHandle[] targets; private Select instruction; - private int match_length; + private int matchLength; /** @@ -49,10 +49,10 @@ public final class SWITCH implements CompoundInstruction { public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target, final int max_gap) { this.match = match.clone(); this.targets = targets.clone(); - if ((match_length = match.length) < 2) { + if ((matchLength = match.length) < 2) { instruction = new TABLESWITCH(match, targets, target); } else { - sort(0, match_length - 1); + sort(0, matchLength - 1); if (matchIsOrdered(max_gap)) { fillup(max_gap, target); instruction = new TABLESWITCH(this.match, this.targets, target); @@ -69,13 +69,13 @@ public final class SWITCH implements CompoundInstruction { private void fillup( final int max_gap, final InstructionHandle target ) { - final int max_size = match_length + match_length * max_gap; + final int max_size = matchLength + matchLength * max_gap; final int[] m_vec = new int[max_size]; final InstructionHandle[] t_vec = new InstructionHandle[max_size]; int count = 1; m_vec[0] = match[0]; t_vec[0] = targets[0]; - for (int i = 1; i < match_length; i++) { + for (int i = 1; i < matchLength; i++) { final int prev = match[i - 1]; final int gap = match[i] - prev; for (int j = 1; j < gap; j++) { @@ -134,7 +134,7 @@ public final class SWITCH implements CompoundInstruction { * @return match is sorted in ascending order with no gap bigger than max_gap? */ private boolean matchIsOrdered( final int max_gap ) { - for (int i = 1; i < match_length; i++) { + for (int i = 1; i < matchLength; i++) { if (match[i] - match[i - 1] > max_gap) { return false; } diff --git a/src/main/java/org/apache/bcel/util/CodeHTML.java b/src/main/java/org/apache/bcel/util/CodeHTML.java index 81b33f3..3160492 100644 --- a/src/main/java/org/apache/bcel/util/CodeHTML.java +++ b/src/main/java/org/apache/bcel/util/CodeHTML.java @@ -44,21 +44,21 @@ import org.apache.bcel.classfile.Utility; */ final class CodeHTML { - private final String class_name; // name of current class + private final String className; // name of current class // private Method[] methods; // Methods to print private final PrintWriter file; // file to write to - private BitSet goto_set; - private final ConstantPool constant_pool; - private final ConstantHTML constant_html; + private BitSet gotoSet; + private final ConstantPool constantPool; + private final ConstantHTML constantHtml; private static boolean wide = false; CodeHTML(final String dir, final String class_name, final Method[] methods, final ConstantPool constant_pool, final ConstantHTML constant_html) throws IOException { - this.class_name = class_name; + this.className = class_name; // this.methods = methods; - this.constant_pool = constant_pool; - this.constant_html = constant_html; + this.constantPool = constant_pool; + this.constantHtml = constant_html; file = new PrintWriter(new FileOutputStream(dir + class_name + "_code.html")); file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\">"); for (int i = 0; i < methods.length; i++) { @@ -227,19 +227,19 @@ final class CodeHTML { case Const.PUTFIELD: case Const.PUTSTATIC: index = bytes.readShort(); - final ConstantFieldref c1 = (ConstantFieldref) constant_pool.getConstant(index, + final ConstantFieldref c1 = (ConstantFieldref) constantPool.getConstant(index, Const.CONSTANT_Fieldref); class_index = c1.getClassIndex(); - name = constant_pool.getConstantString(class_index, Const.CONSTANT_Class); + name = constantPool.getConstantString(class_index, Const.CONSTANT_Class); name = Utility.compactClassName(name, false); index = c1.getNameAndTypeIndex(); - final String field_name = constant_pool.constantToString(index, Const.CONSTANT_NameAndType); - if (name.equals(class_name)) { // Local field - buf.append("<A HREF=\"").append(class_name).append("_methods.html#field") + final String field_name = constantPool.constantToString(index, Const.CONSTANT_NameAndType); + if (name.equals(className)) { // Local field + buf.append("<A HREF=\"").append(className).append("_methods.html#field") .append(field_name).append("\" TARGET=Methods>").append(field_name) .append("</A>\n"); } else { - buf.append(constant_html.referenceConstant(class_index)).append(".").append( + buf.append(constantHtml.referenceConstant(class_index)).append(".").append( field_name); } break; @@ -249,7 +249,7 @@ final class CodeHTML { case Const.INSTANCEOF: case Const.NEW: index = bytes.readShort(); - buf.append(constant_html.referenceConstant(index)); + buf.append(constantHtml.referenceConstant(index)); break; /* Operands are references to methods in constant pool */ @@ -265,7 +265,7 @@ final class CodeHTML { bytes.readUnsignedByte(); // Reserved // int nargs = bytes.readUnsignedByte(); // Redundant // int reserved = bytes.readUnsignedByte(); // Reserved - final ConstantInterfaceMethodref c = (ConstantInterfaceMethodref) constant_pool + final ConstantInterfaceMethodref c = (ConstantInterfaceMethodref) constantPool .getConstant(m_index, Const.CONSTANT_InterfaceMethodref); class_index = c.getClassIndex(); index = c.getNameAndTypeIndex(); @@ -273,7 +273,7 @@ final class CodeHTML { } else if (opcode == Const.INVOKEDYNAMIC) { // Special treatment needed bytes.readUnsignedByte(); // Reserved bytes.readUnsignedByte(); // Reserved - final ConstantInvokeDynamic c = (ConstantInvokeDynamic) constant_pool + final ConstantInvokeDynamic c = (ConstantInvokeDynamic) constantPool .getConstant(m_index, Const.CONSTANT_InvokeDynamic); index = c.getNameAndTypeIndex(); name = "#" + c.getBootstrapMethodAttrIndex(); @@ -281,21 +281,21 @@ final class CodeHTML { // UNDONE: Java8 now allows INVOKESPECIAL and INVOKESTATIC to // reference EITHER a Methodref OR an InterfaceMethodref. // Not sure if that affects this code or not. (markro) - final ConstantMethodref c = (ConstantMethodref) constant_pool.getConstant(m_index, + final ConstantMethodref c = (ConstantMethodref) constantPool.getConstant(m_index, Const.CONSTANT_Methodref); class_index = c.getClassIndex(); index = c.getNameAndTypeIndex(); name = Class2HTML.referenceClass(class_index); } - str = Class2HTML.toHTML(constant_pool.constantToString(constant_pool.getConstant( + str = Class2HTML.toHTML(constantPool.constantToString(constantPool.getConstant( index, Const.CONSTANT_NameAndType))); // Get signature, i.e., types - final ConstantNameAndType c2 = (ConstantNameAndType) constant_pool.getConstant(index, + final ConstantNameAndType c2 = (ConstantNameAndType) constantPool.getConstant(index, Const.CONSTANT_NameAndType); - signature = constant_pool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8); + signature = constantPool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8); final String[] args = Utility.methodSignatureArgumentTypes(signature, false); final String type = Utility.methodSignatureReturnType(signature, false); - buf.append(name).append(".<A HREF=\"").append(class_name).append("_cp.html#cp") + buf.append(name).append(".<A HREF=\"").append(className).append("_cp.html#cp") .append(m_index).append("\" TARGET=ConstantPool>").append(str).append( "</A>").append("("); // List arguments @@ -313,30 +313,30 @@ final class CodeHTML { case Const.LDC_W: case Const.LDC2_W: index = bytes.readShort(); - buf.append("<A HREF=\"").append(class_name).append("_cp.html#cp").append(index) + buf.append("<A HREF=\"").append(className).append("_cp.html#cp").append(index) .append("\" TARGET=\"ConstantPool\">").append( - Class2HTML.toHTML(constant_pool.constantToString(index, - constant_pool.getConstant(index).getTag()))).append("</a>"); + Class2HTML.toHTML(constantPool.constantToString(index, + constantPool.getConstant(index).getTag()))).append("</a>"); break; case Const.LDC: index = bytes.readUnsignedByte(); - buf.append("<A HREF=\"").append(class_name).append("_cp.html#cp").append(index) + buf.append("<A HREF=\"").append(className).append("_cp.html#cp").append(index) .append("\" TARGET=\"ConstantPool\">").append( - Class2HTML.toHTML(constant_pool.constantToString(index, - constant_pool.getConstant(index).getTag()))).append("</a>"); + Class2HTML.toHTML(constantPool.constantToString(index, + constantPool.getConstant(index).getTag()))).append("</a>"); break; /* Array of references. */ case Const.ANEWARRAY: index = bytes.readShort(); - buf.append(constant_html.referenceConstant(index)); + buf.append(constantHtml.referenceConstant(index)); break; /* Multidimensional array of references. */ case Const.MULTIANEWARRAY: index = bytes.readShort(); final int dimensions = bytes.readByte(); - buf.append(constant_html.referenceConstant(index)).append(":").append(dimensions) + buf.append(constantHtml.referenceConstant(index)).append(":").append(dimensions) .append("-dimensional"); break; /* Increment local variable. @@ -383,7 +383,7 @@ final class CodeHTML { */ private void findGotos( final ByteSequence bytes, final Code code ) throws IOException { int index; - goto_set = new BitSet(bytes.available()); + gotoSet = new BitSet(bytes.available()); int opcode; /* First get Code attribute from method and the exceptions handled * (try .. catch) in this method. We only need the line number here. @@ -391,9 +391,9 @@ final class CodeHTML { if (code != null) { final CodeException[] ce = code.getExceptionTable(); for (final CodeException cex : ce) { - goto_set.set(cex.getStartPC()); - goto_set.set(cex.getEndPC()); - goto_set.set(cex.getHandlerPC()); + gotoSet.set(cex.getStartPC()); + gotoSet.set(cex.getEndPC()); + gotoSet.set(cex.getHandlerPC()); } // Look for local variables and their range final Attribute[] attributes = code.getAttributes(); @@ -404,8 +404,8 @@ final class CodeHTML { for (final LocalVariable var : vars) { final int start = var.getStartPC(); final int end = start + var.getLength(); - goto_set.set(start); - goto_set.set(end); + gotoSet.set(start); + gotoSet.set(end); } break; } @@ -433,21 +433,21 @@ final class CodeHTML { final int high = bytes.readInt(); offset = bytes.getIndex() - 12 - no_pad_bytes - 1; default_offset += offset; - goto_set.set(default_offset); + gotoSet.set(default_offset); for (int j = 0; j < (high - low + 1); j++) { index = offset + bytes.readInt(); - goto_set.set(index); + gotoSet.set(index); } } else { // LOOKUPSWITCH final int npairs = bytes.readInt(); offset = bytes.getIndex() - 8 - no_pad_bytes - 1; default_offset += offset; - goto_set.set(default_offset); + gotoSet.set(default_offset); for (int j = 0; j < npairs; j++) { // int match = bytes.readInt(); bytes.readInt(); index = offset + bytes.readInt(); - goto_set.set(index); + gotoSet.set(index); } } break; @@ -471,13 +471,13 @@ final class CodeHTML { case Const.JSR: //bytes.readByte(); // Skip already read byte index = bytes.getIndex() + bytes.readShort() - 1; - goto_set.set(index); + gotoSet.set(index); break; case Const.GOTO_W: case Const.JSR_W: //bytes.readByte(); // Skip already read byte index = bytes.getIndex() + bytes.readInt() - 1; - goto_set.set(index); + gotoSet.set(index); break; default: bytes.unreadByte(); @@ -507,7 +507,7 @@ final class CodeHTML { final Attribute[] attributes = method.getAttributes(); file.print("<P><B><FONT COLOR=\"#FF0000\">" + access + "</FONT> " + "<A NAME=method" + method_number + ">" + Class2HTML.referenceType(type) + "</A> <A HREF=\"" - + class_name + "_methods.html#method" + method_number + "\" TARGET=Methods>" + + className + "_methods.html#method" + method_number + "\" TARGET=Methods>" + html_name + "</A>("); for (int i = 0; i < args.length; i++) { file.print(Class2HTML.referenceType(args[i])); @@ -523,7 +523,7 @@ final class CodeHTML { for (int i = 0; i < attributes.length; i++) { byte tag = attributes[i].getTag(); if (tag != Const.ATTR_UNKNOWN) { - file.print("<LI><A HREF=\"" + class_name + "_attributes.html#method" + file.print("<LI><A HREF=\"" + className + "_attributes.html#method" + method_number + "@" + i + "\" TARGET=Attributes>" + Const.getAttributeName(tag) + "</A></LI>\n"); } else { @@ -536,7 +536,7 @@ final class CodeHTML { file.print("<UL>"); for (int j = 0; j < attributes2.length; j++) { tag = attributes2[j].getTag(); - file.print("<LI><A HREF=\"" + class_name + "_attributes.html#" + "method" + file.print("<LI><A HREF=\"" + className + "_attributes.html#" + "method" + method_number + "@" + i + "@" + j + "\" TARGET=Attributes>" + Const.getAttributeName(tag) + "</A></LI>\n"); } @@ -546,7 +546,7 @@ final class CodeHTML { file.println("</UL>"); } if (code != null) { // No code, an abstract method, e.g. - //System.out.println(name + "\n" + Utility.codeToString(code, constant_pool, 0, -1)); + //System.out.println(name + "\n" + Utility.codeToString(code, constantPool, 0, -1)); // Print the byte code try (ByteSequence stream = new ByteSequence(code)) { stream.mark(stream.available()); @@ -562,7 +562,7 @@ final class CodeHTML { * Set an anchor mark if this line is targetted by a goto, jsr, etc. Defining an anchor for every * line is very inefficient! */ - if (goto_set.get(offset)) { + if (gotoSet.get(offset)) { anchor = "<A NAME=code" + method_number + "@" + offset + "></A>"; } String anchor2; diff --git a/src/main/java/org/apache/bcel/util/ConstantHTML.java b/src/main/java/org/apache/bcel/util/ConstantHTML.java index b9564a2..2d8f1bf 100644 --- a/src/main/java/org/apache/bcel/util/ConstantHTML.java +++ b/src/main/java/org/apache/bcel/util/ConstantHTML.java @@ -40,25 +40,25 @@ import org.apache.bcel.classfile.Utility; */ final class ConstantHTML { - private final String class_name; // name of current class - private final String class_package; // name of package - private final ConstantPool constant_pool; // reference to constant pool + private final String className; // name of current class + private final String classPackage; // name of package + private final ConstantPool constantPool; // reference to constant pool private final PrintWriter file; // file to write to - private final String[] constant_ref; // String to return for cp[i] + private final String[] constantRef; // String to return for cp[i] private final Constant[] constants; // The constants in the cp private final Method[] methods; ConstantHTML(final String dir, final String class_name, final String class_package, final Method[] methods, final ConstantPool constant_pool) throws IOException { - this.class_name = class_name; - this.class_package = class_package; - this.constant_pool = constant_pool; + this.className = class_name; + this.classPackage = class_package; + this.constantPool = constant_pool; this.methods = methods; constants = constant_pool.getConstantPool(); file = new PrintWriter(new FileOutputStream(dir + class_name + "_cp.html")); - constant_ref = new String[constants.length]; - constant_ref[0] = "<unknown>"; + constantRef = new String[constants.length]; + constantRef[0] = "<unknown>"; file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>"); // Loop through constants, constants[0] is reserved for (int i = 1; i < constants.length; i++) { @@ -78,7 +78,7 @@ final class ConstantHTML { String referenceConstant( final int index ) { - return constant_ref[index]; + return constantRef[index]; } @@ -97,29 +97,29 @@ final class ConstantHTML { case Const.CONSTANT_Methodref: // Get class_index and name_and_type_index, depending on type if (tag == Const.CONSTANT_Methodref) { - final ConstantMethodref c = (ConstantMethodref) constant_pool.getConstant(index, + final ConstantMethodref c = (ConstantMethodref) constantPool.getConstant(index, Const.CONSTANT_Methodref); class_index = c.getClassIndex(); name_index = c.getNameAndTypeIndex(); } else { - final ConstantInterfaceMethodref c1 = (ConstantInterfaceMethodref) constant_pool + final ConstantInterfaceMethodref c1 = (ConstantInterfaceMethodref) constantPool .getConstant(index, Const.CONSTANT_InterfaceMethodref); class_index = c1.getClassIndex(); name_index = c1.getNameAndTypeIndex(); } // Get method name and its class - final String method_name = constant_pool.constantToString(name_index, + final String method_name = constantPool.constantToString(name_index, Const.CONSTANT_NameAndType); final String html_method_name = Class2HTML.toHTML(method_name); // Partially compacted class name, i.e., / -> . - final String method_class = constant_pool.constantToString(class_index, Const.CONSTANT_Class); + final String method_class = constantPool.constantToString(class_index, Const.CONSTANT_Class); String short_method_class = Utility.compactClassName(method_class); // I.e., remove java.lang. - short_method_class = Utility.compactClassName(short_method_class, class_package + short_method_class = Utility.compactClassName(short_method_class, classPackage + ".", true); // Remove class package prefix // Get method signature - final ConstantNameAndType c2 = (ConstantNameAndType) constant_pool.getConstant( + final ConstantNameAndType c2 = (ConstantNameAndType) constantPool.getConstant( name_index, Const.CONSTANT_NameAndType); - final String signature = constant_pool.constantToString(c2.getSignatureIndex(), + final String signature = constantPool.constantToString(c2.getSignatureIndex(), Const.CONSTANT_Utf8); // Get array of strings containing the argument types final String[] args = Utility.methodSignatureArgumentTypes(signature, false); @@ -135,17 +135,17 @@ final class ConstantHTML { } buf.append(")"); final String arg_types = buf.toString(); - if (method_class.equals(class_name)) { - ref = "<A HREF=\"" + class_name + "_code.html#method" + if (method_class.equals(className)) { + ref = "<A HREF=\"" + className + "_code.html#method" + getMethodNumber(method_name + signature) + "\" TARGET=Code>" + html_method_name + "</A>"; } else { ref = "<A HREF=\"" + method_class + ".html" + "\" TARGET=_top>" + short_method_class + "</A>." + html_method_name; } - constant_ref[index] = ret_type + " <A HREF=\"" + class_name + "_cp.html#cp" + constantRef[index] = ret_type + " <A HREF=\"" + className + "_cp.html#cp" + class_index + "\" TARGET=Constants>" + short_method_class - + "</A>.<A HREF=\"" + class_name + "_cp.html#cp" + index + + "</A>.<A HREF=\"" + className + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + html_method_name + "</A> " + arg_types; file.println("<P><TT>" + ret_type + " " + ref + arg_types + " </TT>\n<UL>" + "<LI><A HREF=\"#cp" + class_index @@ -154,27 +154,27 @@ final class ConstantHTML { break; case Const.CONSTANT_Fieldref: // Get class_index and name_and_type_index - final ConstantFieldref c3 = (ConstantFieldref) constant_pool.getConstant(index, + final ConstantFieldref c3 = (ConstantFieldref) constantPool.getConstant(index, Const.CONSTANT_Fieldref); class_index = c3.getClassIndex(); name_index = c3.getNameAndTypeIndex(); // Get method name and its class (compacted) - final String field_class = constant_pool.constantToString(class_index, Const.CONSTANT_Class); + final String field_class = constantPool.constantToString(class_index, Const.CONSTANT_Class); String short_field_class = Utility.compactClassName(field_class); // I.e., remove java.lang. short_field_class = Utility.compactClassName(short_field_class, - class_package + ".", true); // Remove class package prefix - final String field_name = constant_pool + classPackage + ".", true); // Remove class package prefix + final String field_name = constantPool .constantToString(name_index, Const.CONSTANT_NameAndType); - if (field_class.equals(class_name)) { + if (field_class.equals(className)) { ref = "<A HREF=\"" + field_class + "_methods.html#field" + field_name + "\" TARGET=Methods>" + field_name + "</A>"; } else { ref = "<A HREF=\"" + field_class + ".html\" TARGET=_top>" + short_field_class + "</A>." + field_name + "\n"; } - constant_ref[index] = "<A HREF=\"" + class_name + "_cp.html#cp" + class_index + constantRef[index] = "<A HREF=\"" + className + "_cp.html#cp" + class_index + "\" TARGET=Constants>" + short_field_class + "</A>.<A HREF=\"" - + class_name + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + + className + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + field_name + "</A>"; file.println("<P><TT>" + ref + "</TT><BR>\n" + "<UL>" + "<LI><A HREF=\"#cp" + class_index + "\">Class(" + class_index + ")</A><BR>\n" @@ -182,40 +182,40 @@ final class ConstantHTML { + ")</A></UL>"); break; case Const.CONSTANT_Class: - final ConstantClass c4 = (ConstantClass) constant_pool.getConstant(index, Const.CONSTANT_Class); + final ConstantClass c4 = (ConstantClass) constantPool.getConstant(index, Const.CONSTANT_Class); name_index = c4.getNameIndex(); - final String class_name2 = constant_pool.constantToString(index, tag); // / -> . + final String class_name2 = constantPool.constantToString(index, tag); // / -> . String short_class_name = Utility.compactClassName(class_name2); // I.e., remove java.lang. - short_class_name = Utility.compactClassName(short_class_name, class_package + ".", + short_class_name = Utility.compactClassName(short_class_name, classPackage + ".", true); // Remove class package prefix ref = "<A HREF=\"" + class_name2 + ".html\" TARGET=_top>" + short_class_name + "</A>"; - constant_ref[index] = "<A HREF=\"" + class_name + "_cp.html#cp" + index + constantRef[index] = "<A HREF=\"" + className + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + short_class_name + "</A>"; file.println("<P><TT>" + ref + "</TT><UL>" + "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index + ")</A></UL>\n"); break; case Const.CONSTANT_String: - final ConstantString c5 = (ConstantString) constant_pool.getConstant(index, + final ConstantString c5 = (ConstantString) constantPool.getConstant(index, Const.CONSTANT_String); name_index = c5.getStringIndex(); - final String str = Class2HTML.toHTML(constant_pool.constantToString(index, tag)); + final String str = Class2HTML.toHTML(constantPool.constantToString(index, tag)); file.println("<P><TT>" + str + "</TT><UL>" + "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index + ")</A></UL>\n"); break; case Const.CONSTANT_NameAndType: - final ConstantNameAndType c6 = (ConstantNameAndType) constant_pool.getConstant(index, + final ConstantNameAndType c6 = (ConstantNameAndType) constantPool.getConstant(index, Const.CONSTANT_NameAndType); name_index = c6.getNameIndex(); final int signature_index = c6.getSignatureIndex(); file.println("<P><TT>" - + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + + Class2HTML.toHTML(constantPool.constantToString(index, tag)) + "</TT><UL>" + "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index + ")</A>\n" + "<LI><A HREF=\"#cp" + signature_index + "\">Signature index(" + signature_index + ")</A></UL>\n"); break; default: - file.println("<P><TT>" + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + "</TT>\n"); + file.println("<P><TT>" + Class2HTML.toHTML(constantPool.constantToString(index, tag)) + "</TT>\n"); } // switch } diff --git a/src/main/java/org/apache/bcel/util/InstructionFinder.java b/src/main/java/org/apache/bcel/util/InstructionFinder.java index 2b3214f..f93cbe3 100644 --- a/src/main/java/org/apache/bcel/util/InstructionFinder.java +++ b/src/main/java/org/apache/bcel/util/InstructionFinder.java @@ -69,7 +69,7 @@ public class InstructionFinder { private static final int NO_OPCODES = 256; // Potential number, some are not used private static final Map<String, String> map = new HashMap<>(); private final InstructionList il; - private String il_string; // instruction list as string + private String ilString; // instruction list as string private InstructionHandle[] handles; // map instruction @@ -96,7 +96,7 @@ public class InstructionFinder { for (int i = 0; i < size; i++) { buf[i] = makeChar(handles[i].getInstruction().getOpcode()); } - il_string = new String(buf); + ilString = new String(buf); } @@ -217,8 +217,8 @@ public class InstructionFinder { } final Pattern regex = Pattern.compile(search); final List<InstructionHandle[]> matches = new ArrayList<>(); - final Matcher matcher = regex.matcher(il_string); - while (start < il_string.length() && matcher.find(start)) { + final Matcher matcher = regex.matcher(ilString); + while (start < ilString.length() && matcher.find(start)) { final int startExpr = matcher.start(); final int endExpr = matcher.end(); final int lenExpr = endExpr - startExpr; diff --git a/src/main/java/org/apache/bcel/util/MemorySensitiveClassPathRepository.java b/src/main/java/org/apache/bcel/util/MemorySensitiveClassPathRepository.java index 322e935..cb49dca 100644 --- a/src/main/java/org/apache/bcel/util/MemorySensitiveClassPathRepository.java +++ b/src/main/java/org/apache/bcel/util/MemorySensitiveClassPathRepository.java @@ -32,7 +32,7 @@ import org.apache.bcel.classfile.JavaClass; */ public class MemorySensitiveClassPathRepository extends AbstractClassPathRepository { - private final Map<String, SoftReference<JavaClass>> _loadedClasses = new HashMap<>(); // CLASSNAME X JAVACLASS + private final Map<String, SoftReference<JavaClass>> loadedClasses = new HashMap<>(); // CLASSNAME X JAVACLASS public MemorySensitiveClassPathRepository(final ClassPath path) { super(path); @@ -44,7 +44,7 @@ public class MemorySensitiveClassPathRepository extends AbstractClassPathReposit @Override public void storeClass(final JavaClass clazz) { // Not calling super.storeClass because this subclass maintains the mapping. - _loadedClasses.put(clazz.getClassName(), new SoftReference<>(clazz)); + loadedClasses.put(clazz.getClassName(), new SoftReference<>(clazz)); clazz.setRepository(this); } @@ -53,7 +53,7 @@ public class MemorySensitiveClassPathRepository extends AbstractClassPathReposit */ @Override public void removeClass(final JavaClass clazz) { - _loadedClasses.remove(clazz.getClassName()); + loadedClasses.remove(clazz.getClassName()); } /** @@ -61,7 +61,7 @@ public class MemorySensitiveClassPathRepository extends AbstractClassPathReposit */ @Override public JavaClass findClass(final String className) { - final SoftReference<JavaClass> ref = _loadedClasses.get(className); + final SoftReference<JavaClass> ref = loadedClasses.get(className); if (ref == null) { return null; } @@ -73,6 +73,6 @@ public class MemorySensitiveClassPathRepository extends AbstractClassPathReposit */ @Override public void clear() { - _loadedClasses.clear(); + loadedClasses.clear(); } } diff --git a/src/main/java/org/apache/bcel/util/MethodHTML.java b/src/main/java/org/apache/bcel/util/MethodHTML.java index 5ec16cd..cff316c 100644 --- a/src/main/java/org/apache/bcel/util/MethodHTML.java +++ b/src/main/java/org/apache/bcel/util/MethodHTML.java @@ -37,17 +37,17 @@ import org.apache.bcel.classfile.Utility; */ final class MethodHTML { - private final String class_name; // name of current class + private final String className; // name of current class private final PrintWriter file; // file to write to - private final ConstantHTML constant_html; + private final ConstantHTML constantHtml; private final AttributeHTML attribute_html; MethodHTML(final String dir, final String class_name, final Method[] methods, final Field[] fields, final ConstantHTML constant_html, final AttributeHTML attribute_html) throws IOException { - this.class_name = class_name; + this.className = class_name; this.attribute_html = attribute_html; - this.constant_html = constant_html; + this.constantHtml = constant_html; file = new PrintWriter(new FileOutputStream(dir + class_name + "_methods.html")); file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>"); file.println("<TR><TH ALIGN=LEFT>Access flags</TH><TH ALIGN=LEFT>Type</TH>" @@ -91,7 +91,7 @@ final class MethodHTML { if (attributes[i].getTag() == Const.ATTR_CONSTANT_VALUE) { // Default value final String str = ((ConstantValue) attributes[i]).toString(); // Reference attribute in _attributes.html - file.print("<TD>= <A HREF=\"" + class_name + "_attributes.html#" + name + "@" + i + file.print("<TD>= <A HREF=\"" + className + "_attributes.html#" + name + "@" + i + "\" TARGET=\"Attributes\">" + str + "</TD>\n"); break; } @@ -121,7 +121,7 @@ final class MethodHTML { html_name = Class2HTML.toHTML(name); file.print("<TR VALIGN=TOP><TD><FONT COLOR=\"#FF0000\"><A NAME=method" + method_number + ">" + access + "</A></FONT></TD>"); - file.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD>" + "<A HREF=" + class_name + file.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD>" + "<A HREF=" + className + "_code.html#method" + method_number + " TARGET=Code>" + html_name + "</A></TD>\n<TD>("); for (int i = 0; i < args.length; i++) { @@ -140,7 +140,7 @@ final class MethodHTML { file.print("<TR VALIGN=TOP><TD COLSPAN=2></TD><TH ALIGN=LEFT>throws</TH><TD>"); final int[] exceptions = ((ExceptionTable) attributes[i]).getExceptionIndexTable(); for (int j = 0; j < exceptions.length; j++) { - file.print(constant_html.referenceConstant(exceptions[j])); + file.print(constantHtml.referenceConstant(exceptions[j])); if (j < exceptions.length - 1) { file.print(", "); } diff --git a/src/main/java/org/apache/bcel/verifier/VerifyDialog.java b/src/main/java/org/apache/bcel/verifier/VerifyDialog.java index ca67562..d2e198b 100644 --- a/src/main/java/org/apache/bcel/verifier/VerifyDialog.java +++ b/src/main/java/org/apache/bcel/verifier/VerifyDialog.java @@ -64,7 +64,7 @@ public class VerifyDialog extends javax.swing.JDialog { * instances so the JVM can be exited afer every Dialog had been * closed. */ - private static int classes_to_verify; + private static int classesToVerify; /** Machine-generated. */ class IvjEventHandler implements java.awt.event.ActionListener { @@ -472,7 +472,7 @@ public class VerifyDialog extends javax.swing.JDialog { * @param args java.lang.String[] fully qualified names of classes to verify. */ public static void main( final java.lang.String[] args ) { - classes_to_verify = args.length; + classesToVerify = args.length; for (final String arg : args) { try { VerifyDialog aVerifyDialog; @@ -482,8 +482,8 @@ public class VerifyDialog extends javax.swing.JDialog { @Override public void windowClosing( final java.awt.event.WindowEvent e ) { - classes_to_verify--; - if (classes_to_verify == 0) { + classesToVerify--; + if (classesToVerify == 0) { System.exit(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 cbe91b9..7adea37 100644 --- a/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java +++ b/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java @@ -119,7 +119,7 @@ public final class Pass3aVerifier extends PassVerifier{ * This is the index in the array returned * by JavaClass.getMethods(). */ - private final int method_no; + private final int methodNo; /** * The one and only InstructionList object used by an instance of this class. @@ -136,7 +136,7 @@ public final class Pass3aVerifier extends PassVerifier{ /** Should only be instantiated by a Verifier. */ public Pass3aVerifier(final Verifier owner, final int method_no) { myOwner = owner; - this.method_no = method_no; + this.methodNo = method_no; } /** @@ -164,10 +164,10 @@ public final class Pass3aVerifier extends PassVerifier{ // and satisfies static constraints of Pass 2. final JavaClass jc = Repository.lookupClass(myOwner.getClassName()); final Method[] methods = jc.getMethods(); - if (method_no >= methods.length) { + if (methodNo >= methods.length) { throw new InvalidMethodException("METHOD DOES NOT EXIST!"); } - final Method method = methods[method_no]; + final Method method = methods[methodNo]; code = method.getCode(); // No Code? Nothing to verify! @@ -463,7 +463,7 @@ public final class Pass3aVerifier extends PassVerifier{ /** Returns the method number as supplied when instantiating. */ public int getMethodNo() { - return method_no; + return methodNo; } /** @@ -485,7 +485,7 @@ public final class Pass3aVerifier extends PassVerifier{ */ private int max_locals() { try { - return Repository.lookupClass(myOwner.getClassName()).getMethods()[method_no].getCode().getMaxLocals(); + return Repository.lookupClass(myOwner.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); @@ -1075,7 +1075,7 @@ public final class Pass3aVerifier extends PassVerifier{ constraintViolated(o, "Referenced field '"+f+"' is not static which it should be."); } - final String meth_name = Repository.lookupClass(myOwner.getClassName()).getMethods()[method_no].getName(); + final String meth_name = Repository.lookupClass(myOwner.getClassName()).getMethods()[methodNo].getName(); // If it's an interface, it can be set only in <clinit>. if ((!(jc.isClass())) && (!(meth_name.equals(Const.STATIC_INITIALIZER_NAME)))) { diff --git a/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java b/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java index 291e161..73b6080 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandler.java @@ -29,28 +29,28 @@ import org.apache.bcel.generic.ObjectType; */ public class ExceptionHandler{ /** The type of the exception to catch. NULL means ANY. */ - private final ObjectType catchtype; + private final ObjectType catchType; /** The InstructionHandle where the handling begins. */ - private final InstructionHandle handlerpc; + private final InstructionHandle handlerPc; /** Leave instance creation to JustIce. */ ExceptionHandler(final ObjectType catch_type, final InstructionHandle handler_pc) { - catchtype = catch_type; - handlerpc = handler_pc; + catchType = catch_type; + handlerPc = handler_pc; } /** * Returns the type of the exception that's handled. <B>'null' means 'ANY'.</B> */ public ObjectType getExceptionType() { - return catchtype; + return catchType; } /** * Returns the InstructionHandle where the handler starts off. */ public InstructionHandle getHandlerStart() { - return handlerpc; + return handlerPc; } } diff --git a/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java b/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java index ef11599..68529f2 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java @@ -36,22 +36,22 @@ public class ExceptionHandlers{ * The ExceptionHandler instances. * Key: InstructionHandle objects, Values: HashSet<ExceptionHandler> instances. */ - private final Map<InstructionHandle, Set<ExceptionHandler>> exceptionhandlers; + private final Map<InstructionHandle, Set<ExceptionHandler>> exceptionHandlers; /** * Constructor. Creates a new ExceptionHandlers instance. */ public ExceptionHandlers(final MethodGen mg) { - exceptionhandlers = new HashMap<>(); + exceptionHandlers = new HashMap<>(); final CodeExceptionGen[] cegs = mg.getExceptionHandlers(); for (final CodeExceptionGen ceg : cegs) { final ExceptionHandler eh = new ExceptionHandler(ceg.getCatchType(), ceg.getHandlerPC()); for (InstructionHandle ih=ceg.getStartPC(); ih != ceg.getEndPC().getNext(); ih=ih.getNext()) { Set<ExceptionHandler> hs; - hs = exceptionhandlers.get(ih); + hs = exceptionHandlers.get(ih); if (hs == null) { hs = new HashSet<>(); - exceptionhandlers.put(ih, hs); + exceptionHandlers.put(ih, hs); } hs.add(eh); } @@ -63,7 +63,7 @@ public class ExceptionHandlers{ * handlers that protect the instruction ih. */ public ExceptionHandler[] getExceptionHandlers(final InstructionHandle ih) { - final Set<ExceptionHandler> hsSet = exceptionhandlers.get(ih); + final Set<ExceptionHandler> hsSet = exceptionHandlers.get(ih); if (hsSet == null) { return new ExceptionHandler[0]; } 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 50d2ed9..3e4327a 100644 --- a/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java +++ b/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java @@ -148,7 +148,7 @@ public final class Pass3bVerifier extends PassVerifier{ private final Verifier myOwner; /** The method number to verify. */ - private final int method_no; + private final int methodNo; /** * This class should only be instantiated by a Verifier. @@ -157,7 +157,7 @@ public final class Pass3bVerifier extends PassVerifier{ */ public Pass3bVerifier(final Verifier owner, final int method_no) { myOwner = owner; - this.method_no = method_no; + this.methodNo = method_no; } /** @@ -359,7 +359,7 @@ public final class Pass3bVerifier extends PassVerifier{ */ @Override public VerificationResult do_verify() { - if (! myOwner.doPass3a(method_no).equals(VerificationResult.VR_OK)) { + if (! myOwner.doPass3a(methodNo).equals(VerificationResult.VR_OK)) { return VerificationResult.VR_NOTYET; } @@ -381,11 +381,11 @@ public final class Pass3bVerifier extends PassVerifier{ final ExecutionVisitor ev = new ExecutionVisitor(); ev.setConstantPoolGen(constantPoolGen); - final Method[] methods = jc.getMethods(); // Method no "method_no" exists, we ran Pass3a before on it! + final Method[] methods = jc.getMethods(); // Method no "methodNo" exists, we ran Pass3a before on it! try{ - final MethodGen mg = new MethodGen(methods[method_no], myOwner.getClassName(), constantPoolGen); + final MethodGen mg = new MethodGen(methods[methodNo], myOwner.getClassName(), constantPoolGen); icv.setMethodGen(mg); @@ -423,7 +423,7 @@ public final class Pass3bVerifier extends PassVerifier{ } } catch (final VerifierConstraintViolatedException ce) { - ce.extendMessage("Constraint violated in method '"+methods[method_no]+"':\n",""); + ce.extendMessage("Constraint violated in method '"+methods[methodNo]+"':\n",""); return new VerificationResult(VerificationResult.VERIFIED_REJECTED, ce.getMessage()); } catch (final RuntimeException re) { @@ -434,13 +434,13 @@ public final class Pass3bVerifier extends PassVerifier{ re.printStackTrace(pw); throw new AssertionViolatedException("Some RuntimeException occured while verify()ing class '"+jc.getClassName()+ - "', method '"+methods[method_no]+"'. Original RuntimeException's stack trace:\n---\n"+sw+"---\n", re); + "', method '"+methods[methodNo]+"'. Original RuntimeException's stack trace:\n---\n"+sw+"---\n", re); } return VerificationResult.VR_OK; } /** Returns the method number as supplied when instantiating. */ public int getMethodNo() { - return method_no; + return methodNo; } }