8356107: [java.lang] Use @requires tag instead of exiting based on os.name or separatorChar property

Reviewed-by: naoto, bpb
This commit is contained in:
Brent Christian 2025-05-13 17:05:15 +00:00
parent 08b2df80c6
commit d1543429ff
4 changed files with 9 additions and 79 deletions

View File

@ -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
@ -26,6 +26,7 @@
* @bug 6921885
* @run main/othervm SiblingIOEHandle
* @summary inherit IOE handles and MS CreateProcess limitations (kb315939)
* @requires (os.family == "windows")
*/
import java.io.BufferedReader;
@ -58,10 +59,6 @@ public class SiblingIOEHandle {
}
public static void main(String[] args) {
if (!System.getProperty("os.name").startsWith("Windows")) {
return;
}
APP app = (args.length > 0) ? APP.valueOf(args[0]) : APP.A;
switch (app) {
case A:

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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,13 +24,13 @@
/* @test 1.4 00/10/18
@bug 4231349
@summary test runtime.exec on windows for extra space in cmd
@requires (os.family == "windows")
*/
import java.io.*;
public class Space {
public static void main(String[] args) throws Exception {
if (File.separatorChar == '\\') {
try {
try {
Process p = Runtime.getRuntime().exec( "cmd /c echo hello" );
BufferedReader reader = new BufferedReader(
new InputStreamReader(p.getInputStream()));
@ -38,10 +38,9 @@ public class Space {
String echo = reader.readLine();
if (echo.length() == 6)
throw new RuntimeException("Extra space in command.");
} catch (IOException e) {
// not Win NT - cmd doesnt exist
} catch (IOException e) {
// not Win NT - cmd doesn't exist
return;
}
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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 4763362
* @summary Ensure that Process.waitFor returns the correct status code
* even for very short-running subprocesses
* @requires (os.family == "linux")
*/
@ -35,10 +36,6 @@ public class Status {
public static void main(String args[])
throws Exception
{
if (!System.getProperty("os.name").equals("Linux")) {
System.out.println("Only for Linux");
return;
}
UnixCommands.ensureCommandsAvailable("false");
final String falseCmd = UnixCommands.findCommand("false");

View File

@ -1,63 +0,0 @@
/*
* Copyright (c) 2018, 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 4459099
* @key i18n
* @summary Tests non ANSI code page locales set default file encoding
* to "utf-8". This test must be run on Windows 2K/XP in one of Armenian,
* Georgian, Hindi, Punjabi, Gujarati, Tamil, Telugu, Kannada, Marathi,
* or Sanskrit languages.
*/
public class NonAnsiFileEncodingTest {
public static void main(String[] s) {
String OS = System.getProperty("os.name");
String lang = System.getProperty("user.language");
String fileenc = System.getProperty("file.encoding");
if (!(OS.equals("Windows 2000") || OS.equals("Windows XP"))) {
System.out.println("This test is not meaningful on the platform \"" + OS + "\".");
return;
}
if (!(lang.equals("hy") || // Armenian
lang.equals("ka") || // Georgian
lang.equals("hi") || // Hindi
lang.equals("pa") || // Punjabi
lang.equals("gu") || // Gujarati
lang.equals("ta") || // Tamil
lang.equals("te") || // Telugu
lang.equals("kn") || // Kannada
lang.equals("mr") || // Marathi
lang.equals("sa"))) { // Sanskrit
System.out.println("Windows' locale settings for this test is incorrect. Select one of \"Armenian\", \"Georgian\", \"Hindi\", \"Punjabi\", \"Gujarati\", \"Tamil\", \"Telugu\", \"Kannada\", \"Marathi\", or \"Sanskrit\" for the user locale, and \"English(United States)\" for the system default locale using the Control Panel.");
return;
}
if (!fileenc.equals("utf-8")) {
throw new RuntimeException("file.encoding is incorrectly set to \"" + fileenc + "\". Should be \"utf-8\".");
}
}
}