Package org.apache.bcel.verifier

Examples of org.apache.bcel.verifier.VerificationResult


      // 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


    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

    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

   
    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+"'.");
      }
    }

    Type[] argtypes = o.getArgumentTypes(cpg);
View Full Code Here

    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

            {
                // System.out.println(s);
            }
        });
        Verifier verifier = VerifierFactory.getVerifier(className);
        VerificationResult result;
        result = verifier.doPass1();
        if (VerificationResult.VERIFIED_OK != result.getStatus())
        {
            JPOXLogger.ENHANCER.fatal(result.getMessage());
            return;
        }

        result = verifier.doPass2();
        if (VerificationResult.VERIFIED_OK != result.getStatus())
        {
            JPOXLogger.ENHANCER.fatal(result.getMessage());
            return;
        }
        Method methods[] = ((BCELClassMetaData) cmd).getClassGen().getMethods();
        JPOXLogger.ENHANCER.info("methods num:" + methods.length);
        for (int i = 0; i < methods.length; i++)
        {
            try
            {
                result = verifier.doPass3a(i);
                if (VerificationResult.VERIFIED_OK != result.getStatus())
                {
                    JPOXLogger.ENHANCER.fatal(result.getMessage());
                    // return;
                }
            }
            catch (Exception e)
            {
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(ClassFormatException e){
      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

      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

TOP

Related Classes of org.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.