Reads a JVMS 'element_value' structure and makes the given visitor visit it. @param annotationVisitor the visitor that must visit the element_value structure. @param elementValueOffset the start offset in #b of the element_value structure to be read. @param elementName the name of the e
(
final AnnotationVisitor annotationVisitor,
final int elementValueOffset,
final String elementName,
final char[] charBuffer)
| 2779 | * @return the end offset of the JVMS 'element_value' structure. |
| 2780 | */ |
| 2781 | private int readElementValue( |
| 2782 | final AnnotationVisitor annotationVisitor, |
| 2783 | final int elementValueOffset, |
| 2784 | final String elementName, |
| 2785 | final char[] charBuffer) { |
| 2786 | int currentOffset = elementValueOffset; |
| 2787 | if (annotationVisitor == null) { |
| 2788 | switch (b[currentOffset] & 0xFF) { |
| 2789 | case 'e': // enum_const_value |
| 2790 | return currentOffset + 5; |
| 2791 | case '@': // annotation_value |
| 2792 | return readElementValues(null, currentOffset + 3, /* named = */ true, charBuffer); |
| 2793 | case '[': // array_value |
| 2794 | return readElementValues(null, currentOffset + 1, /* named = */ false, charBuffer); |
| 2795 | default: |
| 2796 | return currentOffset + 3; |
| 2797 | } |
| 2798 | } |
| 2799 | switch (b[currentOffset++] & 0xFF) { |
| 2800 | case 'B': // const_value_index, CONSTANT_Integer |
| 2801 | annotationVisitor.visit( |
| 2802 | elementName, (byte) readInt(cpInfoOffsets[readUnsignedShort(currentOffset)])); |
| 2803 | currentOffset += 2; |
| 2804 | break; |
| 2805 | case 'C': // const_value_index, CONSTANT_Integer |
| 2806 | annotationVisitor.visit( |
| 2807 | elementName, (char) readInt(cpInfoOffsets[readUnsignedShort(currentOffset)])); |
| 2808 | currentOffset += 2; |
| 2809 | break; |
| 2810 | case 'D': // const_value_index, CONSTANT_Double |
| 2811 | case 'F': // const_value_index, CONSTANT_Float |
| 2812 | case 'I': // const_value_index, CONSTANT_Integer |
| 2813 | case 'J': // const_value_index, CONSTANT_Long |
| 2814 | annotationVisitor.visit( |
| 2815 | elementName, readConst(readUnsignedShort(currentOffset), charBuffer)); |
| 2816 | currentOffset += 2; |
| 2817 | break; |
| 2818 | case 'S': // const_value_index, CONSTANT_Integer |
| 2819 | annotationVisitor.visit( |
| 2820 | elementName, (short) readInt(cpInfoOffsets[readUnsignedShort(currentOffset)])); |
| 2821 | currentOffset += 2; |
| 2822 | break; |
| 2823 | |
| 2824 | case 'Z': // const_value_index, CONSTANT_Integer |
| 2825 | annotationVisitor.visit( |
| 2826 | elementName, |
| 2827 | readInt(cpInfoOffsets[readUnsignedShort(currentOffset)]) == 0 |
| 2828 | ? Boolean.FALSE |
| 2829 | : Boolean.TRUE); |
| 2830 | currentOffset += 2; |
| 2831 | break; |
| 2832 | case 's': // const_value_index, CONSTANT_Utf8 |
| 2833 | annotationVisitor.visit(elementName, readUTF8(currentOffset, charBuffer)); |
| 2834 | currentOffset += 2; |
| 2835 | break; |
| 2836 | case 'e': // enum_const_value |
| 2837 | annotationVisitor.visitEnum( |
| 2838 | elementName, |
no test coverage detected