Skip to content

Commit 84f570c

Browse files
author
Brian Burkhalter
committed
8355445: [java.nio] Use @requires tag instead of exiting based on "os.name" property value
Reviewed-by: lancea, jpai, iris
1 parent 4826a91 commit 84f570c

File tree

7 files changed

+13
-38
lines changed

7 files changed

+13
-38
lines changed

test/jdk/java/nio/channels/Selector/HelperSlowToDie.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 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
@@ -26,6 +26,7 @@
2626
* @bug 6823609
2727
* @summary Selector.select can hangs on Windows for cases where a helper thread
2828
* becomes redudant but a new helper is immediately needed.
29+
* @requires (os.family == "windows")
2930
*/
3031

3132
import java.nio.channels.*;
@@ -37,11 +38,6 @@ public class HelperSlowToDie {
3738
private static volatile boolean done;
3839

3940
public static void main(String[] args) throws IOException {
40-
if (!System.getProperty("os.name").startsWith("Windows")) {
41-
System.out.println("Test skipped as it verifies a Windows specific bug");
42-
return;
43-
}
44-
4541
Selector sel = Selector.open();
4642

4743
// register channels

test/jdk/java/nio/channels/SocketChannel/AsyncCloseChannel.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2006, 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
@@ -24,6 +24,7 @@
2424
/* @test
2525
* @bug 6285901 6501089
2626
* @summary Check no data is written to wrong socket channel during async closing.
27+
* @requires (os.family != "windows")
2728
*/
2829

2930
import java.io.IOException;
@@ -44,10 +45,6 @@ public class AsyncCloseChannel {
4445
static int targetPort;
4546

4647
public static void main(String args[]) throws Exception {
47-
if (System.getProperty("os.name").startsWith("Windows")) {
48-
System.err.println("WARNING: Still does not work on Windows!");
49-
return;
50-
}
5148
Thread ss = new SensorServer(); ss.start();
5249
Thread ts = new TargetServer(); ts.start();
5350

test/jdk/java/nio/channels/SocketChannel/SocketInheritance.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 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
@@ -24,6 +24,7 @@
2424
/*
2525
* @test
2626
* @summary Sockets shouldn't be inherited when creating a child process
27+
* @requires (os.family == "windows")
2728
*/
2829
import java.nio.ByteBuffer;
2930
import java.nio.channels.*;
@@ -138,9 +139,6 @@ static void start() throws Exception {
138139
}
139140

140141
public static void main(String[] args) throws Exception {
141-
if (!System.getProperty("os.name").startsWith("Windows"))
142-
return;
143-
144142
if (args.length == 0) {
145143
start();
146144
} else {

test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 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
@@ -59,15 +59,9 @@
5959

6060
public class InheritedChannelTest {
6161

62-
private static final String TEST_SRC = System.getProperty("test.src");
6362
private static final String TEST_CLASSPATH = System.getProperty("test.class.path");
6463
private static final String TEST_CLASSES = System.getProperty("test.classes");
6564

66-
private static final String OS_NAME = System.getProperty("os.name").toLowerCase();
67-
68-
private static final String ARCH = System.getProperty("os.arch");
69-
private static final String OS_ARCH = ARCH.equals("i386") ? "i586" : ARCH;
70-
7165
private static final Path libraryPath
7266
= Paths.get(System.getProperty("java.library.path"));
7367

test/jdk/java/nio/charset/RemovingSunIO/TestCOMP.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 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
@@ -24,6 +24,7 @@
2424
/* @test
2525
@bug 6176819
2626
@summary Check if COMPUND_TEXT charset works as expected
27+
@requires (os.family != "windows")
2728
@run main/timeout=1200 TestCOMP
2829
*/
2930

@@ -35,9 +36,6 @@
3536

3637
public class TestCOMP {
3738
public static void main(String[] argv) throws CharacterCodingException {
38-
String osName = System.getProperty("os.name");
39-
if (osName.startsWith("Windows"))
40-
return;
4139
try {
4240
String src =
4341
"JIS0208\u4eb0" +

test/jdk/java/nio/file/DirectoryStream/DriveLetter.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 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
@@ -25,6 +25,7 @@
2525
* @bug 6808647
2626
* @summary Checks that a DirectoryStream's iterator returns the expected
2727
* path when opening a directory by specifying only the drive letter.
28+
* @requires (os.family == "windows")
2829
* @library ..
2930
*/
3031

@@ -35,11 +36,6 @@
3536
public class DriveLetter {
3637

3738
public static void main(String[] args) throws IOException {
38-
String os = System.getProperty("os.name");
39-
if (!os.startsWith("Windows")) {
40-
System.out.println("This is Windows specific test");
41-
return;
42-
}
4339
String here = System.getProperty("user.dir");
4440
if (here.length() < 2 || here.charAt(1) != ':')
4541
throw new RuntimeException("Unable to determine drive letter");

test/jdk/java/nio/file/WatchService/FileTreeModifier.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 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
@@ -24,6 +24,7 @@
2424
/* @test
2525
* @bug 4313887 6838333
2626
* @summary Sanity test for JDK-specific FILE_TREE watch event modifier
27+
* @requires (os.family == "windows")
2728
* @library ..
2829
* @modules jdk.unsupported
2930
*/
@@ -129,11 +130,6 @@ static void doTest(Path top) throws IOException {
129130

130131

131132
public static void main(String[] args) throws IOException {
132-
if (!System.getProperty("os.name").startsWith("Windows")) {
133-
System.out.println("This is Windows-only test at this time!");
134-
return;
135-
}
136-
137133
Path dir = TestUtil.createTemporaryDirectory();
138134
try {
139135
doTest(dir);

0 commit comments

Comments
 (0)