Java 类org.apache.bcel.generic.GETFIELD 实例源码

项目:parabuild-ci    文件:GETFIELDReference.java   
/**
 * @param aInstruction
 * @param aPoolGen
 */
public GETFIELDReference(
    GETFIELD aInstruction,
    ConstantPoolGen aPoolGen)
{
    super(aInstruction, aPoolGen);
}
项目:Android_Code_Arbiter    文件:TaintFrameModelingVisitor.java   
@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);
}
项目:cacheonix-core    文件:GETFIELDReference.java   
/**
 * @param aInstruction
 * @param aPoolGen
 */
public GETFIELDReference(
    GETFIELD aInstruction,
    ConstantPoolGen aPoolGen)
{
    super(aInstruction, aPoolGen);
}
项目:contribution    文件:GETFIELDReference.java   
/**
 * @param aInstruction
 * @param aPoolGen
 */
public GETFIELDReference(
    GETFIELD aInstruction,
    ConstantPoolGen aPoolGen)
{
    super(aInstruction, aPoolGen);
}
项目:findbugs-all-the-bugs    文件:FindRefComparison.java   
@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);
    }
}
项目:findbugs-all-the-bugs    文件:ValueNumberFrameModelingVisitor.java   
@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);
}
项目:findbugs-all-the-bugs    文件:IsNullValueFrameModelingVisitor.java   
@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);
    }

}
项目:FindBug-for-Domino-Designer    文件:FindRefComparison.java   
@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);
    }
}
项目:FindBug-for-Domino-Designer    文件:ValueNumberFrameModelingVisitor.java   
@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);
}
项目:FindBug-for-Domino-Designer    文件:IsNullValueFrameModelingVisitor.java   
@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);
    }

}
项目:parabuild-ci    文件:ReferenceVisitor.java   
/** @see org.apache.bcel.generic.Visitor */
public void visitGETFIELD(GETFIELD aGETFIELD)
{
    addFieldReference(
        new GETFIELDReference(aGETFIELD, mCurrentPoolGen));
}
项目:cacheonix-core    文件:ReferenceVisitor.java   
/** @see org.apache.bcel.generic.Visitor */
public void visitGETFIELD(GETFIELD aGETFIELD)
{
    addFieldReference(
        new GETFIELDReference(aGETFIELD, mCurrentPoolGen));
}
项目:annotation-tools    文件:BCELPerfTest.java   
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();
}
项目:contribution    文件:ReferenceVisitor.java   
/** @see org.apache.bcel.generic.Visitor */
public void visitGETFIELD(GETFIELD aGETFIELD)
{
    addFieldReference(
        new GETFIELDReference(aGETFIELD, mCurrentPoolGen));
}
项目:findbugs-all-the-bugs    文件:FindUnreleasedLock.java   
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;
        }
项目:FindBug-for-Domino-Designer    文件:FindUnreleasedLock.java   
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;
        }
项目:findbugs-all-the-bugs    文件:FieldAnnotation.java   
/**
 * 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;
}
项目:FindBug-for-Domino-Designer    文件:FieldAnnotation.java   
/**
 * 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;
}