MCPcopy Create free account
hub / github.com/ReadyTalk/avian / parseType

Method parseType

classpath/java/lang/reflect/SignatureParser.java:49–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47 }
48
49 private Type parseType() {
50 char c = array[offset++];
51 if (c == 'B') {
52 return Byte.TYPE;
53 } else if (c == 'C') {
54 return Character.TYPE;
55 } else if (c == 'D') {
56 return Double.TYPE;
57 } else if (c == 'F') {
58 return Float.TYPE;
59 } else if (c == 'I') {
60 return Integer.TYPE;
61 } else if (c == 'J') {
62 return Long.TYPE;
63 } else if (c == 'S') {
64 return Short.TYPE;
65 } else if (c == 'Z') {
66 return Boolean.TYPE;
67 } else if (c == 'T') {
68 int end = signature.indexOf(';', offset);
69 if (end < 0) {
70 throw new RuntimeException("No semicolon found while parsing signature");
71 }
72 Type res = typeVariables.get(new String(array, offset, end - offset));
73 offset = end + 1;
74 return res;
75 } else if (c != 'L') {
76 throw new IllegalArgumentException("Unexpected character: " + c + ", signature: " + new String(array, 0, array.length) + ", i = " + offset);
77 }
78 StringBuilder builder = new StringBuilder();
79 Type ownerType = null;
80 for (;;) {
81 for (;;) {
82 c = array[offset++];
83 if (c == ';' || c == '<') {
84 break;
85 }
86 builder.append(c == '/' ? '.' : c);
87 }
88 String rawTypeName = builder.toString();
89 Class<?> rawType;
90 try {
91 rawType = loader.loadClass(rawTypeName);
92 } catch (ClassNotFoundException e) {
93 throw new RuntimeException("Could not find class " + rawTypeName);
94 }
95
96 int lastDollar = rawTypeName.lastIndexOf('$');
97 if (lastDollar != -1 && ownerType == null) {
98 String ownerName = rawTypeName.substring(0, lastDollar);
99 try {
100 ownerType = loader.loadClass(ownerName);
101 } catch (ClassNotFoundException e) {
102 throw new RuntimeException("Could not find class " + ownerName);
103 }
104 }
105
106 if (c == ';') {

Callers 1

SignatureParserMethod · 0.95

Calls 11

appendMethod · 0.95
toStringMethod · 0.95
lastIndexOfMethod · 0.95
substringMethod · 0.95
addMethod · 0.95
makeTypeMethod · 0.95
sizeMethod · 0.95
indexOfMethod · 0.65
getMethod · 0.65
toArrayMethod · 0.65
loadClassMethod · 0.45

Tested by

no test coverage detected