This commit is contained in:
Lana Steuck 2016-04-21 13:37:31 -07:00
commit 860d968d5c
360 changed files with 14366 additions and 2630 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, 2016, 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
@ -83,20 +83,20 @@ ifneq ($(STATIC_BUILD), true)
endif
ifneq ($(OPENJDK_TARGET_OS), windows)
ifeq ($(JVM_VARIANT_SERVER), true)
ifeq ($(call check-jvm-variant, server), true)
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/server/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX)
ifneq (, $(JSIG_DEBUGINFO))
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/server/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))
endif
endif
ifeq ($(JVM_VARIANT_CLIENT), true)
ifeq ($(call check-jvm-variant, client), true)
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/client/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX)
ifneq (, $(JSIG_DEBUGINFO))
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/client/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))
endif
endif
ifneq ($(OPENJDK_TARGET_OS), macosx)
ifeq ($(JVM_VARIANT_MINIMAL1), true)
ifeq ($(call check-jvm-variant, minimal), true)
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/minimal/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX)
ifneq (,$(JSIG_DEBUGINFO))
BASE_TARGETS += $(BASE_INSTALL_LIBRARIES_HERE)/minimal/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2014, 2016, 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
@ -88,7 +88,7 @@ endif
#
# How to install jvm.cfg.
#
ifeq ($(JVM_VARIANT_ZERO), true)
ifeq ($(call check-jvm-variant, zero zeroshark), true)
JVMCFG_ARCH := zero
else
JVMCFG_ARCH := $(OPENJDK_TARGET_CPU_LEGACY)
@ -99,7 +99,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx)
else
JVMCFG_SRC := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/$(JVMCFG_ARCH)/jvm.cfg
# Allow override by ALT_JVMCFG_SRC if it exists
JVMCFG_SRC := $(if $(wildcard $(ALT_JVMCFG_SRC)),$(ALT_JVMCFG_SRC),$(JVMCFG_SRC))
JVMCFG_SRC := $(if $(wildcard $(ALT_JVMCFG_SRC)),$(ALT_JVMCFG_SRC),$(JVMCFG_SRC))
endif
JVMCFG_DIR := $(LIB_DST_DIR)$(OPENJDK_TARGET_CPU_LIBDIR)
JVMCFG := $(JVMCFG_DIR)/jvm.cfg
@ -117,12 +117,12 @@ else
# The main problem is deciding whether to use aliases for the VMs that are not
# present and the current position is that we add aliases for client and server, but
# not for minimal.
CLIENT_AND_SERVER := $(and $(findstring true, $(JVM_VARIANT_SERVER)), $(findstring true, $(JVM_VARIANT_CLIENT)))
ifeq ($(CLIENT_AND_SERVER), true)
CLIENT_AND_SERVER := $(call check-jvm-variant, client)+$(call check-jvm-variant, server)
ifeq ($(CLIENT_AND_SERVER), true+true)
COPY_JVM_CFG_FILE := true
else
# For zero, the default jvm.cfg file is sufficient
ifeq ($(JVM_VARIANT_ZERO), true)
ifeq ($(call check-jvm-variant, zero zeroshark), true)
COPY_JVM_CFG_FILE := true
endif
endif
@ -136,21 +136,21 @@ else
$(MKDIR) -p $(@D)
$(RM) $(@)
# Now check for other permutations
ifeq ($(JVM_VARIANT_SERVER), true)
ifeq ($(call check-jvm-variant, server), true)
$(PRINTF) "-server KNOWN\n">>$(@)
$(PRINTF) "-client ALIASED_TO -server\n">>$(@)
ifeq ($(JVM_VARIANT_MINIMAL1), true)
ifeq ($(call check-jvm-variant, minimal), true)
$(PRINTF) "-minimal KNOWN\n">>$(@)
endif
else
ifeq ($(JVM_VARIANT_CLIENT), true)
ifeq ($(call check-jvm-variant, client), true)
$(PRINTF) "-client KNOWN\n">>$(@)
$(PRINTF) "-server ALIASED_TO -client\n">>$(@)
ifeq ($(JVM_VARIANT_MINIMAL1), true)
ifeq ($(call check-jvm-variant, minimal), true)
$(PRINTF) "-minimal KNOWN\n">>$(@)
endif
else
ifeq ($(JVM_VARIANT_MINIMAL1), true)
ifeq ($(call check-jvm-variant, minimal), true)
$(PRINTF) "-minimal KNOWN\n">>$(@)
$(PRINTF) "-server ALIASED_TO -minimal\n">>$(@)
$(PRINTF) "-client ALIASED_TO -minimal\n">>$(@)

View File

@ -37,6 +37,7 @@ allfonts.chinese-gb18030-extb=SimSun-ExtB
allfonts.chinese-hkscs=MingLiU_HKSCS
allfonts.chinese-ms950-extb=MingLiU-ExtB
allfonts.devanagari=Mangal
allfonts.kannada=Tunga
allfonts.dingbats=Wingdings
allfonts.lucida=Lucida Sans Regular
allfonts.symbol=Symbol
@ -239,11 +240,11 @@ sequence.allfonts.x-windows-874=alphabetic,thai,dingbats,symbol
sequence.fallback=lucida,symbols,\
chinese-ms950,chinese-hkscs,chinese-ms936,chinese-gb18030,\
japanese,korean,chinese-ms950-extb,chinese-ms936-extb,georgian
japanese,korean,chinese-ms950-extb,chinese-ms936-extb,georgian,kannada
# Exclusion Ranges
exclusion.alphabetic=0700-1e9f,1f00-20ab,20ad-f8ff
exclusion.alphabetic=0700-1e9f,1f00-2017,2020-20ab,20ad-20b8,20bb-20bc,20be-f8ff
exclusion.chinese-gb18030=0390-03d6,2200-22ef,2701-27be
exclusion.hebrew=0041-005a,0060-007a,007f-00ff,20ac-20ac
@ -295,6 +296,7 @@ filename.GulimChe=gulim.TTC
filename.Lucida_Sans_Regular=LucidaSansRegular.ttf
filename.Mangal=MANGAL.TTF
filename.Tunga=TUNGA.TTF
filename.Symbol=SYMBOL.TTF
filename.Wingdings=WINGDING.TTF

View File

@ -375,6 +375,7 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),)
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_XAWT_CFLAGS) \
$(X_CFLAGS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := type-limits pointer-to-int-cast \
deprecated-declarations unused-result maybe-uninitialized format \
format-security int-to-pointer-cast parentheses, \
@ -587,6 +588,7 @@ ifeq ($(BUILD_HEADLESS), true)
$(CUPS_CFLAGS) \
$(X_CFLAGS) \
$(LIBAWT_HEADLESS_CFLAGS), \
DISABLED_WARNINGS_xlc := 1506-356, \
DISABLED_WARNINGS_gcc := maybe-uninitialized int-to-pointer-cast, \
DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE \
E_EMPTY_TRANSLATION_UNIT, \
@ -603,6 +605,10 @@ ifeq ($(BUILD_HEADLESS), true)
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_headless, \
))
# AIX warning explanation:
# 1506-356 : (W) Compilation unit is empty.
# This happens during the headless build
$(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
TARGETS += $(BUILD_LIBAWT_HEADLESS)
@ -700,6 +706,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBFONTMANAGER_CFLAGS), \
OPTIMIZATION := $(LIBFONTMANAGER_OPTIMIZATION), \
CFLAGS_windows = -DCC_NOEX, \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := sign-compare int-to-pointer-cast \
type-limits missing-field-initializers, \
DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \

View File

