Package org.aspectj.apache.bcel.classfile

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


          if (innerCls.getInnerClassIndex() == 0 || innerCls.getOuterClassIndex() == 0) {
            continue;
          }

          // resolve inner class name, check if it matches current class name
          ConstantClass innerClsInfo = (ConstantClass) cpool.getConstant(innerCls.getInnerClassIndex());

          // class names in constant pool use '/' instead of '.', from JVM Spec 2nd ed. par. 4.2
          String innerClsName = cpool.getConstantUtf8(innerClsInfo.getNameIndex()).getValue().replace('/', '.');

          if (innerClsName.compareTo(className) == 0) {
            // resolve outer class name
            ConstantClass outerClsInfo = (ConstantClass) cpool.getConstant(innerCls.getOuterClassIndex());

            // class names in constant pool use '/' instead of '.', from JVM Spec 2nd ed. par. 4.2
            String outerClsName = cpool.getConstantUtf8(outerClsInfo.getNameIndex()).getValue().replace('/', '.');

            UnresolvedType outer = UnresolvedType.forName(outerClsName);
            return outer.resolve(getResolvedTypeX().getWorld());
          }
        }
      }
    }

    for (Attribute attr : javaClass.getAttributes()) { // bug339300
      ConstantPool cpool = javaClass.getConstantPool();
      if (attr instanceof EnclosingMethod) {
        EnclosingMethod enclosingMethodAttribute = (EnclosingMethod) attr;
        if (enclosingMethodAttribute.getEnclosingClassIndex() != 0) {
          ConstantClass outerClassInfo = enclosingMethodAttribute.getEnclosingClass();
          String outerClassName = cpool.getConstantUtf8(outerClassInfo.getNameIndex()).getValue().replace('/', '.');
          UnresolvedType outer = UnresolvedType.forName(outerClassName);
          return outer.resolve(getResolvedTypeX().getWorld());
        }
      }
    }
View Full Code Here


          if (innerCls.getInnerClassIndex() == 0 || innerCls.getOuterClassIndex() == 0) {
            continue;
          }

          // resolve inner class name, check if it matches current class name
          ConstantClass innerClsInfo = (ConstantClass) cpool.getConstant(innerCls.getInnerClassIndex());

          // class names in constant pool use '/' instead of '.', from JVM Spec 2nd ed. par. 4.2
          String innerClsName = cpool.getConstantUtf8(innerClsInfo.getNameIndex()).getValue().replace('/', '.');

          if (innerClsName.compareTo(className) == 0) {
            // resolve outer class name
            ConstantClass outerClsInfo = (ConstantClass) cpool.getConstant(innerCls.getOuterClassIndex());

            // class names in constant pool use '/' instead of '.', from JVM Spec 2nd ed. par. 4.2
            String outerClsName = cpool.getConstantUtf8(outerClsInfo.getNameIndex()).getValue().replace('/', '.');

            UnresolvedType outer = UnresolvedType.forName(outerClsName);
            return outer.resolve(getResolvedTypeX().getWorld());
          }
        }
View Full Code Here

       "<LI><A HREF=\"#cp" + class_index + "\">Class(" + class_index +  ")</A><BR>\n" +
       "<LI><A HREF=\"#cp" + name_index + "\">NameAndType(" + name_index + ")</A></UL>");
      break;
       
    case CONSTANT_Class:
      ConstantClass c4 = (ConstantClass)constant_pool.getConstant(index, CONSTANT_Class);
      name_index  = c4.getNameIndex();
      String class_name2  = constant_pool.constantToString(index, tag); // / -> .
      String short_class_name = Utility.compactClassName(class_name2); // I.e., remove java.lang.
      short_class_name = Utility.compactClassName(short_class_name, class_package + ".", true); // Remove class package prefix

      ref = "<A HREF=\"" + class_name2 + ".html\" TARGET=_top>" + short_class_name + "</A>";
