Package edu.umd.cs.findbugs.visitclass
Class PreorderVisitor
- java.lang.Object
-
- edu.umd.cs.findbugs.visitclass.BetterVisitor
-
- edu.umd.cs.findbugs.visitclass.PreorderVisitor
-
- All Implemented Interfaces:
org.apache.bcel.classfile.Visitor
- Direct Known Subclasses:
AnnotationVisitor,CallToUnconditionalThrower,CheckImmutableAnnotation,ComparatorIdiom,ConfusedInheritance,DontCatchIllegalMonitorStateException,DroppedException,DuplicateBranches,FindBugsSummaryStats,Methods,Naming,PreorderDetector,RedundantInterfaces,ResolveAllReferences,TrainLongInstantfParams
public class PreorderVisitor extends BetterVisitor
Interface to make the use of a visitor pattern programming style possible. I.e. a class that implements this interface can traverse the contents of a Java class just by calling the `accept' method which all classes have.
Implemented by wish of Boris Bokowski.
If don't like it, blame him. If you do like it thank me 8-)
- Version:
- 970819
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.regex.PatternargumentSignatureprivate java.lang.StringclassNameprivate org.apache.bcel.classfile.Codecodeprivate org.apache.bcel.classfile.ConstantPoolconstantPoolprivate java.lang.StringdottedClassNameprivate java.lang.StringdottedFieldSigprivate java.lang.StringdottedMethodSigprivate java.lang.StringdottedSuperclassNameprivate org.apache.bcel.classfile.Fieldfieldprivate booleanfieldIsStaticprivate java.lang.StringfieldNameprivate java.lang.StringfieldSigprivate java.lang.StringfullyQualifiedFieldNameprivate java.lang.StringfullyQualifiedMethodNameprivate org.apache.bcel.classfile.Methodmethodprivate java.lang.StringmethodNameprivate java.lang.StringmethodSigprivate java.lang.StringpackageNameprivate java.lang.StringsourceFileprivate java.lang.StringsuperclassNameprivate org.apache.bcel.classfile.JavaClassthisClassprivate ClassInfothisClassInfoprivate FieldInfothisFieldInfoprivate MethodInfothisMethodInfoprivate booleanvisitingFieldprivate booleanvisitingMethod(package private) booleanvisitMethodsInCallOrder
-
Constructor Summary
Constructors Constructor Description PreorderVisitor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanamVisitingMainMethod()protected intasUnsignedByte(byte b)private voiddoVisitField(org.apache.bcel.classfile.Field field)voiddoVisitMethod(org.apache.bcel.classfile.Method method)ClassDescriptorgetClassDescriptor()java.lang.StringgetClassName()Get the slash-formatted class name for the current or most recently visited classorg.apache.bcel.classfile.CodegetCode()Return the current Code attribute; assuming one is being visitedorg.apache.bcel.classfile.ConstantPoolgetConstantPool()Get the constant pool for the current or most recently visited classjava.lang.StringgetDottedClassName()Get the dotted class name for the current or most recently visited classjava.lang.StringgetDottedFieldSig()Deprecated.java.lang.StringgetDottedMethodSig()If currently visiting a method, get the method's dotted method signaturejava.lang.StringgetDottedSuperclassName()Get the dotted superclass name for the current or most recently visited classorg.apache.bcel.classfile.FieldgetField()If currently visiting a field, get the field's Field objectFieldDescriptorgetFieldDescriptor()booleangetFieldIsStatic()If currently visiting a field, return whether or not the field is staticjava.lang.StringgetFieldName()If currently visiting a field, get the field's namejava.lang.StringgetFieldSig()If currently visiting a field, get the field's slash-formatted signaturejava.lang.StringgetFullyQualifiedFieldName()If currently visiting a field, get the field's fully qualified namejava.lang.StringgetFullyQualifiedMethodName()If currently visiting a method, get the method's fully qualified nameorg.apache.bcel.classfile.MethodgetMethod()If currently visiting a method, get the method's Method objectMethodDescriptorgetMethodDescriptor()java.lang.StringgetMethodName()If currently visiting a method, get the method's namejava.lang.StringgetMethodSig()If currently visiting a method, get the method's slash-formatted signatureprotected java.lang.Iterable<org.apache.bcel.classfile.Method>getMethodVisitOrder(org.apache.bcel.classfile.JavaClass obj)static intgetNumberArguments(java.lang.String signature)intgetNumberMethodArguments()java.lang.StringgetPackageName()Get the (slash-formatted?) package name for the current or most recently visited classintgetSizeOfSurroundingTryBlock(int pc)Get lines of code in try block that surround pcintgetSizeOfSurroundingTryBlock(java.lang.String vmNameOfExceptionClass, int pc)Get lines of code in try block that surround pcjava.lang.StringgetSourceFile()Get the source file name for the current or most recently visited classprotected java.lang.StringgetStringFromIndex(int i)java.lang.StringgetSuperclassName()Get the slash-formatted superclass name for the current or most recently visited classjava.util.Set<java.lang.String>getSurroundingCaughtExceptions(int pc)java.util.Set<java.lang.String>getSurroundingCaughtExceptions(int pc, int maxTryBlockSize)java.util.Set<java.lang.Integer>getSurroundingCaughtExceptionTypes(int pc, int maxTryBlockSize)org.apache.bcel.classfile.CodeExceptiongetSurroundingTryBlock(int pc)org.apache.bcel.classfile.CodeExceptiongetSurroundingTryBlock(java.lang.String vmNameOfExceptionClass, int pc)org.apache.bcel.classfile.JavaClassgetThisClass()Get the JavaClass object for the current or most recently visited classXClassgetXClass()XFieldgetXField()XMethodgetXMethod()static booleanhasInterestingClass(org.apache.bcel.classfile.ConstantPool cp, java.util.Collection<java.lang.String> classes)static booleanhasInterestingMethod(org.apache.bcel.classfile.ConstantPool cp, java.util.Collection<MethodDescriptor> methods)Returns true if given constant pool probably has a reference to any of supplied methods Useful to exclude from analysis uninteresting classesprotected booleanisVisitMethodsInCallOrder()voidsetupVisitorForClass(org.apache.bcel.classfile.JavaClass obj)protected voidsetVisitMethodsInCallOrder(boolean visitMethodsInCallOrder)booleanshouldVisit(org.apache.bcel.classfile.JavaClass obj)java.lang.StringtoString()voidvisitAfter(org.apache.bcel.classfile.Code obj)Called after visiting a code attributevoidvisitAfter(org.apache.bcel.classfile.JavaClass obj)voidvisitAnnotation(org.apache.bcel.classfile.Annotations arg0)voidvisitAnnotationDefault(org.apache.bcel.classfile.AnnotationDefault arg0)voidvisitAnnotationEntry(org.apache.bcel.classfile.AnnotationEntry arg0)voidvisitBootstrapMethods(org.apache.bcel.classfile.BootstrapMethods obj)voidvisitCode(org.apache.bcel.classfile.Code obj)voidvisitConstantInvokeDynamic(org.apache.bcel.classfile.ConstantInvokeDynamic obj)voidvisitConstantMethodHandle(org.apache.bcel.classfile.ConstantMethodHandle obj)voidvisitConstantMethodType(org.apache.bcel.classfile.ConstantMethodType obj)voidvisitConstantModule(org.apache.bcel.classfile.ConstantModule obj)voidvisitConstantPackage(org.apache.bcel.classfile.ConstantPackage obj)voidvisitConstantPool(org.apache.bcel.classfile.ConstantPool obj)voidvisitEnclosingMethod(org.apache.bcel.classfile.EnclosingMethod arg0)booleanvisitingField()is the visitor currently visiting a field?booleanvisitingMethod()is the visitor currently visiting a method?voidvisitInnerClasses(org.apache.bcel.classfile.InnerClasses obj)voidvisitJavaClass(org.apache.bcel.classfile.JavaClass obj)voidvisitLineNumberTable(org.apache.bcel.classfile.LineNumberTable obj)voidvisitLocalVariableTable(org.apache.bcel.classfile.LocalVariableTable obj)voidvisitMethodParameters(org.apache.bcel.classfile.MethodParameters obj)voidvisitParameterAnnotation(org.apache.bcel.classfile.ParameterAnnotations arg0)voidvisitParameterAnnotationEntry(org.apache.bcel.classfile.ParameterAnnotationEntry obj)voidvisitStackMap(org.apache.bcel.classfile.StackMap arg0)voidvisitStackMapEntry(org.apache.bcel.classfile.StackMapEntry arg0)-
Methods inherited from class edu.umd.cs.findbugs.visitclass.BetterVisitor
clone, report, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitCodeException, visitConstantClass, visitConstantDouble, visitConstantFieldref, visitConstantFloat, visitConstantInteger, visitConstantInterfaceMethodref, visitConstantLong, visitConstantMethodref, visitConstantNameAndType, visitConstantString, visitConstantUtf8, visitConstantValue, visitDeprecated, visitExceptionTable, visitField, visitInnerClass, visitLineNumber, visitLocalVariable, visitLocalVariableTypeTable, visitMethod, visitSignature, visitSourceFile, visitSynthetic, visitUnknown
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.bcel.classfile.Visitor
visitConstantDynamic, visitMethodParameter, visitModule, visitModuleExports, visitModuleMainClass, visitModuleOpens, visitModulePackages, visitModuleProvides, visitModuleRequires, visitNestHost, visitNestMembers, visitRecord, visitRecordComponent, visitStackMapType
-
-
-
-
Field Detail
-
constantPool
private org.apache.bcel.classfile.ConstantPool constantPool
-
thisClass
private org.apache.bcel.classfile.JavaClass thisClass
-
thisClassInfo
private ClassInfo thisClassInfo
-
thisMethodInfo
private MethodInfo thisMethodInfo
-
thisFieldInfo
private FieldInfo thisFieldInfo
-
className
private java.lang.String className
-
dottedClassName
private java.lang.String dottedClassName
-
packageName
private java.lang.String packageName
-
sourceFile
private java.lang.String sourceFile
-
superclassName
private java.lang.String superclassName
-
dottedSuperclassName
private java.lang.String dottedSuperclassName
-
visitingMethod
private boolean visitingMethod
-
methodSig
private java.lang.String methodSig
-
dottedMethodSig
private java.lang.String dottedMethodSig
-
method
private org.apache.bcel.classfile.Method method
-
methodName
private java.lang.String methodName
-
fullyQualifiedMethodName
private java.lang.String fullyQualifiedMethodName
-
field
private org.apache.bcel.classfile.Field field
-
visitingField
private boolean visitingField
-
fullyQualifiedFieldName
private java.lang.String fullyQualifiedFieldName
-
fieldName
private java.lang.String fieldName
-
fieldSig
private java.lang.String fieldSig
-
dottedFieldSig
private java.lang.String dottedFieldSig
-
fieldIsStatic
private boolean fieldIsStatic
-
code
private org.apache.bcel.classfile.Code code
-
visitMethodsInCallOrder
boolean visitMethodsInCallOrder
-
argumentSignature
static java.util.regex.Pattern argumentSignature
-
-
Method Detail
-
getStringFromIndex
protected java.lang.String getStringFromIndex(int i)
-
asUnsignedByte
protected int asUnsignedByte(byte b)
-
getCode
public org.apache.bcel.classfile.Code getCode()
Return the current Code attribute; assuming one is being visited- Returns:
- current code attribute
-
getSurroundingCaughtExceptions
public java.util.Set<java.lang.String> getSurroundingCaughtExceptions(int pc)
-
getSurroundingCaughtExceptions
public java.util.Set<java.lang.String> getSurroundingCaughtExceptions(int pc, int maxTryBlockSize)
-
getSurroundingCaughtExceptionTypes
public java.util.Set<java.lang.Integer> getSurroundingCaughtExceptionTypes(int pc, int maxTryBlockSize)
-
getSizeOfSurroundingTryBlock
public int getSizeOfSurroundingTryBlock(int pc)
Get lines of code in try block that surround pc- Parameters:
pc-- Returns:
- number of lines of code in try block
-
getSizeOfSurroundingTryBlock
public int getSizeOfSurroundingTryBlock(java.lang.String vmNameOfExceptionClass, int pc)Get lines of code in try block that surround pc- Parameters:
pc-- Returns:
- number of lines of code in try block
-
getSurroundingTryBlock
public org.apache.bcel.classfile.CodeException getSurroundingTryBlock(int pc)
-
getSurroundingTryBlock
public org.apache.bcel.classfile.CodeException getSurroundingTryBlock(java.lang.String vmNameOfExceptionClass, int pc)
-
visitCode
public void visitCode(org.apache.bcel.classfile.Code obj)
- Specified by:
visitCodein interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitCodein classBetterVisitor
-
visitAfter
public void visitAfter(org.apache.bcel.classfile.Code obj)
Called after visiting a code attribute- Parameters:
obj- Code that was just visited
-
visitConstantPool
public void visitConstantPool(org.apache.bcel.classfile.ConstantPool obj)
- Specified by:
visitConstantPoolin interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitConstantPoolin classBetterVisitor
-
doVisitField
private void doVisitField(org.apache.bcel.classfile.Field field)
-
doVisitMethod
public void doVisitMethod(org.apache.bcel.classfile.Method method)
-
amVisitingMainMethod
public boolean amVisitingMainMethod()
-
visitInnerClasses
public void visitInnerClasses(org.apache.bcel.classfile.InnerClasses obj)
- Specified by:
visitInnerClassesin interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitInnerClassesin classBetterVisitor
-
visitAfter
public void visitAfter(org.apache.bcel.classfile.JavaClass obj)
-
shouldVisit
public boolean shouldVisit(org.apache.bcel.classfile.JavaClass obj)
-
isVisitMethodsInCallOrder
protected boolean isVisitMethodsInCallOrder()
-
setVisitMethodsInCallOrder
protected void setVisitMethodsInCallOrder(boolean visitMethodsInCallOrder)
-
getMethodVisitOrder
protected java.lang.Iterable<org.apache.bcel.classfile.Method> getMethodVisitOrder(org.apache.bcel.classfile.JavaClass obj)
-
visitJavaClass
public void visitJavaClass(org.apache.bcel.classfile.JavaClass obj)
- Specified by:
visitJavaClassin interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitJavaClassin classBetterVisitor
-
setupVisitorForClass
public void setupVisitorForClass(org.apache.bcel.classfile.JavaClass obj)
-
visitLineNumberTable
public void visitLineNumberTable(org.apache.bcel.classfile.LineNumberTable obj)
- Specified by:
visitLineNumberTablein interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitLineNumberTablein classBetterVisitor
-
visitLocalVariableTable
public void visitLocalVariableTable(org.apache.bcel.classfile.LocalVariableTable obj)
- Specified by:
visitLocalVariableTablein interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitLocalVariableTablein classBetterVisitor
-
getXClass
public XClass getXClass()
-
getClassDescriptor
public ClassDescriptor getClassDescriptor()
-
getXMethod
public XMethod getXMethod()
-
getMethodDescriptor
public MethodDescriptor getMethodDescriptor()
-
getXField
public XField getXField()
-
getFieldDescriptor
public FieldDescriptor getFieldDescriptor()
-
getConstantPool
public org.apache.bcel.classfile.ConstantPool getConstantPool()
Get the constant pool for the current or most recently visited class
-
getClassName
@SlashedClassName public java.lang.String getClassName()
Get the slash-formatted class name for the current or most recently visited class
-
getDottedClassName
@DottedClassName public java.lang.String getDottedClassName()
Get the dotted class name for the current or most recently visited class
-
getPackageName
public java.lang.String getPackageName()
Get the (slash-formatted?) package name for the current or most recently visited class
-
getSourceFile
public java.lang.String getSourceFile()
Get the source file name for the current or most recently visited class
-
getSuperclassName
@SlashedClassName public java.lang.String getSuperclassName()
Get the slash-formatted superclass name for the current or most recently visited class
-
getDottedSuperclassName
@DottedClassName public java.lang.String getDottedSuperclassName()
Get the dotted superclass name for the current or most recently visited class
-
getThisClass
public org.apache.bcel.classfile.JavaClass getThisClass()
Get the JavaClass object for the current or most recently visited class
-
getFullyQualifiedMethodName
public java.lang.String getFullyQualifiedMethodName()
If currently visiting a method, get the method's fully qualified name
-
visitingMethod
public boolean visitingMethod()
is the visitor currently visiting a method?
-
visitingField
public boolean visitingField()
is the visitor currently visiting a field?
-
getField
public org.apache.bcel.classfile.Field getField()
If currently visiting a field, get the field's Field object
-
getMethod
public org.apache.bcel.classfile.Method getMethod()
If currently visiting a method, get the method's Method object
-
getMethodName
public java.lang.String getMethodName()
If currently visiting a method, get the method's name
-
getNumberArguments
public static int getNumberArguments(java.lang.String signature)
-
hasInterestingMethod
public static boolean hasInterestingMethod(org.apache.bcel.classfile.ConstantPool cp, java.util.Collection<MethodDescriptor> methods)Returns true if given constant pool probably has a reference to any of supplied methods Useful to exclude from analysis uninteresting classes- Parameters:
cp- constant poolmethods- methods collection- Returns:
- true if method is found
-
hasInterestingClass
public static boolean hasInterestingClass(org.apache.bcel.classfile.ConstantPool cp, java.util.Collection<java.lang.String> classes)
-
getNumberMethodArguments
public int getNumberMethodArguments()
-
getMethodSig
public java.lang.String getMethodSig()
If currently visiting a method, get the method's slash-formatted signature
-
getDottedMethodSig
public java.lang.String getDottedMethodSig()
If currently visiting a method, get the method's dotted method signature
-
getFieldName
public java.lang.String getFieldName()
If currently visiting a field, get the field's name
-
getFieldSig
public java.lang.String getFieldSig()
If currently visiting a field, get the field's slash-formatted signature
-
getFieldIsStatic
public boolean getFieldIsStatic()
If currently visiting a field, return whether or not the field is static
-
getFullyQualifiedFieldName
public java.lang.String getFullyQualifiedFieldName()
If currently visiting a field, get the field's fully qualified name
-
getDottedFieldSig
@Deprecated public java.lang.String getDottedFieldSig()
Deprecated.If currently visiting a field, get the field's dot-formatted signature
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
visitAnnotation
public void visitAnnotation(org.apache.bcel.classfile.Annotations arg0)
-
visitAnnotationDefault
public void visitAnnotationDefault(org.apache.bcel.classfile.AnnotationDefault arg0)
-
visitAnnotationEntry
public void visitAnnotationEntry(org.apache.bcel.classfile.AnnotationEntry arg0)
-
visitEnclosingMethod
public void visitEnclosingMethod(org.apache.bcel.classfile.EnclosingMethod arg0)
-
visitParameterAnnotation
public void visitParameterAnnotation(org.apache.bcel.classfile.ParameterAnnotations arg0)
-
visitStackMap
public void visitStackMap(org.apache.bcel.classfile.StackMap arg0)
- Specified by:
visitStackMapin interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitStackMapin classBetterVisitor
-
visitStackMapEntry
public void visitStackMapEntry(org.apache.bcel.classfile.StackMapEntry arg0)
- Specified by:
visitStackMapEntryin interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitStackMapEntryin classBetterVisitor
-
visitConstantInvokeDynamic
public void visitConstantInvokeDynamic(org.apache.bcel.classfile.ConstantInvokeDynamic obj)
-
visitBootstrapMethods
public void visitBootstrapMethods(org.apache.bcel.classfile.BootstrapMethods obj)
-
visitMethodParameters
public void visitMethodParameters(org.apache.bcel.classfile.MethodParameters obj)
-
visitConstantMethodType
public void visitConstantMethodType(org.apache.bcel.classfile.ConstantMethodType obj)
-
visitConstantMethodHandle
public void visitConstantMethodHandle(org.apache.bcel.classfile.ConstantMethodHandle obj)
-
visitParameterAnnotationEntry
public void visitParameterAnnotationEntry(org.apache.bcel.classfile.ParameterAnnotationEntry obj)
-
visitConstantModule
public void visitConstantModule(org.apache.bcel.classfile.ConstantModule obj)
-
visitConstantPackage
public void visitConstantPackage(org.apache.bcel.classfile.ConstantPackage obj)
-
-