Skip to content

Commit

Permalink
Merge upstream-jdk17u
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Nov 14, 2024
2 parents cf85259 + e470734 commit 265177c
Show file tree
Hide file tree
Showing 19 changed files with 430 additions and 75 deletions.
20 changes: 11 additions & 9 deletions make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ private void load(List<Path> files) throws IOException {
}
continue;
}
if (line.startsWith("Zone")) { // parse Zone line
int token0len = tokens.length > 0 ? tokens[0].length() : line.length();
if (line.regionMatches(true, 0, "Zone", 0, token0len)) { // parse Zone line
String name = tokens[1];
if (excludedZones.contains(name)){
continue;
Expand All @@ -182,13 +183,13 @@ private void load(List<Path> files) throws IOException {
if (zLine.parse(tokens, 2)) {
openZone = null;
}
} else if (line.startsWith("Rule")) { // parse Rule line
} else if (line.regionMatches(true, 0, "Rule", 0, token0len)) { // parse Rule line
String name = tokens[1];
if (!rules.containsKey(name)) {
rules.put(name, new ArrayList<RuleLine>(10));
}
rules.get(name).add(new RuleLine().parse(tokens));
} else if (line.startsWith("Link")) { // parse link line
} else if (line.regionMatches(true, 0, "Link", 0, token0len)) { // parse link line
if (tokens.length >= 3) {
String realId = tokens[1];
String aliasId = tokens[2];
Expand Down Expand Up @@ -304,7 +305,7 @@ private void parse(String[] tokens, int off) {
month = parseMonth(tokens[off++]);
if (off < tokens.length) {
String dayRule = tokens[off++];
if (dayRule.startsWith("last")) {
if (dayRule.regionMatches(true, 0, "last", 0, 4)) {
dayOfMonth = -1;
dayOfWeek = parseDayOfWeek(dayRule.substring(4));
adjustForwards = false;
Expand Down Expand Up @@ -355,11 +356,12 @@ private void parse(String[] tokens, int off) {
}

int parseYear(String year, int defaultYear) {
switch (year.toLowerCase()) {
case "min": return 1900;
case "max": return Year.MAX_VALUE;
case "only": return defaultYear;
}
int len = year.length();

if (year.regionMatches(true, 0, "minimum", 0, len)) return 1900;
if (year.regionMatches(true, 0, "maximum", 0, len)) return Year.MAX_VALUE;
if (year.regionMatches(true, 0, "only", 0, len)) return defaultYear;

return Integer.parseInt(year);
}

Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,10 @@ void os::win32::print_windows_version(outputStream* st) {
// - 2016 GA 10/2016 build: 14393
// - 2019 GA 11/2018 build: 17763
// - 2022 GA 08/2021 build: 20348
if (build_number > 20347) {
// - 2025 Preview build : 26040
if (build_number > 26039) {
st->print("Server 2025");
} else if (build_number > 20347) {
st->print("Server 2022");
} else if (build_number > 17762) {
st->print("Server 2019");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2891,7 +2891,7 @@ static final class Canceller implements BiConsumer<Object, Throwable> {
final Future<?> f;
Canceller(Future<?> f) { this.f = f; }
public void accept(Object ignore, Throwable ex) {
if (ex == null && f != null && !f.isDone())
if (f != null && !f.isDone())
f.cancel(false);
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/java.base/windows/native/libjava/java_props_md.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -474,6 +474,8 @@ GetJavaProperties(JNIEnv* env)
* where (buildNumber > 17762)
* Windows Server 2022 10 0 (!VER_NT_WORKSTATION)
* where (buildNumber > 20347)
* Windows Server 2025 10 0 (!VER_NT_WORKSTATION)
* where (buildNumber > 26039)
*
* This mapping will presumably be augmented as new Windows
* versions are released.
Expand Down Expand Up @@ -557,7 +559,10 @@ GetJavaProperties(JNIEnv* env)
case 0:
/* Windows server 2019 GA 10/2018 build number is 17763 */
/* Windows server 2022 build number is 20348 */
if (buildNumber > 20347) {
/* Windows server 2025 Preview build is 26040 */
if (buildNumber > 26039) {
sprops.os_name = "Windows Server 2025";
} else if (buildNumber > 20347) {
sprops.os_name = "Windows Server 2022";
} else if (buildNumber > 17762) {
sprops.os_name = "Windows Server 2019";
Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/compiler/c1/TestTraceLinearScanLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
* @bug 8251093
* @summary Sanity check the flag TraceLinearScanLevel with the highest level in a silent HelloWorld program.
*
* @requires vm.debug == true & vm.compiler1.enabled
* @run main/othervm -XX:TraceLinearScanLevel=4 compiler.c1.TestTraceLinearScanLevel
* @requires vm.debug == true & vm.compiler1.enabled & vm.compMode != "Xcomp"
* @run main/othervm -Xbatch -XX:TraceLinearScanLevel=4 compiler.c1.TestTraceLinearScanLevel
*/
package compiler.c1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void main(String[] args) throws Exception {
// will be ignored during dumping.
TestCommon.dump(appJar, classlist, "-Xlog:cds")
.shouldContain("Dumping")
.shouldContain("[cds] Prohibited package for non-bootstrap classes: java/lang/Prohibited.class")
.shouldContain("Prohibited package for non-bootstrap classes: java/lang/Prohibited.class")
.shouldHaveExitValue(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ private int runIt(String argv[], PrintStream out) {
this.out = out;
log = new Log(out, argHandler);

Map<String,? extends com.sun.jdi.connect.Connector.Argument> cArgs1 = initConnector(argHandler.getTransportPort());
Map<String,? extends com.sun.jdi.connect.Connector.Argument> cArgs2 = initConnector(null);
if ((addr = startListen(cArgs2)) == null) {
log.complain("FAILURE: unable to start listening the address " +
Expand All @@ -93,6 +92,12 @@ private int runIt(String argv[], PrintStream out) {
else
log.display("TEST: start listening the address " + addr);

// argHandler.getTransportPort() returns a free port (different from the port allocated by startListen(cArgs2))
Map<String,? extends com.sun.jdi.connect.Connector.Argument> cArgs1 = initConnector(argHandler.getTransportPort());

log.display("cArgs1: " + cArgs1);
log.display("cArgs2: " + cArgs2);

/* Check that an Exception is thrown if ListeningConnector.stopListening
has been invoked with argument map different from the one given for
a previous ListeningConnector.startListening() invocation */
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
* argument map is the same with the one given for the previous
* ListeningConnector.startListening() invocation.
*
* NOTE: this test is tagged "nonconcurrent" because it uses the default
* "javadebug" shmem file, as do some other tests.
*
* @library /vmTestbase
* /test/lib
* @build nsk.jdi.ListeningConnector.stopListening.stoplis001
Expand Down
1 change: 1 addition & 0 deletions test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ javax/sound/midi/Sequencer/Looping.java 8136897 generic-all
# jdk_swing

javax/swing/plaf/basic/BasicTextUI/8001470/bug8001470.java 8233177 linux-all,windows-all
javax/swing/plaf/basic/BasicDirectoryModel/LoaderThreadCount.java 8333880 windows-all

javax/swing/JFrame/MaximizeWindowTest.java 8321289 linux-all
javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java 8233582 linux-all
Expand Down
33 changes: 16 additions & 17 deletions test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,27 @@ public static void main(String[] args)
System.out.println("SystemTray is not supported");
return;
}
PassFailJFrame passFailJFrame = PassFailJFrame.builder()
.title("TrayIcon Test Instructions")
.instructions(INSTRUCTIONS)
.testTimeOut(8)
.rows(25)
.columns(70)
.screenCapture()
.build();

createAndShowGUI();
// does not have a test window,
// hence only the instruction frame is positioned
PassFailJFrame.positionTestWindow(null,
PassFailJFrame.Position.HORIZONTAL);
createAndShowTrayIcon();

try {
passFailJFrame.awaitAndCheck();
PassFailJFrame.builder()
.title("TrayIcon Test Instructions")
.instructions(INSTRUCTIONS)
.testTimeOut(8)
.rows(25)
.columns(70)
.screenCapture()
.build()
.awaitAndCheck();
} finally {
tray.remove(icon);
if (tray != null) {
tray.remove(icon);
}
}
}

private static void createAndShowGUI() {
private static void createAndShowTrayIcon() {
ArrayList<Image> imageList = new ArrayList<>();
for (int size = 16; size <= 48; size += 4) {
imageList.add(createIcon(size));
Expand All @@ -120,7 +119,7 @@ private static void createAndShowGUI() {
try {
tray.add(icon);
} catch (AWTException e) {
throw new RuntimeException("Error while adding icon to system tray");
throw new RuntimeException("Error while adding icon to system tray", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8303742
* @summary CompletableFuture.orTimeout can leak memory if completed exceptionally
* @modules java.base/java.util.concurrent:open
* @run junit/othervm -Xmx128m CompletableFutureOrTimeoutExceptionallyTest
*/

import java.time.Duration;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;

class CompletableFutureOrTimeoutExceptionallyTest {
static final BlockingQueue<Runnable> delayerQueue;
static {
try {
var delayerClass = Class.forName("java.util.concurrent.CompletableFuture$Delayer",
true,
CompletableFuture.class.getClassLoader());
var delayerField = delayerClass.getDeclaredField("delayer");
delayerField.setAccessible(true);
delayerQueue = ((ScheduledThreadPoolExecutor)delayerField.get(null)).getQueue();
} catch (Throwable t) {
throw new ExceptionInInitializerError(t);
}
}

/**
* Test that orTimeout task is cancelled if the CompletableFuture is completed Exceptionally
*/
@Test
void testOrTimeoutWithCompleteExceptionallyDoesNotLeak() throws InterruptedException {
assertTrue(delayerQueue.peek() == null);
var future = new CompletableFuture<>().orTimeout(12, TimeUnit.HOURS);
assertTrue(delayerQueue.peek() != null);
future.completeExceptionally(new RuntimeException("This is fine"));
while (delayerQueue.peek() != null) {
Thread.sleep(100);
};
}

/**
* Test that the completeOnTimeout task is cancelled if the CompletableFuture is completed Exceptionally
*/
@Test
void testCompleteOnTimeoutWithCompleteExceptionallyDoesNotLeak() throws InterruptedException {
assertTrue(delayerQueue.peek() == null);
var future = new CompletableFuture<>().completeOnTimeout(null, 12, TimeUnit.HOURS);
assertTrue(delayerQueue.peek() != null);
future.completeExceptionally(new RuntimeException("This is fine"));
while (delayerQueue.peek() != null) {
Thread.sleep(100);
};
}
}
4 changes: 2 additions & 2 deletions test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -273,7 +273,7 @@ protected void doClientSide() throws Exception {
configureClientSocket(sslSocket);
InetAddress serverAddress = this.serverAddress;
InetSocketAddress connectAddress = serverAddress == null
? new InetSocketAddress("localhost", serverPort)
? new InetSocketAddress(InetAddress.getLoopbackAddress(), serverPort)
: new InetSocketAddress(serverAddress, serverPort);
sslSocket.connect(connectAddress, 15000);
} catch (IOException ioe) {
Expand Down
3 changes: 2 additions & 1 deletion test/jdk/javax/net/ssl/templates/TLSBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -222,7 +223,7 @@ public SSLSocket connect() {
try {
sslContext = SSLContext.getDefault();
sock = (SSLSocket)sslContext.getSocketFactory().createSocket();
sock.connect(new InetSocketAddress("localhost", serverPort));
sock.connect(new InetSocketAddress(InetAddress.getLoopbackAddress(), serverPort));
System.err.println("Client connected using port " +
sock.getLocalPort());
name = "client(" + sock.toString() + ")";
Expand Down
Loading

0 comments on commit 265177c

Please sign in to comment.