Package org.apache.bcel.verifier.exc

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


     * All instructions must have been added before invoking setLeavingRET().
     * @see #setLeavingRET
     */
    void addInstruction(InstructionHandle ih){
      if (theRET != null){
        throw new AssertionViolatedException("All instructions must have been added before invoking setLeavingRET().");
      }
      instructions.add(ih);
    }
View Full Code Here


     */
    public int[] getAccessedLocalsIndices(){
      //TODO: Implement caching.
      Set acc = new HashSet();
      if (theRET == null && this != TOPLEVEL){
        throw new AssertionViolatedException("This subroutine object must be built up completely before calculating accessed locals.");
      }
      Iterator i = instructions.iterator();
      while (i.hasNext()){
        InstructionHandle ih = (InstructionHandle) i.next();
        // RET is not a LocalVariableInstruction in the current version of BCEL.
        if (ih.getInstruction() instanceof LocalVariableInstruction || ih.getInstruction() instanceof RET){
          int idx = ((IndexedInstruction) (ih.getInstruction())).getIndex();
          acc.add(new Integer(idx));
          // LONG? DOUBLE?.
          try{
            // LocalVariableInstruction instances are typed without the need to look into
            // the constant pool.
            if (ih.getInstruction() instanceof LocalVariableInstruction){
              int s = ((LocalVariableInstruction) ih.getInstruction()).getType(null).getSize();
              if (s==2) {
                                acc.add(new Integer(idx+1));
                            }
            }
          }
          catch(RuntimeException re){
            throw new AssertionViolatedException("Oops. BCEL did not like NULL as a ConstantPoolGen object.");
          }
        }
      }
     
      int[] ret = new int[acc.size()];
View Full Code Here

     * This subroutine's RET operates on that same local variable
     * slot, of course.
     */
    void setLocalVariable(int i){
      if (localVariable != UNSET){
        throw new AssertionViolatedException("localVariable set twice.");
      }
      else{
        localVariable = i;
      }
    }
View Full Code Here

   * 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;
  }
View Full Code Here

     * Creates an InstructionHandleImpl object from an InstructionHandle.
     * Creation of one per InstructionHandle suffices. Don't create more.
     */
    public InstructionContextImpl(InstructionHandle inst){
      if (inst == null) {
                throw new AssertionViolatedException("Cannot instantiate InstructionContextImpl from NULL.");
            }
   
      instruction = inst;
      inFrames = new java.util.HashMap();
      outFrames = new java.util.HashMap();
View Full Code Here

      InstructionContext jsr = lastExecutionJSR();

      org = (Frame) outFrames.get(jsr);

      if (org == null){
        throw new AssertionViolatedException("outFrame not set! This:\n"+this+"\nExecutionChain: "+getExecutionChain()+"\nOutFrames: '"+outFrames+"'.");
      }
      return org.getClone();
    }
View Full Code Here

      InstructionContext jsr = lastExecutionJSR();
     
      org = (Frame) inFrames.get(jsr);

      if (org == null){
          throw new AssertionViolatedException("inFrame not set! This:\n"+this+"\nInFrames: '"+inFrames+"'.");
      }
      return org.getClone();
    }
View Full Code Here

      executionPredecessors = (ArrayList) execPreds.clone();

      //sanity check
      if ( (lastExecutionJSR() == null) && (subroutines.subroutineOf(getInstruction()) != subroutines.getTopLevel() ) ){
        throw new AssertionViolatedException("Huh?! Am I '"+this+"' part of a subroutine or not?");
      }
      if ( (lastExecutionJSR() != null) && (subroutines.subroutineOf(getInstruction()) == subroutines.getTopLevel() ) ){
        throw new AssertionViolatedException("Huh?! Am I '"+this+"' part of a subroutine or not?");
      }

      Frame inF = (Frame) inFrames.get(lastExecutionJSR());
      if (inF == null){// no incoming frame was set, so set it.
        inFrames.put(lastExecutionJSR(), inFrame);
View Full Code Here

      Instruction inst = getInstruction().getInstruction();
   
      if (inst instanceof RET){
        Subroutine s = subroutines.subroutineOf(getInstruction());
        if (s==null){ //return empty; // RET in dead code. "empty" would be the correct answer, but we know something about the surrounding project...
          throw new AssertionViolatedException("Asking for successors of a RET in dead code?!");
        }

//TODO: remove. Only JustIce must not use it, but foreign users of the ControlFlowGraph
//      will want it. Thanks Johannes Wust.
//throw new AssertionViolatedException("DID YOU REALLY WANT TO ASK FOR RET'S SUCCS?");
View Full Code Here

        // Sanity check
        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?!");
          }
//System.err.println("+"+oldchain.get(ss));
          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());
        }
View Full Code Here

TOP

Related Classes of org.apache.bcel.verifier.exc.AssertionViolatedException

Copyright © 2018 www.massapicom. 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.