Package org.aspectj.apache.bcel.classfile

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


    }

    public String getValueString() {
      if (type != STRING)
        throw new RuntimeException("Dont call getValueString() on a non STRING ElementValue");
    ConstantUtf8 c = (ConstantUtf8)cpGen.getConstant(idx);
    return c.getBytes();
    }
View Full Code Here


        case PRIMITIVE_BOOLEAN:
        ConstantInteger bo = (ConstantInteger)cpGen.getConstant(idx);
        if (bo.getBytes() == 0) return "false";
        if (bo.getBytes() != 0) return "true";
        case STRING:
        ConstantUtf8 cu8 = (ConstantUtf8)cpGen.getConstant(idx);
        return cu8.getBytes();
       
       default:
         throw new RuntimeException("SimpleElementValueGen class does not know how to stringify type "+type);
      }
    }
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

          constraintViolated(o, "Indexing a constant that's not a CONSTANT_Methodref but a '"+c+"'.");
        }
        else{
          // Constants are okay due to pass2.
          ConstantNameAndType cnat = (ConstantNameAndType) (cpg.getConstant(((ConstantMethodref) c).getNameAndTypeIndex()));
          ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant(cnat.getNameIndex()));
          if (cutf8.getBytes().equals(Constants.CONSTRUCTOR_NAME) && (!(o instanceof INVOKESPECIAL)) ){
            constraintViolated(o, "Only INVOKESPECIAL is allowed to invoke instance initialization methods.");
          }
          if ( (! (cutf8.getBytes().equals(Constants.CONSTRUCTOR_NAME)) ) && (cutf8.getBytes().startsWith("<")) ){
            constraintViolated(o, "No method with a name beginning with '<' other than the instance initialization methods may be called by the method invocation instructions.");
          }
        }
      }
      else{ //if (o instanceof INVOKEINTERFACE){
View Full Code Here

      Constant c = cpg.getConstant(o.getIndex());
      if ((c instanceof ConstantClass)){
        constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
      }
      else{
        ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant( ((ConstantClass) c).getNameIndex() ));
        Type t = Type.getType("L"+cutf8.getBytes()+";");
        if (t instanceof ArrayType){
          constraintViolated(o, "NEW must not be used to create an array.");
        }
      }
     
View Full Code Here

            Constant[] cpool = javaClass.getConstantPool().getConstantPool();
            for (int i = 0; i < cpool.length; i++) {
                Constant constant = cpool[i];
                if (constant != null && constant.getTag() == Constants.CONSTANT_Utf8) {
                    if (!javaClass.getClassName().startsWith("org.aspectj.lang.annotation")) {
                        ConstantUtf8 constantUtf8 = (ConstantUtf8) constant;
                        if ("Lorg/aspectj/lang/annotation/DeclareAnnotation;".equals(constantUtf8.getBytes())) {
                            msgHandler.handleMessage(
                                    new Message(
                                            "Found @DeclareAnnotation while current release does not support it (see '" + type.getName() + "')",
                                            IMessage.WARNING,
                                            null,
View Full Code Here

   
   
    public String getValueString() {
      if (type != STRING)
        throw new RuntimeException("Dont call getValueString() on a non STRING ElementValue");
    ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(idx,Constants.CONSTANT_Utf8);
    return c.getBytes();
    }
View Full Code Here

        case PRIMITIVE_BOOLEAN:
        ConstantInteger bo = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer);
        if (bo.getBytes() == 0) return "false";
        if (bo.getBytes() != 0) return "true";
        case STRING:
        ConstantUtf8 cu8 = (ConstantUtf8)cpool.getConstant(idx,Constants.CONSTANT_Utf8);
        return cu8.getBytes();
       
       default:
         throw new RuntimeException("SimpleElementValue class does not know how to stringify type "+type);
      }
    }
View Full Code Here

  public int getNameIndex() {
    return nameIdx;
  }
 
  public final String getNameString() {
    ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(nameIdx,Constants.CONSTANT_Utf8);
    return c.getBytes();
  }
View Full Code Here

  public int getTypeIndex() {
    return typeIndex;
  }
 
  public String getTypeSignature() {
    ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(typeIndex,Constants.CONSTANT_Utf8);
    return c.getBytes();
  }
View Full Code Here

TOP

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

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.