Examples of StructuralCodeConstraintException


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

                    {
                        try
                        {
                            if( !((ObjectType)returnedType).isAssignmentCompatibleWith(m.getReturnType()) )
                            {
                                throw new StructuralCodeConstraintException("Returned type "+returnedType+" does not match Method's return type "+m.getReturnType());
                            }
                        }
                        catch (Exception e)
                        {
                            //dont know what do do now, so raise RuntimeException
                            throw new RuntimeException(e);
                        }
                    }
                    else if( !returnedType.equals(m.getReturnType()) )
                    {
                        throw new StructuralCodeConstraintException("Returned type "+returnedType+" does not match Method's return type "+m.getReturnType());
                    }
                }
            }
        }while ((ih = ih.getNext()) != null);
       
View Full Code Here

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

   * StructuralCodeConstraintException.
   * @throws org.apache.bcel.verifier.exc.StructuralCodeConstraintException always.
   */
  private void constraintViolated(Instruction violator, String description){
    String fq_classname = violator.getClass().getName();
    throw new StructuralCodeConstraintException("Instruction "+ fq_classname.substring(fq_classname.lastIndexOf('.')+1) +" constraint violated: " + description);
  }
View Full Code Here

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

      InstructionHandle ret = null;
      while(iter.hasNext()){
        InstructionHandle actual = (InstructionHandle) iter.next();
        if (actual.getInstruction() instanceof RET){
          if (ret != null){
            throw new StructuralCodeConstraintException("Subroutine with more then one RET detected: '"+ret+"' and '"+actual+"'.");
          }
          else{
            ret = actual;
          }
        }
      }
      if (ret == null){
        throw new StructuralCodeConstraintException("Subroutine without a RET detected.");
      }
      if (((RET) ret.getInstruction()).getIndex() != localVariable){
        throw new StructuralCodeConstraintException("Subroutine uses '"+ret+"' which does not match the correct local variable '"+localVariable+"'.");
      }
      theRET = ret;
    }
