Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit 964eb62

Browse files
committed
produce error if mixing styles (class ref/string) in proxy hints
Fixes #629
1 parent a813865 commit 964eb62

File tree

2 files changed

+10
-1
lines changed
  • spring-aot/src/main/java/org/springframework/nativex/type
  • spring-native/src/main/java/org/springframework/nativex/hint

2 files changed

+10
-1
lines changed

spring-aot/src/main/java/org/springframework/nativex/type/Type.java

+7
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,10 @@ private void unpackProxyHint(AnnotationNode typeInfo, HintDeclaration ch) {
20252025
// Note: Proxies hints will get discarded immediately if types are not around
20262026
List<String> proxyTypes = new ArrayList<>();
20272027
boolean typeMissing = false;
2028+
boolean typesSpecified = false;
2029+
boolean typenamesSpecified = false;
20282030
for (org.objectweb.asm.Type type : types) {
2031+
typesSpecified = true;
20292032
String typeName = type.getClassName();
20302033
Type resolvedType = typeSystem.resolveName(typeName, true);
20312034
if (resolvedType != null) {
@@ -2035,13 +2038,17 @@ private void unpackProxyHint(AnnotationNode typeInfo, HintDeclaration ch) {
20352038
}
20362039
}
20372040
for (String typeName : typeNames) {
2041+
typenamesSpecified = true;
20382042
Type resolvedType = typeSystem.resolveName(typeName, true);
20392043
if (resolvedType != null) {
20402044
proxyTypes.add(typeName);
20412045
} else {
20422046
typeMissing = true;
20432047
}
20442048
}
2049+
if (typesSpecified && typenamesSpecified) {
2050+
throw new IllegalStateException("ERROR: [Limitation] Don't mix typenames and explicit type references in a ProxyHint on type "+getDottedName());
2051+
}
20452052
if (!typeMissing) {
20462053
ch.addProxyDescriptor(new ProxyDescriptor(proxyTypes.toArray(new String[0])));
20472054
}

spring-native/src/main/java/org/springframework/nativex/hint/ProxyHint.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
* sets of types need proxies.
2626
* Interface references via the {@link #types} member are the preferred form of use but sometimes due
2727
* to accessibility restrictions or nested types the type names may need to be specified in the {@link #typeNames}
28-
* member.
28+
* member. The ordering of types when building a proxy is important, therefore we don't allow mixing the class reference
29+
* and string styles as it may not result in the ordering you entered the attributes in at the source level. In these cases
30+
* it is best to simple use the typeNames attribute (the ordering within a particular attribute is guaranteed).
2931
*
3032
* @see <a href="https://www.graalvm.org/reference-manual/native-image/DynamicProxy/">Dynamic proxy in native image</a>
3133
* @author Andy Clement

0 commit comments

Comments
 (0)