8303485: Replacing os.name for operating system customization

Reviewed-by: naoto, erikj, alanb
This commit is contained in:
Roger Riggs 2023-03-27 17:45:20 +00:00
parent 87b314a985
commit 6c3b10fb1d
13 changed files with 371 additions and 114 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, 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 @@
package java.lang;
import jdk.internal.util.OperatingSystem;
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
@ -35,7 +36,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import jdk.internal.event.ProcessStartEvent;
import sun.security.action.GetPropertyAction;
/**
* This class is used to create operating system processes.
@ -469,9 +469,8 @@ public final class ProcessBuilder
* @since 1.7
*/
public abstract static class Redirect {
private static final File NULL_FILE = new File(
(GetPropertyAction.privilegedGetProperty("os.name")
.startsWith("Windows") ? "NUL" : "/dev/null")
private static final File NULL_FILE =
new File((OperatingSystem.isWindows() ? "NUL" : "/dev/null")
);
/**

View file

@ -63,7 +63,7 @@ import java.util.stream.StreamSupport;
import jdk.internal.access.JavaUtilZipFileAccess;
import jdk.internal.access.JavaUtilJarAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.VM;
import jdk.internal.util.OperatingSystem;
import jdk.internal.perf.PerfCounter;
import jdk.internal.ref.CleanerFactory;
import jdk.internal.vm.annotation.Stable;
@ -1085,8 +1085,6 @@ public class ZipFile implements ZipConstants, Closeable {
}
}
private static boolean isWindows;
static {
SharedSecrets.setJavaUtilZipFileAccess(
new JavaUtilZipFileAccess() {
@ -1133,7 +1131,6 @@ public class ZipFile implements ZipConstants, Closeable {
}
);
isWindows = VM.getSavedProperty("os.name").contains("Windows");
}
private static class Source {
@ -1321,7 +1318,7 @@ public class ZipFile implements ZipConstants, Closeable {
this.zc = zc;
this.key = key;
if (toDelete) {
if (isWindows) {
if (OperatingSystem.isWindows()) {
this.zfile = SharedSecrets.getJavaIORandomAccessFileAccess()
.openAndDelete(key.file, "r");
} else {