Examples of AssertionViolatedException


Examples of org.apache.bcel.verifier.exc.AssertionViolatedException

        }
      }
    }
      } catch (ClassNotFoundException e) {
    // FIXME: maybe not the best way to handle this
    throw new AssertionViolatedException("Missing class: " + e.toString());
      }
  }
View Full Code Here

Examples of org.apache.bcel.verifier.exc.AssertionViolatedException

    if ( ! Repository.instanceOf(objref_classname, theClass) ){
      constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theClass+"' as expected.");
   
      } catch (ClassNotFoundException e) {
    // FIXME: maybe not the best way to handle this
    throw new AssertionViolatedException("Missing class: " + e.toString());
      }
  }
View Full Code Here

Examples of org.apache.bcel.verifier.exc.AssertionViolatedException

    //visitCPInstruction(CPInstruction) has been called before.
    //visitLoadClass(LoadClass) has been called before.
   
    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;
View Full Code Here

Examples of org.apache.bcel.verifier.exc.AssertionViolatedException

            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.");
      }
      // TODO: This can possibly only be checked using Staerk-et-al's "set-of-object types", not
      // using "wider cast object types" created during verification.
      // Comment it out if you encounter problems. See also the analogon at visitPUTSTATIC.
      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.");
      }
    }
   
    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.");
        }
      }
    }

    // TODO: Could go into Pass 3a.
    if (f.isStatic()){
      constraintViolated(o, "Referenced field '"+f+"' is static which it shouldn't be.");
    }

      } catch (ClassNotFoundException e) {
    // FIXME: maybe not the best way to handle this
    throw new AssertionViolatedException("Missing class: " + e.toString());
      }
  }
View Full Code Here

Examples of org.apache.bcel.verifier.exc.AssertionViolatedException

            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.");
      }
      // TODO: This can possibly only be checked using Staerk-et-al's "set-of-object types", not
      // using "wider cast object types" created during verification.
      // Comment it out if you encounter problems. See also the analogon at visitPUTFIELD.
      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.");
      }
    }
    // TODO: Interface fields may be assigned to only once. (Hard to implement in
    //       JustIce's execution model). This may only happen in <clinit>, see Pass 3a.

      } catch (ClassNotFoundException e) {
    // FIXME: maybe not the best way to handle this
    throw new AssertionViolatedException("Missing class: " + e.toString());
      }
  }
View Full Code Here

Examples of org.apache.bcel.verifier.exc.AssertionViolatedException

  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!");
    }
    // Other constraints such as non-allowed overlapping subroutines are enforced
    // while building the Subroutines data structure.
  }
View Full Code Here

Examples of org.apache.bcel.verifier.exc.AssertionViolatedException

     * Sets the leaving RET instruction. Must be invoked after all instructions are added.
     * Must not be invoked for top-level 'subroutine'.
     */
    void setLeavingRET(){
      if (localVariable == UNSET){
        throw new AssertionViolatedException("setLeavingRET() called for top-level 'subroutine' or forgot to set local variable first.");
      }
      Iterator iter = instructions.iterator();
      InstructionHandle ret = null;
      while(iter.hasNext()){
        InstructionHandle actual = (InstructionHandle) iter.next();
View Full Code Here

Examples of org.apache.bcel.verifier.exc.AssertionViolatedException

    /*
     * Refer to the Subroutine interface for documentation.
     */
    public InstructionHandle[] getEnteringJsrInstructions(){
      if (this == TOPLEVEL) {
        throw new AssertionViolatedException("getLeavingRET() called on top level pseudo-subroutine.");
      }
      InstructionHandle[] jsrs = new InstructionHandle[theJSRs.size()];
      return (InstructionHandle[]) (theJSRs.toArray(jsrs));
    }
View Full Code Here

Examples of org.apache.bcel.verifier.exc.AssertionViolatedException

    /**
     * Adds a new JSR or JSR_W that has this subroutine as its target.
     */
    public void addEnteringJsrInstruction(InstructionHandle jsrInst){
      if ( (jsrInst == null) || (! (jsrInst.getInstruction() instanceof JsrInstruction))){
        throw new AssertionViolatedException("Expecting JsrInstruction InstructionHandle.");
      }
      if (localVariable == UNSET){
        throw new AssertionViolatedException("Set the localVariable first!");
      }
      else{
        // Something is wrong when an ASTORE is targeted that does not operate on the same local variable than the rest of the
        // JsrInstruction-targets and the RET.
        // (We don't know out leader here so we cannot check if we're really targeted!)
        if (localVariable != ((ASTORE) (((JsrInstruction) jsrInst.getInstruction()).getTarget().getInstruction())).getIndex()){
          throw new AssertionViolatedException("Setting a wrong JsrInstruction.");
        }
      }
      theJSRs.add(jsrInst);
    }
View Full Code Here

Examples of org.apache.bcel.verifier.exc.AssertionViolatedException

    /*
     * Refer to the Subroutine interface for documentation.
     */
    public InstructionHandle getLeavingRET(){
      if (this == TOPLEVEL) {
        throw new AssertionViolatedException("getLeavingRET() called on top level pseudo-subroutine.");
      }
      return theRET;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.