com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException
AssertionViolatedException is described in the javadoc comments as:
Instances of this class should never be thrown. When such an instance is thrown, this is due to an INTERNAL ERROR of BCEL's class file verifier "JustIce".
version: $Id: AssertionViolatedException.java,v 1.2 2003/10/07 07:38:12 rameshm Exp $ author: Enver Haase
Where is this exception thrown?
Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.
- The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Cannot push NULL onto OperandStack.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.OperandStack.push(Type) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Could not load all the super classes of ' ... ' and ' ... '.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.LocalVariables.merge(LocalVariables, int) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Field not found?!?' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitGETFIELD(GETFIELD) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Field not found?!?' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitPUTFIELD(PUTFIELD) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Field not found?!?' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitPUTSTATIC(PUTSTATIC) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Huh?! Constant pool index of instruction ' ... ' illegal? Pass 3a should have checked this!' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitCPInstruction(CPInstruction) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: In this JustIce verification pass there should not occur an illegal instruction such as BREAKPOINT.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitBREAKPOINT(BREAKPOINT) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP1.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitIMPDEP1(IMPDEP1) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP2.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitIMPDEP2(IMPDEP2) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: InstructionContext requested for an InstructionHandle that's not known!' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.ControlFlowGraph.contextOf(InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: LocalVariables do not know about ' ... '. Use Type.INT instead.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.LocalVariables.set(int, Type) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Merging LocalVariables of different size?!? From different methods or what?!?' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.LocalVariables.merge(LocalVariables) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Method number out of range.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.statics.Pass2Verifier.getLocalVariablesInfo(int) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: More RET than JSR in execution chain?!' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.Pass3bVerifier.circulationPump(ControlFlowGraph, InstructionContext, Frame, InstConstraintVisitor, ExecutionVisitor) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: NEW.getType() returning a non-reference type?!' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitNEW(NEW) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Oops: RET expecting a target!' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitRET(RET) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: OperandStack too small, should have thrown proper Exception elsewhere. Stack: ...' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.OperandStack.push(Type) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: RET ' ... ' info inconsistent: jump back to ' ... ' or ' ... '?' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.Pass3bVerifier.circulationPump(ControlFlowGraph, InstructionContext, Frame, InstConstraintVisitor, ExecutionVisitor) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: RET without a JSR before in ExecutionChain?! EC: ' ... '.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.Pass3bVerifier.circulationPump(ControlFlowGraph, InstructionContext, Frame, InstConstraintVisitor, ExecutionVisitor) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Slot number for local variable information out of range.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.statics.LocalVariablesInfo.add(int, String, int, int, Type) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Slot number for local variable information out of range.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.statics.LocalVariablesInfo.getLocalVariableInfo(int) - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Some RuntimeException occured while verify()ing class ' ... ', method ' ... '. Original RuntimeException's stack trace:\n---\n ... ---\n' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.Pass3bVerifier.do_verify() - The message 'com.sun.org.apache.bcel.internal.verifier.exc.AssertionViolatedException: Subroutine requested for an InstructionHandle that is not a leader of a subroutine.' is thrown within the method:
com.sun.org.apache.bcel.internal.verifier.structurals.Subroutines.getSubroutine(InstructionHandle)
How is this exception thrown?
The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.
Any source code quoted in this section is subject to the Java Research License unless stated otherwise.
com.sun.org.apache.bcel.internal.verifier.structurals.OperandStack.push(Type)
/** * Pushes a Type object onto the stack. */ public void push(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); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.LocalVariables.merge(LocalVariables, int)
/** * Merges a single local variable. * * @see #merge(LocalVariables) */ private void merge(LocalVariables lv, int i) { if ((!(locals[i] instanceof UninitializedObjectType)) && (lv.locals[i] instanceof UninitializedObjectType)) { throw new StructuralCodeConstraintException('Backwards branch with an uninitialized object in the local variables detected.'); } if ((!(locals[i].equals(lv.locals[i]))) && (locals[i] instanceof UninitializedObjectType) && (lv.locals[i] instanceof UninitializedObjectType)) { throw new StructuralCodeConstraintException('Backwards branch with an uninitialized object in the local variables detected.'); } if (locals[i] instanceof UninitializedObjectType) { if (!(lv.locals[i] instanceof UninitializedObjectType)) { locals[i] = ((UninitializedObjectType) locals[i]).getInitialized(); } } if ((locals[i] instanceof ReferenceType) && (lv.locals[i] instanceof ReferenceType)) { if (!locals[i].equals(lv.locals[i])) { Type sup = ((ReferenceType) locals[i]).firstCommonSuperclass((ReferenceType) (lv.locals[i])); if (sup != null) { locals[i] = sup; } else { throw new AssertionViolatedException('Could not load all the super classes of '' + locals[i] + '' and '' + lv.locals[i] + ''.'); } } } else { if (!(locals[i].equals(lv.locals[i]))) { locals[i] = Type.UNKNOWN; } } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitGETFIELD(GETFIELD)
/** * Ensures the specific preconditions of the said instruction. */ public void visitGETFIELD(GETFIELD o) { Type objectref = stack().peek(); if (!((objectref instanceof ObjectType) || (objectref == Type.NULL))) { constraintViolated(o, 'Stack top should be an object reference that's not an array reference, but is '' + objectref + ''.'); } String field_name = o.getFieldName(cpg); JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName()); Field[] fields = jc.getFields(); Field f = null; for (int i = 0; i < fields.length; i++) { if (fields[i].getName().equals(field_name)) { f = fields[i]; break; } } if (f == null) { throw new AssertionViolatedException('Field not found?!?'); } if (f.isProtected()) { ObjectType classtype = o.getClassType(cpg); ObjectType curr = new ObjectType(mg.getClassName()); if (classtype.equals(curr) || curr.subclassOf(classtype)) { Type t = stack().peek(); if (t == Type.NULL) { return; } if (!(t instanceof ObjectType)) { constraintViolated(o, 'The 'objectref' must refer to an object that's not an array. Found instead: '' + t + ''.'); } ObjectType objreftype = (ObjectType) t; if (!(objreftype.equals(curr) || objreftype.subclassOf(curr))) { } } } if (f.isStatic()) { constraintViolated(o, 'Referenced field '' + f + '' is static which it shouldn't be.'); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitPUTFIELD(PUTFIELD)
/** * Ensures the specific preconditions of the said instruction. */ public void visitPUTFIELD(PUTFIELD o) { Type objectref = stack().peek(1); if (!((objectref instanceof ObjectType) || (objectref == Type.NULL))) { constraintViolated(o, 'Stack next-to-top should be an object reference that's not an array reference, but is '' + objectref + ''.'); } String field_name = o.getFieldName(cpg); JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName()); Field[] fields = jc.getFields(); Field f = null; for (int i = 0; i < fields.length; i++) { if (fields[i].getName().equals(field_name)) { f = fields[i]; break; } } if (f == null) { throw new AssertionViolatedException('Field not found?!?'); } Type value = stack().peek(); Type t = Type.getType(f.getSignature()); Type shouldbe = t; if (shouldbe == Type.BOOLEAN || shouldbe == Type.BYTE || shouldbe == Type.CHAR || shouldbe == Type.SHORT) { shouldbe = Type.INT; } if (t instanceof ReferenceType) { ReferenceType rvalue = null; if (value instanceof ReferenceType) { rvalue = (ReferenceType) value; referenceTypeIsInitialized(o, rvalue); } else { constraintViolated(o, 'The stack top type '' + value + '' is not of a reference type as expected.'); } } else { if (shouldbe != value) { constraintViolated(o, 'The stack top type '' + value + '' is not of type '' + shouldbe + '' as expected.'); } } if (f.isProtected()) { ObjectType classtype = o.getClassType(cpg); ObjectType curr = new ObjectType(mg.getClassName()); if (classtype.equals(curr) || curr.subclassOf(classtype)) { Type tp = stack().peek(1); if (tp == Type.NULL) { return; } if (!(tp instanceof ObjectType)) { constraintViolated(o, 'The 'objectref' must refer to an object that's not an array. Found instead: '' + tp + ''.'); } ObjectType objreftype = (ObjectType) tp; if (!(objreftype.equals(curr) || objreftype.subclassOf(curr))) { constraintViolated(o, 'The referenced field has the ACC_PROTECTED modifier, and it's a member of the current class or a superclass of the current class. However, the referenced object type '' + stack().peek() + '' is not the current class or a subclass of the current class.'); } } } if (f.isStatic()) { constraintViolated(o, 'Referenced field '' + f + '' is static which it shouldn't be.'); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitPUTSTATIC(PUTSTATIC)
/** * Ensures the specific preconditions of the said instruction. */ public void visitPUTSTATIC(PUTSTATIC o) { String field_name = o.getFieldName(cpg); JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName()); Field[] fields = jc.getFields(); Field f = null; for (int i = 0; i < fields.length; i++) { if (fields[i].getName().equals(field_name)) { f = fields[i]; break; } } if (f == null) { throw new AssertionViolatedException('Field not found?!?'); } Type value = stack().peek(); Type t = Type.getType(f.getSignature()); Type shouldbe = t; if (shouldbe == Type.BOOLEAN || shouldbe == Type.BYTE || shouldbe == Type.CHAR || shouldbe == Type.SHORT) { shouldbe = Type.INT; } if (t instanceof ReferenceType) { ReferenceType rvalue = null; if (value instanceof ReferenceType) { rvalue = (ReferenceType) value; referenceTypeIsInitialized(o, rvalue); } else { constraintViolated(o, 'The stack top type '' + value + '' is not of a reference type as expected.'); } if (!(rvalue.isAssignmentCompatibleWith(shouldbe))) { constraintViolated(o, 'The stack top type '' + value + '' is not assignment compatible with '' + shouldbe + ''.'); } } else { if (shouldbe != value) { constraintViolated(o, 'The stack top type '' + value + '' is not of type '' + shouldbe + '' as expected.'); } } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitCPInstruction(CPInstruction)
/** * Ensures the general preconditions of a CPInstruction instance. */ public void visitCPInstruction(CPInstruction o) { int idx = o.getIndex(); if ((idx < 0) || (idx >= cpg.getSize())) { throw new AssertionViolatedException('Huh?! Constant pool index of instruction '' + o + '' illegal? Pass 3a should have checked this!'); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitBREAKPOINT(BREAKPOINT)
/** * Ensures the specific preconditions of the said instruction. */ public void visitBREAKPOINT(BREAKPOINT o) { throw new AssertionViolatedException('In this JustIce verification pass there should not occur an illegal instruction such as BREAKPOINT.'); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitIMPDEP1(IMPDEP1)
/** * Ensures the specific preconditions of the said instruction. */ public void visitIMPDEP1(IMPDEP1 o) { throw new AssertionViolatedException('In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP1.'); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitIMPDEP2(IMPDEP2)
/** * Ensures the specific preconditions of the said instruction. */ public void visitIMPDEP2(IMPDEP2 o) { throw new AssertionViolatedException('In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP2.'); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.ControlFlowGraph.contextOf(InstructionHandle)
/** * Returns the InstructionContext of a given instruction. */ public InstructionContext contextOf(InstructionHandle inst) { InstructionContext ic = (InstructionContext) instructionContexts.get(inst); if (ic == null) { throw new AssertionViolatedException('InstructionContext requested for an InstructionHandle that's not known!'); } return ic; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.LocalVariables.set(int, Type)
/** * 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; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.LocalVariables.merge(LocalVariables)
/** * Merges two local variables sets as described in the Java Virtual Machine Specification, * Second Edition, section 4.9.2, page 146. */ public void merge(LocalVariables lv) { if (this.locals.length != lv.locals.length) { throw new AssertionViolatedException('Merging LocalVariables of different size?!? From different methods or what?!?'); } for (int i = 0; i < locals.length; i++) { merge(lv, i); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.statics.Pass2Verifier.getLocalVariablesInfo(int)
/** * Returns a LocalVariablesInfo object containing information * about the usage of the local variables in the Code attribute * of the said method or <B>null</B> if the class file this * Pass2Verifier operates on could not be pass-2-verified correctly. * The method number method_nr is the method you get using * <B>Repository.lookupClass(myOwner.getClassname()).getMethods()[method_nr];</B>. * You should not add own information. Leave that to JustIce. */ public LocalVariablesInfo getLocalVariablesInfo(int method_nr) { if (this.verify() != VerificationResult.VR_OK) return null; if (method_nr < 0 || method_nr >= localVariablesInfos.length) { throw new AssertionViolatedException('Method number out of range.'); } return localVariablesInfos[method_nr]; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.Pass3bVerifier.circulationPump(ControlFlowGraph, InstructionContext, Frame, InstConstraintVisitor, ExecutionVisitor)
/** * Whenever the outgoing frame * situation of an InstructionContext changes, all its successors are * put [back] into the queue [as if they were unvisited]. * The proof of termination is about the existence of a * fix point of frame merging. */ private void circulationPump(ControlFlowGraph cfg, InstructionContext start, Frame vanillaFrame, InstConstraintVisitor icv, ExecutionVisitor ev) { final Random random = new Random(); InstructionContextQueue icq = new InstructionContextQueue(); start.execute(vanillaFrame, new ArrayList(), icv, ev); icq.add(start, new ArrayList()); while (!icq.isEmpty()) { InstructionContext u; ArrayList ec; if (!DEBUG) { int r = random.nextInt(icq.size()); u = icq.getIC(r); ec = icq.getEC(r); icq.remove(r); } else { u = icq.getIC(0); ec = icq.getEC(0); icq.remove(0); } ArrayList oldchain = (ArrayList) (ec.clone()); ArrayList newchain = (ArrayList) (ec.clone()); newchain.add(u); if ((u.getInstruction().getInstruction()) instanceof RET) { RET ret = (RET) (u.getInstruction().getInstruction()); ReturnaddressType t = (ReturnaddressType) u.getOutFrame(oldchain).getLocals().get(ret.getIndex()); InstructionContext theSuccessor = cfg.contextOf(t.getTarget()); InstructionContext lastJSR = null; int skip_jsr = 0; for (int ss = oldchain.size() - 1; ss >= 0; ss--) { if (skip_jsr < 0) { throw new AssertionViolatedException('More RET than JSR in execution chain?!'); } if (((InstructionContext) oldchain.get(ss)).getInstruction().getInstruction() instanceof JsrInstruction) { if (skip_jsr == 0) { lastJSR = (InstructionContext) oldchain.get(ss); break; } else { skip_jsr--; } } if (((InstructionContext) oldchain.get(ss)).getInstruction().getInstruction() instanceof RET) { skip_jsr++; } } if (lastJSR == null) { throw new AssertionViolatedException('RET without a JSR before in ExecutionChain?! EC: '' + oldchain + ''.'); } JsrInstruction jsr = (JsrInstruction) (lastJSR.getInstruction().getInstruction()); if (theSuccessor != (cfg.contextOf(jsr.physicalSuccessor()))) { throw new AssertionViolatedException('RET '' + u.getInstruction() + '' info inconsistent: jump back to '' + theSuccessor + '' or '' + cfg.contextOf(jsr.physicalSuccessor()) + ''?'); } if (theSuccessor.execute(u.getOutFrame(oldchain), newchain, icv, ev)) { icq.add(theSuccessor, (ArrayList) newchain.clone()); } } else { InstructionContext[] succs = u.getSuccessors(); for (int s = 0; s < succs.length; s++) { InstructionContext v = succs[s]; if (v.execute(u.getOutFrame(oldchain), newchain, icv, ev)) { icq.add(v, (ArrayList) newchain.clone()); } } } ExceptionHandler[] exc_hds = u.getExceptionHandlers(); for (int s = 0; s < exc_hds.length; s++) { InstructionContext v = cfg.contextOf(exc_hds[s].getHandlerStart()); if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack(u.getOutFrame(oldchain).getStack().maxStack(), (exc_hds[s].getExceptionType() == null ? Type.THROWABLE : exc_hds[s].getExceptionType()))), new ArrayList(), icv, ev)) { icq.add(v, new ArrayList()); } } } InstructionHandle ih = start.getInstruction(); do { if ((ih.getInstruction() instanceof ReturnInstruction) && (!(cfg.isDead(ih)))) { InstructionContext ic = cfg.contextOf(ih); Frame f = ic.getOutFrame(new ArrayList()); LocalVariables lvs = f.getLocals(); for (int i = 0; i < lvs.maxLocals(); i++) { if (lvs.get(i) instanceof UninitializedObjectType) { this.addMessage('Warning: ReturnInstruction '' + ic + '' may leave method with an uninitialized object in the local variables array '' + lvs + ''.'); } } OperandStack os = f.getStack(); for (int i = 0; i < os.size(); i++) { if (os.peek(i) instanceof UninitializedObjectType) { this.addMessage('Warning: ReturnInstruction '' + ic + '' may leave method with an uninitialized object on the operand stack '' + os + ''.'); } } } } while ((ih = ih.getNext()) != null); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitNEW(NEW)
/** * Ensures the specific preconditions of the said instruction. */ public void visitNEW(NEW o) { Type t = o.getType(cpg); if (!(t instanceof ReferenceType)) { throw new AssertionViolatedException('NEW.getType() returning a non-reference type?!'); } if (!(t instanceof ObjectType)) { constraintViolated(o, 'Expecting a class type (ObjectType) to work on. Found: '' + t + ''.'); } ObjectType obj = (ObjectType) t; if (!obj.referencesClass()) { constraintViolated(o, 'Expecting a class type (ObjectType) to work on. Found: '' + obj + ''.'); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.InstConstraintVisitor.visitRET(RET)
/** * Ensures the specific preconditions of the said instruction. */ public void visitRET(RET o) { if (!(locals().get(o.getIndex()) instanceof ReturnaddressType)) { constraintViolated(o, 'Expecting a ReturnaddressType in local variable ' + o.getIndex() + '.'); } if (locals().get(o.getIndex()) == ReturnaddressType.NO_TARGET) { throw new AssertionViolatedException('Oops: RET expecting a target!'); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.statics.LocalVariablesInfo.add(int, String, int, int, Type)
/** * Adds information about the local variable in slot 'slot'. Automatically * adds information for slot+1 if 't' is Type.LONG or Type.DOUBLE. * @throws LocalVariableInfoInconsistentException if the new information conflicts * with already gathered information. */ public void add(int slot, String name, int startpc, int length, Type t) throws LocalVariableInfoInconsistentException { if (slot < 0 || slot >= localVariableInfos.length) { throw new AssertionViolatedException('Slot number for local variable information out of range.'); } localVariableInfos[slot].add(name, startpc, length, t); if (t == Type.LONG) localVariableInfos[slot + 1].add(name, startpc, length, LONG_Upper.theInstance()); if (t == Type.DOUBLE) localVariableInfos[slot + 1].add(name, startpc, length, DOUBLE_Upper.theInstance()); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.statics.LocalVariablesInfo.getLocalVariableInfo(int)
/** Returns the LocalVariableInfo for the given slot. */ public LocalVariableInfo getLocalVariableInfo(int slot) { if (slot < 0 || slot >= localVariableInfos.length) { throw new AssertionViolatedException('Slot number for local variable information out of range.'); } return localVariableInfos[slot]; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.Pass3bVerifier.do_verify()
/** * 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 com.sun.org.apache.bcel.internal.verifier.statics.LocalVariablesInfo * @see com.sun.org.apache.bcel.internal.verifier.statics.Pass2Verifier#getLocalVariablesInfo(int) */ public VerificationResult do_verify() { if (!myOwner.doPass3a(method_no).equals(VerificationResult.VR_OK)) { return VerificationResult.VR_NOTYET; } JavaClass jc = Repository.lookupClass(myOwner.getClassName()); ConstantPoolGen constantPoolGen = new ConstantPoolGen(jc.getConstantPool()); InstConstraintVisitor icv = new InstConstraintVisitor(); icv.setConstantPoolGen(constantPoolGen); ExecutionVisitor ev = new ExecutionVisitor(); ev.setConstantPoolGen(constantPoolGen); Method[] methods = jc.getMethods(); try { MethodGen mg = new MethodGen(methods[method_no], myOwner.getClassName(), constantPoolGen); icv.setMethodGen(mg); if (!(mg.isAbstract() || mg.isNative())) { ControlFlowGraph cfg = new ControlFlowGraph(mg); Frame f = new Frame(mg.getMaxLocals(), mg.getMaxStack()); if (!mg.isStatic()) { if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)) { f._this = new UninitializedObjectType(new ObjectType(jc.getClassName())); f.getLocals().set(0, f._this); } else { f._this = null; f.getLocals().set(0, new ObjectType(jc.getClassName())); } } 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(cfg, cfg.contextOf(mg.getInstructionList().getStart()), f, icv, ev); } } catch (VerifierConstraintViolatedException ce) { ce.extendMessage('Constraint violated in method '' + methods[method_no] + '':\n', ''); return new VerificationResult(VerificationResult.VERIFIED_REJECTED, ce.getMessage()); } catch (RuntimeException re) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); re.printStackTrace(pw); throw new AssertionViolatedException('Some RuntimeException occured while verify()ing class '' + jc.getClassName() + '', method '' + methods[method_no] + ''. Original RuntimeException's stack trace:\n---\n' + sw + '---\n'); } return VerificationResult.VR_OK; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.verifier.structurals.Subroutines.getSubroutine(InstructionHandle)
/** * Returns the Subroutine object associated with the given * leader (that is, the first instruction of the subroutine). * You must not use this to get the top-level instructions * modeled as a Subroutine object. * * @see #getTopLevel() */ public Subroutine getSubroutine(InstructionHandle leader) { Subroutine ret = (Subroutine) subroutines.get(leader); if (ret == null) { throw new AssertionViolatedException('Subroutine requested for an InstructionHandle that is not a leader of a subroutine.'); } if (ret == TOPLEVEL) { throw new AssertionViolatedException('TOPLEVEL special subroutine requested; use getTopLevel().'); } return ret; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Comments
Post a Comment