Merge
This commit is contained in:
commit
6fd49139e8
1
.hgtags
1
.hgtags
@ -294,3 +294,4 @@ b2f9702efbe95527ea3a991474fda23987ff1c5c jdk9-b48
|
||||
5b8db585a33c3cc48e70e688ceee57dd9271dc5d jdk9-b49
|
||||
1550b2f6b63d1411fa84dc7bbc6f04809aedb43f jdk9-b50
|
||||
6efe265424e3f1ea596408a1f71baf2de316c772 jdk9-b51
|
||||
d6224d6021459ac8b3832e822f5acc849fa944af jdk9-b52
|
||||
|
@ -294,3 +294,4 @@ b6cca3e6175a69f39e5799b7349ddb0176630291 jdk9-b47
|
||||
d91ed1951b948210590ce1394bea5515357246ba jdk9-b49
|
||||
d1f37d39ff2421f956a6ddf316cf763807bc3363 jdk9-b50
|
||||
6207b4b8731ca75c51b031c47daa813ab92ef558 jdk9-b51
|
||||
1822e59f17121b09e7899cf338cfb6e37fe5fceb jdk9-b52
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2015, 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
|
||||
@ -77,26 +77,30 @@ AC_DEFUN([BASIC_PREPEND_TO_PATH],
|
||||
# $1: The name of the variable to fix
|
||||
AC_DEFUN([BASIC_FIXUP_PATH],
|
||||
[
|
||||
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
|
||||
BASIC_FIXUP_PATH_CYGWIN($1)
|
||||
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
|
||||
BASIC_FIXUP_PATH_MSYS($1)
|
||||
else
|
||||
# We're on a unix platform. Hooray! :)
|
||||
path="[$]$1"
|
||||
has_space=`$ECHO "$path" | $GREP " "`
|
||||
if test "x$has_space" != x; then
|
||||
AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
|
||||
AC_MSG_ERROR([Spaces are not allowed in this path.])
|
||||
fi
|
||||
# Only process if variable expands to non-empty
|
||||
|
||||
if test "x[$]$1" != x; then
|
||||
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
|
||||
BASIC_FIXUP_PATH_CYGWIN($1)
|
||||
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
|
||||
BASIC_FIXUP_PATH_MSYS($1)
|
||||
else
|
||||
# We're on a unix platform. Hooray! :)
|
||||
path="[$]$1"
|
||||
has_space=`$ECHO "$path" | $GREP " "`
|
||||
if test "x$has_space" != x; then
|
||||
AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
|
||||
AC_MSG_ERROR([Spaces are not allowed in this path.])
|
||||
fi
|
||||
|
||||
# Use eval to expand a potential ~
|
||||
eval path="$path"
|
||||
if test ! -f "$path" && test ! -d "$path"; then
|
||||
AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.])
|
||||
fi
|
||||
# Use eval to expand a potential ~
|
||||
eval path="$path"
|
||||
if test ! -f "$path" && test ! -d "$path"; then
|
||||
AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.])
|
||||
fi
|
||||
|
||||
$1="`cd "$path"; $THEPWDCMD -L`"
|
||||
$1="`cd "$path"; $THEPWDCMD -L`"
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
@ -113,57 +117,61 @@ AC_DEFUN([BASIC_FIXUP_PATH],
|
||||
# $1: The name of the variable to fix
|
||||
AC_DEFUN([BASIC_FIXUP_EXECUTABLE],
|
||||
[
|
||||
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
|
||||
BASIC_FIXUP_EXECUTABLE_CYGWIN($1)
|
||||
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
|
||||
BASIC_FIXUP_EXECUTABLE_MSYS($1)
|
||||
else
|
||||
# We're on a unix platform. Hooray! :)
|
||||
# First separate the path from the arguments. This will split at the first
|
||||
# space.
|
||||
complete="[$]$1"
|
||||
path="${complete%% *}"
|
||||
tmp="$complete EOL"
|
||||
arguments="${tmp#* }"
|
||||
|
||||
# Cannot rely on the command "which" here since it doesn't always work.
|
||||
is_absolute_path=`$ECHO "$path" | $GREP ^/`
|
||||
if test -z "$is_absolute_path"; then
|
||||
# Path to executable is not absolute. Find it.
|
||||
IFS_save="$IFS"
|
||||
IFS=:
|
||||
for p in $PATH; do
|
||||
if test -f "$p/$path" && test -x "$p/$path"; then
|
||||
new_path="$p/$path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$IFS_save"
|
||||
# Only process if variable expands to non-empty
|
||||
|
||||
if test "x[$]$1" != x; then
|
||||
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
|
||||
BASIC_FIXUP_EXECUTABLE_CYGWIN($1)
|
||||
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
|
||||
BASIC_FIXUP_EXECUTABLE_MSYS($1)
|
||||
else
|
||||
# This is an absolute path, we can use it without further modifications.
|
||||
new_path="$path"
|
||||
fi
|
||||
# We're on a unix platform. Hooray! :)
|
||||
# First separate the path from the arguments. This will split at the first
|
||||
# space.
|
||||
complete="[$]$1"
|
||||
path="${complete%% *}"
|
||||
tmp="$complete EOL"
|
||||
arguments="${tmp#* }"
|
||||
|
||||
if test "x$new_path" = x; then
|
||||
AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.])
|
||||
has_space=`$ECHO "$complete" | $GREP " "`
|
||||
if test "x$has_space" != x; then
|
||||
AC_MSG_NOTICE([This might be caused by spaces in the path, which is not allowed.])
|
||||
# Cannot rely on the command "which" here since it doesn't always work.
|
||||
is_absolute_path=`$ECHO "$path" | $GREP ^/`
|
||||
if test -z "$is_absolute_path"; then
|
||||
# Path to executable is not absolute. Find it.
|
||||
IFS_save="$IFS"
|
||||
IFS=:
|
||||
for p in $PATH; do
|
||||
if test -f "$p/$path" && test -x "$p/$path"; then
|
||||
new_path="$p/$path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$IFS_save"
|
||||
else
|
||||
# This is an absolute path, we can use it without further modifications.
|
||||
new_path="$path"
|
||||
fi
|
||||
|
||||
if test "x$new_path" = x; then
|
||||
AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.])
|
||||
has_space=`$ECHO "$complete" | $GREP " "`
|
||||
if test "x$has_space" != x; then
|
||||
AC_MSG_NOTICE([This might be caused by spaces in the path, which is not allowed.])
|
||||
fi
|
||||
AC_MSG_ERROR([Cannot locate the the path of $1])
|
||||
fi
|
||||
AC_MSG_ERROR([Cannot locate the the path of $1])
|
||||
fi
|
||||
fi
|
||||
|
||||
# Now join together the path and the arguments once again
|
||||
if test "x$arguments" != xEOL; then
|
||||
new_complete="$new_path ${arguments% *}"
|
||||
else
|
||||
new_complete="$new_path"
|
||||
fi
|
||||
# Now join together the path and the arguments once again
|
||||
if test "x$arguments" != xEOL; then
|
||||
new_complete="$new_path ${arguments% *}"
|
||||
else
|
||||
new_complete="$new_path"
|
||||
fi
|
||||
|
||||
if test "x$complete" != "x$new_complete"; then
|
||||
$1="$new_complete"
|
||||
AC_MSG_NOTICE([Rewriting $1 to "$new_complete"])
|
||||
if test "x$complete" != "x$new_complete"; then
|
||||
$1="$new_complete"
|
||||
AC_MSG_NOTICE([Rewriting $1 to "$new_complete"])
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -351,18 +351,34 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
|
||||
IFS=";"
|
||||
for i in $VS_INCLUDE; do
|
||||
ipath=$i
|
||||
IFS="$OLDIFS"
|
||||
BASIC_FIXUP_PATH([ipath])
|
||||
IFS=";"
|
||||
SYSROOT_CFLAGS="$SYSROOT_CFLAGS -I$ipath"
|
||||
# Only process non-empty elements
|
||||
if test "x$ipath" != x; then
|
||||
IFS="$OLDIFS"
|
||||
# Check that directory exists before calling fixup_path
|
||||
testpath=$ipath
|
||||
BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([testpath])
|
||||
if test -d "$testpath"; then
|
||||
BASIC_FIXUP_PATH([ipath])
|
||||
SYSROOT_CFLAGS="$SYSROOT_CFLAGS -I$ipath"
|
||||
fi
|
||||
IFS=";"
|
||||
fi
|
||||
done
|
||||
# Convert VS_LIB into SYSROOT_LDFLAGS
|
||||
for i in $VS_LIB; do
|
||||
libpath=$i
|
||||
IFS="$OLDIFS"
|
||||
BASIC_FIXUP_PATH([libpath])
|
||||
IFS=";"
|
||||
SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -libpath:$libpath"
|
||||
# Only process non-empty elements
|
||||
if test "x$libpath" != x; then
|
||||
IFS="$OLDIFS"
|
||||
# Check that directory exists before calling fixup_path
|
||||
testpath=$libpath
|
||||
BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([testpath])
|
||||
if test -d "$testpath"; then
|
||||
BASIC_FIXUP_PATH([libpath])
|
||||
SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -libpath:$libpath"
|
||||
fi
|
||||
IFS=";"
|
||||
fi
|
||||
done
|
||||
IFS="$OLDIFS"
|
||||
fi
|
||||
|
@ -180,7 +180,6 @@ jdk/src/java.base/share/classes/sun/nio/ch : jdk/src/share/classes/sun/nio/ch
|
||||
jdk/src/java.base/share/classes/sun/nio/cs : jdk/src/share/classes/sun/nio/cs
|
||||
jdk/src/java.base/share/classes/sun/nio/fs : jdk/src/share/classes/sun/nio/fs
|
||||
jdk/src/java.base/share/classes/sun/reflect : jdk/src/share/classes/sun/reflect
|
||||
jdk/src/java.base/share/classes/sun/security/acl : jdk/src/share/classes/sun/security/acl
|
||||
jdk/src/java.base/share/classes/sun/security/action : jdk/src/share/classes/sun/security/action
|
||||
jdk/src/java.base/share/classes/sun/security/internal : jdk/src/share/classes/sun/security/internal
|
||||
jdk/src/java.base/share/classes/sun/security/jca : jdk/src/share/classes/sun/security/jca
|
||||
|
@ -294,3 +294,4 @@ a13c49c5f2899b702652a460ed7aa73123e671e6 jdk9-b48
|
||||
9285d14eb7b6b0815679bae98dd936dbc136218d jdk9-b49
|
||||
224f593393e5b01b3c8f1e591b7f4b1790a3737a jdk9-b50
|
||||
2309c02386d1fa4ced5051873ffb9e04874f7a44 jdk9-b51
|
||||
b8538bbb6f224ab1dabba579137099c166ad4724 jdk9-b52
|
||||
|
@ -43,7 +43,6 @@ import java.io.FileInputStream;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import java.util.Properties;
|
||||
|
||||
class GetORBPropertiesFileAction implements PrivilegedAction {
|
||||
|
@ -454,3 +454,4 @@ cc775a4a24c7f5d9e624b4205e9fbd48a17331f6 jdk9-b48
|
||||
360cd1fc42f10941a9fd17cc32d5b85a22d12a0b jdk9-b49
|
||||
e0947f58c9c1426aa0d98b98ebb78357b27a7b99 jdk9-b50
|
||||
403b9cbadb04d3d1201823591cf931dc93b38e3a jdk9-b51
|
||||
9fb7fdc554db5be5c5b10f88f529ec3b870c44e3 jdk9-b52
|
||||
|
81
hotspot/make/test/JtregNative.gmk
Normal file
81
hotspot/make/test/JtregNative.gmk
Normal file
@ -0,0 +1,81 @@
|
||||
#
|
||||
# Copyright (c) 2015, 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.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# This file builds the native component of the JTReg tests for Hotspot.
|
||||
# It also covers the test-image part, where the built files are copied to the
|
||||
# test image.
|
||||
################################################################################
|
||||
|
||||
default: all
|
||||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
include TestFilesCompilation.gmk
|
||||
|
||||
################################################################################
|
||||
# Targets for building the native tests themselves.
|
||||
################################################################################
|
||||
|
||||
# Add more directories here when needed.
|
||||
BUILD_HOTSPOT_JTREG_NATIVE_SRC := \
|
||||
$(HOTSPOT_TOPDIR)/test/native_sanity \
|
||||
#
|
||||
|
||||
BUILD_HOTSPOT_JTREG_OUTPUT_DIR := $(BUILD_OUTPUT)/support/test/hotspot/jtreg/native
|
||||
|
||||
BUILD_HOTSPOT_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/hotspot/jtreg
|
||||
|
||||
$(eval $(call SetupTestFilesCompilation, BUILD_HOTSPOT_JTREG_LIBRARIES, \
|
||||
TYPE := LIBRARY, \
|
||||
SOURCE_DIRS := $(BUILD_HOTSPOT_JTREG_NATIVE_SRC), \
|
||||
OUTPUT_DIR := $(BUILD_HOTSPOT_JTREG_OUTPUT_DIR), \
|
||||
))
|
||||
|
||||
$(eval $(call SetupTestFilesCompilation, BUILD_HOTSPOT_JTREG_EXECUTABLES, \
|
||||
TYPE := PROGRAM, \
|
||||
SOURCE_DIRS := $(BUILD_HOTSPOT_JTREG_NATIVE_SRC), \
|
||||
OUTPUT_DIR := $(BUILD_HOTSPOT_JTREG_OUTPUT_DIR), \
|
||||
))
|
||||
|
||||
build-test-hotspot-jtreg-native: $(BUILD_HOTSPOT_JTREG_LIBRARIES) $(BUILD_HOTSPOT_JTREG_EXECUTABLES)
|
||||
|
||||
################################################################################
|
||||
# Targets for building test-image.
|
||||
################################################################################
|
||||
|
||||
# Copy to hotspot jtreg test image
|
||||
$(eval $(call SetupCopyFiles,COPY_HOTSPOT_JTREG_NATIVE, \
|
||||
SRC := $(BUILD_HOTSPOT_JTREG_OUTPUT_DIR), \
|
||||
DEST := $(TEST_IMAGE_DIR)/hotspot/jtreg/native, \
|
||||
FILES := $(BUILD_HOTSPOT_JTREG_LIBRARIES) $(BUILD_HOTSPOT_JTREG_EXECUTABLES), \
|
||||
FLATTEN := true))
|
||||
|
||||
test-image-hotspot-jtreg-native: $(COPY_HOTSPOT_JTREG_NATIVE)
|
||||
|
||||
all: build-test-hotspot-jtreg-native
|
||||
test-image: test-image-hotspot-jtreg-native
|
||||
|
||||
.PHONY: default all build-test-hotspot-jtreg-native test-image-hotspot-jtreg-native test-image
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 1995, 2015, 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
|
||||
@ -143,11 +143,24 @@ ifndef PRODUCT_HOME
|
||||
endif
|
||||
|
||||
# Expect JPRT to set JAVA_ARGS (e.g. -server etc.)
|
||||
JAVA_OPTIONS =
|
||||
JAVA_OPTIONS =
|
||||
ifdef JAVA_ARGS
|
||||
JAVA_OPTIONS = $(JAVA_ARGS)
|
||||
endif
|
||||
|
||||
# jtreg -nativepath <dir>
|
||||
#
|
||||
# Local make tests will be TEST_IMAGE_DIR and JPRT with jprt.use.reg.test.bundle=true
|
||||
# should be JPRT_TESTNATIVE_PATH
|
||||
ifdef TEST_IMAGE_DIR
|
||||
TESTNATIVE_DIR = $(TEST_IMAGE_DIR)
|
||||
else ifdef JPRT_TESTNATIVE_PATH
|
||||
TESTNATIVE_DIR = $(JPRT_TESTNATIVE_PATH)
|
||||
endif
|
||||
ifdef TESTNATIVE_DIR
|
||||
JTREG_NATIVE_PATH = -nativepath:$(shell $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/hotspot/jtreg/native")
|
||||
endif
|
||||
|
||||
# Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
|
||||
ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip
|
||||
ifdef JPRT_ARCHIVE_BUNDLE
|
||||
@ -303,6 +316,7 @@ jtreg_tests: prep $(PRODUCT_HOME) $(JTREG)
|
||||
-r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport") \
|
||||
-w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork") \
|
||||
-jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \
|
||||
$(JTREG_NATIVE_PATH) \
|
||||
$(JTREG_EXCLUSIONS) \
|
||||
$(JTREG_TEST_OPTIONS) \
|
||||
$(TEST_SELECTION) \
|
||||
@ -313,7 +327,7 @@ jtreg_tests: prep $(PRODUCT_HOME) $(JTREG)
|
||||
PHONY_LIST += jtreg_tests
|
||||
|
||||
# flags used to execute java in test targets
|
||||
TEST_FLAGS += -version -Xinternalversion -X -help
|
||||
TEST_FLAGS += -version -Xinternalversion -X -help
|
||||
|
||||
sanitytest: prep $(PRODUCT_HOME)
|
||||
@for flag in $(TEST_FLAGS); \
|
||||
|
@ -332,6 +332,9 @@ applicable_cmsgc = \
|
||||
hotspot_wbapitest = \
|
||||
sanity/
|
||||
|
||||
hotspot_native_sanity = \
|
||||
native_sanity
|
||||
|
||||
hotspot_compiler_1 = \
|
||||
compiler/arraycopy/ \
|
||||
compiler/c1/ \
|
||||
|
41
hotspot/test/native_sanity/JniVersion.java
Normal file
41
hotspot/test/native_sanity/JniVersion.java
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @run main/native JniVersion
|
||||
*/
|
||||
public class JniVersion {
|
||||
|
||||
public static final int JNI_VERSION_1_8 = 0x00010008;
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
System.loadLibrary("JniVersion");
|
||||
int res = getJniVersion();
|
||||
if (res < JNI_VERSION_1_8) {
|
||||
throw new Exception("Unexpected value returned from getJniVersion(): 0x" + Integer.toHexString(res));
|
||||
}
|
||||
}
|
||||
|
||||
static native int getJniVersion();
|
||||
}
|
29
hotspot/test/native_sanity/libJniVersion.c
Normal file
29
hotspot/test/native_sanity/libJniVersion.c
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_JniVersion_getJniVersion(JNIEnv *env, jclass clz) {
|
||||
return (*env)->GetVersion(env);
|
||||
}
|
@ -294,3 +294,4 @@ e391de88e69b59d7c618387e3cf91032f6991ce9 jdk9-b47
|
||||
786058752e0ac3e48d7aef79e0885d29d6a2a7eb jdk9-b49
|
||||
74ead7bddde19263fd463bc1bd87de84f27d1b5e jdk9-b50
|
||||
7cb3674cbd8c06222851444285bb66b2952a2a5c jdk9-b51
|
||||
57b26c883d54f45912bc3885ccad3c6b80960b1f jdk9-b52
|
||||
|
@ -297,3 +297,4 @@ e529374fbe526dbd668e5e98fc047b42b3bc6d33 jdk9-b45
|
||||
435a49db1de0589acc86b2cc5fd61d546f94b56c jdk9-b49
|
||||
45a30e7ee623031a1532685512dd2c2d8e8fa0ad jdk9-b50
|
||||
bb9cf97a5ac6aa1aa2a1034676d64413071f58ea jdk9-b51
|
||||
1d1e7704eca9c77ebe6a8705d17ac568801f7a3b jdk9-b52
|
||||
|
@ -30,6 +30,8 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.logging.Level;
|
||||
@ -85,19 +87,25 @@ public final class ClassFactory {
|
||||
if(consRef!=null)
|
||||
cons = consRef.get();
|
||||
if(cons==null) {
|
||||
try {
|
||||
cons = clazz.getDeclaredConstructor(emptyClass);
|
||||
} catch (NoSuchMethodException e) {
|
||||
logger.log(Level.INFO,"No default constructor found on "+clazz,e);
|
||||
NoSuchMethodError exp;
|
||||
if(clazz.getDeclaringClass()!=null && !Modifier.isStatic(clazz.getModifiers())) {
|
||||
exp = new NoSuchMethodError(Messages.NO_DEFAULT_CONSTRUCTOR_IN_INNER_CLASS.format(clazz.getName()));
|
||||
} else {
|
||||
exp = new NoSuchMethodError(e.getMessage());
|
||||
cons = AccessController.doPrivileged(new PrivilegedAction<Constructor<T>>() {
|
||||
@Override
|
||||
public Constructor<T> run() {
|
||||
try {
|
||||
return clazz.getDeclaredConstructor(emptyClass);
|
||||
} catch (NoSuchMethodException e) {
|
||||
logger.log(Level.INFO,"No default constructor found on "+clazz,e);
|
||||
NoSuchMethodError exp;
|
||||
if(clazz.getDeclaringClass()!=null && !Modifier.isStatic(clazz.getModifiers())) {
|
||||
exp = new NoSuchMethodError(Messages.NO_DEFAULT_CONSTRUCTOR_IN_INNER_CLASS
|
||||
.format(clazz.getName()));
|
||||
} else {
|
||||
exp = new NoSuchMethodError(e.getMessage());
|
||||
}
|
||||
exp.initCause(e);
|
||||
throw exp;
|
||||
}
|
||||
}
|
||||
exp.initCause(e);
|
||||
throw exp;
|
||||
}
|
||||
});
|
||||
|
||||
int classMod = clazz.getModifiers();
|
||||
|
||||
|
@ -36,9 +36,6 @@ import com.sun.xml.internal.bind.marshaller.SAX2DOMEx;
|
||||
//TODO DOMHeader DOMMessage SAAJMessage StatefulInstanceResolver
|
||||
import com.sun.xml.internal.bind.unmarshaller.DOMScanner;
|
||||
|
||||
//TODO MtomCodec
|
||||
import com.sun.xml.internal.bind.v2.runtime.output.Encoded;
|
||||
|
||||
//TODO ExceptionBean
|
||||
import com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper;
|
||||
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
package com.sun.tools.internal.ws.wsdl.document.soap;
|
||||
|
||||
import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
@ -37,7 +35,9 @@ import javax.xml.namespace.QName;
|
||||
public interface SOAPConstants {
|
||||
|
||||
// namespace URIs
|
||||
public static final String URI_ENVELOPE = SOAPNamespaceConstants.ENVELOPE;
|
||||
public static final String URI_ENVELOPE =
|
||||
"http://schemas.xmlsoap.org/soap/envelope/";
|
||||
|
||||
public static final String NS_WSDL_SOAP =
|
||||
"http://schemas.xmlsoap.org/wsdl/soap/";
|
||||
public static final String NS_SOAP_ENCODING = "http://schemas.xmlsoap.org/soap/encoding/";
|
||||
|
@ -294,3 +294,4 @@ ebb2eb7f1aec78eb6d8cc4c96f018afa11093cde jdk9-b48
|
||||
541a8cef4e0d54c3e4b52a98c6af3c31e2096669 jdk9-b49
|
||||
f6b8edd397ee463be208fee27517c99101293267 jdk9-b50
|
||||
a0dad230aeb3b0d5cfd5b0715029e48d50573f8c jdk9-b51
|
||||
607ea68032cd4a4cf2c7a7a41fcb39602d6a75e2 jdk9-b52
|
||||
|
1
jdk/make/data/charsetmapping/IBM1166.c2b
Normal file
1
jdk/make/data/charsetmapping/IBM1166.c2b
Normal file
@ -0,0 +1 @@
|
||||
0x15 U+0085
|
256
jdk/make/data/charsetmapping/IBM1166.map
Normal file
256
jdk/make/data/charsetmapping/IBM1166.map
Normal file
@ -0,0 +1,256 @@
|
||||
0x00 U+0000
|
||||
0x01 U+0001
|
||||
0x02 U+0002
|
||||
0x03 U+0003
|
||||
0x04 U+009c
|
||||
0x05 U+0009
|
||||
0x06 U+0086
|
||||
0x07 U+007f
|
||||
0x08 U+0097
|
||||
0x09 U+008d
|
||||
0x0a U+008e
|
||||
0x0b U+000b
|
||||
0x0c U+000c
|
||||
0x0d U+000d
|
||||
0x0e U+000e
|
||||
0x0f U+000f
|
||||
0x10 U+0010
|
||||
0x11 U+0011
|
||||
0x12 U+0012
|
||||
0x13 U+0013
|
||||
0x14 U+009d
|
||||
0x15 U+000a
|
||||
0x16 U+0008
|
||||
0x17 U+0087
|
||||
0x18 U+0018
|
||||
0x19 U+0019
|
||||
0x1a U+0092
|
||||
0x1b U+008f
|
||||
0x1c U+001c
|
||||
0x1d U+001d
|
||||
0x1e U+001e
|
||||
0x1f U+001f
|
||||
0x20 U+0080
|
||||
0x21 U+0081
|
||||
0x22 U+0082
|
||||
0x23 U+0083
|
||||
0x24 U+0084
|
||||
0x25 U+000a
|
||||
0x26 U+0017
|
||||
0x27 U+001b
|
||||
0x28 U+0088
|
||||
0x29 U+0089
|
||||
0x2a U+008a
|
||||
0x2b U+008b
|
||||
0x2c U+008c
|
||||
0x2d U+0005
|
||||
0x2e U+0006
|
||||
0x2f U+0007
|
||||
0x30 U+0090
|
||||
0x31 U+0091
|
||||
0x32 U+0016
|
||||
0x33 U+0093
|
||||
0x34 U+0094
|
||||
0x35 U+0095
|
||||
0x36 U+0096
|
||||
0x37 U+0004
|
||||
0x38 U+0098
|
||||
0x39 U+0099
|
||||
0x3a U+009a
|
||||
0x3b U+009b
|
||||
0x3c U+0014
|
||||
0x3d U+0015
|
||||
0x3e U+009e
|
||||
0x3f U+001a
|
||||
0x40 U+0020
|
||||
0x41 U+00a0
|
||||
0x42 U+04d9
|
||||
0x43 U+0493
|
||||
0x44 U+0451
|
||||
0x45 U+0454
|
||||
0x46 U+0455
|
||||
0x47 U+0456
|
||||
0x48 U+049b
|
||||
0x49 U+0458
|
||||
0x4a U+005b
|
||||
0x4b U+002e
|
||||
0x4c U+003c
|
||||
0x4d U+0028
|
||||
0x4e U+002b
|
||||
0x4f U+0021
|
||||
0x50 U+0026
|
||||
0x51 U+04a3
|
||||
0x52 U+04e9
|
||||
0x53 U+04b1
|
||||
0x54 U+04af
|
||||
0x55 U+045e
|
||||
0x56 U+04bb
|
||||
0x57 U+042a
|
||||
0x58 U+2116
|
||||
0x59 U+04d8
|
||||
0x5a U+005d
|
||||
0x5b U+0024
|
||||
0x5c U+002a
|
||||
0x5d U+0029
|
||||
0x5e U+003b
|
||||
0x5f U+005e
|
||||
0x60 U+002d
|
||||
0x61 U+002f
|
||||
0x62 U+0492
|
||||
0x63 U+0401
|
||||
0x64 U+0404
|
||||
0x65 U+0405
|
||||
0x66 U+0406
|
||||
0x67 U+049a
|
||||
0x68 U+0408
|
||||
0x69 U+04a2
|
||||
0x6a U+007c
|
||||
0x6b U+002c
|
||||
0x6c U+0025
|
||||
0x6d U+005f
|
||||
0x6e U+003e
|
||||
0x6f U+003f
|
||||
0x70 U+04e8
|
||||
0x71 U+04b0
|
||||
0x72 U+04ae
|
||||
0x73 U+00ad
|
||||
0x74 U+040e
|
||||
0x75 U+04ba
|
||||
0x76 U+044e
|
||||
0x77 U+0430
|
||||
0x78 U+0431
|
||||
0x79 U+0060
|
||||
0x7a U+003a
|
||||
0x7b U+0023
|
||||
0x7c U+0040
|
||||
0x7d U+0027
|
||||
0x7e U+003d
|
||||
0x7f U+0022
|
||||
0x80 U+0446
|
||||
0x81 U+0061
|
||||
0x82 U+0062
|
||||
0x83 U+0063
|
||||
0x84 U+0064
|
||||
0x85 U+0065
|
||||
0x86 U+0066
|
||||
0x87 U+0067
|
||||
0x88 U+0068
|
||||
0x89 U+0069
|
||||
0x8a U+0434
|
||||
0x8b U+0435
|
||||
0x8c U+0444
|
||||
0x8d U+0433
|
||||
0x8e U+0445
|
||||
0x8f U+0438
|
||||
0x90 U+0439
|
||||
0x91 U+006a
|
||||
0x92 U+006b
|
||||
0x93 U+006c
|
||||
0x94 U+006d
|
||||
0x95 U+006e
|
||||
0x96 U+006f
|
||||
0x97 U+0070
|
||||
0x98 U+0071
|
||||
0x99 U+0072
|
||||
0x9a U+043a
|
||||
0x9b U+043b
|
||||
0x9c U+043c
|
||||
0x9d U+043d
|
||||
0x9e U+043e
|
||||
0x9f U+043f
|
||||
0xa0 U+044f
|
||||
0xa1 U+007e
|
||||
0xa2 U+0073
|
||||
0xa3 U+0074
|
||||
0xa4 U+0075
|
||||
0xa5 U+0076
|
||||
0xa6 U+0077
|
||||
0xa7 U+0078
|
||||
0xa8 U+0079
|
||||
0xa9 U+007a
|
||||
0xaa U+0440
|
||||
0xab U+0441
|
||||
0xac U+0442
|
||||
0xad U+0443
|
||||
0xae U+0436
|
||||
0xaf U+0432
|
||||
0xb0 U+044c
|
||||
0xb1 U+044b
|
||||
0xb2 U+0437
|
||||
0xb3 U+0448
|
||||
0xb4 U+044d
|
||||
0xb5 U+0449
|
||||
0xb6 U+0447
|
||||
0xb7 U+044a
|
||||
0xb8 U+042e
|
||||
0xb9 U+0410
|
||||
0xba U+0411
|
||||
0xbb U+0426
|
||||
0xbc U+0414
|
||||
0xbd U+0415
|
||||
0xbe U+0424
|
||||
0xbf U+0413
|
||||
0xc0 U+007b
|
||||
0xc1 U+0041
|
||||
0xc2 U+0042
|
||||
0xc3 U+0043
|
||||
0xc4 U+0044
|
||||
0xc5 U+0045
|
||||
0xc6 U+0046
|
||||
0xc7 U+0047
|
||||
0xc8 U+0048
|
||||
0xc9 U+0049
|
||||
0xca U+0425
|
||||
0xcb U+0418
|
||||
0xcc U+0419
|
||||
0xcd U+041a
|
||||
0xce U+041b
|
||||
0xcf U+041c
|
||||
0xd0 U+007d
|
||||
0xd1 U+004a
|
||||
0xd2 U+004b
|
||||
0xd3 U+004c
|
||||
0xd4 U+004d
|
||||
0xd5 U+004e
|
||||
0xd6 U+004f
|
||||
0xd7 U+0050
|
||||
0xd8 U+0051
|
||||
0xd9 U+0052
|
||||
0xda U+041d
|
||||
0xdb U+041e
|
||||
0xdc U+041f
|
||||
0xdd U+042f
|
||||
0xde U+0420
|
||||
0xdf U+0421
|
||||
0xe0 U+005c
|
||||
0xe1 U+20ac
|
||||
0xe2 U+0053
|
||||
0xe3 U+0054
|
||||
0xe4 U+0055
|
||||
0xe5 U+0056
|
||||
0xe6 U+0057
|
||||
0xe7 U+0058
|
||||
0xe8 U+0059
|
||||
0xe9 U+005a
|
||||
0xea U+0422
|
||||
0xeb U+0423
|
||||
0xec U+0416
|
||||
0xed U+0412
|
||||
0xee U+042c
|
||||
0xef U+042b
|
||||
0xf0 U+0030
|
||||
0xf1 U+0031
|
||||
0xf2 U+0032
|
||||
0xf3 U+0033
|
||||
0xf4 U+0034
|
||||
0xf5 U+0035
|
||||
0xf6 U+0036
|
||||
0xf7 U+0037
|
||||
0xf8 U+0038
|
||||
0xf9 U+0039
|
||||
0xfa U+0417
|
||||
0xfb U+0428
|
||||
0xfc U+042d
|
||||
0xfd U+0429
|
||||
0xfe U+0427
|
||||
0xff U+009f
|
1
jdk/make/data/charsetmapping/IBM1166.nr
Normal file
1
jdk/make/data/charsetmapping/IBM1166.nr
Normal file
@ -0,0 +1 @@
|
||||
0x25 U+000a
|
@ -503,7 +503,7 @@ charset x-windows-874 MS874
|
||||
|
||||
charset x-EUC-TW EUC_TW
|
||||
package sun.nio.cs.ext
|
||||
type source
|
||||
type template
|
||||
alias euc_tw # JDK historical
|
||||
alias euctw
|
||||
alias cns11643
|
||||
@ -1660,6 +1660,16 @@ charset IBM290 IBM290
|
||||
alias EBCDIC-JP-kana
|
||||
alias 290
|
||||
|
||||
charset x-IBM1166 IBM1166
|
||||
package sun.nio.cs.ext
|
||||
type sbcs
|
||||
hisname Cp1166
|
||||
ascii false
|
||||
alias cp1166
|
||||
alias ibm1166
|
||||
alias ibm-1166
|
||||
alias 1166
|
||||
|
||||
charset x-IBM300 IBM300
|
||||
package sun.nio.cs.ext
|
||||
type dbcsonly
|
||||
@ -1816,3 +1826,17 @@ charset x-JIS0212_MS5022X JIS_X_0212_MS5022X
|
||||
ascii false
|
||||
minmax 0x21 0x7e 0x21 0x7e
|
||||
internal true # "internal implementation
|
||||
|
||||
########################################################
|
||||
#
|
||||
# platform specific charsets, to be registered into spi
|
||||
##
|
||||
########################################################
|
||||
|
||||
charset x-COMPOUND_TEXT COMPOUND_TEXT
|
||||
package sun.nio.cs.ext
|
||||
type source
|
||||
os unix
|
||||
alias COMPOUND_TEXT # JDK historical
|
||||
alias x11-compound_text
|
||||
alias x-compound-text
|
||||
|
@ -57,6 +57,7 @@ IBM1146 IBM01146 Cp1146 false sun.nio.cs.ext
|
||||
IBM1147 IBM01147 Cp1147 false sun.nio.cs.ext
|
||||
IBM1148 IBM01148 Cp1148 false sun.nio.cs.ext
|
||||
IBM1149 IBM01149 Cp1149 false sun.nio.cs.ext
|
||||
IBM1166 x-IBM1166 Cp1166 false sun.nio.cs.ext
|
||||
IBM273 IBM273 Cp273 false sun.nio.cs.ext
|
||||
IBM277 IBM277 Cp277 false sun.nio.cs.ext
|
||||
IBM278 IBM278 Cp278 false sun.nio.cs.ext
|
||||
|
@ -9,6 +9,7 @@ EUC_KR
|
||||
EUC_JP
|
||||
EUC_JP_LINUX
|
||||
EUC_JP_Open
|
||||
EUC_TW
|
||||
GBK
|
||||
ISO_8859_11
|
||||
ISO_8859_3
|
||||
|
@ -50,7 +50,9 @@ $(CHARSET_DONE_CS)-extcs: $(CHARSET_DATA_DIR)/charsets \
|
||||
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_CS) \
|
||||
extcs charsets $(CHARSET_STANDARD_OS) \
|
||||
$(CHARSET_EXTENDED_JAVA_TEMPLATES) \
|
||||
$(CHARSET_EXTENDED_JAVA_DIR) $(LOG_INFO)
|
||||
$(CHARSET_EXTENDED_JAVA_DIR) \
|
||||
$(CHARSET_COPYRIGHT_HEADER) \
|
||||
$(LOG_INFO)
|
||||
$(TOUCH) '$@'
|
||||
|
||||
$(CHARSET_DONE_CS)-hkscs: $(CHARSET_COPYRIGHT_HEADER)/HKSCS.java \
|
||||
|
@ -32,6 +32,7 @@ CHARSET_DATA_DIR := $(JDK_TOPDIR)/make/data/charsetmapping
|
||||
CHARSET_EXTSRC_DIR := $(JDK_TOPDIR)/src/jdk.charsets/share/classes/sun/nio/cs/ext
|
||||
CHARSET_GENSRC_JAVA_DIR_BASE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/cs
|
||||
CHARSET_DONE_BASE := $(CHARSET_GENSRC_JAVA_DIR_BASE)/_the.charsetmapping
|
||||
CHARSET_COPYRIGHT_HEADER := $(JDK_TOPDIR)/make/src/classes/build/tools/charsetmapping
|
||||
CHARSET_TEMPLATES := \
|
||||
$(CHARSET_DATA_DIR)/SingleByte-X.java.template \
|
||||
$(CHARSET_DATA_DIR)/DoubleByte-X.java.template
|
||||
@ -46,7 +47,9 @@ $(CHARSET_DONE_BASE)-stdcs: $(CHARSET_DATA_DIR)/charsets \
|
||||
$(MKDIR) -p $(@D)
|
||||
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_BASE) \
|
||||
stdcs charsets $(CHARSET_STANDARD_OS) \
|
||||
$(CHARSET_STANDARD_JAVA_TEMPLATES) $(CHARSET_EXTSRC_DIR) $(LOG_INFO)
|
||||
$(CHARSET_STANDARD_JAVA_TEMPLATES) $(CHARSET_EXTSRC_DIR) \
|
||||
$(CHARSET_COPYRIGHT_HEADER) \
|
||||
$(LOG_INFO)
|
||||
$(TOUCH) '$@'
|
||||
|
||||
GENSRC_JAVA_BASE += $(CHARSET_DONE_BASE)-stdcs
|
||||
|
@ -53,15 +53,21 @@ endef
|
||||
# Param 1 - Variable to add targets to, must not contain space
|
||||
# Param 2 - Properties files to process
|
||||
# Param 3 - The super class for the generated classes
|
||||
# Param 4 - Module path root, defaults to $(JDK_TOPDIR)/src
|
||||
define SetupCompileProperties
|
||||
$1_SRCS := $2
|
||||
$1_CLASS := $3
|
||||
$1_MODULE_PATH_ROOT := $4
|
||||
|
||||
ifeq ($$($1_MODULE_PATH_ROOT), )
|
||||
$1_MODULE_PATH_ROOT := $(JDK_TOPDIR)/src
|
||||
endif
|
||||
|
||||
# Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
|
||||
# to .../support/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
|
||||
# Strip away prefix and suffix, leaving for example only:
|
||||
# "<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN"
|
||||
$1_JAVAS := $$(patsubst $(JDK_TOPDIR)/src/%, \
|
||||
$1_JAVAS := $$(patsubst $$($1_MODULE_PATH_ROOT)/%, \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/%, \
|
||||
$$(patsubst %.properties, %.java, \
|
||||
$$(subst /$(OPENJDK_TARGET_OS)/classes,, \
|
||||
|
@ -31,6 +31,7 @@ class Charset {
|
||||
String csName;
|
||||
String hisName;
|
||||
String type;
|
||||
String os;
|
||||
boolean isASCII;
|
||||
int b1Min;
|
||||
int b1Max;
|
||||
|
@ -80,12 +80,12 @@ public class EUC_TW {
|
||||
|
||||
private static Pattern euctw = Pattern.compile("(?:8ea)?(\\p{XDigit}++)\\s++(\\p{XDigit}++)?\\s*+.*");
|
||||
|
||||
static void genClass(String args[]) throws Exception
|
||||
static void genClass(String pkg, String args[]) throws Exception
|
||||
{
|
||||
InputStream is = new FileInputStream(new File(args[0], "euc_tw.map"));
|
||||
PrintStream ps = new PrintStream(new File(args[1], "EUC_TWMapping.java"),
|
||||
"ISO-8859-1");
|
||||
String copyright = getCopyright(new File(args[3]));
|
||||
String copyright = getCopyright(new File(args[7], "EUC_TW.java"));
|
||||
|
||||
|
||||
// ranges of byte1 and byte2, something should come from a "config" file
|
||||
@ -128,7 +128,7 @@ public class EUC_TW {
|
||||
|
||||
out.format(copyright);
|
||||
out.format("%n// -- This file was mechanically generated: Do not edit! -- //%n");
|
||||
out.format("package sun.nio.cs.ext;%n%n");
|
||||
out.format("package %s;%n%n", pkg);
|
||||
out.format("class EUC_TWMapping {%n%n");
|
||||
|
||||
// boundaries
|
||||
|
@ -42,7 +42,7 @@ public class HKSCS {
|
||||
private static Pattern hkscs =
|
||||
Pattern.compile("(?:0x)?+(\\p{XDigit}++)\\s++(?:0x|U\\+)?+(\\p{XDigit}++)?\\s*+(?:0x|U\\+)?(\\p{XDigit}++)?\\s*+.*");
|
||||
|
||||
static void genClass2008(String srcDir, String dstDir, String pkgName)
|
||||
static void genClass2008(String srcDir, String dstDir, String pkgName, File copyright)
|
||||
throws Exception
|
||||
{
|
||||
// hkscs2008
|
||||
@ -53,10 +53,11 @@ public class HKSCS {
|
||||
pkgName,
|
||||
"HKSCSMapping",
|
||||
true,
|
||||
"");
|
||||
getCopyright(copyright));
|
||||
|
||||
}
|
||||
|
||||
static void genClassXP(String srcDir, String dstDir, String pkgName)
|
||||
static void genClassXP(String srcDir, String dstDir, String pkgName, File copyright)
|
||||
throws Exception
|
||||
{
|
||||
genClass0(new FileInputStream(new File(srcDir, "HKSCS_XP.map")),
|
||||
@ -66,7 +67,7 @@ public class HKSCS {
|
||||
pkgName,
|
||||
"HKSCS_XPMapping",
|
||||
false,
|
||||
"");
|
||||
getCopyright(copyright));
|
||||
}
|
||||
|
||||
static void genClass2001(String args[]) throws Exception {
|
||||
|
@ -41,6 +41,7 @@ public class Main {
|
||||
int OS = 4;
|
||||
int TEMPLATE = 5;
|
||||
int EXT_SRC = 6;
|
||||
int COPYRIGHT_SRC = 7;
|
||||
|
||||
if (args.length < 3 ) {
|
||||
System.out.println("Usage: java -jar charsetmapping.jar src dst spiType charsets os [template]");
|
||||
@ -54,6 +55,7 @@ public class Main {
|
||||
String[] osStdcs = getOSStdCSList(new File(args[SRC_DIR], args[OS]));
|
||||
boolean hasBig5_HKSCS = false;
|
||||
boolean hasMS950_HKSCS_XP = false;
|
||||
boolean hasEUC_TW = false;
|
||||
for (String name : osStdcs) {
|
||||
Charset cs = charsets.get(name);
|
||||
if (cs != null) {
|
||||
@ -63,6 +65,8 @@ public class Main {
|
||||
hasBig5_HKSCS = true;
|
||||
} else if (name.equals("MS950_HKSCS_XP")) {
|
||||
hasMS950_HKSCS_XP = true;
|
||||
} else if (name.equals("EUC_TW")) {
|
||||
hasEUC_TW = true;
|
||||
}
|
||||
}
|
||||
for (Charset cs : charsets.values()) {
|
||||
@ -89,19 +93,28 @@ public class Main {
|
||||
}
|
||||
}
|
||||
// provider StandardCharsets.java / ExtendedCharsets.java
|
||||
SPI.genClass(args[TYPE], charsets, args[SRC_DIR], args[DST_DIR], args[TEMPLATE]);
|
||||
SPI.genClass(args[TYPE], charsets,
|
||||
args[SRC_DIR], args[DST_DIR],
|
||||
args[TEMPLATE],
|
||||
args[OS].endsWith("windows") ? "windows" : "unix");
|
||||
|
||||
// HKSCSMapping2008/XP.java goes together with Big5/MS950XP_HKSCS
|
||||
if (isStandard && hasBig5_HKSCS || isExtended && !hasBig5_HKSCS) {
|
||||
HKSCS.genClass2008(args[SRC_DIR], args[DST_DIR],
|
||||
isStandard ? "sun.nio.cs" : "sun.nio.cs.ext");
|
||||
isStandard ? "sun.nio.cs" : "sun.nio.cs.ext",
|
||||
new File(args[COPYRIGHT_SRC], "HKSCS.java"));
|
||||
}
|
||||
if (isStandard && hasMS950_HKSCS_XP || isExtended && !hasMS950_HKSCS_XP) {
|
||||
HKSCS.genClassXP(args[SRC_DIR], args[DST_DIR],
|
||||
isStandard ? "sun.nio.cs" : "sun.nio.cs.ext");
|
||||
isStandard ? "sun.nio.cs" : "sun.nio.cs.ext",
|
||||
new File(args[COPYRIGHT_SRC], "HKSCS.java"));
|
||||
}
|
||||
if (isStandard && hasEUC_TW) {
|
||||
EUC_TW.genClass("sun.nio.cs", args);
|
||||
}
|
||||
if (!isStandard && !hasEUC_TW) {
|
||||
EUC_TW.genClass("sun.nio.cs.ext", args);
|
||||
}
|
||||
} else if ("euctw".equals(args[TYPE])) {
|
||||
EUC_TW.genClass(args);
|
||||
} else if ("sjis0213".equals(args[TYPE])) {
|
||||
JIS0213.genClass(args);
|
||||
} else if ("hkscs".equals(args[TYPE])) {
|
||||
@ -157,6 +170,9 @@ public class Main {
|
||||
case "type":
|
||||
cs.type = tokens[2];
|
||||
break;
|
||||
case "os":
|
||||
cs.os = tokens[2];
|
||||
break;
|
||||
case "hisname":
|
||||
cs.hisName = tokens[2];
|
||||
break;
|
||||
|
@ -33,8 +33,10 @@ import java.util.Scanner;
|
||||
|
||||
public class SPI {
|
||||
|
||||
public static void genClass(String type, LinkedHashMap<String, Charset> charsets,
|
||||
String srcDir, String dstDir, String template)
|
||||
public static void genClass(String type,
|
||||
LinkedHashMap<String, Charset> charsets,
|
||||
String srcDir, String dstDir, String template,
|
||||
String os)
|
||||
throws Exception
|
||||
{
|
||||
try (Scanner s = new Scanner(new File(template));
|
||||
@ -50,7 +52,8 @@ public class SPI {
|
||||
charsets.values()
|
||||
.stream()
|
||||
.filter(cs -> cs.pkgName.equals("sun.nio.cs.ext") &&
|
||||
!cs.isInternal)
|
||||
!cs.isInternal &&
|
||||
(cs.os == null || cs.os.equals(os)))
|
||||
.forEach( cs -> {
|
||||
out.printf(" charset(\"%s\", \"%s\",%n", cs.csName, cs.clzName);
|
||||
out.printf(" new String[] {%n");
|
||||
|
@ -1063,16 +1063,24 @@ public final class Class<T> implements java.io.Serializable,
|
||||
parameterClasses[i] = toClass(parameterTypes[i]);
|
||||
|
||||
// Perform access check
|
||||
Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
|
||||
final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
|
||||
enclosingCandidate.checkMemberAccess(Member.DECLARED,
|
||||
Reflection.getCallerClass(), true);
|
||||
// Client is ok to access declared methods but j.l.Class might not be.
|
||||
Method[] candidates = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Method[]>() {
|
||||
@Override
|
||||
public Method[] run() {
|
||||
return enclosingCandidate.getDeclaredMethods();
|
||||
}
|
||||
});
|
||||
/*
|
||||
* Loop over all declared methods; match method name,
|
||||
* number of and type of parameters, *and* return
|
||||
* type. Matching return type is also necessary
|
||||
* because of covariant returns, etc.
|
||||
*/
|
||||
for(Method m: enclosingCandidate.getDeclaredMethods()) {
|
||||
for(Method m: candidates) {
|
||||
if (m.getName().equals(enclosingInfo.getName()) ) {
|
||||
Class<?>[] candidateParamClasses = m.getParameterTypes();
|
||||
if (candidateParamClasses.length == parameterClasses.length) {
|
||||
@ -1215,14 +1223,22 @@ public final class Class<T> implements java.io.Serializable,
|
||||
parameterClasses[i] = toClass(parameterTypes[i]);
|
||||
|
||||
// Perform access check
|
||||
Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
|
||||
final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
|
||||
enclosingCandidate.checkMemberAccess(Member.DECLARED,
|
||||
Reflection.getCallerClass(), true);
|
||||
// Client is ok to access declared methods but j.l.Class might not be.
|
||||
Constructor<?>[] candidates = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Constructor<?>[]>() {
|
||||
@Override
|
||||
public Constructor<?>[] run() {
|
||||
return enclosingCandidate.getDeclaredConstructors();
|
||||
}
|
||||
});
|
||||
/*
|
||||
* Loop over all declared constructors; match number
|
||||
* of and type of parameters.
|
||||
*/
|
||||
for(Constructor<?> c: enclosingCandidate.getDeclaredConstructors()) {
|
||||
for(Constructor<?> c: candidates) {
|
||||
Class<?>[] candidateParamClasses = c.getParameterTypes();
|
||||
if (candidateParamClasses.length == parameterClasses.length) {
|
||||
boolean matches = true;
|
||||
|
@ -35,6 +35,7 @@ import static java.lang.invoke.MethodTypeForm.*;
|
||||
import static java.lang.invoke.MethodHandleStatics.*;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Objects;
|
||||
import sun.invoke.util.ValueConversions;
|
||||
import sun.invoke.util.VerifyType;
|
||||
import sun.invoke.util.Wrapper;
|
||||
@ -439,8 +440,7 @@ class DirectMethodHandle extends MethodHandle {
|
||||
// Therefore, the only remaining check is for null.
|
||||
// Since this check is *not* guaranteed by Unsafe.getInt
|
||||
// and its siblings, we need to make an explicit one here.
|
||||
obj.getClass(); // maybe throw NPE
|
||||
return obj;
|
||||
return Objects.requireNonNull(obj);
|
||||
}
|
||||
|
||||
/** This subclass handles static field references. */
|
||||
@ -468,8 +468,7 @@ class DirectMethodHandle extends MethodHandle {
|
||||
|
||||
@ForceInline
|
||||
/*non-public*/ static Object nullCheck(Object obj) {
|
||||
obj.getClass();
|
||||
return obj;
|
||||
return Objects.requireNonNull(obj);
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
|
@ -521,7 +521,7 @@ import java.util.Objects;
|
||||
}
|
||||
@SuppressWarnings("LeakingThisInConstructor")
|
||||
public MemberName(Method m, boolean wantSpecial) {
|
||||
m.getClass(); // NPE check
|
||||
Objects.requireNonNull(m);
|
||||
// fill in vmtarget, vmindex while we have m in hand:
|
||||
MethodHandleNatives.init(this, m);
|
||||
if (clazz == null) { // MHN.init failed
|
||||
@ -600,7 +600,7 @@ import java.util.Objects;
|
||||
/** Create a name for the given reflected constructor. The resulting name will be in a resolved state. */
|
||||
@SuppressWarnings("LeakingThisInConstructor")
|
||||
public MemberName(Constructor<?> ctor) {
|
||||
ctor.getClass(); // NPE check
|
||||
Objects.requireNonNull(ctor);
|
||||
// fill in vmtarget, vmindex while we have ctor in hand:
|
||||
MethodHandleNatives.init(this, ctor);
|
||||
assert(isResolved() && this.clazz != null);
|
||||
@ -615,7 +615,7 @@ import java.util.Objects;
|
||||
}
|
||||
@SuppressWarnings("LeakingThisInConstructor")
|
||||
public MemberName(Field fld, boolean makeSetter) {
|
||||
fld.getClass(); // NPE check
|
||||
Objects.requireNonNull(fld);
|
||||
// fill in vmtarget, vmindex while we have fld in hand:
|
||||
MethodHandleNatives.init(this, fld);
|
||||
assert(isResolved() && this.clazz != null);
|
||||
|
@ -453,10 +453,8 @@ public abstract class MethodHandle {
|
||||
*/
|
||||
// @param type type (permanently assigned) of the new method handle
|
||||
/*non-public*/ MethodHandle(MethodType type, LambdaForm form) {
|
||||
type.getClass(); // explicit NPE
|
||||
form.getClass(); // explicit NPE
|
||||
this.type = type;
|
||||
this.form = form.uncustomize();
|
||||
this.type = Objects.requireNonNull(type);
|
||||
this.form = Objects.requireNonNull(form).uncustomize();
|
||||
|
||||
this.form.prepare(); // TO DO: Try to delay this step until just before invocation.
|
||||
}
|
||||
@ -1171,7 +1169,7 @@ assertEquals("[three, thee, tee]", Arrays.toString((Object[])ls.get(0)));
|
||||
* @see #asFixedArity
|
||||
*/
|
||||
public MethodHandle asVarargsCollector(Class<?> arrayType) {
|
||||
arrayType.getClass(); // explicit NPE
|
||||
Objects.requireNonNull(arrayType);
|
||||
boolean lastMatch = asCollectorChecks(arrayType, 0);
|
||||
if (isVarargsCollector() && lastMatch)
|
||||
return this;
|
||||
|
@ -29,6 +29,7 @@ import java.lang.reflect.*;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import sun.invoke.util.ValueConversions;
|
||||
import sun.invoke.util.VerifyAccess;
|
||||
@ -632,7 +633,7 @@ public class MethodHandles {
|
||||
* @throws NullPointerException if the argument is null
|
||||
*/
|
||||
public Lookup in(Class<?> requestedLookupClass) {
|
||||
requestedLookupClass.getClass(); // null check
|
||||
Objects.requireNonNull(requestedLookupClass);
|
||||
if (allowedModes == TRUSTED) // IMPL_LOOKUP can make any lookup at all
|
||||
return new Lookup(requestedLookupClass, ALL_MODES);
|
||||
if (requestedLookupClass == this.lookupClass)
|
||||
@ -1367,16 +1368,16 @@ return mh1;
|
||||
|
||||
MemberName resolveOrFail(byte refKind, Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
|
||||
checkSymbolicClass(refc); // do this before attempting to resolve
|
||||
name.getClass(); // NPE
|
||||
type.getClass(); // NPE
|
||||
Objects.requireNonNull(name);
|
||||
Objects.requireNonNull(type);
|
||||
return IMPL_NAMES.resolveOrFail(refKind, new MemberName(refc, name, type, refKind), lookupClassOrNull(),
|
||||
NoSuchFieldException.class);
|
||||
}
|
||||
|
||||
MemberName resolveOrFail(byte refKind, Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
|
||||
checkSymbolicClass(refc); // do this before attempting to resolve
|
||||
name.getClass(); // NPE
|
||||
type.getClass(); // NPE
|
||||
Objects.requireNonNull(name);
|
||||
Objects.requireNonNull(type);
|
||||
checkMethodName(refKind, name); // NPE check on name
|
||||
return IMPL_NAMES.resolveOrFail(refKind, new MemberName(refc, name, type, refKind), lookupClassOrNull(),
|
||||
NoSuchMethodException.class);
|
||||
@ -1384,14 +1385,14 @@ return mh1;
|
||||
|
||||
MemberName resolveOrFail(byte refKind, MemberName member) throws ReflectiveOperationException {
|
||||
checkSymbolicClass(member.getDeclaringClass()); // do this before attempting to resolve
|
||||
member.getName().getClass(); // NPE
|
||||
member.getType().getClass(); // NPE
|
||||
Objects.requireNonNull(member.getName());
|
||||
Objects.requireNonNull(member.getType());
|
||||
return IMPL_NAMES.resolveOrFail(refKind, member, lookupClassOrNull(),
|
||||
ReflectiveOperationException.class);
|
||||
}
|
||||
|
||||
void checkSymbolicClass(Class<?> refc) throws IllegalAccessException {
|
||||
refc.getClass(); // NPE
|
||||
Objects.requireNonNull(refc);
|
||||
Class<?> caller = lookupClassOrNull();
|
||||
if (caller != null && !VerifyAccess.isClassAccessible(refc, caller, allowedModes))
|
||||
throw new MemberName(refc).makeAccessException("symbolic reference class is not public", this);
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
package java.lang.invoke;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
@ -275,7 +276,7 @@ public class MutableCallSite extends CallSite {
|
||||
if (sites.length == 0) return;
|
||||
STORE_BARRIER.lazySet(0);
|
||||
for (MutableCallSite site : sites) {
|
||||
site.getClass(); // trigger NPE on first null
|
||||
Objects.requireNonNull(site); // trigger NPE on first null
|
||||
}
|
||||
// FIXME: NYI
|
||||
}
|
||||
|
@ -296,7 +296,8 @@ public final class Constructor<T> extends Executable {
|
||||
* constructor has default (package) access.
|
||||
*
|
||||
* @return a string describing this {@code Constructor}
|
||||
* @jls 8.8.3. Constructor Modifiers
|
||||
* @jls 8.8.3 Constructor Modifiers
|
||||
* @jls 8.9.2 Enum Body Declarations
|
||||
*/
|
||||
public String toString() {
|
||||
return sharedToString(Modifier.constructorModifiers(),
|
||||
@ -342,7 +343,8 @@ public final class Constructor<T> extends Executable {
|
||||
* include type parameters
|
||||
*
|
||||
* @since 1.5
|
||||
* @jls 8.8.3. Constructor Modifiers
|
||||
* @jls 8.8.3 Constructor Modifiers
|
||||
* @jls 8.9.2 Enum Body Declarations
|
||||
*/
|
||||
@Override
|
||||
public String toGenericString() {
|
||||
|
@ -356,6 +356,8 @@ public final class Method extends Executable {
|
||||
* @return a string describing this {@code Method}
|
||||
*
|
||||
* @jls 8.4.3 Method Modifiers
|
||||
* @jls 9.4 Method Declarations
|
||||
* @jls 9.6.1 Annotation Type Elements
|
||||
*/
|
||||
public String toString() {
|
||||
return sharedToString(Modifier.methodModifiers(),
|
||||
@ -409,6 +411,8 @@ public final class Method extends Executable {
|
||||
* @since 1.5
|
||||
*
|
||||
* @jls 8.4.3 Method Modifiers
|
||||
* @jls 9.4 Method Declarations
|
||||
* @jls 9.6.1 Annotation Type Elements
|
||||
*/
|
||||
@Override
|
||||
public String toGenericString() {
|
||||
|
@ -388,14 +388,13 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
}
|
||||
while (iProxy.hasNext()) {
|
||||
p = iProxy.next();
|
||||
if (p == null || p == Proxy.NO_PROXY) {
|
||||
if (p == null || p.type() != Proxy.Type.SOCKS) {
|
||||
super.connect(epoint, remainingMillis(deadlineMillis));
|
||||
return;
|
||||
}
|
||||
if (p.type() != Proxy.Type.SOCKS)
|
||||
throw new SocketException("Unknown proxy type : " + p.type());
|
||||
|
||||
if (!(p.address() instanceof InetSocketAddress))
|
||||
throw new SocketException("Unknow address type for proxy: " + p);
|
||||
throw new SocketException("Unknown address type for proxy: " + p);
|
||||
// Use getHostString() to avoid reverse lookups
|
||||
server = ((InetSocketAddress) p.address()).getHostString();
|
||||
serverPort = ((InetSocketAddress) p.address()).getPort();
|
||||
@ -707,13 +706,12 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
}
|
||||
while (iProxy.hasNext()) {
|
||||
p = iProxy.next();
|
||||
if (p == null || p == Proxy.NO_PROXY) {
|
||||
if (p == null || p.type() != Proxy.Type.SOCKS) {
|
||||
return;
|
||||
}
|
||||
if (p.type() != Proxy.Type.SOCKS)
|
||||
throw new SocketException("Unknown proxy type : " + p.type());
|
||||
|
||||
if (!(p.address() instanceof InetSocketAddress))
|
||||
throw new SocketException("Unknow address type for proxy: " + p);
|
||||
throw new SocketException("Unknown address type for proxy: " + p);
|
||||
// Use getHostString() to avoid reverse lookups
|
||||
server = ((InetSocketAddress) p.address()).getHostString();
|
||||
serverPort = ((InetSocketAddress) p.address()).getPort();
|
||||
|
@ -27,8 +27,15 @@ package java.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.spi.URLStreamHandlerProvider;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Hashtable;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
/**
|
||||
@ -248,23 +255,19 @@ public final class URL implements java.io.Serializable {
|
||||
* stream protocol handler.
|
||||
* <li>If no {@code URLStreamHandlerFactory} has yet been set up,
|
||||
* or if the factory's {@code createURLStreamHandler} method
|
||||
* returns {@code null}, then the constructor finds the
|
||||
* value of the system property:
|
||||
* <blockquote><pre>
|
||||
* java.protocol.handler.pkgs
|
||||
* </pre></blockquote>
|
||||
* If the value of that system property is not {@code null},
|
||||
* it is interpreted as a list of packages separated by a vertical
|
||||
* slash character '{@code |}'. The constructor tries to load
|
||||
* the class named:
|
||||
* <blockquote><pre>
|
||||
* <<i>package</i>>.<<i>protocol</i>>.Handler
|
||||
* </pre></blockquote>
|
||||
* where <<i>package</i>> is replaced by the name of the package
|
||||
* and <<i>protocol</i>> is replaced by the name of the protocol.
|
||||
* If this class does not exist, or if the class exists but it is not
|
||||
* a subclass of {@code URLStreamHandler}, then the next package
|
||||
* in the list is tried.
|
||||
* returns {@code null}, then the {@linkplain java.util.ServiceLoader
|
||||
* ServiceLoader} mechanism is used to locate {@linkplain
|
||||
* java.net.spi.URLStreamHandlerProvider URLStreamHandlerProvider}
|
||||
* implementations using the system class
|
||||
* loader. The order that providers are located is implementation
|
||||
* specific, and an implementation is free to cache the located
|
||||
* providers. A {@linkplain java.util.ServiceConfigurationError
|
||||
* ServiceConfigurationError}, {@code Error} or {@code RuntimeException}
|
||||
* thrown from the {@code createURLStreamHandler}, if encountered, will
|
||||
* be propagated to the calling thread. The {@code
|
||||
* createURLStreamHandler} method of each provider, if instantiated, is
|
||||
* invoked, with the protocol string, until a provider returns non-null,
|
||||
* or all providers have been exhausted.
|
||||
* <li>If the previous step fails to find a protocol handler, then the
|
||||
* constructor tries to load a built-in protocol handler.
|
||||
* If this class does not exist, or if the class exists but it is not a
|
||||
@ -277,8 +280,12 @@ public final class URL implements java.io.Serializable {
|
||||
* <blockquote><pre>
|
||||
* http, https, file, and jar
|
||||
* </pre></blockquote>
|
||||
* Protocol handlers for additional protocols may also be
|
||||
* available.
|
||||
* Protocol handlers for additional protocols may also be available.
|
||||
* Some protocol handlers, for example those used for loading platform
|
||||
* classes or classes on the class path, may not be overridden. The details
|
||||
* of such restrictions, and when those restrictions apply (during
|
||||
* initialization of the runtime for example), are implementation specific
|
||||
* and therefore not specified
|
||||
*
|
||||
* <p>No validation of the inputs is performed by this constructor.
|
||||
*
|
||||
@ -1107,20 +1114,115 @@ public final class URL implements java.io.Serializable {
|
||||
}
|
||||
handlers.clear();
|
||||
|
||||
// ensure the core protocol handlers are loaded before setting
|
||||
// a custom URLStreamHandlerFactory
|
||||
ensureHandlersLoaded("jrt", "jar", "file");
|
||||
|
||||
// safe publication of URLStreamHandlerFactory with volatile write
|
||||
factory = fac;
|
||||
}
|
||||
}
|
||||
|
||||
private static final URLStreamHandlerFactory defaultFactory = new DefaultFactory();
|
||||
|
||||
private static class DefaultFactory implements URLStreamHandlerFactory {
|
||||
private static String PREFIX = "sun.net.www.protocol";
|
||||
|
||||
public URLStreamHandler createURLStreamHandler(String protocol) {
|
||||
String name = PREFIX + "." + protocol + ".Handler";
|
||||
try {
|
||||
Class<?> c = Class.forName(name);
|
||||
return (URLStreamHandler)c.newInstance();
|
||||
} catch (ClassNotFoundException x) {
|
||||
// ignore
|
||||
} catch (Exception e) {
|
||||
// For compatibility, all Exceptions are ignored.
|
||||
// any number of exceptions can get thrown here
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Iterator<URLStreamHandlerProvider> providers() {
|
||||
return new Iterator<URLStreamHandlerProvider>() {
|
||||
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||
ServiceLoader<URLStreamHandlerProvider> sl =
|
||||
ServiceLoader.load(URLStreamHandlerProvider.class, cl);
|
||||
Iterator<URLStreamHandlerProvider> i = sl.iterator();
|
||||
|
||||
URLStreamHandlerProvider next = null;
|
||||
|
||||
private boolean getNext() {
|
||||
while (next == null) {
|
||||
try {
|
||||
if (!i.hasNext())
|
||||
return false;
|
||||
next = i.next();
|
||||
} catch (ServiceConfigurationError sce) {
|
||||
if (sce.getCause() instanceof SecurityException) {
|
||||
// Ignore security exceptions
|
||||
continue;
|
||||
}
|
||||
throw sce;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return getNext();
|
||||
}
|
||||
|
||||
public URLStreamHandlerProvider next() {
|
||||
if (!getNext())
|
||||
throw new NoSuchElementException();
|
||||
URLStreamHandlerProvider n = next;
|
||||
next = null;
|
||||
return n;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Thread-local gate to prevent recursive provider lookups
|
||||
private static ThreadLocal<Object> gate = new ThreadLocal<>();
|
||||
|
||||
private static URLStreamHandler lookupViaProviders(final String protocol) {
|
||||
if (!sun.misc.VM.isBooted())
|
||||
return null;
|
||||
|
||||
if (gate.get() != null)
|
||||
throw new Error("Circular loading of URL stream handler providers detected");
|
||||
|
||||
gate.set(gate);
|
||||
try {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<URLStreamHandler>() {
|
||||
public URLStreamHandler run() {
|
||||
Iterator<URLStreamHandlerProvider> itr = providers();
|
||||
while (itr.hasNext()) {
|
||||
URLStreamHandlerProvider f = itr.next();
|
||||
URLStreamHandler h = f.createURLStreamHandler(protocol);
|
||||
if (h != null)
|
||||
return h;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
gate.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] NON_OVERRIDEABLE_PROTOCOLS = {"file", "jrt"};
|
||||
private static boolean isOverrideable(String protocol) {
|
||||
for (String p : NON_OVERRIDEABLE_PROTOCOLS)
|
||||
if (protocol.equalsIgnoreCase(p))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A table of protocol handlers.
|
||||
*/
|
||||
static Hashtable<String,URLStreamHandler> handlers = new Hashtable<>();
|
||||
private static Object streamHandlerLock = new Object();
|
||||
private static final Object streamHandlerLock = new Object();
|
||||
|
||||
/**
|
||||
* Returns the Stream Handler.
|
||||
@ -1129,66 +1231,33 @@ public final class URL implements java.io.Serializable {
|
||||
static URLStreamHandler getURLStreamHandler(String protocol) {
|
||||
|
||||
URLStreamHandler handler = handlers.get(protocol);
|
||||
if (handler == null) {
|
||||
|
||||
boolean checkedWithFactory = false;
|
||||
if (handler != null) {
|
||||
return handler;
|
||||
}
|
||||
|
||||
URLStreamHandlerFactory fac;
|
||||
boolean checkedWithFactory = false;
|
||||
|
||||
if (isOverrideable(protocol)) {
|
||||
// Use the factory (if any). Volatile read makes
|
||||
// URLStreamHandlerFactory appear fully initialized to current thread.
|
||||
URLStreamHandlerFactory fac = factory;
|
||||
fac = factory;
|
||||
if (fac != null) {
|
||||
handler = fac.createURLStreamHandler(protocol);
|
||||
checkedWithFactory = true;
|
||||
}
|
||||
|
||||
// Try java protocol handler
|
||||
if (handler == null) {
|
||||
String packagePrefixList = null;
|
||||
|
||||
packagePrefixList
|
||||
= java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction(
|
||||
protocolPathProp,""));
|
||||
if (packagePrefixList != "") {
|
||||
packagePrefixList += "|";
|
||||
}
|
||||
|
||||
// REMIND: decide whether to allow the "null" class prefix
|
||||
// or not.
|
||||
packagePrefixList += "sun.net.www.protocol";
|
||||
|
||||
StringTokenizer packagePrefixIter =
|
||||
new StringTokenizer(packagePrefixList, "|");
|
||||
|
||||
while (handler == null &&
|
||||
packagePrefixIter.hasMoreTokens()) {
|
||||
|
||||
String packagePrefix =
|
||||
packagePrefixIter.nextToken().trim();
|
||||
try {
|
||||
String clsName = packagePrefix + "." + protocol +
|
||||
".Handler";
|
||||
Class<?> cls = null;
|
||||
try {
|
||||
cls = Class.forName(clsName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||
if (cl != null) {
|
||||
cls = cl.loadClass(clsName);
|
||||
}
|
||||
}
|
||||
if (cls != null) {
|
||||
handler =
|
||||
(URLStreamHandler)cls.newInstance();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// any number of exceptions can get thrown here
|
||||
}
|
||||
}
|
||||
if (handler == null && !protocol.equalsIgnoreCase("jar")) {
|
||||
handler = lookupViaProviders(protocol);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (streamHandlerLock) {
|
||||
|
||||
synchronized (streamHandlerLock) {
|
||||
if (handler == null) {
|
||||
// Try the built-in protocol handler
|
||||
handler = defaultFactory.createURLStreamHandler(protocol);
|
||||
} else {
|
||||
URLStreamHandler handler2 = null;
|
||||
|
||||
// Check again with hashtable just in case another
|
||||
@ -1202,7 +1271,7 @@ public final class URL implements java.io.Serializable {
|
||||
// Check with factory if another thread set a
|
||||
// factory since our last check
|
||||
if (!checkedWithFactory && (fac = factory) != null) {
|
||||
handler2 = fac.createURLStreamHandler(protocol);
|
||||
handler2 = fac.createURLStreamHandler(protocol);
|
||||
}
|
||||
|
||||
if (handler2 != null) {
|
||||
@ -1211,29 +1280,17 @@ public final class URL implements java.io.Serializable {
|
||||
// this thread created.
|
||||
handler = handler2;
|
||||
}
|
||||
}
|
||||
|
||||
// Insert this handler into the hashtable
|
||||
if (handler != null) {
|
||||
handlers.put(protocol, handler);
|
||||
}
|
||||
|
||||
// Insert this handler into the hashtable
|
||||
if (handler != null) {
|
||||
handlers.put(protocol, handler);
|
||||
}
|
||||
}
|
||||
|
||||
return handler;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the given protocol handlers are loaded
|
||||
*/
|
||||
private static void ensureHandlersLoaded(String... protocols) {
|
||||
for (String protocol: protocols) {
|
||||
getURLStreamHandler(protocol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* WriteObject is called to save the state of the URL to an
|
||||
* ObjectOutputStream. The handler is not saved since it is
|
||||
|
@ -44,7 +44,9 @@ public interface URLStreamHandlerFactory {
|
||||
*
|
||||
* @param protocol the protocol ("{@code ftp}",
|
||||
* "{@code http}", "{@code nntp}", etc.).
|
||||
* @return a {@code URLStreamHandler} for the specific protocol.
|
||||
* @return a {@code URLStreamHandler} for the specific protocol, or {@code
|
||||
* null} if this factory cannot create a handler for the specific
|
||||
* protocol
|
||||
* @see java.net.URLStreamHandler
|
||||
*/
|
||||
URLStreamHandler createURLStreamHandler(String protocol);
|
||||
|
@ -143,13 +143,11 @@
|
||||
* a similar URL will try to instantiate the handler for the specified protocol;
|
||||
* if it doesn't exist an exception will be thrown.
|
||||
* <p>By default the protocol handlers are loaded dynamically from the default
|
||||
* location. It is, however, possible to add to the search path by setting
|
||||
* the {@code java.protocol.handler.pkgs} system property. For instance if
|
||||
* it is set to {@code myapp.protocols}, then the URL code will try, in the
|
||||
* case of http, first to load {@code myapp.protocols.http.Handler}, then,
|
||||
* if this fails, {@code http.Handler} from the default location.
|
||||
* <p>Note that the Handler class <b>has to</b> be a subclass of the abstract
|
||||
* class {@link java.net.URLStreamHandler}.</p>
|
||||
* location. It is, however, possible to deploy additional protocols handlers
|
||||
* as {@link java.util.ServiceLoader services}. Service providers of type
|
||||
* {@linkplain java.net.spi.URLStreamHandlerProvider} are located at
|
||||
* runtime, as specified in the {@linkplain
|
||||
* java.net.URL#URL(String,String,int,String) URL constructor}.
|
||||
* <h2>Additional Specification</h2>
|
||||
* <ul>
|
||||
* <li><a href="doc-files/net-properties.html">
|
||||
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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 java.net.spi;
|
||||
|
||||
import java.net.URLStreamHandlerFactory;
|
||||
|
||||
/**
|
||||
* URL stream handler service-provider class.
|
||||
*
|
||||
*<p> A URL stream handler provider is a concrete subclass of this class that
|
||||
* has a zero-argument constructor. URL stream handler providers may be
|
||||
* installed in an instance of the Java platform by adding them to the
|
||||
* application class path.
|
||||
*
|
||||
* <p> A URL stream handler provider identifies itself with a
|
||||
* provider-configuration file named java.net.spi.URLStreamHandlerProvider in
|
||||
* the resource directory META-INF/services. The file should contain a list of
|
||||
* fully-qualified concrete URL stream handler provider class names, one per
|
||||
* line.
|
||||
*
|
||||
* @since 1.9
|
||||
*/
|
||||
public abstract class URLStreamHandlerProvider
|
||||
implements URLStreamHandlerFactory
|
||||
{
|
||||
private static Void checkPermission() {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkPermission(new RuntimePermission("setFactory"));
|
||||
return null;
|
||||
}
|
||||
private URLStreamHandlerProvider(Void ignore) { }
|
||||
|
||||
/**
|
||||
* Initializes a new URL stream handler provider.
|
||||
*
|
||||
* @throws SecurityException
|
||||
* If a security manager has been installed and it denies
|
||||
* {@link RuntimePermission}{@code ("setFactory")}.
|
||||
*/
|
||||
protected URLStreamHandlerProvider() {
|
||||
this(checkPermission());
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 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
|
||||
@ -23,26 +23,13 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.security.acl;
|
||||
|
||||
import java.security.*;
|
||||
|
||||
/**
|
||||
* This class implements a group of principals.
|
||||
* @author Satish Dharmaraj
|
||||
* Service-provider classes for the <tt>{@link java.net}</tt> package.
|
||||
*
|
||||
* <p> Only developers who are defining new URL stream handler providers
|
||||
* should need to make direct use of this package.
|
||||
*
|
||||
* @since 1.9
|
||||
*/
|
||||
public class WorldGroupImpl extends GroupImpl {
|
||||
|
||||
public WorldGroupImpl(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true for all passed principals
|
||||
* @param member The principal whose membership must be checked in this Group.
|
||||
* @return true always since this is the "world" group.
|
||||
*/
|
||||
public boolean isMember(Principal member) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package java.net.spi;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2015, 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
|
||||
@ -68,11 +68,7 @@ import java.security.Principal;
|
||||
*
|
||||
* The {@code java.security.acl } package provides the
|
||||
* interfaces to the ACL and related data structures (ACL entries,
|
||||
* groups, permissions, etc.), and the {@code sun.security.acl }
|
||||
* classes provide a default implementation of the interfaces. For
|
||||
* example, {@code java.security.acl.Acl } provides the
|
||||
* interface to an ACL and the {@code sun.security.acl.AclImpl }
|
||||
* class provides the default implementation of the interface.<p>
|
||||
* groups, permissions, etc.).<p>
|
||||
*
|
||||
* The {@code java.security.acl.Acl } interface extends the
|
||||
* {@code java.security.acl.Owner } interface. The Owner
|
||||
|
@ -155,7 +155,7 @@ public abstract class Clock {
|
||||
* @return a clock that uses the best available system clock in the UTC zone, not null
|
||||
*/
|
||||
public static Clock systemUTC() {
|
||||
return new SystemClock(ZoneOffset.UTC);
|
||||
return SystemClock.UTC;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,6 +198,9 @@ public abstract class Clock {
|
||||
*/
|
||||
public static Clock system(ZoneId zone) {
|
||||
Objects.requireNonNull(zone, "zone");
|
||||
if (zone == ZoneOffset.UTC) {
|
||||
return SystemClock.UTC;
|
||||
}
|
||||
return new SystemClock(zone);
|
||||
}
|
||||
|
||||
@ -451,6 +454,8 @@ public abstract class Clock {
|
||||
private static final long serialVersionUID = 6740630888130243051L;
|
||||
private static final long OFFSET_SEED =
|
||||
System.currentTimeMillis()/1000 - 1024; // initial offest
|
||||
static final SystemClock UTC = new SystemClock(ZoneOffset.UTC);
|
||||
|
||||
private final ZoneId zone;
|
||||
// We don't actually need a volatile here.
|
||||
// We don't care if offset is set or read concurrently by multiple
|
||||
|
@ -848,7 +848,7 @@ public interface DoubleStream extends BaseStream<Double, DoubleStream> {
|
||||
* @implNote
|
||||
* Use caution when constructing streams from repeated concatenation.
|
||||
* Accessing an element of a deeply concatenated stream can result in deep
|
||||
* call chains, or even {@code StackOverflowException}.
|
||||
* call chains, or even {@code StackOverflowError}.
|
||||
*
|
||||
* @param a the first stream
|
||||
* @param b the second stream
|
||||
|
@ -837,7 +837,7 @@ public interface IntStream extends BaseStream<Integer, IntStream> {
|
||||
* @implNote
|
||||
* Use caution when constructing streams from repeated concatenation.
|
||||
* Accessing an element of a deeply concatenated stream can result in deep
|
||||
* call chains, or even {@code StackOverflowException}.
|
||||
* call chains, or even {@code StackOverflowError}.
|
||||
*
|
||||
* @param a the first stream
|
||||
* @param b the second stream
|
||||
|
@ -845,7 +845,7 @@ public interface LongStream extends BaseStream<Long, LongStream> {
|
||||
* @implNote
|
||||
* Use caution when constructing streams from repeated concatenation.
|
||||
* Accessing an element of a deeply concatenated stream can result in deep
|
||||
* call chains, or even {@code StackOverflowException}.
|
||||
* call chains, or even {@code StackOverflowError}.
|
||||
*
|
||||
* @param a the first stream
|
||||
* @param b the second stream
|
||||
|
@ -1079,7 +1079,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
|
||||
* @implNote
|
||||
* Use caution when constructing streams from repeated concatenation.
|
||||
* Accessing an element of a deeply concatenated stream can result in deep
|
||||
* call chains, or even {@code StackOverflowException}.
|
||||
* call chains, or even {@code StackOverflowError}.
|
||||
*
|
||||
* @param <T> The type of stream elements
|
||||
* @param a the first stream
|
||||
|
@ -180,8 +180,7 @@ class ZipEntry implements ZipConstants, Cloneable {
|
||||
* @since 1.8
|
||||
*/
|
||||
public ZipEntry setLastModifiedTime(FileTime time) {
|
||||
Objects.requireNonNull(name, "time");
|
||||
this.mtime = time;
|
||||
this.mtime = Objects.requireNonNull(time, "lastModifiedTime");
|
||||
this.time = time.to(TimeUnit.MILLISECONDS);
|
||||
return this;
|
||||
}
|
||||
@ -227,8 +226,7 @@ class ZipEntry implements ZipConstants, Cloneable {
|
||||
* @since 1.8
|
||||
*/
|
||||
public ZipEntry setLastAccessTime(FileTime time) {
|
||||
Objects.requireNonNull(name, "time");
|
||||
this.atime = time;
|
||||
this.atime = Objects.requireNonNull(time, "lastAccessTime");
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -265,8 +263,7 @@ class ZipEntry implements ZipConstants, Cloneable {
|
||||
* @since 1.8
|
||||
*/
|
||||
public ZipEntry setCreationTime(FileTime time) {
|
||||
Objects.requireNonNull(name, "time");
|
||||
this.ctime = time;
|
||||
this.ctime = Objects.requireNonNull(time, "creationTime");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1,181 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2011, 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 sun.security.acl;
|
||||
|
||||
import java.util.*;
|
||||
import java.security.Principal;
|
||||
import java.security.acl.*;
|
||||
|
||||
/**
|
||||
* This is a class that describes one entry that associates users
|
||||
* or groups with permissions in the ACL.
|
||||
* The entry may be used as a way of granting or denying permissions.
|
||||
* @author Satish Dharmaraj
|
||||
*/
|
||||
public class AclEntryImpl implements AclEntry {
|
||||
private Principal user = null;
|
||||
private Vector<Permission> permissionSet = new Vector<>(10, 10);
|
||||
private boolean negative = false;
|
||||
|
||||
/**
|
||||
* Construct an ACL entry that associates a user with permissions
|
||||
* in the ACL.
|
||||
* @param user The user that is associated with this entry.
|
||||
*/
|
||||
public AclEntryImpl(Principal user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a null ACL entry
|
||||
*/
|
||||
public AclEntryImpl() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the principal in the entity. If a group or a
|
||||
* principal had already been set, a false value is
|
||||
* returned, otherwise a true value is returned.
|
||||
* @param user The user that is associated with this entry.
|
||||
* @return true if the principal is set, false if there is
|
||||
* one already.
|
||||
*/
|
||||
public boolean setPrincipal(Principal user) {
|
||||
if (this.user != null)
|
||||
return false;
|
||||
this.user = user;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the ACL to have negative permissions.
|
||||
* That is the user or group is denied the permission set
|
||||
* specified in the entry.
|
||||
*/
|
||||
public void setNegativePermissions() {
|
||||
negative = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is a negative ACL.
|
||||
*/
|
||||
public boolean isNegative() {
|
||||
return negative;
|
||||
}
|
||||
|
||||
/**
|
||||
* A principal or a group can be associated with multiple
|
||||
* permissions. This method adds a permission to the ACL entry.
|
||||
* @param permission The permission to be associated with
|
||||
* the principal or the group in the entry.
|
||||
* @return true if the permission was added, false if the
|
||||
* permission was already part of the permission set.
|
||||
*/
|
||||
public boolean addPermission(Permission permission) {
|
||||
|
||||
if (permissionSet.contains(permission))
|
||||
return false;
|
||||
|
||||
permissionSet.addElement(permission);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method disassociates the permission from the Principal
|
||||
* or the Group in this ACL entry.
|
||||
* @param permission The permission to be disassociated with
|
||||
* the principal or the group in the entry.
|
||||
* @return true if the permission is removed, false if the
|
||||
* permission is not part of the permission set.
|
||||
*/
|
||||
public boolean removePermission(Permission permission) {
|
||||
return permissionSet.removeElement(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the passed permission is part of the allowed
|
||||
* permission set in this entry.
|
||||
* @param permission The permission that has to be part of
|
||||
* the permission set in the entry.
|
||||
* @return true if the permission passed is part of the
|
||||
* permission set in the entry, false otherwise.
|
||||
*/
|
||||
public boolean checkPermission(Permission permission) {
|
||||
return permissionSet.contains(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* return an enumeration of the permissions in this ACL entry.
|
||||
*/
|
||||
public Enumeration<Permission> permissions() {
|
||||
return permissionSet.elements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation of the contents of the ACL entry.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer s = new StringBuffer();
|
||||
if (negative)
|
||||
s.append("-");
|
||||
else
|
||||
s.append("+");
|
||||
if (user instanceof Group)
|
||||
s.append("Group.");
|
||||
else
|
||||
s.append("User.");
|
||||
s.append(user + "=");
|
||||
Enumeration<Permission> e = permissions();
|
||||
while(e.hasMoreElements()) {
|
||||
Permission p = e.nextElement();
|
||||
s.append(p);
|
||||
if (e.hasMoreElements())
|
||||
s.append(",");
|
||||
}
|
||||
return new String(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones an AclEntry.
|
||||
*/
|
||||
@SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
|
||||
public synchronized Object clone() {
|
||||
AclEntryImpl cloned;
|
||||
cloned = new AclEntryImpl(user);
|
||||
cloned.permissionSet = (Vector<Permission>) permissionSet.clone();
|
||||
cloned.negative = negative;
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Principal associated in this ACL entry.
|
||||
* The method returns null if the entry uses a group
|
||||
* instead of a principal.
|
||||
*/
|
||||
public Principal getPrincipal() {
|
||||
return user;
|
||||
}
|
||||
}
|
@ -1,408 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2011, 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 sun.security.acl;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.security.Principal;
|
||||
import java.security.acl.*;
|
||||
|
||||
/**
|
||||
* An Access Control List (ACL) is encapsulated by this class.
|
||||
* @author Satish Dharmaraj
|
||||
*/
|
||||
public class AclImpl extends OwnerImpl implements Acl {
|
||||
//
|
||||
// Maintain four tables. one each for positive and negative
|
||||
// ACLs. One each depending on whether the entity is a group
|
||||
// or principal.
|
||||
//
|
||||
private Hashtable<Principal, AclEntry> allowedUsersTable =
|
||||
new Hashtable<>(23);
|
||||
private Hashtable<Principal, AclEntry> allowedGroupsTable =
|
||||
new Hashtable<>(23);
|
||||
private Hashtable<Principal, AclEntry> deniedUsersTable =
|
||||
new Hashtable<>(23);
|
||||
private Hashtable<Principal, AclEntry> deniedGroupsTable =
|
||||
new Hashtable<>(23);
|
||||
private String aclName = null;
|
||||
private Vector<Permission> zeroSet = new Vector<>(1,1);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for creating an empty ACL.
|
||||
*/
|
||||
public AclImpl(Principal owner, String name) {
|
||||
super(owner);
|
||||
try {
|
||||
setName(owner, name);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the ACL.
|
||||
* @param caller the principal who is invoking this method.
|
||||
* @param name the name of the ACL.
|
||||
* @exception NotOwnerException if the caller principal is
|
||||
* not on the owners list of the Acl.
|
||||
*/
|
||||
public void setName(Principal caller, String name)
|
||||
throws NotOwnerException
|
||||
{
|
||||
if (!isOwner(caller))
|
||||
throw new NotOwnerException();
|
||||
|
||||
aclName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the ACL.
|
||||
* @return the name of the ACL.
|
||||
*/
|
||||
public String getName() {
|
||||
return aclName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an ACL entry to this ACL. An entry associates a
|
||||
* group or a principal with a set of permissions. Each
|
||||
* user or group can have one positive ACL entry and one
|
||||
* negative ACL entry. If there is one of the type (negative
|
||||
* or positive) already in the table, a false value is returned.
|
||||
* The caller principal must be a part of the owners list of
|
||||
* the ACL in order to invoke this method.
|
||||
* @param caller the principal who is invoking this method.
|
||||
* @param entry the ACL entry that must be added to the ACL.
|
||||
* @return true on success, false if the entry is already present.
|
||||
* @exception NotOwnerException if the caller principal
|
||||
* is not on the owners list of the Acl.
|
||||
*/
|
||||
public synchronized boolean addEntry(Principal caller, AclEntry entry)
|
||||
throws NotOwnerException
|
||||
{
|
||||
if (!isOwner(caller))
|
||||
throw new NotOwnerException();
|
||||
|
||||
Hashtable<Principal, AclEntry> aclTable = findTable(entry);
|
||||
Principal key = entry.getPrincipal();
|
||||
|
||||
if (aclTable.get(key) != null)
|
||||
return false;
|
||||
|
||||
aclTable.put(key, entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an ACL entry from this ACL.
|
||||
* The caller principal must be a part of the owners list of the ACL
|
||||
* in order to invoke this method.
|
||||
* @param caller the principal who is invoking this method.
|
||||
* @param entry the ACL entry that must be removed from the ACL.
|
||||
* @return true on success, false if the entry is not part of the ACL.
|
||||
* @exception NotOwnerException if the caller principal is not
|
||||
* the owners list of the Acl.
|
||||
*/
|
||||
public synchronized boolean removeEntry(Principal caller, AclEntry entry)
|
||||
throws NotOwnerException
|
||||
{
|
||||
if (!isOwner(caller))
|
||||
throw new NotOwnerException();
|
||||
|
||||
Hashtable<Principal, AclEntry> aclTable = findTable(entry);
|
||||
Principal key = entry.getPrincipal();
|
||||
|
||||
AclEntry o = aclTable.remove(key);
|
||||
return (o != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the set of allowed permissions for the
|
||||
* specified principal. This set of allowed permissions is calculated
|
||||
* as follows:
|
||||
*
|
||||
* If there is no entry for a group or a principal an empty permission
|
||||
* set is assumed.
|
||||
*
|
||||
* The group positive permission set is the union of all
|
||||
* the positive permissions of each group that the individual belongs to.
|
||||
* The group negative permission set is the union of all
|
||||
* the negative permissions of each group that the individual belongs to.
|
||||
* If there is a specific permission that occurs in both
|
||||
* the postive permission set and the negative permission set,
|
||||
* it is removed from both. The group positive and negatoive permission
|
||||
* sets are calculated.
|
||||
*
|
||||
* The individial positive permission set and the individual negative
|
||||
* permission set is then calculated. Again abscence of an entry means
|
||||
* the empty set.
|
||||
*
|
||||
* The set of permissions granted to the principal is then calculated using
|
||||
* the simple rule: Individual permissions always override the Group permissions.
|
||||
* Specifically, individual negative permission set (specific
|
||||
* denial of permissions) overrides the group positive permission set.
|
||||
* And the individual positive permission set override the group negative
|
||||
* permission set.
|
||||
*
|
||||
* @param user the principal for which the ACL entry is returned.
|
||||
* @return The resulting permission set that the principal is allowed.
|
||||
*/
|
||||
public synchronized Enumeration<Permission> getPermissions(Principal user) {
|
||||
|
||||
Enumeration<Permission> individualPositive;
|
||||
Enumeration<Permission> individualNegative;
|
||||
Enumeration<Permission> groupPositive;
|
||||
Enumeration<Permission> groupNegative;
|
||||
|
||||
//
|
||||
// canonicalize the sets. That is remove common permissions from
|
||||
// positive and negative sets.
|
||||
//
|
||||
groupPositive =
|
||||
subtract(getGroupPositive(user), getGroupNegative(user));
|
||||
groupNegative =
|
||||
subtract(getGroupNegative(user), getGroupPositive(user));
|
||||
individualPositive =
|
||||
subtract(getIndividualPositive(user), getIndividualNegative(user));
|
||||
individualNegative =
|
||||
subtract(getIndividualNegative(user), getIndividualPositive(user));
|
||||
|
||||
//
|
||||
// net positive permissions is individual positive permissions
|
||||
// plus (group positive - individual negative).
|
||||
//
|
||||
Enumeration<Permission> temp1 =
|
||||
subtract(groupPositive, individualNegative);
|
||||
Enumeration<Permission> netPositive =
|
||||
union(individualPositive, temp1);
|
||||
|
||||
// recalculate the enumeration since we lost it in performing the
|
||||
// subtraction
|
||||
//
|
||||
individualPositive =
|
||||
subtract(getIndividualPositive(user), getIndividualNegative(user));
|
||||
individualNegative =
|
||||
subtract(getIndividualNegative(user), getIndividualPositive(user));
|
||||
|
||||
//
|
||||
// net negative permissions is individual negative permissions
|
||||
// plus (group negative - individual positive).
|
||||
//
|
||||
temp1 = subtract(groupNegative, individualPositive);
|
||||
Enumeration<Permission> netNegative = union(individualNegative, temp1);
|
||||
|
||||
return subtract(netPositive, netNegative);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks whether or not the specified principal
|
||||
* has the required permission. If permission is denied
|
||||
* permission false is returned, a true value is returned otherwise.
|
||||
* This method does not authenticate the principal. It presumes that
|
||||
* the principal is a valid authenticated principal.
|
||||
* @param principal the name of the authenticated principal
|
||||
* @param permission the permission that the principal must have.
|
||||
* @return true of the principal has the permission desired, false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean checkPermission(Principal principal, Permission permission)
|
||||
{
|
||||
Enumeration<Permission> permSet = getPermissions(principal);
|
||||
while (permSet.hasMoreElements()) {
|
||||
Permission p = permSet.nextElement();
|
||||
if (p.equals(permission))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an enumeration of the entries in this ACL.
|
||||
*/
|
||||
public synchronized Enumeration<AclEntry> entries() {
|
||||
return new AclEnumerator(this,
|
||||
allowedUsersTable, allowedGroupsTable,
|
||||
deniedUsersTable, deniedGroupsTable);
|
||||
}
|
||||
|
||||
/**
|
||||
* return a stringified version of the
|
||||
* ACL.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Enumeration<AclEntry> entries = entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
AclEntry entry = entries.nextElement();
|
||||
sb.append(entry.toString().trim());
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
//
|
||||
// Find the table that this entry belongs to. There are 4
|
||||
// tables that are maintained. One each for postive and
|
||||
// negative ACLs and one each for groups and users.
|
||||
// This method figures out which
|
||||
// table is the one that this AclEntry belongs to.
|
||||
//
|
||||
private Hashtable<Principal, AclEntry> findTable(AclEntry entry) {
|
||||
Hashtable<Principal, AclEntry> aclTable = null;
|
||||
|
||||
Principal p = entry.getPrincipal();
|
||||
if (p instanceof Group) {
|
||||
if (entry.isNegative())
|
||||
aclTable = deniedGroupsTable;
|
||||
else
|
||||
aclTable = allowedGroupsTable;
|
||||
} else {
|
||||
if (entry.isNegative())
|
||||
aclTable = deniedUsersTable;
|
||||
else
|
||||
aclTable = allowedUsersTable;
|
||||
}
|
||||
return aclTable;
|
||||
}
|
||||
|
||||
//
|
||||
// returns the set e1 U e2.
|
||||
//
|
||||
private static Enumeration<Permission> union(Enumeration<Permission> e1,
|
||||
Enumeration<Permission> e2) {
|
||||
Vector<Permission> v = new Vector<>(20, 20);
|
||||
|
||||
while (e1.hasMoreElements())
|
||||
v.addElement(e1.nextElement());
|
||||
|
||||
while (e2.hasMoreElements()) {
|
||||
Permission o = e2.nextElement();
|
||||
if (!v.contains(o))
|
||||
v.addElement(o);
|
||||
}
|
||||
|
||||
return v.elements();
|
||||
}
|
||||
|
||||
//
|
||||
// returns the set e1 - e2.
|
||||
//
|
||||
private Enumeration<Permission> subtract(Enumeration<Permission> e1,
|
||||
Enumeration<Permission> e2) {
|
||||
Vector<Permission> v = new Vector<>(20, 20);
|
||||
|
||||
while (e1.hasMoreElements())
|
||||
v.addElement(e1.nextElement());
|
||||
|
||||
while (e2.hasMoreElements()) {
|
||||
Permission o = e2.nextElement();
|
||||
if (v.contains(o))
|
||||
v.removeElement(o);
|
||||
}
|
||||
|
||||
return v.elements();
|
||||
}
|
||||
|
||||
private Enumeration<Permission> getGroupPositive(Principal user) {
|
||||
Enumeration<Permission> groupPositive = zeroSet.elements();
|
||||
Enumeration<Principal> e = allowedGroupsTable.keys();
|
||||
while (e.hasMoreElements()) {
|
||||
Group g = (Group)e.nextElement();
|
||||
if (g.isMember(user)) {
|
||||
AclEntry ae = allowedGroupsTable.get(g);
|
||||
groupPositive = union(ae.permissions(), groupPositive);
|
||||
}
|
||||
}
|
||||
return groupPositive;
|
||||
}
|
||||
|
||||
private Enumeration<Permission> getGroupNegative(Principal user) {
|
||||
Enumeration<Permission> groupNegative = zeroSet.elements();
|
||||
Enumeration<Principal> e = deniedGroupsTable.keys();
|
||||
while (e.hasMoreElements()) {
|
||||
Group g = (Group)e.nextElement();
|
||||
if (g.isMember(user)) {
|
||||
AclEntry ae = deniedGroupsTable.get(g);
|
||||
groupNegative = union(ae.permissions(), groupNegative);
|
||||
}
|
||||
}
|
||||
return groupNegative;
|
||||
}
|
||||
|
||||
private Enumeration<Permission> getIndividualPositive(Principal user) {
|
||||
Enumeration<Permission> individualPositive = zeroSet.elements();
|
||||
AclEntry ae = allowedUsersTable.get(user);
|
||||
if (ae != null)
|
||||
individualPositive = ae.permissions();
|
||||
return individualPositive;
|
||||
}
|
||||
|
||||
private Enumeration<Permission> getIndividualNegative(Principal user) {
|
||||
Enumeration<Permission> individualNegative = zeroSet.elements();
|
||||
AclEntry ae = deniedUsersTable.get(user);
|
||||
if (ae != null)
|
||||
individualNegative = ae.permissions();
|
||||
return individualNegative;
|
||||
}
|
||||
}
|
||||
|
||||
final class AclEnumerator implements Enumeration<AclEntry> {
|
||||
Acl acl;
|
||||
Enumeration<AclEntry> u1, u2, g1, g2;
|
||||
|
||||
AclEnumerator(Acl acl, Hashtable<?,AclEntry> u1, Hashtable<?,AclEntry> g1,
|
||||
Hashtable<?,AclEntry> u2, Hashtable<?,AclEntry> g2) {
|
||||
this.acl = acl;
|
||||
this.u1 = u1.elements();
|
||||
this.u2 = u2.elements();
|
||||
this.g1 = g1.elements();
|
||||
this.g2 = g2.elements();
|
||||
}
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
return (u1.hasMoreElements() ||
|
||||
u2.hasMoreElements() ||
|
||||
g1.hasMoreElements() ||
|
||||
g2.hasMoreElements());
|
||||
}
|
||||
|
||||
public AclEntry nextElement()
|
||||
{
|
||||
AclEntry o;
|
||||
synchronized (acl) {
|
||||
if (u1.hasMoreElements())
|
||||
return u1.nextElement();
|
||||
if (u2.hasMoreElements())
|
||||
return u2.nextElement();
|
||||
if (g1.hasMoreElements())
|
||||
return g1.nextElement();
|
||||
if (g2.hasMoreElements())
|
||||
return g2.nextElement();
|
||||
}
|
||||
throw new NoSuchElementException("Acl Enumerator");
|
||||
}
|
||||
}
|
@ -1,186 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2011, 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 sun.security.acl;
|
||||
|
||||
import java.util.*;
|
||||
import java.security.*;
|
||||
import java.security.acl.*;
|
||||
|
||||
/**
|
||||
* This class implements a group of principals.
|
||||
* @author Satish Dharmaraj
|
||||
*/
|
||||
public class GroupImpl implements Group {
|
||||
private Vector<Principal> groupMembers = new Vector<>(50, 100);
|
||||
private String group;
|
||||
|
||||
/**
|
||||
* Constructs a Group object with no members.
|
||||
* @param groupName the name of the group
|
||||
*/
|
||||
public GroupImpl(String groupName) {
|
||||
this.group = groupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds the specified member to the group.
|
||||
* @param user The principal to add to the group.
|
||||
* @return true if the member was added - false if the
|
||||
* member could not be added.
|
||||
*/
|
||||
public boolean addMember(Principal user) {
|
||||
if (groupMembers.contains(user))
|
||||
return false;
|
||||
|
||||
// do not allow groups to be added to itself.
|
||||
if (group.equals(user.toString()))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
groupMembers.addElement(user);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* removes the specified member from the group.
|
||||
* @param user The principal to remove from the group.
|
||||
* @param true if the principal was removed false if
|
||||
* the principal was not a member
|
||||
*/
|
||||
public boolean removeMember(Principal user) {
|
||||
return groupMembers.removeElement(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the enumeration of the members in the group.
|
||||
*/
|
||||
public Enumeration<? extends Principal> members() {
|
||||
return groupMembers.elements();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns true if the group passed matches
|
||||
* the group represented in this interface.
|
||||
* @param another The group to compare this group to.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof Group == false) {
|
||||
return false;
|
||||
}
|
||||
Group another = (Group)obj;
|
||||
return group.equals(another.toString());
|
||||
}
|
||||
|
||||
// equals(Group) for compatibility
|
||||
public boolean equals(Group another) {
|
||||
return equals((Object)another);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a stringified version of the group.
|
||||
*/
|
||||
public String toString() {
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* return a hashcode for the principal.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return group.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if the passed principal is a member of the group.
|
||||
* @param member The principal whose membership must be checked for.
|
||||
* @return true if the principal is a member of this group,
|
||||
* false otherwise
|
||||
*/
|
||||
public boolean isMember(Principal member) {
|
||||
|
||||
//
|
||||
// if the member is part of the group (common case), return true.
|
||||
// if not, recursively search depth first in the group looking for the
|
||||
// principal.
|
||||
//
|
||||
if (groupMembers.contains(member)) {
|
||||
return true;
|
||||
} else {
|
||||
Vector<Group> alreadySeen = new Vector<>(10);
|
||||
return isMemberRecurse(member, alreadySeen);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return the name of the principal.
|
||||
*/
|
||||
public String getName() {
|
||||
return group;
|
||||
}
|
||||
|
||||
//
|
||||
// This function is the recursive search of groups for this
|
||||
// implementation of the Group. The search proceeds building up
|
||||
// a vector of already seen groups. Only new groups are considered,
|
||||
// thereby avoiding loops.
|
||||
//
|
||||
boolean isMemberRecurse(Principal member, Vector<Group> alreadySeen) {
|
||||
Enumeration<? extends Principal> e = members();
|
||||
while (e.hasMoreElements()) {
|
||||
boolean mem = false;
|
||||
Principal p = (Principal) e.nextElement();
|
||||
|
||||
// if the member is in this collection, return true
|
||||
if (p.equals(member)) {
|
||||
return true;
|
||||
} else if (p instanceof GroupImpl) {
|
||||
//
|
||||
// if not recurse if the group has not been checked already.
|
||||
// Can call method in this package only if the object is an
|
||||
// instance of this class. Otherwise call the method defined
|
||||
// in the interface. (This can lead to a loop if a mixture of
|
||||
// implementations form a loop, but we live with this improbable
|
||||
// case rather than clutter the interface by forcing the
|
||||
// implementation of this method.)
|
||||
//
|
||||
GroupImpl g = (GroupImpl) p;
|
||||
alreadySeen.addElement(this);
|
||||
if (!alreadySeen.contains(g))
|
||||
mem = g.isMemberRecurse(member, alreadySeen);
|
||||
} else if (p instanceof Group) {
|
||||
Group g = (Group) p;
|
||||
if (!alreadySeen.contains(g))
|
||||
mem = g.isMember(member);
|
||||
}
|
||||
|
||||
if (mem)
|
||||
return mem;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2006, 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 sun.security.acl;
|
||||
|
||||
import java.util.*;
|
||||
import java.security.*;
|
||||
import java.security.acl.*;
|
||||
|
||||
/**
|
||||
* Class implementing the Owner interface. The
|
||||
* initial owner principal is configured as
|
||||
* part of the constructor.
|
||||
* @author Satish Dharmaraj
|
||||
*/
|
||||
public class OwnerImpl implements Owner {
|
||||
private Group ownerGroup;
|
||||
|
||||
public OwnerImpl(Principal owner) {
|
||||
ownerGroup = new GroupImpl("AclOwners");
|
||||
ownerGroup.addMember(owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an owner. Owners can modify ACL contents and can disassociate
|
||||
* ACLs from the objects they protect in the AclConfig interface.
|
||||
* The caller principal must be a part of the owners list of the ACL in
|
||||
* order to invoke this method. The initial owner is configured
|
||||
* at ACL construction time.
|
||||
* @param caller the principal who is invoking this method.
|
||||
* @param owner The owner that should be added to the owners list.
|
||||
* @return true if success, false if already an owner.
|
||||
* @exception NotOwnerException if the caller principal is not on
|
||||
* the owners list of the Acl.
|
||||
*/
|
||||
public synchronized boolean addOwner(Principal caller, Principal owner)
|
||||
throws NotOwnerException
|
||||
{
|
||||
if (!isOwner(caller))
|
||||
throw new NotOwnerException();
|
||||
|
||||
ownerGroup.addMember(owner);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete owner. If this is the last owner in the ACL, an exception is
|
||||
* raised.
|
||||
* The caller principal must be a part of the owners list of the ACL in
|
||||
* order to invoke this method.
|
||||
* @param caller the principal who is invoking this method.
|
||||
* @param owner The owner to be removed from the owners list.
|
||||
* @return true if the owner is removed, false if the owner is not part
|
||||
* of the owners list.
|
||||
* @exception NotOwnerException if the caller principal is not on
|
||||
* the owners list of the Acl.
|
||||
* @exception LastOwnerException if there is only one owner left in the group, then
|
||||
* deleteOwner would leave the ACL owner-less. This exception is raised in such a case.
|
||||
*/
|
||||
public synchronized boolean deleteOwner(Principal caller, Principal owner)
|
||||
throws NotOwnerException, LastOwnerException
|
||||
{
|
||||
if (!isOwner(caller))
|
||||
throw new NotOwnerException();
|
||||
|
||||
Enumeration<? extends Principal> e = ownerGroup.members();
|
||||
//
|
||||
// check if there is atleast 2 members left.
|
||||
//
|
||||
Object o = e.nextElement();
|
||||
if (e.hasMoreElements())
|
||||
return ownerGroup.removeMember(owner);
|
||||
else
|
||||
throw new LastOwnerException();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* returns if the given principal belongs to the owner list.
|
||||
* @param owner The owner to check if part of the owners list
|
||||
* @return true if the passed principal is in the owner list, false if not.
|
||||
*/
|
||||
public synchronized boolean isOwner(Principal owner) {
|
||||
return ownerGroup.isMember(owner);
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1999, 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 sun.security.acl;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.security.acl.*;
|
||||
|
||||
/**
|
||||
* The PermissionImpl class implements the permission
|
||||
* interface for permissions that are strings.
|
||||
* @author Satish Dharmaraj
|
||||
*/
|
||||
public class PermissionImpl implements Permission {
|
||||
|
||||
private String permission;
|
||||
|
||||
/**
|
||||
* Construct a permission object using a string.
|
||||
* @param permission the stringified version of the permission.
|
||||
*/
|
||||
public PermissionImpl(String permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns true if the object passed matches the permission
|
||||
* represented in this interface.
|
||||
* @param another The Permission object to compare with.
|
||||
* @return true if the Permission objects are equal, false otherwise
|
||||
*/
|
||||
public boolean equals(Object another) {
|
||||
if (another instanceof Permission) {
|
||||
Permission p = (Permission) another;
|
||||
return permission.equals(p.toString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a stringified version of the permission.
|
||||
* @return the string representation of the Permission.
|
||||
*/
|
||||
public String toString() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for this PermissionImpl.
|
||||
*
|
||||
* @return a hashcode for this PermissionImpl.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return toString().hashCode();
|
||||
}
|
||||
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.security.acl;
|
||||
|
||||
import java.security.*;
|
||||
|
||||
/**
|
||||
* This class implements the principal interface.
|
||||
*
|
||||
* @author Satish Dharmaraj
|
||||
*/
|
||||
public class PrincipalImpl implements Principal {
|
||||
|
||||
private String user;
|
||||
|
||||
/**
|
||||
* Construct a principal from a string user name.
|
||||
* @param user The string form of the principal name.
|
||||
*/
|
||||
public PrincipalImpl(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns true if the object passed matches
|
||||
* the principal represented in this implementation
|
||||
* @param another the Principal to compare with.
|
||||
* @return true if the Principal passed is the same as that
|
||||
* encapsulated in this object, false otherwise
|
||||
*/
|
||||
public boolean equals(Object another) {
|
||||
if (another instanceof PrincipalImpl) {
|
||||
PrincipalImpl p = (PrincipalImpl) another;
|
||||
return user.equals(p.toString());
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a stringified version of the principal.
|
||||
*/
|
||||
public String toString() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* return a hashcode for the principal.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return user.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* return the name of the principal.
|
||||
*/
|
||||
public String getName() {
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
@ -3765,55 +3765,70 @@ public final class Main {
|
||||
}
|
||||
}
|
||||
|
||||
// Add an extension into a CertificateExtensions, always using OID as key
|
||||
private static void setExt(CertificateExtensions result, Extension ex)
|
||||
throws IOException {
|
||||
result.set(ex.getId(), ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create X509v3 extensions from a string representation. Note that the
|
||||
* SubjectKeyIdentifierExtension will always be created non-critical besides
|
||||
* the extension requested in the <code>extstr</code> argument.
|
||||
*
|
||||
* @param reqex the requested extensions, can be null, used for -gencert
|
||||
* @param ext the original extensions, can be null, used for -selfcert
|
||||
* @param requestedEx the requested extensions, can be null, used for -gencert
|
||||
* @param existingEx the original extensions, can be null, used for -selfcert
|
||||
* @param extstrs -ext values, Read keytool doc
|
||||
* @param pkey the public key for the certificate
|
||||
* @param akey the public key for the authority (issuer)
|
||||
* @return the created CertificateExtensions
|
||||
*/
|
||||
private CertificateExtensions createV3Extensions(
|
||||
CertificateExtensions reqex,
|
||||
CertificateExtensions ext,
|
||||
CertificateExtensions requestedEx,
|
||||
CertificateExtensions existingEx,
|
||||
List <String> extstrs,
|
||||
PublicKey pkey,
|
||||
PublicKey akey) throws Exception {
|
||||
|
||||
if (ext != null && reqex != null) {
|
||||
if (existingEx != null && requestedEx != null) {
|
||||
// This should not happen
|
||||
throw new Exception("One of request and original should be null.");
|
||||
}
|
||||
if (ext == null) ext = new CertificateExtensions();
|
||||
// A new extensions always using OID as key
|
||||
CertificateExtensions result = new CertificateExtensions();
|
||||
if (existingEx != null) {
|
||||
for (Extension ex: existingEx.getAllExtensions()) {
|
||||
setExt(result, ex);
|
||||
}
|
||||
}
|
||||
try {
|
||||
// name{:critical}{=value}
|
||||
// Honoring requested extensions
|
||||
if (reqex != null) {
|
||||
if (requestedEx != null) {
|
||||
for(String extstr: extstrs) {
|
||||
if (extstr.toLowerCase(Locale.ENGLISH).startsWith("honored=")) {
|
||||
List<String> list = Arrays.asList(
|
||||
extstr.toLowerCase(Locale.ENGLISH).substring(8).split(","));
|
||||
// First check existence of "all"
|
||||
if (list.contains("all")) {
|
||||
ext = reqex; // we know ext was null
|
||||
for (Extension ex: requestedEx.getAllExtensions()) {
|
||||
setExt(result, ex);
|
||||
}
|
||||
}
|
||||
// one by one for others
|
||||
for (String item: list) {
|
||||
if (item.equals("all")) continue;
|
||||
|
||||
// add or remove
|
||||
boolean add = true;
|
||||
// -1, unchanged, 0 crtical, 1 non-critical
|
||||
boolean add;
|
||||
// -1, unchanged, 0 critical, 1 non-critical
|
||||
int action = -1;
|
||||
String type = null;
|
||||
if (item.startsWith("-")) {
|
||||
add = false;
|
||||
type = item.substring(1);
|
||||
} else {
|
||||
add = true;
|
||||
int colonpos = item.indexOf(':');
|
||||
if (colonpos >= 0) {
|
||||
type = item.substring(0, colonpos);
|
||||
@ -3823,21 +3838,23 @@ public final class Main {
|
||||
throw new Exception(rb.getString
|
||||
("Illegal.value.") + item);
|
||||
}
|
||||
} else {
|
||||
type = item;
|
||||
}
|
||||
}
|
||||
String n = reqex.getNameByOid(findOidForExtName(type));
|
||||
String n = findOidForExtName(type).toString();
|
||||
if (add) {
|
||||
Extension e = reqex.get(n);
|
||||
Extension e = requestedEx.get(n);
|
||||
if (!e.isCritical() && action == 0
|
||||
|| e.isCritical() && action == 1) {
|
||||
e = Extension.newExtension(
|
||||
e.getExtensionId(),
|
||||
!e.isCritical(),
|
||||
e.getExtensionValue());
|
||||
ext.set(n, e);
|
||||
}
|
||||
setExt(result, e);
|
||||
} else {
|
||||
ext.delete(n);
|
||||
result.delete(n);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -3899,8 +3916,7 @@ public final class Main {
|
||||
}
|
||||
}
|
||||
}
|
||||
ext.set(BasicConstraintsExtension.NAME,
|
||||
new BasicConstraintsExtension(isCritical, isCA,
|
||||
setExt(result, new BasicConstraintsExtension(isCritical, isCA,
|
||||
pathLen));
|
||||
break;
|
||||
case 1: // KU
|
||||
@ -3928,7 +3944,7 @@ public final class Main {
|
||||
KeyUsageExtension kue = new KeyUsageExtension(ok);
|
||||
// The above KeyUsageExtension constructor does not
|
||||
// allow isCritical value, so...
|
||||
ext.set(KeyUsageExtension.NAME, Extension.newExtension(
|
||||
setExt(result, Extension.newExtension(
|
||||
kue.getExtensionId(),
|
||||
isCritical,
|
||||
kue.getExtensionValue()));
|
||||
@ -3966,8 +3982,7 @@ public final class Main {
|
||||
v.add(new ObjectIdentifier("1.3.6.1.5.5.7.3." + p));
|
||||
}
|
||||
}
|
||||
ext.set(ExtendedKeyUsageExtension.NAME,
|
||||
new ExtendedKeyUsageExtension(isCritical, v));
|
||||
setExt(result, new ExtendedKeyUsageExtension(isCritical, v));
|
||||
} else {
|
||||
throw new Exception(rb.getString
|
||||
("Illegal.value.") + extstr);
|
||||
@ -3988,13 +4003,11 @@ public final class Main {
|
||||
gnames.add(createGeneralName(t, v));
|
||||
}
|
||||
if (exttype == 3) {
|
||||
ext.set(SubjectAlternativeNameExtension.NAME,
|
||||
new SubjectAlternativeNameExtension(
|
||||
isCritical, gnames));
|
||||
setExt(result, new SubjectAlternativeNameExtension(
|
||||
isCritical, gnames));
|
||||
} else {
|
||||
ext.set(IssuerAlternativeNameExtension.NAME,
|
||||
new IssuerAlternativeNameExtension(
|
||||
isCritical, gnames));
|
||||
setExt(result, new IssuerAlternativeNameExtension(
|
||||
isCritical, gnames));
|
||||
}
|
||||
} else {
|
||||
throw new Exception(rb.getString
|
||||
@ -4044,11 +4057,9 @@ public final class Main {
|
||||
oid, createGeneralName(t, v)));
|
||||
}
|
||||
if (exttype == 5) {
|
||||
ext.set(SubjectInfoAccessExtension.NAME,
|
||||
new SubjectInfoAccessExtension(accessDescriptions));
|
||||
setExt(result, new SubjectInfoAccessExtension(accessDescriptions));
|
||||
} else {
|
||||
ext.set(AuthorityInfoAccessExtension.NAME,
|
||||
new AuthorityInfoAccessExtension(accessDescriptions));
|
||||
setExt(result, new AuthorityInfoAccessExtension(accessDescriptions));
|
||||
}
|
||||
} else {
|
||||
throw new Exception(rb.getString
|
||||
@ -4068,10 +4079,9 @@ public final class Main {
|
||||
String v = item.substring(colonpos+1);
|
||||
gnames.add(createGeneralName(t, v));
|
||||
}
|
||||
ext.set(CRLDistributionPointsExtension.NAME,
|
||||
new CRLDistributionPointsExtension(
|
||||
isCritical, Collections.singletonList(
|
||||
new DistributionPoint(gnames, null, null))));
|
||||
setExt(result, new CRLDistributionPointsExtension(
|
||||
isCritical, Collections.singletonList(
|
||||
new DistributionPoint(gnames, null, null))));
|
||||
} else {
|
||||
throw new Exception(rb.getString
|
||||
("Illegal.value.") + extstr);
|
||||
@ -4109,7 +4119,7 @@ public final class Main {
|
||||
} else {
|
||||
data = new byte[0];
|
||||
}
|
||||
ext.set(oid.toString(), new Extension(oid, isCritical,
|
||||
setExt(result, new Extension(oid, isCritical,
|
||||
new DerValue(DerValue.tag_OctetString, data)
|
||||
.toByteArray()));
|
||||
break;
|
||||
@ -4119,18 +4129,16 @@ public final class Main {
|
||||
}
|
||||
}
|
||||
// always non-critical
|
||||
ext.set(SubjectKeyIdentifierExtension.NAME,
|
||||
new SubjectKeyIdentifierExtension(
|
||||
new KeyIdentifier(pkey).getIdentifier()));
|
||||
setExt(result, new SubjectKeyIdentifierExtension(
|
||||
new KeyIdentifier(pkey).getIdentifier()));
|
||||
if (akey != null && !pkey.equals(akey)) {
|
||||
ext.set(AuthorityKeyIdentifierExtension.NAME,
|
||||
new AuthorityKeyIdentifierExtension(
|
||||
new KeyIdentifier(akey), null, null));
|
||||
setExt(result, new AuthorityKeyIdentifierExtension(
|
||||
new KeyIdentifier(akey), null, null));
|
||||
}
|
||||
} catch(IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return ext;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, 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
|
||||
@ -80,11 +80,13 @@ public class Debug {
|
||||
System.err.println("jar jar verification");
|
||||
System.err.println("logincontext login context results");
|
||||
System.err.println("jca JCA engine class debugging");
|
||||
System.err.println("keystore KeyStore debugging");
|
||||
System.err.println("policy loading and granting");
|
||||
System.err.println("provider security provider debugging");
|
||||
System.err.println("pkcs11 PKCS11 session manager debugging");
|
||||
System.err.println("pkcs11keystore");
|
||||
System.err.println(" PKCS11 KeyStore debugging");
|
||||
System.err.println("pkcs12 PKCS12 KeyStore debugging");
|
||||
System.err.println("sunpkcs11 SunPKCS11 provider debugging");
|
||||
System.err.println("scl permissions SecureClassLoader assigns");
|
||||
System.err.println("ts timestamping");
|
||||
@ -114,6 +116,10 @@ public class Debug {
|
||||
System.err.println(" KeyPairGenerator, KeyStore, Mac,");
|
||||
System.err.println(" MessageDigest, SecureRandom, Signature.");
|
||||
System.err.println();
|
||||
System.err.println("The following can be used with certpath:");
|
||||
System.err.println();
|
||||
System.err.println("ocsp dump the OCSP protocol exchanges");
|
||||
System.err.println();
|
||||
System.err.println("Note: Separate multiple options with a comma");
|
||||
System.exit(0);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2015, 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,7 +29,7 @@ package sun.util.logging;
|
||||
import java.lang.reflect.Field;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Date;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* Internal API to support JRE implementation to detect if the java.util.logging
|
||||
@ -145,6 +145,11 @@ public class LoggingSupport {
|
||||
return proxy.getLevelValue(level);
|
||||
}
|
||||
|
||||
// Since JDK 9, logging uses java.time to get more precise time stamps.
|
||||
// It is possible to configure the simple format to print nano seconds (.%1$tN)
|
||||
// by specifying:
|
||||
// java.util.logging.SimpleFormatter.format=%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS.%1$tN %1$Tp %2$s%n%4$s: %5$s%6$s%n
|
||||
// in the logging configuration
|
||||
private static final String DEFAULT_FORMAT =
|
||||
"%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%6$s%n";
|
||||
|
||||
@ -171,7 +176,7 @@ public class LoggingSupport {
|
||||
if (format != null) {
|
||||
try {
|
||||
// validate the user-defined format string
|
||||
String.format(format, new Date(), "", "", "", "", "");
|
||||
String.format(format, ZonedDateTime.now(), "", "", "", "", "");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// illegal syntax; fall back to the default format
|
||||
format = DEFAULT_FORMAT;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2015, 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
|
||||
@ -32,8 +32,11 @@ import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.time.Clock;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import sun.misc.JavaLangAccess;
|
||||
@ -514,11 +517,9 @@ public class PlatformLogger {
|
||||
|
||||
private static final String formatString =
|
||||
LoggingSupport.getSimpleFormat(false); // don't check logging.properties
|
||||
|
||||
// minimize memory allocation
|
||||
private Date date = new Date();
|
||||
private final ZoneId zoneId = ZoneId.systemDefault();
|
||||
private synchronized String format(Level level, String msg, Throwable thrown) {
|
||||
date.setTime(System.currentTimeMillis());
|
||||
ZonedDateTime zdt = ZonedDateTime.now(zoneId);
|
||||
String throwable = "";
|
||||
if (thrown != null) {
|
||||
StringWriter sw = new StringWriter();
|
||||
@ -530,7 +531,7 @@ public class PlatformLogger {
|
||||
}
|
||||
|
||||
return String.format(formatString,
|
||||
date,
|
||||
zdt,
|
||||
getCallerInfo(),
|
||||
name,
|
||||
level.name(),
|
||||
|
@ -651,9 +651,26 @@ static void
|
||||
SetJvmEnvironment(int argc, char **argv) {
|
||||
|
||||
static const char* NMT_Env_Name = "NMT_LEVEL_";
|
||||
|
||||
int i;
|
||||
for (i = 0; i < argc; i++) {
|
||||
char *arg = argv[i];
|
||||
/*
|
||||
* Since this must be a VM flag we stop processing once we see
|
||||
* an argument the launcher would not have processed beyond (such
|
||||
* as -version or -h), or an argument that indicates the following
|
||||
* arguments are for the application (i.e. the main class name, or
|
||||
* the -jar argument).
|
||||
*/
|
||||
if ((i > 0 && *arg != '-')
|
||||
|| JLI_StrCmp(arg, "-version") == 0
|
||||
|| JLI_StrCmp(arg, "-fullversion") == 0
|
||||
|| JLI_StrCmp(arg, "-help") == 0
|
||||
|| JLI_StrCmp(arg, "-?") == 0
|
||||
|| JLI_StrCmp(arg, "-jar") == 0
|
||||
|| JLI_StrCmp(arg, "-X") == 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* The following case checks for "-XX:NativeMemoryTracking=value".
|
||||
* If value is non null, an environmental variable set to this value
|
||||
@ -661,7 +678,6 @@ SetJvmEnvironment(int argc, char **argv) {
|
||||
* The argument is passed to the JVM, which will check validity.
|
||||
* The JVM is responsible for removing the env variable.
|
||||
*/
|
||||
char *arg = argv[i];
|
||||
if (JLI_StrCCmp(arg, "-XX:NativeMemoryTracking=") == 0) {
|
||||
int retval;
|
||||
// get what follows this parameter, include "="
|
||||
|
@ -88,6 +88,7 @@ JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_init
|
||||
/* SocketFlow fields */
|
||||
|
||||
c = (*env)->FindClass(env, "jdk/net/SocketFlow");
|
||||
CHECK_NULL(c);
|
||||
|
||||
/* status */
|
||||
|
||||
|
@ -201,7 +201,7 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this,
|
||||
}
|
||||
if (senderAddr == NULL) {
|
||||
jobject isa = NULL;
|
||||
int port;
|
||||
int port = 0;
|
||||
jobject ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
|
||||
if (ia != NULL) {
|
||||
isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port);
|
||||
|
@ -84,7 +84,7 @@ Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv *env, jobject this,
|
||||
int alloc_len;
|
||||
jobject remote_ia = 0;
|
||||
jobject isa;
|
||||
jint remote_port;
|
||||
jint remote_port = 0;
|
||||
|
||||
NET_AllocSockaddr(&sa, &alloc_len);
|
||||
if (sa == NULL) {
|
||||
|
@ -188,6 +188,7 @@ getJavaIDFromLangID(LANGID langID)
|
||||
free(elems[index]);
|
||||
}
|
||||
} else {
|
||||
free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,8 @@ package sun.awt.motif;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.*;
|
||||
import sun.nio.cs.ext.EUC_TW;
|
||||
import sun.nio.cs.*;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
public abstract class X11CNS11643 extends Charset {
|
||||
private final int plane;
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
package java.util.logging;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
@ -165,9 +166,7 @@ public abstract class Handler {
|
||||
*/
|
||||
public synchronized void setFormatter(Formatter newFormatter) throws SecurityException {
|
||||
checkPermission();
|
||||
// Check for a null pointer:
|
||||
newFormatter.getClass();
|
||||
formatter = newFormatter;
|
||||
formatter = Objects.requireNonNull(newFormatter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,10 +24,12 @@
|
||||
*/
|
||||
|
||||
package java.util.logging;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.io.*;
|
||||
import java.time.Clock;
|
||||
|
||||
import sun.misc.JavaLangAccess;
|
||||
import sun.misc.SharedSecrets;
|
||||
@ -88,55 +90,94 @@ public class LogRecord implements java.io.Serializable {
|
||||
private static final ThreadLocal<Integer> threadIds = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* @serial Logging message level
|
||||
* Logging message level
|
||||
*/
|
||||
private Level level;
|
||||
|
||||
/**
|
||||
* @serial Sequence number
|
||||
* Sequence number
|
||||
*/
|
||||
private long sequenceNumber;
|
||||
|
||||
/**
|
||||
* @serial Class that issued logging call
|
||||
* Class that issued logging call
|
||||
*/
|
||||
private String sourceClassName;
|
||||
|
||||
/**
|
||||
* @serial Method that issued logging call
|
||||
* Method that issued logging call
|
||||
*/
|
||||
private String sourceMethodName;
|
||||
|
||||
/**
|
||||
* @serial Non-localized raw message text
|
||||
* Non-localized raw message text
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* @serial Thread ID for thread that issued logging call.
|
||||
* Thread ID for thread that issued logging call.
|
||||
*/
|
||||
private int threadID;
|
||||
|
||||
/**
|
||||
* @serial Event time in milliseconds since 1970
|
||||
*/
|
||||
private long millis;
|
||||
|
||||
/**
|
||||
* @serial The Throwable (if any) associated with log message
|
||||
* The Throwable (if any) associated with log message
|
||||
*/
|
||||
private Throwable thrown;
|
||||
|
||||
/**
|
||||
* @serial Name of the source Logger.
|
||||
* Name of the source Logger.
|
||||
*/
|
||||
private String loggerName;
|
||||
|
||||
/**
|
||||
* @serial Resource bundle name to localized log message.
|
||||
* Resource bundle name to localized log message.
|
||||
*/
|
||||
private String resourceBundleName;
|
||||
|
||||
/**
|
||||
* Event time.
|
||||
* @since 1.9
|
||||
*/
|
||||
private Instant instant;
|
||||
|
||||
/**
|
||||
* @serialField level Level Logging message level
|
||||
* @serialField sequenceNumber long Sequence number
|
||||
* @serialField sourceClassName String Class that issued logging call
|
||||
* @serialField sourceMethodName String Method that issued logging call
|
||||
* @serialField message String Non-localized raw message text
|
||||
* @serialField threadID int Thread ID for thread that issued logging call
|
||||
* @serialField millis long Truncated event time in milliseconds since 1970
|
||||
* - calculated as getInstant().toEpochMilli().
|
||||
* The event time instant can be reconstructed using
|
||||
* <code>Instant.ofEpochSecond(millis/1000, (millis % 1000) * 1000_000 + nanoAdjustment)</code>
|
||||
* @serialField nanoAdjustment int Nanoseconds adjustment to the millisecond of
|
||||
* event time - calculated as getInstant().getNano() % 1000_000
|
||||
* The event time instant can be reconstructed using
|
||||
* <code>Instant.ofEpochSecond(millis/1000, (millis % 1000) * 1000_000 + nanoAdjustment)</code>
|
||||
* <p>
|
||||
* Since: 1.9
|
||||
* @serialField thrown Throwable The Throwable (if any) associated with log
|
||||
* message
|
||||
* @serialField loggerName String Name of the source Logger
|
||||
* @serialField resourceBundleName String Resource bundle name to localized
|
||||
* log message
|
||||
*/
|
||||
private static final ObjectStreamField[] serialPersistentFields =
|
||||
new ObjectStreamField[] {
|
||||
new ObjectStreamField("level", Level.class),
|
||||
new ObjectStreamField("sequenceNumber", long.class),
|
||||
new ObjectStreamField("sourceClassName", String.class),
|
||||
new ObjectStreamField("sourceMethodName", String.class),
|
||||
new ObjectStreamField("message", String.class),
|
||||
new ObjectStreamField("threadID", int.class),
|
||||
new ObjectStreamField("millis", long.class),
|
||||
new ObjectStreamField("nanoAdjustment", int.class),
|
||||
new ObjectStreamField("thrown", Throwable.class),
|
||||
new ObjectStreamField("loggerName", String.class),
|
||||
new ObjectStreamField("resourceBundleName", String.class),
|
||||
};
|
||||
|
||||
private transient boolean needToInferCaller;
|
||||
private transient Object parameters[];
|
||||
private transient ResourceBundle resourceBundle;
|
||||
@ -164,7 +205,10 @@ public class LogRecord implements java.io.Serializable {
|
||||
* The sequence property will be initialized with a new unique value.
|
||||
* These sequence values are allocated in increasing order within a VM.
|
||||
* <p>
|
||||
* The millis property will be initialized to the current time.
|
||||
* Since JDK 1.9, the event time is represented by an {@link Instant}.
|
||||
* The instant property will be initialized to the {@linkplain
|
||||
* Instant#now() current instant}, using the best available
|
||||
* {@linkplain Clock#systemUTC() clock} on the system.
|
||||
* <p>
|
||||
* The thread ID property will be initialized with a unique ID for
|
||||
* the current thread.
|
||||
@ -173,16 +217,15 @@ public class LogRecord implements java.io.Serializable {
|
||||
*
|
||||
* @param level a logging level value
|
||||
* @param msg the raw non-localized logging message (may be null)
|
||||
* @see java.time.Clock#systemUTC()
|
||||
*/
|
||||
public LogRecord(Level level, String msg) {
|
||||
// Make sure level isn't null, by calling random method.
|
||||
level.getClass();
|
||||
this.level = level;
|
||||
this.level = Objects.requireNonNull(level);
|
||||
message = msg;
|
||||
// Assign a thread ID and a unique sequence number.
|
||||
sequenceNumber = globalSequenceNumber.getAndIncrement();
|
||||
threadID = defaultThreadID();
|
||||
millis = System.currentTimeMillis();
|
||||
instant = Instant.now();
|
||||
needToInferCaller = true;
|
||||
}
|
||||
|
||||
@ -418,21 +461,63 @@ public class LogRecord implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get event time in milliseconds since 1970.
|
||||
* Get truncated event time in milliseconds since 1970.
|
||||
*
|
||||
* @return event time in millis since 1970
|
||||
* @return truncated event time in millis since 1970
|
||||
*
|
||||
* @implSpec This is equivalent to calling
|
||||
* {@link #getInstant() getInstant().toEpochMilli()}.
|
||||
*
|
||||
* @deprecated To get the full nanosecond resolution event time,
|
||||
* use {@link #getInstant()}.
|
||||
*
|
||||
* @see #getInstant()
|
||||
*/
|
||||
@Deprecated
|
||||
public long getMillis() {
|
||||
return millis;
|
||||
return instant.toEpochMilli();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set event time.
|
||||
*
|
||||
* @param millis event time in millis since 1970
|
||||
* @param millis event time in millis since 1970.
|
||||
*
|
||||
* @implSpec This is equivalent to calling
|
||||
* {@link #setInstant(java.time.Instant)
|
||||
* setInstant(Instant.ofEpochMilli(millis))}.
|
||||
*
|
||||
* @deprecated To set event time with nanosecond resolution,
|
||||
* use {@link #setInstant(java.time.Instant)}.
|
||||
*
|
||||
* @see #setInstant(java.time.Instant)
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMillis(long millis) {
|
||||
this.millis = millis;
|
||||
this.instant = Instant.ofEpochMilli(millis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instant that the event occurred.
|
||||
*
|
||||
* @return the instant that the event occurred.
|
||||
*
|
||||
* @since 1.9
|
||||
*/
|
||||
public Instant getInstant() {
|
||||
return instant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the instant that the event occurred.
|
||||
*
|
||||
* @param instant the instant that the event occurred.
|
||||
*
|
||||
* @throws NullPointerException if {@code instant} is null.
|
||||
* @since 1.9
|
||||
*/
|
||||
public void setInstant(Instant instant) {
|
||||
this.instant = Objects.requireNonNull(instant);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -459,7 +544,7 @@ public class LogRecord implements java.io.Serializable {
|
||||
private static final long serialVersionUID = 5372048053134512534L;
|
||||
|
||||
/**
|
||||
* @serialData Default fields, followed by a two byte version number
|
||||
* @serialData Serialized fields, followed by a two byte version number
|
||||
* (major byte, followed by minor byte), followed by information on
|
||||
* the log record parameter array. If there is no parameter array,
|
||||
* then -1 is written. If there is a parameter array (possible of zero
|
||||
@ -469,8 +554,20 @@ public class LogRecord implements java.io.Serializable {
|
||||
* is written.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream out) throws IOException {
|
||||
// We have to call defaultWriteObject first.
|
||||
out.defaultWriteObject();
|
||||
// We have to write serialized fields first.
|
||||
ObjectOutputStream.PutField pf = out.putFields();
|
||||
pf.put("level", level);
|
||||
pf.put("sequenceNumber", sequenceNumber);
|
||||
pf.put("sourceClassName", sourceClassName);
|
||||
pf.put("sourceMethodName", sourceMethodName);
|
||||
pf.put("message", message);
|
||||
pf.put("threadID", threadID);
|
||||
pf.put("millis", instant.toEpochMilli());
|
||||
pf.put("nanoAdjustment", instant.getNano() % 1000_000);
|
||||
pf.put("thrown", thrown);
|
||||
pf.put("loggerName", loggerName);
|
||||
pf.put("resourceBundleName", resourceBundleName);
|
||||
out.writeFields();
|
||||
|
||||
// Write our version number.
|
||||
out.writeByte(1);
|
||||
@ -488,8 +585,21 @@ public class LogRecord implements java.io.Serializable {
|
||||
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException {
|
||||
// We have to call defaultReadObject first.
|
||||
in.defaultReadObject();
|
||||
// We have to read serialized fields first.
|
||||
ObjectInputStream.GetField gf = in.readFields();
|
||||
level = (Level) gf.get("level", null);
|
||||
sequenceNumber = gf.get("sequenceNumber", 0L);
|
||||
sourceClassName = (String) gf.get("sourceClassName", null);
|
||||
sourceMethodName = (String) gf.get("sourceMethodName", null);
|
||||
message = (String) gf.get("message", null);
|
||||
threadID = gf.get("threadID", 0);
|
||||
long millis = gf.get("millis", 0L);
|
||||
int nanoOfMilli = gf.get("nanoAdjustment", 0);
|
||||
instant = Instant.ofEpochSecond(
|
||||
millis / 1000L, (millis % 1000L) * 1000_000L + nanoOfMilli);
|
||||
thrown = (Throwable) gf.get("thrown", null);
|
||||
loggerName = (String) gf.get("loggerName", null);
|
||||
resourceBundleName = (String) gf.get("resourceBundleName", null);
|
||||
|
||||
// Read version number.
|
||||
byte major = in.readByte();
|
||||
|
@ -33,6 +33,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Supplier;
|
||||
@ -1746,8 +1747,7 @@ public class Logger {
|
||||
* does not have LoggingPermission("control").
|
||||
*/
|
||||
public void addHandler(Handler handler) throws SecurityException {
|
||||
// Check for null handler
|
||||
handler.getClass();
|
||||
Objects.requireNonNull(handler);
|
||||
checkPermission();
|
||||
handlers.add(handler);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2015, 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
|
||||
@ -27,8 +27,9 @@
|
||||
package java.util.logging;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import sun.util.logging.LoggingSupport;
|
||||
|
||||
/**
|
||||
@ -59,8 +60,8 @@ import sun.util.logging.LoggingSupport;
|
||||
public class SimpleFormatter extends Formatter {
|
||||
|
||||
// format string for printing the log record
|
||||
private static final String format = LoggingSupport.getSimpleFormat();
|
||||
private final Date dat = new Date();
|
||||
private final String format = LoggingSupport.getSimpleFormat();
|
||||
private final ZoneId zoneId = ZoneId.systemDefault();
|
||||
|
||||
/**
|
||||
* Format the given LogRecord.
|
||||
@ -79,8 +80,9 @@ public class SimpleFormatter extends Formatter {
|
||||
* java.util.Formatter} format string specified in the
|
||||
* {@code java.util.logging.SimpleFormatter.format} property
|
||||
* or the default format.</li>
|
||||
* <li>{@code date} - a {@link Date} object representing
|
||||
* {@linkplain LogRecord#getMillis event time} of the log record.</li>
|
||||
* <li>{@code date} - a {@link ZonedDateTime} object representing
|
||||
* {@linkplain LogRecord#getInstant() event time} of the log record
|
||||
* in the {@link ZoneId#systemDefault()} system time zone.</li>
|
||||
* <li>{@code source} - a string representing the caller, if available;
|
||||
* otherwise, the logger's name.</li>
|
||||
* <li>{@code logger} - the logger's name.</li>
|
||||
@ -129,6 +131,16 @@ public class SimpleFormatter extends Formatter {
|
||||
* Mar 22, 2011 1:11:31 PM MyClass fatal
|
||||
* SEVERE: several message with an exception
|
||||
* </pre></li>
|
||||
* <li> {@code java.util.logging.SimpleFormatter.format="%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS.%1$tN %1$Tp %2$s%n%4$s: %5$s%6$s%n"}
|
||||
* <p>Since JDK 1.9, {@code java.util.logging} uses {@link
|
||||
* java.time.Clock#systemUTC() java.time} to create more precise time
|
||||
* stamps.
|
||||
* The format above can be used to add a {@code .%1$tN} to the
|
||||
* date/time formatting so that nanoseconds will also be printed:
|
||||
* <pre>
|
||||
* Feb 06, 2015 5:33:10.279216000 PM example.Main main
|
||||
* INFO: This is a test
|
||||
* </pre></li>
|
||||
* </ul>
|
||||
* <p>This method can also be overridden in a subclass.
|
||||
* It is recommended to use the {@link Formatter#formatMessage}
|
||||
@ -137,8 +149,10 @@ public class SimpleFormatter extends Formatter {
|
||||
* @param record the log record to be formatted.
|
||||
* @return a formatted log record
|
||||
*/
|
||||
@Override
|
||||
public synchronized String format(LogRecord record) {
|
||||
dat.setTime(record.getMillis());
|
||||
ZonedDateTime zdt = ZonedDateTime.ofInstant(
|
||||
record.getInstant(), zoneId);
|
||||
String source;
|
||||
if (record.getSourceClassName() != null) {
|
||||
source = record.getSourceClassName();
|
||||
@ -159,7 +173,7 @@ public class SimpleFormatter extends Formatter {
|
||||
throwable = sw.toString();
|
||||
}
|
||||
return String.format(format,
|
||||
dat,
|
||||
zdt,
|
||||
source,
|
||||
record.getLoggerName(),
|
||||
record.getLevel().getLocalizedLevelName(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,8 +26,9 @@
|
||||
|
||||
package java.util.logging;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -40,11 +41,70 @@ import java.util.*;
|
||||
* but it is recommended that it normally be used with UTF-8. The
|
||||
* character encoding can be set on the output Handler.
|
||||
*
|
||||
* @implSpec Since JDK 1.9, instances of {@linkplain LogRecord} contain
|
||||
* an {@link LogRecord#getInstant() Instant} which can have nanoseconds below
|
||||
* the millisecond resolution.
|
||||
* The DTD specification has been updated to allow for an optional
|
||||
* {@code <nanos>} element. By default, the XMLFormatter will compute the
|
||||
* nanosecond adjustment below the millisecond resolution (using
|
||||
* {@code LogRecord.getInstant().getNano() % 1000_000}) - and if this is not 0,
|
||||
* this adjustment value will be printed in the new {@code <nanos>} element.
|
||||
* The event instant can then be reconstructed using
|
||||
* {@code Instant.ofEpochSecond(millis/1000L, (millis % 1000L) * 1000_000L + nanos)}
|
||||
* where {@code millis} and {@code nanos} represent the numbers serialized in
|
||||
* the {@code <millis>} and {@code <nanos>} elements, respectively.
|
||||
* <br>
|
||||
* The {@code <date>} element will now contain the whole instant as formatted
|
||||
* by the {@link DateTimeFormatter#ISO_INSTANT DateTimeFormatter.ISO_INSTANT}
|
||||
* formatter.
|
||||
* <p>
|
||||
* For compatibility with old parsers, XMLFormatters can
|
||||
* be configured to revert to the old format by specifying a
|
||||
* {@code <xml-formatter-fully-qualified-class-name>.useInstant = false}
|
||||
* {@linkplain LogManager#getProperty(java.lang.String) property} in the
|
||||
* logging configuration. When {@code useInstant} is {@code false}, the old
|
||||
* formatting will be preserved. When {@code useInstant} is {@code true}
|
||||
* (the default), the {@code <nanos>} element will be printed and the
|
||||
* {@code <date>} element will contain the {@linkplain
|
||||
* DateTimeFormatter#ISO_INSTANT formatted} instant.
|
||||
* <p>
|
||||
* For instance, in order to configure plain instances of XMLFormatter to omit
|
||||
* the new {@code <nano>} element,
|
||||
* {@code java.util.logging.XMLFormatter.useInstant = false} can be specified
|
||||
* in the logging configuration.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class XMLFormatter extends Formatter {
|
||||
private LogManager manager = LogManager.getLogManager();
|
||||
private final LogManager manager = LogManager.getLogManager();
|
||||
private final boolean useInstant;
|
||||
|
||||
/**
|
||||
* Creates a new instance of XMLFormatter.
|
||||
*
|
||||
* @implSpec
|
||||
* Since JDK 1.9, the XMLFormatter will print out the record {@linkplain
|
||||
* LogRecord#getInstant() event time} as an Instant. This instant
|
||||
* has the best resolution available on the system. The {@code <date>}
|
||||
* element will contain the instant as formatted by the {@link
|
||||
* DateTimeFormatter#ISO_INSTANT}.
|
||||
* In addition, an optional {@code <nanos>} element containing a
|
||||
* nanosecond adjustment will be printed if the instant contains some
|
||||
* nanoseconds below the millisecond resolution.
|
||||
* <p>
|
||||
* This new behavior can be turned off, and the old formatting restored,
|
||||
* by specifying a property in the {@linkplain
|
||||
* LogManager#getProperty(java.lang.String) logging configuration}.
|
||||
* If {@code LogManager.getLogManager().getProperty(
|
||||
* this.getClass().getName()+".useInstant")} is {@code "false"} or
|
||||
* {@code "0"}, the old formatting will be restored.
|
||||
*/
|
||||
public XMLFormatter() {
|
||||
useInstant = (manager == null)
|
||||
|| manager.getBooleanProperty(
|
||||
this.getClass().getName()+".useInstant", true);
|
||||
}
|
||||
|
||||
// Append a two digit number.
|
||||
private void a2(StringBuilder sb, int x) {
|
||||
@ -102,18 +162,35 @@ public class XMLFormatter extends Formatter {
|
||||
* @param record the log record to be formatted.
|
||||
* @return a formatted log record
|
||||
*/
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
StringBuilder sb = new StringBuilder(500);
|
||||
sb.append("<record>\n");
|
||||
|
||||
final Instant instant = record.getInstant();
|
||||
|
||||
sb.append(" <date>");
|
||||
appendISO8601(sb, record.getMillis());
|
||||
if (useInstant) {
|
||||
// If useInstant is true - we will print the instant in the
|
||||
// date field, using the ISO_INSTANT formatter.
|
||||
DateTimeFormatter.ISO_INSTANT.formatTo(instant, sb);
|
||||
} else {
|
||||
// If useInstant is false - we will keep the 'old' formating
|
||||
appendISO8601(sb, instant.toEpochMilli());
|
||||
}
|
||||
sb.append("</date>\n");
|
||||
|
||||
sb.append(" <millis>");
|
||||
sb.append(record.getMillis());
|
||||
sb.append(instant.toEpochMilli());
|
||||
sb.append("</millis>\n");
|
||||
|
||||
final int nanoAdjustment = instant.getNano() % 1000_000;
|
||||
if (useInstant && nanoAdjustment != 0) {
|
||||
sb.append(" <nanos>");
|
||||
sb.append(nanoAdjustment);
|
||||
sb.append("</nanos>\n");
|
||||
}
|
||||
|
||||
sb.append(" <sequence>");
|
||||
sb.append(record.getSequenceNumber());
|
||||
sb.append("</sequence>\n");
|
||||
@ -223,6 +300,7 @@ public class XMLFormatter extends Formatter {
|
||||
* @param h The target handler (can be null)
|
||||
* @return a valid XML string
|
||||
*/
|
||||
@Override
|
||||
public String getHead(Handler h) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String encoding;
|
||||
@ -251,6 +329,7 @@ public class XMLFormatter extends Formatter {
|
||||
sb.append(encoding);
|
||||
sb.append("\"");
|
||||
sb.append(" standalone=\"no\"?>\n");
|
||||
|
||||
sb.append("<!DOCTYPE log SYSTEM \"logger.dtd\">\n");
|
||||
sb.append("<log>\n");
|
||||
return sb.toString();
|
||||
@ -262,6 +341,7 @@ public class XMLFormatter extends Formatter {
|
||||
* @param h The target handler (can be null)
|
||||
* @return a valid XML string
|
||||
*/
|
||||
@Override
|
||||
public String getTail(Handler h) {
|
||||
return "</log>\n";
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ import java.lang.management.PlatformManagedObject;
|
||||
* All methods throw a {@code NullPointerException} if any input argument is
|
||||
* {@code null} unless it's stated otherwise.
|
||||
*
|
||||
* @see ManagementFactory#getPlatformMXBeans(Class)
|
||||
* @see java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
|
||||
|
@ -31,12 +31,13 @@ import sun.management.ThreadInfoCompositeData;
|
||||
import static java.lang.Thread.State.*;
|
||||
|
||||
/**
|
||||
* Thread information. <tt>ThreadInfo</tt> contains the information
|
||||
* Thread information. {@code ThreadInfo} contains the information
|
||||
* about a thread including:
|
||||
* <h3>General thread information</h3>
|
||||
* <ul>
|
||||
* <li>Thread ID.</li>
|
||||
* <li>Name of the thread.</li>
|
||||
* <li>Whether a thread is a daemon thread</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Execution information</h3>
|
||||
@ -57,6 +58,7 @@ import static java.lang.Thread.State.*;
|
||||
* <li>List of object monitors locked by the thread.</li>
|
||||
* <li>List of <a href="LockInfo.html#OwnableSynchronizer">
|
||||
* ownable synchronizers</a> locked by the thread.</li>
|
||||
* <li>Thread priority</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h4><a name="SyncStats">Synchronization Statistics</a></h4>
|
||||
@ -78,7 +80,7 @@ import static java.lang.Thread.State.*;
|
||||
* the system, not for synchronization control.
|
||||
*
|
||||
* <h4>MXBean Mapping</h4>
|
||||
* <tt>ThreadInfo</tt> is mapped to a {@link CompositeData CompositeData}
|
||||
* {@code ThreadInfo} is mapped to a {@link CompositeData CompositeData}
|
||||
* with attributes as specified in
|
||||
* the {@link #from from} method.
|
||||
*
|
||||
@ -100,9 +102,11 @@ public class ThreadInfo {
|
||||
private String lockName;
|
||||
private long lockOwnerId;
|
||||
private String lockOwnerName;
|
||||
private boolean daemon;
|
||||
private boolean inNative;
|
||||
private boolean suspended;
|
||||
private Thread.State threadState;
|
||||
private int priority;
|
||||
private StackTraceElement[] stackTrace;
|
||||
private MonitorInfo[] lockedMonitors;
|
||||
private LockInfo[] lockedSynchronizers;
|
||||
@ -229,6 +233,8 @@ public class ThreadInfo {
|
||||
this.blockedTime = blockedTime;
|
||||
this.waitedCount = waitedCount;
|
||||
this.waitedTime = waitedTime;
|
||||
this.daemon = t.isDaemon();
|
||||
this.priority = t.getPriority();
|
||||
|
||||
if (lockObj == null) {
|
||||
this.lock = null;
|
||||
@ -256,7 +262,7 @@ public class ThreadInfo {
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructs a <tt>ThreadInfo</tt> object from a
|
||||
* Constructs a {@code ThreadInfo} object from a
|
||||
* {@link CompositeData CompositeData}.
|
||||
*/
|
||||
private ThreadInfo(CompositeData cd) {
|
||||
@ -277,7 +283,7 @@ public class ThreadInfo {
|
||||
stackTrace = ticd.stackTrace();
|
||||
|
||||
// 6.0 attributes
|
||||
if (ticd.isCurrentVersion()) {
|
||||
if (ticd.hasV6()) {
|
||||
lock = ticd.lockInfo();
|
||||
lockedMonitors = ticd.lockedMonitors();
|
||||
lockedSynchronizers = ticd.lockedSynchronizers();
|
||||
@ -300,10 +306,20 @@ public class ThreadInfo {
|
||||
lockedMonitors = EMPTY_MONITORS;
|
||||
lockedSynchronizers = EMPTY_SYNCS;
|
||||
}
|
||||
|
||||
// 9.0 attributes
|
||||
if (ticd.isCurrentVersion()) {
|
||||
daemon = ticd.isDaemon();
|
||||
priority = ticd.getPriority();
|
||||
} else {
|
||||
// Not ideal, but unclear what else we can do.
|
||||
daemon = false;
|
||||
priority = Thread.NORM_PRIORITY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the thread associated with this <tt>ThreadInfo</tt>.
|
||||
* Returns the ID of the thread associated with this {@code ThreadInfo}.
|
||||
*
|
||||
* @return the ID of the associated thread.
|
||||
*/
|
||||
@ -312,7 +328,7 @@ public class ThreadInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the thread associated with this <tt>ThreadInfo</tt>.
|
||||
* Returns the name of the thread associated with this {@code ThreadInfo}.
|
||||
*
|
||||
* @return the name of the associated thread.
|
||||
*/
|
||||
@ -321,9 +337,9 @@ public class ThreadInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the thread associated with this <tt>ThreadInfo</tt>.
|
||||
* Returns the state of the thread associated with this {@code ThreadInfo}.
|
||||
*
|
||||
* @return <tt>Thread.State</tt> of the associated thread.
|
||||
* @return {@code Thread.State} of the associated thread.
|
||||
*/
|
||||
public Thread.State getThreadState() {
|
||||
return threadState;
|
||||
@ -331,13 +347,13 @@ public class ThreadInfo {
|
||||
|
||||
/**
|
||||
* Returns the approximate accumulated elapsed time (in milliseconds)
|
||||
* that the thread associated with this <tt>ThreadInfo</tt>
|
||||
* that the thread associated with this {@code ThreadInfo}
|
||||
* has blocked to enter or reenter a monitor
|
||||
* since thread contention monitoring is enabled.
|
||||
* I.e. the total accumulated time the thread has been in the
|
||||
* {@link java.lang.Thread.State#BLOCKED BLOCKED} state since thread
|
||||
* contention monitoring was last enabled.
|
||||
* This method returns <tt>-1</tt> if thread contention monitoring
|
||||
* This method returns {@code -1} if thread contention monitoring
|
||||
* is disabled.
|
||||
*
|
||||
* <p>The Java virtual machine may measure the time with a high
|
||||
@ -345,8 +361,8 @@ public class ThreadInfo {
|
||||
* the thread contention monitoring is reenabled.
|
||||
*
|
||||
* @return the approximate accumulated elapsed time in milliseconds
|
||||
* that a thread entered the <tt>BLOCKED</tt> state;
|
||||
* <tt>-1</tt> if thread contention monitoring is disabled.
|
||||
* that a thread entered the {@code BLOCKED} state;
|
||||
* {@code -1} if thread contention monitoring is disabled.
|
||||
*
|
||||
* @throws java.lang.UnsupportedOperationException if the Java
|
||||
* virtual machine does not support this operation.
|
||||
@ -360,13 +376,13 @@ public class ThreadInfo {
|
||||
|
||||
/**
|
||||
* Returns the total number of times that
|
||||
* the thread associated with this <tt>ThreadInfo</tt>
|
||||
* the thread associated with this {@code ThreadInfo}
|
||||
* blocked to enter or reenter a monitor.
|
||||
* I.e. the number of times a thread has been in the
|
||||
* {@link java.lang.Thread.State#BLOCKED BLOCKED} state.
|
||||
*
|
||||
* @return the total number of times that the thread
|
||||
* entered the <tt>BLOCKED</tt> state.
|
||||
* entered the {@code BLOCKED} state.
|
||||
*/
|
||||
public long getBlockedCount() {
|
||||
return blockedCount;
|
||||
@ -374,14 +390,14 @@ public class ThreadInfo {
|
||||
|
||||
/**
|
||||
* Returns the approximate accumulated elapsed time (in milliseconds)
|
||||
* that the thread associated with this <tt>ThreadInfo</tt>
|
||||
* that the thread associated with this {@code ThreadInfo}
|
||||
* has waited for notification
|
||||
* since thread contention monitoring is enabled.
|
||||
* I.e. the total accumulated time the thread has been in the
|
||||
* {@link java.lang.Thread.State#WAITING WAITING}
|
||||
* or {@link java.lang.Thread.State#TIMED_WAITING TIMED_WAITING} state
|
||||
* since thread contention monitoring is enabled.
|
||||
* This method returns <tt>-1</tt> if thread contention monitoring
|
||||
* This method returns {@code -1} if thread contention monitoring
|
||||
* is disabled.
|
||||
*
|
||||
* <p>The Java virtual machine may measure the time with a high
|
||||
@ -389,9 +405,9 @@ public class ThreadInfo {
|
||||
* the thread contention monitoring is reenabled.
|
||||
*
|
||||
* @return the approximate accumulated elapsed time in milliseconds
|
||||
* that a thread has been in the <tt>WAITING</tt> or
|
||||
* <tt>TIMED_WAITING</tt> state;
|
||||
* <tt>-1</tt> if thread contention monitoring is disabled.
|
||||
* that a thread has been in the {@code WAITING} or
|
||||
* {@code TIMED_WAITING} state;
|
||||
* {@code -1} if thread contention monitoring is disabled.
|
||||
*
|
||||
* @throws java.lang.UnsupportedOperationException if the Java
|
||||
* virtual machine does not support this operation.
|
||||
@ -405,29 +421,29 @@ public class ThreadInfo {
|
||||
|
||||
/**
|
||||
* Returns the total number of times that
|
||||
* the thread associated with this <tt>ThreadInfo</tt>
|
||||
* the thread associated with this {@code ThreadInfo}
|
||||
* waited for notification.
|
||||
* I.e. the number of times that a thread has been
|
||||
* in the {@link java.lang.Thread.State#WAITING WAITING}
|
||||
* or {@link java.lang.Thread.State#TIMED_WAITING TIMED_WAITING} state.
|
||||
*
|
||||
* @return the total number of times that the thread
|
||||
* was in the <tt>WAITING</tt> or <tt>TIMED_WAITING</tt> state.
|
||||
* was in the {@code WAITING} or {@code TIMED_WAITING} state.
|
||||
*/
|
||||
public long getWaitedCount() {
|
||||
return waitedCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>LockInfo</tt> of an object for which
|
||||
* the thread associated with this <tt>ThreadInfo</tt>
|
||||
* Returns the {@code LockInfo} of an object for which
|
||||
* the thread associated with this {@code ThreadInfo}
|
||||
* is blocked waiting.
|
||||
* A thread can be blocked waiting for one of the following:
|
||||
* <ul>
|
||||
* <li>an object monitor to be acquired for entering or reentering
|
||||
* a synchronization block/method.
|
||||
* <br>The thread is in the {@link java.lang.Thread.State#BLOCKED BLOCKED}
|
||||
* state waiting to enter the <tt>synchronized</tt> statement
|
||||
* state waiting to enter the {@code synchronized} statement
|
||||
* or method.
|
||||
* </li>
|
||||
* <li>an object monitor to be notified by another thread.
|
||||
@ -448,11 +464,11 @@ public class ThreadInfo {
|
||||
* or a {@link java.util.concurrent.locks.Condition Condition}.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>This method returns <tt>null</tt> if the thread is not in any of
|
||||
* <p>This method returns {@code null} if the thread is not in any of
|
||||
* the above conditions.
|
||||
*
|
||||
* @return <tt>LockInfo</tt> of an object for which the thread
|
||||
* is blocked waiting if any; <tt>null</tt> otherwise.
|
||||
* @return {@code LockInfo} of an object for which the thread
|
||||
* is blocked waiting if any; {@code null} otherwise.
|
||||
* @since 1.6
|
||||
*/
|
||||
public LockInfo getLockInfo() {
|
||||
@ -462,19 +478,19 @@ public class ThreadInfo {
|
||||
/**
|
||||
* Returns the {@link LockInfo#toString string representation}
|
||||
* of an object for which the thread associated with this
|
||||
* <tt>ThreadInfo</tt> is blocked waiting.
|
||||
* {@code ThreadInfo} is blocked waiting.
|
||||
* This method is equivalent to calling:
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* getLockInfo().toString()
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* <p>This method will return <tt>null</tt> if this thread is not blocked
|
||||
* <p>This method will return {@code null} if this thread is not blocked
|
||||
* waiting for any object or if the object is not owned by any thread.
|
||||
*
|
||||
* @return the string representation of the object on which
|
||||
* the thread is blocked if any;
|
||||
* <tt>null</tt> otherwise.
|
||||
* {@code null} otherwise.
|
||||
*
|
||||
* @see #getLockInfo
|
||||
*/
|
||||
@ -484,14 +500,14 @@ public class ThreadInfo {
|
||||
|
||||
/**
|
||||
* Returns the ID of the thread which owns the object
|
||||
* for which the thread associated with this <tt>ThreadInfo</tt>
|
||||
* for which the thread associated with this {@code ThreadInfo}
|
||||
* is blocked waiting.
|
||||
* This method will return <tt>-1</tt> if this thread is not blocked
|
||||
* This method will return {@code -1} if this thread is not blocked
|
||||
* waiting for any object or if the object is not owned by any thread.
|
||||
*
|
||||
* @return the thread ID of the owner thread of the object
|
||||
* this thread is blocked on;
|
||||
* <tt>-1</tt> if this thread is not blocked
|
||||
* {@code -1} if this thread is not blocked
|
||||
* or if the object is not owned by any thread.
|
||||
*
|
||||
* @see #getLockInfo
|
||||
@ -502,14 +518,14 @@ public class ThreadInfo {
|
||||
|
||||
/**
|
||||
* Returns the name of the thread which owns the object
|
||||
* for which the thread associated with this <tt>ThreadInfo</tt>
|
||||
* for which the thread associated with this {@code ThreadInfo}
|
||||
* is blocked waiting.
|
||||
* This method will return <tt>null</tt> if this thread is not blocked
|
||||
* This method will return {@code null} if this thread is not blocked
|
||||
* waiting for any object or if the object is not owned by any thread.
|
||||
*
|
||||
* @return the name of the thread that owns the object
|
||||
* this thread is blocked on;
|
||||
* <tt>null</tt> if this thread is not blocked
|
||||
* {@code null} if this thread is not blocked
|
||||
* or if the object is not owned by any thread.
|
||||
*
|
||||
* @see #getLockInfo
|
||||
@ -520,7 +536,7 @@ public class ThreadInfo {
|
||||
|
||||
/**
|
||||
* Returns the stack trace of the thread
|
||||
* associated with this <tt>ThreadInfo</tt>.
|
||||
* associated with this {@code ThreadInfo}.
|
||||
* If no stack trace was requested for this thread info, this method
|
||||
* will return a zero-length array.
|
||||
* If the returned array is of non-zero length then the first element of
|
||||
@ -532,41 +548,66 @@ public class ThreadInfo {
|
||||
* <p>Some Java virtual machines may, under some circumstances, omit one
|
||||
* or more stack frames from the stack trace. In the extreme case,
|
||||
* a virtual machine that has no stack trace information concerning
|
||||
* the thread associated with this <tt>ThreadInfo</tt>
|
||||
* the thread associated with this {@code ThreadInfo}
|
||||
* is permitted to return a zero-length array from this method.
|
||||
*
|
||||
* @return an array of <tt>StackTraceElement</tt> objects of the thread.
|
||||
* @return an array of {@code StackTraceElement} objects of the thread.
|
||||
*/
|
||||
public StackTraceElement[] getStackTrace() {
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the thread associated with this <tt>ThreadInfo</tt>
|
||||
* is suspended. This method returns <tt>true</tt> if
|
||||
* Tests if the thread associated with this {@code ThreadInfo}
|
||||
* is suspended. This method returns {@code true} if
|
||||
* {@link Thread#suspend} has been called.
|
||||
*
|
||||
* @return <tt>true</tt> if the thread is suspended;
|
||||
* <tt>false</tt> otherwise.
|
||||
* @return {@code true} if the thread is suspended;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
public boolean isSuspended() {
|
||||
return suspended;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the thread associated with this <tt>ThreadInfo</tt>
|
||||
* Tests if the thread associated with this {@code ThreadInfo}
|
||||
* is executing native code via the Java Native Interface (JNI).
|
||||
* The JNI native code does not include
|
||||
* the virtual machine support code or the compiled native
|
||||
* code generated by the virtual machine.
|
||||
*
|
||||
* @return <tt>true</tt> if the thread is executing native code;
|
||||
* <tt>false</tt> otherwise.
|
||||
* @return {@code true} if the thread is executing native code;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
public boolean isInNative() {
|
||||
return inNative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the thread associated with this {@code ThreadInfo} is
|
||||
* a {@linkplain Thread#isDaemon daemon thread}.
|
||||
*
|
||||
* @return {@code true} if the thread is a daemon thread,
|
||||
* {@code false} otherwise.
|
||||
* @see Thread#isDaemon
|
||||
* @since 1.9
|
||||
*/
|
||||
public boolean isDaemon() {
|
||||
return daemon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@linkplain Thread#getPriority() thread priority} of the
|
||||
* thread associated with this {@code ThreadInfo}.
|
||||
*
|
||||
* @return The priority of the thread associated with this
|
||||
* {@code ThreadInfo}.
|
||||
* @since 1.9
|
||||
*/
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this thread info.
|
||||
* The format of this string depends on the implementation.
|
||||
@ -580,6 +621,8 @@ public class ThreadInfo {
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("\"" + getThreadName() + "\"" +
|
||||
(daemon ? " daemon" : "") +
|
||||
" prio=" + priority +
|
||||
" Id=" + getThreadId() + " " +
|
||||
getThreadState());
|
||||
if (getLockName() != null) {
|
||||
@ -647,9 +690,9 @@ public class ThreadInfo {
|
||||
private static final int MAX_FRAMES = 8;
|
||||
|
||||
/**
|
||||
* Returns a <tt>ThreadInfo</tt> object represented by the
|
||||
* given <tt>CompositeData</tt>.
|
||||
* The given <tt>CompositeData</tt> must contain the following attributes
|
||||
* Returns a {@code ThreadInfo} object represented by the
|
||||
* given {@code CompositeData}.
|
||||
* The given {@code CompositeData} must contain the following attributes
|
||||
* unless otherwise specified below:
|
||||
* <blockquote>
|
||||
* <table border summary="The attributes and their types the given CompositeData contains">
|
||||
@ -659,67 +702,67 @@ public class ThreadInfo {
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>threadId</td>
|
||||
* <td><tt>java.lang.Long</tt></td>
|
||||
* <td>{@code java.lang.Long}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>threadName</td>
|
||||
* <td><tt>java.lang.String</tt></td>
|
||||
* <td>{@code java.lang.String}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>threadState</td>
|
||||
* <td><tt>java.lang.String</tt></td>
|
||||
* <td>{@code java.lang.String}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>suspended</td>
|
||||
* <td><tt>java.lang.Boolean</tt></td>
|
||||
* <td>{@code java.lang.Boolean}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>inNative</td>
|
||||
* <td><tt>java.lang.Boolean</tt></td>
|
||||
* <td>{@code java.lang.Boolean}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>blockedCount</td>
|
||||
* <td><tt>java.lang.Long</tt></td>
|
||||
* <td>{@code java.lang.Long}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>blockedTime</td>
|
||||
* <td><tt>java.lang.Long</tt></td>
|
||||
* <td>{@code java.lang.Long}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>waitedCount</td>
|
||||
* <td><tt>java.lang.Long</tt></td>
|
||||
* <td>{@code java.lang.Long}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>waitedTime</td>
|
||||
* <td><tt>java.lang.Long</tt></td>
|
||||
* <td>{@code java.lang.Long}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>lockInfo</td>
|
||||
* <td><tt>javax.management.openmbean.CompositeData</tt>
|
||||
* <td>{@code javax.management.openmbean.CompositeData}
|
||||
* - the mapped type for {@link LockInfo} as specified in the
|
||||
* {@link LockInfo#from} method.
|
||||
* <p>
|
||||
* If <tt>cd</tt> does not contain this attribute,
|
||||
* the <tt>LockInfo</tt> object will be constructed from
|
||||
* the value of the <tt>lockName</tt> attribute. </td>
|
||||
* If {@code cd} does not contain this attribute,
|
||||
* the {@code LockInfo} object will be constructed from
|
||||
* the value of the {@code lockName} attribute. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>lockName</td>
|
||||
* <td><tt>java.lang.String</tt></td>
|
||||
* <td>{@code java.lang.String}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>lockOwnerId</td>
|
||||
* <td><tt>java.lang.Long</tt></td>
|
||||
* <td>{@code java.lang.Long}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>lockOwnerName</td>
|
||||
* <td><tt>java.lang.String</tt></td>
|
||||
* <td>{@code java.lang.String}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><a name="StackTrace">stackTrace</a></td>
|
||||
* <td><tt>javax.management.openmbean.CompositeData[]</tt>
|
||||
* <td>{@code javax.management.openmbean.CompositeData[]}
|
||||
* <p>
|
||||
* Each element is a <tt>CompositeData</tt> representing
|
||||
* Each element is a {@code CompositeData} representing
|
||||
* StackTraceElement containing the following attributes:
|
||||
* <blockquote>
|
||||
* <table cellspacing=1 cellpadding=0 summary="The attributes and their types the given CompositeData contains">
|
||||
@ -729,23 +772,23 @@ public class ThreadInfo {
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>className</td>
|
||||
* <td><tt>java.lang.String</tt></td>
|
||||
* <td>{@code java.lang.String}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>methodName</td>
|
||||
* <td><tt>java.lang.String</tt></td>
|
||||
* <td>{@code java.lang.String}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>fileName</td>
|
||||
* <td><tt>java.lang.String</tt></td>
|
||||
* <td>{@code java.lang.String}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>lineNumber</td>
|
||||
* <td><tt>java.lang.Integer</tt></td>
|
||||
* <td>{@code java.lang.Integer}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>nativeMethod</td>
|
||||
* <td><tt>java.lang.Boolean</tt></td>
|
||||
* <td>{@code java.lang.Boolean}</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
@ -753,35 +796,43 @@ public class ThreadInfo {
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>lockedMonitors</td>
|
||||
* <td><tt>javax.management.openmbean.CompositeData[]</tt>
|
||||
* <td>{@code javax.management.openmbean.CompositeData[]}
|
||||
* whose element type is the mapped type for
|
||||
* {@link MonitorInfo} as specified in the
|
||||
* {@link MonitorInfo#from Monitor.from} method.
|
||||
* <p>
|
||||
* If <tt>cd</tt> does not contain this attribute,
|
||||
* If {@code cd} does not contain this attribute,
|
||||
* this attribute will be set to an empty array. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>lockedSynchronizers</td>
|
||||
* <td><tt>javax.management.openmbean.CompositeData[]</tt>
|
||||
* <td>{@code javax.management.openmbean.CompositeData[]}
|
||||
* whose element type is the mapped type for
|
||||
* {@link LockInfo} as specified in the {@link LockInfo#from} method.
|
||||
* <p>
|
||||
* If <tt>cd</tt> does not contain this attribute,
|
||||
* If {@code cd} does not contain this attribute,
|
||||
* this attribute will be set to an empty array. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>daemon</td>
|
||||
* <td>{@code java.lang.Boolean}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>priority</td>
|
||||
* <td>{@code java.lang.Integer}</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
*
|
||||
* @param cd <tt>CompositeData</tt> representing a <tt>ThreadInfo</tt>
|
||||
* @param cd {@code CompositeData} representing a {@code ThreadInfo}
|
||||
*
|
||||
* @throws IllegalArgumentException if <tt>cd</tt> does not
|
||||
* represent a <tt>ThreadInfo</tt> with the attributes described
|
||||
* @throws IllegalArgumentException if {@code cd} does not
|
||||
* represent a {@code ThreadInfo} with the attributes described
|
||||
* above.
|
||||
*
|
||||
* @return a <tt>ThreadInfo</tt> object represented
|
||||
* by <tt>cd</tt> if <tt>cd</tt> is not <tt>null</tt>;
|
||||
* <tt>null</tt> otherwise.
|
||||
* @return a {@code ThreadInfo} object represented
|
||||
* by {@code cd} if {@code cd} is not {@code null};
|
||||
* {@code null} otherwise.
|
||||
*/
|
||||
public static ThreadInfo from(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
@ -798,12 +849,12 @@ public class ThreadInfo {
|
||||
/**
|
||||
* Returns an array of {@link MonitorInfo} objects, each of which
|
||||
* represents an object monitor currently locked by the thread
|
||||
* associated with this <tt>ThreadInfo</tt>.
|
||||
* associated with this {@code ThreadInfo}.
|
||||
* If no locked monitor was requested for this thread info or
|
||||
* no monitor is locked by the thread, this method
|
||||
* will return a zero-length array.
|
||||
*
|
||||
* @return an array of <tt>MonitorInfo</tt> objects representing
|
||||
* @return an array of {@code MonitorInfo} objects representing
|
||||
* the object monitors locked by the thread.
|
||||
*
|
||||
* @since 1.6
|
||||
@ -816,11 +867,11 @@ public class ThreadInfo {
|
||||
* Returns an array of {@link LockInfo} objects, each of which
|
||||
* represents an <a href="LockInfo.html#OwnableSynchronizer">ownable
|
||||
* synchronizer</a> currently locked by the thread associated with
|
||||
* this <tt>ThreadInfo</tt>. If no locked synchronizer was
|
||||
* this {@code ThreadInfo}. If no locked synchronizer was
|
||||
* requested for this thread info or no synchronizer is locked by
|
||||
* the thread, this method will return a zero-length array.
|
||||
*
|
||||
* @return an array of <tt>LockInfo</tt> objects representing
|
||||
* @return an array of {@code LockInfo} objects representing
|
||||
* the ownable synchronizers locked by the thread.
|
||||
*
|
||||
* @since 1.6
|
||||
|
@ -87,26 +87,6 @@ public class AgentConfigurationError extends Error {
|
||||
"agent.err.connector.server.io.error";
|
||||
public static final String INVALID_OPTION =
|
||||
"agent.err.invalid.option";
|
||||
public static final String INVALID_SNMP_PORT =
|
||||
"agent.err.invalid.snmp.port";
|
||||
public static final String INVALID_SNMP_TRAP_PORT =
|
||||
"agent.err.invalid.snmp.trap.port";
|
||||
public static final String UNKNOWN_SNMP_INTERFACE =
|
||||
"agent.err.unknown.snmp.interface";
|
||||
public static final String SNMP_ACL_FILE_NOT_SET =
|
||||
"agent.err.acl.file.notset";
|
||||
public static final String SNMP_ACL_FILE_NOT_FOUND =
|
||||
"agent.err.acl.file.notfound";
|
||||
public static final String SNMP_ACL_FILE_NOT_READABLE =
|
||||
"agent.err.acl.file.not.readable";
|
||||
public static final String SNMP_ACL_FILE_READ_FAILED =
|
||||
"agent.err.acl.file.read.failed";
|
||||
public static final String SNMP_ACL_FILE_ACCESS_NOT_RESTRICTED =
|
||||
"agent.err.acl.file.access.notrestricted";
|
||||
public static final String SNMP_ADAPTOR_START_FAILED =
|
||||
"agent.err.snmp.adaptor.start.failed";
|
||||
public static final String SNMP_MIB_INIT_FAILED =
|
||||
"agent.err.snmp.mib.init.failed";
|
||||
public static final String INVALID_STATE =
|
||||
"agent.err.invalid.state";
|
||||
|
||||
|
@ -43,23 +43,30 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
private final ThreadInfo threadInfo;
|
||||
private final CompositeData cdata;
|
||||
private final boolean currentVersion;
|
||||
private final boolean hasV6;
|
||||
|
||||
private ThreadInfoCompositeData(ThreadInfo ti) {
|
||||
this.threadInfo = ti;
|
||||
this.currentVersion = true;
|
||||
this.cdata = null;
|
||||
this.hasV6 = true;
|
||||
}
|
||||
|
||||
private ThreadInfoCompositeData(CompositeData cd) {
|
||||
this.threadInfo = null;
|
||||
this.currentVersion = ThreadInfoCompositeData.isCurrentVersion(cd);
|
||||
this.cdata = cd;
|
||||
this.hasV6 = ThreadInfoCompositeData.hasV6(cd);
|
||||
}
|
||||
|
||||
public ThreadInfo getThreadInfo() {
|
||||
return threadInfo;
|
||||
}
|
||||
|
||||
public boolean hasV6() {
|
||||
return hasV6;
|
||||
}
|
||||
|
||||
public boolean isCurrentVersion() {
|
||||
return currentVersion;
|
||||
}
|
||||
@ -124,6 +131,8 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
threadInfo.isInNative(),
|
||||
lockedMonitorsData,
|
||||
lockedSyncsData,
|
||||
threadInfo.isDaemon(),
|
||||
threadInfo.getPriority(),
|
||||
};
|
||||
|
||||
try {
|
||||
@ -151,6 +160,8 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
private static final String STACK_TRACE = "stackTrace";
|
||||
private static final String SUSPENDED = "suspended";
|
||||
private static final String IN_NATIVE = "inNative";
|
||||
private static final String DAEMON = "daemon";
|
||||
private static final String PRIORITY = "priority";
|
||||
private static final String LOCKED_MONITORS = "lockedMonitors";
|
||||
private static final String LOCKED_SYNCS = "lockedSynchronizers";
|
||||
|
||||
@ -171,6 +182,8 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
IN_NATIVE,
|
||||
LOCKED_MONITORS,
|
||||
LOCKED_SYNCS,
|
||||
DAEMON,
|
||||
PRIORITY,
|
||||
};
|
||||
|
||||
// New attributes added in 6.0 ThreadInfo
|
||||
@ -180,9 +193,16 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
LOCKED_SYNCS,
|
||||
};
|
||||
|
||||
private static final String[] threadInfoV9Attributes = {
|
||||
DAEMON,
|
||||
PRIORITY,
|
||||
};
|
||||
|
||||
// Current version of ThreadInfo
|
||||
private static final CompositeType threadInfoCompositeType;
|
||||
// Previous version of ThreadInfo
|
||||
private static final CompositeType threadInfoV6CompositeType;
|
||||
// Previous-previous version of ThreadInfo
|
||||
private static final CompositeType threadInfoV5CompositeType;
|
||||
private static final CompositeType lockInfoCompositeType;
|
||||
static {
|
||||
@ -193,7 +213,7 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
String[] itemNames =
|
||||
threadInfoCompositeType.keySet().toArray(new String[0]);
|
||||
int numV5Attributes = threadInfoItemNames.length -
|
||||
threadInfoV6Attributes.length;
|
||||
threadInfoV6Attributes.length - threadInfoV9Attributes.length;
|
||||
String[] v5ItemNames = new String[numV5Attributes];
|
||||
String[] v5ItemDescs = new String[numV5Attributes];
|
||||
OpenType<?>[] v5ItemTypes = new OpenType<?>[numV5Attributes];
|
||||
@ -213,6 +233,31 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
v5ItemNames,
|
||||
v5ItemDescs,
|
||||
v5ItemTypes);
|
||||
|
||||
|
||||
// Form a CompositeType for JDK 6.0 ThreadInfo version
|
||||
int numV6Attributes = threadInfoItemNames.length -
|
||||
threadInfoV9Attributes.length;
|
||||
String[] v6ItemNames = new String[numV6Attributes];
|
||||
String[] v6ItemDescs = new String[numV6Attributes];
|
||||
OpenType<?>[] v6ItemTypes = new OpenType<?>[numV6Attributes];
|
||||
i = 0;
|
||||
for (String n : itemNames) {
|
||||
if (isV5Attribute(n) || isV6Attribute(n)) {
|
||||
v6ItemNames[i] = n;
|
||||
v6ItemDescs[i] = threadInfoCompositeType.getDescription(n);
|
||||
v6ItemTypes[i] = threadInfoCompositeType.getType(n);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
threadInfoV6CompositeType =
|
||||
new CompositeType("java.lang.management.ThreadInfo",
|
||||
"Java SE 6 java.lang.management.ThreadInfo",
|
||||
v6ItemNames,
|
||||
v6ItemDescs,
|
||||
v6ItemTypes);
|
||||
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw new AssertionError(e);
|
||||
@ -236,6 +281,20 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (String n : threadInfoV9Attributes) {
|
||||
if (itemName.equals(n)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isV6Attribute(String itemName) {
|
||||
for (String n : threadInfoV9Attributes) {
|
||||
if (itemName.equals(n)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -247,6 +306,15 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
return isTypeMatched(threadInfoCompositeType, cd.getCompositeType());
|
||||
}
|
||||
|
||||
private static boolean hasV6(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
return isTypeMatched(threadInfoCompositeType, cd.getCompositeType()) ||
|
||||
isTypeMatched(threadInfoV6CompositeType, cd.getCompositeType());
|
||||
}
|
||||
|
||||
public long threadId() {
|
||||
return getLong(cdata, THREAD_ID);
|
||||
}
|
||||
@ -304,6 +372,14 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
return getBoolean(cdata, IN_NATIVE);
|
||||
}
|
||||
|
||||
public boolean isDaemon() {
|
||||
return getBoolean(cdata, DAEMON);
|
||||
}
|
||||
|
||||
public int getPriority(){
|
||||
return getInt(cdata, PRIORITY);
|
||||
}
|
||||
|
||||
public StackTraceElement[] stackTrace() {
|
||||
CompositeData[] stackTraceData =
|
||||
(CompositeData[]) cdata.get(STACK_TRACE);
|
||||
@ -368,9 +444,10 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
if (!isTypeMatched(threadInfoCompositeType, type)) {
|
||||
currentVersion = false;
|
||||
// check if cd is an older version
|
||||
if (!isTypeMatched(threadInfoV5CompositeType, type)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for ThreadInfo");
|
||||
if (!isTypeMatched(threadInfoV5CompositeType, type) &&
|
||||
!isTypeMatched(threadInfoV6CompositeType, type)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for ThreadInfo");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
@ -24,9 +23,6 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Localizations for Level names. For the US locale
|
||||
# these are the same as the non-localized level name.
|
||||
|
||||
agent.err.error = Error
|
||||
agent.err.exception = Exception thrown by the agent
|
||||
agent.err.warning = Warning
|
||||
@ -67,27 +63,9 @@ agent.err.access.file.notfound = Access file not found
|
||||
agent.err.connector.server.io.error = JMX connector server communication error
|
||||
|
||||
agent.err.invalid.option = Invalid option specified
|
||||
agent.err.invalid.snmp.port = Invalid com.sun.management.snmp.port number
|
||||
agent.err.invalid.snmp.trap.port = Invalid com.sun.management.snmp.trap number
|
||||
agent.err.unknown.snmp.interface = Unknown SNMP interface
|
||||
agent.err.acl.file.notset = No SNMP ACL file is specified but com.sun.management.snmp.acl=true
|
||||
agent.err.acl.file.notfound = SNMP ACL file not found
|
||||
agent.err.acl.file.not.readable = SNMP ACL file not readable
|
||||
agent.err.acl.file.read.failed = Failed in reading SNMP ACL file
|
||||
agent.err.acl.file.access.notrestricted = Password file read access must be restricted
|
||||
|
||||
agent.err.snmp.adaptor.start.failed = Failed to start SNMP adaptor with address
|
||||
agent.err.snmp.mib.init.failed = Failed to initialize SNMP MIB with error
|
||||
|
||||
jmxremote.ConnectorBootstrap.starting = Starting JMX Connector Server:
|
||||
jmxremote.ConnectorBootstrap.noAuthentication = No Authentication
|
||||
jmxremote.ConnectorBootstrap.ready = JMX Connector ready at: {0}
|
||||
jmxremote.ConnectorBootstrap.password.readonly = Password file read access must be restricted: {0}
|
||||
jmxremote.ConnectorBootstrap.file.readonly = File read access must be restricted: {0}
|
||||
|
||||
jmxremote.AdaptorBootstrap.getTargetList.processing = Processing ACL
|
||||
jmxremote.AdaptorBootstrap.getTargetList.adding = Adding target: {0}
|
||||
jmxremote.AdaptorBootstrap.getTargetList.starting = Starting Adaptor Server:
|
||||
jmxremote.AdaptorBootstrap.getTargetList.initialize1 = Adaptor ready.
|
||||
jmxremote.AdaptorBootstrap.getTargetList.initialize2 = SNMP Adaptor ready on: {0}:{1}
|
||||
jmxremote.AdaptorBootstrap.getTargetList.terminate = terminate {0}
|
||||
|
@ -46,7 +46,7 @@ public class AttachOperationFailedException extends IOException {
|
||||
* Constructs an <code>AttachOperationFailedException</code> with
|
||||
* the specified detail message.
|
||||
*
|
||||
* @param s the detail message.
|
||||
* @param message the detail message.
|
||||
*/
|
||||
public AttachOperationFailedException(String message) {
|
||||
super(message);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
package $PACKAGE$;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.CharBuffer;
|
||||
@ -79,7 +79,7 @@ public class EUC_TW extends Charset implements HistoricallyNamedCharset
|
||||
*/
|
||||
|
||||
public EUC_TW() {
|
||||
super("x-EUC-TW", ExtendedCharsets.aliasesFor("x-EUC-TW"));
|
||||
super("x-EUC-TW", $ALIASES$);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
@ -222,16 +222,6 @@ public class ExtendedCharsets extends AbstractCharsetProvider {
|
||||
|
||||
}
|
||||
}
|
||||
String osName = getProperty("os.name");
|
||||
if ("SunOS".equals(osName) || "Linux".equals(osName) || "AIX".equals(osName)
|
||||
|| osName.contains("OS X")) {
|
||||
charset("x-COMPOUND_TEXT", "COMPOUND_TEXT",
|
||||
new String[] {
|
||||
"COMPOUND_TEXT", // JDK historical
|
||||
"x11-compound_text",
|
||||
"x-compound-text"
|
||||
});
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import sun.nio.cs.*;
|
||||
|
||||
public class ISO2022_CN_CNS extends ISO2022 implements HistoricallyNamedCharset
|
||||
{
|
||||
|
@ -31,7 +31,6 @@ import java.nio.channels.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
import java.util.*;
|
||||
import sun.net.www.MessageHeader;
|
||||
|
||||
/**
|
||||
* This class encapsulates a HTTP request received and a
|
||||
|
@ -29,7 +29,6 @@ import com.sun.net.httpserver.*;
|
||||
import java.io.*;
|
||||
import java.nio.*;
|
||||
import java.nio.channels.*;
|
||||
import sun.net.www.MessageHeader;
|
||||
import java.util.*;
|
||||
import javax.security.auth.*;
|
||||
import javax.security.auth.callback.*;
|
||||
|
@ -31,7 +31,6 @@ import java.nio.channels.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
import java.util.*;
|
||||
import sun.net.www.MessageHeader;
|
||||
import com.sun.net.httpserver.*;
|
||||
import com.sun.net.httpserver.spi.*;
|
||||
|
||||
|
@ -31,7 +31,6 @@ import java.nio.channels.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
import java.util.*;
|
||||
import sun.net.www.MessageHeader;
|
||||
import com.sun.net.httpserver.*;
|
||||
import com.sun.net.httpserver.spi.*;
|
||||
|
||||
|
@ -145,7 +145,7 @@ public interface InterfaceType extends ReferenceType {
|
||||
* not be done from the client's event handler thread.
|
||||
* <p>
|
||||
* The resumption of other threads during the invocation can be prevented
|
||||
* by specifying the {@link #INVOKE_SINGLE_THREADED}
|
||||
* by specifying the {@link ClassType#INVOKE_SINGLE_THREADED}
|
||||
* bit flag in the <code>options</code> argument; however,
|
||||
* there is no protection against or recovery from the deadlocks
|
||||
* described above, so this option should be used with great caution.
|
||||
|
@ -431,7 +431,7 @@ jobjectArray getRemoteAddresses
|
||||
paddr = addr_buf;
|
||||
for (i=0; i<addrCount; i++) {
|
||||
jobject ia, isa = NULL;
|
||||
int port;
|
||||
int port = 0;
|
||||
sap = (struct sockaddr*)addr_buf;
|
||||
ia = NET_SockaddrToInetAddress(env, sap, &port);
|
||||
if (ia != NULL)
|
||||
@ -543,6 +543,7 @@ JNIEXPORT int JNICALL Java_sun_nio_ch_sctp_SctpNet_getIntOption0
|
||||
void *arg;
|
||||
int arglen;
|
||||
|
||||
memset((char *) &linger, 0, sizeof(linger));
|
||||
if (mapSocketOption(opt, &klevel, &kopt) < 0) {
|
||||
JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
|
||||
"Unsupported socket option");
|
||||
@ -600,7 +601,7 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPrimAddrOption0
|
||||
(JNIEnv *env, jclass klass, jint fd, jint assocId, jobject iaObj, jint port) {
|
||||
struct sctp_setprim prim;
|
||||
struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
|
||||
int sap_len;
|
||||
int sap_len = sizeof(sap);
|
||||
|
||||
if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
|
||||
&sap_len, JNI_TRUE) != 0) {
|
||||
@ -625,7 +626,7 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPeerPrimAddrOption0
|
||||
jobject iaObj, jint port, jboolean preferIPv6) {
|
||||
struct sctp_setpeerprim prim;
|
||||
struct sockaddr* sap = (struct sockaddr*)&prim.sspp_addr;
|
||||
int sap_len;
|
||||
int sap_len = sizeof(sap);
|
||||
|
||||
if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
|
||||
&sap_len, preferIPv6) != 0) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2013, 2015, 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
|
||||
@ -567,7 +567,6 @@ needs_compact3 = \
|
||||
javax/smartcardio \
|
||||
javax/sql/rowset \
|
||||
javax/xml/crypto \
|
||||
sun/security/acl \
|
||||
sun/security/jgss \
|
||||
sun/security/krb5 \
|
||||
java/lang/annotation/AnnotationType/AnnotationTypeDeadlockTest.java \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, 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
|
||||
@ -22,11 +22,16 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @test
|
||||
* @bug 4858522
|
||||
* @summary Basic unit test of OperatingSystemMXBean.getTotalSwapSpaceSize()
|
||||
*
|
||||
* @library /lib/testlibrary
|
||||
* @build TestTotalSwap jdk.testlibrary.*
|
||||
* @run main TestTotalSwap
|
||||
*
|
||||
* @author Steve Bohne
|
||||
* @author Jaroslav Bachorik
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -50,9 +55,13 @@
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import java.lang.management.*;
|
||||
|
||||
public class GetTotalSwapSpaceSize {
|
||||
import jdk.testlibrary.OSInfo;
|
||||
import jdk.testlibrary.ProcessTools;
|
||||
import jdk.testlibrary.OutputAnalyzer;
|
||||
|
||||
private static OperatingSystemMXBean mbean =
|
||||
public class TestTotalSwap {
|
||||
|
||||
private static final OperatingSystemMXBean mbean =
|
||||
(com.sun.management.OperatingSystemMXBean)
|
||||
ManagementFactory.getOperatingSystemMXBean();
|
||||
|
||||
@ -62,19 +71,9 @@ public class GetTotalSwapSpaceSize {
|
||||
private static long min_size_for_pass = 0;
|
||||
private static final long MAX_SIZE_FOR_PASS = Long.MAX_VALUE;
|
||||
|
||||
private static boolean trace = false;
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
if (args.length > 1 && args[1].equals("trace")) {
|
||||
trace = true;
|
||||
}
|
||||
|
||||
long expected_swap_size = 0;
|
||||
|
||||
if (args.length < 1 || args.length > 2) {
|
||||
throw new IllegalArgumentException("Unexpected number of args " + args.length);
|
||||
}
|
||||
public static void main(String args[]) throws Throwable {
|
||||
|
||||
long expected_swap_size = getSwapSizeFromOs();
|
||||
|
||||
long min_size = mbean.getFreeSwapSpaceSize();
|
||||
if (min_size > 0) {
|
||||
@ -83,12 +82,9 @@ public class GetTotalSwapSpaceSize {
|
||||
|
||||
long size = mbean.getTotalSwapSpaceSize();
|
||||
|
||||
if (trace) {
|
||||
System.out.println("Total swap space size in bytes: " + size);
|
||||
}
|
||||
System.out.println("Total swap space size in bytes: " + size);
|
||||
|
||||
if (!args[0].matches("sanity-only")) {
|
||||
expected_swap_size = Long.parseLong(args[0]);
|
||||
if (expected_swap_size > -1) {
|
||||
if (size != expected_swap_size) {
|
||||
throw new RuntimeException("Expected total swap size : " +
|
||||
expected_swap_size +
|
||||
@ -97,6 +93,7 @@ public class GetTotalSwapSpaceSize {
|
||||
}
|
||||
}
|
||||
|
||||
// sanity check
|
||||
if (size < min_size_for_pass || size > MAX_SIZE_FOR_PASS) {
|
||||
throw new RuntimeException("Total swap space size " +
|
||||
"illegal value: " + size + " bytes " +
|
||||
@ -106,4 +103,60 @@ public class GetTotalSwapSpaceSize {
|
||||
|
||||
System.out.println("Test passed.");
|
||||
}
|
||||
|
||||
private static long getSwapSizeFromOs() throws Throwable {
|
||||
OSInfo.OSType os = OSInfo.getOSType();
|
||||
|
||||
switch (os) {
|
||||
// total used free shared buffers cached
|
||||
// Mem: 16533540864 13638467584 2895073280 534040576 1630248960 6236909568
|
||||
// -/+ buffers/cache: 5771309056 10762231808
|
||||
// Swap: 15999168512 0 15999168512
|
||||
|
||||
case LINUX: {
|
||||
String swapSizeStr = ProcessTools.executeCommand("free", "-b")
|
||||
.firstMatch("Swap:\\s+([0-9]+)\\s+.*", 1);
|
||||
return Long.parseLong(swapSizeStr);
|
||||
}
|
||||
case SOLARIS: {
|
||||
// swapfile dev swaplo blocks free
|
||||
// /dev/dsk/c0t0d0s1 136,1 16 1638608 1600528
|
||||
OutputAnalyzer out= ProcessTools.executeCommand(
|
||||
"/usr/sbin/swap",
|
||||
"-l"
|
||||
);
|
||||
|
||||
long swapSize = 0;
|
||||
|
||||
for (String line : out.asLines()) {
|
||||
if (line.contains("swapfile")) continue;
|
||||
|
||||
String[] vals = line.split("\\s+");
|
||||
if (vals.length == 5) {
|
||||
swapSize += Long.parseLong(vals[3]) * 512; // size is reported in 512b blocks
|
||||
}
|
||||
}
|
||||
|
||||
return swapSize;
|
||||
}
|
||||
case MACOSX: {
|
||||
// total = 8192.00M used = 7471.11M free = 720.89M (encrypted)
|
||||
String swapSizeStr = ProcessTools.executeCommand(
|
||||
"/usr/sbin/sysctl",
|
||||
"-n",
|
||||
"vm.swapusage"
|
||||
).firstMatch("total\\s+=\\s+([0-9]+(\\.[0-9]+)?[Mm]?).*", 1);
|
||||
if (swapSizeStr.toLowerCase().endsWith("m")) {
|
||||
swapSizeStr = swapSizeStr.substring(0, swapSizeStr.length() - 1);
|
||||
return (long)(Double.parseDouble(swapSizeStr) * 1024 * 1024); // size in MB
|
||||
}
|
||||
return (long)(Double.parseDouble(swapSizeStr) * 1024 * 1024);
|
||||
}
|
||||
default: {
|
||||
System.err.println("Unsupported operating system: " + os);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
#
|
||||
# @test
|
||||
# @summary Tests MM getTotalSwapSpaceSize() api.
|
||||
# @author Swamy V
|
||||
# @bug 6252770
|
||||
#
|
||||
# @run build GetTotalSwapSpaceSize
|
||||
# @run shell TestTotalSwap.sh
|
||||
#
|
||||
|
||||
#
|
||||
# This test tests the actual swap size on linux and solaris.
|
||||
# On windows this is just a sanity check and correct size should
|
||||
# be checked manually:
|
||||
#
|
||||
# Windows NT/XP/2000:
|
||||
# 1. Run Start->Accessories->System Tools->System Information.
|
||||
# 2. The value (reported in Kbytes) is in the "Page File Space" entry
|
||||
# Windows 98/ME:
|
||||
# Unknown.
|
||||
#
|
||||
|
||||
|
||||
#set -x
|
||||
|
||||
#Set appropriate jdk
|
||||
#
|
||||
|
||||
if [ ! -z "${TESTJAVA}" ] ; then
|
||||
jdk="$TESTJAVA"
|
||||
else
|
||||
echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
runOne()
|
||||
{
|
||||
echo "runOne $@"
|
||||
$TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 3
|
||||
}
|
||||
|
||||
solaris_swap_size()
|
||||
{
|
||||
total_swap=0
|
||||
for i in `/usr/sbin/swap -l | awk '{print $4}' | grep -v blocks`
|
||||
do
|
||||
# swap -l returns size in blocks of 512 bytes.
|
||||
total_swap=`expr $i \* 512 + $total_swap`
|
||||
done
|
||||
}
|
||||
|
||||
# Test GetTotalSwapSpaceSize if we are running on Unix
|
||||
total_swap=0
|
||||
case `uname -s` in
|
||||
SunOS )
|
||||
solaris_swap_size
|
||||
runOne GetTotalSwapSpaceSize $total_swap
|
||||
;;
|
||||
Linux )
|
||||
total_swap=`free -b | grep -i swap | awk '{print $2}'`
|
||||
runOne GetTotalSwapSpaceSize $total_swap
|
||||
;;
|
||||
Darwin )
|
||||
# $ sysctl -n vm.swapusage
|
||||
# total = 8192.00M used = 7471.11M free = 720.89M (encrypted)
|
||||
swap=`/usr/sbin/sysctl -n vm.swapusage | awk '{ print $3 }' | awk -F . '{ print $1 }'` || exit 2
|
||||
total_swap=`expr $swap \* 1024 \* 1024` || exit 2
|
||||
runOne GetTotalSwapSpaceSize $total_swap
|
||||
;;
|
||||
* )
|
||||
runOne GetTotalSwapSpaceSize "sanity-only"
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
@ -1,12 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1997, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 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.
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
@ -23,28 +21,30 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.security.acl;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.security.acl.*;
|
||||
|
||||
/**
|
||||
* This class implements the principal interface for the set of all permissions.
|
||||
* @author Satish Dharmaraj
|
||||
/*
|
||||
* @test
|
||||
* @bug 8014678
|
||||
* @run main EnclosingConstructorWithSecurityManager
|
||||
* @run main/othervm EnclosingConstructorWithSecurityManager "WithSecurityManager"
|
||||
*/
|
||||
public class AllPermissionsImpl extends PermissionImpl {
|
||||
|
||||
public AllPermissionsImpl(String s) {
|
||||
super(s);
|
||||
public class EnclosingConstructorWithSecurityManager {
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 1) {
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
}
|
||||
|
||||
new Inner();
|
||||
Inner.theInner.getEnclosingConstructor();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns true if the permission passed matches the permission represented in
|
||||
* this interface.
|
||||
* @param another The Permission object to compare with.
|
||||
* @returns true always
|
||||
*/
|
||||
public boolean equals(Permission another) {
|
||||
return true;
|
||||
public static class Inner {
|
||||
public static Class<?> theInner;
|
||||
|
||||
public Inner() {
|
||||
Object o = new Object() {
|
||||
};
|
||||
Inner.theInner = o.getClass();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8014678
|
||||
* @run main EnclosingMethodWithSecurityManager
|
||||
* @run main/othervm EnclosingMethodWithSecurityManager "WithSecurityManager"
|
||||
*/
|
||||
|
||||
public class EnclosingMethodWithSecurityManager {
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 1) {
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
}
|
||||
|
||||
new Inner().setTheInner();
|
||||
Inner.theInner.getEnclosingMethod();
|
||||
}
|
||||
|
||||
public static class Inner {
|
||||
public static Class<?> theInner;
|
||||
|
||||
public void setTheInner() {
|
||||
Object o = new Object() {
|
||||
};
|
||||
Inner.theInner = o.getClass();
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Objects;
|
||||
|
||||
interface Intf {
|
||||
static int i = 0;
|
||||
@ -40,9 +41,8 @@ interface Intf {
|
||||
|
||||
public class Test8009222 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
MethodHandles.lookup()
|
||||
.findStaticGetter(Intf.class, "i", int.class)
|
||||
.getClass(); // null check
|
||||
Objects.requireNonNull(MethodHandles.lookup()
|
||||
.findStaticGetter(Intf.class, "i", int.class));
|
||||
|
||||
System.out.println("TEST PASSED");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2015, 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
|
||||
@ -32,6 +32,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@ -235,8 +236,23 @@ public class LogGeneratedClassesTest extends LUtils {
|
||||
.filter(s -> s.startsWith("WARNING: Exception"))
|
||||
.count(),
|
||||
2, "show error each capture");
|
||||
// dumpLong/com/example/nosense/nosense
|
||||
assertEquals(Files.walk(Paths.get("dumpLong")).count(), 5, "Two lambda captured failed to log");
|
||||
// dumpLong/com/example/nonsense/nonsense
|
||||
Path dumpPath = Paths.get("dumpLong/com/example/nonsense");
|
||||
Predicate<Path> filter = p -> p.getParent() == null || dumpPath.startsWith(p) || p.startsWith(dumpPath);
|
||||
boolean debug = true;
|
||||
if (debug) {
|
||||
Files.walk(Paths.get("dumpLong"))
|
||||
.forEachOrdered(p -> {
|
||||
if (filter.test(p)) {
|
||||
System.out.println("accepted: " + p.toString());
|
||||
} else {
|
||||
System.out.println("filetered out: " + p.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
assertEquals(Files.walk(Paths.get("dumpLong"))
|
||||
.filter(filter)
|
||||
.count(), 5, "Two lambda captured failed to log");
|
||||
tr.assertZero("Should still return 0");
|
||||
}
|
||||
}
|
||||
|
@ -147,6 +147,11 @@ public class ThreadInfoCompositeData {
|
||||
info.getLockOwnerName() + " expected = " +
|
||||
values[LOCK_OWNER_NAME]);
|
||||
}
|
||||
if (!values[DAEMON].equals(info.isDaemon())) {
|
||||
throw new RuntimeException("Daemon = " +
|
||||
info.isDaemon() + " expected = " +
|
||||
values[DAEMON]);
|
||||
}
|
||||
|
||||
checkStackTrace(info.getStackTrace());
|
||||
|
||||
@ -258,8 +263,11 @@ public class ThreadInfoCompositeData {
|
||||
private static final int SUSPENDED = 11;
|
||||
private static final int IN_NATIVE = 12;
|
||||
private static final int NUM_V5_ATTS = 13;
|
||||
// JDK 6.0 ThreadInfo attribtues
|
||||
// JDK 6.0 ThreadInfo attributes
|
||||
private static final int LOCK_INFO = 13;
|
||||
// JDK 9.0 ThreadInfo attributes
|
||||
private static final int DAEMON = 14;
|
||||
private static final int PRIORITY = 15;
|
||||
|
||||
private static final String[] validItemNames = {
|
||||
"threadId",
|
||||
@ -276,6 +284,8 @@ public class ThreadInfoCompositeData {
|
||||
"suspended",
|
||||
"inNative",
|
||||
"lockInfo",
|
||||
"daemon",
|
||||
"priority",
|
||||
};
|
||||
|
||||
private static OpenType[] validItemTypes = {
|
||||
@ -293,6 +303,8 @@ public class ThreadInfoCompositeData {
|
||||
SimpleType.BOOLEAN,
|
||||
SimpleType.BOOLEAN,
|
||||
null, // CompositeType for LockInfo
|
||||
SimpleType.BOOLEAN,
|
||||
SimpleType.INTEGER,
|
||||
};
|
||||
|
||||
private static Object[] values = {
|
||||
@ -310,6 +322,8 @@ public class ThreadInfoCompositeData {
|
||||
new Boolean(false),
|
||||
new Boolean(false),
|
||||
null, // To be initialized to lockInfoCD
|
||||
new Boolean(false),
|
||||
Thread.NORM_PRIORITY,
|
||||
};
|
||||
|
||||
private static final String[] steItemNames = {
|
||||
@ -381,6 +395,8 @@ public class ThreadInfoCompositeData {
|
||||
"suspended",
|
||||
"inNative",
|
||||
"lockInfo",
|
||||
"daemon",
|
||||
"priority",
|
||||
};
|
||||
private static final OpenType[] badItemTypes = {
|
||||
SimpleType.LONG,
|
||||
@ -397,6 +413,8 @@ public class ThreadInfoCompositeData {
|
||||
SimpleType.BOOLEAN,
|
||||
SimpleType.BOOLEAN,
|
||||
SimpleType.LONG, // bad type
|
||||
SimpleType.BOOLEAN,
|
||||
SimpleType.INTEGER,
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.lang.management.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6588467
|
||||
* @summary Basic test of ThreadInfo.isDaemon
|
||||
* @author Jeremy Manson
|
||||
*/
|
||||
public class ThreadDaemonTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
final int NUM_THREADS = 20;
|
||||
final String THREAD_PREFIX = "ThreadDaemonTest-";
|
||||
|
||||
final CountDownLatch started = new CountDownLatch(NUM_THREADS);
|
||||
final CountDownLatch finished = new CountDownLatch(1);
|
||||
final AtomicReference<Exception> fail = new AtomicReference<>(null);
|
||||
|
||||
Thread[] allThreads = new Thread[NUM_THREADS];
|
||||
ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
|
||||
Random rand = new Random();
|
||||
|
||||
for (int i = 0; i < NUM_THREADS; i++) {
|
||||
allThreads[i] = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
started.countDown();
|
||||
finished.await();
|
||||
} catch (InterruptedException e) {
|
||||
fail.set(new Exception(
|
||||
"Unexpected InterruptedException"));
|
||||
}
|
||||
}
|
||||
}, THREAD_PREFIX + i);
|
||||
allThreads[i].setDaemon(rand.nextBoolean());
|
||||
allThreads[i].start();
|
||||
}
|
||||
|
||||
started.await();
|
||||
try {
|
||||
ThreadInfo[] allThreadInfos = mbean.dumpAllThreads(false, false);
|
||||
int count = 0;
|
||||
for (int i = 0; i < allThreadInfos.length; i++) {
|
||||
String threadName = allThreadInfos[i].getThreadName();
|
||||
if (threadName.startsWith(THREAD_PREFIX)) {
|
||||
count++;
|
||||
String[] nameAndNumber = threadName.split("-");
|
||||
int threadNum = Integer.parseInt(nameAndNumber[1]);
|
||||
if (allThreads[threadNum].isDaemon() !=
|
||||
allThreadInfos[i].isDaemon()) {
|
||||
throw new RuntimeException(
|
||||
allThreads[threadNum] + " is not like " +
|
||||
allThreadInfos[i] + ". TEST FAILED.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count != NUM_THREADS) {
|
||||
throw new RuntimeException("Wrong number of threads examined");
|
||||
}
|
||||
}
|
||||
finally { finished.countDown(); }
|
||||
|
||||
for (int i = 0; i < NUM_THREADS; i++) {
|
||||
allThreads[i].join();
|
||||
}
|
||||
if (fail.get() != null) {
|
||||
throw fail.get();
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user