7171import com .oracle .svm .core .annotate .TargetElement ;
7272import com .oracle .svm .core .annotate .Uninterruptible ;
7373import com .oracle .svm .core .annotate .UnknownObjectField ;
74+ import com .oracle .svm .core .annotate .UnknownPrimitiveField ;
7475import com .oracle .svm .core .classinitialization .ClassInitializationInfo ;
7576import com .oracle .svm .core .classinitialization .EnsureClassInitializedNode ;
7677import com .oracle .svm .core .jdk .JDK11OrEarlier ;
7778import com .oracle .svm .core .jdk .JDK17OrLater ;
7879import com .oracle .svm .core .jdk .Resources ;
7980import com .oracle .svm .core .meta .SharedType ;
80- import com .oracle .svm .core .reflect .MethodMetadataDecoder ;
81+ import com .oracle .svm .core .reflect .ReflectionMetadataDecoder ;
8182import com .oracle .svm .core .reflect .Target_java_lang_reflect_RecordComponent ;
8283import com .oracle .svm .core .reflect .Target_jdk_internal_reflect_ConstantPool ;
8384import com .oracle .svm .core .util .LazyFinalReference ;
@@ -323,24 +324,24 @@ public void setModule(Module module) {
323324 @ TargetElement (onlyWith = JDK11OrEarlier .class ) //
324325 private Class <?> newInstanceCallerCache ;
325326
326- @ UnknownObjectField ( types = { byte []. class }) private byte [] enclosingMethodInfo ;
327+ @ UnknownPrimitiveField private int enclosingMethodInfoIndex ;
327328
328- @ UnknownObjectField ( types = { byte []. class }) private byte [] annotations ;
329+ @ UnknownPrimitiveField private int annotationsIndex ;
329330
330- @ UnknownObjectField ( types = { byte []. class }) private byte [] typeAnnotations ;
331+ @ UnknownPrimitiveField private int typeAnnotationsIndex ;
331332
332- @ UnknownObjectField ( types = { byte []. class }) byte [] fieldsEncoding ;
333+ @ UnknownPrimitiveField int fieldsEncodingIndex ;
333334
334- @ UnknownObjectField ( types = { byte []. class }) byte [] methodsEncoding ;
335+ @ UnknownPrimitiveField int methodsEncodingIndex ;
335336
336- @ UnknownObjectField ( types = { byte []. class }) byte [] constructorsEncoding ;
337+ @ UnknownPrimitiveField int constructorsEncodingIndex ;
337338
338- @ UnknownObjectField ( types = { byte []. class }) byte [] classesEncoding ;
339+ @ UnknownPrimitiveField int classesEncodingIndex ;
339340
340341 @ TargetElement (onlyWith = JDK17OrLater .class )//
341- @ UnknownObjectField ( types = { byte []. class }) byte [] recordComponentsEncoding ;
342+ @ UnknownPrimitiveField int recordComponentsEncodingIndex ;
342343
343- @ UnknownObjectField ( types = { byte []. class }) byte [] permittedSubclassesEncoding ;
344+ @ UnknownPrimitiveField int permittedSubclassesEncodingIndex ;
344345
345346 @ Platforms (Platform .HOSTED_ONLY .class )
346347 public DynamicHub (Class <?> hostedJavaClass , String name , HubType hubType , ReferenceType referenceType , Object isLocalClass , Object isAnonymousClass , DynamicHub superType , DynamicHub componentHub ,
@@ -475,48 +476,48 @@ public String getSignature() {
475476 }
476477
477478 @ Platforms (Platform .HOSTED_ONLY .class )
478- public void setFieldsEncoding ( byte [] encoding ) {
479- this .fieldsEncoding = encoding ;
479+ public void setFieldsEncodingIndex ( int encodingIndex ) {
480+ this .fieldsEncodingIndex = encodingIndex ;
480481 }
481482
482483 @ Platforms (Platform .HOSTED_ONLY .class )
483- public void setMethodsEncoding ( byte [] encoding ) {
484- this .methodsEncoding = encoding ;
484+ public void setMethodsEncodingIndex ( int encodingIndex ) {
485+ this .methodsEncodingIndex = encodingIndex ;
485486 }
486487
487488 @ Platforms (Platform .HOSTED_ONLY .class )
488- public void setConstructorsEncoding ( byte [] encoding ) {
489- this .constructorsEncoding = encoding ;
489+ public void setConstructorsEncodingIndex ( int encodingIndex ) {
490+ this .constructorsEncodingIndex = encodingIndex ;
490491 }
491492
492493 @ Platforms (Platform .HOSTED_ONLY .class )
493- public void setClassesEncoding ( byte [] encoding ) {
494- this .classesEncoding = encoding ;
494+ public void setClassesEncodingIndex ( int encodingIndex ) {
495+ this .classesEncodingIndex = encodingIndex ;
495496 }
496497
497498 @ Platforms (Platform .HOSTED_ONLY .class )
498- public void setRecordComponentsEncoding ( byte [] encoding ) {
499- this .recordComponentsEncoding = encoding ;
499+ public void setRecordComponentsEncodingIndex ( int encodingIndex ) {
500+ this .recordComponentsEncodingIndex = encodingIndex ;
500501 }
501502
502503 @ Platforms (Platform .HOSTED_ONLY .class )
503- public void setPermittedSubclassesEncoding ( byte [] encoding ) {
504- this .permittedSubclassesEncoding = encoding ;
504+ public void setPermittedSubclassesEncodingIndex ( int encodingIndex ) {
505+ this .permittedSubclassesEncodingIndex = encodingIndex ;
505506 }
506507
507508 @ Platforms (Platform .HOSTED_ONLY .class )
508- public void setAnnotationsEncoding ( byte [] encoding ) {
509- this .annotations = encoding ;
509+ public void setAnnotationsEncodingIndex ( int encodingIndex ) {
510+ this .annotationsIndex = encodingIndex ;
510511 }
511512
512513 @ Platforms (Platform .HOSTED_ONLY .class )
513- public void setTypeAnnotationsEncoding ( byte [] encoding ) {
514- this .typeAnnotations = encoding ;
514+ public void setTypeAnnotationsEncodingIndex ( int encodingIndex ) {
515+ this .typeAnnotationsIndex = encodingIndex ;
515516 }
516517
517518 @ Platforms (Platform .HOSTED_ONLY .class )
518- public void setEnclosingMethodInfo ( byte [] encoding ) {
519- this .enclosingMethodInfo = encoding ;
519+ public void setEnclosingMethodInfoIndex ( int encodingIndex ) {
520+ this .enclosingMethodInfoIndex = encodingIndex ;
520521 }
521522
522523 /** Executed at runtime. */
@@ -1001,12 +1002,12 @@ public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass)
10011002 @ Substitute
10021003 @ TargetElement (onlyWith = JDK17OrLater .class )
10031004 private Target_java_lang_reflect_RecordComponent [] getRecordComponents0 () {
1004- if (recordComponentsEncoding == null ) {
1005+ if (recordComponentsEncodingIndex == ReflectionMetadataDecoder . NULL_ARRAY ) {
10051006 /* See ReflectionDataBuilder.buildRecordComponents() for details. */
10061007 throw VMError .unsupportedFeature ("Record components not available for record class " + getTypeName () + ". " +
10071008 "All record component accessor methods of this record class must be included in the reflection configuration at image build time, then this method can be called." );
10081009 }
1009- return ImageSingletons .lookup (MethodMetadataDecoder .class ).parseRecordComponents (this , recordComponentsEncoding );
1010+ return ImageSingletons .lookup (ReflectionMetadataDecoder .class ).parseRecordComponents (this , recordComponentsEncodingIndex );
10101011 }
10111012
10121013 @ KeepOriginal
@@ -1329,10 +1330,10 @@ public Optional<?> describeConstable() {
13291330
13301331 @ Substitute
13311332 private Object [] getEnclosingMethod0 () {
1332- if (enclosingMethodInfo == null ) {
1333+ if (enclosingMethodInfoIndex == ReflectionMetadataDecoder . NULL_ARRAY ) {
13331334 return null ;
13341335 }
1335- Object [] enclosingMethod = ImageSingletons .lookup (MethodMetadataDecoder .class ).parseEnclosingMethod (enclosingMethodInfo );
1336+ Object [] enclosingMethod = ImageSingletons .lookup (ReflectionMetadataDecoder .class ).parseEnclosingMethod (enclosingMethodInfoIndex );
13361337 if (enclosingMethod != null ) {
13371338 PredefinedClassesSupport .throwIfUnresolvable ((Class <?>) enclosingMethod [0 ], getClassLoader0 ());
13381339 }
@@ -1365,12 +1366,12 @@ private String getGenericSignature0() {
13651366
13661367 @ Substitute
13671368 byte [] getRawAnnotations () {
1368- return annotations ;
1369+ return ImageSingletons . lookup ( ReflectionMetadataDecoder . class ). parseByteArray ( annotationsIndex ) ;
13691370 }
13701371
13711372 @ Substitute
13721373 byte [] getRawTypeAnnotations () {
1373- return typeAnnotations ;
1374+ return ImageSingletons . lookup ( ReflectionMetadataDecoder . class ). parseByteArray ( typeAnnotationsIndex ) ;
13741375 }
13751376
13761377 @ Substitute
@@ -1380,22 +1381,22 @@ Target_jdk_internal_reflect_ConstantPool getConstantPool() {
13801381
13811382 @ Substitute
13821383 private Field [] getDeclaredFields0 (boolean publicOnly ) {
1383- return ImageSingletons .lookup (MethodMetadataDecoder .class ).parseFields (this , fieldsEncoding , publicOnly , true );
1384+ return ImageSingletons .lookup (ReflectionMetadataDecoder .class ).parseFields (this , fieldsEncodingIndex , publicOnly , true );
13841385 }
13851386
13861387 @ Substitute
13871388 private Method [] getDeclaredMethods0 (boolean publicOnly ) {
1388- return ImageSingletons .lookup (MethodMetadataDecoder .class ).parseMethods (this , methodsEncoding , publicOnly , true );
1389+ return ImageSingletons .lookup (ReflectionMetadataDecoder .class ).parseMethods (this , methodsEncodingIndex , publicOnly , true );
13891390 }
13901391
13911392 @ Substitute
13921393 private Constructor <?>[] getDeclaredConstructors0 (boolean publicOnly ) {
1393- return ImageSingletons .lookup (MethodMetadataDecoder .class ).parseConstructors (this , constructorsEncoding , publicOnly , true );
1394+ return ImageSingletons .lookup (ReflectionMetadataDecoder .class ).parseConstructors (this , constructorsEncodingIndex , publicOnly , true );
13941395 }
13951396
13961397 @ Substitute
13971398 private Class <?>[] getDeclaredClasses0 () {
1398- Class <?>[] declaredClasses = ImageSingletons .lookup (MethodMetadataDecoder .class ).parseClasses (classesEncoding );
1399+ Class <?>[] declaredClasses = ImageSingletons .lookup (ReflectionMetadataDecoder .class ).parseClasses (classesEncodingIndex );
13991400 for (Class <?> clazz : declaredClasses ) {
14001401 PredefinedClassesSupport .throwIfUnresolvable (clazz , getClassLoader0 ());
14011402 }
@@ -1447,10 +1448,10 @@ private native <T> Target_java_lang_Class_ReflectionData<T> newReflectionData(So
14471448 @ Substitute
14481449 @ TargetElement (onlyWith = JDK17OrLater .class )
14491450 private Class <?>[] getPermittedSubclasses0 () {
1450- if (permittedSubclassesEncoding . length == 0 ) {
1451+ if (permittedSubclassesEncodingIndex == ReflectionMetadataDecoder . NULL_ARRAY ) {
14511452 return null ;
14521453 }
1453- Class <?>[] permittedSubclasses = ImageSingletons .lookup (MethodMetadataDecoder .class ).parseClasses (permittedSubclassesEncoding );
1454+ Class <?>[] permittedSubclasses = ImageSingletons .lookup (ReflectionMetadataDecoder .class ).parseClasses (permittedSubclassesEncodingIndex );
14541455 for (Class <?> clazz : permittedSubclasses ) {
14551456 PredefinedClassesSupport .throwIfUnresolvable (clazz , getClassLoader0 ());
14561457 }
@@ -1478,7 +1479,7 @@ private Class<?>[] getPermittedSubclasses0() {
14781479 private static Method [] filterHidingMethods (Method ... methods ) {
14791480 List <Method > filtered = new ArrayList <>();
14801481 for (Method method : methods ) {
1481- if (!ImageSingletons .lookup (MethodMetadataDecoder .class ).isHidingMethod (method .getModifiers ())) {
1482+ if (!ImageSingletons .lookup (ReflectionMetadataDecoder .class ).isHidingMethod (method .getModifiers ())) {
14821483 filtered .add (method );
14831484 }
14841485 }
@@ -1531,15 +1532,15 @@ private static void setNewInstanceCallerCache(DynamicHub that, Class<?> value) {
15311532 }
15321533
15331534 public Field [] getReachableFields () {
1534- return ImageSingletons .lookup (MethodMetadataDecoder .class ).parseFields (this , fieldsEncoding , false , false );
1535+ return ImageSingletons .lookup (ReflectionMetadataDecoder .class ).parseFields (this , fieldsEncodingIndex , false , false );
15351536 }
15361537
15371538 public Method [] getReachableMethods () {
1538- return ImageSingletons .lookup (MethodMetadataDecoder .class ).parseMethods (this , methodsEncoding , false , false );
1539+ return ImageSingletons .lookup (ReflectionMetadataDecoder .class ).parseMethods (this , methodsEncodingIndex , false , false );
15391540 }
15401541
15411542 public Constructor <?>[] getReachableConstructors () {
1542- return ImageSingletons .lookup (MethodMetadataDecoder .class ).parseConstructors (this , constructorsEncoding , false , false );
1543+ return ImageSingletons .lookup (ReflectionMetadataDecoder .class ).parseConstructors (this , constructorsEncodingIndex , false , false );
15431544 }
15441545}
15451546
@@ -1640,7 +1641,7 @@ Method getMostSpecific() {
16401641 }
16411642 }
16421643 /* Filter out hiding methods after the retursive lookup is done */
1643- return ImageSingletons .lookup (MethodMetadataDecoder .class ).isHidingMethod (m .getModifiers ()) ? null : m ;
1644+ return ImageSingletons .lookup (ReflectionMetadataDecoder .class ).isHidingMethod (m .getModifiers ()) ? null : m ;
16441645 }
16451646}
16461647
0 commit comments