public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); _right.translate(classGen, methodGen); il.append(new CHECKCAST(cpg.addClass(_className))); } }
@Override public void visitCHECKCAST(CHECKCAST obj) { try { Type t = getFrame().popValue(); if (t instanceof NullType) { pushValue(t); } else { pushValue(obj.getType(getCPG())); } } catch (DataflowAnalysisException e) { throw new InvalidBytecodeException("Stack underflow for " + obj + ": " + e.getMessage()); } }
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ @Override public void visitCHECKCAST(final CHECKCAST 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+"'."); } }
@Override public void visitCHECKCAST(CHECKCAST obj) { // cast to a safe object type ObjectType objectType = obj.getLoadClassType(cpg); if (objectType == null) { return; } String objectTypeSignature = objectType.getSignature(); if(!taintConfig.isClassTaintSafe(objectTypeSignature)) { return; } try { getFrame().popValue(); pushSafe(); } catch (DataflowAnalysisException ex) { throw new InvalidBytecodeException("empty stack for checkcast", ex); } }
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ public void visitCHECKCAST(CHECKCAST 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+"'."); } }
@Override public void visitCHECKCAST(CHECKCAST obj) { // cast to a safe object type ObjectType objectType = obj.getLoadClassType(cpg); if (objectType == null) { return; } String objectTypeSignature = objectType.getSignature(); if(!taintConfig.isClassTaintSafe(objectTypeSignature)) { return; } try { getFrame().popValue(); pushSafe(); } catch (DataflowAnalysisException ex) { throw new InvalidBytecodeException("empty stack for checkcast", ex); } }
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(DOUBLE_CLASS))); il.append(new INVOKEVIRTUAL(cpg.addMethodref(DOUBLE_CLASS, DOUBLE_VALUE, DOUBLE_VALUE_SIG))); }
public ObjectType getLoadClassType(ConstantPoolGen cpg) { Type t = getType(cpg); if(t instanceof ArrayType) t = ((ArrayType) t).getBasicType(); return (t instanceof ObjectType)? (ObjectType) t : null; }
/** * Ensures the specific preconditions of the said instruction. */ @Override public void visitCHECKCAST(final CHECKCAST o) { // The objectref must be of type reference. final Type objectref = stack().peek(0); if (!(objectref instanceof ReferenceType)) { constraintViolated(o, "The 'objectref' is not of a ReferenceType but of type "+objectref+"."); } //else{ // referenceTypeIsInitialized(o, (ReferenceType) objectref); //} // The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the // current class (�3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant // pool item at the index must be a symbolic reference to a class, array, or interface type. final Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)) { constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'."); } }
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(BOOLEAN_CLASS))); il.append(new INVOKEVIRTUAL(cpg.addMethodref(BOOLEAN_CLASS, BOOLEAN_VALUE, BOOLEAN_VALUE_SIG))); }
public void visitCHECKCAST(CHECKCAST i) { Type type = i.getType(_cp); _out.println("il.append(_factory.createCheckCast(" + BCELifier.printType(type) + "));"); }
/** * Ensures the specific preconditions of the said instruction. */ public void visitCHECKCAST(CHECKCAST o){ // The objectref must be of type reference. Type objectref = stack().peek(0); if (!(objectref instanceof ReferenceType)){ constraintViolated(o, "The 'objectref' is not of a ReferenceType but of type "+objectref+"."); } else{ referenceTypeIsInitialized(o, (ReferenceType) objectref); } // The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the // current class (3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant // pool item at the index must be a symbolic reference to a class, array, or interface type. Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)){ constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'."); } }
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(RUNTIME_NODE_CLASS))); il.append(new GETFIELD(cpg.addFieldref(RUNTIME_NODE_CLASS, NODE_FIELD, NODE_FIELD_SIG))); }
@Override public ObjectType getLoadClassType( final ConstantPoolGen cpg ) { Type t = getType(cpg); if (t instanceof ArrayType) { t = ((ArrayType) t).getBasicType(); } return (t instanceof ObjectType) ? (ObjectType) t : null; }
/** * Translates an object of this type to its unboxed representation. */ public void translateUnBox(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); il.append(new CHECKCAST(cpg.addClass(INTEGER_CLASS))); final int index = cpg.addMethodref(INTEGER_CLASS, INT_VALUE, INT_VALUE_SIG); il.append(new INVOKEVIRTUAL(index)); }
@Override public void visitCHECKCAST( final CHECKCAST i ) { final Type type = i.getType(_cp); _out.println("il.append(_factory.createCheckCast(" + BCELifier.printType(type) + "));"); }
/** * Translate a predicate expression. If non of the optimizations apply * then this translation pushes two references on the stack: a reference * to a newly created filter object and a reference to the predicate's * closure. See class <code>Step</code> for further details. */ public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); if (_nthPositionFilter || _nthDescendant) { _exp.translate(classGen, methodGen); } else if (isNodeValueTest() && (getParent() instanceof Step)) { _value.translate(classGen, methodGen); il.append(new CHECKCAST(cpg.addClass(STRING_CLASS))); il.append(new PUSH(cpg, ((EqualityExpr)_exp).getOp())); } else { translateFilter(classGen, methodGen); } } }
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ public void visitCHECKCAST(CHECKCAST o){ // It's possibly wrong to do so, but SUN's // ByteCode verifier seems to do (only) this, too. // TODO: One could use a sophisticated analysis here to check // if a type cannot possibly be cated to another and by // so doing predict the ClassCastException at run-time. stack().pop(); stack().push(o.getType(cpg)); }
"makeNodeSortRecord", "(II)" + NODE_SORT_RECORD_SIG))); il.append(DUP); il.append(new CHECKCAST(cpg.addClass(sortRecordClass)));
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitCHECKCAST(final CHECKCAST o) { // It's possibly wrong to do so, but SUN's // ByteCode verifier seems to do (only) this, too. // TODO: One could use a sophisticated analysis here to check // if a type cannot possibly be cated to another and by // so doing predict the ClassCastException at run-time. stack().pop(); stack().push(o.getType(cpg)); }