/** * Expects an integer on the stack and pushes a boxed integer. * Boxed integers are represented by an instance of * <code>java.lang.Integer</code>. * * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo */ public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, ReferenceType type) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new NEW(cpg.addClass(INTEGER_CLASS))); il.append(DUP_X1); il.append(SWAP); il.append(new INVOKESPECIAL(cpg.addMethodref(INTEGER_CLASS, "<init>", "(I)V"))); }
public static boolean isNullCheck(InstructionHandle h, ConstantPoolGen cpg) { if (!(h.getInstruction() instanceof IFNONNULL)) { return false; } h = h.getNext(); final Instruction newInstruction = h.getInstruction(); if (!(newInstruction instanceof NEW)) { return false; } final ObjectType loadClassType = ((NEW) newInstruction).getLoadClassType(cpg); if (!"java.lang.NullPointerException".equals(loadClassType.getClassName())) { return false; } h = h.getNext(); return check(h, NULLCHECK1) || check(h, NULLCHECK2); }
@Override public void visitNEW(NEW obj) { // FIXME: type is technically "uninitialized" // However, we don't model that yet. pushValue(obj.getType(getCPG())); // We now have an exact type for this value. setTopOfStackIsExact(); }
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ public void visitNEW(NEW o){ indexValid(o, o.getIndex()); Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)){ constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'."); } else{ ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant( ((ConstantClass) c).getNameIndex() )); Type t = Type.getType("L"+cutf8.getBytes()+";"); if (t instanceof ArrayType){ constraintViolated(o, "NEW must not be used to create an array."); } } }
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ @Override public void visitNEW(final NEW o) { indexValid(o, o.getIndex()); final Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)) { constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'."); } else{ final ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant( ((ConstantClass) c).getNameIndex() )); final Type t = Type.getType("L"+cutf8.getBytes()+";"); if (t instanceof ArrayType) { constraintViolated(o, "NEW must not be used to create an array."); } } }
/** * Expects a boolean on the stack and pushes a boxed boolean. * Boxed booleans are represented by an instance of * <code>java.lang.Boolean</code>. * * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo */ public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, ReferenceType type) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new NEW(cpg.addClass(BOOLEAN_CLASS))); il.append(DUP_X1); il.append(SWAP); il.append(new INVOKESPECIAL(cpg.addMethodref(BOOLEAN_CLASS, "<init>", "(Z)V"))); }
@Override public ObjectType getLoadClassType( final ConstantPoolGen cpg ) { return (ObjectType) getType(cpg); }
} else if (ins instanceof NEW) { NEW i = (NEW) ins; ObjectType type = i.getLoadClassType(cpg); System.out.println(formatName(ins) + " " + type.toString()); } else if (ins instanceof LoadInstruction) {
/** * Expects a node on the stack and pushes a singleton node-set. Singleton * iterators are already started after construction. * * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo */ public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, NodeSetType type) { ConstantPoolGen cpg = classGen.getConstantPool(); InstructionList il = methodGen.getInstructionList(); // Create a new instance of SingletonIterator il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR))); il.append(DUP_X1); il.append(SWAP); final int init = cpg.addMethodref(SINGLETON_ITERATOR, "<init>", "(" + NODE_SIG +")V"); il.append(new INVOKESPECIAL(init)); }
public ObjectType getLoadClassType(ConstantPoolGen cpg) { return (ObjectType)getType(cpg); }
public static boolean isNullCheck(InstructionHandle h, ConstantPoolGen cpg) { if (!(h.getInstruction() instanceof IFNONNULL)) { return false; } h = h.getNext(); final Instruction newInstruction = h.getInstruction(); if (!(newInstruction instanceof NEW)) { return false; } final ObjectType loadClassType = ((NEW) newInstruction).getLoadClassType(cpg); if (!"java.lang.NullPointerException".equals(loadClassType.getClassName())) { return false; } h = h.getNext(); return check(h, NULLCHECK1) || check(h, NULLCHECK2); }
/** * Expects a double on the stack and pushes a boxed double. Boxed * double are represented by an instance of <code>java.lang.Double</code>. * * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo */ public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, ReferenceType type) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new NEW(cpg.addClass(DOUBLE_CLASS))); il.append(DUP_X2); il.append(DUP_X2); il.append(POP); il.append(new INVOKESPECIAL(cpg.addMethodref(DOUBLE_CLASS, "<init>", "(D)V"))); }
@Override public void visitNEW(NEW obj) { // FIXME: type is technically "uninitialized" // However, we don't model that yet. pushValue(obj.getType(getCPG())); // We now have an exact type for this value. setTopOfStackIsExact(); }
} else if (ins instanceof NEW) { NEW i = (NEW) ins; ObjectType type = i.getLoadClassType(cpg); System.out.println(formatName(ins) + " " + type.toString()); } else if (ins instanceof LoadInstruction) {
/** * Expects a node on the stack and pushes a boxed node. Boxed nodes * are represented by an instance of <code>org.apache.xalan.xsltc.dom.Node</code>. * * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo */ public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, ReferenceType type) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new NEW(cpg.addClass(RUNTIME_NODE_CLASS))); il.append(DUP_X1); il.append(SWAP); il.append(new PUSH(cpg, _type)); il.append(new INVOKESPECIAL(cpg.addMethodref(RUNTIME_NODE_CLASS, "<init>", "(II)V"))); }
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitNEW(final NEW o) { stack().push(new UninitializedObjectType((ObjectType) (o.getType(cpg)))); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */
@Override public void visitNEW(NEW obj) { Taint taint = new Taint(Taint.State.SAFE); ObjectType type = obj.getLoadClassType(cpg); taint.setRealInstanceClass(type); if (FindSecBugsGlobalConfig.getInstance().isDebugTaintState()) { taint.setDebugInfo("new " + type.getClassName() + "()"); } getFrame().pushValue(taint); }
il.append(new NEW(cpg.addClass(_className))); il.append(InstructionConstants.DUP);
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ public void visitNEW(NEW o){ stack().push(new UninitializedObjectType((ObjectType) (o.getType(cpg)))); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */
@Override public void visitNEW(NEW obj) { Taint taint = new Taint(Taint.State.SAFE); ObjectType type = obj.getLoadClassType(cpg); taint.setRealInstanceClass(type); if (FindSecBugsGlobalConfig.getInstance().isDebugTaintState()) { taint.setDebugInfo("new " + type.getClassName() + "()"); } getFrame().pushValue(taint); }