本文整理匯總了Java中org.apache.bcel.classfile.JavaClass.getSourceFileName方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaClass.getSourceFileName方法的具體用法?Java JavaClass.getSourceFileName怎麽用?Java JavaClass.getSourceFileName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.bcel.classfile.JavaClass
的用法示例。
在下文中一共展示了JavaClass.getSourceFileName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: inspectResult
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public void inspectResult(JavaClass javaClass, MethodGen methodGen, CFG cfg,
Dataflow<ResourceValueFrame, ResourceValueAnalysis<Lock>> dataflow, Lock resource) {
ResourceValueFrame exitFrame = dataflow.getResultFact(cfg.getExit());
int exitStatus = exitFrame.getStatus();
if (exitStatus == ResourceValueFrame.OPEN || exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {
String bugType;
int priority;
if (exitStatus == ResourceValueFrame.OPEN) {
bugType = "UL_UNRELEASED_LOCK";
priority = HIGH_PRIORITY;
} else {
bugType = "UL_UNRELEASED_LOCK_EXCEPTION_PATH";
priority = NORMAL_PRIORITY;
}
String sourceFile = javaClass.getSourceFileName();
bugReporter.reportBug(new BugInstance(this, bugType, priority)
.addClassAndMethod(methodGen, sourceFile)
.addSourceLine(methodGen, sourceFile, resource.getLocation().getHandle()));
}
}
示例2: reportMatch
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public void reportMatch(ClassContext classContext, Method method, ByteCodePatternMatch match) {
MethodGen methodGen = classContext.getMethodGen(method);
JavaClass javaClass = classContext.getJavaClass();
BindingSet bindingSet = match.getBindingSet();
// Note that the lookup of "h" cannot fail, and
// it is guaranteed to be bound to a FieldVariable.
Binding binding = bindingSet.lookup("h");
FieldVariable field = (FieldVariable) binding.getVariable();
// Ignore fields generated for accesses to Foo.class
if (field.getFieldName().startsWith("class$"))
return;
// Find start and end instructions (for reporting source lines)
InstructionHandle start = match.getLabeledInstruction("startDC");
InstructionHandle end = match.getLabeledInstruction("endDC");
String sourceFile = javaClass.getSourceFileName();
bugReporter.reportBug(new BugInstance(this, "BCPDC_DOUBLECHECK", NORMAL_PRIORITY)
.addClassAndMethod(methodGen, sourceFile)
.addField(field).describe("FIELD_ON")
.addSourceLine(methodGen, sourceFile, start, end));
}
示例3: analyzeBasicBlock
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
private void analyzeBasicBlock(ClassContext classContext, Method method, BasicBlock basicBlock) {
int lastLoaded = -1;
for (Iterator<InstructionHandle> i = basicBlock.instructionIterator(); i.hasNext();) {
InstructionHandle handle = i.next();
Instruction ins = handle.getInstruction();
int loaded = -1, stored = -1;
if (ins instanceof LoadInstruction) {
LoadInstruction load = (LoadInstruction) ins;
loaded = load.getIndex();
} else if (ins instanceof StoreInstruction) {
StoreInstruction store = (StoreInstruction) ins;
stored = store.getIndex();
}
if (stored >= 0 && stored == lastLoaded) {
JavaClass javaClass = classContext.getJavaClass();
MethodGen methodGen = classContext.getMethodGen(method);
String sourceFile = javaClass.getSourceFileName();
bugReporter.reportBug(new BugInstance(this, "SA_LOCAL_SELF_ASSIGNMENT", NORMAL_PRIORITY)
.addClass(javaClass)
.addMethod(methodGen, sourceFile)
.addSourceLine(methodGen, sourceFile, handle));
}
lastLoaded = (loaded >= 0) ? loaded : -1;
}
}
示例4: addAccess
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public void addAccess(ClassContext classContext, Method method, InstructionHandle handle, boolean isLocked) {
if (!SYNC_ACCESS && isLocked)
return;
JavaClass javaClass = classContext.getJavaClass();
String sourceFile = javaClass.getSourceFileName();
MethodGen methodGen = classContext.getMethodGen(method);
SourceLineAnnotation accessSourceLine = SourceLineAnnotation.fromVisitedInstruction(methodGen, sourceFile, handle);
if (accessSourceLine != null)
(isLocked ? syncAccessList : unsyncAccessList).add(accessSourceLine);
}
示例5: reportMatch
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public void reportMatch(ClassContext classContext, Method method, ByteCodePatternMatch match) {
MethodGen methodGen = classContext.getMethodGen(method);
JavaClass javaClass = classContext.getJavaClass();
InstructionHandle call = match.getLabeledInstruction("call");
// Ignore inner-class access methods
InvokeInstruction inv = (InvokeInstruction) call.getInstruction();
ConstantPoolGen cp = methodGen.getConstantPool();
String calledMethodName = inv.getMethodName(cp);
if (calledMethodName.startsWith("access$")
|| calledMethodName.startsWith("access+"))
return;
/*
System.out.println("Found " + calledMethodName);
System.out.println(inv.getSignature(cp));
System.out.println(inv.getClassName(cp));
*/
String calledMethodClass = inv.getClassName(cp);
if (inv.getSignature(cp).endsWith("V") && !calledMethodName.equals("<init>"))
return;
/*
if (calledMethodClass.equals(javaClass.getClassName()))
return;
*/
String sourceFile = javaClass.getSourceFileName();
/*
System.out.println("CalledMethodClass: " + calledMethodClass);
System.out.println("CalledMethodName: " + calledMethodName);
*/
int priority = NORMAL_PRIORITY;
if (calledMethodName.equals("createNewFile"))
priority = LOW_PRIORITY;
else if (calledMethodClass.startsWith("java.lang")
|| calledMethodClass.endsWith("Error")
|| calledMethodClass.endsWith("Exception"))
priority = HIGH_PRIORITY;
/*
String calledPackage = extractPackageName(calledMethodClass);
String callingPackage = extractPackageName(javaClass.getClassName());
if (calledPackage.length() > 0
&& callingPackage.length() > 0
&& (calledPackage.startsWith(callingPackage)
|| callingPackage.startsWith(calledPackage)))
priority++;
*/
// System.out.println("priority: " + priority);
bugReporter.reportBug(new BugInstance(this, "RV_RETURN_VALUE_IGNORED",
priority)
.addClassAndMethod(methodGen, sourceFile)
.addCalledMethod(methodGen, inv)
.addSourceLine(methodGen, sourceFile, call));
}