@@ -94,8 +94,8 @@ public class RuntimeMetadataDecoderImpl implements RuntimeMetadataDecoder {
94
94
// Value from Reflection.getClassAccessFlags()
95
95
public static final int CLASS_ACCESS_FLAGS_MASK = 0x1FFF ;
96
96
97
- static byte [] getEncoding (DynamicHub hub ) {
98
- return MultiLayeredImageSingleton .getForLayer (RuntimeMetadataEncoding .class , hub . getLayerId () ).getEncoding ();
97
+ static byte [] getEncoding (int layerId ) {
98
+ return MultiLayeredImageSingleton .getForLayer (RuntimeMetadataEncoding .class , layerId ).getEncoding ();
99
99
}
100
100
101
101
static List <byte []> getEncodings () {
@@ -110,16 +110,14 @@ static List<byte[]> getEncodings() {
110
110
* </pre>
111
111
*/
112
112
@ Override
113
- public Field [] parseFields (DynamicHub declaringType , int index , boolean publicOnly ) {
114
- int layerId = declaringType .getLayerId ();
115
- UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
113
+ public Field [] parseFields (DynamicHub declaringType , int index , boolean publicOnly , int layerId ) {
114
+ UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (layerId ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
116
115
return decodeArray (reader , Field .class , (i ) -> (Field ) decodeField (reader , DynamicHub .toClass (declaringType ), publicOnly , true , layerId ), layerId );
117
116
}
118
117
119
118
@ Override
120
- public FieldDescriptor [] parseReachableFields (DynamicHub declaringType , int index ) {
121
- int layerId = declaringType .getLayerId ();
122
- UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
119
+ public FieldDescriptor [] parseReachableFields (DynamicHub declaringType , int index , int layerId ) {
120
+ UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (layerId ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
123
121
return decodeArray (reader , FieldDescriptor .class , (i ) -> (FieldDescriptor ) decodeField (reader , DynamicHub .toClass (declaringType ), false , false , layerId ), layerId );
124
122
}
125
123
@@ -131,16 +129,14 @@ public FieldDescriptor[] parseReachableFields(DynamicHub declaringType, int inde
131
129
* </pre>
132
130
*/
133
131
@ Override
134
- public Method [] parseMethods (DynamicHub declaringType , int index , boolean publicOnly ) {
135
- int layerId = declaringType .getLayerId ();
136
- UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
132
+ public Method [] parseMethods (DynamicHub declaringType , int index , boolean publicOnly , int layerId ) {
133
+ UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (layerId ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
137
134
return decodeArray (reader , Method .class , (i ) -> (Method ) decodeExecutable (reader , DynamicHub .toClass (declaringType ), publicOnly , true , true , layerId ), layerId );
138
135
}
139
136
140
137
@ Override
141
- public MethodDescriptor [] parseReachableMethods (DynamicHub declaringType , int index ) {
142
- int layerId = declaringType .getLayerId ();
143
- UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
138
+ public MethodDescriptor [] parseReachableMethods (DynamicHub declaringType , int index , int layerId ) {
139
+ UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (layerId ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
144
140
return decodeArray (reader , MethodDescriptor .class , (i ) -> (MethodDescriptor ) decodeExecutable (reader , DynamicHub .toClass (declaringType ), false , false , true , layerId ), layerId );
145
141
}
146
142
@@ -152,16 +148,14 @@ public MethodDescriptor[] parseReachableMethods(DynamicHub declaringType, int in
152
148
* </pre>
153
149
*/
154
150
@ Override
155
- public Constructor <?>[] parseConstructors (DynamicHub declaringType , int index , boolean publicOnly ) {
156
- int layerId = declaringType .getLayerId ();
157
- UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
151
+ public Constructor <?>[] parseConstructors (DynamicHub declaringType , int index , boolean publicOnly , int layerId ) {
152
+ UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (layerId ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
158
153
return decodeArray (reader , Constructor .class , (i ) -> (Constructor <?>) decodeExecutable (reader , DynamicHub .toClass (declaringType ), publicOnly , true , false , layerId ), layerId );
159
154
}
160
155
161
156
@ Override
162
- public ConstructorDescriptor [] parseReachableConstructors (DynamicHub declaringType , int index ) {
163
- int layerId = declaringType .getLayerId ();
164
- UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
157
+ public ConstructorDescriptor [] parseReachableConstructors (DynamicHub declaringType , int index , int layerId ) {
158
+ UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (layerId ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
165
159
return decodeArray (reader , ConstructorDescriptor .class , (i ) -> (ConstructorDescriptor ) decodeExecutable (reader , DynamicHub .toClass (declaringType ), false , false , false , layerId ),
166
160
layerId );
167
161
}
@@ -175,7 +169,7 @@ public ConstructorDescriptor[] parseReachableConstructors(DynamicHub declaringTy
175
169
*/
176
170
@ Override
177
171
public Class <?>[] parseClasses (int index , DynamicHub declaringType ) {
178
- return parseClasses (index , getEncoding (declaringType ), declaringType .getLayerId ());
172
+ return parseClasses (index , getEncoding (declaringType . getLayerId () ), declaringType .getLayerId ());
179
173
}
180
174
181
175
@ Override
@@ -201,9 +195,8 @@ private static Class<?>[] parseClasses(int index, byte[] encoding, int layerId)
201
195
* </pre>
202
196
*/
203
197
@ Override
204
- public RecordComponent [] parseRecordComponents (DynamicHub declaringType , int index ) {
205
- int layerId = declaringType .getLayerId ();
206
- UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
198
+ public RecordComponent [] parseRecordComponents (DynamicHub declaringType , int index , int layerId ) {
199
+ UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType .getLayerId ()), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
207
200
return decodeArray (reader , RecordComponent .class , (i ) -> decodeRecordComponent (reader , DynamicHub .toClass (declaringType ), layerId ), layerId );
208
201
}
209
202
@@ -216,7 +209,7 @@ public RecordComponent[] parseRecordComponents(DynamicHub declaringType, int ind
216
209
*/
217
210
@ Override
218
211
public Object [] parseObjects (int index , DynamicHub declaringType ) {
219
- UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
212
+ UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType . getLayerId () ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
220
213
int layerId = declaringType .getLayerId ();
221
214
return decodeArray (reader , Object .class , (i ) -> decodeObject (reader , layerId ), layerId );
222
215
}
@@ -253,7 +246,7 @@ public Object[] parseEnclosingMethod(int index, DynamicHub declaringType) {
253
246
if (isErrorIndex (index )) {
254
247
decodeAndThrowError (index , layerId );
255
248
}
256
- UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
249
+ UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType . getLayerId () ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
257
250
Class <?> declaringClass = decodeType (reader , layerId );
258
251
String name = decodeMemberName (reader , layerId );
259
252
String descriptor = decodeOtherString (reader , layerId );
@@ -262,7 +255,7 @@ public Object[] parseEnclosingMethod(int index, DynamicHub declaringType) {
262
255
263
256
@ Override
264
257
public byte [] parseByteArray (int index , DynamicHub declaringType ) {
265
- UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
258
+ UnsafeArrayTypeReader reader = UnsafeArrayTypeReader .create (getEncoding (declaringType . getLayerId () ), index , ByteArrayReader .supportsUnalignedMemoryAccess ());
266
259
return decodeByteArray (reader );
267
260
}
268
261
@@ -530,7 +523,7 @@ private static Object decodeExecutable(UnsafeArrayTypeReader buf, Class<?> decla
530
523
*/
531
524
if (isMethod ) {
532
525
executable = ReflectionObjectFactory .newMethod (conditions , declaringClass , executable .getName (), executable .getParameterTypes (), Object .class , null , modifiers | NEGATIVE_FLAG_MASK ,
533
- null , null , null , null , null , null , null );
526
+ null , null , null , null , null , null , null , layerId );
534
527
} else {
535
528
executable = ReflectionObjectFactory .newConstructor (conditions , declaringClass , executable .getParameterTypes (), null , modifiers | NEGATIVE_FLAG_MASK , null , null , null , null , null ,
536
529
null );
@@ -576,7 +569,7 @@ private static Object decodeExecutable(UnsafeArrayTypeReader buf, Class<?> decla
576
569
return new MethodDescriptor (declaringClass , name , (String []) parameterTypes );
577
570
}
578
571
return ReflectionObjectFactory .newMethod (conditions , declaringClass , name , (Class <?>[]) parameterTypes , negative ? Object .class : returnType , null , modifiers ,
579
- null , null , null , null , null , null , null );
572
+ null , null , null , null , null , null , null , layerId );
580
573
} else {
581
574
if (!reflectOnly ) {
582
575
return new ConstructorDescriptor (declaringClass , (String []) parameterTypes );
@@ -599,7 +592,7 @@ private static Object decodeExecutable(UnsafeArrayTypeReader buf, Class<?> decla
599
592
Target_java_lang_reflect_Executable executable ;
600
593
if (isMethod ) {
601
594
Method method = ReflectionObjectFactory .newMethod (conditions , declaringClass , name , (Class <?>[]) parameterTypes , returnType , exceptionTypes , modifiers ,
602
- signature , annotations , parameterAnnotations , annotationDefault , accessor , reflectParameters , typeAnnotations );
595
+ signature , annotations , parameterAnnotations , annotationDefault , accessor , reflectParameters , typeAnnotations , layerId );
603
596
if (!reflectOnly ) {
604
597
return new MethodDescriptor (method );
605
598
}
0 commit comments