jodd-proxetta/src/main/java/jodd/asm7/AnnotationWriter.java
@Override
  public void visit(final String name, final Object value) {
    // Case of an element_value with a const_value_index, class_info_index or array_index field.
    // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1.
    ++numElementValuePairs;
    if (useNamedValues) {
      annotation.putShort(symbolTable.addConstantUtf8(name));
    }
    if (value instanceof String) {
      annotation.put12('s', symbolTable.addConstantUtf8((String) value));
    } else if (value instanceof Byte) {
      annotation.put12('B', symbolTable.addConstantInteger(((Byte) value).byteValue()).index);
    } else if (value instanceof Boolean) {
      int booleanValue = ((Boolean) value).booleanValue() ? 1 : 0;
      annotation.put12('Z', symbolTable.addConstantInteger(booleanValue).index);
    } else if (value instanceof Character) {
      annotation.put12('C', symbolTable.addConstantInteger(((Character) value).charValue()).index);
    } else if (value instanceof Short) {
      annotation.put12('S', symbolTable.addConstantInteger(((Short) value).shortValue()).index);
    } else if (value instanceof Type) {
      annotation.put12('c', symbolTable.addConstantUtf8(((Type) value).getDescriptor()));
    } else if (value instanceof byte[]) {
      byte[] byteArray = (byte[]) value;
      annotation.put12('[', byteArray.length);
      for (byte byteValue : byteArray) {
        annotation.put12('B', symbolTable.addConstantInteger(byteValue).index);
      }
    } else if (value instanceof boolean[]) {
      boolean[] booleanArray = (boolean[]) value;
      annotation.put12('[', booleanArray.length);
      for (boolean booleanValue : booleanArray) {
        annotation.put12('Z', symbolTable.addConstantInteger(booleanValue ? 1 : 0).index);
      }
    } else if (value instanceof short[]) {
      short[] shortArray = (short[]) value;
      annotation.put12('[', shortArray.length);
      for (short shortValue : shortArray) {
        annotation.put12('S', symbolTable.addConstantInteger(shortValue).index);
      }
    } else if (value instanceof char[]) {
      char[] charArray = (char[]) value;
      annotation.put12('[', charArray.length);
      for (char charValue : charArray) {
        annotation.put12('C', symbolTable.addConstantInteger(charValue).index);
      }
    } else if (value instanceof int[]) {
      int[] intArray = (int[]) value;
      annotation.put12('[', intArray.length);
      for (int intValue : intArray) {
        annotation.put12('I', symbolTable.addConstantInteger(intValue).index);
      }
    } else if (value instanceof long[]) {
      long[] longArray = (long[]) value;
      annotation.put12('[', longArray.length);
      for (long longValue : longArray) {
        annotation.put12('J', symbolTable.addConstantLong(longValue).index);
      }
    } else if (value instanceof float[]) {
      float[] floatArray = (float[]) value;
      annotation.put12('[', floatArray.length);
      for (float floatValue : floatArray) {
        annotation.put12('F', symbolTable.addConstantFloat(floatValue).index);
      }
    } else if (value instanceof double[]) {
      double[] doubleArray = (double[]) value;
      annotation.put12('[', doubleArray.length);
      for (double doubleValue : doubleArray) {
        annotation.put12('D', symbolTable.addConstantDouble(doubleValue).index);
      }
    } else {
      Symbol symbol = symbolTable.addConstant(value);
      annotation.put12(".s.IFJDCS".charAt(symbol.tag), symbol.index);
    }
  }

  @Override
  public void visitEnum(final String name, final String descriptor, final String value) {
    // Case of an element_value with an enum_const_value field.
    // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1.
    ++numElementValuePairs;
    if (useNamedValues) {
      annotation.putShort(symbolTable.addConstantUtf8(name));
    }
    annotation
        .put12('e', symbolTable.addConstantUtf8(descriptor))
        .putShort(symbolTable.addConstantUtf8(value));
  }

  @Override
  public AnnotationVisitor visitAnnotation(final String name, final String descriptor) {
    // Case of an element_value with an annotation_value field.
    // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1.
    ++numElementValuePairs;
    if (useNamedValues) {
      annotation.putShort(symbolTable.addConstantUtf8(name));
    }
    // Write tag and type_index, and reserve 2 bytes for num_element_value_pairs.
    annotation.put12('@', symbolTable.addConstantUtf8(descriptor)).putShort(0);
    return new AnnotationWriter(symbolTable, annotation, null);
  }
