MCPcopy Index your code
hub / github.com/clojure/clojure / readMethod

Method readMethod

src/jvm/clojure/asm/ClassReader.java:1008–1280  ·  view source on GitHub ↗

Reads a JVMS method_info structure and makes the given visitor visit it. @param classVisitor the visitor that must visit the method. @param context information about the class being parsed. @param methodInfoOffset the start offset of the method_info structure. @return the offset of the first byte f

(
      final ClassVisitor classVisitor, final Context context, final int methodInfoOffset)

Source from the content-addressed store, hash-verified

1006 * @return the offset of the first byte following the method_info structure.
1007 */
1008 private int readMethod(
1009 final ClassVisitor classVisitor, final Context context, final int methodInfoOffset) {
1010 char[] charBuffer = context.charBuffer;
1011
1012 // Read the access_flags, name_index and descriptor_index fields.
1013 int currentOffset = methodInfoOffset;
1014 context.currentMethodAccessFlags = readUnsignedShort(currentOffset);
1015 context.currentMethodName = readUTF8(currentOffset + 2, charBuffer);
1016 context.currentMethodDescriptor = readUTF8(currentOffset + 4, charBuffer);
1017 currentOffset += 6;
1018
1019 // Read the method attributes (the variables are ordered as in Section 4.7 of the JVMS).
1020 // Attribute offsets exclude the attribute_name_index and attribute_length fields.
1021 // - The offset of the Code attribute, or 0.
1022 int codeOffset = 0;
1023 // - The offset of the Exceptions attribute, or 0.
1024 int exceptionsOffset = 0;
1025 // - The strings corresponding to the Exceptions attribute, or null.
1026 String[] exceptions = null;
1027 // - Whether the method has a Synthetic attribute.
1028 boolean synthetic = false;
1029 // - The constant pool index contained in the Signature attribute, or 0.
1030 int signatureIndex = 0;
1031 // - The offset of the RuntimeVisibleAnnotations attribute, or 0.
1032 int runtimeVisibleAnnotationsOffset = 0;
1033 // - The offset of the RuntimeInvisibleAnnotations attribute, or 0.
1034 int runtimeInvisibleAnnotationsOffset = 0;
1035 // - The offset of the RuntimeVisibleParameterAnnotations attribute, or 0.
1036 int runtimeVisibleParameterAnnotationsOffset = 0;
1037 // - The offset of the RuntimeInvisibleParameterAnnotations attribute, or 0.
1038 int runtimeInvisibleParameterAnnotationsOffset = 0;
1039 // - The offset of the RuntimeVisibleTypeAnnotations attribute, or 0.
1040 int runtimeVisibleTypeAnnotationsOffset = 0;
1041 // - The offset of the RuntimeInvisibleTypeAnnotations attribute, or 0.
1042 int runtimeInvisibleTypeAnnotationsOffset = 0;
1043 // - The offset of the AnnotationDefault attribute, or 0.
1044 int annotationDefaultOffset = 0;
1045 // - The offset of the MethodParameters attribute, or 0.
1046 int methodParametersOffset = 0;
1047 // - The non standard attributes (linked with their {@link Attribute#nextAttribute} field).
1048 // This list in the <i>reverse order</i> or their order in the ClassFile structure.
1049 Attribute attributes = null;
1050
1051 int attributesCount = readUnsignedShort(currentOffset);
1052 currentOffset += 2;
1053 while (attributesCount-- > 0) {
1054 // Read the attribute_info's attribute_name and attribute_length fields.
1055 String attributeName = readUTF8(currentOffset, charBuffer);
1056 int attributeLength = readInt(currentOffset + 2);
1057 currentOffset += 6;
1058 // The tests are sorted in decreasing frequency order (based on frequencies observed on
1059 // typical classes).
1060 if (Constants.CODE.equals(attributeName)) {
1061 if ((context.parsingOptions & SKIP_CODE) == 0) {
1062 codeOffset = currentOffset;
1063 }
1064 } else if (Constants.EXCEPTIONS.equals(attributeName)) {
1065 exceptionsOffset = currentOffset;

Callers 1

acceptMethod · 0.95

Calls 15

readUnsignedShortMethod · 0.95
readUTF8Method · 0.95
readIntMethod · 0.95
readClassMethod · 0.95
readAttributeMethod · 0.95
readUTFMethod · 0.95
readByteMethod · 0.95
visitParameterMethod · 0.95
readElementValueMethod · 0.95
visitEndMethod · 0.95

Tested by

no test coverage detected