本文整理汇总了Java中org.apache.bcel.generic.MethodGen.getClassName方法的典型用法代码示例。如果您正苦于以下问题:Java MethodGen.getClassName方法的具体用法?Java MethodGen.getClassName怎么用?Java MethodGen.getClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.generic.MethodGen
的用法示例。
在下文中一共展示了MethodGen.getClassName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromVisitedMethod
import org.apache.bcel.generic.MethodGen; //导入方法依赖的package包/类
/**
* Factory method for creating a source line annotation describing
* an entire method.
*
* @param methodGen the method being visited
* @return the SourceLineAnnotation, or null if we do not have line number information
* for the method
*/
public static SourceLineAnnotation fromVisitedMethod(MethodGen methodGen, String sourceFile) {
LineNumberTable lineNumberTable = methodGen.getLineNumberTable(methodGen.getConstantPool());
String className = methodGen.getClassName();
int codeSize = methodGen.getInstructionList().getLength();
if (lineNumberTable == null)
return createUnknown(className, sourceFile, 0, codeSize - 1);
return forEntireMethod(className, sourceFile, lineNumberTable, codeSize);
}
示例2: fromVisitedInstruction
import org.apache.bcel.generic.MethodGen; //导入方法依赖的package包/类
/**
* Factory method for creating a source line annotation describing the
* source line number for a visited instruction.
*
* @param methodGen the MethodGen object representing the method
* @param handle the InstructionHandle containing the visited instruction
* @return the SourceLineAnnotation, or null if we do not have line number information
* for the instruction
*/
public static SourceLineAnnotation fromVisitedInstruction(MethodGen methodGen, String sourceFile, InstructionHandle handle) {
LineNumberTable table = methodGen.getLineNumberTable(methodGen.getConstantPool());
String className = methodGen.getClassName();
int bytecodeOffset = handle.getPosition();
if (table == null)
return createUnknown(className, sourceFile, bytecodeOffset, bytecodeOffset);
int lineNumber = table.getSourceLine(handle.getPosition());
return new SourceLineAnnotation(className, sourceFile, lineNumber, lineNumber, bytecodeOffset, bytecodeOffset);
}
示例3: fromVisitedInstructionRange
import org.apache.bcel.generic.MethodGen; //导入方法依赖的package包/类
/**
* Factory method for creating a source line annotation describing
* the source line numbers for a range of instruction in a method.
*
* @param methodGen the method
* @param start the start instruction
* @param end the end instruction (inclusive)
*/
public static SourceLineAnnotation fromVisitedInstructionRange(MethodGen methodGen, String sourceFile, InstructionHandle start, InstructionHandle end) {
LineNumberTable lineNumberTable = methodGen.getLineNumberTable(methodGen.getConstantPool());
String className = methodGen.getClassName();
if (lineNumberTable == null)
return createUnknown(className, sourceFile, start.getPosition(), end.getPosition());
int startLine = lineNumberTable.getSourceLine(start.getPosition());
int endLine = lineNumberTable.getSourceLine(end.getPosition());
return new SourceLineAnnotation(className, sourceFile, startLine, endLine, start.getPosition(), end.getPosition());
}
示例4: fromVisitedInstruction
import org.apache.bcel.generic.MethodGen; //导入方法依赖的package包/类
/**
* Factory method for creating a source line annotation describing the
* source line number for a visited instruction.
*
* @param classContext
* the ClassContext
* @param methodGen
* the MethodGen object representing the method
* @param handle
* the InstructionHandle containing the visited instruction
* @return the SourceLineAnnotation, or null if we do not have line number
* information for the instruction
*/
public static SourceLineAnnotation fromVisitedInstruction(ClassContext classContext, MethodGen methodGen, String sourceFile,
@Nonnull InstructionHandle handle) {
LineNumberTable table = methodGen.getLineNumberTable(methodGen.getConstantPool());
String className = methodGen.getClassName();
int bytecodeOffset = handle.getPosition();
if (table == null)
return createUnknown(className, sourceFile, bytecodeOffset, bytecodeOffset);
int lineNumber = table.getSourceLine(handle.getPosition());
return new SourceLineAnnotation(className, sourceFile, lineNumber, lineNumber, bytecodeOffset, bytecodeOffset);
}
示例5: createXMethod
import org.apache.bcel.generic.MethodGen; //导入方法依赖的package包/类
public static XMethod createXMethod(MethodGen methodGen) {
String className = methodGen.getClassName();
String methodName = methodGen.getName();
String methodSig = methodGen.getSignature();
int accessFlags = methodGen.getAccessFlags();
return createXMethod(className, methodName, methodSig, accessFlags);
}
示例6: analyzeMethod
import org.apache.bcel.generic.MethodGen; //导入方法依赖的package包/类
private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {
MethodGen methodGen = classContext.getMethodGen(method);
if (methodGen == null)
return;
BitSet bytecodeSet = classContext.getBytecodeSet(method);
if (bytecodeSet == null)
return;
// We don't adequately model instanceof interfaces yet
if (bytecodeSet.get(Constants.INSTANCEOF) || bytecodeSet.get(Constants.CHECKCAST))
return;
CFG cfg = classContext.getCFG(method);
TypeDataflow typeDataflow = classContext.getTypeDataflow(method);
ConstantPoolGen cpg = classContext.getConstantPoolGen();
String sourceFile = classContext.getJavaClass().getSourceFileName();
if (DEBUG) {
String methodName = methodGen.getClassName() + "." + methodGen.getName();
System.out.println("Checking " + methodName);
}
for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
Location location = i.next();
InstructionHandle handle = location.getHandle();
Instruction ins = handle.getInstruction();
if (!(ins instanceof INVOKEINTERFACE))
continue;
INVOKEINTERFACE invoke = (INVOKEINTERFACE) ins;
String mName = invoke.getMethodName(cpg);
if (!mName.equals("setAttribute"))
continue;
String cName = invoke.getClassName(cpg);
if (!cName.equals("javax.servlet.http.HttpSession"))
continue;
TypeFrame frame = typeDataflow.getFactAtLocation(location);
if (!frame.isValid()) {
// This basic block is probably dead
continue;
}
Type operandType = frame.getTopValue();
if (operandType.equals(TopType.instance())) {
// unreachable
continue;
}
if (!(operandType instanceof ReferenceType)) {
// Shouldn't happen - illegal bytecode
continue;
}
ReferenceType refType = (ReferenceType) operandType;
if (refType.equals(NullType.instance())) {
continue;
}
try {
double isSerializable = DeepSubtypeAnalysis.isDeepSerializable(refType);
if (isSerializable < 0.9) {
SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext,
methodGen, sourceFile, handle);
ReferenceType problem = DeepSubtypeAnalysis.getLeastSerializableTypeComponent(refType);
bugAccumulator.accumulateBug(new BugInstance(this, "J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION",
isSerializable < 0.15 ? HIGH_PRIORITY : isSerializable > 0.5 ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClassAndMethod(methodGen, sourceFile).addType(problem).describe(TypeAnnotation.FOUND_ROLE),
sourceLineAnnotation);
}
} catch (ClassNotFoundException e) {
// ignore
}
}
}
示例7: addMethod
import org.apache.bcel.generic.MethodGen; //导入方法依赖的package包/类
/**
* Add a method annotation. If this is the first method annotation added,
* it becomes the primary method annotation.
* If the method has source line information, then a SourceLineAnnotation
* is added to the method.
*
* @param methodGen the MethodGen object for the method
* @param sourceFile source file method is defined in
* @return this object
*/
public BugInstance addMethod(MethodGen methodGen, String sourceFile) {
MethodAnnotation methodAnnotation =
new MethodAnnotation(methodGen.getClassName(), methodGen.getName(), methodGen.getSignature());
addMethod(methodAnnotation);
addSourceLinesForMethod(methodAnnotation, SourceLineAnnotation.fromVisitedMethod(methodGen, sourceFile));
return this;
}
示例8: fromVisitedMethod
import org.apache.bcel.generic.MethodGen; //导入方法依赖的package包/类
/**
* Factory method for creating a source line annotation describing an entire
* method.
*
* @param methodGen
* the method being visited
* @return the SourceLineAnnotation, or null if we do not have line number
* information for the method
*/
public static SourceLineAnnotation fromVisitedMethod(MethodGen methodGen, String sourceFile) {
LineNumberTable lineNumberTable = methodGen.getLineNumberTable(methodGen.getConstantPool());
String className = methodGen.getClassName();
int codeSize = methodGen.getInstructionList().getLength();
if (lineNumberTable == null)
return createUnknown(className, sourceFile, 0, codeSize - 1);
return forEntireMethod(className, sourceFile, lineNumberTable, codeSize);
}
示例9: fromVisitedInstructionRange
import org.apache.bcel.generic.MethodGen; //导入方法依赖的package包/类
/**
* Factory method for creating a source line annotation describing the
* source line numbers for a range of instruction in a method.
*
* @param classContext
* theClassContext
* @param methodGen
* the method
* @param start
* the start instruction
* @param end
* the end instruction (inclusive)
*/
public static SourceLineAnnotation fromVisitedInstructionRange(ClassContext classContext, MethodGen methodGen,
String sourceFile, InstructionHandle start, InstructionHandle end) {
LineNumberTable lineNumberTable = methodGen.getLineNumberTable(methodGen.getConstantPool());
String className = methodGen.getClassName();
if (lineNumberTable == null)
return createUnknown(className, sourceFile, start.getPosition(), end.getPosition());
int startLine = lineNumberTable.getSourceLine(start.getPosition());
int endLine = lineNumberTable.getSourceLine(end.getPosition());
return new SourceLineAnnotation(className, sourceFile, startLine, endLine, start.getPosition(), end.getPosition());
}
示例10: addMethod
import org.apache.bcel.generic.MethodGen; //导入方法依赖的package包/类
/**
* Add a method annotation. If this is the first method annotation added, it
* becomes the primary method annotation. If the method has source line
* information, then a SourceLineAnnotation is added to the method.
*
* @param methodGen
* the MethodGen object for the method
* @param sourceFile
* source file method is defined in
* @return this object
*/
@Nonnull
public BugInstance addMethod(MethodGen methodGen, String sourceFile) {
String className = methodGen.getClassName();
MethodAnnotation methodAnnotation = new MethodAnnotation(className, methodGen.getName(), methodGen.getSignature(),
methodGen.isStatic());
addMethod(methodAnnotation);
addSourceLinesForMethod(methodAnnotation, SourceLineAnnotation.fromVisitedMethod(methodGen, sourceFile));
return this;
}