View Full Code Here

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

      // BFS ended above.
      for (int i=0; i<all.length; i++){
        if (colors.get(all[i]) == BLACK){
          ((SubroutineImpl) (actual==all[0]?getTopLevel():getSubroutine(actual))).addInstruction(all[i]);
          if (instructions_assigned.contains(all[i])){
            throw new StructuralCodeConstraintException("Instruction '"+all[i]+"' is part of more than one subroutine (or of the top level and a subroutine).");
          }
          else{
            instructions_assigned.add(all[i]);
          }
        }
      }
      if (actual != all[0]){// If we don't deal with the top-level 'subroutine'
        ((SubroutineImpl) getSubroutine(actual)).setLeavingRET();
      }
    }
   
    // Now make sure no instruction of a Subroutine is protected by exception handling code
    // as is mandated by JustIces notion of subroutines.
    for (int i=0; i<handlers.length; i++){
      InstructionHandle _protected = handlers[i].getStartPC();
      while (_protected != handlers[i].getEndPC().getNext()){// Note the inclusive/inclusive notation of "generic API" exception handlers!
        Iterator subs = subroutines.values().iterator();
        while (subs.hasNext()){
          Subroutine sub = (Subroutine) subs.next();
          if (sub != subroutines.get(all[0])){  // We don't want to forbid top-level exception handlers.
            if (sub.contains(_protected)){
              throw new StructuralCodeConstraintException("Subroutine instruction '"+_protected+"' is protected by an exception handler, '"+handlers[i]+"'. This is forbidden by the JustIce verifier due to its clear definition of subroutines.");
            }
          }
        }
        _protected = _protected.getNext();
      }
View Full Code Here

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

      int index = ((RET) (subs[i].getLeavingRET().getInstruction())).getIndex();
     
      if (!set.add(new Integer(index))){
        // Don't use toString() here because of possibly infinite recursive subSubs() calls then.
        SubroutineImpl si = (SubroutineImpl) subs[i];
        throw new StructuralCodeConstraintException("Subroutine with local variable '"+si.localVariable+"', JSRs '"+si.theJSRs+"', RET '"+si.theRET+"' is called by a subroutine which uses the same local variable index as itself; maybe even a recursive call? JustIce's clean definition of a subroutine forbids both.");
      }

      noRecursiveCalls(subs[i], set);
     
      set.remove(new Integer(index));
View Full Code Here

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

   * for details.
   */
  public void merge(OperandStack s){
      try {
    if ( (slotsUsed() != s.slotsUsed()) || (size() != s.size()) ) {
            throw new StructuralCodeConstraintException("Cannot merge stacks of different size:\nOperandStack A:\n"+this+"\nOperandStack B:\n"+s);
        }
   
    for (int i=0; i<size(); i++){
      // If the object _was_ initialized and we're supposed to merge
      // in some uninitialized object, we reject the code (see vmspec2, 4.9.4, last paragraph).
      if ( (! (stack.get(i) instanceof UninitializedObjectType)) && (s.stack.get(i) instanceof UninitializedObjectType) ){
        throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object on the stack detected.");
      }
      // Even harder, we're not initialized but are supposed to broaden
      // the known object type
      if ( (!(stack.get(i).equals(s.stack.get(i)))) && (stack.get(i) instanceof UninitializedObjectType) && (!(s.stack.get(i) instanceof UninitializedObjectType))){
        throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object on the stack detected.");
      }
      // on the other hand...
      if (stack.get(i) instanceof UninitializedObjectType){ //if we have an uninitialized object here
        if (! (s.stack.get(i) instanceof UninitializedObjectType)){ //that has been initialized by now
          stack.set(i, ((UninitializedObjectType) (stack.get(i))).getInitialized() ); //note that.
        }
      }
      if (! stack.get(i).equals(s.stack.get(i))){
        if (  (stack.get(i) instanceof ReferenceType) &&
              (s.stack.get(i) instanceof ReferenceType)  ){
          stack.set(i, ((ReferenceType) stack.get(i)).getFirstCommonSuperclass((ReferenceType) (s.stack.get(i))));
        }
        else{
          throw new StructuralCodeConstraintException("Cannot merge stacks of different types:\nStack A:\n"+this+"\nStack B:\n"+s);
        }
      }
    }
      } catch (ClassNotFoundException e) {
    // FIXME: maybe not the best way to handle this
View Full Code Here

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

      try {
   
    // We won't accept an unitialized object if we know it was initialized;
    // compare vmspec2, 4.9.4, last paragraph.
    if ( (!(locals[i] instanceof UninitializedObjectType)) && (lv.locals[i] instanceof UninitializedObjectType) ){
      throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object in the local variables detected.");
    }
    // Even harder, what about _different_ uninitialized object types?!
    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 we just didn't know that it was initialized, we have now learned.
    if (locals[i] instanceof UninitializedObjectType){
      if (! (lv.locals[i] instanceof UninitializedObjectType)){
        locals[i] = ((UninitializedObjectType) locals[i]).getInitialized();
View Full Code Here

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

   * StructuralCodeConstraintException.
   * @throws org.apache.bcel.verifier.exc.StructuralCodeConstraintException always.
   */
  private void constraintViolated(Instruction violator, String description){
    String fq_classname = violator.getClass().getName();
    throw new StructuralCodeConstraintException("Instruction "+ fq_classname.substring(fq_classname.lastIndexOf('.')+1) +" constraint violated: " + description);
  }
View Full Code Here

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

   * for details.
   */
  public void merge(OperandStack s){
      try {
    if ( (slotsUsed() != s.slotsUsed()) || (size() != s.size()) ) {
            throw new StructuralCodeConstraintException("Cannot merge stacks of different size:\nOperandStack A:\n"+this+"\nOperandStack B:\n"+s);
        }
   
    for (int i=0; i<size(); i++){
      // If the object _was_ initialized and we're supposed to merge
      // in some uninitialized object, we reject the code (see vmspec2, 4.9.4, last paragraph).
      if ( (! (stack.get(i) instanceof UninitializedObjectType)) && (s.stack.get(i) instanceof UninitializedObjectType) ){
        throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object on the stack detected.");
      }
      // Even harder, we're not initialized but are supposed to broaden
      // the known object type
      if ( (!(stack.get(i).equals(s.stack.get(i)))) && (stack.get(i) instanceof UninitializedObjectType) && (!(s.stack.get(i) instanceof UninitializedObjectType))){
        throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object on the stack detected.");
      }
      // on the other hand...
      if (stack.get(i) instanceof UninitializedObjectType){ //if we have an uninitialized object here
        if (! (s.stack.get(i) instanceof UninitializedObjectType)){ //that has been initialized by now
          stack.set(i, ((UninitializedObjectType) (stack.get(i))).getInitialized() ); //note that.
        }
      }
      if (! stack.get(i).equals(s.stack.get(i))){
        if (  (stack.get(i) instanceof ReferenceType) &&
              (s.stack.get(i) instanceof ReferenceType)  ){
          stack.set(i, ((ReferenceType) stack.get(i)).getFirstCommonSuperclass((ReferenceType) (s.stack.get(i))));
        }
        else{
          throw new StructuralCodeConstraintException("Cannot merge stacks of different types:\nStack A:\n"+this+"\nStack B:\n"+s);
        }
      }
    }
      } catch (ClassNotFoundException e) {
    // FIXME: maybe not the best way to handle this
View Full Code Here

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

      try {
   
    // We won't accept an unitialized object if we know it was initialized;
    // compare vmspec2, 4.9.4, last paragraph.
    if ( (!(locals[i] instanceof UninitializedObjectType)) && (lv.locals[i] instanceof UninitializedObjectType) ){
      throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object in the local variables detected.");
    }
    // Even harder, what about _different_ uninitialized object types?!
    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 we just didn't know that it was initialized, we have now learned.
    if (locals[i] instanceof UninitializedObjectType){
      if (! (lv.locals[i] instanceof UninitializedObjectType)){
        locals[i] = ((UninitializedObjectType) locals[i]).getInitialized();
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.