@Override
  public void visit(final String name, final Object value) {
    // Case of an element_value with a const_value_index, class_info_index or array_index field.
    // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1.
    ++numElementValuePairs;
    if (useNamedValues) {
      annotation.putShort(symbolTable.addConstantUtf8(name));
    }
    if (value instanceof String) {
      annotation.put12('s', symbolTable.addConstantUtf8((String) value));
    } else if (value instanceof Byte) {
      annotation.put12('B', symbolTable.addConstantInteger(((Byte) value).byteValue()).index);
    } else if (value instanceof Boolean) {
      int booleanValue = ((Boolean) value).booleanValue() ? 1 : 0;
      annotation.put12('Z', symbolTable.addConstantInteger(booleanValue).index);
    } else if (value instanceof Character) {
      annotation.put12('C', symbolTable.addConstantInteger(((Character) value).charValue()).index);
    } else if (value instanceof Short) {
      annotation.put12('S', symbolTable.addConstantInteger(((Short) value).shortValue()).index);
    } else if (value instanceof Type) {
      annotation.put12('c', symbolTable.addConstantUtf8(((Type) value).getDescriptor()));
    } else if (value instanceof byte[]) {
      byte[] byteArray = (byte[]) value;
      annotation.put12('[', byteArray.length);
      for (byte byteValue : byteArray) {
        annotation.put12('B', symbolTable.addConstantInteger(byteValue).index);
      }
    } else if (value instanceof boolean[]) {
      boolean[] booleanArray = (boolean[]) value;
      annotation.put12('[', booleanArray.length);
      for (boolean booleanValue : booleanArray) {
        annotation.put12('Z', symbolTable.addConstantInteger(booleanValue ? 1 : 0).index);
      }
    } else if (value instanceof short[]) {
      short[] shortArray = (short[]) value;
      annotation.put12('[', shortArray.length);
      for (short shortValue : shortArray) {
        annotation.put12('S', symbolTable.addConstantInteger(shortValue).index);
      }
    } else if (value instanceof char[]) {
      char[] charArray = (char[]) value;
      annotation.put12('[', charArray.length);
      for (char charValue : charArray) {
        annotation.put12('C', symbolTable.addConstantInteger(charValue).index);
      }
    } else if (value instanceof int[]) {
      int[] intArray = (int[]) value;
      annotation.put12('[', intArray.length);
      for (int intValue : intArray) {
        annotation.put12('I', symbolTable.addConstantInteger(intValue).index);
      }
    } else if (value instanceof long[]) {
      long[] longArray = (long[]) value;
      annotation.put12('[', longArray.length);
      for (long longValue : longArray) {
        annotation.put12('J', symbolTable.addConstantLong(longValue).index);
      }
    } else if (value instanceof float[]) {
      float[] floatArray = (float[]) value;
      annotation.put12('[', floatArray.length);
      for (float floatValue : floatArray) {
        annotation.put12('F', symbolTable.addConstantFloat(floatValue).index);
      }
    } else if (value instanceof double[]) {
      double[] doubleArray = (double[]) value;
      annotation.put12('[', doubleArray.length);
      for (double doubleValue : doubleArray) {
        annotation.put12('D', symbolTable.addConstantDouble(doubleValue).index);
      }
    } else {
      Symbol symbol = symbolTable.addConstant(value);
      annotation.put12(".s.IFJDCS".charAt(symbol.tag), symbol.index);
    }
  }

  @Override
  public void visitEnum(final String name, final String descriptor, final String value) {
    // Case of an element_value with an enum_const_value field.
    // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1.
    ++numElementValuePairs;
    if (useNamedValues) {
      annotation.putShort(symbolTable.addConstantUtf8(name));
    }
    annotation
        .put12('e', symbolTable.addConstantUtf8(descriptor))
        .putShort(symbolTable.addConstantUtf8(value));
  }

  @Override
  public AnnotationVisitor visitAnnotation(final String name, final String descriptor) {
    // Case of an element_value with an annotation_value field.
    // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1.
    ++numElementValuePairs;
    if (useNamedValues) {
      annotation.putShort(symbolTable.addConstantUtf8(name));
    }
    // Write tag and type_index, and reserve 2 bytes for num_element_value_pairs.
    annotation.put12('@', symbolTable.addConstantUtf8(descriptor)).putShort(0);
    return new AnnotationWriter(symbolTable, annotation, null);
  }
