Package org.apache.bcel.verifier

Examples of org.apache.bcel.verifier.Verifier


     */
    private boolean verifyBCEL(ClassFile file) {
        try {
           
            // construct verifier for class file
            Verifier verifier = VerifierFactory.getVerifier(file.getName());
           
            // run validation in stages with error handling for each stage
            boolean verified = false;
            VerificationResult vr = verifier.doPass1();
            if (vr.getStatus() == VerificationResult.VERIFIED_OK) {
                vr = verifier.doPass2();
                if (vr.getStatus() == VerificationResult.VERIFIED_OK) {
                    Method[] methods = file.getRawClass().getMethods();
                    for (int j = 0; j < methods.length; j++) {
                        vr = verifier.doPass3a(j);
                        if (vr.getStatus() == VerificationResult.VERIFIED_OK) {
                            vr = verifier.doPass3b(j);
                        }
                        if (vr.getStatus() == VerificationResult.VERIFIED_OK) {
                            verified = true;
                        } else {
                            System.out.println
View Full Code Here


      throw new RuntimeException( "nothing to verify" );

    JavaClass jc = clGen.getJavaClass();
    Repository.addClass( jc );

    Verifier v = VerifierFactory.getVerifier( jc.getClassName() );
    checkVerificationResult(v.doPass1(), "1");
    checkVerificationResult(v.doPass2(), "2");
    MethodWeaver methodWeavers[] = new MethodWeaver[methods.size()];
    methods.values().toArray( methodWeavers );
    for( int i = 0; i < methods.size(); i++ ) {
      int method_index = methodWeavers[i].targetIndex;
      checkVerificationResult(v.doPass3a(method_index), "3a");
      checkVerificationResult(v.doPass3b(method_index), "3b");
    }

    try {
      String[] warnings = v.getMessages();
      if (warnings.length != 0)
        System.err.println("Messages:");
      for (int j = 0; j < warnings.length; j++)
        System.err.println(warnings[j]);
    } catch(Exception e) { System.err.println("could not verify " + targetClass); }
View Full Code Here

      throw new RuntimeException( "nothing to verify" );

    JavaClass jc = clGen.getJavaClass();
    Repository.addClass( jc );

    Verifier v = VerifierFactory.getVerifier( jc.getClassName() );
    checkVerificationResult(v.doPass1(), "1");
    checkVerificationResult(v.doPass2(), "2");
    MethodWeaver methodWeavers[] = new MethodWeaver[methods.size()];
    methods.values().toArray( methodWeavers );
    for( int i = 0; i < methods.size(); i++ ) {
      int method_index = methodWeavers[i].getTargetIndex();
      checkVerificationResult(v.doPass3a(method_index), "3a");
      checkVerificationResult(v.doPass3b(method_index), "3b");
    }

    try {
      String[] warnings = v.getMessages();
      if (warnings.length != 0)
        System.err.println("Messages:");
      for (int j = 0; j < warnings.length; j++)
        System.err.println(warnings[j]);
    } catch(Exception e) {System.err.println("could not verify " + targetClass);}
View Full Code Here

   * The referenced class is loaded and pass2-verified.
   */
  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.doPass2();
      if (vr.getStatus() != VerificationResult.VERIFIED_OK){
        constraintViolated((Instruction) o, "Class '"+o.getLoadClassType(cpg).getClassName()+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
      }
    }
  }
View Full Code Here

      }
      // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).
      Type t = o.getType(cpg);
      if (t instanceof ObjectType){
        String name = ((ObjectType)t).getClassName();
        Verifier v = VerifierFactory.getVerifier( name );
        VerificationResult vr = v.doPass2();
        if (vr.getStatus() != VerificationResult.VERIFIED_OK){
          constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
        }
      }
   }
View Full Code Here

    // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).

    Type t = o.getType(cpg);
    if (t instanceof ObjectType){
      String name = ((ObjectType)t).getClassName();
      Verifier v = VerifierFactory.getVerifier( name );
      VerificationResult vr = v.doPass2();
      if (vr.getStatus() != VerificationResult.VERIFIED_OK){
        constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
      }
    }
View Full Code Here

    // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).

    Type t = o.getType(cpg);
    if (t instanceof ObjectType){
      String name = ((ObjectType)t).getClassName();
      Verifier v = VerifierFactory.getVerifier( name );
      VerificationResult vr = v.doPass2();
      if (vr.getStatus() != VerificationResult.VERIFIED_OK){
        constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
      }
    }
View Full Code Here

    // Method is not native, otherwise pass 3 would not happen.
   
    Type t = o.getType(cpg);
    if (t instanceof ObjectType){
      String name = ((ObjectType)t).getClassName();
      Verifier v = VerifierFactory.getVerifier( name );
      VerificationResult vr = v.doPass2();
      if (vr.getStatus() != VerificationResult.VERIFIED_OK){
        constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
      }
    }
View Full Code Here

    // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).

    Type t = o.getType(cpg);
    if (t instanceof ObjectType){
      String name = ((ObjectType)t).getClassName();
      Verifier v = VerifierFactory.getVerifier( name );
      VerificationResult vr = v.doPass2();
      if (vr.getStatus() != VerificationResult.VERIFIED_OK){
        constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
      }
    }
View Full Code Here

     * The referenced class is loaded and pass2-verified.
     */
    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.apache.bcel.verifier.Verifier

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.