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.Pattern
argumentSignature
private java.lang.String
className
private org.apache.bcel.classfile.Code
code
private org.apache.bcel.classfile.ConstantPool
constantPool
private java.lang.String
dottedClassName
private java.lang.String
dottedFieldSig
private java.lang.String
dottedMethodSig
private java.lang.String
dottedSuperclassName
private org.apache.bcel.classfile.Field
field
private boolean
fieldIsStatic
private java.lang.String
fieldName
private java.lang.String
fieldSig
private java.lang.String
fullyQualifiedFieldName
private java.lang.String
fullyQualifiedMethodName
private org.apache.bcel.classfile.Method
method
private java.lang.String
methodName
private java.lang.String
methodSig
private java.lang.String
packageName
private java.lang.String
sourceFile
private java.lang.String
superclassName
private org.apache.bcel.classfile.JavaClass
thisClass
private ClassInfo
thisClassInfo
private FieldInfo
thisFieldInfo
private MethodInfo
thisMethodInfo
private boolean
visitingField
private boolean
visitingMethod
(package private) boolean
visitMethodsInCallOrder
-
Constructor Summary
Constructors Constructor Description PreorderVisitor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
amVisitingMainMethod()
protected int
asUnsignedByte(byte b)
private void
doVisitField(org.apache.bcel.classfile.Field field)
void
doVisitMethod(org.apache.bcel.classfile.Method method)
ClassDescriptor
getClassDescriptor()
java.lang.String
getClassName()
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
getConstantPool()
Get the constant pool for the current or most recently visited classjava.lang.String
getDottedClassName()
Get the dotted class name for the current or most recently visited classjava.lang.String
getDottedFieldSig()
Deprecated.java.lang.String
getDottedMethodSig()
If currently visiting a method, get the method's dotted method signaturejava.lang.String
getDottedSuperclassName()
Get 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 objectFieldDescriptor
getFieldDescriptor()
boolean
getFieldIsStatic()
If currently visiting a field, return whether or not the field is staticjava.lang.String
getFieldName()
If currently visiting a field, get the field's namejava.lang.String
getFieldSig()
If currently visiting a field, get the field's slash-formatted signaturejava.lang.String
getFullyQualifiedFieldName()
If currently visiting a field, get the field's fully qualified namejava.lang.String
getFullyQualifiedMethodName()
If currently visiting a method, get the method's fully qualified nameorg.apache.bcel.classfile.Method
getMethod()
If currently visiting a method, get the method's Method objectMethodDescriptor
getMethodDescriptor()
java.lang.String
getMethodName()
If currently visiting a method, get the method's namejava.lang.String
getMethodSig()
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 int
getNumberArguments(java.lang.String signature)
int
getNumberMethodArguments()
java.lang.String
getPackageName()
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(java.lang.String vmNameOfExceptionClass, int pc)
Get lines of code in try block that surround pcjava.lang.String
getSourceFile()
Get the source file name for the current or most recently visited classprotected java.lang.String
getStringFromIndex(int i)
java.lang.String
getSuperclassName()
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.CodeException
getSurroundingTryBlock(int pc)
org.apache.bcel.classfile.CodeException
getSurroundingTryBlock(java.lang.String vmNameOfExceptionClass, int pc)
org.apache.bcel.classfile.JavaClass
getThisClass()
Get the JavaClass object for the current or most recently visited classXClass
getXClass()
XField
getXField()
XMethod
getXMethod()
static boolean
hasInterestingClass(org.apache.bcel.classfile.ConstantPool cp, java.util.Collection<java.lang.String> classes)
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 classesprotected boolean
isVisitMethodsInCallOrder()
void
setupVisitorForClass(org.apache.bcel.classfile.JavaClass obj)
protected void
setVisitMethodsInCallOrder(boolean visitMethodsInCallOrder)
boolean
shouldVisit(org.apache.bcel.classfile.JavaClass obj)
java.lang.String
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
visitingField()
is the visitor currently visiting a field?boolean
visitingMethod()
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
-
-
-
-
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:
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
-
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:
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 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:
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
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:
toString
in 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:
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)
-
-