Skip to content

Commit 877c84c

Browse files
committed
Don't add empty TimeZoneSupport in OS other than Windows
1 parent d71c9f2 commit 877c84c

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ private static String getSystemTimeZoneID(String javaHome) {
100100
if (ImageSingletons.contains(TimeZoneSupport.class)) {
101101
byte[] content = ImageSingletons.lookup(TimeZoneSupport.class).getTzMappingsContent();
102102
contentLen = content.length;
103-
if (contentLen != 0) {
104-
refContent = PrimitiveArrayView.createForReading(content);
105-
tzMappingsPtr = refContent.addressOfArrayElement(0);
106-
}
103+
refContent = PrimitiveArrayView.createForReading(content);
104+
tzMappingsPtr = refContent.addressOfArrayElement(0);
107105
}
108106
CCharPointer tzId = LibCHelper.SVM_FindJavaTZmd(tzMappingsPtr, contentLen);
109107
String result = CTypeConversion.toJavaString(tzId);
@@ -187,11 +185,6 @@ private static byte[] cleanCR(byte[] buffer) {
187185
public void afterRegistration(AfterRegistrationAccess access) {
188186

189187
if (OS.getCurrent() != OS.WINDOWS) {
190-
if (ImageLayerBuildingSupport.buildingImageLayer()) {
191-
// GR-75591: The ImageSingletons.contains plugin records this application-layer
192-
// singleton even when the platform-specific payload is unused.
193-
ImageSingletons.add(TimeZoneSupport.class, new TimeZoneSupport(new byte[0]));
194-
}
195188
return;
196189
}
197190

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.oracle.svm.core.graal.code.CGlobalDataInfo;
3232
import com.oracle.svm.core.imagelayer.AccessImageSingletonFactory;
3333
import com.oracle.svm.hosted.c.CGlobalDataFeature;
34+
import com.oracle.svm.shared.BuildPhaseProvider;
3435
import com.oracle.svm.shared.singletons.LayeredImageSingletonSupport;
3536
import com.oracle.svm.shared.util.VMError;
3637

@@ -100,7 +101,13 @@ void setApplicationLayerConstant() {
100101

101102
@Override
102103
public final boolean isApplicationLayerConstant() {
103-
return applicationLayerConstant;
104+
VMError.guarantee(BuildPhaseProvider.isAnalysisStarted(), "The singleton can still be added until the analysis starts.");
105+
/*
106+
* Application layer singletons are optional, so even if they are looked up in a shared
107+
* layer, they might still not be present in the final image. In that case, the lookup
108+
* throws at runtime and the singleton cannot be folded.
109+
*/
110+
return applicationLayerConstant && ImageSingletons.contains(slotData.key);
104111
}
105112
}
106113

0 commit comments

Comments
 (0)