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
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
- Author:
- M. Dahm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
protected int
asUnsignedByte
(byte b) void
doVisitMethod
(org.apache.bcel.classfile.Method method) Get the slash-formatted class name for the current or most recently visited classorg.apache.bcel.classfile.Code
getCode()
Return the current Code attribute; assuming one is being visitedorg.apache.bcel.classfile.ConstantPool
Get the constant pool for the current or most recently visited classGet the dotted class name for the current or most recently visited classDeprecated.If currently visiting a method, get the method's dotted method signatureGet the dotted superclass name for the current or most recently visited classorg.apache.bcel.classfile.Field
getField()
If currently visiting a field, get the field's Field objectboolean
If currently visiting a field, return whether or not the field is staticIf currently visiting a field, get the field's nameIf currently visiting a field, get the field's slash-formatted signatureIf currently visiting a field, get the field's fully qualified nameIf currently visiting a method, get the method's fully qualified nameorg.apache.bcel.classfile.Method
If currently visiting a method, get the method's Method objectIf currently visiting a method, get the method's nameIf currently visiting a method, get the method's slash-formatted signatureprotected Iterable<org.apache.bcel.classfile.Method>
getMethodVisitOrder
(org.apache.bcel.classfile.JavaClass obj) static int
getNumberArguments
(String signature) int
Get the (slash-formatted?) package name for the current or most recently visited classint
getSizeOfSurroundingTryBlock
(int pc) Get lines of code in try block that surround pcint
getSizeOfSurroundingTryBlock
(String vmNameOfExceptionClass, int pc) Get lines of code in try block that surround pcGet the source file name for the current or most recently visited classprotected String
getStringFromIndex
(int i) Get the slash-formatted superclass name for the current or most recently visited classgetSurroundingCaughtExceptions
(int pc) getSurroundingCaughtExceptions
(int pc, int maxTryBlockSize) org.apache.bcel.classfile.CodeException
getSurroundingTryBlock
(int pc) org.apache.bcel.classfile.CodeException
getSurroundingTryBlock
(String vmNameOfExceptionClass, int pc) org.apache.bcel.classfile.JavaClass
Get the JavaClass object for the current or most recently visited classstatic boolean
hasInterestingClass
(org.apache.bcel.classfile.ConstantPool cp, Collection<String> classes) static boolean
hasInterestingMethod
(org.apache.bcel.classfile.ConstantPool cp, 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 boolean
void
setupVisitorForClass
(org.apache.bcel.classfile.JavaClass obj) protected void
setVisitMethodsInCallOrder
(boolean visitMethodsInCallOrder) boolean
shouldVisit
(org.apache.bcel.classfile.JavaClass obj) toString()
void
visitAfter
(org.apache.bcel.classfile.Code obj) Called after visiting a code attributevoid
visitAfter
(org.apache.bcel.classfile.JavaClass obj) void
visitAnnotation
(org.apache.bcel.classfile.Annotations arg0) void
visitAnnotationDefault
(org.apache.bcel.classfile.AnnotationDefault arg0) void
visitAnnotationEntry
(org.apache.bcel.classfile.AnnotationEntry arg0) void
visitBootstrapMethods
(org.apache.bcel.classfile.BootstrapMethods obj) void
visitCode
(org.apache.bcel.classfile.Code obj) void
visitConstantInvokeDynamic
(org.apache.bcel.classfile.ConstantInvokeDynamic obj) void
visitConstantMethodHandle
(org.apache.bcel.classfile.ConstantMethodHandle obj) void
visitConstantMethodType
(org.apache.bcel.classfile.ConstantMethodType obj) void
visitConstantModule
(org.apache.bcel.classfile.ConstantModule obj) void
visitConstantPackage
(org.apache.bcel.classfile.ConstantPackage obj) void
visitConstantPool
(org.apache.bcel.classfile.ConstantPool obj) void
visitEnclosingMethod
(org.apache.bcel.classfile.EnclosingMethod arg0) boolean
is the visitor currently visiting a field?boolean
is the visitor currently visiting a method?void
visitInnerClasses
(org.apache.bcel.classfile.InnerClasses obj) void
visitJavaClass
(org.apache.bcel.classfile.JavaClass obj) void
visitLineNumberTable
(org.apache.bcel.classfile.LineNumberTable obj) void
visitLocalVariableTable
(org.apache.bcel.classfile.LocalVariableTable obj) void
visitMethodParameters
(org.apache.bcel.classfile.MethodParameters obj) void
visitParameterAnnotation
(org.apache.bcel.classfile.ParameterAnnotations arg0) void
visitParameterAnnotationEntry
(org.apache.bcel.classfile.ParameterAnnotationEntry obj) void
visitStackMap
(org.apache.bcel.classfile.StackMap arg0) void
visitStackMapEntry
(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
-
Constructor Details
-
PreorderVisitor
public PreorderVisitor()
-
-
Method Details
-
getStringFromIndex
-
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
-
getSurroundingCaughtExceptions
-
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
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(String vmNameOfExceptionClass, int pc) -
visitCode
public void visitCode(org.apache.bcel.classfile.Code obj) - Specified by:
visitCode
in interfaceorg.apache.bcel.classfile.Visitor
- Overrides:
visitCode
in 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:
visitConstantPool
in interfaceorg.apache.bcel.classfile.Visitor
- Overrides:
visitConstantPool
in classBetterVisitor
-
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:
visitInnerClasses
in interfaceorg.apache.bcel.classfile.Visitor
- Overrides:
visitInnerClasses
in 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 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:
visitJavaClass
in interfaceorg.apache.bcel.classfile.Visitor
- Overrides:
visitJavaClass
in classBetterVisitor
-
setupVisitorForClass
public void setupVisitorForClass(org.apache.bcel.classfile.JavaClass obj) -
visitLineNumberTable
public void visitLineNumberTable(org.apache.bcel.classfile.LineNumberTable obj) - Specified by:
visitLineNumberTable
in interfaceorg.apache.bcel.classfile.Visitor
- Overrides:
visitLineNumberTable
in classBetterVisitor
-
visitLocalVariableTable
public void visitLocalVariableTable(org.apache.bcel.classfile.LocalVariableTable obj) - Specified by:
visitLocalVariableTable
in interfaceorg.apache.bcel.classfile.Visitor
- Overrides:
visitLocalVariableTable
in classBetterVisitor
-
getXClass
-
getClassDescriptor
-
getXMethod
-
getMethodDescriptor
-
getXField
-
getFieldDescriptor
-
getConstantPool
public org.apache.bcel.classfile.ConstantPool getConstantPool()Get the constant pool for the current or most recently visited class -
getClassName
Get the slash-formatted class name for the current or most recently visited class -
getDottedClassName
Get the dotted class name for the current or most recently visited class -
getPackageName
Get the (slash-formatted?) package name for the current or most recently visited class -
getSourceFile
Get the source file name for the current or most recently visited class -
getSuperclassName
Get the slash-formatted superclass name for the current or most recently visited class -
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
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
If currently visiting a method, get the method's name -
getNumberArguments
-
hasInterestingMethod
public static boolean hasInterestingMethod(org.apache.bcel.classfile.ConstantPool cp, 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, Collection<String> classes) -
getNumberMethodArguments
public int getNumberMethodArguments() -
getMethodSig
If currently visiting a method, get the method's slash-formatted signature -
getDottedMethodSig
If currently visiting a method, get the method's dotted method signature -
getFieldName
If currently visiting a field, get the field's name -
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
If currently visiting a field, get the field's fully qualified name -
getDottedFieldSig
Deprecated.If currently visiting a field, get the field's dot-formatted signature -
toString
-
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:
visitStackMap
in interfaceorg.apache.bcel.classfile.Visitor
- Overrides:
visitStackMap
in classBetterVisitor
-
visitStackMapEntry
public void visitStackMapEntry(org.apache.bcel.classfile.StackMapEntry arg0) - Specified by:
visitStackMapEntry
in interfaceorg.apache.bcel.classfile.Visitor
- Overrides:
visitStackMapEntry
in 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)
-