本文整理汇总了Java中org.apache.bcel.generic.GETFIELD类的典型用法代码示例。如果您正苦于以下问题:Java GETFIELD类的具体用法?Java GETFIELD怎么用?Java GETFIELD使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GETFIELD类属于org.apache.bcel.generic包,在下文中一共展示了GETFIELD类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GETFIELDReference
import org.apache.bcel.generic.GETFIELD; //导入依赖的package包/类
/**
* @param aInstruction
* @param aPoolGen
*/
public GETFIELDReference(
GETFIELD aInstruction,
ConstantPoolGen aPoolGen)
{
super(aInstruction, aPoolGen);
}
示例2: visitGETFIELD
import org.apache.bcel.generic.GETFIELD; //导入依赖的package包/类
@Override
public void visitGETFIELD(GETFIELD obj) {
Taint.State state = taintConfig.getClassTaintState(obj.getSignature(cpg), Taint.State.UNKNOWN);
Taint taint = new Taint(state);
if (!state.equals(Taint.State.SAFE)){
taint.addLocation(getTaintLocation(), false);
}
if (FindSecBugsGlobalConfig.getInstance().isDebugTaintState()) {
taint.setDebugInfo("." + obj.getFieldName(cpg));
}
modelInstruction(obj, getNumWordsConsumed(obj), getNumWordsProduced(obj), taint);
}
示例3: visitGETFIELD
import org.apache.bcel.generic.GETFIELD; //导入依赖的package包/类
@Override
public void visitGETFIELD(GETFIELD obj) {
Type type = obj.getType(getCPG());
if (type.getSignature().equals(STRING_SIGNATURE)) {
handleLoad(obj);
} else {
XField xf = XFactory.createXField(obj, cpg);
if (xf.isFinal()) {
FieldSummary fieldSummary = AnalysisContext.currentAnalysisContext().getFieldSummary();
Item summary = fieldSummary.getSummary(xf);
if (summary.isNull()) {
consumeStack(obj);
pushValue(TypeFrame.getNullType());
return;
}
String slashedClassName = ClassName.fromFieldSignature(type.getSignature());
if (slashedClassName != null) {
String dottedClassName = ClassName.toDottedClassName(slashedClassName);
if (DEFAULT_SUSPICIOUS_SET.contains(dottedClassName)) {
type = new FinalConstant(dottedClassName, xf);
consumeStack(obj);
pushValue(type);
return;
}
}
}
super.visitGETFIELD(obj);
}
}
示例4: visitGETFIELD
import org.apache.bcel.generic.GETFIELD; //导入依赖的package包/类
@Override
public void visitGETFIELD(GETFIELD obj) {
XField xfield = Hierarchy.findXField(obj, getCPG());
if (xfield != null) {
if (xfield.isVolatile())
getFrame().killAllLoads();
if (doRedundantLoadElimination()) {
loadInstanceField(xfield, obj);
return;
}
}
handleNormalInstruction(obj);
}
示例5: visitGETFIELD
import org.apache.bcel.generic.GETFIELD; //导入依赖的package包/类
@Override
public void visitGETFIELD(GETFIELD obj) {
if (getNumWordsProduced(obj) != 1) {
super.visitGETFIELD(obj);
return;
}
if (checkForKnownValue(obj)) {
return;
}
XField field = XFactory.createXField(obj, cpg);
NullnessAnnotation annotation = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase()
.getResolvedAnnotation(field, false);
if (annotation == NullnessAnnotation.NONNULL) {
modelNormalInstruction(obj, getNumWordsConsumed(obj), 0);
produce(IsNullValue.nonNullValue());
} else if (annotation == NullnessAnnotation.CHECK_FOR_NULL) {
modelNormalInstruction(obj, getNumWordsConsumed(obj), 0);
produce(IsNullValue.nullOnSimplePathValue().markInformationAsComingFromFieldValue(field));
} else {
super.visitGETFIELD(obj);
}
}
示例6: visitGETFIELD
import org.apache.bcel.generic.GETFIELD; //导入依赖的package包/类
/** @see org.apache.bcel.generic.Visitor */
public void visitGETFIELD(GETFIELD aGETFIELD)
{
addFieldReference(
new GETFIELDReference(aGETFIELD, mCurrentPoolGen));
}
示例7: counterAdaptClass
import org.apache.bcel.generic.GETFIELD; //导入依赖的package包/类
byte[] counterAdaptClass(final InputStream is, final String name)
throws Exception
{
JavaClass jc = new ClassParser(is, name + ".class").parse();
ClassGen cg = new ClassGen(jc);
ConstantPoolGen cp = cg.getConstantPool();
if (!cg.isInterface()) {
FieldGen fg = new FieldGen(ACC_PUBLIC,
Type.getType("I"),
"_counter",
cp);
cg.addField(fg.getField());
}
Method[] ms = cg.getMethods();
for (int j = 0; j < ms.length; ++j) {
MethodGen mg = new MethodGen(ms[j], cg.getClassName(), cp);
if (!mg.getName().equals("<init>") && !mg.isStatic()
&& !mg.isAbstract() && !mg.isNative())
{
if (mg.getInstructionList() != null) {
InstructionList il = new InstructionList();
il.append(new ALOAD(0));
il.append(new ALOAD(0));
il.append(new GETFIELD(cp.addFieldref(name, "_counter", "I")));
il.append(new ICONST(1));
il.append(new IADD());
il.append(new PUTFIELD(cp.addFieldref(name, "_counter", "I")));
mg.getInstructionList().insert(il);
mg.setMaxStack(Math.max(mg.getMaxStack(), 2));
boolean lv = ms[j].getLocalVariableTable() == null;
boolean ln = ms[j].getLineNumberTable() == null;
if (lv) {
mg.removeLocalVariables();
}
if (ln) {
mg.removeLineNumbers();
}
cg.replaceMethod(ms[j], mg.getMethod());
}
}
}
return cg.getJavaClass().getBytes();
}
示例8: ignoreExceptionEdge
import org.apache.bcel.generic.GETFIELD; //导入依赖的package包/类
public boolean ignoreExceptionEdge(Edge edge, Lock resource, ConstantPoolGen cpg) {
try {
Location location = cfg.getExceptionThrowerLocation(edge);
if (DEBUG) {
System.out.println("Exception thrower location: " + location);
}
Instruction ins = location.getHandle().getInstruction();
if (ins instanceof GETFIELD) {
GETFIELD insGetfield = (GETFIELD) ins;
String fieldName = insGetfield.getFieldName(cpg);
if (DEBUG) {
System.out.println("Inspecting GETFIELD of " + fieldName + " at " + location);
}
// Ignore exceptions from getfield instructions where the
// object reference is known not to be null
if (fieldName.equals("lock"))
return true;
IsNullValueFrame frame = isNullDataflow.getFactAtLocation(location);
if (!frame.isValid())
return false;
IsNullValue receiver = frame.getInstance(ins, cpg);
boolean notNull = receiver.isDefinitelyNotNull();
if (DEBUG && notNull) {
System.out.println("Ignoring exception from non-null GETFIELD");
}
return notNull;
} else if (ins instanceof InvokeInstruction) {
InvokeInstruction iins = (InvokeInstruction) ins;
String methodName = iins.getMethodName(cpg);
// System.out.println("Method " + methodName);
if (methodName.startsWith("access$"))
return true;
if (methodName.equals("readLock") || methodName.equals("writeLock"))
return true;
if (methodName.equals("lock") || methodName.equals("unlock"))
return true;
}
if (DEBUG) {
System.out.println("FOUND Exception thrower at: " + location);
}
} catch (DataflowAnalysisException e) {
AnalysisContext.logError("Error while looking for exception edge", e);
}
return false;
}
示例9: isRead
import org.apache.bcel.generic.GETFIELD; //导入依赖的package包/类
/**
* Is the given instruction a read of a field?
*
* @param ins
* the Instruction to check
* @param cpg
* ConstantPoolGen of the method containing the instruction
* @return the Field if the instruction is a read of a field, null otherwise
*/
public static FieldAnnotation isRead(Instruction ins, ConstantPoolGen cpg) {
if (ins instanceof GETFIELD || ins instanceof GETSTATIC) {
FieldInstruction fins = (FieldInstruction) ins;
String className = fins.getClassName(cpg);
return new FieldAnnotation(className, fins.getName(cpg), fins.getSignature(cpg), fins instanceof GETSTATIC);
} else
return null;
}