Skip to content

Commit 92ed2df

Browse files
committed
Merge master HEAD into openj9-staging
Signed-off-by: J9 Build <[email protected]>
2 parents f11021a + 2e46245 commit 92ed2df

File tree

12 files changed

+560
-65
lines changed

12 files changed

+560
-65
lines changed

src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -172,13 +172,13 @@ public void execute(Runnable command) {
172172
public void ensureExecutedAsync(Runnable command) {
173173
try {
174174
delegate.execute(command);
175-
} catch (Throwable t) {
175+
} catch (RejectedExecutionException t) {
176176
errorHandler.accept(command, t);
177177
ASYNC_POOL.execute(command);
178178
}
179179
}
180180

181-
private void shutdown() {
181+
void shutdown() {
182182
if (delegate instanceof ExecutorService service) {
183183
service.shutdown();
184184
}

test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsics.java

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ private void checkIntrinsics(Operation op, Method m, String latin1, String utf16
155155
char cL = latin1.charAt(indexL);
156156
char cU = utf16.charAt(indexU);
157157
invokeAndCheck(m, cL - cU, latin1, latin1.replace(cL, cU));
158+
invokeAndCheck(m, cU - cL, latin1.replace(cL, cU), latin1);
158159
invokeAndCheck(m, cU - cL, utf16, utf16.replace(cU, cL));
159160

160161
// Different lengths

test/hotspot/jtreg/compiler/loopopts/superword/ProdRed_Int.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -85,6 +85,10 @@ public static void prodReductionInit(int[] a, int[] b) {
8585
@IR(applyIfCPUFeature = {"sse4.1", "true"},
8686
applyIfAnd = {"SuperWordReductions", "true", "LoopMaxUnroll", ">= 8"},
8787
counts = {IRNode.MUL_REDUCTION_VI, ">= 1", IRNode.MUL_REDUCTION_VI, "<= 2"}) // one for main-loop, one for vector-post-loop
88+
@IR(applyIfPlatform = {"riscv64", "true"},
89+
applyIfCPUFeature = {"rvv", "true"},
90+
applyIfAnd = {"SuperWordReductions", "true", "LoopMaxUnroll", ">= 8"},
91+
counts = {IRNode.MUL_REDUCTION_VI, ">= 1", IRNode.MUL_REDUCTION_VI, "<= 2"}) // one for main-loop, one for vector-post-loop
8892
public static int prodReductionImplement(int[] a, int[] b, int total) {
8993
for (int i = 0; i < a.length; i++) {
9094
total *= a[i] + b[i];

test/hotspot/jtreg/compiler/loopopts/superword/RedTest_int.java

+4
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ public static int xorReductionImplement(
219219
@IR(applyIfCPUFeature = {"sse4.1", "true"},
220220
applyIfAnd = {"SuperWordReductions", "true", "LoopMaxUnroll", ">= 8"},
221221
counts = {IRNode.MUL_REDUCTION_VI, ">= 1", IRNode.MUL_REDUCTION_VI, "<= 2"}) // one for main-loop, one for vector-post-loop
222+
@IR(applyIfPlatform = {"riscv64", "true"},
223+
applyIfCPUFeature = {"rvv", "true"},
224+
applyIfAnd = {"SuperWordReductions", "true", "LoopMaxUnroll", ">= 8"},
225+
counts = {IRNode.MUL_REDUCTION_VI, ">= 1", IRNode.MUL_REDUCTION_VI, "<= 2"}) // one for main-loop, one for vector-post-loop
222226
public static int mulReductionImplement(
223227
int[] a,
224228
int[] b,

test/hotspot/jtreg/compiler/loopopts/superword/RedTest_long.java

+4
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ public static long xorReductionImplement(
226226
applyIfAnd = {"SuperWordReductions", "true", "LoopMaxUnroll", ">= 8"},
227227
applyIfPlatform = {"64-bit", "true"},
228228
counts = {IRNode.MUL_REDUCTION_VL, ">= 1", IRNode.MUL_REDUCTION_VL, "<= 2"}) // one for main-loop, one for vector-post-loop
229+
@IR(applyIfPlatform = {"riscv64", "true"},
230+
applyIfCPUFeature = {"rvv", "true"},
231+
applyIfAnd = {"SuperWordReductions", "true", "LoopMaxUnroll", ">= 8"},
232+
counts = {IRNode.MUL_REDUCTION_VL, ">= 1", IRNode.MUL_REDUCTION_VL, "<= 2"}) // one for main-loop, one for vector-post-loop
229233
public static long mulReductionImplement(
230234
long[] a,
231235
long[] b,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025, 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.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8350019
27+
* @summary Verifies `HttpClientImpl.DelegatingExecutor` behavior
28+
* @modules java.net.http/jdk.internal.net.http
29+
* @run junit java.net.http/jdk.internal.net.http.DelegatingExecutorTest
30+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
/*
2+
* Copyright (c) 2025, 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.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
package jdk.internal.net.http;
25+
26+
import jdk.internal.net.http.HttpClientImpl.DelegatingExecutor;
27+
import org.junit.jupiter.api.Test;
28+
29+
import java.util.ArrayList;
30+
import java.util.List;
31+
import java.util.concurrent.CountDownLatch;
32+
import java.util.concurrent.Executor;
33+
import java.util.concurrent.ExecutorService;
34+
import java.util.concurrent.LinkedBlockingQueue;
35+
import java.util.concurrent.RejectedExecutionException;
36+
import java.util.concurrent.ThreadPoolExecutor;
37+
import java.util.concurrent.TimeUnit;
38+
import java.util.concurrent.atomic.AtomicInteger;
39+
import java.util.function.BiConsumer;
40+
41+
import static org.junit.jupiter.api.Assertions.assertEquals;
42+
import static org.junit.jupiter.api.Assertions.assertSame;
43+
import static org.junit.jupiter.api.Assertions.assertThrows;
44+
import static org.junit.jupiter.api.Assertions.assertTrue;
45+
import static org.junit.jupiter.api.Assertions.fail;
46+
47+
public class DelegatingExecutorTest {
48+
49+
@Test
50+
public void testInlineExecution() {
51+
Thread callSiteThread = Thread.currentThread();
52+
Thread[] runSiteThreadRef = {null};
53+
new DelegatingExecutor(() -> false, null, null)
54+
.execute(() -> runSiteThreadRef[0] = Thread.currentThread());
55+
assertSame(callSiteThread, runSiteThreadRef[0]);
56+
}
57+
58+
@Test
59+
public void testDelegateDeferral() {
60+
ImmediateExecutor delegate = new ImmediateExecutor();
61+
Runnable task = () -> {};
62+
new DelegatingExecutor(() -> true, delegate, null).execute(task);
63+
delegate.assertReception(task);
64+
}
65+
66+
@Test
67+
public void testRejectedExecutionException() throws InterruptedException {
68+
69+
// Create a deterministically throwing task
70+
RuntimeException error = new RejectedExecutionException();
71+
FirstThrowingAndThenCompletingRunnable task = new FirstThrowingAndThenCompletingRunnable(error);
72+
73+
// Create a recording delegate
74+
ImmediateExecutor delegate = new ImmediateExecutor();
75+
76+
// Create a recording error handler
77+
List<Runnable> reportedTasks = new ArrayList<>();
78+
List<Throwable> reportedErrors = new ArrayList<>();
79+
BiConsumer<Runnable, Throwable> errorHandler = (task_, error_) -> {
80+
synchronized (this) {
81+
reportedTasks.add(task_);
82+
reportedErrors.add(error_);
83+
}
84+
};
85+
86+
// Verify the initial failing execution
87+
new DelegatingExecutor(() -> true, delegate, errorHandler).execute(task);
88+
delegate.assertReception(task);
89+
90+
// Verify fallback to the async. pool
91+
assertEquals(1, reportedTasks.size());
92+
assertSame(task, reportedTasks.getFirst());
93+
assertEquals(1, reportedErrors.size());
94+
assertSame(error, reportedErrors.getFirst());
95+
boolean completed = task.completionLatch.await(5, TimeUnit.SECONDS);
96+
assertTrue(completed);
97+
98+
}
99+
100+
@Test
101+
public void testNotRejectedExecutionException() {
102+
103+
// Create a deterministically throwing task
104+
RuntimeException error = new RuntimeException();
105+
FirstThrowingAndThenCompletingRunnable task = new FirstThrowingAndThenCompletingRunnable(error);
106+
107+
// Create a recording delegate
108+
ImmediateExecutor delegate = new ImmediateExecutor();
109+
110+
// Verify the immediate exception propagation
111+
Throwable thrownError = assertThrows(
112+
Throwable.class,
113+
() -> new DelegatingExecutor(() -> true, delegate, null).execute(task));
114+
delegate.assertReception(task);
115+
assertSame(error, thrownError);
116+
117+
}
118+
119+
private static final class ImmediateExecutor implements Executor {
120+
121+
private final List<Runnable> receivedTasks = new ArrayList<>();
122+
123+
@Override
124+
public synchronized void execute(Runnable task) {
125+
receivedTasks.add(task);
126+
task.run();
127+
}
128+
129+
private synchronized void assertReception(Runnable... tasks) {
130+
assertSame(tasks.length, receivedTasks.size());
131+
for (int taskIndex = 0; taskIndex < tasks.length; taskIndex++) {
132+
assertSame(tasks[taskIndex], receivedTasks.get(taskIndex));
133+
}
134+
}
135+
136+
}
137+
138+
private static final class FirstThrowingAndThenCompletingRunnable implements Runnable {
139+
140+
private final AtomicInteger invocationCounter = new AtomicInteger(0);
141+
142+
private final CountDownLatch completionLatch = new CountDownLatch(1);
143+
144+
private final RuntimeException exception;
145+
146+
private FirstThrowingAndThenCompletingRunnable(RuntimeException exception) {
147+
this.exception = exception;
148+
}
149+
150+
@Override
151+
public void run() {
152+
switch (invocationCounter.getAndIncrement()) {
153+
case 0: throw exception;
154+
case 1: { completionLatch.countDown(); break; }
155+
default: fail();
156+
}
157+
}
158+
159+
}
160+
161+
@Test
162+
public void testDelegateShutdown() {
163+
AtomicInteger invocationCounter = new AtomicInteger();
164+
try (ExecutorService delegate = new ThreadPoolExecutor(1, 1, 1, TimeUnit.DAYS, new LinkedBlockingQueue<>()) {
165+
@Override
166+
public void shutdown() {
167+
invocationCounter.incrementAndGet();
168+
super.shutdown();
169+
}
170+
}) {
171+
new DelegatingExecutor(() -> true, delegate, null).shutdown();
172+
assertEquals(1, invocationCounter.get());
173+
}
174+
}
175+
176+
}

test/jdk/javax/crypto/CryptoPermissions/InconsistentEntries.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
import java.util.List;
3333
import jdk.test.lib.Utils;
34-
import jdk.test.lib.cds.CDSTestUtils;
3534
import jdk.test.lib.process.ProcessTools;
35+
import jdk.test.lib.util.FileUtils;
3636
import org.testng.Assert;
3737
import org.testng.annotations.BeforeTest;
3838
import org.testng.annotations.Test;
@@ -59,7 +59,7 @@ public class InconsistentEntries {
5959
@BeforeTest
6060
public void setUp() throws Exception {
6161
// Clone the tested JDK to the scratch directory
62-
CDSTestUtils.clone(new File(JDK_HOME), new File(TEMP_JDK_HOME.toString()));
62+
FileUtils.copyDirectory(Path.of(JDK_HOME), TEMP_JDK_HOME);
6363

6464
// create policy directory in the cloned JDK
6565
if (!POLICY_DIR.toFile().exists()) {

0 commit comments

Comments
 (0)