Skip to content

Commit 1bfc3c0

Browse files
committed
Keep svmjunit separate from libjvm state
1 parent 9371b2e commit 1bfc3c0

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

substratevm/AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ Do not run `mx` commands concurrently; parallel runs can produce misleading fail
2727

2828
- If you touch documented behavior, update `docs/`.
2929
- Do not commit generated output from `mxbuild/`, `svmbuild/`, `graal_dumps/`, or `sources/`.
30+
- Be careful when changing `mx native-unittest` / `svmjunit` feature registration. Features added to the shared native test image affect unrelated tests too.
31+
- Do not register production ImageSingletons or other global runtime markers from shared `svmjunit` test features. In particular, avoid making the shared test image look like a different product or launch mode, such as a `libjvm` image.
32+
- If a test needs product-specific global state, prefer a targeted image or test-specific setup over adding that state to the global native-unit-test feature list in `mx.substratevm/mx_substratevm.py`.

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,11 @@ def native_image_func(args, **kwargs):
392392
yield native_image_func
393393

394394
native_image_context.hosted_assertions = ['-J-ea', '-J-esa']
395+
# Features added here are loaded into the shared `svmjunit` image used by unrelated native unit
396+
# tests as well. Keep them limited to generic test support; do not register product-specific global
397+
# state or ImageSingleton markers here (for example anything that makes `svmjunit` look like a
398+
# `libjvm` image).
395399
_native_unittest_features = '--features=' + ','.join(('com.oracle.svm.test.ImageInfoTest$TestFeature',
396-
'com.oracle.svm.test.LibJVMLauncherOptionTest$TestFeature',
397400
'com.oracle.svm.test.services.ServiceLoaderTest$TestFeature',
398401
'com.oracle.svm.test.services.SecurityServiceTest$TestFeature',
399402
'com.oracle.svm.test.ReflectionRegistrationTest$TestFeature',

substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/LibJVMLauncherOptionTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,11 @@
4040
import java.util.Set;
4141

4242
import org.graalvm.nativeimage.ImageInfo;
43-
import org.graalvm.nativeimage.ImageSingletons;
44-
import org.graalvm.nativeimage.hosted.Feature;
4543
import org.junit.Assert;
4644
import org.junit.Assume;
4745
import org.junit.Test;
4846

4947
import com.oracle.svm.core.jdk.RuntimeBootModuleLayerSupport;
50-
import com.oracle.svm.core.libjvm.LibJVMMainMethodWrappers;
5148
import com.oracle.svm.core.properties.RuntimeSystemPropertyParser;
5249

5350
/// Regression tests for `libjvm` launcher option handling in native unit tests.
@@ -61,15 +58,6 @@ public class LibJVMLauncherOptionTest {
6158

6259
private static final String MISSING_MODULE_NAME = "com.oracle.svm.test.missing.module";
6360

64-
public static class TestFeature implements Feature {
65-
@Override
66-
public void afterRegistration(AfterRegistrationAccess access) {
67-
if (!ImageSingletons.contains(LibJVMMainMethodWrappers.class)) {
68-
ImageSingletons.add(LibJVMMainMethodWrappers.class, new LibJVMMainMethodWrappers());
69-
}
70-
}
71-
}
72-
7361
/// Verifies that runtime parsing consumes only the JVM-level `--module-path=...` and
7462
/// `--add-modules=...` forms, leaving launcher-handled variants untouched.
7563
@Test
@@ -181,7 +169,6 @@ public void bootLayerRootModuleComputationExpandsAndDeduplicates() throws Except
181169

182170
private static void assumeLibJVMNativeImage() {
183171
Assume.assumeTrue(ImageInfo.inImageCode());
184-
Assume.assumeTrue(ImageSingletons.contains(LibJVMMainMethodWrappers.class));
185172
}
186173

187174
private static void invokeRuntimeBootLayerInitialize() throws Exception {

0 commit comments

Comments
 (0)