@ Override public void visit ( final String name , final Object value ) { // Case of an element_value with a const_value_index, class_info_index or array_index field. // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1. ++ numElementValuePairs ; if ( useNamedValues ) { annotation . putShort ( symbolTable . addConstantUtf8 ( name ) ) ; } if ( value instanceof String ) { annotation . put12 ( ' ' , symbolTable . addConstantUtf8 ( ( String ) value ) ) ; } else if ( value instanceof Byte ) { annotation . put12 ( ' ' , symbolTable . addConstantInteger ( ( ( Byte ) value ) . byteValue ( ) ) . index ) ; } else if ( value instanceof Boolean ) { int booleanValue = ( ( Boolean ) value ) . booleanValue ( ) ? 1 : 0 ; annotation . put12 ( ' ' , symbolTable . addConstantInteger ( booleanValue ) . index ) ; } else if ( value instanceof Character ) { annotation . put12 ( ' ' , symbolTable . addConstantInteger ( ( ( Character ) value ) . charValue ( ) ) . index ) ; } else if ( value instanceof Short ) { annotation . put12 ( ' ' , symbolTable . addConstantInteger ( ( ( Short ) value ) . shortValue ( ) ) . index ) ; } else if ( value instanceof Type ) { annotation . put12 ( ' ' , symbolTable . addConstantUtf8 ( ( ( Type ) value ) . getDescriptor ( ) ) ) ; } else if ( value instanceof byte [ ] ) { byte [ ] byteArray = ( byte [ ] ) value ; annotation . put12 ( ' [ ' , byteArray . length ) ; for ( byte byteValue : byteArray ) { annotation . put12 ( ' ' , symbolTable . addConstantInteger ( byteValue ) . index ) ; } } else if ( value instanceof boolean [ ] ) { boolean [ ] booleanArray = ( boolean [ ] ) value ; annotation . put12 ( ' [ ' , booleanArray . length ) ; for ( boolean booleanValue : booleanArray ) { annotation . put12 ( ' Z ' , symbolTable . addConstantInteger ( booleanValue ? 1 : 0 ) . index ) ; } } else if ( value instanceof short [ ] ) { short [ ] shortArray = ( short [ ] ) value ; annotation . put12 ( ' [ ' , shortArray . length ) ; for ( short shortValue : shortArray ) { annotation . put12 ( ' S ' , symbolTable . addConstantInteger ( shortValue ) . index ) ; } } else if ( value instanceof char [ ] ) { char [ ] charArray = ( char [ ] ) value ; annotation . put12 ( ' [ ' , charArray . length ) ; for ( char charValue : charArray ) { annotation . put12 ( ' ' , symbolTable . addConstantInteger ( charValue ) . index ) ; } } else if ( value instanceof int [ ] ) { int [ ] intArray = ( int [ ] ) value ; annotation . put12 ( ' [ ' , intArray . length ) ; for ( int intValue : intArray ) { annotation . put12 ( ' I ' , symbolTable . addConstantInteger ( intValue ) . index ) ; } } else if ( value instanceof long [ ] ) { long [ ] longArray = ( long [ ] ) value ; annotation . put12 ( ' [ ' , longArray . length ) ; for ( long longValue : longArray ) { annotation . put12 ( ' J ' , symbolTable . addConstantLong ( longValue ) . index ) ; } } else if ( value instanceof float [ ] ) { float [ ] floatArray = ( float [ ] ) value ; annotation . put12 ( ' [ ' , floatArray . length ) ; for ( float floatValue : floatArray ) { annotation . put12 ( ' ' , symbolTable . addConstantFloat ( floatValue ) . index ) ; } } else if ( value instanceof double [ ] ) { double [ ] doubleArray = ( double [ ] ) value ; annotation . put12 ( ' [ ' , doubleArray . length ) ; for ( double doubleValue : doubleArray ) { annotation . put12 ( ' ' , symbolTable . addConstantDouble ( doubleValue ) . index ) ; } } else { Symbol symbol = symbolTable . addConstant ( value ) ; annotation . put12 ( ".s.IFJDCS" . charAt ( symbol . tag ) , symbol . index ) ; } } @ Override public void visitEnum ( final String name , final String descriptor , final String value ) { // Case of an element_value with an enum_const_value field. // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1. ++ numElementValuePairs ; if ( useNamedValues ) { annotation . putShort ( symbolTable . addConstantUtf8 ( name ) ) ; } annotation . put12 ( ' ' , symbolTable . addConstantUtf8 ( descriptor ) ) . putShort ( symbolTable . addConstantUtf8 ( value ) ) ; } @ Override public AnnotationVisitor visitAnnotation ( final String name , final String descriptor ) { // Case of an element_value with an annotation_value field. // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1. ++ numElementValuePairs ; if ( useNamedValues ) { annotation . putShort ( symbolTable . addConstantUtf8 ( name ) ) ; } // Write tag and type_index, and reserve 2 bytes for num_element_value_pairs. annotation . put12 ( ' ' , symbolTable . addConstantUtf8 ( descriptor ) ) . putShort ( 0 ) ; return new AnnotationWriter ( symbolTable , annotation , null ) ; }
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------