Skip to content

Commit

Permalink
Merge branch 'community-backports-jdk21u' master into mandrel/23.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jerboaa committed Sep 16, 2024
2 parents adc3f3f + a4bc8f4 commit c58002c
Showing 1 changed file with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,23 +635,35 @@ private static boolean hasDefaultValue(Field annotatedField) {

private void handleDeletedClass(Class<?> originalClass, Delete deleteAnnotation) {
if (NativeImageOptions.ReportUnsupportedElementsAtRuntime.getValue()) {
ResolvedJavaType type = metaAccess.lookupJavaType(originalClass);

try {
type.link();
} catch (LinkageError ignored) {
/*
* Ignore any linking errors. A type that cannot be linked doesn't need elements
* replaced: it will simply fail at runtime with the same linkage error before
* reaching those elements.
*/
return;
}

/*
* We register all methods and fields as deleted. That still allows usage of the type in
* type checks.
*/
for (Executable m : originalClass.getDeclaredMethods()) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
registerAsDeleted(null, method, deleteAnnotation);
}
for (Executable m : originalClass.getDeclaredConstructors()) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
registerAsDeleted(null, method, deleteAnnotation);
for (ResolvedJavaMethod constructor : type.getDeclaredConstructors()) {
registerAsDeleted(null, constructor, deleteAnnotation);
}
for (Field f : originalClass.getDeclaredFields()) {
ResolvedJavaField field = metaAccess.lookupJavaField(f);
registerAsDeleted(null, field, deleteAnnotation);
for (ResolvedJavaField f : type.getInstanceFields(false)) {
registerAsDeleted(null, f, deleteAnnotation);
}
for (ResolvedJavaField f : type.getStaticFields()) {
registerAsDeleted(null, f, deleteAnnotation);
}

} else {
deleteAnnotations.put(metaAccess.lookupJavaType(originalClass), deleteAnnotation);
}
Expand Down

0 comments on commit c58002c

Please sign in to comment.