Package org.aspectj.apache.bcel.verifier

Examples of org.aspectj.apache.bcel.verifier.VerificationResult


                        .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) {
            // These are internal errors

            StringWriter sw = new StringWriter();
View Full Code Here


                        .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) {
            // These are internal errors

            StringWriter sw = new StringWriter();
View Full Code Here

        }
      }
     
    }
    catch(LoadingException e){
      return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage());
    }
    catch(ClassFormatError e){
      // BCEL sometimes is a little harsh describing exceptual situations.
      return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage());
    }
    catch(RuntimeException e){
      // BCEL does not catch every possible RuntimeException; e.g. if
      // a constant pool index is referenced that does not exist.
      return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Parsing via BCEL did not succeed. "+e.getClass().getName()+" occured:\n"+Utility.getStackTrace(e));
    }

    if (jc != null){
      return VerificationResult.VR_OK;
    }
    else{
      //TODO: Maybe change Repository's behaviour to throw a LoadingException instead of just returning "null"
      //      if a class file cannot be found or in another way be looked up.
      return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Repository.lookup() failed. FILE NOT FOUND?");
    }
  }
View Full Code Here

   * see the pass 3a documentation, too.
   *
   * @see org.aspectj.apache.bcel.verifier.statics.Pass3aVerifier
   */
  public VerificationResult do_verify(){
    VerificationResult vr1 = myOwner.doPass1();
    if (vr1.equals(VerificationResult.VR_OK)){
     
      // For every method, we could have information about the local variables out of LocalVariableTable attributes of
      // the Code attributes.
      localVariablesInfos = new LocalVariablesInfo[Repository.lookupClass(myOwner.getClassName()).getMethods().length];

      VerificationResult vr = VerificationResult.VR_OK; // default.
      try{
        constant_pool_entries_satisfy_static_constraints();
        field_and_method_refs_are_valid();
        every_class_has_an_accessible_superclass();
        final_methods_are_not_overridden();
      }
      catch (ClassConstraintException cce){
        vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, cce.getMessage());
      }
      return vr;
    }
    else
      return VerificationResult.VR_NOTYET;
View Full Code Here

        String supername = jc.getSuperclassName();
        if (! hs.add(supername)){  // If supername already is in the list
          throw new ClassConstraintException("Circular superclass hierarchy detected.");
        }
        Verifier v = VerifierFactory.getVerifier(supername);
        VerificationResult vr = v.doPass1();

        if (vr != VerificationResult.VR_OK){
          throw new ClassConstraintException("Could not load in ancestor class '"+supername+"'.");
        }
        jc = Repository.lookupClass(supername);
View Full Code Here

      // Check if referenced objects exist.
      Type act = t;
      if (act instanceof ArrayType) act = ((ArrayType) act).getBasicType();
      if (act instanceof ObjectType){
        Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() );
        VerificationResult vr = v.doPass1();
        if (vr != VerificationResult.VR_OK) {
          throw new ClassConstraintException("Method '"+tostring(obj)+"' has a return type that does not pass verification pass 1: '"+vr+"'.");
        }
      }

      for (int i=0; i<ts.length; i++){
        act = ts[i];
        if (act instanceof ArrayType) act = ((ArrayType) act).getBasicType();
        if (act instanceof ObjectType){
          Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() );
          VerificationResult vr = v.doPass1();
          if (vr != VerificationResult.VR_OK) {
            throw new ClassConstraintException("Method '"+tostring(obj)+"' has an argument type that does not pass verification pass 1: '"+vr+"'.");
          }
        }
      }
View Full Code Here

          ConstantClass cc = (ConstantClass) (cp.getConstant(exc_index));
          checkIndex(cc, cc.getNameIndex(), CONST_Utf8); // cannot be sure this ConstantClass has already been visited (checked)!
          String cname = ((ConstantUtf8) cp.getConstant(cc.getNameIndex())).getBytes().replace('/','.');

          Verifier v = VerifierFactory.getVerifier(cname);
          VerificationResult vr = v.doPass1();

          if (vr != VerificationResult.VR_OK){
            throw new ClassConstraintException("Code attribute '"+tostring(obj)+"' (method '"+m+"') has an exception_table entry '"+tostring(exc_table[i])+"' that references '"+cname+"' as an Exception but it does not pass verification pass 1: "+vr);
          }
          else{
View Full Code Here

        ConstantClass cc = (ConstantClass) (cp.getConstant(exc_indices[i]));
        checkIndex(cc, cc.getNameIndex(), CONST_Utf8); // cannot be sure this ConstantClass has already been visited (checked)!
        String cname = ((ConstantUtf8) cp.getConstant(cc.getNameIndex())).getBytes().replace('/','.'); //convert internal notation on-the-fly to external notation

        Verifier v = VerifierFactory.getVerifier(cname);
        VerificationResult vr = v.doPass1();

        if (vr != VerificationResult.VR_OK){
          throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but it does not pass verification pass 1: "+vr);
        }
        else{
View Full Code Here

      // instruction and so on.
      try{
        instructionList = new InstructionList(method.getCode().getCode());
      }
      catch(RuntimeException re){
        return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Bad bytecode in the code array of the Code attribute of method '"+method+"'.");
      }
     
      instructionList.setPositions(true);

      // Start verification.
      VerificationResult vr = VerificationResult.VR_OK; //default
      try{
        delayedPass2Checks();
      }
      catch(ClassConstraintException cce){
        vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, cce.getMessage());
        return vr;
      }
      try{
        pass3StaticInstructionChecks();
        pass3StaticInstructionOperandsChecks();
      }
      catch(StaticCodeConstraintException scce){
        vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, scce.getMessage());
      }
      return vr;
    }
    else{ //did not pass Pass 2.
      return VerificationResult.VR_NOTYET;
View Full Code Here

     */
    public void visitLoadClass(LoadClass o){
      ObjectType t = o.getLoadClassType(cpg);
      if (t != null){// null means "no class is loaded"
        Verifier v = VerifierFactory.getVerifier(t.getClassName());
        VerificationResult vr = v.doPass1();
        if (vr.getStatus() != VerificationResult.VERIFIED_OK){
          constraintViolated((Instruction) o, "Class '"+o.getLoadClassType(cpg).getClassName()+"' is referenced, but cannot be loaded: '"+vr+"'.");
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.verifier.VerificationResult

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.