@@ -972,11 +972,15 @@ public RecordComponent[] getRecordComponents(Class<?> type) {
972972
973973 @ Override
974974 public void registerHeapDynamicHub (Object object , ScanReason reason ) {
975- assert !sealed ;
976975 DynamicHub hub = (DynamicHub ) object ;
977976 Class <?> javaClass = hub .getHostedJavaClass ();
978- if (heapDynamicHubs .add (hub ) && !SubstitutionReflectivityFilter .shouldExclude (javaClass , metaAccess , universe )) {
979- registerTypesForClass (metaAccess .lookupJavaType (javaClass ), javaClass );
977+ if (heapDynamicHubs .add (hub )) {
978+ if (sealed ) {
979+ throw new UnsupportedFeatureException ("Registering new class for reflection when the image heap is already sealed: " + javaClass );
980+ }
981+ if (!SubstitutionReflectivityFilter .shouldExclude (javaClass , metaAccess , universe )) {
982+ registerTypesForClass (metaAccess .lookupJavaType (javaClass ), javaClass );
983+ }
980984 }
981985 }
982986
@@ -988,24 +992,32 @@ public Set<DynamicHub> getHeapDynamicHubs() {
988992
989993 @ Override
990994 public void registerHeapReflectionField (Field reflectField , ScanReason reason ) {
991- assert !sealed ;
992995 AnalysisField analysisField = metaAccess .lookupJavaField (reflectField );
993- if (heapFields .put (analysisField , reflectField ) == null && !SubstitutionReflectivityFilter .shouldExclude (reflectField , metaAccess , universe )) {
994- registerTypesForField (analysisField , reflectField );
995- if (analysisField .getDeclaringClass ().isAnnotation ()) {
996- processAnnotationField (reflectField );
996+ if (heapFields .put (analysisField , reflectField ) == null ) {
997+ if (sealed ) {
998+ throw new UnsupportedFeatureException ("Registering new field for reflection when the image heap is already sealed: " + reflectField );
999+ }
1000+ if (!SubstitutionReflectivityFilter .shouldExclude (reflectField , metaAccess , universe )) {
1001+ registerTypesForField (analysisField , reflectField );
1002+ if (analysisField .getDeclaringClass ().isAnnotation ()) {
1003+ processAnnotationField (reflectField );
1004+ }
9971005 }
9981006 }
9991007 }
10001008
10011009 @ Override
10021010 public void registerHeapReflectionExecutable (Executable reflectExecutable , ScanReason reason ) {
1003- assert !sealed ;
10041011 AnalysisMethod analysisMethod = metaAccess .lookupJavaMethod (reflectExecutable );
1005- if (heapMethods .put (analysisMethod , reflectExecutable ) == null && !SubstitutionReflectivityFilter .shouldExclude (reflectExecutable , metaAccess , universe )) {
1006- registerTypesForMethod (analysisMethod , reflectExecutable );
1007- if (reflectExecutable instanceof Method && reflectExecutable .getDeclaringClass ().isAnnotation ()) {
1008- processAnnotationMethod (false , (Method ) reflectExecutable );
1012+ if (heapMethods .put (analysisMethod , reflectExecutable ) == null ) {
1013+ if (sealed ) {
1014+ throw new UnsupportedFeatureException ("Registering new method for reflection when the image heap is already sealed: " + reflectExecutable );
1015+ }
1016+ if (!SubstitutionReflectivityFilter .shouldExclude (reflectExecutable , metaAccess , universe )) {
1017+ registerTypesForMethod (analysisMethod , reflectExecutable );
1018+ if (reflectExecutable instanceof Method && reflectExecutable .getDeclaringClass ().isAnnotation ()) {
1019+ processAnnotationMethod (false , (Method ) reflectExecutable );
1020+ }
10091021 }
10101022 }
10111023 }
0 commit comments