@ -146,6 +146,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \
$(LIBJAVA_CFLAGS), \
System.c_CFLAGS := $(VERSION_CFLAGS), \
jdk_util.c_CFLAGS := $(VERSION_CFLAGS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := unused-result, \
DISABLED_WARNINGS_solstudio := E_STATEMENT_NOT_REACHED, \
MAPFILE := $(LIBJAVA_MAPFILE), \
@ -289,7 +290,7 @@ LIBJLI_SRC_DIRS := $(call FindSrcDirsForLib, java.base, jli)
LIBJLI_CFLAGS := $(CFLAGS_JDKLIB)
ifeq ($(JVM_VARIANT_ZERO), true)
ifeq ($(call check-jvm-variant, zero zeroshark), true)
ERGO_FAMILY := zero
else
ifeq ($(OPENJDK_TARGET_CPU_ARCH), x86)

View File

@ -70,6 +70,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBNIO, \
SRC := $(BUILD_LIBNIO_SRC), \
EXCLUDE_FILES := $(BUILD_LIBNIO_EXFILES), \
OPTIMIZATION := HIGH, \
WARNINGS_AS_ERRORS_xlc := false, \
CFLAGS := $(CFLAGS_JDKLIB) \
$(BUILD_LIBNIO_CFLAGS), \
MAPFILE := $(BUILD_LIBNIO_MAPFILE), \

View File

@ -139,8 +139,7 @@ SUNWprivate_1.1 {
Java_java_lang_Double_doubleToRawLongBits;
Java_java_lang_Float_intBitsToFloat;
Java_java_lang_Float_floatToRawIntBits;
Java_java_lang_StackFrameInfo_fillInStackFrames;
Java_java_lang_StackFrameInfo_setMethodInfo;
Java_java_lang_StackFrameInfo_toStackTraceElement0;
Java_java_lang_StackStreamFactory_checkStackWalkModes;
Java_java_lang_StackStreamFactory_00024AbstractStackWalker_callStackWalk;
Java_java_lang_StackStreamFactory_00024AbstractStackWalker_fetchStackFrames;

View File

@ -102,8 +102,8 @@ public class LinuxFileSystemProvider extends UnixFileSystemProvider {
@Override
FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get(AccessController.doPrivileged(
new GetPropertyAction("user.home")), ".mime.types");
String userHome = GetPropertyAction.getProperty("user.home");
Path userMimeTypes = Paths.get(userHome, ".mime.types");
Path etcMimeTypes = Paths.get("/etc/mime.types");
return chain(new GioFileTypeDetector(),

View File

@ -32,9 +32,9 @@
package sun.nio.ch;
import java.io.IOException;
import java.io.FileDescriptor;
import java.util.Iterator;
import java.util.LinkedList;
import sun.security.action.GetPropertyAction;
/*
* struct kevent { // 32-bit 64-bit
@ -84,10 +84,8 @@ class KQueueArrayWrapper {
static {
IOUtil.load();
initStructSizes();
String datamodel = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.arch.data.model")
);
is64bit = datamodel.equals("64");
String datamodel = GetPropertyAction.getProperty("sun.arch.data.model");
is64bit = "64".equals(datamodel);
}
KQueueArrayWrapper() {

View File

@ -28,7 +28,6 @@ package sun.nio.fs;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.spi.FileTypeDetector;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
/**
@ -47,8 +46,8 @@ public class MacOSXFileSystemProvider extends BsdFileSystemProvider {
@Override
FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get(AccessController.doPrivileged(
new GetPropertyAction("user.home")), ".mime.types");
Path userMimeTypes = Paths.get(
GetPropertyAction.getProperty("user.home"), ".mime.types");
return chain(new MimeTypesFileTypeDetector(userMimeTypes),
new UTIFileTypeDetector());

View File

@ -512,11 +512,17 @@ final class GaloisCounterMode extends FeedbackCipher {
byte[] sOut = new byte[s.length];
GCTR gctrForSToTag = new GCTR(embeddedCipher, this.preCounterBlock);
gctrForSToTag.doFinal(s, 0, s.length, sOut, 0);
// check entire authentication tag for time-consistency
int mismatch = 0;
for (int i = 0; i < tagLenBytes; i++) {
if (tag[i] != sOut[i]) {
throw new AEADBadTagException("Tag mismatch!");
}
mismatch |= tag[i] ^ sOut[i];
}
if (mismatch != 0) {
throw new AEADBadTagException("Tag mismatch!");
}
return len;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2016, 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
@ -182,10 +182,11 @@ interface DataInput {
* not all bytes of {@code b} have been
* updated with data from the input stream.
*
* @param b the buffer into which the data is read.
* @exception EOFException if this stream reaches the end before reading
* all the bytes.
* @exception IOException if an I/O error occurs.
* @param b the buffer into which the data is read.
* @throws NullPointerException if {@code b} is {@code null}.
* @throws EOFException if this stream reaches the end before reading
* all the bytes.
* @throws IOException if an I/O error occurs.
*/
void readFully(byte b[]) throws IOException;
@ -226,12 +227,16 @@ interface DataInput {
* and so on. The number of bytes read is,
* at most, equal to {@code len}.
*
* @param b the buffer into which the data is read.
* @param off an int specifying the offset into the data.
* @param len an int specifying the number of bytes to read.
* @exception EOFException if this stream reaches the end before reading
* all the bytes.
* @exception IOException if an I/O error occurs.
* @param b the buffer into which the data is read.
* @param off an int specifying the offset in the data array {@code b}.
* @param len an int specifying the number of bytes to read.
* @throws NullPointerException if {@code b} is {@code null}.
* @throws IndexOutOfBoundsException if {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}.
* @throws EOFException if this stream reaches the end before reading
* all the bytes.
* @throws IOException if an I/O error occurs.
*/
void readFully(byte b[], int off, int len) throws IOException;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2016, 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
@ -150,38 +150,43 @@ class DataInputStream extends FilterInputStream implements DataInput {
}
/**
* See the general contract of the <code>readFully</code>
* method of <code>DataInput</code>.
* See the general contract of the {@code readFully}
* method of {@code DataInput}.
* <p>
* Bytes
* for this operation are read from the contained
* input stream.
*
* @param b the buffer into which the data is read.
* @exception EOFException if this input stream reaches the end before
* reading all the bytes.
* @exception IOException the stream has been closed and the contained
* input stream does not support reading after close, or
* another I/O error occurs.
* @see java.io.FilterInputStream#in
* @param b the buffer into which the data is read.
* @throws NullPointerException if {@code b} is {@code null}.
* @throws EOFException if this input stream reaches the end before
* reading all the bytes.
* @throws IOException the stream has been closed and the contained
* input stream does not support reading after close, or
* another I/O error occurs.
* @see java.io.FilterInputStream#in
*/
public final void readFully(byte b[]) throws IOException {
readFully(b, 0, b.length);
}
/**
* See the general contract of the <code>readFully</code>
* method of <code>DataInput</code>.
* See the general contract of the {@code readFully}
* method of {@code DataInput}.
* <p>
* Bytes
* for this operation are read from the contained
* input stream.
*
* @param b the buffer into which the data is read.
* @param off the start offset of the data.
* @param off the start offset in the data array {@code b}.
* @param len the number of bytes to read.
* @exception NullPointerException if {@code b} is {@code null}.
* @exception IndexOutOfBoundsException if {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}.
* @exception EOFException if this input stream reaches the end before
* reading all the bytes.
* reading all the bytes.
* @exception IOException the stream has been closed and the contained
* input stream does not support reading after close, or
* another I/O error occurs.

View File

@ -31,7 +31,6 @@ import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.ArrayList;
import java.security.AccessController;
import java.security.SecureRandom;
import java.nio.file.Path;
import java.nio.file.FileSystems;
@ -1896,8 +1895,8 @@ public class File
private TempDirectory() { }
// temporary directory location
private static final File tmpdir = new File(AccessController
.doPrivileged(new GetPropertyAction("java.io.tmpdir")));
private static final File tmpdir = new File(
GetPropertyAction.getProperty("java.io.tmpdir"));
static File location() {
return tmpdir;
}

View File

@ -40,6 +40,9 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import static java.io.ObjectStreamClass.processQueue;
import jdk.internal.misc.JavaObjectInputStreamAccess;
import jdk.internal.misc.ObjectStreamClassValidator;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.Unsafe;
import sun.reflect.misc.ReflectUtil;
@ -853,10 +856,14 @@ public class ObjectInputStream
* exactly 'length' bytes.
*
* @param buf the buffer into which the data is read
* @param off the start offset of the data
* @param off the start offset in the destination array {@code buf}
* @param len the maximum number of bytes read
* @return the actual number of bytes read, -1 is returned when the end of
* the stream is reached.
* @throws NullPointerException if {@code buf} is {@code null}.
* @throws IndexOutOfBoundsException if {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
* {@code buf.length - off}.
* @throws IOException If an I/O error has occurred.
* @see java.io.DataInputStream#readFully(byte[],int,int)
*/
@ -1014,6 +1021,7 @@ public class ObjectInputStream
* Reads bytes, blocking until all bytes are read.
*
* @param buf the buffer into which the data is read
* @throws NullPointerException If {@code buf} is {@code null}.
* @throws EOFException If end of file is reached.
* @throws IOException If other I/O error has occurred.
*/
@ -1025,8 +1033,12 @@ public class ObjectInputStream
* Reads bytes, blocking until all bytes are read.
*
* @param buf the buffer into which the data is read
* @param off the start offset of the data
* @param off the start offset into the data array {@code buf}
* @param len the maximum number of bytes to read
* @throws NullPointerException If {@code buf} is {@code null}.
* @throws IndexOutOfBoundsException If {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
* {@code buf.length - off}.
* @throws EOFException If end of file is reached.
* @throws IOException If other I/O error has occurred.
*/
@ -1509,23 +1521,28 @@ public class ObjectInputStream
throws IOException
{
byte tc = bin.peekByte();
ObjectStreamClass descriptor;
switch (tc) {
case TC_NULL:
return (ObjectStreamClass) readNull();
descriptor = (ObjectStreamClass) readNull();
break;
case TC_REFERENCE:
return (ObjectStreamClass) readHandle(unshared);
descriptor = (ObjectStreamClass) readHandle(unshared);
break;
case TC_PROXYCLASSDESC:
return readProxyDesc(unshared);
descriptor = readProxyDesc(unshared);
break;
case TC_CLASSDESC:
return readNonProxyDesc(unshared);
descriptor = readNonProxyDesc(unshared);
break;
default:
throw new StreamCorruptedException(
String.format("invalid type code: %02X", tc));
}
if (descriptor != null) {
validateDescriptor(descriptor);
}
return descriptor;
}
private boolean isCustomSubclass() {
@ -1915,6 +1932,8 @@ public class ObjectInputStream
if (obj == null || handles.lookupException(passHandle) != null) {
defaultReadFields(null, slotDesc); // skip field values
} else if (slotDesc.hasReadObjectMethod()) {
ThreadDeath t = null;
boolean reset = false;
SerialCallbackContext oldContext = curContext;
if (oldContext != null)
oldContext.check();
@ -1933,10 +1952,19 @@ public class ObjectInputStream
*/
handles.markException(passHandle, ex);
} finally {
curContext.setUsed();
if (oldContext!= null)
oldContext.check();
curContext = oldContext;
do {
try {
curContext.setUsed();
if (oldContext!= null)
oldContext.check();
curContext = oldContext;
reset = true;
} catch (ThreadDeath x) {
t = x; // defer until reset is true
}
} while (!reset);
if (t != null)
throw t;
}
/*
@ -3647,4 +3675,20 @@ public class ObjectInputStream
}
}
private void validateDescriptor(ObjectStreamClass descriptor) {
ObjectStreamClassValidator validating = validator;
if (validating != null) {
validating.validateDescriptor(descriptor);
}
}
// controlled access to ObjectStreamClassValidator
private volatile ObjectStreamClassValidator validator;
private static void setValidator(ObjectInputStream ois, ObjectStreamClassValidator validator) {
ois.validator = validator;
}
static {
SharedSecrets.setJavaObjectInputStreamAccess(ObjectInputStream::setValidator);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2016, 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
@ -418,10 +418,11 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* read. This method blocks until the requested number of bytes are
* read, the end of the stream is detected, or an exception is thrown.
*
* @param b the buffer into which the data is read.
* @exception EOFException if this file reaches the end before reading
* all the bytes.
* @exception IOException if an I/O error occurs.
* @param b the buffer into which the data is read.
* @throws NullPointerException if {@code b} is {@code null}.
* @throws EOFException if this file reaches the end before reading
* all the bytes.
* @throws IOException if an I/O error occurs.
*/
public final void readFully(byte b[]) throws IOException {
readFully(b, 0, b.length);
@ -434,12 +435,16 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* read. This method blocks until the requested number of bytes are
* read, the end of the stream is detected, or an exception is thrown.
*
* @param b the buffer into which the data is read.
* @param off the start offset of the data.
* @param len the number of bytes to read.
* @exception EOFException if this file reaches the end before reading
* all the bytes.
* @exception IOException if an I/O error occurs.
* @param b the buffer into which the data is read.
* @param off the start offset into the data array {@code b}.
* @param len the number of bytes to read.
* @throws NullPointerException if {@code b} is {@code null}.
* @throws IndexOutOfBoundsException if {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}.
* @throws EOFException if this file reaches the end before reading
* all the bytes.
* @throws IOException if an I/O error occurs.
*/
public final void readFully(byte b[], int off, int len) throws IOException {
int n = 0;

View File

@ -79,13 +79,16 @@ public final class Boolean implements java.io.Serializable,
* Allocates a {@code Boolean} object representing the
* {@code value} argument.
*
* <p><b>Note: It is rarely appropriate to use this constructor.
* Unless a <i>new</i> instance is required, the static factory
* {@link #valueOf(boolean)} is generally a better choice. It is
* likely to yield significantly better space and time performance.</b>
*
* @param value the value of the {@code Boolean}.
*
* @deprecated
* It is rarely appropriate to use this constructor. The static factory
* {@link #valueOf(boolean)} is generally a better choice, as it is
* likely to yield significantly better space and time performance.
* Also consider using the final fields {@link #TRUE} and {@link #FALSE}
* if possible.
*/
@Deprecated(since="9")
public Boolean(boolean value) {
this.value = value;
}
@ -94,15 +97,18 @@ public final class Boolean implements java.io.Serializable,
* Allocates a {@code Boolean} object representing the value
* {@code true} if the string argument is not {@code null}
* and is equal, ignoring case, to the string {@code "true"}.
* Otherwise, allocate a {@code Boolean} object representing the
* value {@code false}. Examples:<p>
* {@code new Boolean("True")} produces a {@code Boolean} object
* that represents {@code true}.<br>
* {@code new Boolean("yes")} produces a {@code Boolean} object
* that represents {@code false}.
* Otherwise, allocates a {@code Boolean} object representing the
* value {@code false}.
*
* @param s the string to be converted to a {@code Boolean}.
*
* @deprecated
* It is rarely appropriate to use this constructor.
* Use {@link #parseBoolean(String)} to convert a string to a
* {@code boolean} primitive, or use {@link #valueOf(String)}
* to convert a string to a {@code Boolean} object.
*/
@Deprecated(since="9")
public Boolean(String s) {
this(parseBoolean(s));
}

View File

@ -297,7 +297,13 @@ public final class Byte extends Number implements Comparable<Byte> {
*
* @param value the value to be represented by the
* {@code Byte}.
*
* @deprecated
* It is rarely appropriate to use this constructor. The static factory
* {@link #valueOf(byte)} is generally a better choice, as it is
* likely to yield significantly better space and time performance.
*/
@Deprecated(since="9")
public Byte(byte value) {
this.value = value;
}
@ -311,10 +317,16 @@ public final class Byte extends Number implements Comparable<Byte> {
*
* @param s the {@code String} to be converted to a
* {@code Byte}
* @throws NumberFormatException If the {@code String}
* @throws NumberFormatException if the {@code String}
* does not contain a parsable {@code byte}.
* @see java.lang.Byte#parseByte(java.lang.String, int)
*
* @deprecated
* It is rarely appropriate to use this constructor.
* Use {@link #parseByte(String)} to convert a string to a
* {@code byte} primitive, or use {@link #valueOf(String)}
* to convert a string to a {@code Byte} object.
*/
@Deprecated(since="9")
public Byte(String s) throws NumberFormatException {
this.value = parseByte(s, 10);
}

View File

@ -1256,14 +1256,14 @@ class Character implements java.io.Serializable, Comparable<Character> {
new UnicodeBlock("SPECIALS");
/**
* @deprecated As of J2SE 5, use {@link #HIGH_SURROGATES},
* {@link #HIGH_PRIVATE_USE_SURROGATES}, and
* {@link #LOW_SURROGATES}. These new constants match
* the block definitions of the Unicode Standard.
* The {@link #of(char)} and {@link #of(int)} methods
* return the new constants, not SURROGATES_AREA.
* @deprecated
* Instead of {@code SURROGATES_AREA}, use {@link #HIGH_SURROGATES},
* {@link #HIGH_PRIVATE_USE_SURROGATES}, and {@link #LOW_SURROGATES}.
* These constants match the block definitions of the Unicode Standard.
* The {@link #of(char)} and {@link #of(int)} methods return the
* standard constants.
*/
@Deprecated
@Deprecated(since="1.5")
public static final UnicodeBlock SURROGATES_AREA =
new UnicodeBlock("SURROGATES_AREA");
@ -7451,7 +7451,13 @@ class Character implements java.io.Serializable, Comparable<Character> {
*
* @param value the value to be represented by the
* {@code Character} object.
*
* @deprecated
* It is rarely appropriate to use this constructor. The static factory
* {@link #valueOf(char)} is generally a better choice, as it is
* likely to yield significantly better space and time performance.
*/
@Deprecated(since="9")
public Character(char value) {
this.value = value;
}
@ -8799,7 +8805,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
* @since 1.0.2
* @deprecated Replaced by isJavaIdentifierStart(char).
*/
@Deprecated
@Deprecated(since="1.1")
public static boolean isJavaLetter(char ch) {
return isJavaIdentifierStart(ch);
}
@ -8835,7 +8841,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
* @since 1.0.2
* @deprecated Replaced by isJavaIdentifierPart(char).
*/
@Deprecated
@Deprecated(since="1.1")
public static boolean isJavaLetterOrDigit(char ch) {
return isJavaIdentifierPart(ch);
}
@ -9580,7 +9586,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
* @see Character#isWhitespace(char)
* @deprecated Replaced by isWhitespace(char).
*/
@Deprecated
@Deprecated(since="1.1")
public static boolean isSpace(char ch) {
return (ch <= 0x0020) &&
(((((1L << 0x0009) |

View File

@ -727,7 +727,7 @@ public abstract class ClassLoader {
* @deprecated Replaced by {@link #defineClass(String, byte[], int, int)
* defineClass(String, byte[], int, int)}
*/
@Deprecated
@Deprecated(since="1.1")
protected final Class<?> defineClass(byte[] b, int off, int len)
throws ClassFormatError
{
@ -817,6 +817,9 @@ public abstract class ClassLoader {
if (!checkName(name))
throw new NoClassDefFoundError("IllegalName: " + name);
// Note: Checking logic in java.lang.invoke.MemberName.checkForTypeAlias
// relies on the fact that spoofing is impossible if a class has a name
// of the form "java.*"
if ((name != null) && name.startsWith("java.")
&& this != getBuiltinPlatformClassLoader()) {
throw new SecurityException
@ -2012,7 +2015,7 @@ public abstract class ClassLoader {
*
* @since 1.2
*/
@Deprecated
@Deprecated(since="9")
protected Package getPackage(String name) {
Package pkg = getDefinedPackage(name);
if (pkg == null) {

View File

@ -589,7 +589,13 @@ public final class Double extends Number implements Comparable<Double> {
* represents the primitive {@code double} argument.
*
* @param value the value to be represented by the {@code Double}.
*
* @deprecated
* It is rarely appropriate to use this constructor. The static factory
* {@link #valueOf(double)} is generally a better choice, as it is
* likely to yield significantly better space and time performance.
*/
@Deprecated(since="9")
public Double(double value) {
this.value = value;
}
@ -601,10 +607,16 @@ public final class Double extends Number implements Comparable<Double> {
* {@code double} value as if by the {@code valueOf} method.
*
* @param s a string to be converted to a {@code Double}.
* @throws NumberFormatException if the string does not contain a
* @throws NumberFormatException if the string does not contain a
* parsable number.
* @see java.lang.Double#valueOf(java.lang.String)
*
* @deprecated
* It is rarely appropriate to use this constructor.
* Use {@link #parseDouble(String)} to convert a string to a
* {@code double} primitive, or use {@link #valueOf(String)}
* to convert a string to a {@code Double} object.
*/
@Deprecated(since="9")
public Double(String s) throws NumberFormatException {
value = parseDouble(s);
}

View File

@ -502,7 +502,13 @@ public final class Float extends Number implements Comparable<Float> {
* represents the primitive {@code float} argument.
*
* @param value the value to be represented by the {@code Float}.
*
* @deprecated
* It is rarely appropriate to use this constructor. The static factory
* {@link #valueOf(float)} is generally a better choice, as it is
* likely to yield significantly better space and time performance.
*/
@Deprecated(since="9")
public Float(float value) {
this.value = value;
}
@ -512,7 +518,13 @@ public final class Float extends Number implements Comparable<Float> {
* represents the argument converted to type {@code float}.
*
* @param value the value to be represented by the {@code Float}.
*
* @deprecated
* It is rarely appropriate to use this constructor. Instead, use the
* static factory method {@link #valueOf(float)} method as follows:
* {@code Float.valueOf((float)value)}.
*/
@Deprecated(since="9")
public Float(double value) {
this.value = (float)value;
}
@ -523,11 +535,17 @@ public final class Float extends Number implements Comparable<Float> {
* represented by the string. The string is converted to a
* {@code float} value as if by the {@code valueOf} method.
*
* @param s a string to be converted to a {@code Float}.
* @throws NumberFormatException if the string does not contain a
* parsable number.
* @see java.lang.Float#valueOf(java.lang.String)
* @param s a string to be converted to a {@code Float}.
* @throws NumberFormatException if the string does not contain a
* parsable number.
*
* @deprecated
* It is rarely appropriate to use this constructor.
* Use {@link #parseFloat(String)} to convert a string to a
* {@code float} primitive, or use {@link #valueOf(String)}
* to convert a string to a {@code Float} object.
*/
@Deprecated(since="9")
public Float(String s) throws NumberFormatException {
value = parseFloat(s);
}

View File

@ -1106,7 +1106,13 @@ public final class Integer extends Number implements Comparable<Integer> {
*
* @param value the value to be represented by the
* {@code Integer} object.
*
* @deprecated
* It is rarely appropriate to use this constructor. The static factory
* {@link #valueOf(int)} is generally a better choice, as it is
* likely to yield significantly better space and time performance.
*/
@Deprecated(since="9")
public Integer(int value) {
this.value = value;
}
@ -1118,12 +1124,17 @@ public final class Integer extends Number implements Comparable<Integer> {
* {@code int} value in exactly the manner used by the
* {@code parseInt} method for radix 10.
*
* @param s the {@code String} to be converted to an
* {@code Integer}.
* @exception NumberFormatException if the {@code String} does not
* contain a parsable integer.
* @see java.lang.Integer#parseInt(java.lang.String, int)
* @param s the {@code String} to be converted to an {@code Integer}.
* @throws NumberFormatException if the {@code String} does not
* contain a parsable integer.
*
* @deprecated
* It is rarely appropriate to use this constructor.
* Use {@link #parseInt(String)} to convert a string to a
* {@code int} primitive, or use {@link #valueOf(String)}
* to convert a string to an {@code Integer} object.
*/
@Deprecated(since="9")
public Integer(String s) throws NumberFormatException {
this.value = parseInt(s, 10);
}

View File

@ -1340,7 +1340,13 @@ public final class Long extends Number implements Comparable<Long> {
*
* @param value the value to be represented by the
* {@code Long} object.
*
* @deprecated
* It is rarely appropriate to use this constructor. The static factory
* {@link #valueOf(long)} is generally a better choice, as it is
* likely to yield significantly better space and time performance.
*/
@Deprecated(since="9")
public Long(long value) {
this.value = value;
}
@ -1356,8 +1362,14 @@ public final class Long extends Number implements Comparable<Long> {
* {@code Long}.
* @throws NumberFormatException if the {@code String} does not
* contain a parsable {@code long}.
* @see java.lang.Long#parseLong(java.lang.String, int)
*
* @deprecated
* It is rarely appropriate to use this constructor.
* Use {@link #parseLong(String)} to convert a string to a
* {@code long} primitive, or use {@link #valueOf(String)}
* to convert a string to a {@code Long} object.
*/
@Deprecated(since="9")
public Long(String s) throws NumberFormatException {
this.value = parseLong(s, 10);
}

View File

@ -333,7 +333,7 @@ public class Package extends NamedPackage implements java.lang.reflect.Annotated
* @see ClassLoader#getDefinedPackage
*/
@CallerSensitive
@Deprecated
@Deprecated(since="9")
@SuppressWarnings("deprecation")
public static Package getPackage(String name) {
ClassLoader l = ClassLoader.getClassLoader(Reflection.getCallerClass());

View File

@ -30,13 +30,12 @@ import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.Pipe;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.action.GetPropertyAction;
/**
* This class is used to create operating system processes.
*
@ -468,11 +467,9 @@ public final class ProcessBuilder
* @since 1.7
*/
public abstract static class Redirect {
private static final File NULL_FILE = AccessController.doPrivileged(
(PrivilegedAction<File>) () -> {
return new File((System.getProperty("os.name")
.startsWith("Windows") ? "NUL" : "/dev/null"));
}
private static final File NULL_FILE = new File(
(GetPropertyAction.getProperty("os.name")
.startsWith("Windows") ? "NUL" : "/dev/null")
);
/**

View File

@ -289,6 +289,7 @@ public class Runtime {
* finalizers being called on live objects while other threads are
* concurrently manipulating those objects, resulting in erratic
* behavior or deadlock.
* This method is subject to removal in a future version of Java SE.
*
* @throws SecurityException
* if a security manager exists and its {@code checkExit}
@ -299,7 +300,7 @@ public class Runtime {
* @see java.lang.SecurityManager#checkExit(int)
* @since 1.1
*/
@Deprecated
@Deprecated(since="1.2", forRemoval=true)
public static void runFinalizersOnExit(boolean value) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
@ -894,8 +895,9 @@ public class Runtime {
* stream in the local encoding into a character stream in Unicode is via
* the {@code InputStreamReader} and {@code BufferedReader}
* classes.
* This method is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="1.1", forRemoval=true)
public InputStream getLocalizedInputStream(InputStream in) {
return in;
}
@ -915,6 +917,7 @@ public class Runtime {
* Unicode character stream into a byte stream in the local encoding is via
* the {@code OutputStreamWriter}, {@code BufferedWriter}, and
* {@code PrintWriter} classes.
* This method is subject to removal in a future version of Java SE.
*
* @param out OutputStream to localize
* @return a localized output stream
@ -923,7 +926,7 @@ public class Runtime {
* @see java.io.OutputStreamWriter#OutputStreamWriter(java.io.OutputStream)
* @see java.io.PrintWriter#PrintWriter(java.io.OutputStream)
*/
@Deprecated
@Deprecated(since="1.1", forRemoval=true)
public OutputStream getLocalizedOutputStream(OutputStream out) {
return out;
}

View File

@ -229,7 +229,7 @@ class SecurityManager {
* It is recommended that the <code>checkPermission</code>
* call be used instead.
*/
@Deprecated
@Deprecated(since="1.2")
protected boolean inCheck;
/*
@ -262,7 +262,7 @@ class SecurityManager {
* It is recommended that the <code>checkPermission</code>
* call be used instead.
*/
@Deprecated
@Deprecated(since="1.2")
public boolean getInCheck() {
return inCheck;
}
@ -345,7 +345,7 @@ class SecurityManager {
* @see java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
@Deprecated(since="1.2")
protected ClassLoader currentClassLoader() {
ClassLoader cl = currentClassLoader0();
if ((cl != null) && hasAllPermission())
@ -391,7 +391,7 @@ class SecurityManager {
* @see java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
@Deprecated(since="1.2")
protected Class<?> currentLoadedClass() {
Class<?> c = currentLoadedClass0();
if ((c != null) && hasAllPermission())
@ -411,7 +411,7 @@ class SecurityManager {
* call be used instead.
*
*/
@Deprecated
@Deprecated(since="1.2")
protected native int classDepth(String name);
/**
@ -449,7 +449,7 @@ class SecurityManager {
* @see java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
@Deprecated(since="1.2")
protected int classLoaderDepth() {
int depth = classLoaderDepth0();
if (depth != -1) {
@ -474,7 +474,7 @@ class SecurityManager {
* It is recommended that the <code>checkPermission</code>
* call be used instead.
*/
@Deprecated
@Deprecated(since="1.2")
protected boolean inClass(String name) {
return classDepth(name) >= 0;
}
@ -491,7 +491,7 @@ class SecurityManager {
* call be used instead.
* @see #currentClassLoader() currentClassLoader
*/
@Deprecated
@Deprecated(since="1.2")
protected boolean inClassLoader() {
return currentClassLoader() != null;
}
@ -1217,7 +1217,7 @@ class SecurityManager {
* @deprecated Use #checkPermission(java.security.Permission) instead
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
@Deprecated(since="1.4")
public void checkMulticast(InetAddress maddr, byte ttl) {
String host = maddr.getHostAddress();
if (!host.startsWith("[") && host.indexOf(':') != -1) {
@ -1297,9 +1297,10 @@ class SecurityManager {
* was trusted to bring up a top-level window. The method has been
* obsoleted and code should instead use {@link #checkPermission}
* to check {@code AWTPermission("showWindowWithoutWarningBanner")}.
* This method is subject to removal in a future version of Java SE.
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
@Deprecated(since="1.8", forRemoval=true)
public boolean checkTopLevelWindow(Object window) {
if (window == null) {
throw new NullPointerException("window can't be null");
@ -1340,9 +1341,10 @@ class SecurityManager {
* thread could access the system clipboard. The method has been
* obsoleted and code should instead use {@link #checkPermission}
* to check {@code AWTPermission("accessClipboard")}.
* This method is subject to removal in a future version of Java SE.
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
@Deprecated(since="1.8", forRemoval=true)
public void checkSystemClipboardAccess() {
checkPermission(SecurityConstants.ALL_PERMISSION);
}
@ -1358,9 +1360,10 @@ class SecurityManager {
* thread could access the AWT event queue. The method has been
* obsoleted and code should instead use {@link #checkPermission}
* to check {@code AWTPermission("accessEventQueue")}.
* This method is subject to removal in a future version of Java SE.
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
@Deprecated(since="1.8", forRemoval=true)
public void checkAwtEventQueueAccess() {
checkPermission(SecurityConstants.ALL_PERMISSION);
}
@ -1626,12 +1629,13 @@ class SecurityManager {
* Users of this method should instead invoke {@link #checkPermission}
* directly. This method will be changed in a future release
* to check the permission {@code java.security.AllPermission}.
* This method is subject to removal in a future version of Java SE.
*
* @see java.lang.reflect.Member
* @since 1.1
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated
@Deprecated(since="1.8", forRemoval=true)
@CallerSensitive
public void checkMemberAccess(Class<?> clazz, int which) {
if (clazz == null) {

View File

@ -302,7 +302,13 @@ public final class Short extends Number implements Comparable<Short> {
*
* @param value the value to be represented by the
* {@code Short}.
*
* @deprecated
* It is rarely appropriate to use this constructor. The static factory
* {@link #valueOf(short)} is generally a better choice, as it is
* likely to yield significantly better space and time performance.
*/
@Deprecated(since="9")
public Short(short value) {
this.value = value;
}
@ -318,8 +324,14 @@ public final class Short extends Number implements Comparable<Short> {
* {@code Short}
* @throws NumberFormatException If the {@code String}
* does not contain a parsable {@code short}.
* @see java.lang.Short#parseShort(java.lang.String, int)
*
* @deprecated
* It is rarely appropriate to use this constructor.
* Use {@link #parseShort(String)} to convert a string to a
* {@code short} primitive, or use {@link #valueOf(String)}
* to convert a string to a {@code Short} object.
*/
@Deprecated(since="9")
public Short(String s) throws NumberFormatException {
this.value = parseShort(s, 10);
}

View File

@ -37,24 +37,14 @@ class StackFrameInfo implements StackFrame {
private final static JavaLangInvokeAccess jlInvokeAccess =
SharedSecrets.getJavaLangInvokeAccess();
// -XX:+MemberNameInStackFrame will initialize MemberName and all other fields;
// otherwise, VM will set the hidden fields (injected by the VM).
// -XX:+MemberNameInStackFrame is temporary to enable performance measurement
//
// Footprint improvement: MemberName::clazz and MemberName::name
// can replace StackFrameInfo::declaringClass and StackFrameInfo::methodName
// Currently VM sets StackFrameInfo::methodName instead of expanding MemberName::name
// Footprint improvement: MemberName::clazz can replace
// StackFrameInfo::declaringClass.
final StackWalker walker;
final Class<?> declaringClass;
final Object memberName;
final int bci;
// methodName, fileName, and lineNumber will be lazily set by the VM
// when first requested.
private String methodName;
private String fileName = null; // default for unavailable filename
private int lineNumber = -1; // default for unavailable lineNumber
final short bci;
private volatile StackTraceElement ste;
/*
* Create StackFrameInfo for StackFrameTraverser and LiveStackFrameTraverser
@ -78,77 +68,53 @@ class StackFrameInfo implements StackFrame {
return declaringClass;
}
// Call the VM to set methodName, lineNumber, and fileName
private synchronized void ensureMethodInfoInitialized() {
if (methodName == null) {
setMethodInfo();
}
}
@Override
public String getMethodName() {
ensureMethodInfoInitialized();
return methodName;
return jlInvokeAccess.getName(memberName);
}
@Override
public Optional<String> getFileName() {
ensureMethodInfoInitialized();
return fileName != null ? Optional.of(fileName) : Optional.empty();
public final Optional<String> getFileName() {
StackTraceElement ste = toStackTraceElement();
return ste.getFileName() != null ? Optional.of(ste.getFileName()) : Optional.empty();
}
@Override
public OptionalInt getLineNumber() {
ensureMethodInfoInitialized();
return lineNumber > 0 ? OptionalInt.of(lineNumber) : OptionalInt.empty();
public final OptionalInt getLineNumber() {
StackTraceElement ste = toStackTraceElement();
return ste.getLineNumber() > 0 ? OptionalInt.of(ste.getLineNumber()) : OptionalInt.empty();
}
@Override
public boolean isNativeMethod() {
ensureMethodInfoInitialized();
return lineNumber == -2;
public final boolean isNativeMethod() {
StackTraceElement ste = toStackTraceElement();
return ste.isNativeMethod();
}
@Override
public String toString() {
ensureMethodInfoInitialized();
// similar format as StackTraceElement::toString
if (isNativeMethod()) {
return getClassName() + "." + getMethodName() + "(Native Method)";
} else {
// avoid allocating Optional objects
return getClassName() + "." + getMethodName() +
"(" + (fileName != null ? fileName : "Unknown Source") +
(lineNumber > 0 ? ":" + lineNumber : " bci:" + bci) + ")";
}
StackTraceElement ste = toStackTraceElement();
return ste.toString();
}
/**
* Lazily initialize method name, file name, line number
* Fill in the fields of the given StackTraceElement
*/
private native void setMethodInfo();
/**
* Fill in source file name and line number of the given StackFrame array.
*/
static native void fillInStackFrames(int startIndex,
Object[] stackframes,
int fromIndex, int toIndex);
private native void toStackTraceElement0(StackTraceElement ste);
@Override
public StackTraceElement toStackTraceElement() {
ensureMethodInfoInitialized();
Module module = declaringClass.getModule();
String moduleName = module.isNamed() ? module.getName() : null;
String moduleVersion = null;
if (module.isNamed() && module.getDescriptor().version().isPresent()) {
moduleVersion = module.getDescriptor().version().get().toString();
StackTraceElement s = ste;
if (s == null) {
synchronized (this) {
s = ste;
if (s == null) {
s = new StackTraceElement();
toStackTraceElement0(s);
ste = s;
}
}
}
return new StackTraceElement(moduleName, moduleVersion,
getClassName(), getMethodName(),
fileName,
lineNumber);
return s;
}
}

View File

@ -363,7 +363,7 @@ public final class String
* @see #String(byte[], java.nio.charset.Charset)
* @see #String(byte[])
*/
@Deprecated
@Deprecated(since="1.1")
public String(byte ascii[], int hibyte, int offset, int count) {
checkBoundsOffCount(offset, count, ascii.length);
if (count == 0) {
@ -415,7 +415,7 @@ public final class String
* @see #String(byte[], java.nio.charset.Charset)
* @see #String(byte[])
*/
@Deprecated
@Deprecated(since="1.1")
public String(byte ascii[], int hibyte) {
this(ascii, hibyte, 0, ascii.length);
}
@ -911,7 +911,7 @@ public final class String
* dst.length}
* </ul>
*/
@Deprecated
@Deprecated(since="1.1")
public void getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin) {
checkBoundsBeginEnd(srcBegin, srcEnd, length());
Objects.requireNonNull(dst);

View File

@ -1715,6 +1715,7 @@ public final class System {
* finalizers being called on live objects while other threads are
* concurrently manipulating those objects, resulting in erratic
* behavior or deadlock.
* This method is subject to removal in a future version of Java SE.
* @param value indicating enabling or disabling of finalization
* @throws SecurityException
* if a security manager exists and its <code>checkExit</code>
@ -1725,7 +1726,7 @@ public final class System {
* @see java.lang.SecurityManager#checkExit(int)
* @since 1.1
*/
@Deprecated
@Deprecated(since="1.2", forRemoval=true)
public static void runFinalizersOnExit(boolean value) {
Runtime.runFinalizersOnExit(value);
}

View File

@ -890,7 +890,7 @@ class Thread implements Runnable {
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
*/
@Deprecated
@Deprecated(since="1.2")
public final void stop() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
@ -922,8 +922,9 @@ class Thread implements Runnable {
* For more information, see
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
* This method is subject to removal in a future version of Java SE.
*/
@Deprecated
@Deprecated(since="1.2", forRemoval=true)
public final synchronized void stop(Throwable obj) {
throw new UnsupportedOperationException();
}
@ -1043,9 +1044,10 @@ class Thread implements Runnable {
* "frozen" processes. For more information, see
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">
* Why are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
* This method is subject to removal in a future version of Java SE.
* @throws NoSuchMethodError always
*/
@Deprecated
@Deprecated(since="1.5", forRemoval=true)
public void destroy() {
throw new NoSuchMethodError();
}
@ -1083,7 +1085,7 @@ class Thread implements Runnable {
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
*/
@Deprecated
@Deprecated(since="1.2")
public final void suspend() {
checkAccess();
suspend0();
@ -1109,7 +1111,7 @@ class Thread implements Runnable {
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
*/
@Deprecated
@Deprecated(since="1.2")
public final void resume() {
checkAccess();
resume0();
@ -1270,8 +1272,10 @@ class Thread implements Runnable {
* @deprecated The definition of this call depends on {@link #suspend},
* which is deprecated. Further, the results of this call
* were never well-defined.
* This method is subject to removal in a future version of Java SE.
* @see StackWalker
*/
@Deprecated
@Deprecated(since="1.2", forRemoval=true)
public native int countStackFrames();
/**
@ -1388,7 +1392,7 @@ class Thread implements Runnable {
* This method is used only for debugging.
*/
public static void dumpStack() {
StackStreamFactory.makeStackTrace().printStackTrace(System.err);
new Exception("Stack trace").printStackTrace();
}
/**
@ -1610,8 +1614,7 @@ class Thread implements Runnable {
}
return stackTrace;
} else {
// Don't need JVM help for current thread
return StackStreamFactory.makeStackTrace().getStackTraceElements();
return (new Exception()).getStackTrace();
}
}

View File

@ -607,7 +607,7 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
* @deprecated This method is inherently unsafe. See
* {@link Thread#stop} for details.
*/
@Deprecated
@Deprecated(since="1.2")
public final void stop() {
if (stopOrSuspend(false))
Thread.currentThread().stop();
@ -669,7 +669,7 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
* @deprecated This method is inherently deadlock-prone. See
* {@link Thread#suspend} for details.
*/
@Deprecated
@Deprecated(since="1.2")
@SuppressWarnings("deprecation")
public final void suspend() {
if (stopOrSuspend(true))
@ -732,7 +732,7 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
* both of which have been deprecated, as they are inherently
* deadlock-prone. See {@link Thread#suspend} for details.
*/
@Deprecated
@Deprecated(since="1.2")
@SuppressWarnings("deprecation")
public final void resume() {
int ngroupsSnapshot;
@ -1073,7 +1073,7 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
* which is deprecated. Further, the behavior of this call
* was never specified.
*/
@Deprecated
@Deprecated(since="1.2")
public boolean allowThreadSuspension(boolean b) {
this.vmAllowSuspension = b;
if (!b) {

View File

@ -785,11 +785,7 @@ public class Throwable implements Serializable {
public synchronized Throwable fillInStackTrace() {
if (stackTrace != null ||
backtrace != null /* Out of protocol state */ ) {
if (backtrace == null && StackStreamFactory.useStackTrace(this)) {
backtrace = StackStreamFactory.makeStackTrace(this);
} else {
fillInStackTrace(0);
}
fillInStackTrace(0);
stackTrace = UNASSIGNED_STACK;
}
return this;
@ -830,15 +826,11 @@ public class Throwable implements Serializable {
// backtrace if this is the first call to this method
if (stackTrace == UNASSIGNED_STACK ||
(stackTrace == null && backtrace != null) /* Out of protocol state */) {
if (backtrace instanceof StackStreamFactory.StackTrace) {
stackTrace = ((StackStreamFactory.StackTrace)backtrace).getStackTraceElements();
} else {
stackTrace = new StackTraceElement[depth];
for (int i = 0; i < depth; i++) {
stackTrace[i] = new StackTraceElement();
}
getStackTraceElements(stackTrace);
stackTrace = new StackTraceElement[depth];
for (int i = 0; i < depth; i++) {
stackTrace[i] = new StackTraceElement();
}
getStackTraceElements(stackTrace);
} else if (stackTrace == null) {
return UNASSIGNED_STACK;
}

View File

@ -88,8 +88,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
static {
final String key = "jdk.internal.lambda.dumpProxyClasses";
String path = AccessController.doPrivileged(
new GetPropertyAction(key));
String path = GetPropertyAction.getProperty(key);
dumper = (null == path) ? null : ProxyClassesDumper.getInstance(path);
}

View File

@ -733,6 +733,7 @@ import java.util.Objects;
}
@Override
@SuppressWarnings("deprecation")
public int hashCode() {
// Avoid autoboxing getReferenceKind(), since this is used early and will force
// early initialization of Byte$ByteCache
@ -826,7 +827,7 @@ import java.util.Objects;
assert(isResolved() == isResolved);
}
void checkForTypeAlias() {
void checkForTypeAlias(Class<?> refc) {
if (isInvocable()) {
MethodType type;
if (this.type instanceof MethodType)
@ -834,16 +835,16 @@ import java.util.Objects;
else
this.type = type = getMethodType();
if (type.erase() == type) return;
if (VerifyAccess.isTypeVisible(type, clazz)) return;
throw new LinkageError("bad method type alias: "+type+" not visible from "+clazz);
if (VerifyAccess.isTypeVisible(type, refc)) return;
throw new LinkageError("bad method type alias: "+type+" not visible from "+refc);
} else {
Class<?> type;
if (this.type instanceof Class<?>)
type = (Class<?>) this.type;
else
this.type = type = getFieldType();
if (VerifyAccess.isTypeVisible(type, clazz)) return;
throw new LinkageError("bad field type alias: "+type+" not visible from "+clazz);
if (VerifyAccess.isTypeVisible(type, refc)) return;
throw new LinkageError("bad field type alias: "+type+" not visible from "+refc);
}
}
@ -1015,10 +1016,25 @@ import java.util.Objects;
MemberName m = ref.clone(); // JVM will side-effect the ref
assert(refKind == m.getReferenceKind());
try {
// There are 4 entities in play here:
// * LC: lookupClass
// * REFC: symbolic reference class (MN.clazz before resolution);
// * DEFC: resolved method holder (MN.clazz after resolution);
// * PTYPES: parameter types (MN.type)
//
// What we care about when resolving a MemberName is consistency between DEFC and PTYPES.
// We do type alias (TA) checks on DEFC to ensure that. DEFC is not known until the JVM
// finishes the resolution, so do TA checks right after MHN.resolve() is over.
//
// All parameters passed by a caller are checked against MH type (PTYPES) on every invocation,
// so it is safe to call a MH from any context.
//
// REFC view on PTYPES doesn't matter, since it is used only as a starting point for resolution and doesn't
// participate in method selection.
m = MethodHandleNatives.resolve(m, lookupClass);
m.checkForTypeAlias();
m.checkForTypeAlias(m.getDeclaringClass());
m.resolution = null;
} catch (LinkageError ex) {
} catch (ClassNotFoundException | LinkageError ex) {
// JVM reports that the "bytecode behavior" would get an error
assert(!m.isResolved());
m.resolution = ex;
@ -1132,6 +1148,10 @@ import java.util.Objects;
public Object newMemberName() {
return new MemberName();
}
public String getName(Object mname) {
MemberName memberName = (MemberName)mname;
return memberName.getName();
}
});
}
}

View File

@ -49,7 +49,7 @@ class MethodHandleNatives {
static native void init(MemberName self, Object ref);
static native void expand(MemberName self);
static native MemberName resolve(MemberName self, Class<?> caller) throws LinkageError;
static native MemberName resolve(MemberName self, Class<?> caller) throws LinkageError, ClassNotFoundException;
static native int getMembers(Class<?> defc, String matchName, String matchSig,
int matchFlags, Class<?> caller, int skip, MemberName[] results);

View File

@ -25,9 +25,9 @@
package java.lang.invoke;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Properties;
import jdk.internal.misc.Unsafe;
import sun.security.action.GetPropertyAction;
/**
* This class consists exclusively of static names internal to the
@ -53,32 +53,27 @@ import jdk.internal.misc.Unsafe;
static final boolean VAR_HANDLE_GUARDS;
static {
final Object[] values = new Object[10];
AccessController.doPrivileged(new PrivilegedAction<>() {
public Void run() {
values[0] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES");
values[1] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES");
values[2] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_INTERPRETER");
values[3] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE");
values[4] = Integer.getInteger("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", 0);
values[5] = Integer.getInteger("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", 30);
values[6] = Integer.getInteger("java.lang.invoke.MethodHandle.PROFILE_LEVEL", 0);
values[7] = Boolean.parseBoolean(System.getProperty("java.lang.invoke.MethodHandle.PROFILE_GWT", "true"));
values[8] = Integer.getInteger("java.lang.invoke.MethodHandle.CUSTOMIZE_THRESHOLD", 127);
values[9] = Boolean.parseBoolean(System.getProperty("java.lang.invoke.VarHandle.VAR_HANDLE_GUARDS", "true"));
return null;
}
});
DEBUG_METHOD_HANDLE_NAMES = (Boolean) values[0];
DUMP_CLASS_FILES = (Boolean) values[1];
TRACE_INTERPRETER = (Boolean) values[2];
TRACE_METHOD_LINKAGE = (Boolean) values[3];
COMPILE_THRESHOLD = (Integer) values[4];
DONT_INLINE_THRESHOLD = (Integer) values[5];
PROFILE_LEVEL = (Integer) values[6];
PROFILE_GWT = (Boolean) values[7];
CUSTOMIZE_THRESHOLD = (Integer) values[8];
VAR_HANDLE_GUARDS = (Boolean) values[9];
Properties props = GetPropertyAction.getProperties();
DEBUG_METHOD_HANDLE_NAMES = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.MethodHandle.DEBUG_NAMES"));
DUMP_CLASS_FILES = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES"));
TRACE_INTERPRETER = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.MethodHandle.TRACE_INTERPRETER"));
TRACE_METHOD_LINKAGE = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE"));
COMPILE_THRESHOLD = Integer.parseInt(
props.getProperty("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", "0"));
DONT_INLINE_THRESHOLD = Integer.parseInt(
props.getProperty("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", "30"));
PROFILE_LEVEL = Integer.parseInt(
props.getProperty("java.lang.invoke.MethodHandle.PROFILE_LEVEL", "0"));
PROFILE_GWT = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.MethodHandle.PROFILE_GWT", "true"));
CUSTOMIZE_THRESHOLD = Integer.parseInt(
props.getProperty("java.lang.invoke.MethodHandle.CUSTOMIZE_THRESHOLD", "127"));
VAR_HANDLE_GUARDS = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.VarHandle.VAR_HANDLE_GUARDS", "true"));
if (CUSTOMIZE_THRESHOLD < -1 || CUSTOMIZE_THRESHOLD > 127) {
throw newInternalError("CUSTOMIZE_THRESHOLD should be in [-1...127] range");

View File

@ -28,6 +28,7 @@ package java.lang.invoke;
import java.lang.reflect.*;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Iterator;
import java.util.List;
import java.util.Arrays;
import java.util.Objects;
@ -53,6 +54,7 @@ import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Opcodes;
import static java.lang.invoke.MethodHandleStatics.newIllegalArgumentException;
import static java.lang.invoke.MethodType.methodType;
/**
* This class consists exclusively of static methods that operate on or return
@ -3000,7 +3002,7 @@ assert((int)twice.invokeExact(21) == 42);
private static final MethodHandle[] IDENTITY_MHS = new MethodHandle[Wrapper.values().length];
private static MethodHandle makeIdentity(Class<?> ptype) {
MethodType mtype = MethodType.methodType(ptype, ptype);
MethodType mtype = methodType(ptype, ptype);
LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.IDENTITY);
}
@ -3018,7 +3020,7 @@ assert((int)twice.invokeExact(21) == 42);
}
private static final MethodHandle[] ZERO_MHS = new MethodHandle[Wrapper.values().length];
private static MethodHandle makeZero(Class<?> rtype) {
MethodType mtype = MethodType.methodType(rtype);
MethodType mtype = methodType(rtype);
LambdaForm lform = LambdaForm.zeroForm(BasicType.basicType(rtype));
return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.ZERO);
}
@ -3929,7 +3931,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
MethodHandle throwException(Class<?> returnType, Class<? extends Throwable> exType) {
if (!Throwable.class.isAssignableFrom(exType))
throw new ClassCastException(exType.getName());
return MethodHandleImpl.throwException(MethodType.methodType(returnType, exType));
return MethodHandleImpl.throwException(methodType(returnType, exType));
}
/**
@ -4166,7 +4168,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
for (int i = 0; i < nclauses; ++i) {
Class<?> t = iterationVariableTypes.get(i);
if (init.get(i) == null) {
init.set(i, empty(MethodType.methodType(t, commonSuffix)));
init.set(i, empty(methodType(t, commonSuffix)));
}
if (step.get(i) == null) {
step.set(i, dropArgumentsToMatch(identityOrVoid(t), 0, commonParameterSequence, i));
@ -4175,7 +4177,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
pred.set(i, dropArguments(constant(boolean.class, true), 0, commonParameterSequence));
}
if (fini.get(i) == null) {
fini.set(i, empty(MethodType.methodType(t, commonParameterSequence)));
fini.set(i, empty(methodType(t, commonParameterSequence)));
}
}
@ -4269,7 +4271,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* @since 9
*/
public static MethodHandle whileLoop(MethodHandle init, MethodHandle pred, MethodHandle body) {
MethodHandle fin = init == null ? zero(void.class) : identity(init.type().returnType());
MethodHandle fin = init == null || init.type().returnType() == void.class ? zero(void.class) :
identity(init.type().returnType());
MethodHandle[] checkExit = {null, null, pred, fin};
MethodHandle[] varBody = {init, body};
return loop(checkExit, varBody);
@ -4335,7 +4338,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* @since 9
*/
public static MethodHandle doWhileLoop(MethodHandle init, MethodHandle body, MethodHandle pred) {
MethodHandle fin = init == null ? zero(void.class) : identity(init.type().returnType());
MethodHandle fin = init == null || init.type().returnType() == void.class ? zero(void.class) :
identity(init.type().returnType());
MethodHandle[] clause = {init, body, pred, fin};
return loop(clause);
}
@ -4472,8 +4476,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* @since 9
*/
public static MethodHandle countedLoop(MethodHandle start, MethodHandle end, MethodHandle init, MethodHandle body) {
MethodHandle returnVar = dropArguments(init == null ? zero(void.class) : identity(init.type().returnType()),
0, int.class, int.class);
MethodHandle returnVar = dropArguments(init == null || init.type().returnType() == void.class ?
zero(void.class) : identity(init.type().returnType()), 0, int.class, int.class);
MethodHandle[] indexVar = {start, MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopStep)};
MethodHandle[] loopLimit = {end, null, MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_countedLoopPred), returnVar};
MethodHandle[] bodyClause = {init,
@ -4485,6 +4489,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
/**
* Constructs a loop that ranges over the elements produced by an {@code Iterator<T>}.
* The iterator will be produced by the evaluation of the {@code iterator} handle.
* This handle must have {@link java.util.Iterator} as its return type.
* If this handle is passed as {@code null} the method {@link Iterable#iterator} will be used instead,
* and will be applied to a leading argument of the loop handle.
* Each value produced by the iterator is passed to the {@code body}, which must accept an initial {@code T} parameter.
@ -4534,7 +4539,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* assertEquals(reversedList, (List<String>) loop.invoke(list));
* }</pre></blockquote>
* <p>
* @implSpec The implementation of this method is equivalent to:
* @implSpec The implementation of this method is equivalent to (excluding error handling):
* <blockquote><pre>{@code
* MethodHandle iteratedLoop(MethodHandle iterator, MethodHandle init, MethodHandle body) {
* // assume MH_next and MH_hasNext are handles to methods of Iterator
@ -4550,6 +4555,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* }</pre></blockquote>
*
* @param iterator a handle to return the iterator to start the loop.
* The handle must have {@link java.util.Iterator} as its return type.
* Passing {@code null} will make the loop call {@link Iterable#iterator()} on the first
* incoming value.
* @param init initializer for additional loop state. This determines the loop's result type.
@ -4565,21 +4571,23 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* @since 9
*/
public static MethodHandle iteratedLoop(MethodHandle iterator, MethodHandle init, MethodHandle body) {
checkIteratedLoop(body);
checkIteratedLoop(iterator, body);
final boolean voidInit = init == null || init.type().returnType() == void.class;
MethodHandle initit = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_initIterator);
MethodHandle initIterator = iterator == null ?
initit.asType(initit.type().changeParameterType(0, body.type().parameterType(init == null ? 1 : 2))) :
initit.asType(initit.type().changeParameterType(0, body.type().parameterType(voidInit ? 1 : 2))) :
iterator;
Class<?> itype = initIterator.type().returnType();
Class<?> ttype = body.type().parameterType(0);
MethodHandle returnVar =
dropArguments(init == null ? zero(void.class) : identity(init.type().returnType()), 0, itype);
dropArguments(voidInit ? zero(void.class) : identity(init.type().returnType()), 0, itype);
MethodHandle initnx = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_iterateNext);
MethodHandle nextVal = initnx.asType(initnx.type().changeReturnType(ttype));
MethodHandle[] iterVar = {initIterator, null, MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_iteratePred), returnVar};
MethodHandle[] iterVar = {initIterator, null, MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_iteratePred),
returnVar};
MethodHandle[] bodyClause = {init, filterArgument(body, 0, nextVal)};
return loop(iterVar, bodyClause);
@ -4833,7 +4841,10 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
}
}
private static void checkIteratedLoop(MethodHandle body) {
private static void checkIteratedLoop(MethodHandle iterator, MethodHandle body) {
if (null != iterator && !Iterator.class.isAssignableFrom(iterator.type().returnType())) {
throw newIllegalArgumentException("iteratedLoop first argument must have Iterator return type");
}
if (null == body) {
throw newIllegalArgumentException("iterated loop body must not be null");
}

View File

@ -33,7 +33,6 @@ import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.misc.Unsafe;
import java.lang.invoke.MethodHandles.Lookup;
import java.security.AccessController;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@ -188,14 +187,15 @@ public final class StringConcatFactory {
private static final ProxyClassesDumper DUMPER;
static {
final String strategy = AccessController.doPrivileged(
new GetPropertyAction("java.lang.invoke.stringConcat"));
CACHE_ENABLE = Boolean.parseBoolean(AccessController.doPrivileged(
new GetPropertyAction("java.lang.invoke.stringConcat.cache")));
DEBUG = Boolean.parseBoolean(AccessController.doPrivileged(
new GetPropertyAction("java.lang.invoke.stringConcat.debug")));
final String dumpPath = AccessController.doPrivileged(
new GetPropertyAction("java.lang.invoke.stringConcat.dumpClasses"));
Properties props = GetPropertyAction.getProperties();
final String strategy =
props.getProperty("java.lang.invoke.stringConcat");
CACHE_ENABLE = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.stringConcat.cache"));
DEBUG = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.stringConcat.debug"));
final String dumpPath =
props.getProperty("java.lang.invoke.stringConcat.dumpClasses");
STRATEGY = (strategy == null) ? DEFAULT_STRATEGY : Strategy.valueOf(strategy);
CACHE = CACHE_ENABLE ? new ConcurrentHashMap<>() : null;

View File

@ -39,6 +39,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import sun.security.action.GetPropertyAction;
/**
* A finder of modules. A {@code ModuleFinder} is used to find modules during
@ -152,7 +153,7 @@ public interface ModuleFinder {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
PrivilegedAction<String> pa = () -> System.getProperty("java.home");
PrivilegedAction<String> pa = new GetPropertyAction("java.home");
home = AccessController.doPrivileged(pa);
Permission p = new FilePermission(home + File.separator + "-", "read");
sm.checkPermission(p);

View File

@ -50,6 +50,7 @@ import jdk.internal.misc.VM;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;
import sun.security.action.GetPropertyAction;
import sun.security.util.SecurityConstants;
/**
@ -581,11 +582,7 @@ public class Proxy implements java.io.Serializable {
}
private static final String DEBUG =
AccessController.doPrivileged(new PrivilegedAction<>() {
public String run() {
return System.getProperty("jdk.proxy.debug", "");
}
});
GetPropertyAction.getProperty("jdk.proxy.debug", "");
private static boolean isDebug() {
return !DEBUG.isEmpty();

View File

@ -1750,7 +1750,7 @@ class ProxyGenerator {
* Get or assign the index for a CONSTANT_Float entry.
*/
public short getFloat(float f) {
return getValue(new Float(f));
return getValue(f);
}
/**

View File

@ -31,6 +31,7 @@ import sun.net.ResourceManager;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
import sun.security.action.GetPropertyAction;
/**
* Abstract datagram and multicast socket implementation base class.
@ -51,9 +52,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
protected InetAddress connectedAddress = null;
private int connectedPort = -1;
private static final String os = AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("os.name")
);
private static final String os = GetPropertyAction.getProperty("os.name");
/**
* flag set if the native connect() call not to be used

View File

@ -1123,8 +1123,8 @@ class InetAddress implements java.io.Serializable {
*/
private static NameService createNameService() {
String hostsFileName = AccessController
.doPrivileged(new GetPropertyAction("jdk.net.hosts.file"));
String hostsFileName =
GetPropertyAction.getProperty("jdk.net.hosts.file");
NameService theNameService;
if (hostsFileName != null) {
theNameService = new HostsFileNameService(hostsFileName);
@ -1643,8 +1643,7 @@ class InetAddress implements java.io.Serializable {
* property can vary across implementations of the java.
* classes. The default is an empty String "".
*/
String prefix = AccessController.doPrivileged(
new GetPropertyAction("impl.prefix", ""));
String prefix = GetPropertyAction.getProperty("impl.prefix", "");
try {
impl = Class.forName("java.net." + prefix + implName).newInstance();
} catch (ClassNotFoundException e) {

View File

@ -33,6 +33,7 @@ import java.security.PrivilegedExceptionAction;
import sun.net.SocksProxy;
import sun.net.spi.DefaultProxySelector;
import sun.net.www.ParseUtil;
import sun.security.action.GetPropertyAction;
/* import org.ietf.jgss.*; */
/**
@ -177,8 +178,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
userName = pw.getUserName();
password = new String(pw.getPassword());
} else {
userName = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("user.name"));
userName = GetPropertyAction.getProperty("user.name");
}
if (userName == null)
return false;
@ -1088,8 +1088,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
userName = System.getProperty("user.name");
} catch (SecurityException se) { /* swallow Exception */ }
} else {
userName = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("user.name"));
userName = GetPropertyAction.getProperty("user.name");
}
return userName;
}

View File

@ -42,6 +42,7 @@ import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import sun.security.util.SecurityConstants;
import sun.security.action.GetPropertyAction;
/**
* Class {@code URL} represents a Uniform Resource
@ -1210,12 +1211,8 @@ public final class URL implements java.io.Serializable {
}
private static URLStreamHandler lookupViaProperty(String protocol) {
String packagePrefixList = java.security.AccessController.doPrivileged(
new PrivilegedAction<>() {
public String run() {
return System.getProperty(protocolPathProp, null);
}
});
String packagePrefixList =
GetPropertyAction.getProperty(protocolPathProp);
if (packagePrefixList == null) {
// not set
return null;

View File

@ -43,6 +43,7 @@ import java.security.Permission;
import java.security.AccessController;
import sun.security.util.SecurityConstants;
import sun.net.www.MessageHeader;
import sun.security.action.GetPropertyAction;
/**
* The abstract class {@code URLConnection} is the superclass
@ -1395,8 +1396,8 @@ public abstract class URLConnection {
* is always the last one on the returned package list.
*/
private String getContentHandlerPkgPrefixes() {
String packagePrefixList = AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(contentPathProp, ""));
String packagePrefixList =
GetPropertyAction.getProperty(contentPathProp, "");
if (packagePrefixList != "") {
packagePrefixList += "|";

View File

@ -25,19 +25,12 @@
package java.net;
import java.io.ByteArrayOutputStream;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.CharArrayWriter;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException ;
import java.util.BitSet;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.action.GetBooleanAction;
import sun.security.action.GetPropertyAction;
/**
@ -140,9 +133,7 @@ public class URLEncoder {
dontNeedEncoding.set('.');
dontNeedEncoding.set('*');
dfltEncName = AccessController.doPrivileged(
new GetPropertyAction("file.encoding")
);
dfltEncName = GetPropertyAction.getProperty("file.encoding");
}
/**

View File

@ -170,7 +170,8 @@ public final class URLPermission extends Permission {
parseURI(getName());
int colon = actions.indexOf(':');
if (actions.lastIndexOf(':') != colon) {
throw new IllegalArgumentException("invalid actions string");
throw new IllegalArgumentException(
"Invalid actions string: \"" + actions + "\"");
}
String methods, headers;
@ -371,7 +372,8 @@ public final class URLPermission extends Permission {
l.add(s);
b = new StringBuilder();
} else if (c == ' ' || c == '\t') {
throw new IllegalArgumentException("white space not allowed");
throw new IllegalArgumentException(
"White space not allowed in methods: \"" + methods + "\"");
} else {
if (c >= 'a' && c <= 'z') {
c += 'A' - 'a';
@ -398,7 +400,8 @@ public final class URLPermission extends Permission {
}
b.append(c);
} else if (c == ' ' || c == '\t') {
throw new IllegalArgumentException("white space not allowed");
throw new IllegalArgumentException(
"White space not allowed in headers: \"" + headers + "\"");
} else if (c == '-') {
capitalizeNext = true;
b.append(c);
@ -423,14 +426,16 @@ public final class URLPermission extends Permission {
int len = url.length();
int delim = url.indexOf(':');
if (delim == -1 || delim + 1 == len) {
throw new IllegalArgumentException("invalid URL string");
throw new IllegalArgumentException(
"Invalid URL string: \"" + url + "\"");
}
scheme = url.substring(0, delim).toLowerCase();
this.ssp = url.substring(delim + 1);
if (!ssp.startsWith("//")) {
if (!ssp.equals("*")) {
throw new IllegalArgumentException("invalid URL string");
throw new IllegalArgumentException(
"Invalid URL string: \"" + url + "\"");
}
this.authority = new Authority(scheme, "*");
return;

View File

@ -283,8 +283,8 @@ public abstract class Charset
if (level == null) {
if (!VM.isBooted())
return false;
bugLevel = level = AccessController.doPrivileged(
new GetPropertyAction("sun.nio.cs.bugLevel", ""));
bugLevel = level =
GetPropertyAction.getProperty("sun.nio.cs.bugLevel", "");
}
return level.equals(bl);
}
@ -609,8 +609,7 @@ public abstract class Charset
public static Charset defaultCharset() {
if (defaultCharset == null) {
synchronized (Charset.class) {
String csn = AccessController.doPrivileged(
new GetPropertyAction("file.encoding"));
String csn = GetPropertyAction.getProperty("file.encoding");
Charset cs = lookup(csn);
if (cs != null)
defaultCharset = cs;

View File

@ -28,7 +28,6 @@ package java.nio.file;
import java.util.Set;
import java.util.EnumSet;
import java.security.SecureRandom;
import static java.security.AccessController.*;
import java.io.IOException;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
@ -47,7 +46,7 @@ class TempFileHelper {
// temporary directory location
private static final Path tmpdir =
Paths.get(doPrivileged(new GetPropertyAction("java.io.tmpdir")));
Paths.get(GetPropertyAction.getProperty("java.io.tmpdir"));
private static final boolean isPosix =
FileSystems.getDefault().supportedFileAttributeViews().contains("posix");

View File

@ -437,7 +437,7 @@ public class ChoiceFormat extends NumberFormat {
if (status.index == start) {
status.errorIndex = furthest;
}
return new Double(bestNumber);
return Double.valueOf(bestNumber);
}
/**

View File

@ -1996,7 +1996,7 @@ public class DecimalFormat extends NumberFormat {
// special case NaN
if (text.regionMatches(pos.index, symbols.getNaN(), 0, symbols.getNaN().length())) {
pos.index = pos.index + symbols.getNaN().length();
return new Double(Double.NaN);
return Double.valueOf(Double.NaN);
}
boolean[] status = new boolean[STATUS_LENGTH];
@ -2007,19 +2007,19 @@ public class DecimalFormat extends NumberFormat {
// special case INFINITY
if (status[STATUS_INFINITE]) {
if (status[STATUS_POSITIVE] == (multiplier >= 0)) {
return new Double(Double.POSITIVE_INFINITY);
return Double.valueOf(Double.POSITIVE_INFINITY);
} else {
return new Double(Double.NEGATIVE_INFINITY);
return Double.valueOf(Double.NEGATIVE_INFINITY);
}
}
if (multiplier == 0) {
if (digitList.isZero()) {
return new Double(Double.NaN);
return Double.valueOf(Double.NaN);
} else if (status[STATUS_POSITIVE]) {
return new Double(Double.POSITIVE_INFINITY);
return Double.valueOf(Double.POSITIVE_INFINITY);
} else {
return new Double(Double.NEGATIVE_INFINITY);
return Double.valueOf(Double.NEGATIVE_INFINITY);
}
}
@ -2093,8 +2093,8 @@ public class DecimalFormat extends NumberFormat {
!isParseIntegerOnly();
}
return gotDouble ?
(Number)new Double(doubleResult) : (Number)Long.valueOf(longResult);
// cast inside of ?: because of binary numeric promotion, JLS 15.25
return gotDouble ? (Number)doubleResult : (Number)longResult;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2016, 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
@ -1539,8 +1539,8 @@ public final class DateTimeFormatterBuilder {
* <pre>
* Pattern Count Equivalent builder methods
* ------- ----- --------------------------
* O 1 appendLocalizedOffsetPrefixed(TextStyle.SHORT);
* OOOO 4 appendLocalizedOffsetPrefixed(TextStyle.FULL);
* O 1 appendLocalizedOffset(TextStyle.SHORT);
* OOOO 4 appendLocalizedOffset(TextStyle.FULL);
* X 1 appendOffset("+HHmm","Z")
* XX 2 appendOffset("+HHMM","Z")
* XXX 3 appendOffset("+HH:MM","Z")
@ -3519,9 +3519,7 @@ public final class DateTimeFormatterBuilder {
return false;
}
String gmtText = "GMT"; // TODO: get localized version of 'GMT'
if (gmtText != null) {
buf.append(gmtText);
}
buf.append(gmtText);
int totalSecs = Math.toIntExact(offsetSecs);
if (totalSecs != 0) {
int absHours = Math.abs((totalSecs / 3600) % 100); // anything larger than 99 silently dropped
@ -3565,14 +3563,12 @@ public final class DateTimeFormatterBuilder {
@Override
public int parse(DateTimeParseContext context, CharSequence text, int position) {
int pos = position;
int end = pos + text.length();
int end = text.length();
String gmtText = "GMT"; // TODO: get localized version of 'GMT'
if (gmtText != null) {
if (!context.subSequenceEquals(text, pos, gmtText, 0, gmtText.length())) {
if (!context.subSequenceEquals(text, pos, gmtText, 0, gmtText.length())) {
return ~position;
}
pos += gmtText.length();
}
pos += gmtText.length();
// parse normal plus/minus offset
int negative = 0;
if (pos == end) {

View File

@ -45,7 +45,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectStreamField;
import java.io.Serializable;
import java.security.AccessController;
import java.text.MessageFormat;
import java.util.spi.LocaleNameProvider;
@ -859,11 +858,10 @@ public final class Locale implements Cloneable, Serializable {
private static Locale initDefault() {
String language, region, script, country, variant;
language = AccessController.doPrivileged(
new GetPropertyAction("user.language", "en"));
Properties props = GetPropertyAction.getProperties();
language = props.getProperty("user.language", "en");
// for compatibility, check for old user.region property
region = AccessController.doPrivileged(
new GetPropertyAction("user.region"));
region = props.getProperty("user.region");
if (region != null) {
// region can be of form country, country_variant, or _variant
int i = region.indexOf('_');
@ -876,27 +874,25 @@ public final class Locale implements Cloneable, Serializable {
}
script = "";
} else {
script = AccessController.doPrivileged(
new GetPropertyAction("user.script", ""));
country = AccessController.doPrivileged(
new GetPropertyAction("user.country", ""));
variant = AccessController.doPrivileged(
new GetPropertyAction("user.variant", ""));
script = props.getProperty("user.script", "");
country = props.getProperty("user.country", "");
variant = props.getProperty("user.variant", "");
}
return getInstance(language, script, country, variant, null);
}
private static Locale initDefault(Locale.Category category) {
Properties props = GetPropertyAction.getProperties();
return getInstance(
AccessController.doPrivileged(
new GetPropertyAction(category.languageKey, defaultLocale.getLanguage())),
AccessController.doPrivileged(
new GetPropertyAction(category.scriptKey, defaultLocale.getScript())),
AccessController.doPrivileged(
new GetPropertyAction(category.countryKey, defaultLocale.getCountry())),
AccessController.doPrivileged(
new GetPropertyAction(category.variantKey, defaultLocale.getVariant())),
props.getProperty(category.languageKey,
defaultLocale.getLanguage()),
props.getProperty(category.scriptKey,
defaultLocale.getScript()),
props.getProperty(category.countryKey,
defaultLocale.getCountry()),
props.getProperty(category.variantKey,
defaultLocale.getVariant()),
null);
}

View File

@ -43,7 +43,6 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.MalformedInputException;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnmappableCharacterException;
@ -142,8 +141,8 @@ public class PropertyResourceBundle extends ResourceBundle {
// Check whether the strict encoding is specified.
// The possible encoding is either "ISO-8859-1" or "UTF-8".
private static final String encoding =
AccessController.doPrivileged(
new GetPropertyAction("java.util.PropertyResourceBundle.encoding", ""))
GetPropertyAction
.getProperty("java.util.PropertyResourceBundle.encoding", "")
.toUpperCase(Locale.ROOT);
/**

View File

@ -660,14 +660,12 @@ public abstract class TimeZone implements Serializable, Cloneable {
private static synchronized TimeZone setDefaultZone() {
TimeZone tz;
// get the time zone ID from the system properties
String zoneID = AccessController.doPrivileged(
new GetPropertyAction("user.timezone"));
String zoneID = GetPropertyAction.getProperty("user.timezone");
// if the time zone ID is not set (yet), perform the
// platform to Java time zone ID mapping.
if (zoneID == null || zoneID.isEmpty()) {
String javaHome = AccessController.doPrivileged(
new GetPropertyAction("java.home"));
String javaHome = GetPropertyAction.getProperty("java.home");
try {
zoneID = getSystemTimeZoneID(javaHome);
if (zoneID == null) {

View File

@ -455,7 +455,7 @@ public class ThreadLocalRandom extends Random {
s = v1 * v1 + v2 * v2;
} while (s >= 1 || s == 0);
double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s)/s);
nextLocalGaussian.set(new Double(v2 * multiplier));
nextLocalGaussian.set(Double.valueOf(v2 * multiplier));
return v1 * multiplier;
}

View File

@ -34,7 +34,6 @@ import java.util.stream.StreamSupport;
import java.util.zip.*;
import java.security.CodeSigner;
import java.security.cert.Certificate;
import java.security.AccessController;
import java.security.CodeSource;
import jdk.internal.misc.SharedSecrets;
import sun.security.action.GetPropertyAction;
@ -155,16 +154,16 @@ class JarFile extends ZipFile {
BASE_VERSION = 8; // one less than lowest version for versioned entries
int runtimeVersion = jdk.Version.current().major();
String jarVersion = AccessController.doPrivileged(
new GetPropertyAction("jdk.util.jar.version"));
String jarVersion =
GetPropertyAction.getProperty("jdk.util.jar.version");
if (jarVersion != null) {
int jarVer = Integer.parseInt(jarVersion);
runtimeVersion = (jarVer > runtimeVersion)
? runtimeVersion : Math.max(jarVer, 0);
}
RUNTIME_VERSION = runtimeVersion;
String enableMultiRelease = AccessController.doPrivileged(
new GetPropertyAction("jdk.util.jar.enableMultiRelease", "true"));
String enableMultiRelease = GetPropertyAction
.getProperty("jdk.util.jar.enableMultiRelease", "true");
switch (enableMultiRelease) {
case "true":
default:

View File

@ -29,6 +29,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.File;
import java.io.IOException;
import sun.security.action.GetPropertyAction;
/**
@ -694,8 +695,7 @@ public abstract class Pack200 {
Class<?> impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl;
if (impl == null) {
// The first time, we must decide which class to use.
implName = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(prop,""));
implName = GetPropertyAction.getProperty(prop,"");
if (implName != null && !implName.equals(""))
impl = Class.forName(implName);
else if (PACK_PROVIDER.equals(prop))

View File

@ -94,8 +94,7 @@ public class PatternSyntaxException
}
private static final String nl =
java.security.AccessController
.doPrivileged(new GetPropertyAction("line.separator"));
GetPropertyAction.getProperty("line.separator");
/**
* Returns a multi-line string containing the description of the syntax

View File

@ -33,6 +33,7 @@ import java.util.Vector;
import java.util.HashSet;
import static java.util.zip.ZipConstants64.*;
import static java.util.zip.ZipUtils.*;
import sun.security.action.GetPropertyAction;
/**
* This class implements an output stream filter for writing files in the
@ -54,9 +55,7 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
*/
private static final boolean inhibitZip64 =
Boolean.parseBoolean(
java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(
"jdk.util.zip.inhibitZip64", "false")));
GetPropertyAction.getProperty("jdk.util.zip.inhibitZip64"));
private static class XEntry {
final ZipEntry entry;

View File

@ -51,9 +51,9 @@ public abstract class SSLSocketFactory extends SocketFactory
static final boolean DEBUG;
static {
String s = java.security.AccessController.doPrivileged(
new GetPropertyAction("javax.net.debug", "")).toLowerCase(
Locale.ENGLISH);
String s = GetPropertyAction.getProperty("javax.net.debug", "")
.toLowerCase(Locale.ENGLISH);
DEBUG = s.contains("all") || s.contains("ssl");
}

View File

@ -26,8 +26,6 @@
package jdk;
import java.math.BigInteger;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -35,6 +33,7 @@ import java.util.stream.Collectors;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import sun.security.action.GetPropertyAction;
/**
* A representation of the JDK version-string which contains a version
@ -274,12 +273,7 @@ public final class Version
*/
public static Version current() {
if (current == null) {
current = parse(AccessController.doPrivileged(
new PrivilegedAction<>() {
public String run() {
return System.getProperty("java.version");
}
}));
current = parse(GetPropertyAction.getProperty("java.version"));
}
return current;
}

View File

@ -101,10 +101,10 @@ public final class JrtFileSystemProvider extends FileSystemProvider {
@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env)
throws IOException {
Objects.requireNonNull(env);
checkPermission();
checkUri(uri);
if (env != null && env.containsKey("java.home")) {
if (env.containsKey("java.home")) {
return newFileSystem((String)env.get("java.home"), uri, env);
} else {
return new JrtFileSystem(this, env);

View File

@ -52,6 +52,7 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
@ -69,6 +70,7 @@ import jdk.internal.util.jar.InvalidJarIndexError;
import jdk.internal.util.jar.JarIndex;
import sun.net.util.URLUtil;
import sun.net.www.ParseUtil;
import sun.security.action.GetPropertyAction;
/**
* This class is used to maintain a search path of URLs for loading classes
@ -78,20 +80,15 @@ import sun.net.www.ParseUtil;
*/
public class URLClassPath {
private static final String USER_AGENT_JAVA_VERSION = "UA-Java-Version";
private static final String JAVA_HOME;
private static final String JAVA_VERSION;
private static final boolean DEBUG;
private static final boolean DISABLE_JAR_CHECKING;
static {
JAVA_HOME = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("java.home"));
JAVA_VERSION = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("java.version"));
DEBUG = (java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.debug")) != null);
String p = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.disableJarChecking"));
Properties props = GetPropertyAction.getProperties();
JAVA_VERSION = props.getProperty("java.version");
DEBUG = (props.getProperty("sun.misc.URLClassPath.debug") != null);
String p = props.getProperty("sun.misc.URLClassPath.disableJarChecking");
DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
}

View File

@ -33,6 +33,7 @@ import java.util.Locale;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import sun.security.util.SecurityConstants;
import sun.security.action.GetPropertyAction;
/**
* Helper class used to load the {@link java.lang.System.LoggerFinder}.
@ -79,9 +80,8 @@ public final class LoggerFinderLoader {
// Get configuration error policy
private static ErrorPolicy configurationErrorPolicy() {
final PrivilegedAction<String> getConfigurationErrorPolicy =
() -> System.getProperty("jdk.logger.finder.error");
String errorPolicy = AccessController.doPrivileged(getConfigurationErrorPolicy);
String errorPolicy =
GetPropertyAction.getProperty("jdk.logger.finder.error");
if (errorPolicy == null || errorPolicy.isEmpty()) {
return ErrorPolicy.WARNING;
}
@ -95,9 +95,8 @@ public final class LoggerFinderLoader {
// Whether multiple provider should be considered as an error.
// This is further submitted to the configuration error policy.
private static boolean ensureSingletonProvider() {
final PrivilegedAction<Boolean> ensureSingletonProvider =
() -> Boolean.getBoolean("jdk.logger.finder.singleton");
return AccessController.doPrivileged(ensureSingletonProvider);
return Boolean.parseBoolean(
GetPropertyAction.getProperty("jdk.logger.finder.singleton"));
}
private static Iterator<System.LoggerFinder> findLoggerFinderProviders() {

View File

@ -55,8 +55,8 @@ public class SimpleConsoleLogger extends LoggerConfiguration
PlatformLogger.toPlatformLevel(DEFAULT_LEVEL);
static Level getDefaultLevel() {
String levelName = AccessController.doPrivileged(
new GetPropertyAction("jdk.system.logger.level", "INFO"));
String levelName = GetPropertyAction
.getProperty("jdk.system.logger.level", "INFO");
try {
return Level.valueOf(levelName);
} catch (IllegalArgumentException iae) {
@ -425,8 +425,8 @@ public class SimpleConsoleLogger extends LoggerConfiguration
// Make it easier to wrap Logger...
static private final String[] skips;
static {
String additionalPkgs = AccessController.doPrivileged(
new GetPropertyAction("jdk.logger.packages"));
String additionalPkgs =
GetPropertyAction.getProperty("jdk.logger.packages");
skips = additionalPkgs == null ? new String[0] : additionalPkgs.split(",");
}
@ -485,7 +485,7 @@ public class SimpleConsoleLogger extends LoggerConfiguration
// jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java
// to fail - because that test has a testcase which somehow references
// PlatformLogger and counts the number of generated lambda classes.
String format = AccessController.doPrivileged(new GetPropertyAction(key));
String format = GetPropertyAction.getProperty(key);
if (format == null && defaultPropertyGetter != null) {
format = defaultPropertyGetter.apply(key);

View File

@ -30,4 +30,9 @@ public interface JavaLangInvokeAccess {
* Create a new MemberName instance
*/
Object newMemberName();
/**
* Returns the name for the given MemberName
*/
String getName(Object mname);
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 2016, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package jdk.internal.misc;
import java.io.ObjectInputStream;
/**
* The interface to specify methods for accessing {@code ObjectInputStream}
* @author sjiang
*/
public interface JavaObjectInputStreamAccess {
/**
* Sets a descriptor validating.
* @param ois stream to have the descriptors validated
* @param validator validator used to validate a descriptor.
*/
public void setValidator(ObjectInputStream ois, ObjectStreamClassValidator validator);
}

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2016, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package jdk.internal.misc;
import java.io.ObjectStreamClass;
/**
* A callback used by {@code ObjectInputStream} to do descriptor validation.
*
* @author sjiang
*/
public interface ObjectStreamClassValidator {
/**
* This method will be called by ObjectInputStream to
* check a descriptor just before creating an object described by this descriptor.
* The object will not be created if this method throws a {@code RuntimeException}.
* @param descriptor descriptor to be checked.
*/
public void validateDescriptor(ObjectStreamClass descriptor);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2016, 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
@ -29,9 +29,9 @@ import java.lang.module.ModuleDescriptor;
import java.util.jar.JarFile;
import java.io.Console;
import java.io.FileDescriptor;
import java.io.ObjectInputStream;
import java.security.ProtectionDomain;
import java.security.AccessController;
import jdk.internal.misc.Unsafe;
/** A repository of "shared secrets", which are a mechanism for
calling implementation-private methods in another package without
@ -63,6 +63,7 @@ public class SharedSecrets {
private static JavaAWTAccess javaAWTAccess;
private static JavaAWTFontAccess javaAWTFontAccess;
private static JavaBeansAccess javaBeansAccess;
private static JavaObjectInputStreamAccess javaObjectInputStreamAccess;
public static JavaUtilJarAccess javaUtilJarAccess() {
if (javaUtilJarAccess == null) {
@ -262,4 +263,15 @@ public class SharedSecrets {
public static void setJavaUtilResourceBundleAccess(JavaUtilResourceBundleAccess access) {
javaUtilResourceBundleAccess = access;
}
public static JavaObjectInputStreamAccess getJavaObjectInputStreamAccess() {
if (javaObjectInputStreamAccess == null) {
unsafe.ensureClassInitialized(ObjectInputStream.class);
}
return javaObjectInputStreamAccess;
}
public static void setJavaObjectInputStreamAccess(JavaObjectInputStreamAccess access) {
javaObjectInputStreamAccess = access;
}
}

View File

@ -70,6 +70,7 @@ package jdk.internal.org.objectweb.asm;
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
@SuppressWarnings("deprecation") // for Integer(int) constructor
public interface Opcodes {
// ASM API versions
@ -176,6 +177,8 @@ public interface Opcodes {
*/
int F_SAME1 = 4;
// For reference comparison purposes, construct new instances
// instead of using valueOf() or autoboxing.
Integer TOP = new Integer(0);
Integer INTEGER = new Integer(1);
Integer FLOAT = new Integer(2);

View File

@ -27,13 +27,12 @@ package jdk.internal.reflect;
import java.lang.reflect.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.VM;
import sun.security.action.GetPropertyAction;
/** Common utility routines used by both java.lang and
java.lang.reflect */
@ -344,15 +343,10 @@ public class Reflection {
private static void printStackTraceIfNeeded(Throwable e) {
if (!printStackWhenAccessFailsSet && VM.initLevel() >= 1) {
// can't use method reference here, might be too early in startup
PrivilegedAction<Boolean> pa = new PrivilegedAction<Boolean>() {
public Boolean run() {
String s;
s = System.getProperty("sun.reflect.debugModuleAccessChecks");
return (s != null && !s.equalsIgnoreCase("false"));
}
};
printStackWhenAccessFails = AccessController.doPrivileged(pa);
String s = GetPropertyAction
.getProperty("sun.reflect.debugModuleAccessChecks");
printStackWhenAccessFails =
(s != null && !s.equalsIgnoreCase("false"));
printStackWhenAccessFailsSet = true;
}
if (printStackWhenAccessFails) {

View File

@ -30,10 +30,11 @@ import java.lang.reflect.Executable;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.Permission;
import java.security.PrivilegedAction;
import java.util.Properties;
import sun.reflect.misc.ReflectUtil;
import sun.security.action.GetPropertyAction;
/** <P> The master factory for all reflective objects, both those in
java.lang.reflect (Fields, Methods, Constructors) as well as their
@ -382,41 +383,37 @@ public class ReflectionFactory {
run, before the system properties are set up. */
private static void checkInitted() {
if (initted) return;
AccessController.doPrivileged(
new PrivilegedAction<>() {
public Void run() {
// Tests to ensure the system properties table is fully
// initialized. This is needed because reflection code is
// called very early in the initialization process (before
// command-line arguments have been parsed and therefore
// these user-settable properties installed.) We assume that
// if System.out is non-null then the System class has been
// fully initialized and that the bulk of the startup code
// has been run.
if (System.out == null) {
// java.lang.System not yet fully initialized
return null;
}
// Tests to ensure the system properties table is fully
// initialized. This is needed because reflection code is
// called very early in the initialization process (before
// command-line arguments have been parsed and therefore
// these user-settable properties installed.) We assume that
// if System.out is non-null then the System class has been
// fully initialized and that the bulk of the startup code
// has been run.
String val = System.getProperty("sun.reflect.noInflation");
if (val != null && val.equals("true")) {
noInflation = true;
}
if (System.out == null) {
// java.lang.System not yet fully initialized
return;
}
val = System.getProperty("sun.reflect.inflationThreshold");
if (val != null) {
try {
inflationThreshold = Integer.parseInt(val);
} catch (NumberFormatException e) {
throw new RuntimeException("Unable to parse property sun.reflect.inflationThreshold", e);
}
}
Properties props = GetPropertyAction.getProperties();
String val = props.getProperty("sun.reflect.noInflation");
if (val != null && val.equals("true")) {
noInflation = true;
}
initted = true;
return null;
}
});
val = props.getProperty("sun.reflect.inflationThreshold");
if (val != null) {
try {
inflationThreshold = Integer.parseInt(val);
} catch (NumberFormatException e) {
throw new RuntimeException("Unable to parse property sun.reflect.inflationThreshold", e);
}
}
initted = true;
}
private static LangReflectAccess langReflectAccess() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2016, 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
@ -300,9 +300,5 @@ module java.base {
provides java.nio.file.spi.FileSystemProvider with
jdk.internal.jrtfs.JrtFileSystemProvider;
provides java.security.Provider with sun.security.provider.Sun;
provides java.security.Provider with sun.security.rsa.SunRsaSign;
provides java.security.Provider with com.sun.crypto.provider.SunJCE;
provides java.security.Provider with com.sun.net.ssl.internal.ssl.Provider;
}

View File

@ -231,22 +231,66 @@ public class VerifyAccess {
* @param refc the class attempting to make the reference
*/
public static boolean isTypeVisible(Class<?> type, Class<?> refc) {
if (type == refc) return true; // easy check
if (type == refc) {
return true; // easy check
}
while (type.isArray()) type = type.getComponentType();
if (type.isPrimitive() || type == Object.class) return true;
ClassLoader parent = type.getClassLoader();
if (parent == null) return true;
ClassLoader child = refc.getClassLoader();
if (child == null) return false;
if (parent == child || loadersAreRelated(parent, child, true))
if (type.isPrimitive() || type == Object.class) {
return true;
// Do it the hard way: Look up the type name from the refc loader.
try {
Class<?> res = child.loadClass(type.getName());
return (type == res);
} catch (ClassNotFoundException ex) {
}
ClassLoader typeLoader = type.getClassLoader();
ClassLoader refcLoader = refc.getClassLoader();
if (typeLoader == refcLoader) {
return true;
}
if (refcLoader == null && typeLoader != null) {
return false;
}
if (typeLoader == null && type.getName().startsWith("java.")) {
// Note: The API for actually loading classes, ClassLoader.defineClass,
// guarantees that classes with names beginning "java." cannot be aliased,
// because class loaders cannot load them directly.
return true;
}
// Do it the hard way: Look up the type name from the refc loader.
//
// Force the refc loader to report and commit to a particular binding for this type name (type.getName()).
//
// In principle, this query might force the loader to load some unrelated class,
// which would cause this query to fail (and the original caller to give up).
// This would be wasted effort, but it is expected to be very rare, occurring
// only when an attacker is attempting to create a type alias.
// In the normal case, one class loader will simply delegate to the other,
// and the same type will be visible through both, with no extra loading.
//
// It is important to go through Class.forName instead of ClassLoader.loadClass
// because Class.forName goes through the JVM system dictionary, which records
// the class lookup once for all. This means that even if a not-well-behaved class loader
// would "change its mind" about the meaning of the name, the Class.forName request
// will use the result cached in the JVM system dictionary. Note that the JVM system dictionary
// will record the first successful result. Unsuccessful results are not stored.
//
// We use doPrivileged in order to allow an unprivileged caller to ask an arbitrary
// class loader about the binding of the proposed name (type.getName()).
// The looked up type ("res") is compared for equality against the proposed
// type ("type") and then is discarded. Thus, the worst that can happen to
// the "child" class loader is that it is bothered to load and report a class
// that differs from "type"; this happens once due to JVM system dictionary
// memoization. And the caller never gets to look at the alternate type binding
// ("res"), whether it exists or not.
final String name = type.getName();
Class<?> res = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<>() {
public Class<?> run() {
try {
return Class.forName(name, false, refcLoader);
} catch (ClassNotFoundException | LinkageError e) {
return null; // Assume the class is not found
}
}
});
return (type == res);
}
/**

View File

@ -53,9 +53,8 @@ public class ResourceManager {
private static final AtomicInteger numSockets;
static {
String prop = java.security.AccessController.doPrivileged(
new GetPropertyAction("sun.net.maxDatagramSockets")
);
String prop =
GetPropertyAction.getProperty("sun.net.maxDatagramSockets");
int defmax = DEFAULT_MAX_SOCKETS;
try {
if (prop != null) {

View File

@ -31,6 +31,7 @@ import java.security.AccessController;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaIOFileDescriptorAccess;
import sun.security.action.GetPropertyAction;
/**
@ -39,8 +40,7 @@ import jdk.internal.misc.JavaIOFileDescriptorAccess;
*/
public final class SdpSupport {
private static final String os = AccessController
.doPrivileged(new sun.security.action.GetPropertyAction("os.name"));
private static final String os = GetPropertyAction.getProperty("os.name");
private static final boolean isSupported = (os.equals("SunOS") || (os.equals("Linux")));
private static final JavaIOFileDescriptorAccess fdAccess =
SharedSecrets.getJavaIOFileDescriptorAccess();

View File

@ -25,10 +25,10 @@
package sun.net.smtp;
import java.util.StringTokenizer;
import java.io.*;
import java.net.*;
import sun.net.TransferProtocolClient;
import sun.security.action.GetPropertyAction;
/**
* This class implements the SMTP client.
@ -157,8 +157,7 @@ public class SmtpClient extends TransferProtocolClient {
}
try {
String s;
mailhost = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("mail.host"));
mailhost = GetPropertyAction.getProperty("mail.host");
if (mailhost != null) {
openServer(mailhost);
return;
@ -184,8 +183,7 @@ public class SmtpClient extends TransferProtocolClient {
setConnectTimeout(to);
try {
String s;
mailhost = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("mail.host"));
mailhost = GetPropertyAction.getProperty("mail.host");
if (mailhost != null) {
openServer(mailhost);
return;

View File

@ -27,6 +27,7 @@ package sun.net.www;
import java.net.URL;
import java.io.*;
import java.util.StringTokenizer;
import sun.security.action.GetPropertyAction;
class MimeLauncher extends Thread {
java.net.URLConnection uc;
@ -182,8 +183,7 @@ class MimeLauncher extends Thread {
}
String execPathList;
execPathList = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("exec.path"));
execPathList = GetPropertyAction.getProperty("exec.path");
if (execPathList == null) {
// exec.path property not set
return false;

View File

@ -28,6 +28,7 @@ package sun.net.www.http;
import java.io.*;
import java.net.*;
import java.util.Locale;
import java.util.Properties;
import sun.net.NetworkClient;
import sun.net.ProgressSource;
import sun.net.www.MessageHeader;
@ -37,6 +38,7 @@ import sun.net.www.ParseUtil;
import sun.net.www.protocol.http.HttpURLConnection;
import sun.util.logging.PlatformLogger;
import static sun.net.www.protocol.http.HttpURLConnection.TunnelState.*;
import sun.security.action.GetPropertyAction;
/**
* @author Herb Jellinek
@ -143,20 +145,18 @@ public class HttpClient extends NetworkClient {
}
static {
String keepAlive = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("http.keepAlive"));
String retryPost = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.net.http.retryPost"));
Properties props = GetPropertyAction.getProperties();
String keepAlive = props.getProperty("http.keepAlive");
String retryPost = props.getProperty("sun.net.http.retryPost");
if (keepAlive != null) {
keepAliveProp = Boolean.valueOf(keepAlive).booleanValue();
keepAliveProp = Boolean.parseBoolean(keepAlive);
} else {
keepAliveProp = true;
}
if (retryPost != null) {
retryPostProp = Boolean.valueOf(retryPost).booleanValue();
retryPostProp = Boolean.parseBoolean(retryPost);
} else
retryPostProp = true;

View File

@ -46,6 +46,7 @@ import java.net.ProxySelector;
import java.util.StringTokenizer;
import java.util.Iterator;
import java.security.Permission;
import java.util.Properties;
import sun.net.NetworkClient;
import sun.net.www.MessageHeader;
import sun.net.www.MeteredStream;
@ -277,11 +278,10 @@ public class FtpURLConnection extends URLConnection {
if (user == null) {
user = "anonymous";
String vers = java.security.AccessController.doPrivileged(
new GetPropertyAction("java.version"));
password = java.security.AccessController.doPrivileged(
new GetPropertyAction("ftp.protocol.user",
"Java" + vers + "@"));
Properties props = GetPropertyAction.getProperties();
String vers = props.getProperty("java.version");
password = props.getProperty("ftp.protocol.user",
"Java" + vers + "@");
}
try {
ftp = FtpClient.create();

View File

@ -25,9 +25,10 @@
package sun.net.www.protocol.http;
import sun.net.www.*;
import java.util.Iterator;
import java.util.HashMap;
import sun.net.www.*;
import sun.security.action.GetPropertyAction;
/**
* This class is used to parse the information in WWW-Authenticate: and Proxy-Authenticate:
@ -93,8 +94,7 @@ public class AuthenticationHeader {
}
static {
authPref = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("http.auth.preference"));
authPref = GetPropertyAction.getProperty("http.auth.preference");
// http.auth.preference can be set to SPNEGO or Kerberos.
// In fact they means "Negotiate with SPNEGO" and "Negotiate with

View File

@ -52,7 +52,6 @@ import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException;
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@ -78,12 +77,15 @@ import java.text.SimpleDateFormat;
import java.util.TimeZone;
import java.net.MalformedURLException;
import java.nio.ByteBuffer;
import java.util.Properties;
import static sun.net.www.protocol.http.AuthScheme.BASIC;
import static sun.net.www.protocol.http.AuthScheme.DIGEST;
import static sun.net.www.protocol.http.AuthScheme.NTLM;
import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE;
import static sun.net.www.protocol.http.AuthScheme.KERBEROS;
import static sun.net.www.protocol.http.AuthScheme.UNKNOWN;
import sun.security.action.GetIntegerAction;
import sun.security.action.GetPropertyAction;
/**
* A class to represent an HTTP connection to a remote object.
@ -205,46 +207,38 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
};
static {
maxRedirects = java.security.AccessController.doPrivileged(
new sun.security.action.GetIntegerAction(
"http.maxRedirects", defaultmaxRedirects)).intValue();
version = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("java.version"));
String agent = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("http.agent"));
Properties props = GetPropertyAction.getProperties();
maxRedirects = GetIntegerAction.getProperty("http.maxRedirects",
defaultmaxRedirects);
version = props.getProperty("java.version");
String agent = props.getProperty("http.agent");
if (agent == null) {
agent = "Java/"+version;
} else {
agent = agent + " Java/"+version;
}
userAgent = agent;
validateProxy = java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction(
"http.auth.digest.validateProxy")).booleanValue();
validateServer = java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction(
"http.auth.digest.validateServer")).booleanValue();
validateProxy = Boolean.parseBoolean(
props.getProperty("http.auth.digest.validateProxy"));
validateServer = Boolean.parseBoolean(
props.getProperty("http.auth.digest.validateServer"));
enableESBuffer = java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction(
"sun.net.http.errorstream.enableBuffering")).booleanValue();
timeout4ESBuffer = java.security.AccessController.doPrivileged(
new sun.security.action.GetIntegerAction(
"sun.net.http.errorstream.timeout", 300)).intValue();
enableESBuffer = Boolean.parseBoolean(
props.getProperty("sun.net.http.errorstream.enableBuffering"));
timeout4ESBuffer = GetIntegerAction
.getProperty("sun.net.http.errorstream.timeout", 300);
if (timeout4ESBuffer <= 0) {
timeout4ESBuffer = 300; // use the default
}
bufSize4ES = java.security.AccessController.doPrivileged(
new sun.security.action.GetIntegerAction(
"sun.net.http.errorstream.bufferSize", 4096)).intValue();
bufSize4ES = GetIntegerAction
.getProperty("sun.net.http.errorstream.bufferSize", 4096);
if (bufSize4ES <= 0) {
bufSize4ES = 4096; // use the default
}
allowRestrictedHeaders = java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction(
"sun.net.http.allowRestrictedHeaders")).booleanValue();
allowRestrictedHeaders = Boolean.parseBoolean(
props.getProperty("sun.net.http.allowRestrictedHeaders"));
if (!allowRestrictedHeaders) {
restrictedHeaderSet = new HashSet<>(restrictedHeaders.length);
for (int i=0; i < restrictedHeaders.length; i++) {

View File

@ -41,7 +41,6 @@ import java.security.Principal;
import java.security.cert.*;
import java.util.StringTokenizer;
import java.util.Vector;
import java.security.AccessController;
import javax.security.auth.x500.X500Principal;
@ -139,8 +138,8 @@ final class HttpsClient extends HttpClient
// If ciphers are assigned, sort them into an array.
//
String ciphers [];
String cipherString = AccessController.doPrivileged(
new GetPropertyAction("https.cipherSuites"));
String cipherString =
GetPropertyAction.getProperty("https.cipherSuites");
if (cipherString == null || "".equals(cipherString)) {
ciphers = null;
@ -163,8 +162,8 @@ final class HttpsClient extends HttpClient
// If protocols are assigned, sort them into an array.
//
String protocols [];
String protocolString = AccessController.doPrivileged(
new GetPropertyAction("https.protocols"));
String protocolString =
GetPropertyAction.getProperty("https.protocols");
if (protocolString == null || "".equals(protocolString)) {
protocols = null;
@ -184,8 +183,7 @@ final class HttpsClient extends HttpClient
}
private String getUserAgent() {
String userAgent = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("https.agent"));
String userAgent = GetPropertyAction.getProperty("https.agent");
if (userAgent == null || userAgent.length() == 0) {
userAgent = "JSSE";
}

View File

@ -32,10 +32,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.AccessController;
import java.security.Permission;
import java.security.PrivilegedAction;
import java.util.List;
import jdk.internal.jimage.ImageLocation;
import jdk.internal.jimage.ImageReader;
@ -45,6 +42,7 @@ import jdk.internal.loader.URLClassPath;
import jdk.internal.loader.Resource;
import sun.net.www.ParseUtil;
import sun.net.www.URLConnection;
import sun.security.action.GetPropertyAction;
/**
* URLConnection implementation that can be used to connect to resources
@ -163,11 +161,7 @@ public class JavaRuntimeURLConnection extends URLConnection {
public Permission getPermission() throws IOException {
Permission p = permission;
if (p == null) {
// using lambda expression here leads to recursive initialization
PrivilegedAction<String> pa = new PrivilegedAction<String>() {
public String run() { return System.getProperty("java.home"); }
};
String home = AccessController.doPrivileged(pa);
String home = GetPropertyAction.getProperty("java.home");
p = new FilePermission(home + File.separator + "-", "read");
permission = p;
}

View File

@ -40,6 +40,7 @@ import java.net.MalformedURLException;
import java.net.URLStreamHandler;
import java.io.InputStream;
import java.io.IOException;
import sun.security.action.GetPropertyAction;
public class Handler extends URLStreamHandler {
static URL base;
@ -54,12 +55,10 @@ public class Handler extends URLStreamHandler {
URLConnection uc = null;
URL ru;
Boolean tmp = java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction("newdoc.localonly"));
boolean localonly = tmp.booleanValue();
boolean localonly = Boolean.parseBoolean(
GetPropertyAction.getProperty("newdoc.localonly"));
String docurl = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("doc.url"));
String docurl = GetPropertyAction.getProperty("doc.url");
String file = u.getFile();
if (!localonly) {

View File

@ -1019,9 +1019,8 @@ public class FileChannelImpl
if (!propertyChecked) {
synchronized (FileChannelImpl.class) {
if (!propertyChecked) {
String value = AccessController.doPrivileged(
new GetPropertyAction(
"sun.nio.ch.disableSystemWideOverlappingFileLockCheck"));
String value = GetPropertyAction.getProperty(
"sun.nio.ch.disableSystemWideOverlappingFileLockCheck");
isSharedFileLockTable = ((value == null) || value.equals("false"));
propertyChecked = true;
}

View File

@ -33,6 +33,7 @@ import java.util.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.net.ExtendedOptionsImpl;
import sun.security.action.GetPropertyAction;
public class Net {
@ -382,13 +383,8 @@ public class Net {
}
public static boolean isFastTcpLoopbackRequested() {
String loopbackProp = java.security.AccessController.doPrivileged(
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty("jdk.net.useFastTcpLoopback");
}
});
String loopbackProp =
GetPropertyAction.getProperty("jdk.net.useFastTcpLoopback");
boolean enable;
if ("".equals(loopbackProp)) {
enable = true;
@ -647,16 +643,9 @@ public class Net {
int availLevel = isExclusiveBindAvailable();
if (availLevel >= 0) {
String exclBindProp =
java.security.AccessController.doPrivileged(
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty(
"sun.net.useExclusiveBind");
}
});
GetPropertyAction.getProperty("sun.net.useExclusiveBind");
if (exclBindProp != null) {
exclusiveBind = exclBindProp.length() == 0 ?
exclusiveBind = exclBindProp.isEmpty() ?
true : Boolean.parseBoolean(exclBindProp);
} else if (availLevel == 1) {
exclusiveBind = true;

View File

@ -64,13 +64,7 @@ public class Util {
* for potential future-proofing.
*/
private static long getMaxCachedBufferSize() {
String s = java.security.AccessController.doPrivileged(
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty("jdk.nio.maxCachedBufferSize");
}
});
String s = GetPropertyAction.getProperty("jdk.nio.maxCachedBufferSize");
if (s != null) {
try {
long m = Long.parseLong(s);
@ -471,8 +465,7 @@ public class Util {
if (bugLevel == null) {
if (!jdk.internal.misc.VM.isBooted())
return false;
String value = AccessController.doPrivileged(
new GetPropertyAction("sun.nio.ch.bugLevel"));
String value = GetPropertyAction.getProperty("sun.nio.ch.bugLevel");
bugLevel = (value != null) ? value : "";
}
return bugLevel.equals(bl);

View File

@ -34,8 +34,7 @@ import java.nio.charset.spi.CharsetProvider;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.action.GetPropertyAction;
public class StandardCharsets extends CharsetProvider {
@ -201,15 +200,7 @@ public class StandardCharsets extends CharsetProvider {
}
private static String getProperty(String key) {
// this method may be called during initialization of
// system class loader and thus not using lambda
return AccessController.doPrivileged(
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty(key);
}
});
return GetPropertyAction.getProperty(key);
}

View File

@ -28,8 +28,7 @@ package sun.nio.fs;
import java.util.*;
import java.nio.file.*;
import java.nio.charset.Charset;
import java.security.*;
import sun.security.action.*;
import sun.security.action.GetPropertyAction;
/**
* Utility methods
@ -39,7 +38,7 @@ class Util {
private Util() { }
private static final Charset jnuEncoding = Charset.forName(
AccessController.doPrivileged(new GetPropertyAction("sun.jnu.encoding")));
GetPropertyAction.getProperty("sun.jnu.encoding"));
/**
* Returns {@code Charset} corresponding to the sun.jnu.encoding property

View File

@ -25,6 +25,8 @@
package sun.security.action;
import java.security.AccessController;
/**
* A convenience class for retrieving the integer value of a system property
* as a privileged action.
@ -67,7 +69,7 @@ public class GetIntegerAction
implements java.security.PrivilegedAction<Integer> {
private String theProp;
private int defaultVal;
private boolean defaultSet = false;
private boolean defaultSet;
/**
* Constructor that takes the name of the system property whose integer
@ -110,4 +112,39 @@ public class GetIntegerAction
return defaultVal;
return value;
}
/**
* Convenience method to get a property without going through doPrivileged
* if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated.
*
* @param theProp the name of the system property.
*/
public static Integer getProperty(String theProp) {
if (System.getSecurityManager() == null) {
return Integer.getInteger(theProp);
} else {
return AccessController.doPrivileged(
new GetIntegerAction(theProp));
}
}
/**
* Convenience method to get a property without going through doPrivileged
* if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated.
*
* @param theProp the name of the system property.
* @param defaultVal the default value.
*/
public static Integer getProperty(String theProp, int defaultVal) {
Integer value;
if (System.getSecurityManager() == null) {
value = Integer.getInteger(theProp);
} else {
value = AccessController.doPrivileged(
new GetIntegerAction(theProp));
}
return (value != null) ? value : defaultVal;
}
}

View File

@ -25,6 +25,10 @@
package sun.security.action;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Properties;
/**
* A convenience class for retrieving the string value of a system
* property as a privileged action.
@ -46,8 +50,7 @@ package sun.security.action;
* @since 1.2
*/
public class GetPropertyAction
implements java.security.PrivilegedAction<String> {
public class GetPropertyAction implements PrivilegedAction<String> {
private String theProp;
private String defaultVal;
@ -84,4 +87,57 @@ public class GetPropertyAction
String value = System.getProperty(theProp);
return (value == null) ? defaultVal : value;
}
/**
* Convenience method to get a property without going through doPrivileged
* if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated.
*
* @param theProp the name of the system property.
*/
public static String getProperty(String theProp) {
if (System.getSecurityManager() == null) {
return System.getProperty(theProp);
} else {
return AccessController.doPrivileged(
new GetPropertyAction(theProp));
}
}
/**
* Convenience method to get a property without going through doPrivileged
* if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated.
*
* @param theProp the name of the system property.
* @param defaultVal the default value.
*/
public static String getProperty(String theProp, String defaultVal) {
if (System.getSecurityManager() == null) {
return System.getProperty(theProp, defaultVal);
} else {
return AccessController.doPrivileged(
new GetPropertyAction(theProp, defaultVal));
}
}
/**
* Convenience method to call <code>System.getProperties</code> without
* having to go through doPrivileged if no security manager is present.
* This is unsafe for inclusion in a public API but allowable here since
* this class is now encapsulated.
*/
public static Properties getProperties() {
if (System.getSecurityManager() == null) {
return System.getProperties();
} else {
return AccessController.doPrivileged(
new PrivilegedAction<Properties>() {
public Properties run() {
return System.getProperties();
}
}
);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2016, 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
@ -236,9 +236,8 @@ final class ProviderConfig {
if (debug != null) {
debug.println("Loading provider " + ProviderConfig.this);
}
ProviderLoader pl = new ProviderLoader();
try {
Provider p = pl.load(provName);
Provider p = ProviderLoader.INSTANCE.load(provName);
if (p != null) {
if (hasArgument()) {
p = p.configure(argument);
@ -303,9 +302,11 @@ final class ProviderConfig {
// Inner class for loading security providers listed in java.security file
private static final class ProviderLoader {
static final ProviderLoader INSTANCE = new ProviderLoader();
private final ServiceLoader<Provider> services;
ProviderLoader() {
private ProviderLoader() {
// VM should already been booted at this point, if not
// - Only providers in java.base should be loaded, don't use
// ServiceLoader

View File

@ -106,6 +106,18 @@ abstract class DSA extends SignatureSpi {
this.p1363Format = p1363Format;
}
private static void checkKey(DSAParams params, int digestLen, String mdAlgo)
throws InvalidKeyException {
// FIPS186-3 states in sec4.2 that a hash function which provides
// a lower security strength than the (L, N) pair ordinarily should
// not be used.
int valueN = params.getQ().bitLength();
if (valueN > digestLen) {
throw new InvalidKeyException("The security strength of " +
mdAlgo + " digest algorithm is not sufficient for this key size");
}
}
/**
* Initialize the DSA object with a DSA private key.
*
@ -130,6 +142,12 @@ abstract class DSA extends SignatureSpi {
throw new InvalidKeyException("DSA private key lacks parameters");
}
// check key size against hash output size for signing
// skip this check for verification to minimize impact on existing apps
if (md.getAlgorithm() != "NullDigest20") {
checkKey(params, md.getDigestLength()*8, md.getAlgorithm());
}
this.params = params;
this.presetX = priv.getX();
this.presetY = null;
@ -160,7 +178,6 @@ abstract class DSA extends SignatureSpi {
if (params == null) {
throw new InvalidKeyException("DSA public key lacks parameters");
}
this.params = params;
this.presetY = pub.getY();
this.presetX = null;
@ -406,20 +423,13 @@ abstract class DSA extends SignatureSpi {
return t5.mod(q);
}
// NOTE: This following impl is defined in FIPS 186-3 AppendixB.2.2.
// Original DSS algos such as SHA1withDSA and RawDSA uses a different
// algorithm defined in FIPS 186-1 Sec3.2, and thus need to override this.
// NOTE: This following impl is defined in FIPS 186-4 AppendixB.2.1.
protected BigInteger generateK(BigInteger q) {
SecureRandom random = getSigningRandom();
byte[] kValue = new byte[q.bitLength()/8];
byte[] kValue = new byte[(q.bitLength() + 7)/8 + 8];
while (true) {
random.nextBytes(kValue);
BigInteger k = new BigInteger(1, kValue).mod(q);
if (k.signum() > 0 && k.compareTo(q) < 0) {
return k;
}
}
random.nextBytes(kValue);
return new BigInteger(1, kValue).mod(q.subtract(BigInteger.ONE)).add(BigInteger.ONE);
}
// Use the application-specified SecureRandom Object if provided.
@ -504,222 +514,10 @@ abstract class DSA extends SignatureSpi {
}
}
static class LegacyDSA extends DSA {
/* The random seed used to generate k */
private int[] kSeed;
/* The random seed used to generate k (specified by application) */
private byte[] kSeedAsByteArray;
/*
* The random seed used to generate k
* (prevent the same Kseed from being used twice in a row
*/
private int[] kSeedLast;
public LegacyDSA(MessageDigest md) throws NoSuchAlgorithmException {
this(md, false);
}
private LegacyDSA(MessageDigest md, boolean p1363Format)
throws NoSuchAlgorithmException {
super(md, p1363Format);
}
@Deprecated
protected void engineSetParameter(String key, Object param) {
if (key.equals("KSEED")) {
if (param instanceof byte[]) {
kSeed = byteArray2IntArray((byte[])param);
kSeedAsByteArray = (byte[])param;
} else {
debug("unrecognized param: " + key);
throw new InvalidParameterException("kSeed not a byte array");
}
} else {
throw new InvalidParameterException("Unsupported parameter");
}
}
@Deprecated
protected Object engineGetParameter(String key) {
if (key.equals("KSEED")) {
return kSeedAsByteArray;
} else {
return null;
}
}
/*
* Please read bug report 4044247 for an alternative, faster,
* NON-FIPS approved method to generate K
*/
@Override
protected BigInteger generateK(BigInteger q) {
BigInteger k = null;
// The application specified a kSeed for us to use.
// Note: we dis-allow usage of the same Kseed twice in a row
if (kSeed != null && !Arrays.equals(kSeed, kSeedLast)) {
k = generateKUsingKSeed(kSeed, q);
if (k.signum() > 0 && k.compareTo(q) < 0) {
kSeedLast = kSeed.clone();
return k;
}
}
// The application did not specify a Kseed for us to use.
// We'll generate a new Kseed by getting random bytes from
// a SecureRandom object.
SecureRandom random = getSigningRandom();
while (true) {
int[] seed = new int[5];
for (int i = 0; i < 5; i++) seed[i] = random.nextInt();
k = generateKUsingKSeed(seed, q);
if (k.signum() > 0 && k.compareTo(q) < 0) {
kSeedLast = seed;
return k;
}
}
}
/**
* Compute k for the DSA signature as defined in the original DSS,
* i.e. FIPS186.
*
* @param seed the seed for generating k. This seed should be
* secure. This is what is referred to as the KSEED in the DSA
* specification.
*
* @param g the g parameter from the DSA key pair.
*/
private BigInteger generateKUsingKSeed(int[] seed, BigInteger q) {
// check out t in the spec.
int[] t = { 0xEFCDAB89, 0x98BADCFE, 0x10325476,
0xC3D2E1F0, 0x67452301 };
//
int[] tmp = SHA_7(seed, t);
byte[] tmpBytes = new byte[tmp.length * 4];
for (int i = 0; i < tmp.length; i++) {
int k = tmp[i];
for (int j = 0; j < 4; j++) {
tmpBytes[(i * 4) + j] = (byte) (k >>> (24 - (j * 8)));
}
}
BigInteger k = new BigInteger(1, tmpBytes).mod(q);
return k;
}
// Constants for each round
private static final int round1_kt = 0x5a827999;
private static final int round2_kt = 0x6ed9eba1;
private static final int round3_kt = 0x8f1bbcdc;
private static final int round4_kt = 0xca62c1d6;
/**
* Computes set 1 thru 7 of SHA-1 on m1. */
static int[] SHA_7(int[] m1, int[] h) {
int[] W = new int[80];
System.arraycopy(m1,0,W,0,m1.length);
int temp = 0;
for (int t = 16; t <= 79; t++){
temp = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16];
W[t] = ((temp << 1) | (temp >>>(32 - 1)));
}
int a = h[0],b = h[1],c = h[2], d = h[3], e = h[4];
for (int i = 0; i < 20; i++) {
temp = ((a<<5) | (a>>>(32-5))) +
((b&c)|((~b)&d))+ e + W[i] + round1_kt;
e = d;
d = c;
c = ((b<<30) | (b>>>(32-30)));
b = a;
a = temp;
}
// Round 2
for (int i = 20; i < 40; i++) {
temp = ((a<<5) | (a>>>(32-5))) +
(b ^ c ^ d) + e + W[i] + round2_kt;
e = d;
d = c;
c = ((b<<30) | (b>>>(32-30)));
b = a;
a = temp;
}
// Round 3
for (int i = 40; i < 60; i++) {
temp = ((a<<5) | (a>>>(32-5))) +
((b&c)|(b&d)|(c&d)) + e + W[i] + round3_kt;
e = d;
d = c;
c = ((b<<30) | (b>>>(32-30)));
b = a;
a = temp;
}
// Round 4
for (int i = 60; i < 80; i++) {
temp = ((a<<5) | (a>>>(32-5))) +
(b ^ c ^ d) + e + W[i] + round4_kt;
e = d;
d = c;
c = ((b<<30) | (b>>>(32-30)));
b = a;
a = temp;
}
int[] md = new int[5];
md[0] = h[0] + a;
md[1] = h[1] + b;
md[2] = h[2] + c;
md[3] = h[3] + d;
md[4] = h[4] + e;
return md;
}
/*
* Utility routine for converting a byte array into an int array
*/
private int[] byteArray2IntArray(byte[] byteArray) {
int j = 0;
byte[] newBA;
int mod = byteArray.length % 4;
// guarantee that the incoming byteArray is a multiple of 4
// (pad with 0's)
switch (mod) {
case 3: newBA = new byte[byteArray.length + 1]; break;
case 2: newBA = new byte[byteArray.length + 2]; break;
case 1: newBA = new byte[byteArray.length + 3]; break;
default: newBA = new byte[byteArray.length + 0]; break;
}
System.arraycopy(byteArray, 0, newBA, 0, byteArray.length);
// copy each set of 4 bytes in the byte array into an integer
int[] newSeed = new int[newBA.length / 4];
for (int i = 0; i < newBA.length; i += 4) {
newSeed[j] = newBA[i + 3] & 0xFF;
newSeed[j] |= (newBA[i + 2] << 8) & 0xFF00;
newSeed[j] |= (newBA[i + 1] << 16) & 0xFF0000;
newSeed[j] |= (newBA[i + 0] << 24) & 0xFF000000;
j++;
}
return newSeed;
}
}
/**
* Standard SHA1withDSA implementation.
*/
public static final class SHA1withDSA extends LegacyDSA {
public static final class SHA1withDSA extends DSA {
public SHA1withDSA() throws NoSuchAlgorithmException {
super(MessageDigest.getInstance("SHA-1"));
}
@ -728,7 +526,7 @@ abstract class DSA extends SignatureSpi {
/**
* SHA1withDSA implementation that uses the IEEE P1363 format.
*/
public static final class SHA1withDSAinP1363Format extends LegacyDSA {
public static final class SHA1withDSAinP1363Format extends DSA {
public SHA1withDSAinP1363Format() throws NoSuchAlgorithmException {
super(MessageDigest.getInstance("SHA-1"), true);
}
@ -741,7 +539,7 @@ abstract class DSA extends SignatureSpi {
* not, a SignatureException is thrown when sign()/verify() is called
* per JCA spec.
*/
static class Raw extends LegacyDSA {
static class Raw extends DSA {
// Internal special-purpose MessageDigest impl for RawDSA
// Only override whatever methods used
// NOTE: no clone support

Some files were not shown because too many files have changed in this diff Show More