8355445: [java.nio] Use @requires tag instead of exiting based on "os.name" property value

Reviewed-by: lancea, jpai, iris
This commit is contained in:
Brian Burkhalter 2025-05-02 17:00:12 +00:00
parent 4826a91e7a
commit 84f570c573
7 changed files with 13 additions and 38 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2025, 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
@ -26,6 +26,7 @@
* @bug 6823609
* @summary Selector.select can hangs on Windows for cases where a helper thread
* becomes redudant but a new helper is immediately needed.
* @requires (os.family == "windows")
*/
import java.nio.channels.*;
@ -37,11 +38,6 @@ public class HelperSlowToDie {
private static volatile boolean done;
public static void main(String[] args) throws IOException {
if (!System.getProperty("os.name").startsWith("Windows")) {
System.out.println("Test skipped as it verifies a Windows specific bug");
return;
}
Selector sel = Selector.open();
// register channels

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2025, 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
@ -24,6 +24,7 @@
/* @test
* @bug 6285901 6501089
* @summary Check no data is written to wrong socket channel during async closing.
* @requires (os.family != "windows")
*/
import java.io.IOException;
@ -44,10 +45,6 @@ public class AsyncCloseChannel {
static int targetPort;
public static void main(String args[]) throws Exception {
if (System.getProperty("os.name").startsWith("Windows")) {
System.err.println("WARNING: Still does not work on Windows!");
return;
}
Thread ss = new SensorServer(); ss.start();
Thread ts = new TargetServer(); ts.start();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2025, 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
@ -24,6 +24,7 @@
/*
* @test
* @summary Sockets shouldn't be inherited when creating a child process
* @requires (os.family == "windows")
*/
import java.nio.ByteBuffer;
import java.nio.channels.*;
@ -138,9 +139,6 @@ public class SocketInheritance {
}
public static void main(String[] args) throws Exception {
if (!System.getProperty("os.name").startsWith("Windows"))
return;
if (args.length == 0) {
start();
} else {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, 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
@ -59,15 +59,9 @@ import static java.util.Arrays.asList;
public class InheritedChannelTest {
private static final String TEST_SRC = System.getProperty("test.src");
private static final String TEST_CLASSPATH = System.getProperty("test.class.path");
private static final String TEST_CLASSES = System.getProperty("test.classes");
private static final String OS_NAME = System.getProperty("os.name").toLowerCase();
private static final String ARCH = System.getProperty("os.arch");
private static final String OS_ARCH = ARCH.equals("i386") ? "i586" : ARCH;
private static final Path libraryPath
= Paths.get(System.getProperty("java.library.path"));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2025, 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
@ -24,6 +24,7 @@
/* @test
@bug 6176819
@summary Check if COMPUND_TEXT charset works as expected
@requires (os.family != "windows")
@run main/timeout=1200 TestCOMP
*/
@ -35,9 +36,6 @@ import java.nio.*;
public class TestCOMP {
public static void main(String[] argv) throws CharacterCodingException {
String osName = System.getProperty("os.name");
if (osName.startsWith("Windows"))
return;
try {
String src =
"JIS0208\u4eb0" +

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2025, 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
@ -25,6 +25,7 @@
* @bug 6808647
* @summary Checks that a DirectoryStream's iterator returns the expected
* path when opening a directory by specifying only the drive letter.
* @requires (os.family == "windows")
* @library ..
*/
@ -35,11 +36,6 @@ import java.io.IOException;
public class DriveLetter {
public static void main(String[] args) throws IOException {
String os = System.getProperty("os.name");
if (!os.startsWith("Windows")) {
System.out.println("This is Windows specific test");
return;
}
String here = System.getProperty("user.dir");
if (here.length() < 2 || here.charAt(1) != ':')
throw new RuntimeException("Unable to determine drive letter");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2025, 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
@ -24,6 +24,7 @@
/* @test
* @bug 4313887 6838333
* @summary Sanity test for JDK-specific FILE_TREE watch event modifier
* @requires (os.family == "windows")
* @library ..
* @modules jdk.unsupported
*/
@ -129,11 +130,6 @@ public class FileTreeModifier {
public static void main(String[] args) throws IOException {
if (!System.getProperty("os.name").startsWith("Windows")) {
System.out.println("This is Windows-only test at this time!");
return;
}
Path dir = TestUtil.createTemporaryDirectory();
try {
doTest(dir);