8304911: Use OperatingSystem enum in some modules
Reviewed-by: naoto, lancea, iris, jpai
This commit is contained in:
parent
76975da59e
commit
ba90dc7795
@ -281,7 +281,12 @@ module java.base {
|
|||||||
exports jdk.internal.util.random to
|
exports jdk.internal.util.random to
|
||||||
jdk.random;
|
jdk.random;
|
||||||
exports jdk.internal.util to
|
exports jdk.internal.util to
|
||||||
java.desktop;
|
java.desktop,
|
||||||
|
java.prefs,
|
||||||
|
java.security.jgss,
|
||||||
|
java.smartcardio,
|
||||||
|
jdk.charsets,
|
||||||
|
jdk.net;
|
||||||
exports sun.net to
|
exports sun.net to
|
||||||
java.net.http,
|
java.net.http,
|
||||||
jdk.naming.dns;
|
jdk.naming.dns;
|
||||||
|
@ -50,6 +50,8 @@ grant codeBase "jrt:/java.smartcardio" {
|
|||||||
"accessClassInPackage.sun.security.jca";
|
"accessClassInPackage.sun.security.jca";
|
||||||
permission java.lang.RuntimePermission
|
permission java.lang.RuntimePermission
|
||||||
"accessClassInPackage.sun.security.util";
|
"accessClassInPackage.sun.security.util";
|
||||||
|
permission java.lang.RuntimePermission
|
||||||
|
"accessClassInPackage.jdk.internal.util";
|
||||||
permission java.util.PropertyPermission
|
permission java.util.PropertyPermission
|
||||||
"javax.smartcardio.TerminalFactory.DefaultType", "read";
|
"javax.smartcardio.TerminalFactory.DefaultType", "read";
|
||||||
permission java.util.PropertyPermission "os.name", "read";
|
permission java.util.PropertyPermission "os.name", "read";
|
||||||
@ -118,6 +120,8 @@ grant codeBase "jrt:/jdk.charsets" {
|
|||||||
"accessClassInPackage.jdk.internal.access";
|
"accessClassInPackage.jdk.internal.access";
|
||||||
permission java.lang.RuntimePermission
|
permission java.lang.RuntimePermission
|
||||||
"accessClassInPackage.jdk.internal.misc";
|
"accessClassInPackage.jdk.internal.misc";
|
||||||
|
permission java.lang.RuntimePermission
|
||||||
|
"accessClassInPackage.jdk.internal.util";
|
||||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.cs";
|
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.cs";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package java.util.prefs;
|
package java.util.prefs;
|
||||||
|
|
||||||
|
import jdk.internal.util.OperatingSystem;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -292,15 +294,11 @@ public abstract class Preferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. Use platform-specific system-wide default
|
// 3. Use platform-specific system-wide default
|
||||||
String osName = System.getProperty("os.name");
|
String platformFactory = switch (OperatingSystem.current()) {
|
||||||
String platformFactory;
|
case WINDOWS -> "java.util.prefs.WindowsPreferencesFactory";
|
||||||
if (osName.startsWith("Windows")) {
|
case MACOS -> "java.util.prefs.MacOSXPreferencesFactory";
|
||||||
platformFactory = "java.util.prefs.WindowsPreferencesFactory";
|
default -> "java.util.prefs.FileSystemPreferencesFactory";
|
||||||
} else if (osName.contains("OS X")) {
|
};
|
||||||
platformFactory = "java.util.prefs.MacOSXPreferencesFactory";
|
|
||||||
} else {
|
|
||||||
platformFactory = "java.util.prefs.FileSystemPreferencesFactory";
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
Object result = Class.forName(platformFactory, false,
|
Object result = Class.forName(platformFactory, false,
|
||||||
|
@ -30,6 +30,9 @@ import java.util.HashMap;
|
|||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
|
|
||||||
|
import jdk.internal.util.OperatingSystem;
|
||||||
|
import jdk.internal.util.StaticProperty;
|
||||||
import org.ietf.jgss.Oid;
|
import org.ietf.jgss.Oid;
|
||||||
import sun.security.action.GetBooleanAction;
|
import sun.security.action.GetBooleanAction;
|
||||||
import sun.security.action.PutAllAction;
|
import sun.security.action.PutAllAction;
|
||||||
@ -87,25 +90,22 @@ public final class SunNativeProvider extends Provider {
|
|||||||
String defaultLib
|
String defaultLib
|
||||||
= System.getProperty("sun.security.jgss.lib");
|
= System.getProperty("sun.security.jgss.lib");
|
||||||
if (defaultLib == null || defaultLib.trim().equals("")) {
|
if (defaultLib == null || defaultLib.trim().equals("")) {
|
||||||
String osname = System.getProperty("os.name");
|
gssLibs = switch (OperatingSystem.current()) {
|
||||||
if (osname.startsWith("Linux")) {
|
case LINUX -> new String[]{
|
||||||
gssLibs = new String[]{
|
"libgssapi.so",
|
||||||
"libgssapi.so",
|
"libgssapi_krb5.so",
|
||||||
"libgssapi_krb5.so",
|
"libgssapi_krb5.so.2",
|
||||||
"libgssapi_krb5.so.2",
|
|
||||||
};
|
};
|
||||||
} else if (osname.contains("OS X")) {
|
case MACOS -> new String[]{
|
||||||
gssLibs = new String[]{
|
"libgssapi_krb5.dylib",
|
||||||
"libgssapi_krb5.dylib",
|
"/usr/lib/sasl2/libgssapiv2.2.so",
|
||||||
"/usr/lib/sasl2/libgssapiv2.2.so",
|
};
|
||||||
};
|
case WINDOWS -> new String[]{
|
||||||
} else if (osname.contains("Windows")) {
|
// Full path needed, DLL is in jre/bin
|
||||||
// Full path needed, DLL is in jre/bin
|
StaticProperty.javaHome() + "\\bin\\sspi_bridge.dll",
|
||||||
gssLibs = new String[]{ System.getProperty("java.home")
|
};
|
||||||
+ "\\bin\\sspi_bridge.dll" };
|
default -> new String[0];
|
||||||
} else {
|
};
|
||||||
gssLibs = new String[0];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
gssLibs = new String[]{ defaultLib };
|
gssLibs = new String[]{ defaultLib };
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,6 +44,7 @@ import java.security.PrivilegedExceptionAction;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import jdk.internal.util.OperatingSystem;
|
||||||
import sun.net.dns.ResolverConfiguration;
|
import sun.net.dns.ResolverConfiguration;
|
||||||
import sun.security.action.GetPropertyAction;
|
import sun.security.action.GetPropertyAction;
|
||||||
import sun.security.krb5.internal.crypto.EType;
|
import sun.security.krb5.internal.crypto.EType;
|
||||||
@ -159,8 +160,7 @@ public class Config {
|
|||||||
|
|
||||||
private static boolean isMacosLionOrBetter() {
|
private static boolean isMacosLionOrBetter() {
|
||||||
// split the "10.x.y" version number
|
// split the "10.x.y" version number
|
||||||
String osname = GetPropertyAction.privilegedGetProperty("os.name");
|
if (!OperatingSystem.isMacOS()) {
|
||||||
if (!osname.contains("OS X")) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -892,8 +892,7 @@ public class Config {
|
|||||||
*/
|
*/
|
||||||
private String getNativeFileName() {
|
private String getNativeFileName() {
|
||||||
String name = null;
|
String name = null;
|
||||||
String osname = GetPropertyAction.privilegedGetProperty("os.name");
|
if (OperatingSystem.isWindows()) {
|
||||||
if (osname.startsWith("Windows")) {
|
|
||||||
try {
|
try {
|
||||||
Credentials.ensureLoaded();
|
Credentials.ensureLoaded();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -926,7 +925,7 @@ public class Config {
|
|||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = "c:\\winnt\\krb5.ini";
|
name = "c:\\winnt\\krb5.ini";
|
||||||
}
|
}
|
||||||
} else if (osname.contains("OS X")) {
|
} else if (OperatingSystem.isMacOS()) {
|
||||||
name = findMacosConfigFile();
|
name = findMacosConfigFile();
|
||||||
} else {
|
} else {
|
||||||
name = "/etc/krb5.conf";
|
name = "/etc/krb5.conf";
|
||||||
@ -1193,8 +1192,7 @@ public class Config {
|
|||||||
new java.security.PrivilegedAction<String>() {
|
new java.security.PrivilegedAction<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String run() {
|
public String run() {
|
||||||
String osname = System.getProperty("os.name");
|
if (OperatingSystem.isWindows()) {
|
||||||
if (osname.startsWith("Windows")) {
|
|
||||||
return System.getenv("USERDNSDOMAIN");
|
return System.getenv("USERDNSDOMAIN");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -1241,8 +1239,7 @@ public class Config {
|
|||||||
new java.security.PrivilegedAction<String>() {
|
new java.security.PrivilegedAction<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String run() {
|
public String run() {
|
||||||
String osname = System.getProperty("os.name");
|
if (OperatingSystem.isWindows()) {
|
||||||
if (osname.startsWith("Windows")) {
|
|
||||||
String logonServer = System.getenv("LOGONSERVER");
|
String logonServer = System.getenv("LOGONSERVER");
|
||||||
if (logonServer != null
|
if (logonServer != null
|
||||||
&& logonServer.startsWith("\\\\")) {
|
&& logonServer.startsWith("\\\\")) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
package sun.security.krb5;
|
package sun.security.krb5;
|
||||||
|
|
||||||
import sun.security.action.GetPropertyAction;
|
import jdk.internal.util.OperatingSystem;
|
||||||
import sun.security.krb5.internal.*;
|
import sun.security.krb5.internal.*;
|
||||||
import sun.security.krb5.internal.ccache.CredentialsCache;
|
import sun.security.krb5.internal.ccache.CredentialsCache;
|
||||||
import sun.security.krb5.internal.crypto.EType;
|
import sun.security.krb5.internal.crypto.EType;
|
||||||
@ -39,7 +39,6 @@ import sun.security.util.SecurityProperties;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -327,9 +326,8 @@ public class Credentials {
|
|||||||
|
|
||||||
if (ticketCache == null) {
|
if (ticketCache == null) {
|
||||||
// The default ticket cache on Windows and Mac is not a file.
|
// The default ticket cache on Windows and Mac is not a file.
|
||||||
String os = GetPropertyAction.privilegedGetProperty("os.name");
|
if (OperatingSystem.isWindows() ||
|
||||||
if (os.toUpperCase(Locale.ENGLISH).startsWith("WINDOWS") ||
|
OperatingSystem.isMacOS()) {
|
||||||
os.toUpperCase(Locale.ENGLISH).contains("OS X")) {
|
|
||||||
Credentials creds = acquireDefaultCreds();
|
Credentials creds = acquireDefaultCreds();
|
||||||
if (creds == null) {
|
if (creds == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@ -530,7 +528,7 @@ public class Credentials {
|
|||||||
java.security.AccessController.doPrivileged(
|
java.security.AccessController.doPrivileged(
|
||||||
new java.security.PrivilegedAction<Void> () {
|
new java.security.PrivilegedAction<Void> () {
|
||||||
public Void run() {
|
public Void run() {
|
||||||
if (System.getProperty("os.name").contains("OS X")) {
|
if (OperatingSystem.isMacOS()) {
|
||||||
System.loadLibrary("osxkrb5");
|
System.loadLibrary("osxkrb5");
|
||||||
} else {
|
} else {
|
||||||
System.loadLibrary("w2k_lsa_auth");
|
System.loadLibrary("w2k_lsa_auth");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package sun.security.krb5;
|
package sun.security.krb5;
|
||||||
|
|
||||||
|
import jdk.internal.util.OperatingSystem;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -47,8 +49,7 @@ public class SCDynamicStoreConfig {
|
|||||||
boolean isMac = java.security.AccessController.doPrivileged(
|
boolean isMac = java.security.AccessController.doPrivileged(
|
||||||
new java.security.PrivilegedAction<Boolean>() {
|
new java.security.PrivilegedAction<Boolean>() {
|
||||||
public Boolean run() {
|
public Boolean run() {
|
||||||
String osname = System.getProperty("os.name");
|
if (OperatingSystem.isMacOS()) {
|
||||||
if (osname.contains("OS X")) {
|
|
||||||
System.loadLibrary("osxkrb5");
|
System.loadLibrary("osxkrb5");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -33,6 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
package sun.security.krb5.internal.ccache;
|
package sun.security.krb5.internal.ccache;
|
||||||
|
|
||||||
|
import jdk.internal.util.OperatingSystem;
|
||||||
import sun.security.action.GetPropertyAction;
|
import sun.security.action.GetPropertyAction;
|
||||||
import sun.security.krb5.*;
|
import sun.security.krb5.*;
|
||||||
import sun.security.krb5.internal.*;
|
import sun.security.krb5.internal.*;
|
||||||
@ -465,9 +466,6 @@ public class FileCredentialsCache extends CredentialsCache
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get cache name from system.property
|
|
||||||
String osname = GetPropertyAction.privilegedGetProperty("os.name");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For Unix platforms we use the default cache name to be
|
* For Unix platforms we use the default cache name to be
|
||||||
* /tmp/krb5cc_uid ; for all other platforms we use
|
* /tmp/krb5cc_uid ; for all other platforms we use
|
||||||
@ -479,7 +477,7 @@ public class FileCredentialsCache extends CredentialsCache
|
|||||||
* Windows.
|
* Windows.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (osname != null && !osname.startsWith("Windows")) {
|
if (!OperatingSystem.isWindows()) {
|
||||||
long uid = jdk.internal.misc.VM.getuid();
|
long uid = jdk.internal.misc.VM.getuid();
|
||||||
if (uid != -1) {
|
if (uid != -1) {
|
||||||
name = File.separator + "tmp" +
|
name = File.separator + "tmp" +
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,9 +25,8 @@
|
|||||||
|
|
||||||
package sun.security.smartcardio;
|
package sun.security.smartcardio;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import jdk.internal.util.OperatingSystem;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import javax.smartcardio.*;
|
import javax.smartcardio.*;
|
||||||
import static sun.security.smartcardio.PCSC.*;
|
import static sun.security.smartcardio.PCSC.*;
|
||||||
|
|
||||||
@ -62,16 +61,6 @@ final class CardImpl extends Card {
|
|||||||
// thread holding exclusive access to the card, or null
|
// thread holding exclusive access to the card, or null
|
||||||
private volatile Thread exclusiveThread;
|
private volatile Thread exclusiveThread;
|
||||||
|
|
||||||
// used for platform specific logic
|
|
||||||
private static final boolean isWindows;
|
|
||||||
|
|
||||||
static {
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
final String osName = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<String>) () -> System.getProperty("os.name"));
|
|
||||||
isWindows = osName.startsWith("Windows");
|
|
||||||
}
|
|
||||||
|
|
||||||
CardImpl(TerminalImpl terminal, String protocol) throws PCSCException {
|
CardImpl(TerminalImpl terminal, String protocol) throws PCSCException {
|
||||||
this.terminal = terminal;
|
this.terminal = terminal;
|
||||||
int sharingMode = SCARD_SHARE_SHARED;
|
int sharingMode = SCARD_SHARE_SHARED;
|
||||||
@ -88,7 +77,7 @@ final class CardImpl extends Card {
|
|||||||
// MSDN states that the preferred protocol can be zero, but doesn't
|
// MSDN states that the preferred protocol can be zero, but doesn't
|
||||||
// specify whether other values are allowed.
|
// specify whether other values are allowed.
|
||||||
// pcsc-lite implementation expects the preferred protocol to be non zero.
|
// pcsc-lite implementation expects the preferred protocol to be non zero.
|
||||||
connectProtocol = isWindows ? 0 : SCARD_PROTOCOL_RAW;
|
connectProtocol = OperatingSystem.isWindows() ? 0 : SCARD_PROTOCOL_RAW;
|
||||||
|
|
||||||
sharingMode = SCARD_SHARE_DIRECT;
|
sharingMode = SCARD_SHARE_DIRECT;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2021, 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -35,11 +35,10 @@ import java.nio.charset.CharacterCodingException;
|
|||||||
import java.nio.charset.MalformedInputException;
|
import java.nio.charset.MalformedInputException;
|
||||||
import sun.nio.cs.DelegatableDecoder;
|
import sun.nio.cs.DelegatableDecoder;
|
||||||
import sun.nio.cs.HistoricallyNamedCharset;
|
import sun.nio.cs.HistoricallyNamedCharset;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import sun.nio.cs.*;
|
import sun.nio.cs.*;
|
||||||
import static java.lang.Character.UnicodeBlock;
|
import static java.lang.Character.UnicodeBlock;
|
||||||
|
|
||||||
|
import jdk.internal.util.OperatingSystem;
|
||||||
|
|
||||||
public class JISAutoDetect
|
public class JISAutoDetect
|
||||||
extends Charset
|
extends Charset
|
||||||
@ -93,9 +92,6 @@ public class JISAutoDetect
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Decoder extends CharsetDecoder {
|
private static class Decoder extends CharsetDecoder {
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static final String osName = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<String>) () -> System.getProperty("os.name"));
|
|
||||||
|
|
||||||
private static final String SJISName = getSJISName();
|
private static final String SJISName = getSJISName();
|
||||||
private static final String EUCJPName = "EUC_JP";
|
private static final String EUCJPName = "EUC_JP";
|
||||||
@ -226,7 +222,7 @@ public class JISAutoDetect
|
|||||||
* Returned Shift_JIS Charset name is OS dependent
|
* Returned Shift_JIS Charset name is OS dependent
|
||||||
*/
|
*/
|
||||||
private static String getSJISName() {
|
private static String getSJISName() {
|
||||||
if (osName.startsWith("Windows"))
|
if (OperatingSystem.isWindows())
|
||||||
return("windows-31J");
|
return("windows-31J");
|
||||||
else
|
else
|
||||||
return("Shift_JIS");
|
return("Shift_JIS");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -29,13 +29,12 @@ import java.io.FileDescriptor;
|
|||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.net.SocketOption;
|
import java.net.SocketOption;
|
||||||
import java.net.StandardProtocolFamily;
|
import java.net.StandardProtocolFamily;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import jdk.internal.access.JavaIOFileDescriptorAccess;
|
import jdk.internal.access.JavaIOFileDescriptorAccess;
|
||||||
import jdk.internal.access.SharedSecrets;
|
import jdk.internal.access.SharedSecrets;
|
||||||
|
import jdk.internal.util.OperatingSystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines extended socket options, beyond those defined in
|
* Defines extended socket options, beyond those defined in
|
||||||
@ -400,22 +399,12 @@ public final class ExtendedSocketOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static PlatformSocketOptions create() {
|
private static PlatformSocketOptions create() {
|
||||||
@SuppressWarnings("removal")
|
return switch (OperatingSystem.current()) {
|
||||||
String osname = AccessController.doPrivileged(
|
case LINUX -> newInstance("jdk.net.LinuxSocketOptions");
|
||||||
new PrivilegedAction<String>() {
|
case MACOS -> newInstance("jdk.net.MacOSXSocketOptions");
|
||||||
public String run() {
|
case WINDOWS -> newInstance("jdk.net.WindowsSocketOptions");
|
||||||
return System.getProperty("os.name");
|
default -> new PlatformSocketOptions();
|
||||||
}
|
};
|
||||||
});
|
|
||||||
if ("Linux".equals(osname)) {
|
|
||||||
return newInstance("jdk.net.LinuxSocketOptions");
|
|
||||||
} else if (osname.startsWith("Mac")) {
|
|
||||||
return newInstance("jdk.net.MacOSXSocketOptions");
|
|
||||||
} else if (osname.startsWith("Windows")) {
|
|
||||||
return newInstance("jdk.net.WindowsSocketOptions");
|
|
||||||
} else {
|
|
||||||
return new PlatformSocketOptions();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final PlatformSocketOptions instance = create();
|
private static final PlatformSocketOptions instance = create();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -41,10 +41,6 @@ import com.sun.nio.sctp.SctpSocketOption;
|
|||||||
import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
|
import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
|
||||||
|
|
||||||
public class SctpNet {
|
public class SctpNet {
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static final String osName = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<String>) () -> System.getProperty("os.name"));
|
|
||||||
|
|
||||||
/* -- Miscellaneous SCTP utilities -- */
|
/* -- Miscellaneous SCTP utilities -- */
|
||||||
|
|
||||||
private static boolean IPv4MappedAddresses() {
|
private static boolean IPv4MappedAddresses() {
|
||||||
@ -350,4 +346,3 @@ public class SctpNet {
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user