Package org.aspectj.apache.bcel.classfile

Examples of org.aspectj.apache.bcel.classfile.JavaClass


  public ResolvedType[] getAnnotations(Class forClass, World inWorld) {
    // here we really want both the runtime visible AND the class visible annotations
    // so we bail out to Bcel and then chuck away the JavaClass so that we don't hog
    // memory.
    try {
      JavaClass jc = bcelRepository.loadClass(forClass);
      org.aspectj.apache.bcel.classfile.annotation.Annotation[] anns =jc.getAnnotations();
      bcelRepository.clear();
      if (anns == null) return new ResolvedType[0];
      ResolvedType[] ret = new ResolvedType[anns.length];
      for (int i = 0; i < ret.length; i++) {
        ret[i] = inWorld.resolve(anns[i].getTypeName());
View Full Code Here


    }      


  protected ReferenceTypeDelegate resolveDelegate(ReferenceType ty) {
        String name = ty.getName();
        JavaClass jc = null;
        //UnwovenClassFile classFile = (UnwovenClassFile)sourceJavaClasses.get(name);
        //if (classFile != null) jc = classFile.getJavaClass();
//    if (jc == null) {
//        jc = lookupJavaClass(aspectPath, name);
//    }
View Full Code Here

          ClassPathManager.ClassFile file = classPath.find(UnresolvedType.forName(name));
          if (file == null) return null;
         
          ClassParser parser = new ClassParser(file.getInputStream(), file.getPath());
         
          JavaClass jc = parser.parse();
      file.close();
      return jc;
    } catch (IOException ioe) {
      return null;
    }
View Full Code Here

     * @return true if so
     */
    public boolean isAnnotationStyleAspect(String name, byte[] bytes) {
        try {
            ClassParser cp = new ClassParser(new ByteArrayInputStream(bytes), null);
            JavaClass jc = cp.parse();
            if (!jc.isClass()) {
                return false;
            }
            Annotation anns[] = jc.getAnnotations();
            if (anns.length == 0) {
                return false;
            }
            boolean couldBeAtAspectJStyle = false;
            for (int i = 0; i < anns.length; i++) {
                Annotation ann = anns[i];
                if ("Lorg/aspectj/lang/annotation/Aspect;".equals(ann.getTypeSignature())) {
                    couldBeAtAspectJStyle = true;
                }
            }
           
            if (!couldBeAtAspectJStyle) return false;
           
            // ok, so it has the annotation, but it could have been put
            // on a code style aspect by the annotation visitor
            Attribute[] attributes = jc.getAttributes();
            for (int i = 0; i < attributes.length; i++) {
              if (attributes[i].getName().equals(Aspect.AttributeName)) {
                return false;
              }
            }
View Full Code Here

      }
      else{ // must be Verified_OK, because Pass1 was OK (cannot be Verified_NOTYET).
          pass2TextPane.setText(vr.getMessage());
          pass2TextPane.setBackground(Color.green);

          JavaClass jc = Repository.lookupClass(current_class);
          /*
          boolean all3aok = true;
          boolean all3bok = true;
          String all3amsg = "";
          String all3bmsg = "";
          */

          String[] methodnames = new String[jc.getMethods().length];
          for (int i=0; i<jc.getMethods().length; i++){
            methodnames[i] = jc.getMethods()[i].toString().replace('\n',' ').replace('\t',' ');
          }
          pass3aJList.setListData(methodnames);
          pass3aJList.setSelectionInterval(0,jc.getMethods().length-1);
          pass3bJList.setListData(methodnames);
          pass3bJList.setSelectionInterval(0,jc.getMethods().length-1);
      }

    }
    String[] msgs = v.getMessages();
    messagesTextPane.setBackground(msgs.length == 0? Color.green : Color.yellow);
View Full Code Here

  Color color = Color.green;

  Verifier v = VerifierFactory.getVerifier(class_name);
  VerificationResult vr = v.doPass2();
  if (vr.getStatus() == VerificationResult.VERIFIED_OK){
    JavaClass jc = Repository.lookupClass(class_name);
    int nr = jc.getMethods().length;
    for (int i=0; i<nr; i++) {
      vr = v.doPass3b(i);
      if (vr.getStatus() != VerificationResult.VERIFIED_OK){
        color = Color.red;
        break;
View Full Code Here

    vr = v.doPass2();
      if (vr != VerificationResult.VR_OK) //System.exit(1);
      System.out.println("Pass 2:\n"+vr);

    if (vr == VerificationResult.VR_OK){
      JavaClass jc = Repository.lookupClass(v.getClassName());
      for (int i=0; i<jc.getMethods().length; i++){
        vr = v.doPass3a(i);
        if (vr != VerificationResult.VR_OK) //System.exit(1);
          System.out.println(v.getClassName()+", Pass 3a, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);

        vr = v.doPass3b(i);
        if (vr != VerificationResult.VR_OK) //System.exit(1);
          System.out.println(v.getClassName()+", Pass 3b, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
      }
    }

    indent -= 1;
  }
View Full Code Here

   */
  public VerificationResult do_verify(){
    if (myOwner.doPass2().equals(VerificationResult.VR_OK)){
      // Okay, class file was loaded correctly by Pass 1
      // and satisfies static constraints of Pass 2.
      JavaClass jc = Repository.lookupClass(myOwner.getClassName());
      Method[] methods = jc.getMethods();
      if (method_no >= methods.length){
        throw new InvalidMethodException("METHOD DOES NOT EXIST!");
      }
      Method method = methods[method_no];
      code = method.getCode();
View Full Code Here

      vr = v.doPass2();
      System.out.println("Pass 2:\n"+vr);

      if (vr == VerificationResult.VR_OK){
        JavaClass jc = org.aspectj.apache.bcel.Repository
            .lookupClass(args[k]);
        for (int i=0; i<jc.getMethods().length; i++){
          vr = v.doPass3a(i);
          System.out.println("Pass 3a, method number "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);

          vr = v.doPass3b(i);
          System.out.println("Pass 3b, method number "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
        }
      }

      System.out.println("Warnings:");
      String[] warnings = v.getMessages();
View Full Code Here

  }

  /** Default main method
   */
  public static void main(String[] argv) throws Exception {
    JavaClass java_class;
    String    name = argv[0];

    if((java_class = Repository.lookupClass(name)) == null)
      java_class = new ClassParser(name).parse(); // May throw IOException

View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.classfile.JavaClass

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.