Skip to content

Commit 2a0ee4d

Browse files
committed
8355578: [java.net] Use @requires tag instead of exiting based on "os.name" property value
Backport-of: 60a4594b9f9acd82ef3ff22fc6a2df238dd981b9
1 parent 4047efb commit 2a0ee4d

File tree

6 files changed

+19
-63
lines changed

6 files changed

+19
-63
lines changed

test/jdk/java/net/Inet4Address/PingThis.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 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
@@ -27,27 +27,20 @@
2727

2828
/* @test
2929
* @bug 7163874 8133015
30+
* @summary InetAddress.isReachable is returning false for InetAdress 0.0.0.0 and ::0
31+
* @requires os.family != "windows"
3032
* @library /test/lib
31-
* @summary InetAddress.isReachable is returning false
32-
* for InetAdress 0.0.0.0 and ::0
3333
* @run main PingThis
3434
* @run main/othervm -Djava.net.preferIPv4Stack=true PingThis
3535
*/
3636

37-
import java.net.Inet6Address;
3837
import java.net.InetAddress;
39-
import java.net.NetworkInterface;
4038
import java.util.ArrayList;
41-
import java.util.Collections;
42-
import java.util.Iterator;
4339
import java.util.List;
4440
import jdk.test.lib.net.IPSupport;
4541

