Skip to content

8355578: [java.net] Use @requires tag instead of exiting based on "os.name" property value #3758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions test/jdk/java/net/Inet4Address/PingThis.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
Expand Down Expand Up @@ -27,27 +27,20 @@

/* @test
* @bug 7163874 8133015
* @summary InetAddress.isReachable is returning false for InetAdress 0.0.0.0 and ::0
* @requires os.family != "windows"
* @library /test/lib
* @summary InetAddress.isReachable is returning false
* for InetAdress 0.0.0.0 and ::0
* @run main PingThis
* @run main/othervm -Djava.net.preferIPv4Stack=true PingThis
*/

import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import jdk.test.lib.net.IPSupport;

public class PingThis {
public static void main(String args[]) throws Exception {
if (System.getProperty("os.name").startsWith("Windows")) {
return;
}
IPSupport.throwSkippedExceptionIfNonOperational();

List<String> addrs = new ArrayList<String>();
Expand Down
17 changes: 4 additions & 13 deletions test/jdk/java/net/MulticastSocket/NoLoopbackPackets.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,29 +24,20 @@
/*
* @test
* @bug 4742177
* @library /test/lib
* @summary Re-test IPv6 (and specifically MulticastSocket) with latest Linux & USAGI code
* @requires os.family != "windows"
* @library /test/lib
*/
import java.util.*;
import java.net.*;
import jdk.test.lib.NetworkConfiguration;
import jdk.test.lib.net.IPSupport;

public class NoLoopbackPackets {
private static String osname;

static boolean isWindows() {
if (osname == null)
osname = System.getProperty("os.name");
return osname.contains("Windows");
}

private static final String MESSAGE = "hello world (" + System.nanoTime() + ")";

public static void main(String[] args) throws Exception {
if (isWindows()) {
System.out.println("The test only run on non-Windows OS. Bye.");
return;
}

MulticastSocket msock = null;
List<SocketAddress> failedGroups = new ArrayList<SocketAddress>();
Expand Down
18 changes: 4 additions & 14 deletions test/jdk/java/net/MulticastSocket/PromiscuousIPv6.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 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
Expand All @@ -24,7 +24,9 @@
/*
* @test
* @bug 8215294
* @requires os.family == "linux"
* @requires os.family == "linux" & !(os.version ~= "3\\.10\\.0.*")
* @comment This test should only be run on Linux.
* The behavior under test is known NOT to work on Linux 3.10.0* kernels.
* @library /test/lib
* @build jdk.test.lib.NetworkConfiguration
* PromiscuousIPv6
Expand Down Expand Up @@ -148,18 +150,6 @@ static void test(NetworkInterface nif, InetAddress group1, InetAddress group2)
}

public static void main(String args[]) throws IOException {
String os = System.getProperty("os.name");

if (!os.equals("Linux")) {
throw new SkippedException("This test should be run only on Linux");
} else {
String osVersion = System.getProperty("os.version");
String prefix = "3.10.0";
if (osVersion.startsWith(prefix)) {
throw new SkippedException(
String.format("The behavior under test is known NOT to work on '%s' kernels", prefix));
}
}

NetworkConfiguration.printSystemConfiguration(System.out);
List<NetworkInterface> nifs = NetworkConfiguration.probe()
Expand Down
17 changes: 4 additions & 13 deletions test/jdk/java/net/MulticastSocket/SetOutgoingIf.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, 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
Expand All @@ -24,10 +24,11 @@
/*
* @test
* @bug 4742177 8241786
* @summary Re-test IPv6 (and specifically MulticastSocket) with latest Linux & USAGI code
* @requires os.family != "windows"
* @library /test/lib
* @run main/othervm SetOutgoingIf
* @run main/othervm -Djdk.net.usePlainDatagramSocketImpl SetOutgoingIf
* @summary Re-test IPv6 (and specifically MulticastSocket) with latest Linux & USAGI code
*/
import java.io.IOException;
import java.net.*;
Expand All @@ -37,7 +38,7 @@


public class SetOutgoingIf implements AutoCloseable {
private static String osname;

private final MulticastSocket SOCKET;
private final int PORT;
private final Map<NetIf, MulticastSender> sendersMap = new ConcurrentHashMap<>();
Expand All @@ -50,12 +51,6 @@ private SetOutgoingIf() {
}
}

static boolean isWindows() {
if (osname == null)
osname = System.getProperty("os.name");
return osname.contains("Windows");
}

static boolean isMacOS() {
return System.getProperty("os.name").contains("OS X");
}
Expand Down Expand Up @@ -83,10 +78,6 @@ public void close() {
}

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

if (!hasIPv6()) {
System.out.println("No IPv6 available. Bye.");
Expand Down
7 changes: 2 additions & 5 deletions test/jdk/java/net/ServerSocket/AnotherSelectFdsLimit.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
Expand All @@ -25,6 +25,7 @@
* @test
* @bug 8035897
* @summary FD_SETSIZE should be set on macosx
* @requires os.family == "mac"
* @run main/othervm AnotherSelectFdsLimit 1023
* @run main/othervm AnotherSelectFdsLimit 1024
* @run main/othervm AnotherSelectFdsLimit 1025
Expand All @@ -41,10 +42,6 @@ public class AnotherSelectFdsLimit {
static final int DEFAULT_FDS_TO_USE = 1600;

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

int fdsToUse = DEFAULT_FDS_TO_USE;
if (args.length == 1)
Expand Down
10 changes: 2 additions & 8 deletions test/jdk/java/net/ServerSocket/SelectFdsLimit.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
Expand Down Expand Up @@ -27,6 +27,7 @@
* @summary The total number of file descriptors is limited to
* 1024(FDSET_SIZE) on MacOSX (the size of fd array passed to select()
* call in java.net classes is limited to this value).
* @requires os.family == "mac"
* @run main/othervm SelectFdsLimit
* @author [email protected]
*/
Expand All @@ -35,7 +36,6 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.SocketTimeoutException;

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

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

//The bug 8021820 is a Mac specific and because of that test will pass on all
//other platforms
if (!System.getProperty("os.name").contains("OS X")) {
return;
}

//Create test directory with test files
prepareTestEnv();

Expand Down