Skip to content

Commit b369691

Browse files
committed
[GR-59898] Failure of SourceInternalizationTest#testSourceInterning.
PullRequest: graal/19341
2 parents 8fccd4d + 6869baf commit b369691

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceInternalizationTest.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
import java.io.File;
5050
import java.io.IOException;
51-
import java.lang.ref.ReferenceQueue;
5251
import java.lang.ref.WeakReference;
5352
import java.net.URI;
5453
import java.net.URISyntaxException;
@@ -64,7 +63,8 @@
6463
import java.util.concurrent.TimeUnit;
6564
import java.util.concurrent.atomic.AtomicInteger;
6665

67-
import org.junit.Assume;
66+
import com.oracle.truffle.api.test.SubprocessTestUtils;
67+
import org.graalvm.nativeimage.ImageInfo;
6868
import org.junit.BeforeClass;
6969
import org.junit.Test;
7070

@@ -218,21 +218,25 @@ public void testUncachedAreNotInterned() {
218218
}
219219

220220
@Test
221-
public void testSourceInterning() {
222-
Assume.assumeFalse("This test is too slow in fastdebug.", System.getProperty("java.vm.version").contains("fastdebug"));
223-
224-
byte[] bytes = new byte[16 * 1024 * 1024];
225-
byte byteValue = (byte) 'a';
226-
Arrays.fill(bytes, byteValue);
227-
String testString = new String(bytes); // big string
228-
229-
ReferenceQueue<Object> queue = new ReferenceQueue<>();
230-
List<WeakReference<Object>> sources = new ArrayList<>();
231-
for (int i = 0; i < GCUtils.GC_TEST_ITERATIONS; i++) {
232-
sources.add(new WeakReference<>(createTestSource(testString, i), queue));
233-
}
221+
public void testSourceInterning() throws IOException, InterruptedException {
222+
Runnable action = () -> {
223+
byte[] bytes = new byte[16 * 1024 * 1024];
224+
byte byteValue = (byte) 'a';
225+
Arrays.fill(bytes, byteValue);
226+
String testString = new String(bytes); // big string
227+
228+
List<WeakReference<Object>> sources = new ArrayList<>();
229+
for (int i = 0; i < GCUtils.GC_TEST_ITERATIONS; i++) {
230+
sources.add(new WeakReference<>(createTestSource(testString, i)));
231+
}
234232

235-
GCUtils.assertGc(testString, sources);
233+
GCUtils.assertGc("Sources not referenced from a language must be collected", sources);
234+
};
235+
if (ImageInfo.inImageCode()) {
236+
action.run();
237+
} else {
238+
SubprocessTestUtils.newBuilder(SourceInternalizationTest.class, action).run();
239+
}
236240
}
237241

238242
private static Object createTestSource(String testString, int i) {

0 commit comments

Comments
 (0)