Skip to content

Commit bacdca4

Browse files
committed
Allow layered singletons to be subtyped.
1 parent 6a6115b commit bacdca4

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ImageSingletonsSupportImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,6 @@ private void doAddInternal(Class<?> key, Object value) {
228228

229229
if (singleton instanceof MultiLayeredImageSingleton || ApplicationLayerOnlyImageSingleton.isSingletonInstanceOf(singleton)) {
230230

231-
if (!key.equals(singleton.getClass())) {
232-
throw UserError.abort("The implementation class must be the same as the key class. key: %s, singleton: %s", key, singleton);
233-
}
234-
235231
if (singleton instanceof MultiLayeredImageSingleton && ApplicationLayerOnlyImageSingleton.isSingletonInstanceOf(singleton)) {
236232
throw UserError.abort("Singleton cannot implement both %s and %s. singleton: %s", MultiLayeredImageSingleton.class, ApplicationLayerOnlyImageSingleton.class, singleton);
237233
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/imagelayer/LoadImageSingletonFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ void assignSlots(HostedMetaAccess metaAccess) {
580580
int slotAssignment;
581581
LoadImageSingletonDataImpl info = entry.getValue();
582582
var hType = metaAccess.lookupJavaType(info.getLoadType());
583-
if (hType.isInstantiated()) {
583+
if (hType.getWrapped().isAnySubtypeInstantiated()) {
584584
Class<?> keyClass = entry.getKey();
585585
SlotInfo slotInfo = priorKeyToSlotInfoMap.get(entry.getKey());
586586

0 commit comments

Comments
 (0)