View Full Code Here

      if (!validFieldName(name)){
        throw new ClassConstraintException("Invalid field name '"+name+"' referenced by '"+tostring(obj)+"'.");
      }
     
      int class_index = obj.getClassIndex();
      ConstantClass cc = (ConstantClass) (cp.getConstant(class_index));
      String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getBytes(); // Class Name in internal form
      if (! validClassName(className)){
        throw new ClassConstraintException("Illegal class name '"+className+"' used by '"+tostring(obj)+"'.");
      }

      String sig  = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
View Full Code Here

      if (!validClassMethodName(name)){
        throw new ClassConstraintException("Invalid (non-interface) method name '"+name+"' referenced by '"+tostring(obj)+"'.");
      }

      int class_index = obj.getClassIndex();
      ConstantClass cc = (ConstantClass) (cp.getConstant(class_index));
      String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getBytes(); // Class Name in internal form
      if (! validClassName(className)){
        throw new ClassConstraintException("Illegal class name '"+className+"' used by '"+tostring(obj)+"'.");
      }

      String sig  = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
View Full Code Here

      if (!validInterfaceMethodName(name)){
        throw new ClassConstraintException("Invalid (interface) method name '"+name+"' referenced by '"+tostring(obj)+"'.");
      }

      int class_index = obj.getClassIndex();
      ConstantClass cc = (ConstantClass) (cp.getConstant(class_index));
      String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getBytes(); // Class Name in internal form
      if (! validClassName(className)){
        throw new ClassConstraintException("Illegal class name '"+className+"' used by '"+tostring(obj)+"'.");
      }

      String sig  = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
View Full Code Here

    }

    // Adapt the class name to the passed value
    ConstantPool cp = clazz.getConstantPool();

    ConstantClass cl = (ConstantClass)cp.getConstant(clazz.getClassNameIndex(),
                 Constants.CONSTANT_Class);
    ConstantUtf8 name = (ConstantUtf8)cp.getConstant(cl.getNameIndex(),
                 Constants.CONSTANT_Utf8);
    name.setBytes(class_name.replace('.', '/'));

    return clazz;
  }
View Full Code Here

      CodeException[] exc_table = obj.getExceptionTable();
      for (int i=0; i<exc_table.length; i++){
        int exc_index = exc_table[i].getCatchType();
        if (exc_index != 0){ // if 0, it catches all Throwables
          checkIndex(obj, exc_index, CONST_Class);
          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){
View Full Code Here

      int[] exc_indices = obj.getExceptionIndexTable();

      for (int i=0; i<exc_indices.length; i++){
        checkIndex(obj, exc_indices[i], CONST_Class);

        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){
View Full Code Here

  ConstantString s  = (ConstantString)c;
  ConstantUtf8   u8 = (ConstantUtf8)constants[s.getStringIndex()];

  string_table.put(u8.getBytes(), new Index(i));
      } else if(c instanceof ConstantClass) {
  ConstantClass s  = (ConstantClass)c;
  ConstantUtf8  u8 = (ConstantUtf8)constants[s.getNameIndex()];

  class_table.put(u8.getBytes(), new Index(i));
      } else if(c instanceof ConstantNameAndType) {
  ConstantNameAndType n    = (ConstantNameAndType)c;
  ConstantUtf8        u8   = (ConstantUtf8)constants[n.getNameIndex()];
  ConstantUtf8        u8_2 = (ConstantUtf8)constants[n.getSignatureIndex()];

  n_a_t_table.put(u8.getBytes() + NAT_DELIM + u8_2.getBytes(), new Index(i));
       } else if(c instanceof ConstantUtf8) {
         ConstantUtf8 u = (ConstantUtf8)c;
        
         utf8_table.put(u.getBytes(), new Index(i));
      } else if(c instanceof ConstantCP) {
  ConstantCP          m     = (ConstantCP)c;
  ConstantClass       clazz = (ConstantClass)constants[m.getClassIndex()];
  ConstantNameAndType n     = (ConstantNameAndType)constants[m.getNameAndTypeIndex()];
 
        ConstantUtf8 u8         = (ConstantUtf8)constants[clazz.getNameIndex()];
        String       class_name = u8.getBytes().replace('/', '.');

  u8 = (ConstantUtf8)constants[n.getNameIndex()];
  String method_name = u8.getBytes();
View Full Code Here

TOP

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

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.