Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from upstream community JDK 21 repo #793

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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