提交 4fc81042 编写于 作者: L lana

Merge

......@@ -182,3 +182,5 @@ e8569a473cee7f4955bd9e76a9bdf6c6a07ced27 jdk8-b52
d94613ac03d8de375ef60493e2bb76dbd30d875d jdk8-b58
abad1f417bd3df4296631fc943cd3b7f5062c88a jdk8-b59
cec8fa02f15634acd7d02d04b0b2d8c044cdbaaa jdk8-b60
61ddb3fd000a09ab05bff1940b0ac211661e94cf jdk8-b61
50b8b17449d200c66bfd68fb4f3a9197432c9e2b jdk8-b62
......@@ -2,11 +2,11 @@ DO NOT TRANSLATE OR LOCALIZE.
-----------------------------
%% This notice is provided with respect to ASM Bytecode Manipulation
Framework v3.1, which is included with JRE 7, JDK 7, and OpenJDK 7.
Framework v4.0, which is included with JRE 8, and JDK 8.
--- begin of LICENSE ---
Copyright (c) 2000-2005 INRIA, France Telecom
Copyright (c) 2000-2011 France Télécom
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
......@@ -233,7 +233,7 @@ import_product:
all build:: sanity-all post-sanity-all
SUBDIRS = tools java javax sun com
SUBDIRS = tools java javax sun com jdk
ifeq ($(PLATFORM), macosx)
SUBDIRS += apple
endif
......
......@@ -94,9 +94,9 @@ ifeq ($(PLATFORM), windows)
LDOUTPUT = -Fe
# JDK name required here
RC_FLAGS += /D "JDK_FNAME=$(PGRM).exe" \
/D "JDK_INTERNAL_NAME=$(PGRM)" \
/D "JDK_FTYPE=0x1L"
RC_FLAGS += -D "JDK_FNAME=$(PGRM).exe" \
-D "JDK_INTERNAL_NAME=$(PGRM)" \
-D "JDK_FTYPE=0x1L"
RES = $(OBJDIR)/$(PGRM).res
else
......@@ -161,7 +161,7 @@ $(UNPACK_EXE): $(UNPACK_EXE_FILES_o) updatefiles winres
$(CP) mapfile-vers-unpack200 $(TEMPDIR)/mapfile-vers
$(LINKER) $(LDDFLAGS) $(sort $(UNPACK_EXE_FILES_o)) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
ifdef MT
$(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
$(MT) -manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest -outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
endif
$(CP) $(TEMPDIR)/unpack200$(EXE_SUFFIX) $(UNPACK_EXE)
@$(call binary_file_verification,$@)
......
......@@ -78,7 +78,7 @@ ifeq ($(COMPILER_VERSION), VS2010)
MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL)
endif
EXTRA_LFLAGS += /LIBPATH:$(DXSDK_LIB_PATH)
EXTRA_LFLAGS += -LIBPATH:$(DXSDK_LIB_PATH)
# Full Debug Symbols has been enabled on Windows since JDK1.4.1.
# The Full Debug Symbols (FDS) default for VARIANT == OPT builds is
......@@ -198,7 +198,7 @@ CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
# -MTd Use static debug version (better than -MDd, no runtime issues)
# -D_DEBUG Change use of malloc/free/etc to use special debug ones (-MTd)
#
# NOTE: We also will use /D _STATIC_CPPLIB so we don't need msvcpnn.dll
# NOTE: We also will use -D _STATIC_CPPLIB so we don't need msvcpnn.dll
#
# If MS_RUNTIME_STATIC is requested we may have a problem, it is no longer
# supported by VS2010
......@@ -223,12 +223,12 @@ ifeq ($(MFC_DEBUG), true)
endif
# Always add _STATIC_CPPLIB definition
STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB
STATIC_CPPLIB_OPTION = -D _STATIC_CPPLIB
# Silence the warning about using _STATIC_CPPLIB
ifneq ($(SHOW_ALL_WARNINGS),true)
# Needed with VS2010 to turn off the deprecated warning.
STATIC_CPPLIB_OPTION += /D _DISABLE_DEPRECATE_STATIC_CPPLIB
STATIC_CPPLIB_OPTION += -D _DISABLE_DEPRECATE_STATIC_CPPLIB
endif
MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION)
......@@ -242,7 +242,7 @@ ifeq ($(CC_VERSION),msvc)
# -Od Turns off optimization and speeds compilation
# -YX -Fp/.../foobar.pch Use precompiled headers (try someday?)
# -nologo Don't print out startup message
# /D _STATIC_CPPLIB
# -D _STATIC_CPPLIB
# Use static link for the C++ runtime (so msvcpnn.dll not needed)
#
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
......@@ -258,12 +258,12 @@ ifeq ($(CC_VERSION),msvc)
CFLAGS_COMMON += $(MS_RUNTIME_OPTION) $(CFLAGS_$(COMPILER_VERSION))
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
LDEBUG = /debug
LDEBUG = -debug
endif
ifeq ($(VTUNE_SUPPORT), true)
OTHER_CFLAGS = -Z7 -Ox
LDEBUG += /pdb:NONE
LDEBUG += -pdb:NONE
endif
# VS2010, always need safe exception handlers, not needed on 64bit
......@@ -272,7 +272,7 @@ ifeq ($(CC_VERSION),msvc)
endif
# LFLAGS are the flags given to $(LINK) and used to build the actual DLL file
BASELFLAGS = -nologo /opt:REF /incremental:no
BASELFLAGS = -nologo -opt:REF -incremental:no
LFLAGS = $(BASELFLAGS) $(LDEBUG) $(EXTRA_LFLAGS) $(LFLAGS_$(COMPILER_VERSION))
LDDFLAGS += $(LFLAGS_$(COMPILER_VERSION))
......@@ -404,7 +404,7 @@ else
JDK_UPDATE_VER := 0
endif
RC_FLAGS = /l 0x409 /r
RC_FLAGS = -l 0x409 -r
ifeq ($(VARIANT), OPT)
RC_FLAGS += -d NDEBUG
......
......@@ -292,9 +292,9 @@ endif
ifeq ($(PLATFORM),windows)
# JDK name required here
RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
/D "JDK_INTERNAL_NAME=$(LIBRARY)" \
/D "JDK_FTYPE=0x2L"
RC_FLAGS += -D "JDK_FNAME=$(LIBRARY).dll" \
-D "JDK_INTERNAL_NAME=$(LIBRARY)" \
-D "JDK_FTYPE=0x2L"
endif
# Native library building
......
......@@ -206,9 +206,9 @@ endif
@$(ECHO) Created $@
# JDK name required here
RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
/D "JDK_INTERNAL_NAME=$(LIBRARY)" \
/D "JDK_FTYPE=0x2L"
RC_FLAGS += -D "JDK_FNAME=$(LIBRARY).dll" \
-D "JDK_INTERNAL_NAME=$(LIBRARY)" \
-D "JDK_FTYPE=0x2L"
$(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE)
ifndef LOCAL_RESOURCE_FILE
......
......@@ -157,9 +157,9 @@ $(ACTUAL_PROGRAM):: classes $(INIT)
#
ifeq ($(PLATFORM), windows)
# JDK name required here
RC_FLAGS += /D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
/D "JDK_INTERNAL_NAME=$(PROGRAM)" \
/D "JDK_FTYPE=0x1L"
RC_FLAGS += -D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
-D "JDK_INTERNAL_NAME=$(PROGRAM)" \
-D "JDK_FTYPE=0x1L"
$(OBJDIR)/$(PROGRAM).res: $(VERSIONINFO_RESOURCE)
@$(prep-target)
......@@ -201,11 +201,11 @@ endif
@$(prep-target)
@set -- $?; \
$(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
$(LINK) -out:$@ /STACK:$(STACK_SIZE) \
$(LINK) -out:$@ -STACK:$(STACK_SIZE) \
$(MAP_OPTION) $(LFLAGS) $(LDFLAGS) \
@$(OBJDIR)/$(PROGRAM).lcf $(LDLIBS)
ifdef MT
$(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
$(MT) -manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
endif
@$(call binary_file_verification,$@)
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
......
......@@ -348,15 +348,15 @@ TOOLS = \
sun/tools/serialver \
sun/tools/tree \
sun/tools/util \
sun/security/tools/JarBASE64Encoder.class \
sun/security/tools/JarSigner.class \
sun/security/tools/JarSignerParameters.class \
sun/security/tools/JarSignerResources.class \
sun/security/tools/JarSignerResources_ja.class \
sun/security/tools/JarSignerResources_zh_CN.class \
sun/security/tools/SignatureFile\$$Block.class \
sun/security/tools/SignatureFile.class \
sun/security/tools/TimestampedSigner.class \
sun/security/tools/jarsigner/JarBASE64Encoder.class \
sun/security/tools/jarsigner/Main.class \
sun/security/tools/jarsigner/JarSignerParameters.class \
sun/security/tools/jarsigner/Resources.class \
sun/security/tools/jarsigner/Resources_ja.class \
sun/security/tools/jarsigner/Resources_zh_CN.class \
sun/security/tools/jarsigner/SignatureFile\$$Block.class \
sun/security/tools/jarsigner/SignatureFile.class \
sun/security/tools/jarsigner/TimestampedSigner.class \
sun/rmi/rmic \
sun/applet \
sun/jvmstat \
......@@ -572,15 +572,15 @@ $(NOT_RT_JAR_LIST): FRC
$(ECHO) "sun/tools/serialver/" >> $@
$(ECHO) "sun/tools/tree/" >> $@
$(ECHO) "sun/tools/util/" >> $@
$(ECHO) "sun/security/tools/JarBASE64Encoder.class" >> $@
$(ECHO) "sun/security/tools/JarSigner.class" >> $@
$(ECHO) "sun/security/tools/JarSignerParameters.class" >> $@
$(ECHO) "sun/security/tools/JarSignerResources.class" >> $@
$(ECHO) "sun/security/tools/JarSignerResources_ja.class" >> $@
$(ECHO) "sun/security/tools/JarSignerResources_zh_CN.class" >> $@
$(ECHO) "sun/security/tools/SignatureFile\$$Block.class" >> $@
$(ECHO) "sun/security/tools/SignatureFile.class" >> $@
$(ECHO) "sun/security/tools/TimestampedSigner.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/JarBASE64Encoder.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/Main.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/JarSignerParameters.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/Resources.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/Resources_ja.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/Resources_zh_CN.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/SignatureFile\$$Block.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/SignatureFile.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/TimestampedSigner.class" >> $@
$(ECHO) "sun/security/provider/Sun.class" >> $@
$(ECHO) "sun/security/rsa/SunRsaSign.class" >> $@
$(ECHO) "sun/security/ssl/" >> $@
......@@ -784,11 +784,22 @@ initial-image-jre:: initial-image-jre-setup \
$(RT_JAR) $(RESOURCES_JAR) $(JSSE_JAR) $(JFR_JAR) \
$(BUILDMETAINDEX_JARFILE)
@# Copy in bin directory
ifeq ($(USING_MSYS),true)
# No cpio in MinGW/MSYS
$(CD) $(OUTPUTDIR) && $(TAR) -cf - bin | ($(CD) $(JRE_IMAGE_DIR) && $(TAR) -xpf -)
else
$(CD) $(OUTPUTDIR) && $(FIND) bin -depth | $(CPIO) -pdum $(JRE_IMAGE_DIR)
endif
@# CTE plugin security change require new empty directory lib/applet
$(MKDIR) -p $(JRE_IMAGE_DIR)/lib/applet
@# Copy in lib directory
ifeq ($(USING_MSYS),true)
# No cpio in MinGW/MSYS
$(CD) $(OUTPUTDIR) && $(TAR) -cf - lib | ($(CD) $(JRE_IMAGE_DIR) && $(TAR) -xpf -)
else
$(CD) $(OUTPUTDIR) && $(FIND) lib -depth | $(CPIO) -pdum $(JRE_IMAGE_DIR)
endif
ifeq ($(USING_CYGWIN),true)
$(RM) -rf $(JRE_IMAGE_DIR)/[A-Za-z]:
$(RM) -rf $(OUTPUTDIR)/[A-Za-z]:
......@@ -919,11 +930,17 @@ endif
# only places from which we copy everything), but because the presence
# of this file causes cygwin's find to bomb out, thus breaking the build
# in "install".
initial-image-jdk-setup:
$(RM) -r $(JDK_IMAGE_DIR)
$(MKDIR) -p $(JDK_IMAGE_DIR)/jre
ifeq ($(USING_MSYS),true)
($(CD) $(JRE_IMAGE_DIR) && $(TAR) -cf - . \
| ($(CD) $(JDK_IMAGE_DIR)/jre && $(TAR) -xpf -))
else
($(CD) $(JRE_IMAGE_DIR) && $(FIND) . -depth -print \
| $(CPIO) -pdum $(JDK_IMAGE_DIR)/jre )
endif
ifeq ($(USING_CYGWIN),true)
$(RM) -rf $(JRE_IMAGE_DIR)/[A-Za-z]:
$(RM) -rf $(JDK_IMAGE_DIR)/jre/[A-Za-z]:
......
......@@ -34,6 +34,10 @@ IMPORT_RT_PACKAGES += \
javax/xml/ws \
javax/jws \
javax/annotation \
com/sun/org/glassfish \
com/sun/istack/internal \
com/sun/istack/internal/localization \
com/sun/istack/internal/logging \
com/sun/xml/internal/bind \
com/sun/xml/internal/fastinfoset \
com/sun/xml/internal/messaging \
......
......@@ -169,15 +169,19 @@ CD = cd # intrinsic unix command
ifeq ($(PLATFORM),windows)
ifdef USING_CYGWIN
# Intrinsic unix command, with backslash-escaped character interpretation
ECHO = $(UNIXCOMMAND_PATH)echo -e
ZIPEXE = $(UNIXCOMMAND_PATH)zip
UNZIP = $(UNIXCOMMAND_PATH)unzip
ECHO = $(UNIXCOMMAND_PATH)echo -e
ZIPEXE = $(UNIXCOMMAND_PATH)zip
UNZIP = $(UNIXCOMMAND_PATH)unzip
# Some CYGWIN nawk versions require BINMODE=w for proper '\r' interpretation
NAWK = $(UNIXCOMMAND_PATH)awk -v BINMODE=w
NAWK = $(UNIXCOMMAND_PATH)awk -v BINMODE=w
else
ZIPEXE = $(UTILS_DEVTOOL_PATH)zip
UNZIP = $(UTILS_DEVTOOL_PATH)unzip
NAWK = $(UNIXCOMMAND_PATH)awk
ifdef USING_MSYS
ECHO = $(UTILS_COMMAND_PATH)echo -e
AR = $(UTILS_DEVTOOL_PATH)ar
endif
endif
# Re-define some utilities
LEX =# override GNU Make intrinsic: no lex on windows
......
......@@ -112,6 +112,15 @@ define OptFullPath
$(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1" 2> $(DEV_NULL); else echo "$1"; fi)
endef
else
ifdef USING_MSYS
DOSPATH_CMD:=$(shell cd $(JDK_TOPDIR) 2> $(DEV_NULL) && pwd)/make/tools/msys_build_scripts/dospath.sh
define FullPath
$(subst \,/,$(shell $(DOSPATH_CMD) $1))
endef
define OptFullPath
$(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi)
endef
else
# Temporary until we upgrade to MKS 8.7, MKS pwd returns mixed mode path
define FullPath
$(shell cd $1 2> $(DEV_NULL) && pwd)
......@@ -120,6 +129,7 @@ define OptFullPath
$(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi)
endef
endif
endif
# System drive
ifdef SYSTEMDRIVE
......@@ -146,43 +156,47 @@ else
ifdef USING_CYGWIN
UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin)
else
ifdef ROOTDIR
xROOTDIR :="$(subst \,/,$(ROOTDIR))"
_rootdir :=$(call FullPath,$(xROOTDIR))
ifdef USING_MSYS
UNIXCOMMAND_PATH :=$(call PrefixPath,/bin)
else
xROOTDIR :="$(_system_drive)/mksnt"
_rootdir :=$(call FullPath,$(xROOTDIR))
endif
ifneq ($(_rootdir),)
UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt)
endif
endif
ifdef ROOTDIR
xROOTDIR :="$(subst \,/,$(ROOTDIR))"
_rootdir :=$(call FullPath,$(xROOTDIR))
else
xROOTDIR :="$(_system_drive)/mksnt"
_rootdir :=$(call FullPath,$(xROOTDIR))
endif
ifneq ($(_rootdir),)
UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt)
endif
endif # USING_MSYS
endif # USING_CYGWIN
endif
UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)
# Get version of MKS or CYGWIN
ifndef USING_CYGWIN
_MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@')
MKS_VER :=$(call GetVersion,$(_MKS_VER))
# At this point, we can re-define FullPath to use DOSNAME_CMD
CHECK_MKS87:=$(call CheckVersions,$(MKS_VER),8.7)
TRY_DOSNAME:=false
ifeq ($(CHECK_MKS87),same)
TRY_DOSNAME:=true
endif
# Newer should be ok
ifeq ($(CHECK_MKS87),newer)
TRY_DOSNAME:=true
endif
ifeq ($(TRY_DOSNAME),true)
ifeq ($(shell $(UNIXCOMMAND_PATH)dosname -s $(_system_drive)/ 2> $(DEV_NULL)),$(_system_drive)/)
_DOSNAME=$(UNIXCOMMAND_PATH)dosname
DOSNAME_CMD:=$(_DOSNAME) -s
ifdef USING_MKS
_MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@')
MKS_VER :=$(call GetVersion,$(_MKS_VER))
# At this point, we can re-define FullPath to use DOSNAME_CMD
CHECK_MKS87:=$(call CheckVersions,$(MKS_VER),8.7)
TRY_DOSNAME:=false
ifeq ($(CHECK_MKS87),same)
TRY_DOSNAME:=true
endif
# Newer should be ok
ifeq ($(CHECK_MKS87),newer)
TRY_DOSNAME:=true
endif
ifeq ($(TRY_DOSNAME),true)
ifeq ($(shell $(UNIXCOMMAND_PATH)dosname -s $(_system_drive)/ 2> $(DEV_NULL)),$(_system_drive)/)
_DOSNAME=$(UNIXCOMMAND_PATH)dosname
DOSNAME_CMD:=$(_DOSNAME) -s
define FullPath
$(subst //,/,$(shell echo $1 | $(DOSNAME_CMD) 2> $(DEV_NULL)))
endef
endif # test dosname -s
endif # TRY_DOSNAME
endif # test dosname -s
endif # TRY_DOSNAME
endif # MKS
# We try to get references to what we need via the default component
......@@ -440,10 +454,14 @@ else
ifdef USING_CYGWIN
DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH)
else
xDEVTOOLS_PATH :="$(_system_drive)/utils"
fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH))
DEVTOOLS_PATH :=$(call PrefixPath,$(fxDEVTOOLS_PATH))
endif
ifdef USING_MSYS
DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH)
else
xDEVTOOLS_PATH :="$(_system_drive)/utils"
fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH))
DEVTOOLS_PATH :=$(call PrefixPath,$(fxDEVTOOLS_PATH))
endif # USING_MSYS
endif # USING_CYGWIN
endif
DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH)
......@@ -636,7 +654,7 @@ HOTSPOT_LIB_PATH:=$(call AltCheckValue,HOTSPOT_LIB_PATH)
# Special define for checking the binaries
# All windows dll and exe files should have been built with /NXCOMPAT
# All windows dll and exe files should have been built with -NXCOMPAT
# and be setup for dynamic base addresses.
# In addition, we should not be dependent on certain dll files that
# we do not or cannot redistribute.
......@@ -648,37 +666,37 @@ else
BANNED_DLLS=msvcp100[.]dll|msvcr100d[.]dll|msvcrtd[.]dll
endif
# Check for /safeseh (only used on 32bit)
# Check for -safeseh (only used on 32bit)
define binary_file_safeseh_verification # binary_file
( \
$(ECHO) "Checking for /SAFESEH usage in: $1" && \
if [ "`$(DUMPBIN) /loadconfig $1 | $(EGREP) -i 'Safe Exception Handler Table'`" = "" ] ; then \
$(ECHO) "Checking for -SAFESEH usage in: $1" && \
if [ "`$(DUMPBIN) -loadconfig $1 | $(EGREP) -i 'Safe Exception Handler Table'`" = "" ] ; then \
$(ECHO) "ERROR: Did not find 'Safe Exception Handler Table' in loadconfig: $1" ; \
$(DUMPBIN) /loadconfig $1 ; \
$(DUMPBIN) -loadconfig $1 ; \
exit 6 ; \
fi ; \
)
endef
# Check for /NXCOMPAT usage
# Check for -NXCOMPAT usage
define binary_file_nxcompat_verification # binary_file
( \
$(ECHO) "Checking for /NXCOMPAT usage in: $1" && \
if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'NX compatible'`" = "" ] ; then \
$(ECHO) "Checking for -NXCOMPAT usage in: $1" && \
if [ "`$(DUMPBIN) -headers $1 | $(EGREP) -i 'NX compatible'`" = "" ] ; then \
$(ECHO) "ERROR: Did not find 'NX compatible' in headers: $1" ; \
$(DUMPBIN) /headers $1 ; \
$(DUMPBIN) -headers $1 ; \
exit 7 ; \
fi ; \
)
endef
# Check for /DYNAMICBASE usage
# Check for -DYNAMICBASE usage
define binary_file_dynamicbase_verification # binary_file
( \
$(ECHO) "Checking for /DYNAMICBASE usage in: $1" && \
if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'Dynamic base'`" = "" ] ; then \
$(ECHO) "Checking for -DYNAMICBASE usage in: $1" && \
if [ "`$(DUMPBIN) -headers $1 | $(EGREP) -i 'Dynamic base'`" = "" ] ; then \
$(ECHO) "ERROR: Did not find 'Dynamic base' in headers: $1" ; \
$(DUMPBIN) /headers $1 ; \
$(DUMPBIN) -headers $1 ; \
exit 8 ; \
fi ; \
)
......@@ -688,9 +706,9 @@ endef
define binary_file_dll_verification # binary_file
( \
$(ECHO) "Checking for banned dependencies in: $1" && \
if [ "`$(DUMPBIN) /dependents $1 | $(EGREP) -i '$(BANNED_DLLS)'`" != "" ] ; then \
if [ "`$(DUMPBIN) -dependents $1 | $(EGREP) -i '$(BANNED_DLLS)'`" != "" ] ; then \
$(ECHO) "ERROR: Found use of $(BANNED_DLLS)"; \
$(DUMPBIN) /dependents $1 ; \
$(DUMPBIN) -dependents $1 ; \
exit 9 ; \
fi ; \
)
......
......@@ -70,6 +70,8 @@ PLATFORM_SHARED=done
# LIBARCH32 solaris only: sparc or i386
# LIBARCH64 solaris only: sparcv9 or amd64
# USING_CYGWIN windows only: true or false
# USING_MSYS windows only: true or false
# USING_MKS windows only: true or false
# ISHIELD_TEMP_MIN windows only: minimum disk space in temp area
# Only run uname once in this make session.
......@@ -306,6 +308,8 @@ endif
# Windows with and without CYGWIN will be slightly different
ifeq ($(SYSTEM_UNAME), Windows_NT)
PLATFORM = windows
USING_MKS = true
export USING_MKS
endif
ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME)))
PLATFORM = windows
......@@ -318,6 +322,11 @@ ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME)))
export CYGWIN_HOME
endif
endif
ifneq (,$(findstring MINGW,$(SYSTEM_UNAME)))
PLATFORM = windows
USING_MSYS = true
export USING_MSYS
endif
# Platform settings specific to Windows
ifeq ($(PLATFORM), windows)
......@@ -395,11 +404,12 @@ ifeq ($(PLATFORM), windows)
endif
ARCH_FAMILY = $(ARCH)
# Where is unwanted output to be delivered?
# MKS uses the special file "NUL", cygwin uses the customary unix file.
ifeq ($(USING_CYGWIN),true)
DEV_NULL = /dev/null
else
# MKS uses the special file "NUL"; Cygwin and MinGW/MSYS use the
# customary unix file.
ifeq ($(USING_MKS),true)
DEV_NULL = NUL
else
DEV_NULL = /dev/null
endif
export DEV_NULL
# Classpath separator
......@@ -440,28 +450,11 @@ ifeq ($(PLATFORM), windows)
_MB_OF_MEMORY := \
$(shell free -m | grep Mem: | awk '{print $$2;}' )
else
# Windows 2000 has the mem utility, but two memory areas
# extended memory is what is beyond 1024M
_B_OF_EXT_MEMORY := \
$(shell mem 2> $(DEV_NULL) | \
grep 'total contiguous extended memory' | awk '{print $$1;}')
ifeq ($(_B_OF_EXT_MEMORY),)
_B_OF_MEMORY := \
$(shell mem 2> $(DEV_NULL) | \
grep 'total conventional memory' | awk '{print $$1;}')
else
_B_OF_MEMORY := \
$(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL))
endif
ifeq ($(_B_OF_MEMORY),)
# Windows 2003 has the systeminfo utility use it if mem doesn't work
_MB_OF_MEMORY := \
$(shell systeminfo 2> $(DEV_NULL) | \
grep 'Total Physical Memory:' | \
awk '{print $$4;}' | sed -e 's@,@@')
else
_MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL))
endif
# Windows XP and higher has the systeminfo utility
_MB_OF_MEMORY := \
$(shell systeminfo 2> $(DEV_NULL) | \
grep 'Total Physical Memory:' | \
awk '{print $$4;}' | sed -e 's@,@@')
endif
ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY))
MB_OF_MEMORY := $(_MB_OF_MEMORY)
......
......@@ -182,8 +182,13 @@ ifeq ($(PLATFORM),windows)
ALL_SETTINGS+=$(call addRequiredVersionSetting,CYGWIN_VER)
ALL_SETTINGS+=$(call addRequiredSetting,CYGPATH_CMD)
else
ALL_SETTINGS+=$(call addRequiredVersionSetting,MKS_VER)
ALL_SETTINGS+=$(call addOptionalSetting,DOSNAME_CMD)
ifdef USING_MSYS
ALL_SETTINGS+=$(call addRequiredSetting,USING_MSYS)
ALL_SETTINGS+=$(call addRequiredSetting,DOSPATH_CMD)
else
ALL_SETTINGS+=$(call addRequiredVersionSetting,MKS_VER)
ALL_SETTINGS+=$(call addOptionalSetting,DOSNAME_CMD)
endif
endif
endif
ifeq ($(PLATFORM),linux)
......
......@@ -395,7 +395,7 @@ endif
ifeq ($(PLATFORM), windows)
MKS_CHECK :=$(call CheckVersions,$(MKS_VER),$(REQUIRED_MKS_VER))
sane-mks:
ifndef USING_CYGWIN
ifdef USING_MKS
ifeq ($(MKS_CHECK),missing)
@$(call OfficialErrorMessage,MKS version,$(MKS_VER),$(REQUIRED_MKS_VER))
endif
......@@ -905,14 +905,25 @@ sane-unixcommand_path:
"" >> $(ERROR_FILE) ; \
fi
ifeq ($(PLATFORM), windows)
@for utility in cpio ar file m4 ; do \
ifeq ($(USING_MSYS), true)
@for utility in $(AR) $(FILE) $(M4) ; do \
if [ ! -r "`$(WHICH) $${utility}`" ]; then \
$(ECHO) "WARNING: You do not have the utility $${utility} in the \n" \
" directory $(UNIXCOMMAND_PATH). \n" \
" The utilities cpio, ar, file, and m4 are required. \n" \
" The utilities ar, file and m4 are required. \n" \
"" >> $(WARNING_FILE) ; \
fi; \
done
else
@for utility in $(AR) $(CPIO) $(FILE) $(M4) ; do \
if [ ! -r "`$(WHICH) $${utility}`" ]; then \
$(ECHO) "WARNING: You do not have the utility $${utility} in the \n" \
" directory $(UNIXCOMMAND_PATH). \n" \
" The utilities ar, cpio, file and m4 are required. \n" \
"" >> $(WARNING_FILE) ; \
fi; \
done
endif
endif
######################################################
......@@ -999,7 +1010,8 @@ ifeq ($(PLATFORM), windows)
" This is normally obtained from the WINDOWSSDKDIR." \
"" >> $(ERROR_FILE)
endif
ifeq ($(wildcard $(DUMPBIN)),)
# MinGW/MSYS make 3.81 will not tolerate a path with a quoted substring
ifeq ($(wildcard $(subst ",,$(DUMPBIN))),)
@$(ECHO) "ERROR: Cannot find the DUMPBIN utility from path: $(DUMPBIN)\n" \
" This is normally obtained from the COMPILER_PATH." \
"" >> $(ERROR_FILE)
......
#
# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 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
......@@ -64,13 +64,11 @@ include FILES_java.gmk
include Exportedfiles.gmk
ifeq ($(PLATFORM),windows)
FILES_java += java/io/Win32FileSystem.java \
java/io/WinNTFileSystem.java \
FILES_java += java/io/WinNTFileSystem.java \
java/util/prefs/WindowsPreferences.java \
java/util/prefs/WindowsPreferencesFactory.java
FILES_c += ProcessImpl_md.c \
Win32FileSystem_md.c \
WinNTFileSystem_md.c \
canonicalize_md.c \
dirent_md.c \
......
#
# Copyright (c) 1997, 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. 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.
#
#
# Makefile for building all of java
#
BUILDDIR = ..
PRODUCT = jdk
include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = asm
include $(BUILDDIR)/common/Subdirs.gmk
all build clean clobber::
$(SUBDIRS-loop)
#
# Copyright (c) 1995, 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. 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.
#
BUILDDIR = ../..
PACKAGE = jdk.internal.org.objectweb.asm
PRODUCT = jdk
JAVAC_LINT_OPTIONS=-Xlint:all
include $(BUILDDIR)/common/Defs.gmk
#
# Files to compile
#
AUTO_FILES_JAVA_DIRS = jdk/internal/org/objectweb/asm
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
......@@ -176,17 +176,38 @@ else
else
windows_arch=i586
fi
repo=`hg root | sed -e 's@\\\\@/@g'`
# We need to check if we are running a CYGWIN shell
if [ "$(uname -a | fgrep Cygwin)" != "" -a -f /bin/cygpath ] ; then
if [ "$(echo ${osname} | fgrep Cygwin)" != "" -a -f /bin/cygpath ] ; then
# For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist
# Utility to convert to short pathnames without spaces
cygpath="/usr/bin/cygpath -a -m -s"
cygpathp="/usr/bin/cygpath -p"
# Most unix utilities are in the /usr/bin
unixcommand_path="/usr/bin"
# Make the prompt tell you CYGWIN
export PS1="CYGWIN:${COMPUTERNAME}:${USERNAME}[\!] "
elif [ "$(echo ${osname} | fgrep MINGW)" != "" ] ; then
# Utility to convert to short pathnames without spaces
cygpath="${repo}/make/tools/msys_build_scripts/dospath.sh"
if [ ! -f ${cygpath} ] ; then
echo "ERROR: Cannot find cygpath or equivalent on this machine"
exit 1
fi
# Utility to fix a path to MinGW/MSYS format - the equivalent of 'cygpath -p'
for tfile in "${repo}/make/scripts/fixpath.pl" "${repo}/../make/scripts/fixpath.pl"; do
if [ -f ${tfile} ] ; then
cygpathp="/bin/perl ${tfile} -m"
fi
done;
if [ -z "${cygpathp}" ] ; then
echo "ERROR: Cannot find make/scripts/fixpath.pl on this machine"
exit 1
fi
unixcommand_path="/usr/bin"
else
echo "ERROR: Cannot find CYGWIN on this machine"
echo "ERROR: Cannot find CYGWIN or MinGW/MSYS on this machine"
exit 1
fi
if [ "${ALT_UNIXCOMMAND_PATH}" != "" ] ; then
......@@ -204,17 +225,18 @@ else
else
sys_root=$(${cygpath} "C:/WINNT")
fi
path4sdk="${unixcommand_path};${sys_root}/system32;${sys_root};${sys_root}/System32/Wbem"
if [ ! -d "${sys_root}" ] ; then
echo "WARNING: No system root found at: ${sys_root}"
fi
# Build a : separated path making sure each segment is acceptable to ${osname}
path4sdk="${unixcommand_path}:"`${cygpathp} "${sys_root}/system32;${sys_root};${sys_root}/System32/Wbem"`
# Compiler setup (nasty part)
# NOTE: You can use vcvars32.bat to set PATH, LIB, and INCLUDE.
# NOTE: CYGWIN has a link.exe too, make sure the compilers are first
# Use supplied vsvars.sh
repo=`hg root`
if [ -f "${repo}/make/scripts/vsvars.sh" ] ; then
eval `sh ${repo}/make/scripts/vsvars.sh -v10`
elif [ -f "${repo}/../make/scripts/vsvars.sh" ] ; then
......
......@@ -77,20 +77,18 @@ jprt.make.rule.core.test.targets= \
${jprt.my.test.target.set:TESTNAME=jdk_util}, \
${jprt.my.test.target.set:TESTNAME=jdk_io}, \
${jprt.my.test.target.set:TESTNAME=jdk_net}, \
${jprt.my.test.target.set:TESTNAME=jdk_nio1}, \
${jprt.my.test.target.set:TESTNAME=jdk_nio2}, \
${jprt.my.test.target.set:TESTNAME=jdk_nio3}, \
${jprt.my.test.target.set:TESTNAME=jdk_nio}, \
${jprt.my.test.target.set:TESTNAME=jdk_security1}, \
${jprt.my.test.target.set:TESTNAME=jdk_security2}, \
${jprt.my.test.target.set:TESTNAME=jdk_security3}, \
${jprt.my.test.target.set:TESTNAME=jdk_rmi}, \
${jprt.my.test.target.set:TESTNAME=jdk_management1}, \
${jprt.my.test.target.set:TESTNAME=jdk_management2}, \
${jprt.my.test.target.set:TESTNAME=jdk_management}, \
${jprt.my.test.target.set:TESTNAME=jdk_jmx}, \
${jprt.my.test.target.set:TESTNAME=jdk_text}, \
${jprt.my.test.target.set:TESTNAME=jdk_tools1}, \
${jprt.my.test.target.set:TESTNAME=jdk_tools2}, \
${jprt.my.test.target.set:TESTNAME=jdk_tools}, \
${jprt.my.test.target.set:TESTNAME=jdk_jdi}, \
${jprt.my.test.target.set:TESTNAME=jdk_jfr}, \
${jprt.my.test.target.set:TESTNAME=jdk_misc}
${jprt.my.test.target.set:TESTNAME=jdk_other}
# All vm test targets (testset=all)
jprt.vm.all.test.targets= \
......
......@@ -58,7 +58,7 @@ $(make-appletviewer)
$(call make-launcher, extcheck, com.sun.tools.extcheck.Main, , )
$(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , )
$(call make-launcher, jar, sun.tools.jar.Main, , )
$(call make-launcher, jarsigner, sun.security.tools.JarSigner, , )
$(call make-launcher, jarsigner, sun.security.tools.jarsigner.Main, , )
$(call make-launcher, javac, com.sun.tools.javac.Main, , )
$(call make-launcher, javadoc, com.sun.tools.javadoc.Main, , )
$(call make-launcher, javah, com.sun.tools.javah.Main, , )
......
......@@ -128,8 +128,6 @@ FILES_java = \
sun/net/www/content/audio/x_wav.java \
sun/net/www/protocol/ftp/Handler.java \
sun/net/www/protocol/ftp/FtpURLConnection.java \
sun/net/www/protocol/gopher/GopherClient.java \
sun/net/www/protocol/gopher/Handler.java \
sun/net/www/protocol/mailto/Handler.java \
sun/net/www/protocol/mailto/MailToURLConnection.java \
sun/net/idn/Punycode.java \
......
#
# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 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
......@@ -37,7 +37,7 @@ AUTO_FILES_JAVA_DIRS = sun/security/tools
# Resources
#
LOCALE_SET_DEFINITION = jdk
RESOURCE_BUNDLES_JAVA = sun/security/tools/JarSignerResources.java
RESOURCE_BUNDLES_JAVA = sun/security/tools/jarsigner/Resources.java
#
# Rules
......@@ -45,7 +45,7 @@ RESOURCE_BUNDLES_JAVA = sun/security/tools/JarSignerResources.java
include $(BUILDDIR)/common/Classes.gmk
build:
$(call make-launcher, keytool, sun.security.tools.KeyTool, , )
$(call make-launcher, keytool, sun.security.tools.keytool.Main, , )
ifndef BUILD_HEADLESS_ONLY
$(call make-launcher, policytool, sun.security.tools.policytool.PolicyTool, , )
endif
......
......@@ -37,11 +37,11 @@ ifeq ($(OPENJDK),true)
# Start with CFLAGS (which gets us the required -xarch setting on solaris)
ifeq ($(PLATFORM), windows)
FT_OPTIONS = /nologo /c
FT_OPTIONS = -nologo -c
FREETYPE_DLL = $(FREETYPE_LIB_PATH)/freetype.dll
FT_LD_OPTIONS = $(FREETYPE_LIB_PATH)/freetype.lib
ifdef MT
FT_LD_OPTIONS += /manifest
FT_LD_OPTIONS += -manifest
endif
else
FT_OPTIONS = $(CFLAGS)
......@@ -72,11 +72,11 @@ $(FT_TEST): freetypecheck.c
$(prep-target)
ifeq ($(PLATFORM), windows)
$(CC) $(FT_OPTIONS) $(CC_OBJECT_OUTPUT_FLAG)$(FT_OBJ) $<
$(LINK) $(FT_LD_OPTIONS) /OUT:$(FT_TEST) $(FT_OBJ)
$(LINK) $(FT_LD_OPTIONS) -OUT:$(FT_TEST) $(FT_OBJ)
$(CP) $(FREETYPE_DLL) $(@D)/
ifdef MT
$(CP) $(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL) $(@D)/
$(MT) /manifest $(FT_TEST).manifest /outputresource:$(FT_TEST);#1
$(MT) -manifest $(FT_TEST).manifest -outputresource:$(FT_TEST);#1
endif
else
@$(CC) $(FT_OPTIONS) -o $@ $< $(FT_LD_OPTIONS)
......
#
# Copyright (c) 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. 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.
#
# A shell script which converts its first argument, which must be an existing
# path name, into a DOS (aka 8.3) path name. If the path is a file, only the
# directory part of the whole path will be converted.
# This shell script executes the Visual Basic helper script 'dospath.vbs'
# which must be located in the same directory as this script itself.
# The Visual Basic script will be invoked trough the "Windows Script Host"
# which is available by default on Windows since Windows 98.
pushd `dirname "$0"` > /dev/null
ABS_PATH=`pwd`
popd > /dev/null
if [ -d "$1" ]; then
echo `cd "$1" && cscript.exe -nologo $ABS_PATH/dospath.vbs`;
elif [ -f "$1" ]; then
DIR=`dirname "$1"`;
echo `cd "$DIR" && cscript.exe -nologo $ABS_PATH/dospath.vbs`\\`basename "$1"`;
fi
'
' Copyright (c) 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. 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.
'
'
' Visual Basic Script which returns the DOS (aka 8.3) filename of the current
' directory.
' Only called from 'dospath.sh' during a Windows build under MinGW/MSYS.
'
Set fso=CreateObject("Scripting.FileSystemObject")
Set path = fso.GetFolder(".")
WScript.Echo path.ShortPath
......@@ -232,7 +232,7 @@ $(eval $(call SetupLauncher,jar,\
-DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jar.Main"$(COMMA) }'))
$(eval $(call SetupLauncher,jarsigner,\
-DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.JarSigner"$(COMMA) }'))
-DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.jarsigner.Main"$(COMMA) }'))
$(eval $(call SetupLauncher,javac,\
-DEXPAND_CLASSPATH_WILDCARDS \
......@@ -310,7 +310,7 @@ $(eval $(call SetupLauncher,jstatd,\
-DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.jstatd.Jstatd"$(COMMA) }'))
$(eval $(call SetupLauncher,keytool,\
-DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.KeyTool"$(COMMA) }'))
-DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.security.tools.keytool.Main"$(COMMA) }'))
$(eval $(call SetupLauncher,native2ascii,\
-DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.tools.native2ascii.Main"$(COMMA) }'))
......
......@@ -209,7 +209,6 @@ ifeq ($(OPENJDK_TARGET_OS),windows)
else
LIBJAVA_EXCLUDE_FILES += \
ProcessImpl_md.c \
Win32FileSystem_md.c \
WinNTFileSystem_md.c \
dirent_md.c \
WindowsPreferences.c \
......
......@@ -131,15 +131,15 @@ RT_JAR_EXCLUDES := \
sun/tools/serialver \
sun/tools/tree \
sun/tools/util \
sun/security/tools/JarBASE64Encoder.class \
sun/security/tools/JarSigner.class \
sun/security/tools/JarSignerParameters.class \
sun/security/tools/JarSignerResources.class \
sun/security/tools/JarSignerResources_ja.class \
sun/security/tools/JarSignerResources_zh_CN.class \
sun/security/tools/SignatureFile\$$$$Block.class \
sun/security/tools/SignatureFile.class \
sun/security/tools/TimestampedSigner.class \
sun/security/tools/jarsigner/JarBASE64Encoder.class \
sun/security/tools/jarsigner/Main.class \
sun/security/tools/jarsigner/JarSignerParameters.class \
sun/security/tools/jarsigner/Resources.class \
sun/security/tools/jarsigner/Resources_ja.class \
sun/security/tools/jarsigner/Resources_zh_CN.class \
sun/security/tools/jarsigner/SignatureFile\$$$$Block.class \
sun/security/tools/jarsigner/SignatureFile.class \
sun/security/tools/jarsigner/TimestampedSigner.class \
sun/security/provider/Sun.class \
sun/security/rsa/SunRsaSign.class \
sun/security/ssl \
......
......@@ -379,6 +379,19 @@ public class AquaFileChooserUI extends FileChooserUI {
}
}
updateButtonState(getFileChooser());
} else if (prop.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
JFileChooser fileChooser = getFileChooser();
if (!fileChooser.isDirectorySelectionEnabled()) {
final File[] files = (File[]) e.getNewValue();
if (files != null) {
for (int selectedRow : fFileList.getSelectedRows()) {
File file = (File) fFileList.getValueAt(selectedRow, 0);
if (fileChooser.isTraversable(file)) {
fFileList.removeSelectedIndex(selectedRow);
}
}
}
}
} else if (prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
fFileList.clearSelection();
final File currentDirectory = getFileChooser().getCurrentDirectory();
......
......@@ -100,7 +100,7 @@ class MacOSXPreferences extends AbstractPreferences {
else
this.isUser = isUserNode();
path = isRoot ? absolutePath() : absolutePath() + "/";
file = cfFileForNode(isUser);
file = cfFileForNode(this.isUser);
if (isNew)
newNode = isNew;
else
......
......@@ -33,9 +33,7 @@ import java.awt.DisplayMode;
import sun.java2d.opengl.CGLGraphicsConfig;
import sun.awt.FullScreenCapable;
public class CGraphicsDevice extends GraphicsDevice {
public final class CGraphicsDevice extends GraphicsDevice {
// CoreGraphics display ID
private final int displayID;
......@@ -108,11 +106,6 @@ public class CGraphicsDevice extends GraphicsDevice {
return nativeGetYResolution(displayID);
}
public int getScreenResolution() {
// TODO: report non-72 value when HiDPI is turned on
return 72;
}
private static native double nativeGetXResolution(int displayID);
private static native double nativeGetYResolution(int displayID);
......@@ -194,6 +187,9 @@ public class CGraphicsDevice extends GraphicsDevice {
@Override
public void setDisplayMode(DisplayMode dm) {
if (dm == null) {
throw new IllegalArgumentException("Invalid display mode");
}
nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(), dm.getBitDepth(), dm.getRefreshRate());
if (isFullScreenSupported() && getFullScreenWindow() != null) {
getFullScreenWindow().setSize(dm.getWidth(), dm.getHeight());
......
......@@ -65,7 +65,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
private static native void nativeDispose(long nsWindowPtr);
private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
private static native int nativeGetNSWindowDisplayID_AppKitThread(long nsWindowPtr);
private static native int nativeGetNSWindowDisplayID(long nsWindowPtr);
// Loger to report issues happened during execution but that do not affect functionality
private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
......@@ -444,7 +444,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
public GraphicsDevice getGraphicsDevice() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
CGraphicsEnvironment cge = (CGraphicsEnvironment)ge;
int displayID = nativeGetNSWindowDisplayID_AppKitThread(getNSWindowPtr());
int displayID = nativeGetNSWindowDisplayID(getNSWindowPtr());
GraphicsDevice gd = cge.getScreenDevice(displayID);
if (gd == null) {
// this could possibly happen during device removal
......
......@@ -26,6 +26,7 @@
package sun.lwawt.macosx;
import sun.awt.SunToolkit;
import sun.lwawt.macosx.event.NSEvent;
import javax.swing.*;
import java.awt.*;
......@@ -42,6 +43,16 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
private JDialog messageDialog;
private DialogEventHandler handler;
// In order to construct MouseEvent object, we need to specify a
// Component target. Because TrayIcon isn't Component's subclass,
// we use this dummy frame instead
private final Frame dummyFrame;
// A bitmask that indicates what mouse buttons produce MOUSE_CLICKED events
// on MOUSE_RELEASE. Click events are only generated if there were no drag
// events between MOUSE_PRESSED and MOUSE_RELEASED for particular button
private static int mouseClickButtons = 0;
CTrayIcon(TrayIcon target) {
super(0, true);
......@@ -49,6 +60,7 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
this.handler = null;
this.target = target;
this.popup = target.getPopupMenu();
this.dummyFrame = new Frame();
setPtr(createModel());
//if no one else is creating the peer.
......@@ -119,6 +131,8 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
disposeMessageDialog();
}
dummyFrame.dispose();
LWCToolkit.targetDisposedPeer(target, this);
target = null;
......@@ -161,17 +175,78 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
private native void setNativeImage(final long model, final long nsimage, final boolean autosize);
//invocation from the AWTTrayIcon.m
public void performAction() {
private void postEvent(final AWTEvent event) {
SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
public void run() {
final String cmd = target.getActionCommand();
final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd);
SunToolkit.postEvent(SunToolkit.targetToAppContext(target), event);
}
});
}
//invocation from the AWTTrayIcon.m
private void handleMouseEvent(NSEvent nsEvent) {
int buttonNumber = nsEvent.getButtonNumber();
final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
|| buttonNumber > tk.getNumberOfButtons() - 1) {
return;
}
int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType());
int jbuttonNumber = MouseEvent.NOBUTTON;
int jclickCount = 0;
if (jeventType != MouseEvent.MOUSE_MOVED) {
jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
jclickCount = nsEvent.getClickCount();
}
int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
nsEvent.getModifierFlags());
boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers);
int eventButtonMask = (jbuttonNumber > 0)?
MouseEvent.getMaskForButton(jbuttonNumber) : 0;
long when = System.currentTimeMillis();
if (jeventType == MouseEvent.MOUSE_PRESSED) {
mouseClickButtons |= eventButtonMask;
} else if (jeventType == MouseEvent.MOUSE_DRAGGED) {
mouseClickButtons = 0;
}
// The MouseEvent's coordinates are relative to screen
int absX = nsEvent.getAbsX();
int absY = nsEvent.getAbsY();
MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when,
jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger,
jbuttonNumber);
mouseEvent.setSource(target);
postEvent(mouseEvent);
// fire ACTION event
if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) {
final String cmd = target.getActionCommand();
final ActionEvent event = new ActionEvent(target,
ActionEvent.ACTION_PERFORMED, cmd);
postEvent(event);
}
// synthesize CLICKED event
if (jeventType == MouseEvent.MOUSE_RELEASED) {
if ((mouseClickButtons & eventButtonMask) != 0) {
MouseEvent clickEvent = new MouseEvent(dummyFrame,
MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY,
absX, absY, jclickCount, isPopupTrigger, jbuttonNumber);
clickEvent.setSource(target);
postEvent(clickEvent);
}
mouseClickButtons &= ~eventButtonMask;
}
}
private native Point2D nativeGetIconLocation(long trayIconModel);
public void displayMessageOnEDT(String caption, String text,
......@@ -256,6 +331,9 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.setModal(false);
dialog.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
dialog.setAlwaysOnTop(true);
dialog.setAutoRequestFocus(false);
dialog.setResizable(false);
dialog.setContentPane(op);
......
......@@ -53,7 +53,7 @@ class NamedCursor extends Cursor {
/**
* Mac OS X Cocoa-based AWT Toolkit.
*/
public class LWCToolkit extends LWToolkit {
public final class LWCToolkit extends LWToolkit {
// While it is possible to enumerate all mouse devices
// and query them for the number of buttons, the code
// that does it is rather complex. Instead, we opt for
......@@ -278,7 +278,6 @@ public class LWCToolkit extends LWToolkit {
return new CMouseInfoPeer();
}
@Override
protected int getScreenHeight() {
return GraphicsEnvironment.getLocalGraphicsEnvironment()
......@@ -333,8 +332,9 @@ public class LWCToolkit extends LWToolkit {
@Override
public int getScreenResolution() throws HeadlessException {
return ((CGraphicsDevice) GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice()).getScreenResolution();
return (int) ((CGraphicsDevice) GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice())
.getXResolution();
}
@Override
......
......@@ -324,6 +324,13 @@ AWT_ASSERT_APPKIT_THREAD;
}
}
+ (NSNumber *) getNSWindowDisplayID_AppKitThread:(NSWindow *)window {
AWT_ASSERT_APPKIT_THREAD;
NSScreen *screen = [window screen];
NSDictionary *deviceDescription = [screen deviceDescription];
return [deviceDescription objectForKey:@"NSScreenNumber"];
}
- (void) dealloc {
AWT_ASSERT_APPKIT_THREAD;
......@@ -1113,19 +1120,22 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMou
* Signature: (J)I
*/
JNIEXPORT jint JNICALL
Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID_1AppKitThread
Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID
(JNIEnv *env, jclass clazz, jlong windowPtr)
{
jint ret; // CGDirectDisplayID
__block jint ret; // CGDirectDisplayID
JNF_COCOA_ENTER(env);
AWT_ASSERT_APPKIT_THREAD;
NSWindow *window = OBJC(windowPtr);
NSScreen *screen = [window screen];
NSDictionary *deviceDescription = [screen deviceDescription];
NSNumber *displayID = [deviceDescription objectForKey:@"NSScreenNumber"];
ret = (jint)[displayID intValue];
if ([NSThread isMainThread]) {
ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
} else {
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
}];
}
JNF_COCOA_EXIT(env);
......
......@@ -53,6 +53,7 @@ extern "C" {
- (jobject) peer;
- (void) setImage:(NSImage *) imagePtr sizing:(BOOL)autosize;
- (NSPoint) getLocationOnScreen;
- (void) deliverJavaMouseEvent:(NSEvent*) event;
@end //AWTTrayIcon
......@@ -68,6 +69,7 @@ extern "C" {
-(id)initWithTrayIcon:(AWTTrayIcon *)theTrayIcon;
-(void)setHighlighted:(BOOL)aFlag;
-(void)setImage:(NSImage*)anImage;
-(void)setTrayIcon:(AWTTrayIcon*)theTrayIcon;
@end //AWTTrayIconView
......
......@@ -29,6 +29,7 @@
#import "CTrayIcon.h"
#import "ThreadUtilities.h"
#include "GeomUtilities.h"
#import "LWCToolkit.h"
#define kImageInset 4.0
......@@ -76,8 +77,9 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) {
// Its a bad idea to force the item to release our view by setting
// the item's view to nil: it can lead to a crash in some scenarios.
// The item will release the view later on, so just set the view's image
// to nil since we are done with it.
// and tray icon to nil since we are done with it.
[view setImage: nil];
[view setTrayIcon: nil];
[view release];
[theItem release];
......@@ -115,6 +117,45 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) {
return [[view window] convertBaseToScreen: NSZeroPoint];
}
-(void) deliverJavaMouseEvent: (NSEvent *) event {
[AWTToolkit eventCountPlusPlus];
JNIEnv *env = [ThreadUtilities getJNIEnv];
NSPoint eventLocation = [event locationInWindow];
NSPoint localPoint = [view convertPoint: eventLocation fromView: nil];
localPoint.y = [view bounds].size.height - localPoint.y;
NSPoint absP = [NSEvent mouseLocation];
NSEventType type = [event type];
NSRect screenRect = [[NSScreen mainScreen] frame];
absP.y = screenRect.size.height - absP.y;
jint clickCount;
clickCount = [event clickCount];
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent");
static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V");
jobject jEvent = JNFNewObject(env, jctor_NSEvent,
[event type],
[event modifierFlags],
clickCount,
[event buttonNumber],
(jint)localPoint.x, (jint)localPoint.y,
(jint)absP.x, (jint)absP.y,
[event deltaY],
[event deltaX]);
if (jEvent == nil) {
// Unable to create event by some reason.
return;
}
static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon");
static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V");
JNFCallVoidMethod(env, peer, jm_handleMouseEvent, jEvent);
}
@end //AWTTrayIcon
//================================================
......@@ -123,7 +164,7 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) {
-(id)initWithTrayIcon:(AWTTrayIcon *)theTrayIcon {
self = [super initWithFrame:NSMakeRect(0, 0, 1, 1)];
trayIcon = theTrayIcon;
[self setTrayIcon: theTrayIcon];
isHighlighted = NO;
image = nil;
......@@ -153,6 +194,10 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) {
}
}
-(void)setTrayIcon:(AWTTrayIcon*)theTrayIcon {
trayIcon = theTrayIcon;
}
- (void)menuWillOpen:(NSMenu *)menu
{
[self setHighlighted:YES];
......@@ -191,30 +236,57 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) {
];
}
- (void) mouseDown:(NSEvent *)e {
//find CTrayIcon.getPopupMenuModel method and call it to get popup menu ptr.
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_CLASS_CACHE(jc_CTrayIcon, "sun/lwawt/macosx/CTrayIcon");
static JNF_MEMBER_CACHE(jm_getPopupMenuModel, jc_CTrayIcon, "getPopupMenuModel", "()J");
static JNF_MEMBER_CACHE(jm_performAction, jc_CTrayIcon, "performAction", "()V");
jlong res = JNFCallLongMethod(env, trayIcon.peer, jm_getPopupMenuModel);
if (res != 0) {
CPopupMenu *cmenu = jlong_to_ptr(res);
NSMenu* menu = [cmenu menu];
[menu setDelegate:self];
[trayIcon.theItem popUpStatusItemMenu:menu];
[self setNeedsDisplay:YES];
} else {
JNFCallVoidMethod(env, trayIcon.peer, jm_performAction);
- (void)mouseDown:(NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
// don't show the menu on ctrl+click: it triggers ACTION event, like right click
if (([event modifierFlags] & NSControlKeyMask) == 0) {
//find CTrayIcon.getPopupMenuModel method and call it to get popup menu ptr.
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_CLASS_CACHE(jc_CTrayIcon, "sun/lwawt/macosx/CTrayIcon");
static JNF_MEMBER_CACHE(jm_getPopupMenuModel, jc_CTrayIcon, "getPopupMenuModel", "()J");
jlong res = JNFCallLongMethod(env, trayIcon.peer, jm_getPopupMenuModel);
if (res != 0) {
CPopupMenu *cmenu = jlong_to_ptr(res);
NSMenu* menu = [cmenu menu];
[menu setDelegate:self];
[trayIcon.theItem popUpStatusItemMenu:menu];
[self setNeedsDisplay:YES];
}
}
}
- (void) rightMouseDown:(NSEvent *)e {
// Call CTrayIcon.performAction() method on right mouse press
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_CLASS_CACHE(jc_CTrayIcon, "sun/lwawt/macosx/CTrayIcon");
static JNF_MEMBER_CACHE(jm_performAction, jc_CTrayIcon, "performAction", "()V");
JNFCallVoidMethod(env, trayIcon.peer, jm_performAction);
- (void) mouseUp:(NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
}
- (void) mouseDragged:(NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
}
- (void) rightMouseDown:(NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
}
- (void) rightMouseUp:(NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
}
- (void) rightMouseDragged:(NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
}
- (void) otherMouseDown:(NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
}
- (void) otherMouseUp:(NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
}
- (void) otherMouseDragged:(NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
}
......
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
......@@ -37,6 +37,9 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
......@@ -46,6 +49,8 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import sun.misc.SharedSecrets;
/**
* The main class to parse JavaBeans XML archive.
*
......@@ -56,11 +61,10 @@ import org.xml.sax.helpers.DefaultHandler;
* @see ElementHandler
*/
public final class DocumentHandler extends DefaultHandler {
private final Map<String, Class<? extends ElementHandler>> handlers = new HashMap<String, Class<? extends ElementHandler>>();
private final Map<String, Object> environment = new HashMap<String, Object>();
private final List<Object> objects = new ArrayList<Object>();
private final AccessControlContext acc = AccessController.getContext();
private final Map<String, Class<? extends ElementHandler>> handlers = new HashMap<>();
private final Map<String, Object> environment = new HashMap<>();
private final List<Object> objects = new ArrayList<>();
private Reference<ClassLoader> loader;
private ExceptionListener listener;
......@@ -351,23 +355,32 @@ public final class DocumentHandler extends DefaultHandler {
*
* @param input the input source to parse
*/
public void parse(InputSource input) {
try {
SAXParserFactory.newInstance().newSAXParser().parse(input, this);
public void parse(final InputSource input) {
if ((this.acc == null) && (null != System.getSecurityManager())) {
throw new SecurityException("AccessControlContext is not set");
}
catch (ParserConfigurationException exception) {
handleException(exception);
}
catch (SAXException wrapper) {
Exception exception = wrapper.getException();
if (exception == null) {
exception = wrapper;
AccessControlContext stack = AccessController.getContext();
SharedSecrets.getJavaSecurityAccess().doIntersectionPrivilege(new PrivilegedAction<Void>() {
public Void run() {
try {
SAXParserFactory.newInstance().newSAXParser().parse(input, DocumentHandler.this);
}
catch (ParserConfigurationException exception) {
handleException(exception);
}
catch (SAXException wrapper) {
Exception exception = wrapper.getException();
if (exception == null) {
exception = wrapper;
}
handleException(exception);
}
catch (IOException exception) {
handleException(exception);
}
return null;
}
handleException(exception);
}
catch (IOException exception) {
handleException(exception);
}
}, stack, this.acc);
}
/**
......
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
......@@ -35,6 +35,8 @@ import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import sun.reflect.misc.MethodUtil;
/**
* This class is intended to handle &lt;property&gt; element.
* This element simplifies access to the properties.
......@@ -168,11 +170,11 @@ final class PropertyElementHandler extends AccessorElementHandler {
private static Object getPropertyValue(Object bean, String name, Integer index) throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException {
Class<?> type = bean.getClass();
if (index == null) {
return findGetter(type, name).invoke(bean);
return MethodUtil.invoke(findGetter(type, name), bean, new Object[] {});
} else if (type.isArray() && (name == null)) {
return Array.get(bean, index);
} else {
return findGetter(type, name, int.class).invoke(bean, index);
return MethodUtil.invoke(findGetter(type, name, int.class), bean, new Object[] {index});
}
}
......@@ -197,11 +199,11 @@ final class PropertyElementHandler extends AccessorElementHandler {
: null;
if (index == null) {
findSetter(type, name, param).invoke(bean, value);
MethodUtil.invoke(findSetter(type, name, param), bean, new Object[] {value});
} else if (type.isArray() && (name == null)) {
Array.set(bean, index, value);
} else {
findSetter(type, name, int.class, param).invoke(bean, index, value);
MethodUtil.invoke(findSetter(type, name, int.class, param), bean, new Object[] {index, value});
}
}
......
......@@ -68,9 +68,9 @@ public class ServerNotifForwarder {
this.notifBuffer = notifBuffer;
this.connectionId = connectionId;
connectionTimeout = EnvHelp.getServerConnectionTimeout(env);
checkNotificationEmission = EnvHelp.computeBooleanFromString(
env,
"jmx.remote.x.check.notification.emission",false);
String stringBoolean = (String) env.get("jmx.remote.x.check.notification.emission");
checkNotificationEmission = EnvHelp.computeBooleanFromString( stringBoolean );
notificationAccessController =
EnvHelp.getNotificationAccessController(env);
}
......
......@@ -665,97 +665,57 @@ public class EnvHelp {
* Computes a boolean value from a string value retrieved from a
* property in the given map.
*
* @param env the environment map.
* @param prop the name of the property in the environment map whose
* returned string value must be converted into a boolean value.
* @param systemProperty if true, consult a system property of the
* same name if there is no entry in the environment map.
* @param stringBoolean the string value that must be converted
* into a boolean value.
*
* @return
* <ul>
* <li>{@code false} if {@code env.get(prop)} is {@code null}</li>
* <li>{@code false} if {@code stringBoolean} is {@code null}</li>
* <li>{@code false} if
* {@code ((String)env.get(prop)).equalsIgnoreCase("false")}
* {@code stringBoolean.equalsIgnoreCase("false")}
* is {@code true}</li>
* <li>{@code true} if
* {@code ((String)env.get(prop)).equalsIgnoreCase("true")}
* {@code stringBoolean.equalsIgnoreCase("true")}
* is {@code true}</li>
* </ul>
*
* @throws IllegalArgumentException if {@code env} is {@code null} or
* {@code env.get(prop)} is not {@code null} and
* @throws IllegalArgumentException if
* {@code ((String)env.get(prop)).equalsIgnoreCase("false")} and
* {@code ((String)env.get(prop)).equalsIgnoreCase("true")} are
* {@code false}.
* @throws ClassCastException if {@code env.get(prop)} cannot be cast
* to {@code String}.
*/
public static boolean computeBooleanFromString(
Map<String, ?> env, String prop, boolean systemProperty) {
if (env == null)
throw new IllegalArgumentException("env map cannot be null");
public static boolean computeBooleanFromString(String stringBoolean) {
// returns a default value of 'false' if no property is found...
return computeBooleanFromString(env,prop,systemProperty,false);
return computeBooleanFromString(stringBoolean,false);
}
/**
* Computes a boolean value from a string value retrieved from a
* property in the given map.
*
* @param env the environment map.
* @param prop the name of the property in the environment map whose
* returned string value must be converted into a boolean value.
* @param systemProperty if true, consult a system property of the
* same name if there is no entry in the environment map.
* @param stringBoolean the string value that must be converted
* into a boolean value.
* @param defaultValue a default value to return in case no property
* was defined.
*
* @return
* <ul>
* <li>{@code defaultValue} if {@code env.get(prop)} is {@code null}
* and {@code systemProperty} is {@code false}</li>
* <li>{@code defaultValue} if {@code env.get(prop)} is {@code null}
* and {@code systemProperty} is {@code true} and
* {@code System.getProperty(prop)} is {@code null}</li>
* <li>{@code false} if {@code env.get(prop)} is {@code null}
* and {@code systemProperty} is {@code true} and
* {@code System.getProperty(prop).equalsIgnoreCase("false")}
* is {@code true}</li>
* <li>{@code true} if {@code env.get(prop)} is {@code null}
* and {@code systemProperty} is {@code true} and
* {@code System.getProperty(prop).equalsIgnoreCase("true")}
* is {@code true}</li>
* <li>{@code defaultValue} if {@code stringBoolean}
* is {@code null}</li>
* <li>{@code false} if
* {@code ((String)env.get(prop)).equalsIgnoreCase("false")}
* {@code stringBoolean.equalsIgnoreCase("false")}
* is {@code true}</li>
* <li>{@code true} if
* {@code ((String)env.get(prop)).equalsIgnoreCase("true")}
* {@code stringBoolean.equalsIgnoreCase("true")}
* is {@code true}</li>
* </ul>
*
* @throws IllegalArgumentException if {@code env} is {@code null} or
* {@code env.get(prop)} is not {@code null} and
* @throws IllegalArgumentException if
* {@code ((String)env.get(prop)).equalsIgnoreCase("false")} and
* {@code ((String)env.get(prop)).equalsIgnoreCase("true")} are
* {@code false}.
* @throws ClassCastException if {@code env.get(prop)} cannot be cast
* to {@code String}.
*/
public static boolean computeBooleanFromString(
Map<String, ?> env, String prop,
boolean systemProperty, boolean defaultValue) {
if (env == null)
throw new IllegalArgumentException("env map cannot be null");
String stringBoolean = (String) env.get(prop);
if (stringBoolean == null && systemProperty) {
stringBoolean =
AccessController.doPrivileged(new GetPropertyAction(prop));
}
public static boolean computeBooleanFromString( String stringBoolean, boolean defaultValue) {
if (stringBoolean == null)
return defaultValue;
else if (stringBoolean.equalsIgnoreCase("true"))
......@@ -763,8 +723,8 @@ public class EnvHelp {
else if (stringBoolean.equalsIgnoreCase("false"))
return false;
else
throw new IllegalArgumentException(prop +
" must be \"true\" or \"false\" instead of \"" +
throw new IllegalArgumentException(
"Property value must be \"true\" or \"false\" instead of \"" +
stringBoolean + "\"");
}
......
......@@ -157,7 +157,8 @@ public final class Connection implements Runnable {
volatile IOException closureReason = null;
volatile boolean useable = true; // is Connection still useable
private int readTimeout;
int readTimeout;
int connectTimeout;
// true means v3; false means v2
// Called in LdapClient.authenticate() (which is synchronized)
......@@ -187,6 +188,7 @@ public final class Connection implements Runnable {
this.port = port;
this.parent = parent;
this.readTimeout = readTimeout;
this.connectTimeout = connectTimeout;
if (trace != null) {
traceFile = trace;
......
......@@ -150,149 +150,155 @@ public final class LdapClient implements PooledConnection {
String authMechanism, Control[] ctls, Hashtable<?,?> env)
throws NamingException {
authenticateCalled = true;
int readTimeout = conn.readTimeout;
conn.readTimeout = conn.connectTimeout;
LdapResult res = null;
try {
ensureOpen();
} catch (IOException e) {
NamingException ne = new CommunicationException();
ne.setRootCause(e);
throw ne;
}
authenticateCalled = true;
switch (version) {
case LDAP_VERSION3_VERSION2:
case LDAP_VERSION3:
isLdapv3 = true;
break;
case LDAP_VERSION2:
isLdapv3 = false;
break;
default:
throw new CommunicationException("Protocol version " + version +
" not supported");
}
LdapResult res = null;
try {
ensureOpen();
} catch (IOException e) {
NamingException ne = new CommunicationException();
ne.setRootCause(e);
throw ne;
}
if (authMechanism.equalsIgnoreCase("none") ||
authMechanism.equalsIgnoreCase("anonymous")) {
switch (version) {
case LDAP_VERSION3_VERSION2:
case LDAP_VERSION3:
isLdapv3 = true;
break;
case LDAP_VERSION2:
isLdapv3 = false;
break;
default:
throw new CommunicationException("Protocol version " + version +
" not supported");
}
// Perform LDAP bind if we are reauthenticating, using LDAPv2,
// supporting failover to LDAPv2, or controls have been supplied.
if (!initial ||
(version == LDAP_VERSION2) ||
(version == LDAP_VERSION3_VERSION2) ||
((ctls != null) && (ctls.length > 0))) {
if (authMechanism.equalsIgnoreCase("none") ||
authMechanism.equalsIgnoreCase("anonymous")) {
// Perform LDAP bind if we are reauthenticating, using LDAPv2,
// supporting failover to LDAPv2, or controls have been supplied.
if (!initial ||
(version == LDAP_VERSION2) ||
(version == LDAP_VERSION3_VERSION2) ||
((ctls != null) && (ctls.length > 0))) {
try {
// anonymous bind; update name/pw for LDAPv2 retry
res = ldapBind(name=null, (byte[])(pw=null), ctls, null,
false);
if (res.status == LdapClient.LDAP_SUCCESS) {
conn.setBound();
}
} catch (IOException e) {
NamingException ne =
new CommunicationException("anonymous bind failed: " +
conn.host + ":" + conn.port);
ne.setRootCause(e);
throw ne;
}
} else {
// Skip LDAP bind for LDAPv3 anonymous bind
res = new LdapResult();
res.status = LdapClient.LDAP_SUCCESS;
}
} else if (authMechanism.equalsIgnoreCase("simple")) {
// simple authentication
byte[] encodedPw = null;
try {
// anonymous bind; update name/pw for LDAPv2 retry
res = ldapBind(name=null, (byte[])(pw=null), ctls, null,
false);
encodedPw = encodePassword(pw, isLdapv3);
res = ldapBind(name, encodedPw, ctls, null, false);
if (res.status == LdapClient.LDAP_SUCCESS) {
conn.setBound();
}
} catch (IOException e) {
NamingException ne =
new CommunicationException("anonymous bind failed: " +
conn.host + ":" + conn.port);
new CommunicationException("simple bind failed: " +
conn.host + ":" + conn.port);
ne.setRootCause(e);
throw ne;
}
} else {
// Skip LDAP bind for LDAPv3 anonymous bind
res = new LdapResult();
res.status = LdapClient.LDAP_SUCCESS;
}
} else if (authMechanism.equalsIgnoreCase("simple")) {
// simple authentication
byte[] encodedPw = null;
try {
encodedPw = encodePassword(pw, isLdapv3);
res = ldapBind(name, encodedPw, ctls, null, false);
if (res.status == LdapClient.LDAP_SUCCESS) {
conn.setBound();
}
} catch (IOException e) {
NamingException ne =
new CommunicationException("simple bind failed: " +
conn.host + ":" + conn.port);
ne.setRootCause(e);
throw ne;
} finally {
// If pw was copied to a new array, clear that array as
// a security precaution.
if (encodedPw != pw && encodedPw != null) {
for (int i = 0; i < encodedPw.length; i++) {
encodedPw[i] = 0;
} finally {
// If pw was copied to a new array, clear that array as
// a security precaution.
if (encodedPw != pw && encodedPw != null) {
for (int i = 0; i < encodedPw.length; i++) {
encodedPw[i] = 0;
}
}
}
}
} else if (isLdapv3) {
// SASL authentication
try {
res = LdapSasl.saslBind(this, conn, conn.host, name, pw,
authMechanism, env, ctls);
if (res.status == LdapClient.LDAP_SUCCESS) {
conn.setBound();
} else if (isLdapv3) {
// SASL authentication
try {
res = LdapSasl.saslBind(this, conn, conn.host, name, pw,
authMechanism, env, ctls);
if (res.status == LdapClient.LDAP_SUCCESS) {
conn.setBound();
}
} catch (IOException e) {
NamingException ne =
new CommunicationException("SASL bind failed: " +
conn.host + ":" + conn.port);
ne.setRootCause(e);
throw ne;
}
} catch (IOException e) {
NamingException ne =
new CommunicationException("SASL bind failed: " +
conn.host + ":" + conn.port);
ne.setRootCause(e);
throw ne;
} else {
throw new AuthenticationNotSupportedException(authMechanism);
}
} else {
throw new AuthenticationNotSupportedException(authMechanism);
}
//
// re-try login using v2 if failing over
//
if (initial &&
(res.status == LdapClient.LDAP_PROTOCOL_ERROR) &&
(version == LdapClient.LDAP_VERSION3_VERSION2) &&
(authMechanism.equalsIgnoreCase("none") ||
authMechanism.equalsIgnoreCase("anonymous") ||
authMechanism.equalsIgnoreCase("simple"))) {
byte[] encodedPw = null;
try {
isLdapv3 = false;
encodedPw = encodePassword(pw, false);
res = ldapBind(name, encodedPw, ctls, null, false);
if (res.status == LdapClient.LDAP_SUCCESS) {
conn.setBound();
}
} catch (IOException e) {
NamingException ne =
new CommunicationException(authMechanism + ":" +
conn.host + ":" + conn.port);
ne.setRootCause(e);
throw ne;
} finally {
// If pw was copied to a new array, clear that array as
// a security precaution.
if (encodedPw != pw && encodedPw != null) {
for (int i = 0; i < encodedPw.length; i++) {
encodedPw[i] = 0;
//
// re-try login using v2 if failing over
//
if (initial &&
(res.status == LdapClient.LDAP_PROTOCOL_ERROR) &&
(version == LdapClient.LDAP_VERSION3_VERSION2) &&
(authMechanism.equalsIgnoreCase("none") ||
authMechanism.equalsIgnoreCase("anonymous") ||
authMechanism.equalsIgnoreCase("simple"))) {
byte[] encodedPw = null;
try {
isLdapv3 = false;
encodedPw = encodePassword(pw, false);
res = ldapBind(name, encodedPw, ctls, null, false);
if (res.status == LdapClient.LDAP_SUCCESS) {
conn.setBound();
}
} catch (IOException e) {
NamingException ne =
new CommunicationException(authMechanism + ":" +
conn.host + ":" + conn.port);
ne.setRootCause(e);
throw ne;
} finally {
// If pw was copied to a new array, clear that array as
// a security precaution.
if (encodedPw != pw && encodedPw != null) {
for (int i = 0; i < encodedPw.length; i++) {
encodedPw[i] = 0;
}
}
}
}
}
// principal name not found
// (map NameNotFoundException to AuthenticationException)
// %%% This is a workaround for Netscape servers returning
// %%% no such object when the principal name is not found
// %%% Note that when this workaround is applied, it does not allow
// %%% response controls to be recorded by the calling context
if (res.status == LdapClient.LDAP_NO_SUCH_OBJECT) {
throw new AuthenticationException(
getErrorMessage(res.status, res.errorMessage));
// principal name not found
// (map NameNotFoundException to AuthenticationException)
// %%% This is a workaround for Netscape servers returning
// %%% no such object when the principal name is not found
// %%% Note that when this workaround is applied, it does not allow
// %%% response controls to be recorded by the calling context
if (res.status == LdapClient.LDAP_NO_SUCH_OBJECT) {
throw new AuthenticationException(
getErrorMessage(res.status, res.errorMessage));
}
conn.setV3(isLdapv3);
return res;
} finally {
conn.readTimeout = readTimeout;
}
conn.setV3(isLdapv3);
return res;
}
/**
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -1746,12 +1746,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
// convert to a Double and compare to zero
try {
Double d = new Double(value.toString());
if (d.compareTo(new Double((double)0)) == 0) {
return false;
} else {
return true;
}
return Double.compare(Double.parseDouble(value.toString()), 0) != 0;
} catch (NumberFormatException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.boolfail").toString(),
new Object[] {value.toString().trim(), columnIndex}));
......@@ -2039,6 +2034,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
* the cursor is not on a valid row, or this method fails
* @deprecated
*/
@Deprecated
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
Object value;
BigDecimal bDecimal, retVal;
......@@ -2374,6 +2370,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
* @throws SQLException if an error occurs
* @deprecated
*/
@Deprecated
public java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException {
// always free an old stream
unicodeStream = null;
......@@ -2643,6 +2640,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
* @deprecated Use the <code>getBigDecimal(String columnName)</code>
* method instead
*/
@Deprecated
public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
return getBigDecimal(getColIdxByName(columnName), scale);
}
......@@ -2774,6 +2772,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
* this rowset's rows or its insert row
* @deprecated use the method <code>getCharacterStream</code> instead
*/
@Deprecated
public java.io.InputStream getUnicodeStream(String columnName) throws SQLException {
return getUnicodeStream(getColIdxByName(columnName));
}
......@@ -4428,7 +4427,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
// make sure the cursor is on a valid row
checkCursor();
Object obj = convertNumeric(new Float(x),
Object obj = convertNumeric(Float.valueOf(x),
java.sql.Types.REAL,
RowSetMD.getColumnType(columnIndex));
......@@ -4463,7 +4462,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
checkIndex(columnIndex);
// make sure the cursor is on a valid row
checkCursor();
Object obj = convertNumeric(new Double(x),
Object obj = convertNumeric(Double.valueOf(x),
java.sql.Types.DOUBLE,
RowSetMD.getColumnType(columnIndex));
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -839,7 +839,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
if(onInsertRow) {
if(p != null) {
bool = p.evaluate(new Float(x) , columnIndex);
bool = p.evaluate(Float.valueOf(x), columnIndex);
if(!bool) {
throw new SQLException(resBundle.handleGetObject("filteredrowsetimpl.notallowed").toString());
......@@ -906,7 +906,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
if(onInsertRow) {
if(p != null) {
bool = p.evaluate(new Double(x) , columnIndex);
bool = p.evaluate(Double.valueOf(x) , columnIndex);
if(!bool) {
throw new SQLException(resBundle.handleGetObject("filteredrowsetimpl.notallowed").toString());
......
......@@ -1016,6 +1016,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
* prepared statement, and result set
* @deprecated
*/
@Deprecated
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
checkState();
......@@ -1154,6 +1155,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
* @deprecated use <code>getCharacterStream</code> in place of
* <code>getUnicodeStream</code>
*/
@Deprecated
public java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException {
checkState();
......@@ -1336,6 +1338,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
* prepared statement, and result set
* @deprecated
*/
@Deprecated
public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
return getBigDecimal(findColumn(columnName), scale);
}
......@@ -1461,6 +1464,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
* prepared statement, and result set
* @deprecated
*/
@Deprecated
public java.io.InputStream getUnicodeStream(String columnName) throws SQLException {
return getUnicodeStream(findColumn(columnName));
}
......
......@@ -1153,6 +1153,7 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
* the cursor is not on a valid row, or this method fails
* @deprecated
*/
@Deprecated
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
return crsInternal.getBigDecimal(columnIndex);
}
......@@ -1264,6 +1265,7 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
* @throws SQLException if an error occurs
* @deprecated
*/
@Deprecated
public java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException {
return crsInternal.getUnicodeStream(columnIndex);
}
......@@ -1436,6 +1438,7 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
* @deprecated use the method <code>getBigDecimal(String columnName)</code>
* instead
*/
@Deprecated
public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
return crsInternal.getBigDecimal(columnName);
}
......@@ -1552,6 +1555,7 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
* this rowset's rows or its insert row
* @deprecated use the method <code>getCharacterStream</code> instead
*/
@Deprecated
public java.io.InputStream getUnicodeStream(String columnName) throws SQLException {
return crsInternal.getUnicodeStream(columnName);
}
......
......@@ -1288,6 +1288,7 @@ public class SyncResolverImpl extends CachedRowSetImpl implements SyncResolver {
* the cursor is not on a valid row, or this method fails
* @deprecated
*/
@Deprecated
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
throw new UnsupportedOperationException();
}
......@@ -1424,6 +1425,7 @@ public class SyncResolverImpl extends CachedRowSetImpl implements SyncResolver {
* @throws SQLException if an error occurs
* @deprecated
*/
@Deprecated
public java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException {
throw new UnsupportedOperationException();
}
......@@ -1653,6 +1655,7 @@ public class SyncResolverImpl extends CachedRowSetImpl implements SyncResolver {
* @deprecated Use the <code>getBigDecimal(String columnName)</code>
* method instead
*/
@Deprecated
public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
throw new UnsupportedOperationException();
}
......@@ -1784,6 +1787,7 @@ public class SyncResolverImpl extends CachedRowSetImpl implements SyncResolver {
* this rowset's rows or its insert row
* @deprecated use the method <code>getCharacterStream</code> instead
*/
@Deprecated
public java.io.InputStream getUnicodeStream(String columnName) throws SQLException {
throw new UnsupportedOperationException();
}
......
......@@ -802,7 +802,7 @@ public class Krb5LoginModule implements LoginModule {
if (doNotPrompt) {
throw new LoginException
("Unable to obtain Princpal Name for authentication ");
("Unable to obtain Principal Name for authentication ");
} else {
if (callbackHandler == null)
throw new LoginException("No CallbackHandler "
......
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
......@@ -29,6 +29,9 @@ import com.sun.beans.decoder.DocumentHandler;
import java.io.Closeable;
import java.io.InputStream;
import java.io.IOException;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.DefaultHandler;
......@@ -61,6 +64,7 @@ import org.xml.sax.helpers.DefaultHandler;
* @author Philip Milne
*/
public class XMLDecoder implements AutoCloseable {
private final AccessControlContext acc = AccessController.getContext();
private final DocumentHandler handler = new DocumentHandler();
private final InputSource input;
private Object owner;
......@@ -189,7 +193,15 @@ public class XMLDecoder implements AutoCloseable {
return false;
}
if (this.array == null) {
this.handler.parse(this.input);
if ((this.acc == null) && (null != System.getSecurityManager())) {
throw new SecurityException("AccessControlContext is not set");
}
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
XMLDecoder.this.handler.parse(XMLDecoder.this.input);
return null;
}
}, this.acc);
this.array = this.handler.getObjects();
}
return true;
......
......@@ -407,7 +407,7 @@ public final class FilePermission extends Permission implements Serializable {
* @return a hash code value for this object.
*/
public int hashCode() {
return this.cpath.hashCode();
return 0;
}
/**
......
......@@ -79,7 +79,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
default : throw new InternalError("unexpected xtype: " + xtype);
}
} catch (Throwable t) {
throw new InternalError(t);
throw newInternalError(t);
}
}
......@@ -97,7 +97,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
case 'D': return cloneExtendD(type, form, (double) x);
}
} catch (Throwable t) {
throw new InternalError(t);
throw newInternalError(t);
}
throw new InternalError("unexpected type: " + xtype);
}
......@@ -115,7 +115,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
try {
return clone(srcType, form);
} catch (Throwable t) {
throw new InternalError(t);
throw newInternalError(t);
}
}
......@@ -124,7 +124,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
try {
return clone(newType, form.permuteArguments(1, reorder, basicTypes(newType.parameterList())));
} catch (Throwable t) {
throw new InternalError(t);
throw newInternalError(t);
}
}
......@@ -166,7 +166,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
case 'J': return argJ(i);
}
} catch (Throwable ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
throw new InternalError("unexpected type: " + speciesData().types+"."+i);
}
......@@ -192,7 +192,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
try {
return (MethodHandle) argL(0);
} catch (Throwable ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
}
......@@ -464,7 +464,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
}
}
} catch (Throwable e) {
throw new InternalError(e);
throw newInternalError(e);
}
for (SpeciesData d : CACHE.values()) {
......@@ -748,7 +748,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
try {
return LOOKUP.findGetter(cbmhClass, fieldName, fieldType);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new InternalError(e);
throw newInternalError(e);
}
}
......@@ -776,7 +776,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
Field F_SPECIES_DATA = cbmh.getDeclaredField("SPECIES_DATA");
return (SpeciesData) F_SPECIES_DATA.get(null);
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
}
......@@ -802,7 +802,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
try {
return linkConstructor(LOOKUP.findConstructor(cbmh, MethodType.fromMethodDescriptorString(makeSignature(types, true), null)));
} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | TypeNotPresentException e) {
throw new InternalError(e);
throw newInternalError(e);
}
}
......@@ -833,7 +833,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type;
linkerMN = MemberName.getFactory().resolveOrFail(REF_invokeStatic, linkerMN, null, NoSuchMethodException.class);
assert(linkerMN.isStatic());
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
// extend arguments array
Object[] newArgs = Arrays.copyOf(initName.arguments, initName.arguments.length + 1);
......
......@@ -222,7 +222,7 @@ public class CallSite {
GET_TARGET = IMPL_LOOKUP.
findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class));
} catch (ReflectiveOperationException e) {
throw new InternalError(e);
throw newInternalError(e);
}
}
......
......@@ -218,7 +218,7 @@ class DirectMethodHandle extends MethodHandle {
try {
linker = IMPL_NAMES.resolveOrFail(REF_invokeStatic, linker, null, NoSuchMethodException.class);
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
final int DMH_THIS = 0;
final int ARG_BASE = 1;
......@@ -554,7 +554,7 @@ class DirectMethodHandle extends MethodHandle {
try {
linker = IMPL_NAMES.resolveOrFail(REF_invokeVirtual, linker, null, NoSuchMethodException.class);
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
// What is the external type of the lambda form?
......@@ -653,7 +653,7 @@ class DirectMethodHandle extends MethodHandle {
nf.resolve();
}
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
}
}
......@@ -138,7 +138,7 @@ class InvokerBytecodeGenerator {
DUMP_CLASS_FILES_DIR = dumpDir;
System.out.println("Dumping class files to "+DUMP_CLASS_FILES_DIR+"/...");
} catch (Exception e) {
throw new InternalError(e);
throw newInternalError(e);
}
} else {
DUMP_CLASS_FILES_COUNTERS = null;
......@@ -162,7 +162,7 @@ class InvokerBytecodeGenerator {
file.close();
return null;
} catch (IOException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
}
});
......@@ -279,7 +279,7 @@ class InvokerBytecodeGenerator {
try {
member = MEMBERNAME_FACTORY.resolveOrFail(REF_invokeStatic, member, HOST_CLASS, ReflectiveOperationException.class);
} catch (ReflectiveOperationException e) {
throw new InternalError(e);
throw newInternalError(e);
}
//System.out.println("resolveInvokerMember => "+member);
return member;
......
......@@ -27,6 +27,7 @@ package java.lang.invoke;
import java.util.Arrays;
import sun.invoke.empty.Empty;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
import static java.lang.invoke.LambdaForm.*;
......@@ -128,9 +129,8 @@ class Invokers {
try {
//Lookup.findVirtual(MethodHandle.class, name, type);
return IMPL_LOOKUP.resolveOrFail(REF_invokeVirtual, MethodHandle.class, name, type);
} catch (ReflectiveOperationException ex) {
throw new InternalError("JVM cannot find invoker for "+type, ex);
throw newInternalError("JVM cannot find invoker for "+type, ex);
}
}
......@@ -176,7 +176,7 @@ class Invokers {
.findVirtual(MethodHandle.class, "asSpreader",
MethodType.methodType(MethodHandle.class, Class.class, int.class));
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
makeSpreader = MethodHandles.insertArguments(makeSpreader, 1, Object[].class, spreadArgCount);
vaInvoker = MethodHandles.filterArgument(arrayInvoker, 0, makeSpreader);
......@@ -215,7 +215,7 @@ class Invokers {
.findStatic(CallSite.class, "uninitializedCallSite",
MethodType.methodType(Empty.class));
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
}
invoker = MethodHandles.explicitCastArguments(invoker, MethodType.methodType(targetType.returnType()));
......@@ -389,7 +389,7 @@ class Invokers {
form.genericInvoker = gamh;
return gamh;
} catch (Exception ex) {
throw new InternalError("Exception while resolving inexact invoke", ex);
throw newInternalError("Exception while resolving inexact invoke", ex);
}
}
......@@ -456,7 +456,7 @@ class Invokers {
NF_getCallSiteTarget.resolve();
// bound
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
}
......
......@@ -457,7 +457,7 @@ class LambdaForm {
isCompiled = true;
return vmentry;
} catch (Error | Exception ex) {
throw new InternalError(this.toString(), ex);
throw newInternalError(this.toString(), ex);
}
}
......@@ -1547,7 +1547,7 @@ class LambdaForm {
try {
zmem = IMPL_NAMES.resolveOrFail(REF_invokeStatic, zmem, null, NoSuchMethodException.class);
} catch (IllegalAccessException|NoSuchMethodException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
NamedFunction zcon = new NamedFunction(zmem);
Name n = new Name(zcon).newIndex(0);
......
......@@ -558,7 +558,7 @@ import java.util.Objects;
try {
return (MemberName) super.clone();
} catch (CloneNotSupportedException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
}
......
......@@ -1372,7 +1372,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
NF_reinvokerTarget = new LambdaForm.NamedFunction(MethodHandle.class
.getDeclaredMethod("reinvokerTarget"));
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
}
......@@ -1397,7 +1397,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
try {
FORM_OFFSET = UNSAFE.objectFieldOffset(MethodHandle.class.getDeclaredField("form"));
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
}
}
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
......@@ -25,13 +25,14 @@
package java.lang.invoke;
import sun.invoke.util.VerifyType;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import sun.invoke.empty.Empty;
import sun.invoke.util.ValueConversions;
import sun.invoke.util.VerifyType;
import sun.invoke.util.Wrapper;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.MethodHandleStatics.*;
......@@ -478,7 +479,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
.getDeclaredMethod("checkSpreadArgument", Object.class, int.class));
NF_checkSpreadArgument.resolve();
} catch (ReflectiveOperationException ex) {
throw new InternalError(ex);
throw newInternalError(ex);
}
}
......@@ -781,4 +782,168 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
return mh;
}
/**
* Create an alias for the method handle which, when called,
* appears to be called from the same class loader and protection domain
* as hostClass.
* This is an expensive no-op unless the method which is called
* is sensitive to its caller. A small number of system methods
* are in this category, including Class.forName and Method.invoke.
*/
static
MethodHandle bindCaller(MethodHandle mh, Class<?> hostClass) {
return BindCaller.bindCaller(mh, hostClass);
}
// Put the whole mess into its own nested class.
// That way we can lazily load the code and set up the constants.
private static class BindCaller {
static
MethodHandle bindCaller(MethodHandle mh, Class<?> hostClass) {
// Do not use this function to inject calls into system classes.
if (hostClass == null) {
hostClass = C_Trampoline;
} else if (hostClass.isArray() ||
hostClass.isPrimitive() ||
hostClass.getName().startsWith("java.") ||
hostClass.getName().startsWith("sun.")) {
throw new InternalError(); // does not happen, and should not anyway
}
// For simplicity, convert mh to a varargs-like method.
MethodHandle vamh = prepareForInvoker(mh);
// Cache the result of makeInjectedInvoker once per argument class.
MethodHandle bccInvoker = CV_makeInjectedInvoker.get(hostClass);
return restoreToType(bccInvoker.bindTo(vamh), mh.type());
}
// This class ("Trampoline") is known to be inside a dead-end class loader.
// Inject all doubtful calls into this class.
private static Class<?> C_Trampoline;
static {
Class<?> tramp = null;
try {
final int FRAME_COUNT_ARG = 1; // [0] Reflection [1] Trampoline
java.lang.reflect.Method gcc = sun.reflect.Reflection.class.getMethod("getCallerClass", int.class);
tramp = (Class<?>) sun.reflect.misc.MethodUtil.invoke(gcc, null, new Object[]{ FRAME_COUNT_ARG });
if (tramp.getClassLoader() == BindCaller.class.getClassLoader())
throw new RuntimeException(tramp.getName()+" class loader");
} catch (Throwable ex) {
throw new InternalError(ex);
}
C_Trampoline = tramp;
}
private static MethodHandle makeInjectedInvoker(Class<?> hostClass) {
Class<?> bcc = UNSAFE.defineAnonymousClass(hostClass, T_BYTES, null);
if (hostClass.getClassLoader() != bcc.getClassLoader())
throw new InternalError(hostClass.getName()+" (CL)");
try {
if (hostClass.getProtectionDomain() != bcc.getProtectionDomain())
throw new InternalError(hostClass.getName()+" (PD)");
} catch (SecurityException ex) {
// Self-check was blocked by security manager. This is OK.
// In fact the whole try body could be turned into an assertion.
}
try {
MethodHandle init = IMPL_LOOKUP.findStatic(bcc, "init", MethodType.methodType(void.class));
init.invokeExact(); // force initialization of the class
} catch (Throwable ex) {
throw uncaughtException(ex);
}
MethodHandle bccInvoker;
try {
MethodType invokerMT = MethodType.methodType(Object.class, MethodHandle.class, Object[].class);
bccInvoker = IMPL_LOOKUP.findStatic(bcc, "invoke_V", invokerMT);
} catch (ReflectiveOperationException ex) {
throw uncaughtException(ex);
}
// Test the invoker, to ensure that it really injects into the right place.
try {
MethodHandle vamh = prepareForInvoker(MH_checkCallerClass);
Object ok = bccInvoker.invokeExact(vamh, new Object[]{hostClass, bcc});
} catch (Throwable ex) {
throw new InternalError(ex);
}
return bccInvoker;
}
private static ClassValue<MethodHandle> CV_makeInjectedInvoker = new ClassValue<MethodHandle>() {
@Override protected MethodHandle computeValue(Class<?> hostClass) {
return makeInjectedInvoker(hostClass);
}
};
// Adapt mh so that it can be called directly from an injected invoker:
private static MethodHandle prepareForInvoker(MethodHandle mh) {
mh = mh.asFixedArity();
MethodType mt = mh.type();
int arity = mt.parameterCount();
MethodHandle vamh = mh.asType(mt.generic());
vamh.internalForm().compileToBytecode(); // eliminate LFI stack frames
vamh = vamh.asSpreader(Object[].class, arity);
vamh.internalForm().compileToBytecode(); // eliminate LFI stack frames
return vamh;
}
// Undo the adapter effect of prepareForInvoker:
private static MethodHandle restoreToType(MethodHandle vamh, MethodType type) {
return vamh.asCollector(Object[].class, type.parameterCount()).asType(type);
}
private static final MethodHandle MH_checkCallerClass;
static {
final Class<?> THIS_CLASS = BindCaller.class;
assert(checkCallerClass(THIS_CLASS, THIS_CLASS));
try {
MH_checkCallerClass = IMPL_LOOKUP
.findStatic(THIS_CLASS, "checkCallerClass",
MethodType.methodType(boolean.class, Class.class, Class.class));
assert((boolean) MH_checkCallerClass.invokeExact(THIS_CLASS, THIS_CLASS));
} catch (Throwable ex) {
throw new InternalError(ex);
}
}
private static boolean checkCallerClass(Class<?> expected, Class<?> expected2) {
final int FRAME_COUNT_ARG = 2; // [0] Reflection [1] BindCaller [2] Expected
Class<?> actual = sun.reflect.Reflection.getCallerClass(FRAME_COUNT_ARG);
if (actual != expected && actual != expected2)
throw new InternalError("found "+actual.getName()+", expected "+expected.getName()
+(expected == expected2 ? "" : ", or else "+expected2.getName()));
return true;
}
private static final byte[] T_BYTES;
static {
final Object[] values = {null};
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
try {
Class<T> tClass = T.class;
String tName = tClass.getName();
String tResource = tName.substring(tName.lastIndexOf('.')+1)+".class";
java.net.URLConnection uconn = tClass.getResource(tResource).openConnection();
int len = uconn.getContentLength();
byte[] bytes = new byte[len];
try (java.io.InputStream str = uconn.getInputStream()) {
int nr = str.read(bytes);
if (nr != len) throw new java.io.IOException(tResource);
}
values[0] = bytes;
} catch (java.io.IOException ex) {
throw new InternalError(ex);
}
return null;
}
});
T_BYTES = (byte[]) values[0];
}
// The following class is used as a template for Unsafe.defineAnonymousClass:
private static class T {
static void init() { } // side effect: initializes this class
static Object invoke_V(MethodHandle vamh, Object[] args) throws Throwable {
return vamh.invokeExact(args);
}
}
}
}
......@@ -385,4 +385,101 @@ class MethodHandleNatives {
throw err;
}
}
/**
* Is this method a caller-sensitive method?
* I.e., does it call Reflection.getCallerClass or a similer method
* to ask about the identity of its caller?
*/
// FIXME: Replace this pattern match by an annotation @sun.reflect.CallerSensitive.
static boolean isCallerSensitive(MemberName mem) {
assert(mem.isInvocable());
Class<?> defc = mem.getDeclaringClass();
switch (mem.getName()) {
case "doPrivileged":
return defc == java.security.AccessController.class;
case "getUnsafe":
return defc == sun.misc.Unsafe.class;
case "lookup":
return defc == java.lang.invoke.MethodHandles.class;
case "invoke":
return defc == java.lang.reflect.Method.class;
case "get":
case "getBoolean":
case "getByte":
case "getChar":
case "getShort":
case "getInt":
case "getLong":
case "getFloat":
case "getDouble":
case "set":
case "setBoolean":
case "setByte":
case "setChar":
case "setShort":
case "setInt":
case "setLong":
case "setFloat":
case "setDouble":
return defc == java.lang.reflect.Field.class;
case "newInstance":
if (defc == java.lang.reflect.Constructor.class) return true;
if (defc == java.lang.Class.class) return true;
break;
case "forName":
case "getClassLoader":
case "getClasses":
case "getFields":
case "getMethods":
case "getConstructors":
case "getDeclaredClasses":
case "getDeclaredFields":
case "getDeclaredMethods":
case "getDeclaredConstructors":
case "getField":
case "getMethod":
case "getConstructor":
case "getDeclaredField":
case "getDeclaredMethod":
case "getDeclaredConstructor":
return defc == java.lang.Class.class;
case "getConnection":
case "getDriver":
case "getDrivers":
case "deregisterDriver":
return defc == java.sql.DriverManager.class;
case "newUpdater":
if (defc == java.util.concurrent.atomic.AtomicIntegerFieldUpdater.class) return true;
if (defc == java.util.concurrent.atomic.AtomicLongFieldUpdater.class) return true;
if (defc == java.util.concurrent.atomic.AtomicReferenceFieldUpdater.class) return true;
break;
case "getContextClassLoader":
return defc == java.lang.Thread.class;
case "getPackage":
case "getPackages":
return defc == java.lang.Package.class;
case "getParent":
case "getSystemClassLoader":
return defc == java.lang.ClassLoader.class;
case "load":
case "loadLibrary":
if (defc == java.lang.Runtime.class) return true;
if (defc == java.lang.System.class) return true;
break;
case "getCallerClass":
if (defc == sun.reflect.Reflection.class) return true;
if (defc == java.lang.System.class) return true;
break;
case "getCallerClassLoader":
return defc == java.lang.ClassLoader.class;
case "getProxyClass":
case "newProxyInstance":
return defc == java.lang.reflect.Proxy.class;
case "getBundle":
case "clearCache":
return defc == java.util.ResourceBundle.class;
}
return false;
}
}
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
......@@ -93,6 +93,12 @@ import sun.misc.Unsafe;
}
// handy shared exception makers (they simplify the common case code)
/*non-public*/ static InternalError newInternalError(String message, Throwable cause) {
return new InternalError(message, cause);
}
/*non-public*/ static InternalError newInternalError(Throwable cause) {
return new InternalError(cause);
}
/*non-public*/ static RuntimeException newIllegalStateException(String message) {
return new IllegalStateException(message);
}
......@@ -108,8 +114,8 @@ import sun.misc.Unsafe;
/*non-public*/ static RuntimeException newIllegalArgumentException(String message, Object obj, Object obj2) {
return new IllegalArgumentException(message(message, obj, obj2));
}
/*non-public*/ static Error uncaughtException(Exception ex) {
throw new InternalError("uncaught exception", ex);
/*non-public*/ static Error uncaughtException(Throwable ex) {
throw newInternalError("uncaught exception", ex);
}
static Error NYI() {
throw new AssertionError("NYI");
......
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
......@@ -329,6 +329,7 @@ public class MethodHandles {
* where {@code defcPkg} is the package of {@code defc}.
* </ul>
*/
// FIXME in MR1: clarify that the bytecode behavior of a caller-ID method (like Class.forName) is relative to the lookupClass used to create the method handle, not the dynamic caller of the method handle
public static final
class Lookup {
/** The class on behalf of whom the lookup is being performed. */
......@@ -1209,6 +1210,7 @@ return mh1;
if (method.isMethodHandleInvoke())
return fakeMethodHandleInvoke(method);
MethodHandle mh = DirectMethodHandle.make(refc, method);
mh = maybeBindCaller(method, mh);
mh = mh.setVarargs(method);
if (doRestrict)
mh = restrictReceiver(method, mh, lookupClass());
......@@ -1217,6 +1219,16 @@ return mh1;
private MethodHandle fakeMethodHandleInvoke(MemberName method) {
return throwException(method.getReturnType(), UnsupportedOperationException.class);
}
private MethodHandle maybeBindCaller(MemberName method, MethodHandle mh) throws IllegalAccessException {
if (allowedModes == TRUSTED || !MethodHandleNatives.isCallerSensitive(method))
return mh;
Class<?> hostClass = lookupClass;
if ((allowedModes & PRIVATE) == 0) // caller must use full-power lookup
hostClass = null;
MethodHandle cbmh = MethodHandleImpl.bindCaller(mh, hostClass);
// Note: caller will apply varargs after this step happens.
return cbmh;
}
private MethodHandle getDirectField(byte refKind, Class<?> refc, MemberName field) throws IllegalAccessException {
checkField(refKind, refc, field);
MethodHandle mh = DirectMethodHandle.make(refc, field);
......@@ -1229,6 +1241,7 @@ return mh1;
private MethodHandle getDirectConstructor(Class<?> refc, MemberName ctor) throws IllegalAccessException {
assert(ctor.isConstructor());
checkAccess(REF_newInvokeSpecial, refc, ctor);
assert(!MethodHandleNatives.isCallerSensitive(ctor)); // maybeBindCaller not relevant here
return DirectMethodHandle.make(ctor).setVarargs(ctor);
}
......
......@@ -52,6 +52,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
private boolean shut_wr = false;
private SocketInputStream socketInputStream = null;
private SocketOutputStream socketOutputStream = null;
/* number of threads using the FileDescriptor */
protected int fdUseCount = 0;
......@@ -436,7 +437,10 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
if (shut_wr) {
throw new IOException("Socket output is shutdown");
}
return new SocketOutputStream(this);
if (socketOutputStream == null) {
socketOutputStream = new SocketOutputStream(this);
}
return socketOutputStream;
}
void setFileDescriptor(FileDescriptor fd) {
......
......@@ -127,7 +127,6 @@ public abstract class ProxySelector {
* <UL>
* <LI>http URI for http connections</LI>
* <LI>https URI for https connections
* <LI>ftp URI for ftp connections</LI>
* <LI><code>socket://host:port</code><br>
* for tcp client sockets connections</LI>
* </UL>
......
......@@ -274,7 +274,7 @@ public final class URL implements java.io.Serializable {
* <p>Protocol handlers for the following protocols are guaranteed
* to exist on the search path :-
* <blockquote><pre>
* http, https, ftp, file, and jar
* http, https, file, and jar
* </pre></blockquote>
* Protocol handlers for additional protocols may also be
* available.
......
......@@ -37,8 +37,7 @@ import sun.net.www.ParseUtil;
* The abstract class <code>URLStreamHandler</code> is the common
* superclass for all stream protocol handlers. A stream protocol
* handler knows how to make a connection for a particular protocol
* type, such as <code>http</code>, <code>ftp</code>, or
* <code>gopher</code>.
* type, such as <code>http</code> or <code>https</code>.
* <p>
* In most cases, an instance of a <code>URLStreamHandler</code>
* subclass is not created directly by an application. Rather, the
......
......@@ -72,7 +72,7 @@ Provides the classes for implementing networking applications.
<ul>
<li>{@link java.net.URI} is the class representing a Universal Resource Identifier, as specified in RFC 2396. As the name indicates, this is just an Identifier and doesn't provide directly the means to access the resource.</li>
<li>{@link java.net.URL} is the class representing a Universal Resource Locator, which is both an older concept for URIs and a means to access the resources.</li>
<li>{@link java.net.URLConnection} is created from a URL and is the communication link used to access the resource pointed by the URL. This abstract class will delegate most of the work to the underlying protocol handlers like http or ftp.</li>
<li>{@link java.net.URLConnection} is created from a URL and is the communication link used to access the resource pointed by the URL. This abstract class will delegate most of the work to the underlying protocol handlers like http or https.</li>
<li>{@link java.net.HttpURLConnection} is a subclass of URLConnection and provides some additional functionalities specific to the HTTP protocol.</li>
</ul>
<p>The recommended usage is to use {@link java.net.URI} to identify resources, then convert it into a {@link java.net.URL} when it is time to access the resource. From that URL, you can either get the {@link java.net.URLConnection} for fine control, or get directly the InputStream.<p>
......
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
......@@ -290,11 +290,11 @@ public final class AccessController {
*/
public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) {
DomainCombiner dc = null;
AccessControlContext acc = getStackAccessControlContext();
if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
if (acc == null) {
return AccessController.doPrivileged(action);
}
DomainCombiner dc = acc.getAssignedCombiner();
return AccessController.doPrivileged(action, preserveCombiner(dc));
}
......@@ -386,11 +386,11 @@ public final class AccessController {
public static <T> T doPrivilegedWithCombiner
(PrivilegedExceptionAction<T> action) throws PrivilegedActionException {
DomainCombiner dc = null;
AccessControlContext acc = getStackAccessControlContext();
if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
if (acc == null) {
return AccessController.doPrivileged(action);
}
DomainCombiner dc = acc.getAssignedCombiner();
return AccessController.doPrivileged(action, preserveCombiner(dc));
}
......@@ -417,7 +417,12 @@ public final class AccessController {
// perform 'combine' on the caller of doPrivileged,
// even if the caller is from the bootclasspath
ProtectionDomain[] pds = new ProtectionDomain[] {callerPd};
return new AccessControlContext(combiner.combine(pds, null), combiner);
if (combiner == null) {
return new AccessControlContext(pds);
} else {
return new AccessControlContext(combiner.combine(pds, null),
combiner);
}
}
......
......@@ -295,6 +295,7 @@ public interface CallableStatement extends PreparedStatement {
* or <code>getBigDecimal(String parameterName)</code>
* @see #setBigDecimal
*/
@Deprecated
BigDecimal getBigDecimal(int parameterIndex, int scale)
throws SQLException;
......
......@@ -51,6 +51,7 @@ public class Date extends java.util.Date {
* @param day 1 to 31
* @deprecated instead use the constructor <code>Date(long date)</code>
*/
@Deprecated
public Date(int year, int month, int day) {
super(year, month, day);
}
......@@ -179,6 +180,7 @@ public class Date extends java.util.Date {
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #setHours
*/
@Deprecated
public int getHours() {
throw new java.lang.IllegalArgumentException();
}
......@@ -191,6 +193,7 @@ public class Date extends java.util.Date {
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #setMinutes
*/
@Deprecated
public int getMinutes() {
throw new java.lang.IllegalArgumentException();
}
......@@ -203,6 +206,7 @@ public class Date extends java.util.Date {
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #setSeconds
*/
@Deprecated
public int getSeconds() {
throw new java.lang.IllegalArgumentException();
}
......@@ -215,6 +219,7 @@ public class Date extends java.util.Date {
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #getHours
*/
@Deprecated
public void setHours(int i) {
throw new java.lang.IllegalArgumentException();
}
......@@ -227,6 +232,7 @@ public class Date extends java.util.Date {
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #getMinutes
*/
@Deprecated
public void setMinutes(int i) {
throw new java.lang.IllegalArgumentException();
}
......@@ -239,6 +245,7 @@ public class Date extends java.util.Date {
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #getSeconds
*/
@Deprecated
public void setSeconds(int i) {
throw new java.lang.IllegalArgumentException();
}
......
......@@ -412,13 +412,14 @@ public class DriverManager {
* method throws a <code>java.lang.SecurityException</code>.
*
* @param out the new logging/tracing PrintStream; to disable, set to <code>null</code>
* @deprecated
* @deprecated Use {@code setLogWriter}
* @throws SecurityException if a security manager exists and its
* <code>checkPermission</code> method denies setting the log stream
*
* @see SecurityManager#checkPermission
* @see #getLogStream
*/
@Deprecated
public static void setLogStream(java.io.PrintStream out) {
SecurityManager sec = System.getSecurityManager();
......@@ -438,9 +439,10 @@ public class DriverManager {
* and all drivers.
*
* @return the logging/tracing PrintStream; if disabled, is <code>null</code>
* @deprecated
* @deprecated Use {@code getLogWriter}
* @see #setLogStream
*/
@Deprecated
public static java.io.PrintStream getLogStream() {
return logStream;
}
......
......@@ -342,8 +342,9 @@ public interface PreparedStatement extends Statement {
* this method is called on a closed <code>PreparedStatement</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @deprecated
* @deprecated Use {@code setCharacterStream}
*/
@Deprecated
void setUnicodeStream(int parameterIndex, java.io.InputStream x,
int length) throws SQLException;
......
......@@ -356,8 +356,10 @@ public interface ResultSet extends Wrapper, AutoCloseable {
* called on a closed result set
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @deprecated
* @deprecated Use {@code getBigDecimal(int columnIndex)}
* or {@code getBigDecimal(String columnLabel)}
*/
@Deprecated
BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException;
/**
......@@ -477,6 +479,7 @@ public interface ResultSet extends Wrapper, AutoCloseable {
* @deprecated use <code>getCharacterStream</code> in place of
* <code>getUnicodeStream</code>
*/
@Deprecated
java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException;
/**
......@@ -641,8 +644,10 @@ public interface ResultSet extends Wrapper, AutoCloseable {
* called on a closed result set
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @deprecated
* @deprecated Use {@code getBigDecimal(int columnIndex)}
* or {@code getBigDecimal(String columnLabel)}
*/
@Deprecated
BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException;
/**
......@@ -760,6 +765,7 @@ public interface ResultSet extends Wrapper, AutoCloseable {
* this method
* @deprecated use <code>getCharacterStream</code> instead
*/
@Deprecated
java.io.InputStream getUnicodeStream(String columnLabel) throws SQLException;
/**
......
......@@ -45,6 +45,7 @@ import java.lang.ref.SoftReference;
import java.text.spi.DateFormatSymbolsProvider;
import java.util.Arrays;
import java.util.Locale;
import java.util.Objects;
import java.util.ResourceBundle;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
......@@ -366,6 +367,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public void setEras(String[] newEras) {
eras = Arrays.copyOf(newEras, newEras.length);
cachedHashCode = 0;
}
/**
......@@ -393,6 +395,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public void setMonths(String[] newMonths) {
months = Arrays.copyOf(newMonths, newMonths.length);
cachedHashCode = 0;
}
/**
......@@ -420,6 +423,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public void setShortMonths(String[] newShortMonths) {
shortMonths = Arrays.copyOf(newShortMonths, newShortMonths.length);
cachedHashCode = 0;
}
/**
......@@ -439,6 +443,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public void setWeekdays(String[] newWeekdays) {
weekdays = Arrays.copyOf(newWeekdays, newWeekdays.length);
cachedHashCode = 0;
}
/**
......@@ -458,6 +463,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public void setShortWeekdays(String[] newShortWeekdays) {
shortWeekdays = Arrays.copyOf(newShortWeekdays, newShortWeekdays.length);
cachedHashCode = 0;
}
/**
......@@ -474,6 +480,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public void setAmPmStrings(String[] newAmpms) {
ampms = Arrays.copyOf(newAmpms, newAmpms.length);
cachedHashCode = 0;
}
/**
......@@ -558,6 +565,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
zoneStrings = aCopy;
isZoneStringsSet = true;
cachedHashCode = 0;
}
/**
......@@ -576,6 +584,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
public void setLocalPatternChars(String newLocalPatternChars) {
// Call toString() to throw an NPE in case the argument is null
localPatternChars = newLocalPatternChars.toString();
cachedHashCode = 0;
}
/**
......@@ -597,12 +606,23 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* Override hashCode.
* Generates a hash code for the DateFormatSymbols object.
*/
@Override
public int hashCode() {
int hashcode = 0;
String[][] zoneStrings = getZoneStringsWrapper();
for (int index = 0; index < zoneStrings[0].length; ++index)
hashcode ^= zoneStrings[0][index].hashCode();
return hashcode;
int hashCode = cachedHashCode;
if (hashCode == 0) {
hashCode = 5;
hashCode = 11 * hashCode + Arrays.hashCode(eras);
hashCode = 11 * hashCode + Arrays.hashCode(months);
hashCode = 11 * hashCode + Arrays.hashCode(shortMonths);
hashCode = 11 * hashCode + Arrays.hashCode(weekdays);
hashCode = 11 * hashCode + Arrays.hashCode(shortWeekdays);
hashCode = 11 * hashCode + Arrays.hashCode(ampms);
hashCode = 11 * hashCode + Arrays.deepHashCode(getZoneStringsWrapper());
hashCode = 11 * hashCode + Objects.hashCode(localPatternChars);
cachedHashCode = hashCode;
}
return hashCode;
}
/**
......@@ -641,6 +661,11 @@ public class DateFormatSymbols implements Serializable, Cloneable {
private transient int lastZoneIndex = 0;
/**
* Cached hash code
*/
transient volatile int cachedHashCode = 0;
private void initializeData(Locale desiredLocale) {
locale = desiredLocale;
......@@ -782,6 +807,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
dst.zoneStrings = null;
}
dst.localPatternChars = src.localPatternChars;
dst.cachedHashCode = 0;
}
/**
......
......@@ -1059,7 +1059,7 @@ public class Hashtable<K,V>
}
public int hashCode() {
return hash ^ (value==null ? 0 : value.hashCode());
return (Objects.hashCode(key) ^ Objects.hashCode(value));
}
public String toString() {
......
......@@ -81,8 +81,9 @@ import sun.util.spi.XmlPropertiesProvider;
* <p> The {@link #loadFromXML(InputStream)} and {@link
* #storeToXML(OutputStream, String, String)} methods load and store properties
* in a simple XML format. By default the UTF-8 character encoding is used,
* however a specific encoding may be specified if required. An XML properties
* document has the following DOCTYPE declaration:
* however a specific encoding may be specified if required. Implementations
* are required to support UTF-8 and UTF-16 and may support other encodings.
* An XML properties document has the following DOCTYPE declaration:
*
* <pre>
* &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt;
......@@ -853,23 +854,30 @@ class Properties extends Hashtable<Object,Object> {
* Furthermore, the document must satisfy the properties DTD described
* above.
*
* <p> An implementation is required to read XML documents that use the
* "{@code UTF-8}" or "{@code UTF-16}" encoding. An implementation may
* support additional encodings.
*
* <p>The specified stream is closed after this method returns.
*
* @param in the input stream from which to read the XML document.
* @throws IOException if reading from the specified input stream
* results in an <tt>IOException</tt>.
* @throws java.io.UnsupportedEncodingException if the document's encoding
* declaration can be read and it specifies an encoding that is not
* supported
* @throws InvalidPropertiesFormatException Data on input stream does not
* constitute a valid XML document with the mandated document type.
* @throws NullPointerException if {@code in} is null.
* @see #storeToXML(OutputStream, String, String)
* @see <a href="http://www.w3.org/TR/REC-xml/#charencoding">Character
* Encoding in Entities</a>
* @since 1.5
*/
public synchronized void loadFromXML(InputStream in)
throws IOException, InvalidPropertiesFormatException
{
if (in == null)
throw new NullPointerException();
XmlSupport.load(this, in);
XmlSupport.load(this, Objects.requireNonNull(in));
in.close();
}
......@@ -896,8 +904,6 @@ class Properties extends Hashtable<Object,Object> {
public void storeToXML(OutputStream os, String comment)
throws IOException
{
if (os == null)
throw new NullPointerException();
storeToXML(os, comment, "UTF-8");
}
......@@ -910,9 +916,13 @@ class Properties extends Hashtable<Object,Object> {
* &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt;
* </pre>
*
*<p>If the specified comment is {@code null} then no comment
* <p>If the specified comment is {@code null} then no comment
* will be stored in the document.
*
* <p> An implementation is required to support writing of XML documents
* that use the "{@code UTF-8}" or "{@code UTF-16}" encoding. An
* implementation may support additional encodings.
*
* <p>The specified stream remains open after this method returns.
*
* @param os the output stream on which to emit the XML document.
......@@ -924,20 +934,23 @@ class Properties extends Hashtable<Object,Object> {
*
* @throws IOException if writing to the specified output stream
* results in an <tt>IOException</tt>.
* @throws java.io.UnsupportedEncodingException if the encoding is not
* supported by the implementation.
* @throws NullPointerException if {@code os} is {@code null},
* or if {@code encoding} is {@code null}.
* @throws ClassCastException if this {@code Properties} object
* contains any keys or values that are not
* {@code Strings}.
* @see #loadFromXML(InputStream)
* @see <a href="http://www.w3.org/TR/REC-xml/#charencoding">Character
* Encoding in Entities</a>
* @since 1.5
*/
public void storeToXML(OutputStream os, String comment, String encoding)
throws IOException
{
if (os == null)
throw new NullPointerException();
XmlSupport.save(this, os, comment, encoding);
XmlSupport.save(this, Objects.requireNonNull(os), comment,
Objects.requireNonNull(encoding));
}
/**
......
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* 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
......@@ -214,7 +214,7 @@ public final class ServiceLoader<S>
private ServiceLoader(Class<S> svc, ClassLoader cl) {
service = Objects.requireNonNull(svc, "Service interface cannot be null");
loader = cl;
loader = (cl == null) ? ClassLoader.getSystemClassLoader() : cl;
reload();
}
......@@ -358,14 +358,21 @@ public final class ServiceLoader<S>
}
String cn = nextName;
nextName = null;
Class<?> c = null;
try {
S p = service.cast(Class.forName(cn, true, loader)
.newInstance());
providers.put(cn, p);
return p;
c = Class.forName(cn, false, loader);
} catch (ClassNotFoundException x) {
fail(service,
"Provider " + cn + " not found");
}
if (!service.isAssignableFrom(c)) {
fail(service,
"Provider " + cn + " not a subtype");
}
try {
S p = service.cast(c.newInstance());
providers.put(cn, p);
return p;
} catch (Throwable x) {
fail(service,
"Provider " + cn + " could not be instantiated: " + x,
......
/*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
......@@ -719,15 +719,16 @@ abstract public class TimeZone implements Serializable, Cloneable {
* Returns the default TimeZone in an AppContext if any AppContext
* has ever used. null is returned if any AppContext hasn't been
* used or if the AppContext doesn't have the default TimeZone.
*
* Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
* been loaded. If so, it implies that AWTSecurityManager is not our
* SecurityManager and we can use a local static variable.
* This works around a build time issue.
*/
private synchronized static TimeZone getDefaultInAppContext() {
private static TimeZone getDefaultInAppContext() {
// JavaAWTAccess provides access implementation-private methods without using reflection.
JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
// Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
// been loaded. If so, it implies that AWTSecurityManager is not our
// SecurityManager and we can use a local static variable.
// This works around a build time issue.
if (javaAWTAccess == null) {
return mainAppContextDefault;
} else {
......@@ -749,15 +750,16 @@ abstract public class TimeZone implements Serializable, Cloneable {
* tz. null is handled special: do nothing if any AppContext
* hasn't been used, remove the default TimeZone in the
* AppContext otherwise.
*
* Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
* been loaded. If so, it implies that AWTSecurityManager is not our
* SecurityManager and we can use a local static variable.
* This works around a build time issue.
*/
private synchronized static void setDefaultInAppContext(TimeZone tz) {
private static void setDefaultInAppContext(TimeZone tz) {
// JavaAWTAccess provides access implementation-private methods without using reflection.
JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
// Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
// been loaded. If so, it implies that AWTSecurityManager is not our
// SecurityManager and we can use a local static variable.
// This works around a build time issue.
if (javaAWTAccess == null) {
mainAppContextDefault = tz;
} else {
......@@ -822,7 +824,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
private static final int GMT_ID_LENGTH = 3;
// a static TimeZone we can reference if no AppContext is in place
private static TimeZone mainAppContextDefault;
private static volatile TimeZone mainAppContextDefault;
/**
* Parses a custom time zone identifier and returns a corresponding zone.
......
......@@ -530,18 +530,17 @@ public class Executors {
return AccessController.doPrivileged(
new PrivilegedExceptionAction<T>() {
public T run() throws Exception {
ClassLoader savedcl = null;
Thread t = Thread.currentThread();
try {
ClassLoader cl = t.getContextClassLoader();
if (ccl != cl) {
t.setContextClassLoader(ccl);
savedcl = cl;
}
ClassLoader cl = t.getContextClassLoader();
if (ccl == cl) {
return task.call();
} finally {
if (savedcl != null)
t.setContextClassLoader(savedcl);
} else {
t.setContextClassLoader(ccl);
try {
return task.call();
} finally {
t.setContextClassLoader(cl);
}
}
}
}, acc);
......
/*
* Copyright (c) 2003,2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -456,12 +456,12 @@ public abstract class Pack200 {
* The unpacker's progress as a percentage, as periodically
* updated by the unpacker.
* Values of 0 - 100 are normal, and -1 indicates a stall.
* Observe this property with a {@link PropertyChangeListener}.
* Progress can be monitored by polling the value of this
* property.
* <p>
* At a minimum, the unpacker must set progress to 0
* at the beginning of a packing operation, and to 100
* at the end.
* @see #addPropertyChangeListener
*/
String PROGRESS = "pack.progress";
......@@ -577,7 +577,15 @@ public abstract class Pack200 {
* @see #properties
* @see #PROGRESS
* @param listener An object to be invoked when a property is changed.
*/
* @deprecated The dependency on {@code PropertyChangeListener} creates
* a significant impediment to future modularization of the
* Java platform. This method will be removed in a future
* release.
* Applications that need to monitor progress of the packer
* can poll the value of the {@link #PROGRESS PROGRESS}
* property instead.
*/
@Deprecated
void addPropertyChangeListener(PropertyChangeListener listener) ;
/**
......@@ -586,7 +594,12 @@ public abstract class Pack200 {
*
* @see #addPropertyChangeListener
* @param listener The PropertyChange listener to be removed.
* @deprecated The dependency on {@code PropertyChangeListener} creates
* a significant impediment to future modularization of the
* Java platform. This method will be removed in a future
* release.
*/
@Deprecated
void removePropertyChangeListener(PropertyChangeListener listener);
}
......@@ -640,12 +653,12 @@ public abstract class Pack200 {
* The unpacker's progress as a percentage, as periodically
* updated by the unpacker.
* Values of 0 - 100 are normal, and -1 indicates a stall.
* Observe this property with a {@link PropertyChangeListener}.
* Progress can be monitored by polling the value of this
* property.
* <p>
* At a minimum, the unpacker must set progress to 0
* at the beginning of a packing operation, and to 100
* at the end.
* @see #addPropertyChangeListener
*/
String PROGRESS = "unpack.progress";
......@@ -708,7 +721,15 @@ public abstract class Pack200 {
* @see #properties
* @see #PROGRESS
* @param listener An object to be invoked when a property is changed.
*/
* @deprecated The dependency on {@code PropertyChangeListener} creates
* a significant impediment to future modularization of the
* Java platform. This method will be removed in a future
* release.
* Applications that need to monitor progress of the
* unpacker can poll the value of the {@link #PROGRESS
* PROGRESS} property instead.
*/
@Deprecated
void addPropertyChangeListener(PropertyChangeListener listener) ;
/**
......@@ -717,7 +738,12 @@ public abstract class Pack200 {
*
* @see #addPropertyChangeListener
* @param listener The PropertyChange listener to be removed.
* @deprecated The dependency on {@code PropertyChangeListener} creates
* a significant impediment to future modularization of the
* Java platform. This method will be removed in a future
* release.
*/
@Deprecated
void removePropertyChangeListener(PropertyChangeListener listener);
}
......
......@@ -220,7 +220,7 @@ public class FileHandler extends StreamHandler {
* @exception NullPointerException if pattern property is an empty String.
*/
public FileHandler() throws IOException, SecurityException {
checkAccess();
checkPermission();
configure();
openFiles();
}
......@@ -246,7 +246,7 @@ public class FileHandler extends StreamHandler {
if (pattern.length() < 1 ) {
throw new IllegalArgumentException();
}
checkAccess();
checkPermission();
configure();
this.pattern = pattern;
this.limit = 0;
......@@ -278,7 +278,7 @@ public class FileHandler extends StreamHandler {
if (pattern.length() < 1 ) {
throw new IllegalArgumentException();
}
checkAccess();
checkPermission();
configure();
this.pattern = pattern;
this.limit = 0;
......@@ -315,7 +315,7 @@ public class FileHandler extends StreamHandler {
if (limit < 0 || count < 1 || pattern.length() < 1) {
throw new IllegalArgumentException();
}
checkAccess();
checkPermission();
configure();
this.pattern = pattern;
this.limit = limit;
......@@ -354,7 +354,7 @@ public class FileHandler extends StreamHandler {
if (limit < 0 || count < 1 || pattern.length() < 1) {
throw new IllegalArgumentException();
}
checkAccess();
checkPermission();
configure();
this.pattern = pattern;
this.limit = limit;
......@@ -367,7 +367,7 @@ public class FileHandler extends StreamHandler {
// configured instance variables.
private void openFiles() throws IOException {
LogManager manager = LogManager.getLogManager();
manager.checkAccess();
manager.checkPermission();
if (count < 1) {
throw new IllegalArgumentException("file count = " + count);
}
......
......@@ -111,7 +111,7 @@ public abstract class Handler {
* the caller does not have <tt>LoggingPermission("control")</tt>.
*/
public void setFormatter(Formatter newFormatter) throws SecurityException {
checkAccess();
checkPermission();
// Check for a null pointer:
newFormatter.getClass();
formatter = newFormatter;
......@@ -140,7 +140,7 @@ public abstract class Handler {
*/
public void setEncoding(String encoding)
throws SecurityException, java.io.UnsupportedEncodingException {
checkAccess();
checkPermission();
if (encoding != null) {
try {
if(!java.nio.charset.Charset.isSupported(encoding)) {
......@@ -175,7 +175,7 @@ public abstract class Handler {
* the caller does not have <tt>LoggingPermission("control")</tt>.
*/
public void setFilter(Filter newFilter) throws SecurityException {
checkAccess();
checkPermission();
filter = newFilter;
}
......@@ -199,7 +199,7 @@ public abstract class Handler {
* the caller does not have <tt>LoggingPermission("control")</tt>.
*/
public void setErrorManager(ErrorManager em) {
checkAccess();
checkPermission();
if (em == null) {
throw new NullPointerException();
}
......@@ -213,7 +213,7 @@ public abstract class Handler {
* the caller does not have <tt>LoggingPermission("control")</tt>.
*/
public ErrorManager getErrorManager() {
checkAccess();
checkPermission();
return errorManager;
}
......@@ -253,7 +253,7 @@ public abstract class Handler {
if (newLevel == null) {
throw new NullPointerException();
}
checkAccess();
checkPermission();
logLevel = newLevel;
}
......@@ -296,9 +296,9 @@ public abstract class Handler {
// If "sealed" is true, we check that the caller has
// appropriate security privileges to update Handler
// state and if not throw a SecurityException.
void checkAccess() throws SecurityException {
void checkPermission() throws SecurityException {
if (sealed) {
manager.checkAccess();
manager.checkPermission();
}
}
}
......@@ -311,10 +311,17 @@ public class LogManager {
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
* @exception NullPointerException if the PropertyChangeListener is null.
* @deprecated The dependency on {@code PropertyChangeListener} creates a
* significant impediment to future modularization of the Java
* platform. This method will be removed in a future release.
* The global {@code LogManager} can detect changes to the
* logging configuration by overridding the {@link
* #readConfiguration readConfiguration} method.
*/
@Deprecated
public void addPropertyChangeListener(PropertyChangeListener l) throws SecurityException {
PropertyChangeListener listener = Objects.requireNonNull(l);
checkAccess();
checkPermission();
synchronized (listenerMap) {
// increment the registration count if already registered
Integer value = listenerMap.get(listener);
......@@ -336,9 +343,16 @@ public class LogManager {
* @param l event listener (can be null)
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
* @deprecated The dependency on {@code PropertyChangeListener} creates a
* significant impediment to future modularization of the Java
* platform. This method will be removed in a future release.
* The global {@code LogManager} can detect changes to the
* logging configuration by overridding the {@link
* #readConfiguration readConfiguration} method.
*/
@Deprecated
public void removePropertyChangeListener(PropertyChangeListener l) throws SecurityException {
checkAccess();
checkPermission();
if (l != null) {
PropertyChangeListener listener = l;
synchronized (listenerMap) {
......@@ -793,7 +807,7 @@ public class LogManager {
* @exception IOException if there are IO problems reading the configuration.
*/
public void readConfiguration() throws IOException, SecurityException {
checkAccess();
checkPermission();
// if a configuration class is specified, load it and use it.
String cname = System.getProperty("java.util.logging.config.class");
......@@ -851,7 +865,7 @@ public class LogManager {
*/
public void reset() throws SecurityException {
checkAccess();
checkPermission();
synchronized (this) {
props = new Properties();
// Since we are doing a reset we no longer want to initialize
......@@ -936,7 +950,7 @@ public class LogManager {
* @exception IOException if there are problems reading from the stream.
*/
public void readConfiguration(InputStream ins) throws IOException, SecurityException {
checkAccess();
checkPermission();
reset();
// Load the properties
......@@ -1113,8 +1127,13 @@ public class LogManager {
loadLoggerHandlers(rootLogger, null, "handlers");
}
private final Permission controlPermission = new LoggingPermission("control", null);
private Permission ourPermission = new LoggingPermission("control", null);
void checkPermission() {
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(controlPermission);
}
/**
* Check that the current context is trusted to modify the logging
......@@ -1127,11 +1146,7 @@ public class LogManager {
* the caller does not have LoggingPermission("control").
*/
public void checkAccess() throws SecurityException {
SecurityManager sm = System.getSecurityManager();
if (sm == null) {
return;
}
sm.checkPermission(ourPermission);
checkPermission();
}
// Nested class to represent a node in our tree of named loggers.
......
......@@ -276,13 +276,13 @@ public class Logger {
this.manager = manager;
}
private void checkAccess() throws SecurityException {
private void checkPermission() throws SecurityException {
if (!anonymous) {
if (manager == null) {
// Complete initialization of the global Logger.
manager = LogManager.getLogManager();
}
manager.checkAccess();
manager.checkPermission();
}
}
......@@ -482,7 +482,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void setFilter(Filter newFilter) throws SecurityException {
checkAccess();
checkPermission();
filter = newFilter;
}
......@@ -1168,7 +1168,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void setLevel(Level newLevel) throws SecurityException {
checkAccess();
checkPermission();
synchronized (treeLock) {
levelObject = newLevel;
updateEffectiveLevel();
......@@ -1223,7 +1223,7 @@ public class Logger {
public void addHandler(Handler handler) throws SecurityException {
// Check for null handler
handler.getClass();
checkAccess();
checkPermission();
handlers.add(handler);
}
......@@ -1237,7 +1237,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void removeHandler(Handler handler) throws SecurityException {
checkAccess();
checkPermission();
if (handler == null) {
return;
}
......@@ -1265,7 +1265,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void setUseParentHandlers(boolean useParentHandlers) {
checkAccess();
checkPermission();
this.useParentHandlers = useParentHandlers;
}
......@@ -1420,7 +1420,7 @@ public class Logger {
if (parent == null) {
throw new NullPointerException();
}
manager.checkAccess();
manager.checkPermission();
doSetParent(parent);
}
......
......@@ -238,7 +238,7 @@ public class MemoryHandler extends Handler {
throw new NullPointerException();
}
LogManager manager = LogManager.getLogManager();
checkAccess();
checkPermission();
pushLevel = newLevel;
}
......
......@@ -249,7 +249,7 @@ public class StreamHandler extends Handler {
}
private synchronized void flushAndClose() throws SecurityException {
checkAccess();
checkPermission();
if (writer != null) {
try {
if (!doneHeader) {
......
......@@ -1245,13 +1245,12 @@ public class DescriptorSupport
return s.substring(1, s.length() - 1);
}
final String className = s.substring(1, slash);
final Constructor<?> constr;
try {
ReflectUtil.checkPackageAccess(className);
final ClassLoader contextClassLoader =
Thread.currentThread().getContextClassLoader();
if (contextClassLoader == null) {
ReflectUtil.checkPackageAccess(className);
}
final Class<?> c =
Class.forName(className, false, contextClassLoader);
constr = c.getConstructor(new Class<?>[] {String.class});
......
/*
* Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
......@@ -25,54 +25,40 @@
package javax.management.remote.rmi;
import static com.sun.jmx.mbeanserver.Util.cast;
import com.sun.jmx.remote.internal.ServerCommunicatorAdmin;
import com.sun.jmx.remote.internal.ServerNotifForwarder;
import com.sun.jmx.remote.security.JMXSubjectDomainCombiner;
import com.sun.jmx.remote.security.SubjectDelegator;
import com.sun.jmx.remote.util.ClassLoaderWithRepository;
import com.sun.jmx.remote.util.ClassLogger;
import com.sun.jmx.remote.util.EnvHelp;
import com.sun.jmx.remote.util.OrderClassLoaders;
import java.io.IOException;
import java.rmi.MarshalledObject;
import java.rmi.UnmarshalException;
import java.rmi.server.Unreferenced;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.Permissions;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.ProtectionDomain;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.IntrospectionException;
import javax.management.InvalidAttributeValueException;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.NotCompliantMBeanException;
import javax.management.NotificationFilter;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.QueryExp;
import javax.management.ReflectionException;
import javax.management.RuntimeOperationsException;
import javax.management.*;
import javax.management.remote.JMXServerErrorException;
import javax.management.remote.NotificationResult;
import javax.management.remote.TargetedNotification;
import javax.security.auth.Subject;
import static com.sun.jmx.mbeanserver.Util.cast;
import com.sun.jmx.remote.internal.ServerCommunicatorAdmin;
import com.sun.jmx.remote.internal.ServerNotifForwarder;
import com.sun.jmx.remote.security.JMXSubjectDomainCombiner;
import com.sun.jmx.remote.security.SubjectDelegator;
import com.sun.jmx.remote.util.ClassLoaderWithRepository;
import com.sun.jmx.remote.util.ClassLogger;
import com.sun.jmx.remote.util.EnvHelp;
import com.sun.jmx.remote.util.OrderClassLoaders;
/**
* <p>Implementation of the {@link RMIConnection} interface. User
* code will not usually reference this class.</p>
......@@ -143,6 +129,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
this.mbeanServer = rmiServer.getMBeanServer();
final ClassLoader dcl = defaultClassLoader;
this.classLoaderWithRepository =
AccessController.doPrivileged(
new PrivilegedAction<ClassLoaderWithRepository>() {
......@@ -151,13 +138,40 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
mbeanServer.getClassLoaderRepository(),
dcl);
}
},
withPermissions( new MBeanPermission("*", "getClassLoaderRepository"),
new RuntimePermission("createClassLoader"))
);
this.defaultContextClassLoader =
AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
dcl);
}
});
serverCommunicatorAdmin = new
RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));
this.env = env;
}
private static AccessControlContext withPermissions(Permission ... perms){
Permissions col = new Permissions();
for (Permission thePerm : perms ) {
col.add(thePerm);
}
final ProtectionDomain pd = new ProtectionDomain(null, col);
return new AccessControlContext( new ProtectionDomain[] { pd });
}
private synchronized ServerNotifForwarder getServerNotifFwd() {
// Lazily created when first use. Mainly when
// addNotificationListener is first called.
......@@ -507,7 +521,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
"connectionId=" + connectionId
+" unwrapping query with defaultClassLoader.");
queryValue = unwrap(query, defaultClassLoader, QueryExp.class);
queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class);
try {
final Object params[] = new Object[] { name, queryValue };
......@@ -542,7 +556,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
"connectionId=" + connectionId
+" unwrapping query with defaultClassLoader.");
queryValue = unwrap(query, defaultClassLoader, QueryExp.class);
queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class);
try {
final Object params[] = new Object[] { name, queryValue };
......@@ -1330,7 +1344,9 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
public ClassLoader run() throws InstanceNotFoundException {
return mbeanServer.getClassLoader(name);
}
});
},
withPermissions(new MBeanPermission("*", "getClassLoader"))
);
} catch (PrivilegedActionException pe) {
throw (InstanceNotFoundException) extractException(pe);
}
......@@ -1345,7 +1361,9 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
public Object run() throws InstanceNotFoundException {
return mbeanServer.getClassLoaderFor(name);
}
});
},
withPermissions(new MBeanPermission("*", "getClassLoaderFor"))
);
} catch (PrivilegedActionException pe) {
throw (InstanceNotFoundException) extractException(pe);
}
......@@ -1572,7 +1590,8 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
ClassLoader orderCL = AccessController.doPrivileged(
new PrivilegedExceptionAction<ClassLoader>() {
public ClassLoader run() throws Exception {
return new OrderClassLoaders(cl1, cl2);
return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
new OrderClassLoaders(cl1, cl2));
}
}
);
......@@ -1664,6 +1683,8 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
private final ClassLoader defaultClassLoader;
private final ClassLoader defaultContextClassLoader;
private final ClassLoaderWithRepository classLoaderWithRepository;
private boolean terminated = false;
......@@ -1746,4 +1767,43 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
private static final ClassLogger logger =
new ClassLogger("javax.management.remote.rmi", "RMIConnectionImpl");
private static final class CombinedClassLoader extends ClassLoader {
private final static class ClassLoaderWrapper extends ClassLoader {
ClassLoaderWrapper(ClassLoader cl) {
super(cl);
}
@Override
protected Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException {
return super.loadClass(name, resolve);
}
};
final ClassLoaderWrapper defaultCL;
private CombinedClassLoader(ClassLoader parent, ClassLoader defaultCL) {
super(parent);
this.defaultCL = new ClassLoaderWrapper(defaultCL);
}
@Override
protected Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException {
try {
super.loadClass(name, resolve);
} catch(Exception e) {
for(Throwable t = e; t != null; t = t.getCause()) {
if(t instanceof SecurityException) {
throw t==e?(SecurityException)t:new SecurityException(t.getMessage(), e);
}
}
}
final Class<?> cl = defaultCL.loadClass(name, resolve);
return cl;
}
}
}
......@@ -277,9 +277,9 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
// Check for secure RMIServer stub if the corresponding
// client-side environment property is set to "true".
//
boolean checkStub = EnvHelp.computeBooleanFromString(
usemap,
"jmx.remote.x.check.stub",false);
String stringBoolean = (String) usemap.get("jmx.remote.x.check.stub");
boolean checkStub = EnvHelp.computeBooleanFromString(stringBoolean);
if (checkStub) checkStub(stub, rmiServerImplStubClass);
// Connect IIOP Stub if needed.
......
......@@ -412,9 +412,8 @@ public class RMIConnectorServer extends JMXConnectorServer {
if (tracing)
logger.trace("start", "Using external directory: " + jndiUrl);
final boolean rebind = EnvHelp.computeBooleanFromString(
attributes,
JNDI_REBIND_ATTRIBUTE,false);
String stringBoolean = (String) attributes.get(JNDI_REBIND_ATTRIBUTE);
final boolean rebind = EnvHelp.computeBooleanFromString( stringBoolean );
if (tracing)
logger.trace("start", JNDI_REBIND_ATTRIBUTE + "=" + rebind);
......
......@@ -28,8 +28,7 @@ package javax.management.timer;
import static com.sun.jmx.defaults.JmxProperties.TIMER_LOGGER;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
......@@ -128,8 +127,8 @@ public class Timer extends NotificationBroadcasterSupport
* Table containing all the timer notifications of this timer,
* with the associated date, period and number of occurrences.
*/
private Map<Integer,Object[]> timerTable =
new Hashtable<Integer,Object[]>();
final private Map<Integer,Object[]> timerTable =
new HashMap<>();
/**
* Past notifications sending on/off flag value.
......@@ -163,7 +162,7 @@ public class Timer extends NotificationBroadcasterSupport
* The notification counter ID.
* Used to keep the max key value inserted into the timer table.
*/
private int counterID = 0;
volatile private int counterID = 0;
private java.util.Timer timer;
......@@ -776,7 +775,7 @@ public class Timer extends NotificationBroadcasterSupport
*
* @return The number of timer notifications.
*/
public int getNbNotifications() {
public synchronized int getNbNotifications() {
return timerTable.size();
}
......@@ -824,7 +823,7 @@ public class Timer extends NotificationBroadcasterSupport
* @return The timer notification type or null if the identifier is not mapped to any
* timer notification registered for this timer MBean.
*/
public String getNotificationType(Integer id) {
public synchronized String getNotificationType(Integer id) {
Object[] obj = timerTable.get(id);
if (obj != null) {
......@@ -841,7 +840,7 @@ public class Timer extends NotificationBroadcasterSupport
* @return The timer notification detailed message or null if the identifier is not mapped to any
* timer notification registered for this timer MBean.
*/
public String getNotificationMessage(Integer id) {
public synchronized String getNotificationMessage(Integer id) {
Object[] obj = timerTable.get(id);
if (obj != null) {
......@@ -862,7 +861,7 @@ public class Timer extends NotificationBroadcasterSupport
//public Serializable getNotificationUserData(Integer id) {
// end of NPCTE fix for bugId 4464388
public Object getNotificationUserData(Integer id) {
public synchronized Object getNotificationUserData(Integer id) {
Object[] obj = timerTable.get(id);
if (obj != null) {
return ( ((TimerNotification)obj[TIMER_NOTIF_INDEX]).getUserData() );
......@@ -878,7 +877,7 @@ public class Timer extends NotificationBroadcasterSupport
* @return A copy of the date or null if the identifier is not mapped to any
* timer notification registered for this timer MBean.
*/
public Date getDate(Integer id) {
public synchronized Date getDate(Integer id) {
Object[] obj = timerTable.get(id);
if (obj != null) {
......@@ -896,7 +895,7 @@ public class Timer extends NotificationBroadcasterSupport
* @return A copy of the period or null if the identifier is not mapped to any
* timer notification registered for this timer MBean.
*/
public Long getPeriod(Integer id) {
public synchronized Long getPeriod(Integer id) {
Object[] obj = timerTable.get(id);
if (obj != null) {
......@@ -913,7 +912,7 @@ public class Timer extends NotificationBroadcasterSupport
* @return A copy of the remaining number of occurrences or null if the identifier is not mapped to any
* timer notification registered for this timer MBean.
*/
public Long getNbOccurences(Integer id) {
public synchronized Long getNbOccurences(Integer id) {
Object[] obj = timerTable.get(id);
if (obj != null) {
......@@ -931,7 +930,7 @@ public class Timer extends NotificationBroadcasterSupport
* @return A copy of the flag indicating whether a periodic notification is
* executed at <i>fixed-delay</i> or at <i>fixed-rate</i>.
*/
public Boolean getFixedRate(Integer id) {
public synchronized Boolean getFixedRate(Integer id) {
Object[] obj = timerTable.get(id);
if (obj != null) {
......@@ -982,7 +981,7 @@ public class Timer extends NotificationBroadcasterSupport
*
* @return <CODE>true</CODE> if the list of timer notifications is empty, <CODE>false</CODE> otherwise.
*/
public boolean isEmpty() {
public synchronized boolean isEmpty() {
return (timerTable.isEmpty());
}
......@@ -1184,11 +1183,13 @@ public class Timer extends NotificationBroadcasterSupport
//
TimerAlarmClock alarmClock = (TimerAlarmClock)notification.getSource();
for (Object[] obj : timerTable.values()) {
if (obj[ALARM_CLOCK_INDEX] == alarmClock) {
timerNotification = (TimerNotification)obj[TIMER_NOTIF_INDEX];
timerDate = (Date)obj[TIMER_DATE_INDEX];
break;
synchronized(Timer.this) {
for (Object[] obj : timerTable.values()) {
if (obj[ALARM_CLOCK_INDEX] == alarmClock) {
timerNotification = (TimerNotification)obj[TIMER_NOTIF_INDEX];
timerDate = (Date)obj[TIMER_DATE_INDEX];
break;
}
}
}
......
......@@ -25,6 +25,8 @@
package javax.net.ssl;
import java.util.List;
/**
* Extends the <code>SSLSession</code> interface to support additional
* session attributes.
......@@ -83,4 +85,34 @@ public abstract class ExtendedSSLSession implements SSLSession {
* @see X509ExtendedKeyManager
*/
public abstract String[] getPeerSupportedSignatureAlgorithms();
/**
* Obtains a {@link List} containing all {@link SNIServerName}s
* of the requested Server Name Indication (SNI) extension.
* <P>
* In server mode, unless the return {@link List} is empty,
* the server should use the requested server names to guide its
* selection of an appropriate authentication certificate, and/or
* other aspects of security policy.
* <P>
* In client mode, unless the return {@link List} is empty,
* the client should use the requested server names to guide its
* endpoint identification of the peer's identity, and/or
* other aspects of security policy.
*
* @return a non-null immutable list of {@link SNIServerName}s of the
* requested server name indications. The returned list may be
* empty if no server name indications were requested.
* @throws UnsupportedOperationException if the underlying provider
* does not implement the operation
*
* @see SNIServerName
* @see X509ExtendedTrustManager
* @see X509ExtendedKeyManager
*
* @since 1.8
*/
public List<SNIServerName> getRequestedServerNames() {
throw new UnsupportedOperationException();
}
}
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
......@@ -186,8 +186,7 @@ public class HandshakeCompletedEvent extends EventObject
// if the provider does not support it, fallback to peer certs.
// return the X500Principal of the end-entity cert.
Certificate[] certs = getPeerCertificates();
principal = (X500Principal)
((X509Certificate)certs[0]).getSubjectX500Principal();
principal = ((X509Certificate)certs[0]).getSubjectX500Principal();
}
return principal;
}
......@@ -216,7 +215,7 @@ public class HandshakeCompletedEvent extends EventObject
// return the X500Principal of the end-entity cert.
Certificate[] certs = getLocalCertificates();
if (certs != null) {
principal = (X500Principal)
principal =
((X509Certificate)certs[0]).getSubjectX500Principal();
}
}
......
/*
* Copyright (c) 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. 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 javax.net.ssl;
import java.net.IDN;
import java.nio.ByteBuffer;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharacterCodingException;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Pattern;
/**
* Instances of this class represent a server name of type
* {@link StandardConstants#SNI_HOST_NAME host_name} in a Server Name
* Indication (SNI) extension.
* <P>
* As described in section 3, "Server Name Indication", of
* <A HREF="http://www.ietf.org/rfc/rfc6066.txt">TLS Extensions (RFC 6066)</A>,
* "HostName" contains the fully qualified DNS hostname of the server, as
* understood by the client. The encoded server name value of a hostname is
* represented as a byte string using ASCII encoding without a trailing dot.
* This allows the support of Internationalized Domain Names (IDN) through
* the use of A-labels (the ASCII-Compatible Encoding (ACE) form of a valid
* string of Internationalized Domain Names for Applications (IDNA)) defined
* in <A HREF="http://www.ietf.org/rfc/rfc5890.txt">RFC 5890</A>.
* <P>
* Note that {@code SNIHostName} objects are immutable.
*
* @see SNIServerName
* @see StandardConstants#SNI_HOST_NAME
*
* @since 1.8
*/
public final class SNIHostName extends SNIServerName {
// the decoded string value of the server name
private final String hostname;
/**
* Creates an {@code SNIHostName} using the specified hostname.
* <P>
* Note that per <A HREF="http://www.ietf.org/rfc/rfc6066.txt">RFC 6066</A>,
* the encoded server name value of a hostname is
* {@link StandardCharsets#US_ASCII}-compliant. In this method,
* {@code hostname} can be a user-friendly Internationalized Domain Name
* (IDN). {@link IDN#toASCII(String, int)} is used to enforce the
* restrictions on ASCII characters in hostnames (see
* <A HREF="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</A>,
* <A HREF="http://www.ietf.org/rfc/rfc1122.txt">RFC 1122</A>,
* <A HREF="http://www.ietf.org/rfc/rfc1123.txt">RFC 1123</A>) and
* translate the {@code hostname} into ASCII Compatible Encoding (ACE), as:
* <pre>
* IDN.toASCII(hostname, IDN.USE_STD3_ASCII_RULES);
* </pre>
* <P>
* The {@code hostname} argument is illegal if it:
* <ul>
* <li> {@code hostname} is empty,</li>
* <li> {@code hostname} ends with a trailing dot,</li>
* <li> {@code hostname} is not a valid Internationalized
* Domain Name (IDN) compliant with the RFC 3490 specification.</li>
* </ul>
* @param hostname
* the hostname of this server name
*
* @throws NullPointerException if {@code hostname} is {@code null}
* @throws IllegalArgumentException if {@code hostname} is illegal
*/
public SNIHostName(String hostname) {
// IllegalArgumentException will be thrown if {@code hostname} is
// not a valid IDN.
super(StandardConstants.SNI_HOST_NAME,
(hostname = IDN.toASCII(
Objects.requireNonNull(hostname,
"Server name value of host_name cannot be null"),
IDN.USE_STD3_ASCII_RULES))
.getBytes(StandardCharsets.US_ASCII));
this.hostname = hostname;
// check the validity of the string hostname
checkHostName();
}
/**
* Creates an {@code SNIHostName} using the specified encoded value.
* <P>
* This method is normally used to parse the encoded name value in a
* requested SNI extension.
* <P>
* Per <A HREF="http://www.ietf.org/rfc/rfc6066.txt">RFC 6066</A>,
* the encoded name value of a hostname is
* {@link StandardCharsets#US_ASCII}-compliant. However, in the previous
* version of the SNI extension (
* <A HREF="http://www.ietf.org/rfc/rfc4366.txt">RFC 4366</A>),
* the encoded hostname is represented as a byte string using UTF-8
* encoding. For the purpose of version tolerance, this method allows
* that the charset of {@code encoded} argument can be
* {@link StandardCharsets#UTF_8}, as well as
* {@link StandardCharsets#US_ASCII}. {@link IDN#toASCII(String)} is used
* to translate the {@code encoded} argument into ASCII Compatible
* Encoding (ACE) hostname.
* <P>
* It is strongly recommended that this constructor is only used to parse
* the encoded name value in a requested SNI extension. Otherwise, to
* comply with <A HREF="http://www.ietf.org/rfc/rfc6066.txt">RFC 6066</A>,
* please always use {@link StandardCharsets#US_ASCII}-compliant charset
* and enforce the restrictions on ASCII characters in hostnames (see
* <A HREF="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</A>,
* <A HREF="http://www.ietf.org/rfc/rfc1122.txt">RFC 1122</A>,
* <A HREF="http://www.ietf.org/rfc/rfc1123.txt">RFC 1123</A>)
* for {@code encoded} argument, or use {@link SNIHostName(String)} instead.
* <P>
* The {@code encoded} argument is illegal if it:
* <ul>
* <li> {@code encoded} is empty,</li>
* <li> {@code encoded} ends with a trailing dot,</li>
* <li> {@code encoded} is not encoded in
* {@link StandardCharsets#US_ASCII} or
* {@link StandardCharsets#UTF_8}-compliant charset,</li>
* <li> {@code encoded} is not a valid Internationalized
* Domain Name (IDN) compliant with the RFC 3490 specification.</li>
* </ul>
*
* <P>
* Note that the {@code encoded} byte array is cloned
* to protect against subsequent modification.
*
* @param encoded
* the encoded hostname of this server name
*
* @throws NullPointerException if {@code encoded} is {@code null}
* @throws IllegalArgumentException if {@code encoded} is illegal
*/
public SNIHostName(byte[] encoded) {
// NullPointerException will be thrown if {@code encoded} is null
super(StandardConstants.SNI_HOST_NAME, encoded);
// Compliance: RFC 4366 requires that the hostname is represented
// as a byte string using UTF_8 encoding [UTF8]
try {
// Please don't use {@link String} constructors because they
// do not report coding errors.
CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder()
.onMalformedInput(CodingErrorAction.REPORT)
.onUnmappableCharacter(CodingErrorAction.REPORT);
this.hostname = IDN.toASCII(
decoder.decode(ByteBuffer.wrap(encoded)).toString());
} catch (RuntimeException | CharacterCodingException e) {
throw new IllegalArgumentException(
"The encoded server name value is invalid", e);
}
// check the validity of the string hostname
checkHostName();
}
/**
* Returns the {@link StandardCharsets#US_ASCII}-compliant hostname of
* this {@code SNIHostName} object.
* <P>
* Note that, per
* <A HREF="http://www.ietf.org/rfc/rfc6066.txt">RFC 6066</A>, the
* returned hostname may be an internationalized domain name that
* contains A-labels. See
* <A HREF="http://www.ietf.org/rfc/rfc5890.txt">RFC 5890</A>
* for more information about the detailed A-label specification.
*
* @return the {@link StandardCharsets#US_ASCII}-compliant hostname
* of this {@code SNIHostName} object
*/
public String getAsciiName() {
return hostname;
}
/**
* Compares this server name to the specified object.
* <P>
* Per <A HREF="http://www.ietf.org/rfc/rfc6066.txt">RFC 6066</A>, DNS
* hostnames are case-insensitive. Two server hostnames are equal if,
* and only if, they have the same name type, and the hostnames are
* equal in a case-independent comparison.
*
* @param other
* the other server name object to compare with.
* @return true if, and only if, the {@code other} is considered
* equal to this instance
*/
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other instanceof SNIHostName) {
return hostname.equalsIgnoreCase(((SNIHostName)other).hostname);
}
return false;
}
/**
* Returns a hash code value for this {@code SNIHostName}.
* <P>
* The hash code value is generated using the case-insensitive hostname
* of this {@code SNIHostName}.
*
* @return a hash code value for this {@code SNIHostName}.
*/
@Override
public int hashCode() {
int result = 17; // 17/31: prime number to decrease collisions
result = 31 * result + hostname.toUpperCase(Locale.ENGLISH).hashCode();
return result;
}
/**
* Returns a string representation of the object, including the DNS
* hostname in this {@code SNIHostName} object.
* <P>
* The exact details of the representation are unspecified and subject
* to change, but the following may be regarded as typical:
* <pre>
* "type=host_name (0), value={@literal <hostname>}"
* </pre>
* The "{@literal <hostname>}" is an ASCII representation of the hostname,
* which may contains A-labels. For example, a returned value of an pseudo
* hostname may look like:
* <pre>
* "type=host_name (0), value=www.example.com"
* </pre>
* or
* <pre>
* "type=host_name (0), value=xn--fsqu00a.xn--0zwm56d"
* </pre>
* <P>
* Please NOTE that the exact details of the representation are unspecified
* and subject to change.
*
* @return a string representation of the object.
*/
@Override
public String toString() {
return "type=host_name (0), value=" + hostname;
}
/**
* Creates an {@link SNIMatcher} object for {@code SNIHostName}s.
* <P>
* This method can be used by a server to verify the acceptable
* {@code SNIHostName}s. For example,
* <pre>
* SNIMatcher matcher =
* SNIHostName.createSNIMatcher("www\\.example\\.com");
* </pre>
* will accept the hostname "www.example.com".
* <pre>
* SNIMatcher matcher =
* SNIHostName.createSNIMatcher("www\\.example\\.(com|org)");
* </pre>
* will accept hostnames "www.example.com" and "www.example.org".
*
* @param regex
* the <a href="{@docRoot}/java/util/regex/Pattern.html#sum">
* regular expression pattern</a>
* representing the hostname(s) to match
* @throws NullPointerException if {@code regex} is
* {@code null}
* @throws PatternSyntaxException if the regular expression's syntax
* is invalid
*/
public static SNIMatcher createSNIMatcher(String regex) {
if (regex == null) {
throw new NullPointerException(
"The regular expression cannot be null");
}
return new SNIHostNameMatcher(regex);
}
// check the validity of the string hostname
private void checkHostName() {
if (hostname.isEmpty()) {
throw new IllegalArgumentException(
"Server name value of host_name cannot be empty");
}
if (hostname.endsWith(".")) {
throw new IllegalArgumentException(
"Server name value of host_name cannot have the trailing dot");
}
}
private final static class SNIHostNameMatcher extends SNIMatcher {
// the compiled representation of a regular expression.
private final Pattern pattern;
/**
* Creates an SNIHostNameMatcher object.
*
* @param regex
* the <a href="{@docRoot}/java/util/regex/Pattern.html#sum">
* regular expression pattern</a>
* representing the hostname(s) to match
* @throws NullPointerException if {@code regex} is
* {@code null}
* @throws PatternSyntaxException if the regular expression's syntax
* is invalid
*/
SNIHostNameMatcher(String regex) {
super(StandardConstants.SNI_HOST_NAME);
pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
}
/**
* Attempts to match the given {@link SNIServerName}.
*
* @param serverName
* the {@link SNIServerName} instance on which this matcher
* performs match operations
*
* @return {@code true} if, and only if, the matcher matches the
* given {@code serverName}
*
* @throws NullPointerException if {@code serverName} is {@code null}
* @throws IllegalArgumentException if {@code serverName} is
* not of {@code StandardConstants#SNI_HOST_NAME} type
*
* @see SNIServerName
*/
@Override
public boolean matches(SNIServerName serverName) {
if (serverName == null) {
throw new NullPointerException(
"The SNIServerName argument cannot be null");
}
SNIHostName hostname;
if (!(serverName instanceof SNIHostName)) {
if (serverName.getType() != StandardConstants.SNI_HOST_NAME) {
throw new IllegalArgumentException(
"The server name type is not host_name");
}
try {
hostname = new SNIHostName(serverName.getEncoded());
} catch (NullPointerException | IllegalArgumentException e) {
return false;
}
} else {
hostname = (SNIHostName)serverName;
}
// Let's first try the ascii name matching
String asciiName = hostname.getAsciiName();
if (pattern.matcher(asciiName).matches()) {
return true;
}
// May be an internationalized domain name, check the Unicode
// representations.
return pattern.matcher(IDN.toUnicode(asciiName)).matches();
}
}
}
/*
* Copyright (c) 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. 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 javax.net.ssl;
/**
* Instances of this class represent a matcher that performs match
* operations on an {@link SNIServerName} instance.
* <P>
* Servers can use Server Name Indication (SNI) information to decide if
* specific {@link SSLSocket} or {@link SSLEngine} instances should accept
* a connection. For example, when multiple "virtual" or "name-based"
* servers are hosted on a single underlying network address, the server
* application can use SNI information to determine whether this server is
* the exact server that the client wants to access. Instances of this
* class can be used by a server to verify the acceptable server names of
* a particular type, such as host names.
* <P>
* {@code SNIMatcher} objects are immutable. Subclasses should not provide
* methods that can change the state of an instance once it has been created.
*
* @see SNIServerName
* @see SNIHostName
* @see SSLParameters#getSNIMatchers()
* @see SSLParameters#setSNIMatchers(Collection<SNIMatcher>)
*
* @since 1.8
*/
public abstract class SNIMatcher {
// the type of the server name that this matcher performs on
private final int type;
/**
* Creates an {@code SNIMatcher} using the specified server name type.
*
* @param type
* the type of the server name that this matcher performs on
*
* @throws IllegalArgumentException if {@code type} is not in the range
* of 0 to 255, inclusive.
*/
protected SNIMatcher(int type) {
if (type < 0) {
throw new IllegalArgumentException(
"Server name type cannot be less than zero");
} else if (type > 255) {
throw new IllegalArgumentException(
"Server name type cannot be greater than 255");
}
this.type = type;
}
/**
* Returns the server name type of this {@code SNIMatcher} object.
*
* @return the server name type of this {@code SNIMatcher} object.
*
* @see SNIServerName
*/
public final int getType() {
return type;
}
/**
* Attempts to match the given {@link SNIServerName}.
*
* @param serverName
* the {@link SNIServerName} instance on which this matcher
* performs match operations
*
* @return {@code true} if, and only if, the matcher matches the
* given {@code serverName}
*
* @throws NullPointerException if {@code serverName} is {@code null}
* @throws IllegalArgumentException if {@code serverName} is
* not of the given server name type of this matcher
*
* @see SNIServerName
*/
public abstract boolean matches(SNIServerName serverName);
}
/*
* Copyright (c) 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. 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 javax.net.ssl;
import java.util.Arrays;
/**
* Instances of this class represent a server name in a Server Name
* Indication (SNI) extension.
* <P>
* The SNI extension is a feature that extends the SSL/TLS protocols to
* indicate what server name the client is attempting to connect to during
* handshaking. See section 3, "Server Name Indication", of <A
* HREF="http://www.ietf.org/rfc/rfc6066.txt">TLS Extensions (RFC 6066)</A>.
* <P>
* {@code SNIServerName} objects are immutable. Subclasses should not provide
* methods that can change the state of an instance once it has been created.
*
* @see SSLParameters#getServerNames()
* @see SSLParameters#setServerNames(List<SNIServerName>)
*
* @since 1.8
*/
public abstract class SNIServerName {
// the type of the server name
private final int type;
// the encoded value of the server name
private final byte[] encoded;
// the hex digitals
private static final char[] HEXES = "0123456789ABCDEF".toCharArray();
/**
* Creates an {@code SNIServerName} using the specified name type and
* encoded value.
* <P>
* Note that the {@code encoded} byte array is cloned to protect against
* subsequent modification.
*
* @param type
* the type of the server name
* @param encoded
* the encoded value of the server name
*
* @throws IllegalArgumentException if {@code type} is not in the range
* of 0 to 255, inclusive.
* @throws NullPointerException if {@code encoded} is null
*/
protected SNIServerName(int type, byte[] encoded) {
if (type < 0) {
throw new IllegalArgumentException(
"Server name type cannot be less than zero");
} else if (type > 255) {
throw new IllegalArgumentException(
"Server name type cannot be greater than 255");
}
this.type = type;
if (encoded == null) {
throw new NullPointerException(
"Server name encoded value cannot be null");
}
this.encoded = encoded.clone();
}
/**
* Returns the name type of this server name.
*
* @return the name type of this server name
*/
public final int getType() {
return type;
}
/**
* Returns a copy of the encoded server name value of this server name.
*
* @return a copy of the encoded server name value of this server name
*/
public final byte[] getEncoded() {
return encoded.clone();
}
/**
* Indicates whether some other object is "equal to" this server name.
*
* @return true if, and only if, {@code other} is of the same class
* of this object, and has the same name type and
* encoded value as this server name.
*/
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (this.getClass() != other.getClass()) {
return false;
}
SNIServerName that = (SNIServerName)other;
return (this.type == that.type) &&
Arrays.equals(this.encoded, that.encoded);
}
/**
* Returns a hash code value for this server name.
* <P>
* The hash code value is generated using the name type and encoded
* value of this server name.
*
* @return a hash code value for this server name.
*/
@Override
public int hashCode() {
int result = 17; // 17/31: prime number to decrease collisions
result = 31 * result + type;
result = 31 * result + Arrays.hashCode(encoded);
return result;
}
/**
* Returns a string representation of this server name, including the server
* name type and the encoded server name value in this
* {@code SNIServerName} object.
* <P>
* The exact details of the representation are unspecified and subject
* to change, but the following may be regarded as typical:
* <pre>
* "type={@literal <name type>}, value={@literal <name value>}"
* </pre>
* <P>
* In this class, the format of "{@literal <name type>}" is
* "[LITERAL] (INTEGER)", where the optional "LITERAL" is the literal
* name, and INTEGER is the integer value of the name type. The format
* of "{@literal <name value>}" is "XX:...:XX", where "XX" is the
* hexadecimal digit representation of a byte value. For example, a
* returned value of an pseudo server name may look like:
* <pre>
* "type=(31), value=77:77:77:2E:65:78:61:6D:70:6C:65:2E:63:6E"
* </pre>
* or
* <pre>
* "type=host_name (0), value=77:77:77:2E:65:78:61:6D:70:6C:65:2E:63:6E"
* </pre>
*
* <P>
* Please NOTE that the exact details of the representation are unspecified
* and subject to change, and subclasses may override the method with
* their own formats.
*
* @return a string representation of this server name
*/
@Override
public String toString() {
if (type == StandardConstants.SNI_HOST_NAME) {
return "type=host_name (0), value=" + toHexString(encoded);
} else {
return "type=(" + type + "), value=" + toHexString(encoded);
}
}
// convert byte array to hex string
private static String toHexString(byte[] bytes) {
if (bytes.length == 0) {
return "(empty)";
}
StringBuilder sb = new StringBuilder(bytes.length * 3 - 1);
boolean isInitial = true;
for (byte b : bytes) {
if (isInitial) {
isInitial = false;
} else {
sb.append(':');
}
int k = b & 0xFF;
sb.append(HEXES[k >>> 4]);
sb.append(HEXES[k & 0xF]);
}
return sb.toString();
}
}
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -1214,15 +1214,19 @@ public abstract class SSLEngine {
*
* <p>This means:
* <ul>
* <li>if <code>params.getCipherSuites()</code> is non-null,
* <code>setEnabledCipherSuites()</code> is called with that value
* <li>if <code>params.getProtocols()</code> is non-null,
* <code>setEnabledProtocols()</code> is called with that value
* <li>if <code>params.getNeedClientAuth()</code> or
* <code>params.getWantClientAuth()</code> return <code>true</code>,
* <code>setNeedClientAuth(true)</code> and
* <code>setWantClientAuth(true)</code> are called, respectively;
* otherwise <code>setWantClientAuth(false)</code> is called.
* <li>If {@code params.getCipherSuites()} is non-null,
* {@code setEnabledCipherSuites()} is called with that value.</li>
* <li>If {@code params.getProtocols()} is non-null,
* {@code setEnabledProtocols()} is called with that value.</li>
* <li>If {@code params.getNeedClientAuth()} or
* {@code params.getWantClientAuth()} return {@code true},
* {@code setNeedClientAuth(true)} and
* {@code setWantClientAuth(true)} are called, respectively;
* otherwise {@code setWantClientAuth(false)} is called.</li>
* <li>If {@code params.getServerNames()} is non-null, the engine will
* configure its server names with that value.</li>
* <li>If {@code params.getSNIMatchers()} is non-null, the engine will
* configure its SNI matchers with that value.</li>
* </ul>
*
* @param params the parameters
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册