@Override
 public String print(int length) throws Exception {
   String space = TransformUtil.spaces(length);
   String space1 = TransformUtil.spaces(length + 4);
   String space2 = TransformUtil.spaces(length + 8);
   String result = "";
   try {
     result += space + "RuntimeVisibleParameterAnnotations : \n";
     result +=
         space1
             + "num_parameters : "
             + TransformUtil.bytesToInt(new byte[] {getNum_parameters()})
             + "\n";
     List<Parameter> parameters = getParameters();
     for (Parameter parameter : parameters) {
       result += space1 + "parameter: \n";
       result +=
           space2
               + "num_annotations: "
               + TransformUtil.bytesToInt(parameter.getNum_annotations())
               + "\n";
       List<Annotation> annotations = parameter.getAnnotations();
       for (Annotation annotation : annotations) {
         result += annotation.print(length + 8);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return result;
 }
Exemplo n.º 2
0
 @Override
 public String print(int length) {
   String space = TransformUtil.spaces(length);
   String result = "";
   String type = "";
   try {
     if (tag == CONSTANT_FIELDREF) {
       type = "field";
     } else if (tag == CONSTANT_METHODREF) {
       type = "method";
     } else if (tag == CONSTANT_INTERFACEMETHODREF) {
       type = "interfacemethod";
     }
     result =
         space
             + "const #"
             + getIndex()
             + " ="
             + type
             + space
             + "#"
             + TransformUtil.bytesToInt(class_index)
             + ".#"
             + TransformUtil.bytesToInt(name_and_type_index);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return result;
 }
  @Override
  public void parseSelf(AttributeInfo attributeInfo, List<ConstantPoolInfo> cp_info)
      throws Exception {
    super.parseSelf(attributeInfo, cp_info);

    byte[] info = attributeInfo.getInfo();
    int[] index = new int[] {0};
    setNum_parameters(TransformUtil.subBytes(info, index, 1)[0]);

    int num_param = TransformUtil.bytesToInt(new byte[] {getNum_parameters()});
    if (num_param > 0) {
      List<Parameter> parameters = new ArrayList<Parameter>();
      for (int i = 0; i < num_param; i++) {
        Parameter parameter = new Parameter();
        parameter.setNum_annotations(TransformUtil.subBytes(info, index, 2));

        int num_anno = TransformUtil.bytesToInt(parameter.getNum_annotations());
        if (num_anno > 0) {
          List<Annotation> annotations = new ArrayList<Annotation>();
          for (int j = 0; j < num_anno; j++) {
            Annotation annotation = new Annotation(cp_info);
            annotation.parseSelf(info, index);
            annotations.add(annotation);
          }
          parameter.setAnnotations(annotations);
        }
        setParameters(parameters);
      }
    }
  }
Exemplo n.º 4
0
 @Override
 public String print(int length) throws Exception {
   String space = TransformUtil.spaces(length);
   String result = "";
   result =
       space
           + "const #"
           + getIndex()
           + " =class"
           + space
           + " #"
           + TransformUtil.bytesToInt(name_index);
   return result;
 }