org.apache.bcel.generic.ANEWARRAY Java Examples

The following examples show how to use org.apache.bcel.generic.ANEWARRAY. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Pass3aVerifier.java    From commons-bcel with Apache License 2.0 6 votes vote down vote up
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
@Override
public void visitANEWARRAY(final ANEWARRAY o) {
    indexValid(o, o.getIndex());
    final Constant c = constantPoolGen.getConstant(o.getIndex());
    if (!    (c instanceof ConstantClass)) {
        constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
    }
    final Type t = o.getType(constantPoolGen);
    if (t instanceof ArrayType) {
        final int dimensions = ((ArrayType) t).getDimensions();
        if (dimensions > Const.MAX_ARRAY_DIMENSIONS) {
            constraintViolated(o,
                "Not allowed to create an array with more than "+ Const.MAX_ARRAY_DIMENSIONS + " dimensions;"+
                " actual: " + dimensions);
        }
    }
}
 
Example #2
Source File: TaintFrameModelingVisitor.java    From Android_Code_Arbiter with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void visitANEWARRAY(ANEWARRAY obj) {
    try {
        getFrame().popValue();
        if (FindSecBugsGlobalConfig.getInstance().isDebugTaintState()) {
            pushSafeDebug("new " + obj.getLoadClassType(cpg).getClassName() + "[]");
        } else {
            pushSafe();
        }
    } catch (DataflowAnalysisException ex) {
        throw new InvalidBytecodeException("Array length not in the stack", ex);
    }
}
 
Example #3
Source File: JavaBuilder.java    From luaj with MIT License 5 votes vote down vote up
public void loadArrayArgs(int pc, int firstslot, int nargs) {
	append(new PUSH(cp, nargs));
	append(new ANEWARRAY(cp.addClass(STR_LUAVALUE)));
	for ( int i=0; i<nargs; i++ ) {
		append(InstructionConstants.DUP);
		append(new PUSH(cp, i));
		loadLocal(pc, firstslot++);
		append(new AASTORE());
	}	
}
 
Example #4
Source File: IsNullValueFrameModelingVisitor.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void visitANEWARRAY(ANEWARRAY obj) {
    modelNormalInstruction(obj, getNumWordsConsumed(obj), 0);
    produce(IsNullValue.nonNullValue());
}