Java Code Examples for org.apache.bcel.generic.Type#BOOLEAN
The following examples show how to use
org.apache.bcel.generic.Type#BOOLEAN .
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: LocalVariables.java From ApkToolPlus with Apache License 2.0 | 5 votes |
/** * Sets a new Type for the given local variable slot. */ public void set(int i, Type type){ if (type == Type.BYTE || type == Type.SHORT || type == Type.BOOLEAN || type == Type.CHAR){ throw new AssertionViolatedException("LocalVariables do not know about '"+type+"'. Use Type.INT instead."); } locals[i] = type; }
Example 2
Source File: LocalVariables.java From commons-bcel with Apache License 2.0 | 5 votes |
/** * Sets a new Type for the given local variable slot. * * @param slotIndex Target slot index. * @param type Type to save at the given slot index. */ public void set(final int slotIndex, final Type type) { // TODO could be package-protected? if (type == Type.BYTE || type == Type.SHORT || type == Type.BOOLEAN || type == Type.CHAR) { throw new AssertionViolatedException("LocalVariables do not know about '"+type+"'. Use Type.INT instead."); } locals[slotIndex] = type; }
Example 3
Source File: OperandStack.java From commons-bcel with Apache License 2.0 | 5 votes |
/** * Pushes a Type object onto the stack. */ public void push(final Type type) { if (type == null) { throw new AssertionViolatedException("Cannot push NULL onto OperandStack."); } if (type == Type.BOOLEAN || type == Type.CHAR || type == Type.BYTE || type == Type.SHORT) { throw new AssertionViolatedException("The OperandStack does not know about '"+type+"'; use Type.INT instead."); } if (slotsUsed() >= maxStack) { throw new AssertionViolatedException( "OperandStack too small, should have thrown proper Exception elsewhere. Stack: "+this); } stack.add(type); }
Example 4
Source File: NullnessConversationInstruction.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public Type getType(ConstantPoolGen cp) { return Type.BOOLEAN; }
Example 5
Source File: Pass3bVerifier.java From commons-bcel with Apache License 2.0 | 4 votes |
/** * Pass 3b implements the data flow analysis as described in the Java Virtual * Machine Specification, Second Edition. * Later versions will use LocalVariablesInfo objects to verify if the * verifier-inferred types and the class file's debug information (LocalVariables * attributes) match [TODO]. * * @see org.apache.bcel.verifier.statics.LocalVariablesInfo * @see org.apache.bcel.verifier.statics.Pass2Verifier#getLocalVariablesInfo(int) */ @Override public VerificationResult do_verify() { if (! myOwner.doPass3a(methodNo).equals(VerificationResult.VR_OK)) { return VerificationResult.VR_NOTYET; } // Pass 3a ran before, so it's safe to assume the JavaClass object is // in the BCEL repository. JavaClass jc; try { jc = Repository.lookupClass(myOwner.getClassName()); } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } final ConstantPoolGen constantPoolGen = new ConstantPoolGen(jc.getConstantPool()); // Init Visitors final InstConstraintVisitor icv = new InstConstraintVisitor(); icv.setConstantPoolGen(constantPoolGen); final ExecutionVisitor ev = new ExecutionVisitor(); ev.setConstantPoolGen(constantPoolGen); final Method[] methods = jc.getMethods(); // Method no "methodNo" exists, we ran Pass3a before on it! try{ final MethodGen mg = new MethodGen(methods[methodNo], myOwner.getClassName(), constantPoolGen); icv.setMethodGen(mg); ////////////// DFA BEGINS HERE //////////////// if (! (mg.isAbstract() || mg.isNative()) ) { // IF mg HAS CODE (See pass 2) final ControlFlowGraph cfg = new ControlFlowGraph(mg); // Build the initial frame situation for this method. final Frame f = new Frame(mg.getMaxLocals(),mg.getMaxStack()); if ( !mg.isStatic() ) { if (mg.getName().equals(Const.CONSTRUCTOR_NAME)) { Frame.setThis(new UninitializedObjectType(ObjectType.getInstance(jc.getClassName()))); f.getLocals().set(0, Frame.getThis()); } else{ Frame.setThis(null); f.getLocals().set(0, ObjectType.getInstance(jc.getClassName())); } } final Type[] argtypes = mg.getArgumentTypes(); int twoslotoffset = 0; for (int j=0; j<argtypes.length; j++) { if (argtypes[j] == Type.SHORT || argtypes[j] == Type.BYTE || argtypes[j] == Type.CHAR || argtypes[j] == Type.BOOLEAN) { argtypes[j] = Type.INT; } f.getLocals().set(twoslotoffset + j + (mg.isStatic()?0:1), argtypes[j]); if (argtypes[j].getSize() == 2) { twoslotoffset++; f.getLocals().set(twoslotoffset + j + (mg.isStatic()?0:1), Type.UNKNOWN); } } circulationPump(mg,cfg, cfg.contextOf(mg.getInstructionList().getStart()), f, icv, ev); } } catch (final VerifierConstraintViolatedException ce) { ce.extendMessage("Constraint violated in method '"+methods[methodNo]+"':\n",""); return new VerificationResult(VerificationResult.VERIFIED_REJECTED, ce.getMessage()); } catch (final RuntimeException re) { // These are internal errors final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); re.printStackTrace(pw); throw new AssertionViolatedException("Some RuntimeException occured while verify()ing class '"+jc.getClassName()+ "', method '"+methods[methodNo]+"'. Original RuntimeException's stack trace:\n---\n"+sw+"---\n", re); } return VerificationResult.VR_OK; }