Skip to content

Commit

Permalink
[GR-54692] Accept malformed type descriptors coming from user files w…
Browse files Browse the repository at this point in the history
…ith a warning

PullRequest: graal/18077
  • Loading branch information
loicottet authored and vjovanov committed Aug 1, 2024
2 parents ba1f265 + 99434af commit 5487e6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

import java.util.Collection;

import org.graalvm.nativeimage.ImageInfo;

import com.oracle.svm.util.LogUtils;

import jdk.graal.compiler.util.json.JsonPrintable;
import jdk.vm.ci.meta.MetaUtil;

Expand Down Expand Up @@ -68,7 +72,9 @@ enum Kind {
Collection<String> getAllQualifiedJavaNames();

static String checkQualifiedJavaName(String javaName) {
assert javaName.indexOf('/') == -1 || javaName.indexOf('/') > javaName.lastIndexOf('.') : "Requires qualified Java name, not internal representation: %s".formatted(javaName);
if (ImageInfo.inImageBuildtimeCode() && !(javaName.indexOf('/') == -1 || javaName.indexOf('/') > javaName.lastIndexOf('.'))) {
LogUtils.warning("Type descriptor requires qualified Java name, not internal representation: %s", javaName);
}
return canonicalizeTypeName(javaName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,13 @@ private void registerTypesForRecordComponent(RecordComponent recordComponent) {
registerTypesForTypeAnnotations(recordComponent);
}

private void registerTypesForError(Throwable t) {
metaAccess.lookupJavaType(t.getClass()).registerAsInstantiated("Error object on the image heap for reflective queries");
if (t.getCause() != null) {
registerTypesForError(t.getCause());
}
}

private void registerTypesForAnnotations(AnnotatedElement annotatedElement) {
if (annotatedElement != null) {
if (!filteredAnnotations.containsKey(annotatedElement)) {
Expand Down Expand Up @@ -1097,10 +1104,11 @@ private void maybeRegisterRecordComponents(Class<?> clazz) {
}
}

private static void registerLinkageError(Class<?> clazz, LinkageError error, Map<Class<?>, Throwable> errorMap) {
private void registerLinkageError(Class<?> clazz, LinkageError error, Map<Class<?>, Throwable> errorMap) {
if (LinkAtBuildTimeSupport.singleton().linkAtBuildTime(clazz)) {
throw error;
} else {
registerTypesForError(error);
errorMap.put(clazz, error);
}
}
Expand Down

0 comments on commit 5487e6b

Please sign in to comment.