mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8314877: Make fields final in 'java.net' package
Reviewed-by: jpai
This commit is contained in:
parent
86115c2a2e
commit
283c360392
10 changed files with 23 additions and 27 deletions
|
@ -53,7 +53,7 @@ import java.util.Set;
|
||||||
private final String server;
|
private final String server;
|
||||||
private final Socket socket;
|
private final Socket socket;
|
||||||
private InetSocketAddress external_address;
|
private InetSocketAddress external_address;
|
||||||
private HashMap<Integer, Object> optionsMap = new HashMap<>();
|
private final HashMap<Integer, Object> optionsMap = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 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
|
||||||
|
@ -42,7 +42,7 @@ public class HttpRetryException extends IOException {
|
||||||
/**
|
/**
|
||||||
* The response code.
|
* The response code.
|
||||||
*/
|
*/
|
||||||
private int responseCode;
|
private final int responseCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to be redirected to.
|
* The URL to be redirected to.
|
||||||
|
|
|
@ -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
|
||||||
|
@ -242,9 +242,10 @@ public final class IDN {
|
||||||
private static final int MAX_LABEL_LENGTH = 63;
|
private static final int MAX_LABEL_LENGTH = 63;
|
||||||
|
|
||||||
// single instance of nameprep
|
// single instance of nameprep
|
||||||
private static StringPrep namePrep = null;
|
private static final StringPrep namePrep;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
StringPrep stringPrep = null;
|
||||||
try {
|
try {
|
||||||
final String IDN_PROFILE = "/sun/net/idn/uidna.spp";
|
final String IDN_PROFILE = "/sun/net/idn/uidna.spp";
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
|
@ -255,12 +256,13 @@ public final class IDN {
|
||||||
}})
|
}})
|
||||||
: StringPrep.class.getResourceAsStream(IDN_PROFILE);
|
: StringPrep.class.getResourceAsStream(IDN_PROFILE);
|
||||||
|
|
||||||
namePrep = new StringPrep(stream);
|
stringPrep = new StringPrep(stream);
|
||||||
stream.close();
|
stream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// should never reach here
|
// should never reach here
|
||||||
assert false;
|
assert false;
|
||||||
}
|
}
|
||||||
|
namePrep = stringPrep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 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
|
||||||
|
@ -39,8 +39,8 @@ package java.net;
|
||||||
|
|
||||||
public final class PasswordAuthentication {
|
public final class PasswordAuthentication {
|
||||||
|
|
||||||
private String userName;
|
private final String userName;
|
||||||
private char[] password;
|
private final char[] password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@code PasswordAuthentication} object from the given
|
* Creates a new {@code PasswordAuthentication} object from the given
|
||||||
|
|
|
@ -59,8 +59,8 @@ public class Proxy {
|
||||||
SOCKS
|
SOCKS
|
||||||
};
|
};
|
||||||
|
|
||||||
private Type type;
|
private final Type type;
|
||||||
private SocketAddress sa;
|
private final SocketAddress sa;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A proxy setting that represents a {@code DIRECT} connection,
|
* A proxy setting that represents a {@code DIRECT} connection,
|
||||||
|
|
|
@ -44,6 +44,7 @@ import java.util.Vector;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import sun.net.util.IPAddressUtil;
|
import sun.net.util.IPAddressUtil;
|
||||||
import sun.net.PortConfig;
|
import sun.net.PortConfig;
|
||||||
|
import sun.security.action.GetBooleanAction;
|
||||||
import sun.security.util.RegisteredDomain;
|
import sun.security.util.RegisteredDomain;
|
||||||
import sun.security.util.SecurityConstants;
|
import sun.security.util.SecurityConstants;
|
||||||
import sun.security.util.Debug;
|
import sun.security.util.Debug;
|
||||||
|
@ -234,7 +235,7 @@ public final class SocketPermission extends Permission
|
||||||
private transient boolean trusted;
|
private transient boolean trusted;
|
||||||
|
|
||||||
// true if the sun.net.trustNameService system property is set
|
// true if the sun.net.trustNameService system property is set
|
||||||
private static boolean trustNameService;
|
private static final boolean trustNameService = GetBooleanAction.privilegedGetProperty("sun.net.trustNameService");
|
||||||
|
|
||||||
private static Debug debug = null;
|
private static Debug debug = null;
|
||||||
private static boolean debugInit = false;
|
private static boolean debugInit = false;
|
||||||
|
@ -245,13 +246,6 @@ public final class SocketPermission extends Permission
|
||||||
static final int high = initEphemeralPorts("high", PORT_MAX);
|
static final int high = initEphemeralPorts("high", PORT_MAX);
|
||||||
};
|
};
|
||||||
|
|
||||||
static {
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
Boolean tmp = java.security.AccessController.doPrivileged(
|
|
||||||
new sun.security.action.GetBooleanAction("sun.net.trustNameService"));
|
|
||||||
trustNameService = tmp.booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static synchronized Debug getDebug() {
|
private static synchronized Debug getDebug() {
|
||||||
if (!debugInit) {
|
if (!debugInit) {
|
||||||
debug = Debug.getInstance("access");
|
debug = Debug.getInstance("access");
|
||||||
|
|
|
@ -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
|
||||||
|
@ -2977,7 +2977,7 @@ public final class URI
|
||||||
|
|
||||||
private class Parser {
|
private class Parser {
|
||||||
|
|
||||||
private String input; // URI input string
|
private final String input; // URI input string
|
||||||
private boolean requireServerAuthority = false;
|
private boolean requireServerAuthority = false;
|
||||||
|
|
||||||
Parser(String s) {
|
Parser(String s) {
|
||||||
|
|
|
@ -1471,10 +1471,10 @@ public final class URL implements java.io.Serializable {
|
||||||
private static Iterator<URLStreamHandlerProvider> providers() {
|
private static Iterator<URLStreamHandlerProvider> providers() {
|
||||||
return new Iterator<>() {
|
return new Iterator<>() {
|
||||||
|
|
||||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
final ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||||
ServiceLoader<URLStreamHandlerProvider> sl =
|
final ServiceLoader<URLStreamHandlerProvider> sl =
|
||||||
ServiceLoader.load(URLStreamHandlerProvider.class, cl);
|
ServiceLoader.load(URLStreamHandlerProvider.class, cl);
|
||||||
Iterator<URLStreamHandlerProvider> i = sl.iterator();
|
final Iterator<URLStreamHandlerProvider> i = sl.iterator();
|
||||||
|
|
||||||
URLStreamHandlerProvider next = null;
|
URLStreamHandlerProvider next = null;
|
||||||
|
|
||||||
|
@ -1589,7 +1589,7 @@ public final class URL implements java.io.Serializable {
|
||||||
/**
|
/**
|
||||||
* A table of protocol handlers.
|
* A table of protocol handlers.
|
||||||
*/
|
*/
|
||||||
static Hashtable<String,URLStreamHandler> handlers = new Hashtable<>();
|
private static final Hashtable<String, URLStreamHandler> handlers = new Hashtable<>();
|
||||||
private static final Object streamHandlerLock = new Object();
|
private static final Object streamHandlerLock = new Object();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -264,7 +264,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||||
* we have to keep a weak reference to each stream.
|
* we have to keep a weak reference to each stream.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private WeakHashMap<Closeable,Void>
|
private final WeakHashMap<Closeable,Void>
|
||||||
closeables = new WeakHashMap<>();
|
closeables = new WeakHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -308,7 +308,7 @@ public abstract class URLConnection {
|
||||||
|
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
fileNameMap = map = new FileNameMap() {
|
fileNameMap = map = new FileNameMap() {
|
||||||
private FileNameMap internalMap =
|
private final FileNameMap internalMap =
|
||||||
sun.net.www.MimeTable.loadTable();
|
sun.net.www.MimeTable.loadTable();
|
||||||
|
|
||||||
public String getContentTypeFor(String fileName) {
|
public String getContentTypeFor(String fileName) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue