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

Method makeInvokeCode

classpath/java/lang/reflect/Proxy.java:81–327  ·  view source on GitHub ↗
(List<PoolEntry> pool,
                                       String className,
                                       byte[] spec,
                                       int parameterCount,
                                       int parameterFootprint,
                                       int index)

Source from the content-addressed store, hash-verified

79 }
80
81 private static byte[] makeInvokeCode(List<PoolEntry> pool,
82 String className,
83 byte[] spec,
84 int parameterCount,
85 int parameterFootprint,
86 int index)
87 throws IOException
88 {
89 ByteArrayOutputStream out = new ByteArrayOutputStream();
90 write2(out, 8); // max stack
91 write2(out, parameterFootprint); // max locals
92 write4(out, 0); // length (we'll set the real value later)
93
94 write1(out, aload_0);
95 write1(out, getfield);
96 write2(out, ConstantPool.addFieldRef
97 (pool, "java/lang/reflect/Proxy",
98 "h", "Ljava/lang/reflect/InvocationHandler;") + 1);
99
100 write1(out, aload_0);
101
102 write1(out, aload_0);
103 write1(out, getfield);
104 write2(out, ConstantPool.addFieldRef
105 (pool, className,
106 "methodRefs", "[Ljava/lang/reflect/Method;") + 1);
107 write1(out, ldc_w);
108 write2(out, ConstantPool.addInteger(pool, index) + 1);
109 write1(out, aaload);
110
111 write1(out, ldc_w);
112 write2(out, ConstantPool.addInteger(pool, parameterCount) + 1);
113 write1(out, anewarray);
114 write2(out, ConstantPool.addClass(pool, "java/lang/Object") + 1);
115
116 int ai = 0;
117 int si;
118 for (si = 1; spec[si] != ')'; ++si) {
119 write1(out, dup);
120
121 write1(out, ldc_w);
122 write2(out, ConstantPool.addInteger(pool, ai) + 1);
123
124 switch (spec[si]) {
125 case 'L':
126 ++ si;
127 while (spec[si] != ';') ++si;
128
129 write1(out, aload);
130 write1(out, ai + 1);
131 break;
132
133 case '[':
134 ++ si;
135 while (spec[si] == '[') ++si;
136 switch (spec[si]) {
137 case 'L':
138 ++ si;

Callers 1

makeClassMethod · 0.95

Calls 9

addFieldRefMethod · 0.95
addIntegerMethod · 0.95
addClassMethod · 0.95
addMethodRefMethod · 0.95
toByteArrayMethod · 0.95
write2Method · 0.80
write4Method · 0.80
write1Method · 0.80
set4Method · 0.80

Tested by

no test coverage detected