Skip to content

Commit 3976780

Browse files
committed
[GR-70623] Fix unique proxy name for unnamed package.
PullRequest: graal/22327
2 parents 6417d99 + 86e8b77 commit 3976780

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/ProxyRenamingSubstitutionProcessor.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class ProxyRenamingSubstitutionProcessor extends SubstitutionProcessor {
5353
public static final String NULL_CLASS_LOADER_NAME = "native-image-null-class-loader";
5454
public static final String NULL_MODULE_NAME = "native-image-null-module";
5555
public static final String UNNAMED_MODULE_NAME = "native-image-unnamed";
56-
private static final String STABLE_NAME_TEMPLATE = "/$Proxy.s";
56+
private static final String STABLE_NAME_TEMPLATE = "$Proxy.s";
5757

5858
private final ConcurrentMap<ResolvedJavaType, ProxySubstitutionType> typeSubstitutions = new ConcurrentHashMap<>();
5959
private final Set<String> uniqueTypeNames = new HashSet<>();
@@ -127,12 +127,17 @@ public String getUniqueProxyName(Class<?> clazz) {
127127
}
128128

129129
private String findUniqueName(Class<?> clazz, int hashCode) {
130-
CharSequence baseName = "L" + clazz.getPackageName().replace('.', '/') + STABLE_NAME_TEMPLATE + Integer.toHexString(hashCode);
131-
String name = baseName + ";";
130+
CharSequence baseName;
131+
if (clazz.getPackageName().isEmpty()) {
132+
baseName = STABLE_NAME_TEMPLATE + Integer.toHexString(hashCode);
133+
} else {
134+
baseName = clazz.getPackageName().replace('.', '/') + '/' + STABLE_NAME_TEMPLATE + Integer.toHexString(hashCode);
135+
}
136+
String name = "L" + baseName + ";";
132137
synchronized (uniqueTypeNames) {
133138
int suffix = 1;
134139
while (uniqueTypeNames.contains(name)) {
135-
name = baseName + "_" + suffix + ";";
140+
name = "L" + baseName + "_" + suffix + ";";
136141
suffix++;
137142
}
138143
uniqueTypeNames.add(name);

0 commit comments

Comments
 (0)