Skip to content

Commit 70080a3

Browse files
committed
svm: adopt "JDK-8288899 java/util/concurrent/ExecutorService/CloseTest.java failed with "InterruptedException: sleep interrupted""
1 parent f2f1257 commit 70080a3

File tree

3 files changed

+244
-172
lines changed

3 files changed

+244
-172
lines changed

substratevm/mx.substratevm/suite.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,38 @@
326326
"jacoco" : "exclude",
327327
},
328328

329+
"com.oracle.svm.core.jdk21": {
330+
"subDir": "src",
331+
"sourceDirs": [
332+
"src",
333+
],
334+
"dependencies": [
335+
"com.oracle.svm.common",
336+
],
337+
"javaCompliance" : "21",
338+
"overlayTarget" : "com.oracle.svm.core",
339+
"multiReleaseJarVersion" : "21",
340+
"checkstyle": "com.oracle.svm.core",
341+
"workingSets": "SVM",
342+
"jacoco" : "exclude",
343+
},
344+
345+
"com.oracle.svm.core.jdk22": {
346+
"subDir": "src",
347+
"sourceDirs": [
348+
"src",
349+
],
350+
"dependencies": [
351+
"com.oracle.svm.common",
352+
],
353+
"javaCompliance" : "22+",
354+
"overlayTarget" : "com.oracle.svm.core",
355+
"multiReleaseJarVersion" : "22",
356+
"checkstyle": "com.oracle.svm.core",
357+
"workingSets": "SVM",
358+
"jacoco" : "exclude",
359+
},
360+
329361
"com.oracle.svm.core.genscavenge": {
330362
"subDir": "src",
331363
"sourceDirs": [
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
/*
2+
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.oracle.svm.core.jdk;
26+
27+
import java.util.Collection;
28+
import java.util.List;
29+
import java.util.concurrent.Callable;
30+
import java.util.concurrent.ExecutionException;
31+
import java.util.concurrent.ForkJoinPool;
32+
import java.util.concurrent.ForkJoinTask;
33+
import java.util.concurrent.ForkJoinWorkerThread;
34+
import java.util.concurrent.Future;
35+
import java.util.concurrent.TimeUnit;
36+
import java.util.concurrent.TimeoutException;
37+
38+
/**
39+
* Pure delegate implementation to ForkJoinPool.commonPool().
40+
*/
41+
public final class DeferredCommonPool extends ForkJoinPool {
42+
43+
public DeferredCommonPool() {
44+
super(1, new DisallowingForkJoinWorkerThreadFactory(), null, false);
45+
}
46+
47+
@Override
48+
public <T> T invoke(ForkJoinTask<T> task) {
49+
return ForkJoinPool.commonPool().invoke(task);
50+
}
51+
52+
@Override
53+
public void execute(ForkJoinTask<?> task) {
54+
ForkJoinPool.commonPool().execute(task);
55+
}
56+
57+
@Override
58+
public void execute(Runnable task) {
59+
ForkJoinPool.commonPool().execute(task);
60+
}
61+
62+
@Override
63+
public <T> ForkJoinTask<T> submit(ForkJoinTask<T> task) {
64+
return ForkJoinPool.commonPool().submit(task);
65+
}
66+
67+
@Override
68+
public <T> ForkJoinTask<T> submit(Callable<T> task) {
69+
return ForkJoinPool.commonPool().submit(task);
70+
}
71+
72+
@Override
73+
public <T> ForkJoinTask<T> submit(Runnable task, T result) {
74+
return ForkJoinPool.commonPool().submit(task, result);
75+
}
76+
77+
@Override
78+
public ForkJoinTask<?> submit(Runnable task) {
79+
return ForkJoinPool.commonPool().submit(task);
80+
}
81+
82+
@Override
83+
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
84+
return ForkJoinPool.commonPool().invokeAll(tasks);
85+
}
86+
87+
@Override
88+
public ForkJoinWorkerThreadFactory getFactory() {
89+
return ForkJoinPool.commonPool().getFactory();
90+
}
91+
92+
@Override
93+
public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler() {
94+
return ForkJoinPool.commonPool().getUncaughtExceptionHandler();
95+
}
96+
97+
@Override
98+
public int getParallelism() {
99+
return ForkJoinPool.commonPool().getParallelism();
100+
}
101+
102+
@Override
103+
public int getPoolSize() {
104+
return ForkJoinPool.commonPool().getPoolSize();
105+
}
106+
107+
@Override
108+
public boolean getAsyncMode() {
109+
return ForkJoinPool.commonPool().getAsyncMode();
110+
}
111+
112+
@Override
113+
public int getRunningThreadCount() {
114+
return ForkJoinPool.commonPool().getRunningThreadCount();
115+
}
116+
117+
@Override
118+
public int getActiveThreadCount() {
119+
return ForkJoinPool.commonPool().getActiveThreadCount();
120+
}
121+
122+
@Override
123+
public boolean isQuiescent() {
124+
return ForkJoinPool.commonPool().isQuiescent();
125+
}
126+
127+
@Override
128+
public long getStealCount() {
129+
return ForkJoinPool.commonPool().getStealCount();
130+
}
131+
132+
@Override
133+
public long getQueuedTaskCount() {
134+
return ForkJoinPool.commonPool().getQueuedTaskCount();
135+
}
136+
137+
@Override
138+
public int getQueuedSubmissionCount() {
139+
return ForkJoinPool.commonPool().getQueuedSubmissionCount();
140+
}
141+
142+
@Override
143+
public boolean hasQueuedSubmissions() {
144+
return ForkJoinPool.commonPool().hasQueuedSubmissions();
145+
}
146+
147+
@Override
148+
public String toString() {
149+
return ForkJoinPool.commonPool().toString();
150+
}
151+
152+
@Override
153+
public void shutdown() {
154+
ForkJoinPool.commonPool().shutdown();
155+
}
156+
157+
@Override
158+
public List<Runnable> shutdownNow() {
159+
return ForkJoinPool.commonPool().shutdownNow();
160+
}
161+
162+
@Override
163+
public boolean isTerminated() {
164+
return ForkJoinPool.commonPool().isTerminated();
165+
}
166+
167+
@Override
168+
public boolean isTerminating() {
169+
return ForkJoinPool.commonPool().isTerminating();
170+
}
171+
172+
@Override
173+
public boolean isShutdown() {
174+
return ForkJoinPool.commonPool().isShutdown();
175+
}
176+
177+
@Override
178+
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
179+
return ForkJoinPool.commonPool().awaitTermination(timeout, unit);
180+
}
181+
182+
@Override
183+
public boolean awaitQuiescence(long timeout, TimeUnit unit) {
184+
return ForkJoinPool.commonPool().awaitQuiescence(timeout, unit);
185+
}
186+
187+
@Override
188+
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
189+
return ForkJoinPool.commonPool().invokeAny(tasks);
190+
}
191+
192+
@Override
193+
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
194+
return ForkJoinPool.commonPool().invokeAny(tasks, timeout, unit);
195+
}
196+
197+
@Override
198+
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
199+
return ForkJoinPool.commonPool().invokeAll(tasks, timeout, unit);
200+
}
201+
202+
static class DisallowingForkJoinWorkerThreadFactory implements ForkJoinWorkerThreadFactory {
203+
@Override
204+
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
205+
throw new Error("Deferred ForkJoin.commonPool() delegate should not start its own threads.");
206+
}
207+
}
208+
}

0 commit comments

Comments
 (0)