4642
public class PingThis {
4743
public static void main(String args[]) throws Exception {
48-
if (System.getProperty("os.name").startsWith("Windows")) {
49-
return;
50-
}
5144
IPSupport.throwSkippedExceptionIfNonOperational();
5245

5346
List<String> addrs = new ArrayList<String>();

test/jdk/java/net/MulticastSocket/NoLoopbackPackets.java

Lines changed: 4 additions & 13 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,29 +24,20 @@
2424
/*
2525
* @test
2626
* @bug 4742177
27-
* @library /test/lib
2827
* @summary Re-test IPv6 (and specifically MulticastSocket) with latest Linux & USAGI code
28+
* @requires os.family != "windows"
29+
* @library /test/lib
2930
*/
3031
import java.util.*;
3132
import java.net.*;
3233
import jdk.test.lib.NetworkConfiguration;
3334
import jdk.test.lib.net.IPSupport;
3435

3536
public class NoLoopbackPackets {
36-
private static String osname;
37-
38-
static boolean isWindows() {
39-
if (osname == null)
40-
osname = System.getProperty("os.name");
41-
return osname.contains("Windows");
42-
}
4337

4438
private static final String MESSAGE = "hello world (" + System.nanoTime() + ")";
39+
4540
public static void main(String[] args) throws Exception {
46-
if (isWindows()) {
47-
System.out.println("The test only run on non-Windows OS. Bye.");
48-
return;
49-
}
5041

5142
MulticastSocket msock = null;
5243
List<SocketAddress> failedGroups = new ArrayList<SocketAddress>();

test/jdk/java/net/MulticastSocket/PromiscuousIPv6.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 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,7 +24,9 @@
2424
/*
2525
* @test
2626
* @bug 8215294
27-
* @requires os.family == "linux"
27+
* @requires os.family == "linux" & !(os.version ~= "3\\.10\\.0.*")
28+
* @comment This test should only be run on Linux.
29+
* The behavior under test is known NOT to work on Linux 3.10.0* kernels.
2830
* @library /test/lib
2931
* @build jdk.test.lib.NetworkConfiguration
3032
* PromiscuousIPv6
@@ -148,18 +150,6 @@ static void test(NetworkInterface nif, InetAddress group1, InetAddress group2)
148150
}
149151

150152
public static void main(String args[]) throws IOException {
151-
String os = System.getProperty("os.name");
152-
153-
if (!os.equals("Linux")) {
154-
throw new SkippedException("This test should be run only on Linux");
155-
} else {
156-
String osVersion = System.getProperty("os.version");
157-
String prefix = "3.10.0";
158-
if (osVersion.startsWith(prefix)) {
159-
throw new SkippedException(
160-
String.format("The behavior under test is known NOT to work on '%s' kernels", prefix));
161-
}
162-
}
163153

164154
NetworkConfiguration.printSystemConfiguration(System.out);
165155
List<NetworkInterface> nifs = NetworkConfiguration.probe()

test/jdk/java/net/MulticastSocket/SetOutgoingIf.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2020, 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,10 +24,11 @@
2424
/*
2525
* @test
2626
* @bug 4742177 8241786
27+
* @summary Re-test IPv6 (and specifically MulticastSocket) with latest Linux & USAGI code
28+
* @requires os.family != "windows"
2729
* @library /test/lib
2830
* @run main/othervm SetOutgoingIf
2931
* @run main/othervm -Djdk.net.usePlainDatagramSocketImpl SetOutgoingIf
30-
* @summary Re-test IPv6 (and specifically MulticastSocket) with latest Linux & USAGI code
3132
*/
3233
import java.io.IOException;
3334
import java.net.*;
@@ -37,7 +38,7 @@
3738

3839

3940
public class SetOutgoingIf implements AutoCloseable {
40-
private static String osname;
41+
4142
private final MulticastSocket SOCKET;
4243
private final int PORT;
4344
private final Map<NetIf, MulticastSender> sendersMap = new ConcurrentHashMap<>();
@@ -50,12 +51,6 @@ private SetOutgoingIf() {
5051
}
5152
}
5253

53-
static boolean isWindows() {
54-
if (osname == null)
55-
osname = System.getProperty("os.name");
56-
return osname.contains("Windows");
57-
}
58-
5954
static boolean isMacOS() {
6055
return System.getProperty("os.name").contains("OS X");
6156
}
@@ -83,10 +78,6 @@ public void close() {
8378
}
8479

8580
public void run() throws Exception {
86-
if (isWindows()) {
87-
System.out.println("The test only run on non-Windows OS. Bye.");
88-
return;
89-
}
9081

9182
if (!hasIPv6()) {
9283
System.out.println("No IPv6 available. Bye.");

test/jdk/java/net/ServerSocket/AnotherSelectFdsLimit.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 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
* @test
2626
* @bug 8035897
2727
* @summary FD_SETSIZE should be set on macosx
28+
* @requires os.family == "mac"
2829
* @run main/othervm AnotherSelectFdsLimit 1023
2930
* @run main/othervm AnotherSelectFdsLimit 1024
3031
* @run main/othervm AnotherSelectFdsLimit 1025
@@ -41,10 +42,6 @@ public class AnotherSelectFdsLimit {
4142
static final int DEFAULT_FDS_TO_USE = 1600;
4243

4344
public static void main(String [] args) throws Exception {
44-
if (!System.getProperty("os.name").contains("OS X")) {
45-
System.out.println("Test only run on MAC. Exiting.");
46-
return;
47-
}
4845

4946
int fdsToUse = DEFAULT_FDS_TO_USE;
5047
if (args.length == 1)

test/jdk/java/net/ServerSocket/SelectFdsLimit.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 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
@@ -27,6 +27,7 @@
2727
* @summary The total number of file descriptors is limited to
2828
* 1024(FDSET_SIZE) on MacOSX (the size of fd array passed to select()
2929
* call in java.net classes is limited to this value).
30+
* @requires os.family == "mac"
3031
* @run main/othervm SelectFdsLimit
3132
3233
*/
@@ -35,7 +36,6 @@
3536
import java.io.FileInputStream;
3637
import java.io.FileNotFoundException;
3738
import java.io.IOException;
38-
import java.io.InputStream;
3939
import java.net.ServerSocket;
4040
import java.net.SocketTimeoutException;
4141

@@ -72,12 +72,6 @@ static void openFiles(int fn, File f) throws FileNotFoundException, IOException
7272

7373
public static void main(String [] args) throws IOException, FileNotFoundException {
7474

75-
//The bug 8021820 is a Mac specific and because of that test will pass on all
76-
//other platforms
77-
if (!System.getProperty("os.name").contains("OS X")) {
78-
return;
79-
}
80-
8175
//Create test directory with test files
8276
prepareTestEnv();
8377

0 commit comments

Comments
 (0)