diff --git a/.hgtags b/.hgtags index 77659b823f66c631b1e0e1b5f99083563049ae74..6c271f6efae8321a613b9cee5bf9e2298fe5aa7b 100644 --- a/.hgtags +++ b/.hgtags @@ -109,3 +109,5 @@ bdc069d3f9101f89ec3f81c2950ee2d68fa846d3 jdk7-b130 6bbc7a4734952ae7604578f270e1566639fa8752 jdk7-b132 5e5f68a01d12a4432172f384d5201f3a05254493 jdk7-b133 554adcfb615e63e62af530b1c10fcf7813a75b26 jdk7-b134 +d8ced728159fbb2caa8b6adb477fd8efdbbdf179 jdk7-b135 +aa13e7702cd9d8aca9aa38f1227f966990866944 jdk7-b136 diff --git a/make/common/Defs-windows.gmk b/make/common/Defs-windows.gmk index 87bc793596dcd6b3877cbcdc4ab9d117be3eae4e..f5000e4465ff74f0402d77d8fedbec391ca008bf 100644 --- a/make/common/Defs-windows.gmk +++ b/make/common/Defs-windows.gmk @@ -68,40 +68,10 @@ PLATFORM_INCLUDE = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME) # The following DLL's are considered MS runtime libraries and should # not to be REBASEd, see deploy/make/common/Release.gmk. # msvcr*.dll: Microsoft runtimes -ifeq ($(ARCH_DATA_MODEL), 32) - ifeq ($(COMPILER_VERSION), VS2003) - MSVCRNN_DLL = msvcr71.dll - MSVCPNN_DLL = msvcp71.dll - MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL) - endif - ifeq ($(COMPILER_VERSION), VS2005) - MSVCRNN_DLL = msvcr80.dll - MSVCPNN_DLL = msvcp80.dll - MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL) - endif - ifeq ($(COMPILER_VERSION), VS2008) - MSVCRNN_DLL = msvcr90.dll - MSVCPNN_DLL = msvcp90.dll - MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL) - endif - ifeq ($(COMPILER_VERSION), VS2010) - MSVCRNN_DLL = msvcr100.dll - MSVCPNN_DLL = msvcp100.dll - MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL) - endif -endif - -ifeq ($(ARCH_DATA_MODEL), 64) - ifeq ($(COMPILER_VERSION), VS2008) - MSVCRNN_DLL = msvcr90.dll - MSVCPNN_DLL = msvcp90.dll - MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL) - endif - ifeq ($(COMPILER_VERSION), VS2010) - MSVCRNN_DLL = msvcr100.dll - MSVCPNN_DLL = msvcp100.dll - MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL) - endif +ifeq ($(COMPILER_VERSION), VS2010) + MSVCRNN_DLL = msvcr100.dll + MSVCPNN_DLL = msvcp100.dll + MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL) endif EXTRA_LFLAGS += /LIBPATH:$(DXSDK_LIB_PATH) @@ -124,109 +94,31 @@ ifndef FASTDEBUG_OPTIMIZATION_LEVEL endif ifeq ($(CC_VERSION),msvc) - # Visual Studio .NET 2003 or VS2003 compiler option definitions: + # Visual Studio compiler option definitions: # -O1 Favors reduced size over speed (-Og -Os -Oy -Ob2 -Gs -GF -Gy) # -O2 Favors speed over reduced size (-Og -Oi -Ot -Oy -Ob2 -Gs -GF -Gy) - # -Ox Full optimization (use -O2) (-Og -Oi -Ot -Oy -Ob2) - # (Removed in Visual Studio 2005 or VS2005) # -Ob2 More aggressive inlining # -Og Global optimizations # -Oi Replace some functions with intrinsic or special forms - # -Op Improve floating point calculations (disables some optimizations) - # (Replaced with -fp:precise in VS2005, /Op is default now) + # -fp:precise (should be the default) + # Improve floating point calculations (disables some optimizations) # -Os Favor small code # -Ot Favor faster code # -Oy Frame pointer omission - # -GB Optimize for pentium (old VC6 option?) - # -G6 VS2003 version of -GB? + # -G6 Used to be -GB? # -GF Pool strings in read-only memory # -Gf Pool strings in read-write memory (the default) # -Gs Controls stack probess - # -GS Adds buffer overflow checks on stacks - # (Default in VS2005) - # -GX Enables exception handling - # (Replaced with /EHsc in VS2005) + # -GS Adds buffer overflow checks on stacks (the default) + # -EHsc Enables exception handling # -Gy Function level linking only # - # NOTE: With VC6, -Ox included -Gs. - # NOTE: With VC6, -Ox, -O1, and -O2 used -Ob1, not -Ob2. - # NOTE: With VC6, -O1 and -O2 used -Gf, not -GF. - # CC_OPT/NONE = -Od CC_OPT/LOWER = -O2 CC_OPT/HIGHER = -O3 CC_OPT/HIGHEST = -O3 - ifeq ($(COMPILER_VERSION), VC6) - # VC6 (6.2) msvc compiler (the way Tiger and early Mustang were built) - # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) - AUTOMATIC_PCH_OPTION = - GX_OPTION = -GX - GZ_OPTION = -GZ - ifeq ($(ARCH_DATA_MODEL), 32) - CC_OPT/HIGHEST = -Ox -Gy -Os -GB - CC_OPT/HIGHER = -Ox -Gy -Os -GB - CC_OPT/LOWER = -Ox -Gy -Os -GB - else - CC_OPT/HIGHEST = -Ox -Gy -Op - CC_OPT/HIGHER = -Ox -Gy -Op - CC_OPT/LOWER = -Ox -Gy -Op - endif - endif - - ifeq ($(COMPILER_VERSION), VS2003) - # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) - AUTOMATIC_PCH_OPTION = -YX - # Also known as VC7 compiler - GX_OPTION = -GX - GZ_OPTION = -GZ - ifeq ($(ARCH_DATA_MODEL), 32) - # Lowered opt level to try and reduce footprint, dll size especially. - # Was: CC_OPT/HIGHEST = -O2 -G6 - # Was: CC_OPT/HIGHER = -O2 - CC_OPT/HIGHEST = -O2 - CC_OPT/HIGHER = -O1 - CC_OPT/LOWER = -O1 - else - CC_OPT/HIGHEST = -O2 -Op - CC_OPT/HIGHER = -O2 -Op - CC_OPT/LOWER = -O1 -Op - endif - endif - - ifeq ($(COMPILER_VERSION), VS2005) - # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) - AUTOMATIC_PCH_OPTION = - # VS2005 compiler, only with Platform SDK right now? - GX_OPTION = -EHsc - GZ_OPTION = -RTC1 - ifeq ($(ARCH_DATA_MODEL), 32) - CC_OPT/HIGHEST = -O2 - CC_OPT/HIGHER = -O1 - CC_OPT/LOWER = -O1 - else - CC_OPT/HIGHEST = -O2 - CC_OPT/HIGHER = -O1 - CC_OPT/LOWER = -O1 - endif - endif - ifeq ($(COMPILER_VERSION), VS2008) - # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) - AUTOMATIC_PCH_OPTION = - GX_OPTION = -EHsc - GZ_OPTION = -RTC1 - ifeq ($(ARCH_DATA_MODEL), 32) - CC_OPT/HIGHEST = -O2 - CC_OPT/HIGHER = -O1 - CC_OPT/LOWER = -O1 - else - CC_OPT/HIGHEST = -O2 - CC_OPT/HIGHER = -O1 - CC_OPT/LOWER = -O1 - endif - endif - ifeq ($(COMPILER_VERSION), VS2010) # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) AUTOMATIC_PCH_OPTION = @@ -256,7 +148,7 @@ CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL)) # Select the runtime support library carefully, need to be consistent # -# VS2003 compiler option definitions: +# Visual Studio Runtime compiler option definitions: # -MD Use dynamic multi-threaded runtime library # -MDd Use debug version (don't use, doesn't mix with -MD DLL's) # -MT Use static multi-threaded runtime library (-ML is going away) @@ -265,12 +157,9 @@ CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL)) # # NOTE: We also will use /D _STATIC_CPPLIB so we don't need msvcpnn.dll # -# If MS_RUNTIME_STATIC is requested, use -MT only with VS2003. -ifeq ($(MS_RUNTIME_STATIC),true) - ifeq ($(COMPILER_VERSION), VS2003) - MS_RUNTIME_OPTION=-MT - endif -else +# If MS_RUNTIME_STATIC is requested we may have a problem, it is no longer +# supported by VS2010 +ifneq ($(MS_RUNTIME_STATIC),true) MS_RUNTIME_OPTION=-MD endif # The _DEBUG macro option (changes things like malloc to use debug version) @@ -302,7 +191,7 @@ endif MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION) ifeq ($(CC_VERSION),msvc) - # VS2003 compiler option definitions: + # Visual Studio compiler option definitions: # -Zi Cause *.pdb file to be created, full debug information # -Z7 Full debug inside the .obj, no .pdb # -Zd Basic debug, no local variables? In the .obj @@ -317,31 +206,10 @@ ifeq ($(CC_VERSION),msvc) CFLAGS_OPT = $(CC_OPT) CFLAGS_DBG = -Od $(MS_RUNTIME_DEBUG_OPTION) - # REMIND: I don't see where CFLAGS_VS2005 is used. I suspect its - # pulled in as a combined "CFLAGS_$(COMPILER_VERSION)" string - # but the lack of this isn't causing any apparent build problems - # with VS 2010 but it could be causing compiler warnings. - # For now, I will add it for all cases : CFLAGS_VS2010 += -Zc:wchar_t- - # - # Starting from VS2005 the wchar_t is handled as a built-in C/C++ data type - # by default. However, we expect the wchar_t to be a typedef to the - # unsigned short data type. The -Zc:wchar_t- option restores the old - # behavior (as seen in VS2003) to avoid massive code modifications. - # When/if our code will be "C/C++ Standard"-compliant (at least in the area - # of handling the wchar_t type), the option won't be necessary. - ifeq ($(ARCH_DATA_MODEL), 32) - CFLAGS_VS2005 += -Zc:wchar_t- - else - # The 64bit Platform SDK we use (April 2005) doesn't like this option - ifneq ($(CC_VER), 14.00.40310.41) - CFLAGS_VS2005 += -Zc:wchar_t- - endif - endif # All builds get the same runtime setting CFLAGS_COMMON += $(MS_RUNTIME_OPTION) $(CFLAGS_$(COMPILER_VERSION)) - LDEBUG = /debug @@ -350,21 +218,9 @@ ifeq ($(CC_VERSION),msvc) LDEBUG += /pdb:NONE endif - # The new Platform SDK and VS2005 has /GS as a default and requires - # bufferoverflowU.lib on the link command line, otherwise - # we get missing __security_check_cookie externals at link time. - BUFFEROVERFLOWLIB = bufferoverflowU.lib - # Always add bufferoverflowU.lib to VS2005 link commands (pack uses LDDFLAGS) - LFLAGS_VS2005 = $(BUFFEROVERFLOWLIB) - - # VS2008 has bufferoverflow baked in: - LFLAGS_VS2008 = - # VS2010, always need safe exception handlers, not needed on 64bit ifeq ($(ARCH_DATA_MODEL), 32) - LFLAGS_VS2010 = -SAFESEH - else - LFLAGS_VS2010 = + LFLAGS_VS2010 += -SAFESEH endif # LFLAGS are the flags given to $(LINK) and used to build the actual DLL file diff --git a/make/common/Defs.gmk b/make/common/Defs.gmk index 3c1ff2c0270d1b0a121760032ac303d8c34cbbd9..1e12d4119427be5928109efb269add282f2fe233 100644 --- a/make/common/Defs.gmk +++ b/make/common/Defs.gmk @@ -524,6 +524,10 @@ else COPYRIGHT_YEAR := $(shell $(DATE) '+%Y') endif +ifndef OPENJDK +include $(JDK_TOPDIR)/make/closed/common/Defs.gmk +endif + # Install of imported file (JDK_IMPORT_PATH, or some other external location) define install-importonly-file @$(ECHO) "ASSEMBLY_IMPORT: $@" diff --git a/make/common/Release.gmk b/make/common/Release.gmk index d528fc5c7a95414f23a5f0d72c96d7a9061a15f7..17297d573b04613a6f6c585864f7d8a00f50e952 100644 --- a/make/common/Release.gmk +++ b/make/common/Release.gmk @@ -54,9 +54,6 @@ EXCLUDE_PROPWARN_PKGS = com.sun.java.swing.plaf.windows \ com.sun.java.swing.plaf.motif \ com.sun.java.swing.plaf.gtk -# This is a stopgap until 6839872 is fixed. -EXCLUDE_PROPWARN_PKGS += sun.dyn - # # Include the exported private packages in ct.sym. # This is an interim solution until the ct.sym is replaced @@ -86,14 +83,7 @@ ifdef OPENJDK IMAGE_DOCLIST_JDK = LICENSE ASSEMBLY_EXCEPTION THIRD_PARTY_README IMAGE_DOCLIST_JRE = LICENSE ASSEMBLY_EXCEPTION THIRD_PARTY_README else - # Where to find these files - ifeq ($(J4B), true) - SHARE_JDK_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jdkfb - SHARE_JRE_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jrefb - else - SHARE_JDK_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jdk - SHARE_JRE_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jre - endif + # make/closed/common/Defs.gmk for closed location of SHARE_JDK_DOC_SRC IMAGE_DOCLIST_JDK = COPYRIGHT README.html THIRDPARTYLICENSEREADME.txt IMAGE_DOCLIST_JRE = COPYRIGHT Welcome.html THIRDPARTYLICENSEREADME.txt @@ -932,11 +922,6 @@ initial-image-jdk:: initial-image-jdk-setup \ ifeq ($(COMPILER_VERSION), VS2010) $(CP) $(BINDIR)/msvc*100.$(LIBRARY_SUFFIX) $(JDK_IMAGE_DIR)/bin endif - ifeq ($(ARCH_DATA_MODEL), 32) - ifeq ($(COMPILER_VERSION), VS2003) - $(CP) $(BINDIR)/msvc*71.$(LIBRARY_SUFFIX) $(JDK_IMAGE_DIR)/bin - endif - endif else # PLATFORM @# @# bin/ diff --git a/make/common/shared/Compiler-msvc.gmk b/make/common/shared/Compiler-msvc.gmk index 8be9f79f822b2e0a69f53bf2c60b61013f5e661a..ff00095c565f8bd9d25511d12c3909f450630ba7 100644 --- a/make/common/shared/Compiler-msvc.gmk +++ b/make/common/shared/Compiler-msvc.gmk @@ -47,82 +47,8 @@ ifeq ($(PLATFORM), windows) # Compiler version and type (Always get word after "Version") CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(SED) 's/.*\(Version.*\)/\1/' | $(NAWK) '{print $$2}') - # The MSDEVTOOLS_PATH is for older compilers, place for rc, mt, etc. - _OTHER_TOOLS_PATH = $(MSDEVTOOLS_PATH) - - # SDK-64 and MSVC6 put REBASE.EXE in a different places - go figure... - ifeq ($(ARCH_DATA_MODEL), 32) - LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}') - CC_MAJORVER :=$(call MajorVersion,$(CC_VER)) - ifeq ($(CC_MAJORVER), 13) - # This should be: CC_VER=13.10.3077 LINK_VER=7.10.3077 - COMPILER_NAME=Visual Studio .NET 2003 Professional C++ - COMPILER_VERSION=VS2003 - RC = $(_OTHER_TOOLS_PATH)rc - REBASE = $(COMPILER_PATH)../../Common7/Tools/Bin/rebase - MTL = $(COMPILER_PATH)../../Common7/Tools/Bin/midl - endif - ifeq ($(CC_MAJORVER), 14) - COMPILER_NAME=Visual Studio 8 - COMPILER_VERSION=VS2005 - RC = $(_OTHER_TOOLS_PATH)rc - REBASE = $(COMPILER_PATH)../../Common8/Tools/Bin/rebase - MTL = $(COMPILER_PATH)../../Common8/Tools/Bin/midl - MT = $(_OTHER_TOOLS_PATH)/mt - endif - ifeq ($(CC_MAJORVER), 15) - COMPILER_NAME=Visual Studio 9 - COMPILER_VERSION=VS2008 - RC = $(_OTHER_TOOLS_PATH)rc - #rebase and midl moved out of Visual Studio into the SDK: - REBASE = $(_OTHER_TOOLS_PATH)/rebase - MTL = $(_OTHER_TOOLS_PATH)/midl.exe - MT = $(_OTHER_TOOLS_PATH)mt - endif - else - # else ARCH_DATA_MODEL is 64 - LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}') - CC_MAJORVER :=$(call MajorVersion,$(CC_VER)) - CC_MINORVER :=$(call MinorVersion,$(CC_VER)) - CC_MICROVER :=$(call MicroVersion,$(CC_VER)) - ifeq ($(CC_MAJORVER), 13) - ifeq ($(ARCH), ia64) - # This should be: CC_VER=13.00.9337.7 LINK_VER=7.00.9337.7 - COMPILER_NAME=Microsoft Platform SDK - November 2001 Edition - COMPILER_VERSION=VS2003 - RC = $(_OTHER_TOOLS_PATH)rc - endif - endif - ifeq ($(CC_MAJORVER), 14) - ifeq ($(ARCH), amd64) - #rebase and midl moved out of Visual Studio into the SDK: - RC = $(_OTHER_TOOLS_PATH)/rc - REBASE = $(_OTHER_TOOLS_PATH)/rebase - MTL = $(_OTHER_TOOLS_PATH)/midl.exe - ifeq ($(CC_MICROVER), 30701) - # This should be: CC_VER=14.00.30701 LINK_VER=8.00.30701 - # WARNING: it says 14, but it is such an early build it doesn't - # have all the VS2005 compiler option changes, so treat - # this like a VS2003 compiler. - COMPILER_NAME=Microsoft Platform SDK - February 2003 Edition - COMPILER_VERSION=VS2003 - else - # This should be: CC_VER=14.00.40310.41 LINK_VER=8.00.40310.39 - COMPILER_NAME=Microsoft Platform SDK - April 2005 Edition (3790.1830) - COMPILER_VERSION=VS2005 - endif - else - REBASE = $(COMPILER_PATH)../rebase - endif - endif - ifeq ($(CC_MAJORVER), 15) - COMPILER_NAME=Microsoft Windows SDK with Visual Studio 9 (6001.18000.367) - COMPILER_VERSION=VS2008 - RC = $(MSSDK61)/Bin/X64/rc.exe - MT = $(MSSDK61)/Bin/X64/mt.exe - MTL = $(MSSDK61)/Bin/X64/midl.exe - endif - endif + LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}') + CC_MAJORVER :=$(call MajorVersion,$(CC_VER)) # The VS2010 compiler is the same one used on both 32bit and 64bit ifeq ($(CC_MAJORVER), 16) diff --git a/make/common/shared/Defs-versions.gmk b/make/common/shared/Defs-versions.gmk index 9521e66c9965177e117f9d98430a2bb5f99b615f..05d81efec0887010523965f0fb8849522f10c507 100644 --- a/make/common/shared/Defs-versions.gmk +++ b/make/common/shared/Defs-versions.gmk @@ -190,25 +190,10 @@ ifeq ($(PLATFORM), windows) REQUIRED_FREE_SPACE = 500000 REQUIRED_DXSDK_VER = 0x0900 ifeq ($(CC_VERSION),msvc) - ifeq ($(ARCH_DATA_MODEL), 32) - REQUIRED_COMPILER_NAME = Visual Studio 10 - REQUIRED_COMPILER_VERSION = VS2010 - REQUIRED_CC_VER = 16.00.30319.01 - REQUIRED_LINK_VER = 10.00.30319.01 - else - ifeq ($(ARCH), ia64) - REQUIRED_COMPILER_NAME = Microsoft Platform SDK - November 2001 Edition - REQUIRED_COMPILER_VERSION = VS2003 - REQUIRED_CC_VER = 13.00.9337.7 - REQUIRED_LINK_VER = 7.00.9337.7 - endif - ifeq ($(ARCH), amd64) - REQUIRED_COMPILER_NAME = Visual Studio 10 - REQUIRED_COMPILER_VERSION = VS2010 - REQUIRED_CC_VER = 16.00.30319.01 - REQUIRED_LINK_VER = 10.00.30319.01 - endif - endif + REQUIRED_COMPILER_NAME = Visual Studio 10 + REQUIRED_COMPILER_VERSION = VS2010 + REQUIRED_CC_VER = 16.00.30319.01 + REQUIRED_LINK_VER = 10.00.30319.01 endif ifeq ($(CC_VERSION),gcc) REQUIRED_CC_VER = 3.4.3 diff --git a/make/common/shared/Defs-windows.gmk b/make/common/shared/Defs-windows.gmk index d928448b48f01bcfbcf2b726be140b5cf5c4ca6e..44df76cb3c2846bd2a8a2f27fa07435a11058faa 100644 --- a/make/common/shared/Defs-windows.gmk +++ b/make/common/shared/Defs-windows.gmk @@ -333,136 +333,26 @@ ifndef VS2010_EXISTS export WINDOWSSDKDIR endif -# Setup for VS2010 is simple, others logic is historic -ifeq ($(VS2010_EXISTS),true) - - # VS2010 Compiler root directory - _msvc_dir :=$(VS100COMNTOOLS)/../../Vc - # SDK root directory - _ms_sdk :=$(WINDOWSSDKDIR) - # Compiler bin directory and redist directory - ifeq ($(ARCH_DATA_MODEL), 32) - _compiler_bin :=$(_msvc_dir)/Bin - _redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC100.CRT) - endif - ifeq ($(ARCH_DATA_MODEL), 64) - _compiler_bin :=$(_msvc_dir)/bin/amd64 - _redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x64/Microsoft.VC100.CRT) - endif - ifeq ($(_redist_sdk),) - _redist_sdk :=$(_system_root)/system32 - endif - -else # Not VS2010 - - # Compilers, SDK, and Visual Studio (MSDEV) [32bit is different from 64bit] - ifeq ($(ARCH_DATA_MODEL), 32) - - # Try looking in MSVCDIR or MSVCDir area first - # (set by vcvars32.bat for VC .NET, not defined in the VC 2008/2010) - ifdef MSVCDIR - xMSVCDIR :="$(subst \,/,$(MSVCDIR))" - _msvc_dir :=$(call FullPath,$(xMSVCDIR)) - else - ifdef MSVCDir - xMSVCDIR :="$(subst \,/,$(MSVCDir))" - _msvc_dir :=$(call FullPath,$(xMSVCDIR)) - endif - endif - # If we still don't have it, look for VSnnCOMNTOOLS (newest first), - # set by installer? - ifeq ($(_msvc_dir),) - ifdef VS90COMNTOOLS # /Common/Tools directory, use ../../Vc - xVS90COMNTOOLS :="$(subst \,/,$(VS90COMNTOOLS))" - _vs90tools :=$(call FullPath,$(xVS90COMNTOOLS)) - endif - ifneq ($(_vs90tools),) - _msvc_dir :=$(_vs90tools)/../../Vc - else - ifdef VS80COMNTOOLS # /Common/Tools directory, use ../../Vc - xVS80COMNTOOLS :="$(subst \,/,$(VS80COMNTOOLS))" - _vs80tools :=$(call FullPath,$(xVS80COMNTOOLS)) - endif - ifneq ($(_vs80tools),) - _msvc_dir :=$(_vs80tools)/../../Vc - else - ifdef VS71COMNTOOLS # /Common/Tools directory, use ../../Vc7 - xVS71COMNTOOLS :="$(subst \,/,$(VS71COMNTOOLS))" - _vs71tools :=$(call FullPath,$(xVS71COMNTOOLS)) - endif - ifneq ($(_vs71tools),) - _msvc_dir :=$(_vs71tools)/../../Vc7 - endif - endif - endif - endif - - ifneq ($(_msvc_dir),) - _compiler_bin :=$(_msvc_dir)/Bin - # Assume PlatformSDK is in VS71 (will be empty if VS90) - _ms_sdk :=$(call FullPath,$(_msvc_dir)/PlatformSDK) - _redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC90.CRT) - ifeq ($(_redist_sdk),) - _redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC80.CRT) - ifeq ($(_redist_sdk),) - _redist_sdk :=$(call FullPath,$(_msvc_dir)/../SDK/v1.1/Bin) - endif - endif - endif - endif - - # The Microsoft Platform SDK installed by itself - ifneq ($(_program_files),) - _PSDK :="$(_program_files)/Microsoft SDKs/Windows/v6.1/" - _psdk :=$(call FullPath,$(xMSSDK61)) - ifeq ($(_psdk),) - xPSDK :="$(_program_files)/Microsoft Platform SDK" - _psdk :=$(call FullPath,$(xPSDK)) - ifeq ($(_psdk),) - xPSDK :="$(_program_files)/Microsoft SDK" - _psdk :=$(call FullPath,$(xMSSDK)) - endif - endif - endif - - # If no SDK found yet, look in other places - ifeq ($(_ms_sdk),) - ifdef MSSDK - xMSSDK :="$(subst \,/,$(MSSDK))" - _ms_sdk :=$(call FullPath,$(xMSSDK)) - else - ifdef MSSdk - xMSSDK :="$(subst \,/,$(MSSdk))" - _ms_sdk :=$(call FullPath,$(xMSSDK)) - else - _ms_sdk :=$(_psdk) - endif - endif - endif - - # Compilers for 64bit may be from the free SDK, or Visual Studio Professional. - ifeq ($(ARCH_DATA_MODEL), 64) - xVS2008 :="$(_program_files32)/Microsoft Visual Studio 9.0/" - VS2008 :=$(call FullPath,$(xVS2008)) - ifneq ($(VS2008),) - _compiler_bin :=$(VS2008)/VC/Bin/$(ARCH) - xMSSDK61 :="$(_program_files)/Microsoft SDKs/Windows/v6.1/" - MSSDK61 :=$(call FullPath,$(xMSSDK61)) - _redist_sdk :=$(VS2008)/VC/redist/x64/Microsoft.VC90.CRT - else - ifneq ($(_ms_sdk),) - ifeq ($(ARCH), ia64) - _compiler_bin :=$(_ms_sdk)/Bin/Win64 - endif - ifeq ($(ARCH), amd64) - _compiler_bin :=$(_ms_sdk)/Bin/Win64/x86/$(ARCH) - _redist_sdk :=$(_ms_sdk)/redist/win64/AMD64 - endif - endif - endif - endif - -endif # VS2010_EXISTS +ifneq ($(VS2010_EXISTS),true) + x:=$(error ERROR: No VS2010 found on system.) +endif + +# VS2010 Compiler root directory +_msvc_dir :=$(VS100COMNTOOLS)/../../Vc +# SDK root directory +_ms_sdk :=$(WINDOWSSDKDIR) +# Compiler bin directory and redist directory +ifeq ($(ARCH_DATA_MODEL), 32) + _compiler_bin :=$(_msvc_dir)/Bin + _redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC100.CRT) +endif +ifeq ($(ARCH_DATA_MODEL), 64) + _compiler_bin :=$(_msvc_dir)/bin/amd64 + _redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x64/Microsoft.VC100.CRT) +endif +ifeq ($(_redist_sdk),) + _redist_sdk :=$(_system_root)/system32 +endif # Location on system where jdk installs might be ifneq ($(_program_files),) @@ -566,20 +456,8 @@ ifndef ALT_BOOTDIR _BOOTDIR3 =$(SLASH_JAVA)/re/jdk/$(PREVIOUS_JDK_VERSION)/archive/fcs/binaries/$(PLATFORM)-$(ARCH) endif -# 32bit always needs the MSVCRNN runtime, 64bit does when using VS2008 -ifeq ($(ARCH_DATA_MODEL), 32) - _NEEDS_MSVCRNN = true -else - ifeq ($(VS2010_EXISTS),true) - _NEEDS_MSVCRNN = true - else - ifneq ($(VS2008),) - _NEEDS_MSVCRNN = true - else - _NEEDS_MSVCRNN = false - endif - endif -endif +# Everybody needs the MSVCRNN runtime starting with VS2010 +_NEEDS_MSVCRNN = true ifeq ($(_NEEDS_MSVCRNN), true) # MSVCRNN_DLL_PATH: location of msvcrnn.dll that will be re-distributed @@ -758,8 +636,6 @@ HOTSPOT_LIB_PATH:=$(call AltCheckValue,HOTSPOT_LIB_PATH) # Special define for checking the binaries -ifeq ($(VS2010_EXISTS),true) - # 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 @@ -841,12 +717,3 @@ define binary_file_verification # binary_file endef endif -else - -# Macro to check it's input file for banned dependencies and verify the -# binary was built properly. Relies on process exit code. -define binary_file_verification # binary_file -endef - -endif - diff --git a/make/common/shared/Sanity.gmk b/make/common/shared/Sanity.gmk index 127c9009811df3fe5897cf84e4110a747492b009..99f64fd3842763e6e5848d8e30e825cf41642905 100644 --- a/make/common/shared/Sanity.gmk +++ b/make/common/shared/Sanity.gmk @@ -996,25 +996,15 @@ endif ###################################################### sane-msdevtools_path: ifeq ($(PLATFORM), windows) - ifneq ($(COMPILER_VERSION), VS2010) - @if [ "$(MSDEVTOOLS_PATH)" != "" -a ! -r "$(MSDEVTOOLS_PATH)" ]; then \ - $(ECHO) "ERROR: You do not have a valid MSDEVTOOLS_PATH setting. \n" \ - " Please check your access to \n" \ - " $(MSDEVTOOLS_PATH) \n" \ - " and/or check your value of ALT_MSDEVTOOLS_PATH. \n" \ - "" >> $(ERROR_FILE) ; \ - fi - else - ifeq ($(wildcard $(RC)),) + ifeq ($(wildcard $(RC)),) @$(ECHO) "ERROR: Cannot find the RC utility from path: $(RC)\n" \ " This is normally obtained from the WINDOWSSDKDIR." \ "" >> $(ERROR_FILE) - endif - ifeq ($(wildcard $(DUMPBIN)),) + endif + ifeq ($(wildcard $(DUMPBIN)),) @$(ECHO) "ERROR: Cannot find the DUMPBIN utility from path: $(DUMPBIN)\n" \ " This is normally obtained from the COMPILER_PATH." \ "" >> $(ERROR_FILE) - endif endif endif @@ -1432,7 +1422,6 @@ endif ###################################################### sane-install-mssdk_path: ifeq ($(PLATFORM), windows) - ifeq ($(COMPILER_VERSION), VS2010) @if [ -z "$(WINDOWSSDKDIR)" ]; then \ $(ECHO) "WARNING: Your WINDOWSSDKDIR setting is empty.\n" \ " It is recommended to set ALT_WINDOWSSDKDIR.\n" \ @@ -1445,7 +1434,6 @@ ifeq ($(PLATFORM), windows) " and/or check your value of ALT_WINDOWSSDKDIR. \n" \ "" >> $(ERROR_FILE) ; \ fi - endif @if [ -z "$(INSTALL_MSSDK)" ]; then \ $(ECHO) "WARNING: Your INSTALL_MSSDK setting is empty.\n" \ " It is recommended to set ALT_INSTALL_MSSDK.\n" \ diff --git a/make/docs/CORE_PKGS.gmk b/make/docs/CORE_PKGS.gmk index 66a03df3978a871b7cd01d577ea05ad6795769fe..84c8986370c3ce15464433ff4d01879091b35f96 100644 --- a/make/docs/CORE_PKGS.gmk +++ b/make/docs/CORE_PKGS.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ EXCLUDE_PKGS = \ # This is a list of regular expressions. So foo.* matches "foo" and "foo.bar". # ACTIVE_JSR_PKGS= \ - java.dyn \ + java.lang.invoke \ java.sql \ javax.activation \ javax.annotation.* \ @@ -97,11 +97,11 @@ CORE_PKGS = \ java.awt.print \ java.beans \ java.beans.beancontext \ - java.dyn \ java.io \ java.lang \ java.lang.annotation \ java.lang.instrument \ + java.lang.invoke \ java.lang.management \ java.lang.ref \ java.lang.reflect \ diff --git a/make/java/Makefile b/make/java/Makefile index f988fe95d07c6ce9d08bbbc92527e554701f37b9..3956cadd2f7a1e36a23a7f22f8a3086d1c1de14c 100644 --- a/make/java/Makefile +++ b/make/java/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ SUBDIRS += security math util text net nio jar SUBDIRS_desktop = awt applet beans SUBDIRS_management = management SUBDIRS_misc = npt java_crw_demo java_hprof_demo \ - logging instrument dyn sql rmi + logging instrument invoke sql rmi ifeq ($(PLATFORM), solaris) diff --git a/make/java/dyn/Makefile b/make/java/invoke/Makefile similarity index 86% rename from make/java/dyn/Makefile rename to make/java/invoke/Makefile index 61ca68800b6c42574934de5645fceffa2d461d5c..93b1f46f5d3542e9702d1ecb9371bdcedefb37ad 100644 --- a/make/java/dyn/Makefile +++ b/make/java/invoke/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -25,18 +25,18 @@ BUILDDIR = ../.. -PACKAGE = java.dyn +PACKAGE = java.lang.invoke PRODUCT = java include $(BUILDDIR)/common/Defs.gmk -AUTO_FILES_JAVA_DIRS = java/dyn sun/dyn +AUTO_FILES_JAVA_DIRS = java/lang/invoke sun/invoke +FILES_java = \ + java/lang/ClassValue.java \ + java/lang/BootstrapMethodError.java # The sources built here use new language syntax to generate # method handle calls. Let's be sure we are using that format. LANGUAGE_VERSION = -source 7 CLASS_VERSION = -target 7 -# Tell the compiler not to accept transitional forms. -OTHER_JAVACFLAGS = -XDallowTransitionalJSR292=no - include $(BUILDDIR)/common/Classes.gmk diff --git a/make/java/text/base/FILES_java.gmk b/make/java/text/base/FILES_java.gmk index 8d721300c27c0d17f1e089697bfbd56f6414af43..34c3491d209c80086182bbd5f894003c3c337a71 100644 --- a/make/java/text/base/FILES_java.gmk +++ b/make/java/text/base/FILES_java.gmk @@ -136,6 +136,7 @@ FILES_java = \ sun/text/resources/CollationData_sl.java \ sun/text/resources/CollationData_sq.java \ sun/text/resources/CollationData_sr.java \ + sun/text/resources/CollationData_sr_Latn.java \ sun/text/resources/CollationData_sv.java \ sun/text/resources/CollationData_tr.java \ sun/text/resources/CollationData_uk.java \ @@ -251,6 +252,10 @@ FILES_java = \ sun/text/resources/FormatData_sr_CS.java \ sun/text/resources/FormatData_sr_ME.java \ sun/text/resources/FormatData_sr_RS.java \ + sun/text/resources/FormatData_sr_Latn.java \ + sun/text/resources/FormatData_sr_Latn_BA.java \ + sun/text/resources/FormatData_sr_Latn_ME.java \ + sun/text/resources/FormatData_sr_Latn_RS.java \ sun/text/resources/FormatData_sv.java \ sun/text/resources/FormatData_sv_SE.java \ sun/text/resources/FormatData_tr.java \ diff --git a/make/java/util/FILES_properties.gmk b/make/java/util/FILES_properties.gmk index 49bfc65ef8c6e6b7abb6b632779c697aed176749..5f3bec5e516f1aeaa36a83cda721264514ba6299 100644 --- a/make/java/util/FILES_properties.gmk +++ b/make/java/util/FILES_properties.gmk @@ -65,6 +65,7 @@ FILES_compiled_properties = \ sun/util/resources/LocaleNames_sl.properties \ sun/util/resources/LocaleNames_sq.properties \ sun/util/resources/LocaleNames_sr.properties \ + sun/util/resources/LocaleNames_sr_Latn.properties \ sun/util/resources/LocaleNames_sv.properties \ sun/util/resources/LocaleNames_tr.properties \ sun/util/resources/LocaleNames_uk.properties \ @@ -111,6 +112,9 @@ FILES_compiled_properties = \ sun/util/resources/CalendarData_sl.properties \ sun/util/resources/CalendarData_sq.properties \ sun/util/resources/CalendarData_sr.properties \ + sun/util/resources/CalendarData_sr_Latn_BA.properties \ + sun/util/resources/CalendarData_sr_Latn_ME.properties \ + sun/util/resources/CalendarData_sr_Latn_RS.properties \ sun/util/resources/CalendarData_sv.properties \ sun/util/resources/CalendarData_tr.properties \ sun/util/resources/CalendarData_uk.properties \ @@ -186,6 +190,7 @@ FILES_compiled_properties = \ sun/util/resources/CurrencyNames_nl_NL.properties \ sun/util/resources/CurrencyNames_no_NO.properties \ sun/util/resources/CurrencyNames_pl_PL.properties \ + sun/util/resources/CurrencyNames_pt.properties \ sun/util/resources/CurrencyNames_pt_BR.properties \ sun/util/resources/CurrencyNames_pt_PT.properties \ sun/util/resources/CurrencyNames_ro_RO.properties \ @@ -196,6 +201,10 @@ FILES_compiled_properties = \ sun/util/resources/CurrencyNames_sr_BA.properties \ sun/util/resources/CurrencyNames_sr_CS.properties \ sun/util/resources/CurrencyNames_sr_ME.properties \ + sun/util/resources/CurrencyNames_sr_RS.properties \ + sun/util/resources/CurrencyNames_sr_Latn_BA.properties \ + sun/util/resources/CurrencyNames_sr_Latn_ME.properties \ + sun/util/resources/CurrencyNames_sr_Latn_RS.properties \ sun/util/resources/CurrencyNames_sv.properties \ sun/util/resources/CurrencyNames_sv_SE.properties \ sun/util/resources/CurrencyNames_tr_TR.properties \ diff --git a/make/mkdemo/jfc/Laffy/Makefile b/make/mkdemo/jfc/Laffy/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..7685f1e1381f27d3819440cceb6056a7ca27e71a --- /dev/null +++ b/make/mkdemo/jfc/Laffy/Makefile @@ -0,0 +1,43 @@ +# +# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Makefile to build the Laffy demo. +# + +BUILDDIR = ../../.. +PRODUCT = demo/jfc +DEMONAME = Laffy +include $(BUILDDIR)/common/Defs.gmk + +DEMO_ROOT = $(CLOSED_SRC)/share/demo/jfc/$(DEMONAME) +DEMO_DESTDIR = $(DEMODIR)/jfc/$(DEMONAME) +DEMO_TOPFILES = ./readme.html ./laffy.png +DEMO_SKIP_SRCZIP = true + +# +# Demo jar building rules. +# +include $(BUILDDIR)/common/Demo.gmk diff --git a/make/mkdemo/jfc/Makefile b/make/mkdemo/jfc/Makefile index decfac45061388c2deee0d5eda7ac230fbee6c46..768e5b8f4a81defb9a74b4d51b32dd70b6c15bc8 100644 --- a/make/mkdemo/jfc/Makefile +++ b/make/mkdemo/jfc/Makefile @@ -43,7 +43,7 @@ SUBDIRS = \ # Some demos aren't currently included in OpenJDK ifndef OPENJDK - SUBDIRS += Java2D SwingSet2 SwingSet3 Stylepad + SUBDIRS += Java2D Laffy SwingSet2 SwingSet3 Stylepad endif include $(BUILDDIR)/common/Subdirs.gmk diff --git a/make/sun/cmm/kcms/Makefile b/make/sun/cmm/kcms/Makefile index b0dd8434ee7256a9bc5fc66a0068ef90740fdc95..abcdd9bb39abfc8f600b6e58ab1e5f26d504f55d 100644 --- a/make/sun/cmm/kcms/Makefile +++ b/make/sun/cmm/kcms/Makefile @@ -71,7 +71,8 @@ $(SERVICEDIR)/%: $(CLOSED_SRC)/share/classes/sun/java2d/cmm/kcms/META-INF/servic # Extra rules # ifeq ($(PLATFORM), linux) -LDLIBS += -lpthread + LDLIBS += -lpthread + OTHER_CFLAGS += -Wno-missing-field-initializers endif clean clobber:: @@ -103,6 +104,5 @@ CPPFLAGS += -I$(CLASSHDRDIR) \ endif # PLATFORM -#CFLAGS += -DJAVACMM -DFUT_CALC_EX -DNO_FUT_GCONST -CFLAGS += -DFUT_CALC_EX -DNO_FUT_GCONST +CFLAGS += -DJAVACMM -DFUT_CALC_EX -DNO_FUT_GCONST diff --git a/make/sun/cmm/lcms/Makefile b/make/sun/cmm/lcms/Makefile index 52b550dda106e564636741e0a72313e851a75354..f2794fc525372d6a97bb428432e60c9b85e60fda 100644 --- a/make/sun/cmm/lcms/Makefile +++ b/make/sun/cmm/lcms/Makefile @@ -81,10 +81,6 @@ vpath %.c $(SHARE_SRC)/native/sun/java2d ifeq ($(PLATFORM), windows) OTHER_CFLAGS += -DCMS_IS_WINDOWS_ -ifeq ($(COMPILER_VERSION), VS2003) -OTHER_CFLAGS += -Dsqrtf=sqrt -endif - OTHER_LDLIBS = $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib OTHER_INCLUDES += -I$(SHARE_SRC)/native/sun/java2d \ -I$(SHARE_SRC)/native/sun/awt/debug diff --git a/make/sun/javazic/tzdata/VERSION b/make/sun/javazic/tzdata/VERSION index b82ee890a30866aa38dd80e72491336ba437a28c..0b57ca90d1001d4a819d8959101154f4bccd0339 100644 --- a/make/sun/javazic/tzdata/VERSION +++ b/make/sun/javazic/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2011b +tzdata2011d diff --git a/make/sun/javazic/tzdata/australasia b/make/sun/javazic/tzdata/australasia index 430a6f146f5db8454c46ed950a1d85defb58112b..61d338f968354ab31fe58c87765620f91ff96939 100644 --- a/make/sun/javazic/tzdata/australasia +++ b/make/sun/javazic/tzdata/australasia @@ -531,11 +531,31 @@ Zone Pacific/Pago_Pago 12:37:12 - LMT 1879 Jul 5 # to 01:00am and First Sunday April 2011 (03/04/11) - adjust clocks # backwards from 1:00am to 12:00am" +# From Raymond Hughes (2011-03-07) +# I believe this will be posted shortly on the website +# +# www.mcil.gov.ws +# +# +# PUBLIC NOTICE ON DAYLIGHT SAVING TIME +# +# Pursuant to the Daylight Saving Act 2009 and Cabinets decision, +# businesses and the general public are hereby advised that daylight +# saving time is on the first Saturday of April 2011 (02/04/11). +# +# The public is therefore advised that when the standard time strikes +# the hour of four oclock (4.00am or 0400 Hours) on the 2nd April 2011, +# then all instruments used to measure standard time are to be +# adjusted/changed to three oclock (3:00am or 0300Hrs). +# +# Margaret Fruean ACTING CHIEF EXECUTIVE OFFICER MINISTRY OF COMMERCE, +# INDUSTRY AND LABOUR 28th February 2011 + Zone Pacific/Apia 12:33:04 - LMT 1879 Jul 5 -11:26:56 - LMT 1911 -11:30 - SAMT 1950 # Samoa Time -11:00 - WST 2010 Sep 26 - -11:00 1:00 WSDT 2011 Apr 3 1:00 + -11:00 1:00 WSDT 2011 Apr 2 4:00 -11:00 - WST # Solomon Is diff --git a/make/sun/javazic/tzdata/etcetera b/make/sun/javazic/tzdata/etcetera index e8b3a60fc90f21c884276ba11d030b9de5830858..609b305493cedfeeb70cbe241e05e2a9edbe7f6a 100644 --- a/make/sun/javazic/tzdata/etcetera +++ b/make/sun/javazic/tzdata/etcetera @@ -58,8 +58,7 @@ Link Etc/GMT Etc/GMT0 # (i.e. west of Greenwich) even though many people would expect it to # mean 4 hours ahead of UTC (i.e. east of Greenwich). # -# In the draft 5 of POSIX 1003.1-200x, the angle bracket notation -# (which is not yet supported by the tz code) allows for +# In the draft 5 of POSIX 1003.1-200x, the angle bracket notation allows for # TZ='+4'; if you want time zone abbreviations conforming to # ISO 8601 you can use TZ='<-0400>+4'. Thus the commonly-expected # offset is kept within the angle bracket (and is used for display) diff --git a/make/sun/javazic/tzdata/europe b/make/sun/javazic/tzdata/europe index 6fc7d22f3c251427bdb81f9c3d5dcb896359d155..5b11dfb5122c8304f9974196e755e757a358391b 100644 --- a/make/sun/javazic/tzdata/europe +++ b/make/sun/javazic/tzdata/europe @@ -2505,25 +2505,18 @@ Zone Europe/Zurich 0:34:08 - LMT 1848 Sep 12 # (on a non-government server though) describing dates between 2002 and 2006: # http://www.alomaliye.com/bkk_2002_3769.htm -# From Sue Williams (2008-08-11): -# I spotted this news article about a potential change in Turkey. -# -# -# http://www.hurriyet.com.tr/english/domestic/9626174.asp?scr=1 +# From Gökdeniz Karadağ (2011-03-10): +# +# According to the articles linked below, Turkey will change into summer +# time zone (GMT+3) on March 28, 2011 at 3:00 a.m. instead of March 27. +# This change is due to a nationwide exam on 27th. +# +# +# http://www.worldbulletin.net/?aType=haber&ArticleID=70872 # - -# From Sue Williams (2008-08-20): -# This article says that around the end of March 2011, Turkey wants to -# adjust the clocks forward by 1/2 hour and stay that way permanently. -# The article indicates that this is a change in timezone offset in addition -# to stopping observance of DST. -# This proposal has not yet been approved. -# -# Read more here... -# -# Turkey to abandon daylight saving time in 2011 -# -# http://www.turkishdailynews.com.tr/article.php?enewsid=112989 +# Turkish: +# +# http://www.hurriyet.com.tr/ekonomi/17230464.asp?gid=373 # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -2591,6 +2584,8 @@ Zone Europe/Istanbul 1:55:52 - LMT 1880 2:00 Turkey EE%sT 1978 Oct 15 3:00 Turkey TR%sT 1985 Apr 20 # Turkey Time 2:00 Turkey EE%sT 2007 + 2:00 EU EE%sT 2011 Mar 27 1:00u + 2:00 - EET 2011 Mar 28 1:00u 2:00 EU EE%sT Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. diff --git a/make/sun/javazic/tzdata/leapseconds b/make/sun/javazic/tzdata/leapseconds index 50426088b7602714391eba1fceec6dfb5e8dfdb7..368366a1a927bdf4803f843938e5e360333c104b 100644 --- a/make/sun/javazic/tzdata/leapseconds +++ b/make/sun/javazic/tzdata/leapseconds @@ -78,13 +78,13 @@ Leap 2008 Dec 31 23:59:60 + S # SERVICE DE LA ROTATION TERRESTRE # OBSERVATOIRE DE PARIS # 61, Av. de l'Observatoire 75014 PARIS (France) -# Tel. : 33 (0) 1 40 51 22 26 +# Tel. : 33 (0) 1 40 51 22 29 # FAX : 33 (0) 1 40 51 22 91 # Internet : services.iers@obspm.fr # -# Paris, 14 July 2010 +# Paris, 2 February 2011 # -# Bulletin C 40 +# Bulletin C 41 # # To authorities responsible # for the measurement and @@ -92,9 +92,9 @@ Leap 2008 Dec 31 23:59:60 + S # # INFORMATION ON UTC - TAI # -# NO positive leap second will be introduced at the end of December 2010. +# NO positive leap second will be introduced at the end of June 2011. # The difference between Coordinated Universal Time UTC and the -# International Atomic Time TAI is : +# International Atomic Time TAI is : # # from 2009 January 1, 0h UTC, until further notice : UTC-TAI = -34 s # @@ -104,6 +104,6 @@ Leap 2008 Dec 31 23:59:60 + S # will be no time step at the next possible date. # # Daniel GAMBIS -# Director -# Earth Orientation Center of IERS +# Head +# Earth Orientation Center of the IERS # Observatoire de Paris, France diff --git a/make/sun/javazic/tzdata/northamerica b/make/sun/javazic/tzdata/northamerica index 281ab4f6748312dfed8840ef86d06d6e2ddf8d28..7111cb7048d19da3ae76ff2dee0946765e717cb6 100644 --- a/make/sun/javazic/tzdata/northamerica +++ b/make/sun/javazic/tzdata/northamerica @@ -448,15 +448,74 @@ Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12:07:02 # were nearby inhabitants in some cases and for our purposes perhaps # it's best to simply use the official transition. # + +# From Steve Ferguson (2011-01-31): +# The author lives in Alaska and many of the references listed are only +# available to Alaskan residents. +# +# +# http://www.alaskahistoricalsociety.org/index.cfm?section=discover%20alaska&page=Glimpses%20of%20the%20Past&viewpost=2&ContentId=98 +# + +# From Arthur David Olson (2011-02-01): +# Here's database-relevant material from the 2001 "Alaska History" article: +# +# On September 20 [1979]...DOT...officials decreed that on April 27, +# 1980, Juneau and other nearby communities would move to Yukon Time. +# Sitka, Petersburg, Wrangell, and Ketchikan, however, would remain on +# Pacific Time. +# +# ...on September 22, 1980, DOT Secretary Neil E. Goldschmidt rescinded the +# Department's September 1979 decision. Juneau and other communities in +# northern Southeast reverted to Pacific Time on October 26. +# +# On October 28 [1983]...the Metlakatla Indian Community Council voted +# unanimously to keep the reservation on Pacific Time. +# +# According to DOT official Joanne Petrie, Indian reservations are not +# bound to follow time zones imposed by neighboring jurisdictions. +# +# (The last is consistent with how the database now handles the Navajo +# Nation.) + +# From Arthur David Olson (2011-02-09): +# I just spoke by phone with a staff member at the Metlakatla Indian +# Community office (using contact information available at +# +# http://www.commerce.state.ak.us/dca/commdb/CIS.cfm?Comm_Boro_name=Metlakatla +# ). +# It's shortly after 1:00 here on the east coast of the United States; +# the staffer said it was shortly after 10:00 there. When I asked whether +# that meant they were on Pacific time, they said no--they were on their +# own time. I asked about daylight saving; they said it wasn't used. I +# did not inquire about practices in the past. + # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Juneau 15:02:19 - LMT 1867 Oct 18 -8:57:41 - LMT 1900 Aug 20 12:00 -8:00 - PST 1942 -8:00 US P%sT 1946 -8:00 - PST 1969 + -8:00 US P%sT 1980 Apr 27 2:00 + -9:00 US Y%sT 1980 Oct 26 2:00 + -8:00 US P%sT 1983 Oct 30 2:00 + -9:00 US Y%sT 1983 Nov 30 + -9:00 US AK%sT +Zone America/Sitka -14:58:47 - LMT 1867 Oct 18 + -9:01:13 - LMT 1900 Aug 20 12:00 + -8:00 - PST 1942 + -8:00 US P%sT 1946 + -8:00 - PST 1969 -8:00 US P%sT 1983 Oct 30 2:00 -9:00 US Y%sT 1983 Nov 30 -9:00 US AK%sT +Zone America/Metlakatla 15:13:42 - LMT 1867 Oct 18 + -8:46:18 - LMT 1900 Aug 20 12:00 + -8:00 - PST 1942 + -8:00 US P%sT 1946 + -8:00 - PST 1969 + -8:00 US P%sT 1983 Oct 30 2:00 + -8:00 US MeST Zone America/Yakutat 14:41:05 - LMT 1867 Oct 18 -9:18:55 - LMT 1900 Aug 20 12:00 -9:00 - YST 1942 @@ -2569,6 +2628,21 @@ Zone America/Costa_Rica -5:36:20 - LMT 1890 # San Jose # the time was announced as "diez cinco"--the same time as here, indicating # that has indeed switched to DST. Assume second Sunday from 2009 forward. +# From Steffen Thorsen (2011-03-08): +# Granma announced that Cuba is going to start DST on 2011-03-20 00:00:00 +# this year. Nothing about the end date known so far (if that has +# changed at all). +# +# Source: +# +# http://granma.co.cu/2011/03/08/nacional/artic01.html +# +# +# Our info: +# +# http://www.timeanddate.com/news/time/cuba-starts-dst-2011.html +# + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Cuba 1928 only - Jun 10 0:00 1:00 D Rule Cuba 1928 only - Oct 10 0:00 0 S @@ -2602,7 +2676,9 @@ Rule Cuba 2000 2004 - Apr Sun>=1 0:00s 1:00 D Rule Cuba 2006 max - Oct lastSun 0:00s 0 S Rule Cuba 2007 only - Mar Sun>=8 0:00s 1:00 D Rule Cuba 2008 only - Mar Sun>=15 0:00s 1:00 D -Rule Cuba 2009 max - Mar Sun>=8 0:00s 1:00 D +Rule Cuba 2009 2010 - Mar Sun>=8 0:00s 1:00 D +Rule Cuba 2011 only - Mar Sun>=15 0:00s 1:00 D +Rule Cuba 2012 max - Mar Sun>=8 0:00s 1:00 D # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Havana -5:29:28 - LMT 1890 diff --git a/make/sun/javazic/tzdata/southamerica b/make/sun/javazic/tzdata/southamerica index ea82c22b12cb91296e5cfed075b1b11d8acebfce..a11df76f6e96a20812e4eb4e3cb1958bb2733d76 100644 --- a/make/sun/javazic/tzdata/southamerica +++ b/make/sun/javazic/tzdata/southamerica @@ -1176,6 +1176,23 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # From Arthur Daivd Olson (2010-03-06): # Angel Chiang's message confirmed by Julio Pacheco; Julio provided a patch. +# From Glenn Eychaner (2011-03-02): [geychaner@mac.com] +# It appears that the Chilean government has decided to postpone the +# change from summer time to winter time again, by three weeks to April +# 2nd: +# +# http://www.emol.com/noticias/nacional/detalle/detallenoticias.asp?idnoticia=467651 +# +# +# This is not yet reflected in the offical "cambio de hora" site, but +# probably will be soon: +# +# http://www.horaoficial.cl/cambio.htm +# + +# From Arthur David Olson (2011-03-02): +# The emol.com article mentions a water shortage as the cause of the +# postponement, which may mean that it's not a permanent change. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Chile 1927 1932 - Sep 1 0:00 1:00 S Rule Chile 1928 1932 - Apr 1 0:00 0 - @@ -1211,8 +1228,8 @@ Rule Chile 2000 2007 - Mar Sun>=9 3:00u 0 - # which is used below in specifying the transition. Rule Chile 2008 only - Mar 30 3:00u 0 - Rule Chile 2009 only - Mar Sun>=9 3:00u 0 - -Rule Chile 2010 only - Apr 4 3:00u 0 - -Rule Chile 2011 max - Mar Sun>=9 3:00u 0 - +Rule Chile 2010 2011 - Apr Sun>=1 3:00u 0 - +Rule Chile 2012 max - Mar Sun>=9 3:00u 0 - # IATA SSIM anomalies: (1992-02) says 1992-03-14; # (1996-09) says 1998-03-08. Ignore these. # Zone NAME GMTOFF RULES FORMAT [UNTIL] diff --git a/make/sun/javazic/tzdata/zone.tab b/make/sun/javazic/tzdata/zone.tab index cddfedae509a15e0f650c03e29f68168a2924873..0b158ec22340539f8d477e0eb38e5e42ee165821 100644 --- a/make/sun/javazic/tzdata/zone.tab +++ b/make/sun/javazic/tzdata/zone.tab @@ -434,9 +434,11 @@ US +332654-1120424 America/Phoenix Mountain Standard Time - Arizona US +340308-1181434 America/Los_Angeles Pacific Time US +611305-1495401 America/Anchorage Alaska Time US +581807-1342511 America/Juneau Alaska Time - Alaska panhandle +US +571035-1351807 America/Sitka Alaska Time - southeast Alaska panhandle US +593249-1394338 America/Yakutat Alaska Time - Alaska panhandle neck US +643004-1652423 America/Nome Alaska Time - west Alaska US +515248-1763929 America/Adak Aleutian Islands +US +550737-1313435 America/Metlakatla Metlakatla Time - Annette Island US +211825-1575130 Pacific/Honolulu Hawaii UY -3453-05611 America/Montevideo UZ +3940+06648 Asia/Samarkand west Uzbekistan diff --git a/make/sun/net/FILES_java.gmk b/make/sun/net/FILES_java.gmk index 576159c4799c835652c0e6b9b71bb47dcd18449c..6c140abc68b8f41e33076fd4921199774265c13f 100644 --- a/make/sun/net/FILES_java.gmk +++ b/make/sun/net/FILES_java.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ FILES_java = \ sun/net/ProgressListener.java \ sun/net/ProgressMeteringPolicy.java \ sun/net/SocksProxy.java \ + sun/net/ResourceManager.java \ sun/net/TelnetInputStream.java \ sun/net/TelnetOutputStream.java \ sun/net/TelnetProtocolException.java \ @@ -100,6 +101,7 @@ FILES_java = \ sun/net/www/protocol/http/NegotiateAuthentication.java \ sun/net/www/protocol/http/Negotiator.java \ sun/net/www/protocol/http/ntlm/NTLMAuthentication.java \ + sun/net/www/protocol/http/ntlm/NTLMAuthenticationCallback.java \ sun/net/www/protocol/http/spnego/NegotiatorImpl.java \ sun/net/www/protocol/http/spnego/NegotiateCallbackHandler.java \ sun/net/www/protocol/http/logging/HttpLogFormatter.java \ diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java index 27fcaac0ac76e878ea7889a80128dc3e6b461414..74713133a7d64a299657b8d114d444244bf81a27 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java @@ -210,6 +210,8 @@ public final class Transform extends SignatureElementProxy { public static void init() { if (!alreadyInitialized) { transformClassHash = new HashMap(10); + // make sure builtin algorithms are all registered first + com.sun.org.apache.xml.internal.security.Init.init(); alreadyInitialized = true; } } @@ -236,12 +238,7 @@ public final class Transform extends SignatureElementProxy { "algorithm.alreadyRegistered", exArgs); } - ClassLoader cl = (ClassLoader) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - return Thread.currentThread().getContextClassLoader(); - } - }); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { transformClassHash.put diff --git a/src/share/classes/java/awt/AWTEvent.java b/src/share/classes/java/awt/AWTEvent.java index 60ab93e1dc6a091ae11b22051e8090fa94c37644..5afd14afa23aae3625b1cec3be77b025103912ab 100644 --- a/src/share/classes/java/awt/AWTEvent.java +++ b/src/share/classes/java/awt/AWTEvent.java @@ -33,6 +33,11 @@ import java.lang.reflect.Field; import sun.awt.AWTAccessor; import sun.util.logging.PlatformLogger; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.io.ObjectInputStream; +import java.io.IOException; + /** * The root event class for all AWT events. * This class and its subclasses supercede the original @@ -97,6 +102,22 @@ public abstract class AWTEvent extends EventObject { */ protected boolean consumed = false; + /* + * The event's AccessControlContext. + */ + private transient volatile AccessControlContext acc = + AccessController.getContext(); + + /* + * Returns the acc this event was constructed with. + */ + final AccessControlContext getAccessControlContext() { + if (acc == null) { + throw new SecurityException("AWTEvent is missing AccessControlContext"); + } + return acc; + } + transient boolean focusManagerIsDispatching = false; transient boolean isPosted; @@ -247,6 +268,10 @@ public abstract class AWTEvent extends EventObject { public boolean isSystemGenerated(AWTEvent ev) { return ev.isSystemGenerated; } + + public AccessControlContext getAccessControlContext(AWTEvent ev) { + return ev.getAccessControlContext(); + } }); } diff --git a/src/share/classes/java/awt/Component.java b/src/share/classes/java/awt/Component.java index d0eda994f1bd3dc2f8d79ad5bf479b6c51c06173..c6ab049457425abc37e99a904803712e9dfc5ce5 100644 --- a/src/share/classes/java/awt/Component.java +++ b/src/share/classes/java/awt/Component.java @@ -59,6 +59,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; +import java.security.AccessControlContext; import javax.accessibility.*; import java.applet.Applet; @@ -471,6 +472,12 @@ public abstract class Component implements ImageObserver, MenuContainer, static final Object LOCK = new AWTTreeLock(); static class AWTTreeLock {} + /* + * The component's AccessControlContext. + */ + private transient volatile AccessControlContext acc = + AccessController.getContext(); + /** * Minimum size. * (This field perhaps should have been transient). @@ -671,6 +678,16 @@ public abstract class Component implements ImageObserver, MenuContainer, return objectLock; } + /* + * Returns the acc this component was constructed with. + */ + final AccessControlContext getAccessControlContext() { + if (acc == null) { + throw new SecurityException("Component is missing AccessControlContext"); + } + return acc; + } + boolean isPacked = false; /** @@ -950,6 +967,10 @@ public abstract class Component implements ImageObserver, MenuContainer, public void processEvent(Component comp, AWTEvent e) { comp.processEvent(e); } + + public AccessControlContext getAccessControlContext(Component comp) { + return comp.getAccessControlContext(); + } }); } @@ -3873,6 +3894,11 @@ public abstract class Component implements ImageObserver, MenuContainer, * supported or met * @exception ClassCastException if the component is not a canvas or * window. + * @exception IllegalStateException if the component has no peer + * @exception IllegalArgumentException if {@code numBuffers} is less than two, + * or if {@code BufferCapabilities.isPageFlipping} is not + * {@code true}. + * @see #createBuffers(int, BufferCapabilities) */ protected FlipBufferStrategy(int numBuffers, BufferCapabilities caps) throws AWTException @@ -8608,6 +8634,8 @@ public abstract class Component implements ImageObserver, MenuContainer, { objectLock = new Object(); + acc = AccessController.getContext(); + s.defaultReadObject(); appContext = AppContext.getAppContext(); diff --git a/src/share/classes/java/awt/EventQueue.java b/src/share/classes/java/awt/EventQueue.java index d4c763b4f3fa911da515cfe1b632dd128b84668c..8aab49f075a16951ff9b63351951eb930dea8768 100644 --- a/src/share/classes/java/awt/EventQueue.java +++ b/src/share/classes/java/awt/EventQueue.java @@ -48,6 +48,12 @@ import sun.awt.AWTAccessor; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; +import java.security.AccessControlContext; +import java.security.ProtectionDomain; + +import sun.misc.SharedSecrets; +import sun.misc.JavaSecurityAccess; + /** * EventQueue is a platform-independent class * that queues events, both from the underlying peer classes @@ -612,6 +618,9 @@ public class EventQueue { return null; } + private static final JavaSecurityAccess javaSecurityAccess = + SharedSecrets.getJavaSecurityAccess(); + /** * Dispatches an event. The manner in which the event is * dispatched depends upon the type of the event and the @@ -650,13 +659,49 @@ public class EventQueue { * @throws NullPointerException if event is null * @since 1.2 */ - protected void dispatchEvent(AWTEvent event) { + protected void dispatchEvent(final AWTEvent event) { + final Object src = event.getSource(); + final PrivilegedAction action = new PrivilegedAction() { + public Void run() { + dispatchEventImpl(event, src); + return null; + } + }; + + final AccessControlContext stack = AccessController.getContext(); + final AccessControlContext srcAcc = getAccessControlContextFrom(src); + final AccessControlContext eventAcc = event.getAccessControlContext(); + if (srcAcc == null) { + javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc); + } else { + javaSecurityAccess.doIntersectionPrivilege( + new PrivilegedAction() { + public Void run() { + javaSecurityAccess.doIntersectionPrivilege(action, eventAcc); + return null; + } + }, stack, srcAcc); + } + } + + private static AccessControlContext getAccessControlContextFrom(Object src) { + return src instanceof Component ? + ((Component)src).getAccessControlContext() : + src instanceof MenuComponent ? + ((MenuComponent)src).getAccessControlContext() : + src instanceof TrayIcon ? + ((TrayIcon)src).getAccessControlContext() : + null; + } + + /** + * Called from dispatchEvent() under a correct AccessControlContext + */ + private void dispatchEventImpl(final AWTEvent event, final Object src) { event.isPosted = true; - Object src = event.getSource(); if (event instanceof ActiveEvent) { // This could become the sole method of dispatching in time. setCurrentEventAndMostRecentTimeImpl(event); - ((ActiveEvent)event).dispatch(); } else if (src instanceof Component) { ((Component)src).dispatchEvent(event); diff --git a/src/share/classes/java/awt/LinearGradientPaint.java b/src/share/classes/java/awt/LinearGradientPaint.java index 8d5d727540bffa9eb5da5a9f6b04f9bda1d267b3..7a60c7d4b6cf6176c082b7cb0b9a2bd2b3a49400 100644 --- a/src/share/classes/java/awt/LinearGradientPaint.java +++ b/src/share/classes/java/awt/LinearGradientPaint.java @@ -57,8 +57,14 @@ import java.beans.ConstructorProperties; * * *

- * The user may also select what action the {@code LinearGradientPaint} - * should take when filling color outside the start and end points. + * The user may also select what action the {@code LinearGradientPaint} object + * takes when it is filling the space outside the start and end points by + * setting {@code CycleMethod} to either {@code REFLECTION} or {@code REPEAT}. + * The distances between any two colors in any of the reflected or repeated + * copies of the gradient are the same as the distance between those same two + * colors between the start and end points. + * Note that some minor variations in distances may occur due to sampling at + * the granularity of a pixel. * If no cycle method is specified, {@code NO_CYCLE} will be chosen by * default, which means the endpoint colors will be used to fill the * remaining area. diff --git a/src/share/classes/java/awt/MenuComponent.java b/src/share/classes/java/awt/MenuComponent.java index 19d57394a23b9e7fef3c1c6eee4993a0a735a100..d1a5a2577b415971797cea06be4cde23e102cdb9 100644 --- a/src/share/classes/java/awt/MenuComponent.java +++ b/src/share/classes/java/awt/MenuComponent.java @@ -33,6 +33,9 @@ import sun.awt.SunToolkit; import sun.awt.AWTAccessor; import javax.accessibility.*; +import java.security.AccessControlContext; +import java.security.AccessController; + /** * The abstract class MenuComponent is the superclass * of all menu-related components. In this respect, the class @@ -99,6 +102,23 @@ public abstract class MenuComponent implements java.io.Serializable { */ boolean newEventsOnly = false; + /* + * The menu's AccessControlContext. + */ + private transient volatile AccessControlContext acc = + AccessController.getContext(); + + /* + * Returns the acc this menu component was constructed with. + */ + final AccessControlContext getAccessControlContext() { + if (acc == null) { + throw new SecurityException( + "MenuComponent is missing AccessControlContext"); + } + return acc; + } + /* * Internal constants for serialization. */ @@ -402,6 +422,9 @@ public abstract class MenuComponent implements java.io.Serializable { throws ClassNotFoundException, IOException, HeadlessException { GraphicsEnvironment.checkHeadless(); + + acc = AccessController.getContext(); + s.defaultReadObject(); appContext = AppContext.getAppContext(); diff --git a/src/share/classes/java/awt/MultipleGradientPaint.java b/src/share/classes/java/awt/MultipleGradientPaint.java index 598f68f6f036862415fb912b581df33b001cab0f..0dfaf5071ae039877050009bfbee66f8b10a9561 100644 --- a/src/share/classes/java/awt/MultipleGradientPaint.java +++ b/src/share/classes/java/awt/MultipleGradientPaint.java @@ -286,6 +286,10 @@ public abstract class MultipleGradientPaint implements Paint { /** * Returns a copy of the transform applied to the gradient. * + *

+ * Note that if no transform is applied to the gradient + * when it is created, the identity transform is used. + * * @return a copy of the transform applied to the gradient */ public final AffineTransform getTransform() { @@ -293,10 +297,12 @@ public abstract class MultipleGradientPaint implements Paint { } /** - * Returns the transparency mode for this Paint object. + * Returns the transparency mode for this {@code Paint} object. * - * @return an integer value representing the transparency mode for - * this Paint object + * @return {@code OPAQUE} if all colors used by this + * {@code Paint} object are opaque, + * {@code TRANSLUCENT} if at least one of the + * colors used by this {@code Paint} object is not opaque. * @see java.awt.Transparency */ public final int getTransparency() { diff --git a/src/share/classes/java/awt/RadialGradientPaint.java b/src/share/classes/java/awt/RadialGradientPaint.java index d87a3253d46e5ee158c6b86b705de57c9a69901c..ee99c32d9deebca7b160003ba977c98a7cc3ffb0 100644 --- a/src/share/classes/java/awt/RadialGradientPaint.java +++ b/src/share/classes/java/awt/RadialGradientPaint.java @@ -71,8 +71,24 @@ import java.beans.ConstructorProperties; * * *

- * The user may also select what action the {@code RadialGradientPaint} - * should take when filling color outside the bounds of the circle's radius. + * The user may also select what action the {@code RadialGradientPaint} object + * takes when it is filling the space outside the circle's radius by + * setting {@code CycleMethod} to either {@code REFLECTION} or {@code REPEAT}. + * The gradient color proportions are equal for any particular line drawn + * from the focus point. The following figure shows that the distance AB + * is equal to the distance BC, and the distance AD is equal to the distance DE. + *

+ * + *
+ * If the gradient and graphics rendering transforms are uniformly scaled and + * the user sets the focus so that it coincides with the center of the circle, + * the gradient color proportions are equal for any line drawn from the center. + * The following figure shows the distances AB, BC, AD, and DE. They are all equal. + *
+ * + *
+ * Note that some minor variations in distances may occur due to sampling at + * the granularity of a pixel. * If no cycle method is specified, {@code NO_CYCLE} will be chosen by * default, which means the the last keyframe color will be used to fill the * remaining area. @@ -604,7 +620,7 @@ public final class RadialGradientPaint extends MultipleGradientPaint { } /** - * Returns a copy of the end point of the gradient axis. + * Returns a copy of the focus point of the radial gradient. * * @return a {@code Point2D} object that is a copy of the focus point */ diff --git a/src/share/classes/java/awt/TrayIcon.java b/src/share/classes/java/awt/TrayIcon.java index 35a98706e7f442d39c1704504ea06c45bd65c87d..13185bf92fd9c25868f921abdcf45b0256e3d7b0 100644 --- a/src/share/classes/java/awt/TrayIcon.java +++ b/src/share/classes/java/awt/TrayIcon.java @@ -40,6 +40,8 @@ import sun.awt.AppContext; import sun.awt.SunToolkit; import sun.awt.HeadlessToolkit; import java.util.EventObject; +import java.security.AccessControlContext; +import java.security.AccessController; /** * A TrayIcon object represents a tray icon that can be @@ -90,6 +92,7 @@ import java.util.EventObject; * @author Anton Tarasov */ public class TrayIcon { + private Image image; private String tooltip; private PopupMenu popup; @@ -103,6 +106,24 @@ public class TrayIcon { transient MouseMotionListener mouseMotionListener; transient ActionListener actionListener; + /* + * The tray icon's AccessControlContext. + * + * Unlike the acc in Component, this field is made final + * because TrayIcon is not serializable. + */ + private final AccessControlContext acc = AccessController.getContext(); + + /* + * Returns the acc this tray icon was constructed with. + */ + final AccessControlContext getAccessControlContext() { + if (acc == null) { + throw new SecurityException("TrayIcon is missing AccessControlContext"); + } + return acc; + } + static { Toolkit.loadLibraries(); if (!GraphicsEnvironment.isHeadless()) { diff --git a/src/share/classes/java/awt/doc-files/RadialGradientPaint-3.png b/src/share/classes/java/awt/doc-files/RadialGradientPaint-3.png new file mode 100644 index 0000000000000000000000000000000000000000..46484fdb766c04b23ba013e96ea703b1f9e4a7c5 Binary files /dev/null and b/src/share/classes/java/awt/doc-files/RadialGradientPaint-3.png differ diff --git a/src/share/classes/java/awt/doc-files/RadialGradientPaint-4.png b/src/share/classes/java/awt/doc-files/RadialGradientPaint-4.png new file mode 100644 index 0000000000000000000000000000000000000000..6ab38c833ce8305fbb118642ba2b1c64188c4dd8 Binary files /dev/null and b/src/share/classes/java/awt/doc-files/RadialGradientPaint-4.png differ diff --git a/src/share/classes/java/awt/image/PackedColorModel.java b/src/share/classes/java/awt/image/PackedColorModel.java index 532f8d2678bb467abc4c1e3e38a0d9bfbc8a9e8f..b2ab7ad9c91657dcce27d797cd196a0fa9a4fcf2 100644 --- a/src/share/classes/java/awt/image/PackedColorModel.java +++ b/src/share/classes/java/awt/image/PackedColorModel.java @@ -343,8 +343,13 @@ public abstract class PackedColorModel extends ColorModel { if (bitMasks.length != maskArray.length) { return false; } + + /* compare 'effective' masks only, i.e. only part of the mask + * which fits the capacity of the transfer type. + */ + int maxMask = (int)((1L << DataBuffer.getDataTypeSize(transferType)) - 1); for (int i=0; i < bitMasks.length; i++) { - if (bitMasks[i] != maskArray[i]) { + if ((maxMask & bitMasks[i]) != (maxMask & maskArray[i])) { return false; } } diff --git a/src/share/classes/java/beans/DefaultPersistenceDelegate.java b/src/share/classes/java/beans/DefaultPersistenceDelegate.java index d5c24edcb644a924971323d363c423ae750e0a58..64570928afb9952f058305a6eebb1dfbd5bca383 100644 --- a/src/share/classes/java/beans/DefaultPersistenceDelegate.java +++ b/src/share/classes/java/beans/DefaultPersistenceDelegate.java @@ -35,7 +35,7 @@ import sun.reflect.misc.*; * is the delegate used by default for classes about * which no information is available. The DefaultPersistenceDelegate * provides, version resilient, public API-based persistence for - * classes that follow the JavaBeans conventions without any class specific + * classes that follow the JavaBeans™ conventions without any class specific * configuration. *

* The key assumptions are that the class has a nullary constructor diff --git a/src/share/classes/java/beans/DesignMode.java b/src/share/classes/java/beans/DesignMode.java index 3080706c5a0f60996b26f8936ae234a0ab64a043..af86266dc3f596b026de617190da49a8e576731c 100644 --- a/src/share/classes/java/beans/DesignMode.java +++ b/src/share/classes/java/beans/DesignMode.java @@ -31,7 +31,7 @@ package java.beans; * of java.beans.beancontext.BeanContext, in order to propagate to its nested hierarchy * of java.beans.beancontext.BeanContextChild instances, the current "designTime" property. *

- * The JavaBeans specification defines the notion of design time as is a + * The JavaBeans™ specification defines the notion of design time as is a * mode in which JavaBeans instances should function during their composition * and customization in a interactive design, composition or construction tool, * as opposed to runtime when the JavaBean is part of an applet, application, diff --git a/src/share/classes/java/beans/IndexedPropertyChangeEvent.java b/src/share/classes/java/beans/IndexedPropertyChangeEvent.java index a255ccabd8bcc8a5f49b360b70aee6bae298ba30..7ec03d8fb75b0786a82e0bcfa482d897330929b0 100644 --- a/src/share/classes/java/beans/IndexedPropertyChangeEvent.java +++ b/src/share/classes/java/beans/IndexedPropertyChangeEvent.java @@ -26,7 +26,7 @@ package java.beans; /** * An "IndexedPropertyChange" event gets delivered whenever a component that - * conforms to the JavaBeans specification (a "bean") changes a bound + * conforms to the JavaBeans™ specification (a "bean") changes a bound * indexed property. This class is an extension of PropertyChangeEvent * but contains the index of the property that has changed. *

diff --git a/src/share/classes/java/beans/Introspector.java b/src/share/classes/java/beans/Introspector.java index 9046da817192b15dda25f75c6ebcc1bd795af70a..5892df6cb299bad2f86ad186928d482231ee5d87 100644 --- a/src/share/classes/java/beans/Introspector.java +++ b/src/share/classes/java/beans/Introspector.java @@ -87,7 +87,7 @@ import sun.reflect.misc.ReflectUtil; *

* For more information about introspection and design patterns, please * consult the - * JavaBeans specification. + * JavaBeans™ specification. */ public class Introspector { @@ -1245,7 +1245,7 @@ public class Introspector { try { type = ClassFinder.findClass(name, type.getClassLoader()); // Each customizer should inherit java.awt.Component and implement java.beans.Customizer - // according to the section 9.3 of JavaBeans specification + // according to the section 9.3 of JavaBeans™ specification if (Component.class.isAssignableFrom(type) && Customizer.class.isAssignableFrom(type)) { return type; } diff --git a/src/share/classes/java/beans/VetoableChangeSupport.java b/src/share/classes/java/beans/VetoableChangeSupport.java index a8573da5fc9c4f2372fe40d709cc15c489cf7821..d26f58a219d8607170bc1f5a25a283669605cd4c 100644 --- a/src/share/classes/java/beans/VetoableChangeSupport.java +++ b/src/share/classes/java/beans/VetoableChangeSupport.java @@ -474,7 +474,7 @@ public class VetoableChangeSupport implements Serializable { /** * @serialField children Hashtable * @serialField source Object - * @serialField propertyChangeSupportSerializedDataVersion int + * @serialField vetoableChangeSupportSerializedDataVersion int */ private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField("children", Hashtable.class), diff --git a/src/share/classes/java/beans/package.html b/src/share/classes/java/beans/package.html index 576e1f763dc9fb070336e2b92f9a65a19df4eb05..b1f0a8cf336303421bc6182f34c92cc721b457dc 100644 --- a/src/share/classes/java/beans/package.html +++ b/src/share/classes/java/beans/package.html @@ -29,7 +29,7 @@ Contains classes related to developing beans -- components -based on the JavaBeansTM architecture. +based on the JavaBeans™ architecture. A few of the classes are used by beans while they run in an application. For example, the event classes are diff --git a/src/share/classes/java/dyn/Linkage.java b/src/share/classes/java/dyn/Linkage.java deleted file mode 100644 index 4ddda0a19902740d362d1a44be290700dfa703d1..0000000000000000000000000000000000000000 --- a/src/share/classes/java/dyn/Linkage.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.dyn; - -import java.dyn.MethodHandles.Lookup; -import java.util.WeakHashMap; -import sun.dyn.Access; -import sun.dyn.MethodHandleImpl; -import sun.dyn.util.VerifyAccess; -import sun.reflect.Reflection; -import static sun.dyn.MemberName.newIllegalArgumentException; - -/** - * CLASS WILL BE REMOVED FOR PFD: - * Static routines for controlling invokedynamic behavior. - * Replaced by non-static APIs. - * @author John Rose, JSR 292 EG - * @deprecated This class will be removed in the Public Final Draft. - */ -public class Linkage { - private static final Access IMPL_TOKEN = Access.getToken(); - - private Linkage() {} // do not instantiate - - /** - * METHOD WILL BE REMOVED FOR PFD: - * Register a bootstrap method to use when linking dynamic call sites within - * a given caller class. - * @deprecated Use @{@link BootstrapMethod} annotations instead. - */ - public static - void registerBootstrapMethod(Class callerClass, MethodHandle bootstrapMethod) { - Class callc = Reflection.getCallerClass(2); - if (callc != null && !VerifyAccess.isSamePackage(callerClass, callc)) - throw new IllegalArgumentException("cannot set bootstrap method on "+callerClass); - MethodHandleImpl.registerBootstrap(IMPL_TOKEN, callerClass, bootstrapMethod); - } - - /** - * METHOD WILL BE REMOVED FOR PFD: - * Simplified version of {@code registerBootstrapMethod} for self-registration, - * to be called from a static initializer. - * @deprecated Use @{@link BootstrapMethod} annotations instead. - */ - public static - void registerBootstrapMethod(Class runtime, String name) { - Class callerClass = Reflection.getCallerClass(2); - registerBootstrapMethodLookup(callerClass, runtime, name); - } - - /** - * METHOD WILL BE REMOVED FOR PFD: - * Simplified version of {@code registerBootstrapMethod} for self-registration, - * @deprecated Use @{@link BootstrapMethod} annotations instead. - */ - public static - void registerBootstrapMethod(String name) { - Class callerClass = Reflection.getCallerClass(2); - registerBootstrapMethodLookup(callerClass, callerClass, name); - } - - private static - void registerBootstrapMethodLookup(Class callerClass, Class runtime, String name) { - Lookup lookup = new Lookup(IMPL_TOKEN, callerClass); - MethodHandle bootstrapMethod; - try { - bootstrapMethod = lookup.findStatic(runtime, name, BOOTSTRAP_METHOD_TYPE); - } catch (ReflectiveOperationException ex) { - throw new IllegalArgumentException("no such bootstrap method in "+runtime+": "+name, ex); - } - MethodHandleImpl.registerBootstrap(IMPL_TOKEN, callerClass, bootstrapMethod); - } - - private static final MethodType BOOTSTRAP_METHOD_TYPE - = MethodType.methodType(CallSite.class, - Class.class, String.class, MethodType.class); - - /** - * METHOD WILL BE REMOVED FOR PFD: - * Invalidate all invokedynamic call sites everywhere. - * @deprecated Use {@linkplain MutableCallSite#setTarget call site target setting}, - * {@link MutableCallSite#syncAll call site update pushing}, - * and {@link SwitchPoint#guardWithTest target switching} instead. - */ - public static - Object invalidateAll() { - throw new UnsupportedOperationException(); - } - - /** - * METHOD WILL BE REMOVED FOR PFD: - * Invalidate all {@code invokedynamic} call sites in the bytecodes - * of any methods of the given class. - * @deprecated Use {@linkplain MutableCallSite#setTarget call site target setting}, - * {@link MutableCallSite#syncAll call site update pushing}, - * and {@link SwitchPoint#guardWithTest target switching} instead. - */ - public static - Object invalidateCallerClass(Class callerClass) { - throw new UnsupportedOperationException(); - } -} diff --git a/src/share/classes/java/dyn/InvokeDynamicBootstrapError.java b/src/share/classes/java/lang/BootstrapMethodError.java similarity index 66% rename from src/share/classes/java/dyn/InvokeDynamicBootstrapError.java rename to src/share/classes/java/lang/BootstrapMethodError.java index 76e795e2f0e8ebaf160f0e6d46b309c4764b76ba..0fee75ad33d141e9c6b130aa0764f600647f1d32 100644 --- a/src/share/classes/java/dyn/InvokeDynamicBootstrapError.java +++ b/src/share/classes/java/lang/BootstrapMethodError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,58 +23,56 @@ * questions. */ -package java.dyn; +package java.lang; /** * Thrown to indicate that an {@code invokedynamic} instruction has - * failed to find its - * {@linkplain BootstrapMethod bootstrap method}, - * or the bootstrap method has - * failed to provide a - * {@linkplain CallSite call site} with a {@linkplain CallSite#getTarget target} - * of the correct {@linkplain MethodHandle#type method type}. + * failed to find its bootstrap method, + * or the bootstrap method has failed to provide a + * {@linkplain java.lang.invoke.CallSite call site} with a {@linkplain java.lang.invoke.CallSite#getTarget target} + * of the correct {@linkplain java.lang.invoke.MethodHandle#type method type}. * * @author John Rose, JSR 292 EG * @since 1.7 */ -public class InvokeDynamicBootstrapError extends LinkageError { +public class BootstrapMethodError extends LinkageError { private static final long serialVersionUID = 292L; /** - * Constructs an {@code InvokeDynamicBootstrapError} with no detail message. + * Constructs an {@code BootstrapMethodError} with no detail message. */ - public InvokeDynamicBootstrapError() { + public BootstrapMethodError() { super(); } /** - * Constructs an {@code InvokeDynamicBootstrapError} with the specified + * Constructs an {@code BootstrapMethodError} with the specified * detail message. * * @param s the detail message. */ - public InvokeDynamicBootstrapError(String s) { + public BootstrapMethodError(String s) { super(s); } /** - * Constructs a {@code InvokeDynamicBootstrapError} with the specified + * Constructs a {@code BootstrapMethodError} with the specified * detail message and cause. * * @param s the detail message. * @param cause the cause, may be {@code null}. */ - public InvokeDynamicBootstrapError(String s, Throwable cause) { + public BootstrapMethodError(String s, Throwable cause) { super(s, cause); } /** - * Constructs a {@code InvokeDynamicBootstrapError} with the specified + * Constructs a {@code BootstrapMethodError} with the specified * cause. * * @param cause the cause, may be {@code null}. */ - public InvokeDynamicBootstrapError(Throwable cause) { + public BootstrapMethodError(Throwable cause) { // cf. Throwable(Throwable cause) constructor. super(cause == null ? null : cause.toString()); initCause(cause); diff --git a/src/share/classes/java/dyn/ClassValue.java b/src/share/classes/java/lang/ClassValue.java similarity index 94% rename from src/share/classes/java/dyn/ClassValue.java rename to src/share/classes/java/lang/ClassValue.java index 597dd951eb691471f770b2c6ea30b2cbfc4925f0..92c49a92ef28e88dea0ba9b06a11aadc57caadd8 100644 --- a/src/share/classes/java/dyn/ClassValue.java +++ b/src/share/classes/java/lang/ClassValue.java @@ -23,12 +23,10 @@ * questions. */ -package java.dyn; +package java.lang; import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; -import java.lang.reflect.UndeclaredThrowableException; /** * Lazily associate a computed value with (potentially) every type. @@ -37,10 +35,11 @@ import java.lang.reflect.UndeclaredThrowableException; * it can use a {@code ClassValue} to cache information needed to * perform the message send quickly, for each class encountered. * @author John Rose, JSR 292 EG + * @since 1.7 */ public abstract class ClassValue { /** - * Compute the given class's derived value for this {@code ClassValue}. + * Computes the given class's derived value for this {@code ClassValue}. *

* This method will be invoked within the first thread that accesses * the value with the {@link #get get} method. @@ -159,13 +158,7 @@ public abstract class ClassValue { } /// Implementation... - - // The hash code for this type is based on the identity of the object, - // and is well-dispersed for power-of-two tables. - /** @deprecated This override, which is implementation-specific, will be removed for PFD. */ - public final int hashCode() { return hashCode; } - private final int hashCode = HASH_CODES.getAndAdd(0x61c88647); - private static final AtomicInteger HASH_CODES = new AtomicInteger(); + // FIXME: Use a data structure here similar that of ThreadLocal (7030453). private static final AtomicInteger STORE_BARRIER = new AtomicInteger(); diff --git a/src/share/classes/sun/dyn/AdapterMethodHandle.java b/src/share/classes/java/lang/invoke/AdapterMethodHandle.java similarity index 89% rename from src/share/classes/sun/dyn/AdapterMethodHandle.java rename to src/share/classes/java/lang/invoke/AdapterMethodHandle.java index 676907c9185093c484009794fff8b9522f917d6c..a47b38f8bb3ec50a791ea014e37896bda8117878 100644 --- a/src/share/classes/sun/dyn/AdapterMethodHandle.java +++ b/src/share/classes/java/lang/invoke/AdapterMethodHandle.java @@ -23,20 +23,19 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import sun.dyn.util.VerifyType; -import sun.dyn.util.Wrapper; -import java.dyn.*; +import sun.invoke.util.VerifyType; +import sun.invoke.util.Wrapper; import java.util.Arrays; -import static sun.dyn.MethodHandleNatives.Constants.*; -import static sun.dyn.MemberName.newIllegalArgumentException; +import static java.lang.invoke.MethodHandleNatives.Constants.*; +import static java.lang.invoke.MethodHandleStatics.*; /** * This method handle performs simple conversion or checking of a single argument. * @author jrose */ -public class AdapterMethodHandle extends BoundMethodHandle { +class AdapterMethodHandle extends BoundMethodHandle { //MethodHandle vmtarget; // next AMH or BMH in chain or final DMH //Object argument; // parameter to the conversion if needed @@ -48,25 +47,21 @@ public class AdapterMethodHandle extends BoundMethodHandle { long conv, Object convArg) { super(newType, convArg, newType.parameterSlotDepth(1+convArgPos(conv))); this.conversion = convCode(conv); - if (MethodHandleNatives.JVM_SUPPORT) { - // JVM might update VM-specific bits of conversion (ignore) - MethodHandleNatives.init(this, target, convArgPos(conv)); - } + // JVM might update VM-specific bits of conversion (ignore) + MethodHandleNatives.init(this, target, convArgPos(conv)); } private AdapterMethodHandle(MethodHandle target, MethodType newType, long conv) { this(target, newType, conv, null); } - private static final Access IMPL_TOKEN = Access.getToken(); - // TO DO: When adapting another MH with a null conversion, clone // the target and change its type, instead of adding another layer. /** Can a JVM-level adapter directly implement the proposed * argument conversions, as if by MethodHandles.convertArguments? */ - public static boolean canPairwiseConvert(MethodType newType, MethodType oldType) { + static boolean canPairwiseConvert(MethodType newType, MethodType oldType) { // same number of args, of course int len = newType.parameterCount(); if (len != oldType.parameterCount()) @@ -92,7 +87,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { /** Can a JVM-level adapter directly implement the proposed * argument conversion, as if by MethodHandles.convertArguments? */ - public static boolean canConvertArgument(Class src, Class dst) { + static boolean canConvertArgument(Class src, Class dst) { // ? Retool this logic to use RETYPE_ONLY, CHECK_CAST, etc., as opcodes, // so we don't need to repeat so much decision making. if (VerifyType.isNullConversion(src, dst)) { @@ -118,16 +113,13 @@ public class AdapterMethodHandle extends BoundMethodHandle { * the JVM supports ricochet adapters). * The argument conversions allowed are casting, unboxing, * integral widening or narrowing, and floating point widening or narrowing. - * @param token access check * @param newType required call type * @param target original method handle * @return an adapter to the original handle with the desired new type, * or the original target if the types are already identical * or null if the adaptation cannot be made */ - public static MethodHandle makePairwiseConvert(Access token, - MethodType newType, MethodHandle target) { - Access.check(token); + static MethodHandle makePairwiseConvert(MethodType newType, MethodHandle target) { MethodType oldType = target.type(); if (newType == oldType) return target; @@ -170,9 +162,9 @@ public class AdapterMethodHandle extends BoundMethodHandle { // It parallels canConvertArgument() above. if (src.isPrimitive()) { if (dst.isPrimitive()) { - adapter = makePrimCast(token, midType, adapter, i, dst); + adapter = makePrimCast(midType, adapter, i, dst); } else { - adapter = makeBoxArgument(token, midType, adapter, i, dst); + adapter = makeBoxArgument(midType, adapter, i, dst); } } else { if (dst.isPrimitive()) { @@ -182,13 +174,13 @@ public class AdapterMethodHandle extends BoundMethodHandle { // conversions supported by reflect.Method.invoke. // Those conversions require a big nest of if/then/else logic, // which we prefer to make a user responsibility. - adapter = makeUnboxArgument(token, midType, adapter, i, dst); + adapter = makeUnboxArgument(midType, adapter, i, dst); } else { // Simple reference conversion. // Note: Do not check for a class hierarchy relation // between src and dst. In all cases a 'null' argument // will pass the cast conversion. - adapter = makeCheckCast(token, midType, adapter, i, dst); + adapter = makeCheckCast(midType, adapter, i, dst); } } assert(adapter != null); @@ -196,7 +188,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { } if (adapter.type() != newType) { // Only trivial conversions remain. - adapter = makeRetypeOnly(IMPL_TOKEN, newType, adapter); + adapter = makeRetypeOnly(newType, adapter); assert(adapter != null); // Actually, that's because there were no non-trivial ones: assert(lastConv == -1); @@ -208,7 +200,6 @@ public class AdapterMethodHandle extends BoundMethodHandle { /** * Create a JVM-level adapter method handle to permute the arguments * of the given method. - * @param token access check * @param newType required call type * @param target original method handle * @param argumentMap for each target argument, position of its source in newType @@ -218,8 +209,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { * @throws IllegalArgumentException if the adaptation cannot be made * directly by a JVM-level adapter, without help from Java code */ - public static MethodHandle makePermutation(Access token, - MethodType newType, MethodHandle target, + static MethodHandle makePermutation(MethodType newType, MethodHandle target, int[] argumentMap) { MethodType oldType = target.type(); boolean nullPermutation = true; @@ -234,7 +224,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { if (argumentMap.length != oldType.parameterCount()) throw newIllegalArgumentException("bad permutation: "+Arrays.toString(argumentMap)); if (nullPermutation) { - MethodHandle res = makePairwiseConvert(token, newType, target); + MethodHandle res = makePairwiseConvert(newType, target); // well, that was easy if (res == null) throw newIllegalArgumentException("cannot convert pairwise: "+newType); @@ -435,7 +425,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { } /** Can a retyping adapter (alone) validly convert the target to newType? */ - public static boolean canRetypeOnly(MethodType newType, MethodType targetType) { + static boolean canRetypeOnly(MethodType newType, MethodType targetType) { return canRetype(newType, targetType, false); } /** Can a retyping adapter (alone) convert the target to newType? @@ -444,7 +434,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { * reference conversions on return. This last feature requires that the * caller be trusted, and perform explicit cast conversions on return values. */ - public static boolean canRetypeRaw(MethodType newType, MethodType targetType) { + static boolean canRetypeRaw(MethodType newType, MethodType targetType) { return canRetype(newType, targetType, true); } static boolean canRetype(MethodType newType, MethodType targetType, boolean raw) { @@ -459,17 +449,13 @@ public class AdapterMethodHandle extends BoundMethodHandle { * Allows unchecked argument conversions pairwise, if they are safe. * Returns null if not possible. */ - public static MethodHandle makeRetypeOnly(Access token, - MethodType newType, MethodHandle target) { - return makeRetype(token, newType, target, false); + static MethodHandle makeRetypeOnly(MethodType newType, MethodHandle target) { + return makeRetype(newType, target, false); } - public static MethodHandle makeRetypeRaw(Access token, - MethodType newType, MethodHandle target) { - return makeRetype(token, newType, target, true); + static MethodHandle makeRetypeRaw(MethodType newType, MethodHandle target) { + return makeRetype(newType, target, true); } - static MethodHandle makeRetype(Access token, - MethodType newType, MethodHandle target, boolean raw) { - Access.check(token); + static MethodHandle makeRetype(MethodType newType, MethodHandle target, boolean raw) { MethodType oldType = target.type(); if (oldType == newType) return target; if (!canRetype(newType, oldType, raw)) @@ -478,9 +464,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { return new AdapterMethodHandle(target, newType, makeConv(raw ? OP_RETYPE_RAW : OP_RETYPE_ONLY)); } - static MethodHandle makeVarargsCollector(Access token, - MethodHandle target, Class arrayType) { - Access.check(token); + static MethodHandle makeVarargsCollector(MethodHandle target, Class arrayType) { return new AsVarargsCollector(target, arrayType); } @@ -526,6 +510,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { return collector.asType(newType); } + @Override public MethodHandle asVarargsCollector(Class arrayType) { MethodType type = this.type(); if (type.parameterType(type.parameterCount()-1) == arrayType) @@ -537,7 +522,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { /** Can a checkcast adapter validly convert the target to newType? * The JVM supports all kind of reference casts, even silly ones. */ - public static boolean canCheckCast(MethodType newType, MethodType targetType, + static boolean canCheckCast(MethodType newType, MethodType targetType, int arg, Class castType) { if (!convOpSupported(OP_CHECK_CAST)) return false; Class src = newType.parameterType(arg); @@ -549,7 +534,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { return (diff == arg+1); // arg is sole non-trivial diff } /** Can an primitive conversion adapter validly convert src to dst? */ - public static boolean canCheckCast(Class src, Class dst) { + static boolean canCheckCast(Class src, Class dst) { return (!src.isPrimitive() && !dst.isPrimitive()); } @@ -558,10 +543,8 @@ public class AdapterMethodHandle extends BoundMethodHandle { * with a null conversion to the corresponding target parameter. * Return null if this cannot be done. */ - public static MethodHandle makeCheckCast(Access token, - MethodType newType, MethodHandle target, + static MethodHandle makeCheckCast(MethodType newType, MethodHandle target, int arg, Class castType) { - Access.check(token); if (!canCheckCast(newType, target.type(), arg, castType)) return null; long conv = makeConv(OP_CHECK_CAST, arg, T_OBJECT, T_OBJECT); @@ -572,7 +555,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { * The JVM currently supports all conversions except those between * floating and integral types. */ - public static boolean canPrimCast(MethodType newType, MethodType targetType, + static boolean canPrimCast(MethodType newType, MethodType targetType, int arg, Class convType) { if (!convOpSupported(OP_PRIM_TO_PRIM)) return false; Class src = newType.parameterType(arg); @@ -584,7 +567,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { return (diff == arg+1); // arg is sole non-trivial diff } /** Can an primitive conversion adapter validly convert src to dst? */ - public static boolean canPrimCast(Class src, Class dst) { + static boolean canPrimCast(Class src, Class dst) { if (src == dst || !src.isPrimitive() || !dst.isPrimitive()) { return false; } else if (Wrapper.forPrimitiveType(dst).isFloating()) { @@ -604,10 +587,8 @@ public class AdapterMethodHandle extends BoundMethodHandle { * with a null conversion to the corresponding target parameter. * Return null if this cannot be done. */ - public static MethodHandle makePrimCast(Access token, - MethodType newType, MethodHandle target, + static MethodHandle makePrimCast(MethodType newType, MethodHandle target, int arg, Class convType) { - Access.check(token); MethodType oldType = target.type(); if (!canPrimCast(newType, oldType, arg, convType)) return null; @@ -620,7 +601,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { * The JVM currently supports all kinds of casting and unboxing. * The convType is the unboxed type; it can be either a primitive or wrapper. */ - public static boolean canUnboxArgument(MethodType newType, MethodType targetType, + static boolean canUnboxArgument(MethodType newType, MethodType targetType, int arg, Class convType) { if (!convOpSupported(OP_REF_TO_PRIM)) return false; Class src = newType.parameterType(arg); @@ -635,15 +616,14 @@ public class AdapterMethodHandle extends BoundMethodHandle { return (diff == arg+1); // arg is sole non-trivial diff } /** Can an primitive unboxing adapter validly convert src to dst? */ - public static boolean canUnboxArgument(Class src, Class dst) { + static boolean canUnboxArgument(Class src, Class dst) { return (!src.isPrimitive() && Wrapper.asPrimitiveType(dst).isPrimitive()); } /** Factory method: Unbox the given argument. * Return null if this cannot be done. */ - public static MethodHandle makeUnboxArgument(Access token, - MethodType newType, MethodHandle target, + static MethodHandle makeUnboxArgument(MethodType newType, MethodHandle target, int arg, Class convType) { MethodType oldType = target.type(); Class src = newType.parameterType(arg); @@ -659,11 +639,11 @@ public class AdapterMethodHandle extends BoundMethodHandle { MethodHandle adapter = new AdapterMethodHandle(target, castDone, conv, boxType); if (castDone == newType) return adapter; - return makeCheckCast(token, newType, adapter, arg, boxType); + return makeCheckCast(newType, adapter, arg, boxType); } /** Can an primitive boxing adapter validly convert src to dst? */ - public static boolean canBoxArgument(Class src, Class dst) { + static boolean canBoxArgument(Class src, Class dst) { if (!convOpSupported(OP_PRIM_TO_REF)) return false; throw new UnsupportedOperationException("NYI"); } @@ -671,15 +651,14 @@ public class AdapterMethodHandle extends BoundMethodHandle { /** Factory method: Unbox the given argument. * Return null if this cannot be done. */ - public static MethodHandle makeBoxArgument(Access token, - MethodType newType, MethodHandle target, + static MethodHandle makeBoxArgument(MethodType newType, MethodHandle target, int arg, Class convType) { // this is difficult to do in the JVM because it must GC return null; } /** Can an adapter simply drop arguments to convert the target to newType? */ - public static boolean canDropArguments(MethodType newType, MethodType targetType, + static boolean canDropArguments(MethodType newType, MethodType targetType, int dropArgPos, int dropArgCount) { if (dropArgCount == 0) return canRetypeOnly(newType, targetType); @@ -706,12 +685,10 @@ public class AdapterMethodHandle extends BoundMethodHandle { * Allow unchecked retyping of remaining arguments, pairwise. * Return null if this is not possible. */ - public static MethodHandle makeDropArguments(Access token, - MethodType newType, MethodHandle target, + static MethodHandle makeDropArguments(MethodType newType, MethodHandle target, int dropArgPos, int dropArgCount) { - Access.check(token); if (dropArgCount == 0) - return makeRetypeOnly(IMPL_TOKEN, newType, target); + return makeRetypeOnly(newType, target); if (!canDropArguments(newType, target.type(), dropArgPos, dropArgCount)) return null; // in arglist: [0: ...keep1 | dpos: drop... | dpos+dcount: keep2... ] @@ -727,7 +704,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { } /** Can an adapter duplicate an argument to convert the target to newType? */ - public static boolean canDupArguments(MethodType newType, MethodType targetType, + static boolean canDupArguments(MethodType newType, MethodType targetType, int dupArgPos, int dupArgCount) { if (!convOpSupported(OP_DUP_ARGS)) return false; if (diffReturnTypes(newType, targetType, false) != 0) @@ -749,10 +726,8 @@ public class AdapterMethodHandle extends BoundMethodHandle { /** Factory method: Duplicate the selected argument. * Return null if this is not possible. */ - public static MethodHandle makeDupArguments(Access token, - MethodType newType, MethodHandle target, + static MethodHandle makeDupArguments(MethodType newType, MethodHandle target, int dupArgPos, int dupArgCount) { - Access.check(token); if (!canDupArguments(newType, target.type(), dupArgPos, dupArgCount)) return null; if (dupArgCount == 0) @@ -769,7 +744,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { } /** Can an adapter swap two arguments to convert the target to newType? */ - public static boolean canSwapArguments(MethodType newType, MethodType targetType, + static boolean canSwapArguments(MethodType newType, MethodType targetType, int swapArg1, int swapArg2) { if (!convOpSupported(OP_SWAP_ARGS)) return false; if (diffReturnTypes(newType, targetType, false) != 0) @@ -796,10 +771,8 @@ public class AdapterMethodHandle extends BoundMethodHandle { /** Factory method: Swap the selected arguments. * Return null if this is not possible. */ - public static MethodHandle makeSwapArguments(Access token, - MethodType newType, MethodHandle target, + static MethodHandle makeSwapArguments(MethodType newType, MethodHandle target, int swapArg1, int swapArg2) { - Access.check(token); if (swapArg1 == swapArg2) return target; if (swapArg1 > swapArg2) { int t = swapArg1; swapArg1 = swapArg2; swapArg2 = t; } @@ -829,7 +802,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { final static int MAX_ARG_ROTATION = 1; /** Can an adapter rotate arguments to convert the target to newType? */ - public static boolean canRotateArguments(MethodType newType, MethodType targetType, + static boolean canRotateArguments(MethodType newType, MethodType targetType, int firstArg, int argCount, int rotateBy) { if (!convOpSupported(OP_ROT_ARGS)) return false; if (argCount <= 2) return false; // must be a swap, not a rotate @@ -861,10 +834,8 @@ public class AdapterMethodHandle extends BoundMethodHandle { /** Factory method: Rotate the selected argument range. * Return null if this is not possible. */ - public static MethodHandle makeRotateArguments(Access token, - MethodType newType, MethodHandle target, + static MethodHandle makeRotateArguments(MethodType newType, MethodHandle target, int firstArg, int argCount, int rotateBy) { - Access.check(token); rotateBy = positiveRotation(argCount, rotateBy); if (!canRotateArguments(newType, target.type(), firstArg, argCount, rotateBy)) return null; @@ -904,7 +875,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { } /** Can an adapter spread an argument to convert the target to newType? */ - public static boolean canSpreadArguments(MethodType newType, MethodType targetType, + static boolean canSpreadArguments(MethodType newType, MethodType targetType, Class spreadArgType, int spreadArgPos, int spreadArgCount) { if (!convOpSupported(OP_SPREAD_ARGS)) return false; if (diffReturnTypes(newType, targetType, false) != 0) @@ -937,10 +908,8 @@ public class AdapterMethodHandle extends BoundMethodHandle { /** Factory method: Spread selected argument. */ - public static MethodHandle makeSpreadArguments(Access token, - MethodType newType, MethodHandle target, + static MethodHandle makeSpreadArguments(MethodType newType, MethodHandle target, Class spreadArgType, int spreadArgPos, int spreadArgCount) { - Access.check(token); MethodType targetType = target.type(); if (!canSpreadArguments(newType, targetType, spreadArgType, spreadArgPos, spreadArgCount)) return null; @@ -962,7 +931,7 @@ public class AdapterMethodHandle extends BoundMethodHandle { @Override public String toString() { - return MethodHandleImpl.getNameString(IMPL_TOKEN, nonAdapter((MethodHandle)vmtarget), this); + return getNameString(nonAdapter((MethodHandle)vmtarget), this); } private static MethodHandle nonAdapter(MethodHandle mh) { diff --git a/src/share/classes/sun/dyn/BoundMethodHandle.java b/src/share/classes/java/lang/invoke/BoundMethodHandle.java similarity index 80% rename from src/share/classes/sun/dyn/BoundMethodHandle.java rename to src/share/classes/java/lang/invoke/BoundMethodHandle.java index 0fab63f7c7773b9576bc7e0c20ec638633ac1a13..d0d78895e7773b2b8a741af38ca2e4721a9cbfdb 100644 --- a/src/share/classes/sun/dyn/BoundMethodHandle.java +++ b/src/share/classes/java/lang/invoke/BoundMethodHandle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,15 +23,11 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import sun.dyn.util.VerifyType; -import sun.dyn.util.Wrapper; -import java.dyn.*; -import java.util.List; -import sun.dyn.MethodHandleNatives.Constants; -import static sun.dyn.MethodHandleImpl.IMPL_LOOKUP; -import static sun.dyn.MemberName.newIllegalArgumentException; +import sun.invoke.util.VerifyType; +import sun.invoke.util.Wrapper; +import static java.lang.invoke.MethodHandleStatics.*; /** * The flavor of method handle which emulates an invoke instruction @@ -39,37 +35,29 @@ import static sun.dyn.MemberName.newIllegalArgumentException; * when the handle is created, not when it is invoked. * @author jrose */ -public class BoundMethodHandle extends MethodHandle { +class BoundMethodHandle extends MethodHandle { //MethodHandle vmtarget; // next BMH or final DMH or methodOop private final Object argument; // argument to insert private final int vmargslot; // position at which it is inserted - private static final Access IMPL_TOKEN = Access.getToken(); - private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory(IMPL_TOKEN); - // Constructors in this class *must* be package scoped or private. /** Bind a direct MH to its receiver (or first ref. argument). * The JVM will pre-dispatch the MH if it is not already static. */ - BoundMethodHandle(DirectMethodHandle mh, Object argument) { - super(Access.TOKEN, mh.type().dropParameterTypes(0, 1)); + /*non-public*/ BoundMethodHandle(DirectMethodHandle mh, Object argument) { + super(mh.type().dropParameterTypes(0, 1)); // check the type now, once for all: this.argument = checkReferenceArgument(argument, mh, 0); this.vmargslot = this.type().parameterSlotCount(); - if (MethodHandleNatives.JVM_SUPPORT) { - this.vmtarget = null; // maybe updated by JVM - MethodHandleNatives.init(this, mh, 0); - } else { - this.vmtarget = mh; - } + initTarget(mh, 0); } /** Insert an argument into an arbitrary method handle. * If argnum is zero, inserts the first argument, etc. * The argument type must be a reference. */ - BoundMethodHandle(MethodHandle mh, Object argument, int argnum) { + /*non-public*/ BoundMethodHandle(MethodHandle mh, Object argument, int argnum) { this(mh.type().dropParameterTypes(argnum, argnum+1), mh, argument, argnum); } @@ -77,8 +65,8 @@ public class BoundMethodHandle extends MethodHandle { /** Insert an argument into an arbitrary method handle. * If argnum is zero, inserts the first argument, etc. */ - BoundMethodHandle(MethodType type, MethodHandle mh, Object argument, int argnum) { - super(Access.TOKEN, type); + /*non-public*/ BoundMethodHandle(MethodType type, MethodHandle mh, Object argument, int argnum) { + super(type); if (mh.type().parameterType(argnum).isPrimitive()) this.argument = bindPrimitiveArgument(argument, mh, argnum); else { @@ -89,18 +77,14 @@ public class BoundMethodHandle extends MethodHandle { } private void initTarget(MethodHandle mh, int argnum) { - if (MethodHandleNatives.JVM_SUPPORT) { - this.vmtarget = null; // maybe updated by JVM - MethodHandleNatives.init(this, mh, argnum); - } else { - this.vmtarget = mh; - } + //this.vmtarget = mh; // maybe updated by JVM + MethodHandleNatives.init(this, mh, argnum); } /** For the AdapterMethodHandle subclass. */ - BoundMethodHandle(MethodType type, Object argument, int vmargslot) { - super(Access.TOKEN, type); + /*non-public*/ BoundMethodHandle(MethodType type, Object argument, int vmargslot) { + super(type); this.argument = argument; this.vmargslot = vmargslot; assert(this instanceof AdapterMethodHandle); @@ -112,8 +96,8 @@ public class BoundMethodHandle extends MethodHandle { * same as {@code entryPoint}, except that the first argument * type will be dropped. */ - protected BoundMethodHandle(Access token, MethodHandle entryPoint) { - super(token, entryPoint.type().dropParameterTypes(0, 1)); + /*non-public*/ BoundMethodHandle(MethodHandle entryPoint) { + super(entryPoint.type().dropParameterTypes(0, 1)); this.argument = this; // kludge; get rid of this.vmargslot = this.type().parameterSlotDepth(0); initTarget(entryPoint, 0); @@ -172,7 +156,7 @@ public class BoundMethodHandle extends MethodHandle { @Override public String toString() { - return MethodHandleImpl.addTypeString(baseName(), this); + return addTypeString(baseName(), this); } /** Component of toString() before the type string. */ diff --git a/src/share/classes/java/dyn/CallSite.java b/src/share/classes/java/lang/invoke/CallSite.java similarity index 75% rename from src/share/classes/java/dyn/CallSite.java rename to src/share/classes/java/lang/invoke/CallSite.java index 42af08a729b02c56181154c2a1968146aae48733..b2da146d2618c926a43a2408cae21f8a14bf5315 100644 --- a/src/share/classes/java/dyn/CallSite.java +++ b/src/share/classes/java/lang/invoke/CallSite.java @@ -23,12 +23,12 @@ * questions. */ -package java.dyn; +package java.lang.invoke; -import sun.dyn.*; -import sun.dyn.empty.Empty; +import sun.invoke.empty.Empty; import sun.misc.Unsafe; -import java.util.Collection; +import static java.lang.invoke.MethodHandleStatics.*; +import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /** * A {@code CallSite} is a holder for a variable {@link MethodHandle}, @@ -85,7 +85,6 @@ private static CallSite bootstrapDynamic(MethodHandles.Lookup caller, String nam */ abstract public class CallSite { - private static final Access IMPL_TOKEN = Access.getToken(); static { MethodHandleImpl.initStatics(); } // Fields used only by the JVM. Do not use or change. @@ -96,9 +95,6 @@ public class CallSite { /*package-private*/ MethodHandle target; - // Remove this field for PFD and delete deprecated methods: - private MemberName calleeNameRemoveForPFD; - /** * Make a blank call site object with the given method type. * An initial target method is supplied which will throw @@ -111,7 +107,7 @@ public class CallSite { */ /*package-private*/ CallSite(MethodType type) { - target = MethodHandles.invokers(type).uninitializedCallSite(); + target = type.invokers().uninitializedCallSite(); } /** @@ -145,7 +141,7 @@ public class CallSite { int callerBCI) { if (this.vmmethod != null) { // FIXME - throw new InvokeDynamicBootstrapError("call site has already been linked to an invokedynamic instruction"); + throw new BootstrapMethodError("call site has already been linked to an invokedynamic instruction"); } if (!this.type().equals(type)) { throw wrongTargetType(target, type); @@ -202,7 +198,7 @@ public class CallSite { } /** - * Produce a method handle equivalent to an invokedynamic instruction + * Produces a method handle equivalent to an invokedynamic instruction * which has been linked to this call site. *

* This method is equivalent to the following code: @@ -218,7 +214,7 @@ public class CallSite { public abstract MethodHandle dynamicInvoker(); /*non-public*/ MethodHandle makeDynamicInvoker() { - MethodHandle getTarget = MethodHandleImpl.bindReceiver(IMPL_TOKEN, GET_TARGET, this); + MethodHandle getTarget = MethodHandleImpl.bindReceiver(GET_TARGET, this); MethodHandle invoker = MethodHandles.exactInvoker(this.type()); return MethodHandles.foldArguments(invoker, getTarget); } @@ -226,7 +222,7 @@ public class CallSite { private static final MethodHandle GET_TARGET; static { try { - GET_TARGET = MethodHandles.Lookup.IMPL_LOOKUP. + GET_TARGET = IMPL_LOOKUP. findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class)); } catch (ReflectiveOperationException ignore) { throw new InternalError(); @@ -252,7 +248,6 @@ public class CallSite { /*package-private*/ void setTargetNormal(MethodHandle newTarget) { target = newTarget; - //CallSiteImpl.setCallSiteTarget(IMPL_TOKEN, this, newTarget); } /*package-private*/ MethodHandle getTargetVolatile() { @@ -261,6 +256,68 @@ public class CallSite { /*package-private*/ void setTargetVolatile(MethodHandle newTarget) { unsafe.putObjectVolatile(this, TARGET_OFFSET, newTarget); - //CallSiteImpl.setCallSiteTarget(IMPL_TOKEN, this, newTarget); + } + + // this implements the upcall from the JVM, MethodHandleNatives.makeDynamicCallSite: + static CallSite makeSite(MethodHandle bootstrapMethod, + // Callee information: + String name, MethodType type, + // Extra arguments for BSM, if any: + Object info, + // Caller information: + MemberName callerMethod, int callerBCI) { + Class callerClass = callerMethod.getDeclaringClass(); + Object caller = IMPL_LOOKUP.in(callerClass); + CallSite site; + try { + Object binding; + info = maybeReBox(info); + if (info == null) { + binding = bootstrapMethod.invokeGeneric(caller, name, type); + } else if (!info.getClass().isArray()) { + binding = bootstrapMethod.invokeGeneric(caller, name, type, info); + } else { + Object[] argv = (Object[]) info; + maybeReBoxElements(argv); + if (3 + argv.length > 255) + throw new BootstrapMethodError("too many bootstrap method arguments"); + MethodType bsmType = bootstrapMethod.type(); + if (bsmType.parameterCount() == 4 && bsmType.parameterType(3) == Object[].class) + binding = bootstrapMethod.invokeGeneric(caller, name, type, argv); + else + binding = MethodHandles.spreadInvoker(bsmType, 3) + .invokeGeneric(bootstrapMethod, caller, name, type, argv); + } + //System.out.println("BSM for "+name+type+" => "+binding); + if (binding instanceof CallSite) { + site = (CallSite) binding; + } else { + throw new ClassCastException("bootstrap method failed to produce a CallSite"); + } + assert(site.getTarget() != null); + assert(site.getTarget().type().equals(type)); + } catch (Throwable ex) { + BootstrapMethodError bex; + if (ex instanceof BootstrapMethodError) + bex = (BootstrapMethodError) ex; + else + bex = new BootstrapMethodError("call site initialization exception", ex); + throw bex; + } + return site; + } + + private static Object maybeReBox(Object x) { + if (x instanceof Integer) { + int xi = (int) x; + if (xi == (byte) xi) + x = xi; // must rebox; see JLS 5.1.7 + } + return x; + } + private static void maybeReBoxElements(Object[] xa) { + for (int i = 0; i < xa.length; i++) { + xa[i] = maybeReBox(xa[i]); + } } } diff --git a/src/share/classes/java/dyn/ConstantCallSite.java b/src/share/classes/java/lang/invoke/ConstantCallSite.java similarity index 99% rename from src/share/classes/java/dyn/ConstantCallSite.java rename to src/share/classes/java/lang/invoke/ConstantCallSite.java index 50240a0f50f45e1459fa05e633e83f65560b3375..e182c54aaa9867f0d9b246154caa64d329510c26 100644 --- a/src/share/classes/java/dyn/ConstantCallSite.java +++ b/src/share/classes/java/lang/invoke/ConstantCallSite.java @@ -23,7 +23,7 @@ * questions. */ -package java.dyn; +package java.lang.invoke; /** * A {@code ConstantCallSite} is a {@link CallSite} whose target is permanent, and can never be changed. diff --git a/src/share/classes/sun/dyn/DirectMethodHandle.java b/src/share/classes/java/lang/invoke/DirectMethodHandle.java similarity index 91% rename from src/share/classes/sun/dyn/DirectMethodHandle.java rename to src/share/classes/java/lang/invoke/DirectMethodHandle.java index b43f353bbd68331403cbefee3077a429a497ec54..13bedb1785979d92e53f6164cdd14d6b674cda1d 100644 --- a/src/share/classes/sun/dyn/DirectMethodHandle.java +++ b/src/share/classes/java/lang/invoke/DirectMethodHandle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,9 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; -import static sun.dyn.MethodHandleNatives.Constants.*; +import static java.lang.invoke.MethodHandleNatives.Constants.*; /** * The flavor of method handle which emulates invokespecial or invokestatic. @@ -39,7 +38,7 @@ class DirectMethodHandle extends MethodHandle { // Constructors in this class *must* be package scoped or private. DirectMethodHandle(MethodType mtype, MemberName m, boolean doDispatch, Class lookupClass) { - super(Access.TOKEN, mtype); + super(mtype); assert(m.isMethod() || !doDispatch && m.isConstructor()); if (!m.isResolved()) diff --git a/src/share/classes/sun/dyn/FilterGeneric.java b/src/share/classes/java/lang/invoke/FilterGeneric.java similarity index 99% rename from src/share/classes/sun/dyn/FilterGeneric.java rename to src/share/classes/java/lang/invoke/FilterGeneric.java index e77d742a11e23477b0d7c8b38cc7a9aca48bfcea..6c3395002f5bb37e58d8616667dbe612d5c355c9 100644 --- a/src/share/classes/sun/dyn/FilterGeneric.java +++ b/src/share/classes/java/lang/invoke/FilterGeneric.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,11 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; import java.lang.reflect.*; -import static sun.dyn.MemberName.newIllegalArgumentException; +import static java.lang.invoke.MethodHandleStatics.*; +import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /** * These adapters apply arbitrary conversions to arguments @@ -123,7 +123,7 @@ class FilterGeneric { MethodType entryType = entryType(kind, pos, filterType, targetType); if (entryType.generic() != entryType) throw newIllegalArgumentException("must be generic: "+entryType); - MethodTypeImpl form = MethodTypeImpl.of(entryType); + MethodTypeForm form = entryType.form(); FilterGeneric filterGen = form.filterGeneric; if (filterGen == null) form.filterGeneric = filterGen = new FilterGeneric(entryType); @@ -186,7 +186,7 @@ class FilterGeneric { // see if it has the required invoke method MethodHandle entryPoint = null; try { - entryPoint = MethodHandleImpl.IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls); + entryPoint = IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls); } catch (ReflectiveOperationException ex) { } if (entryPoint == null) continue; @@ -231,7 +231,7 @@ class FilterGeneric { @Override public String toString() { - return MethodHandleImpl.addTypeString(target, this); + return addTypeString(target, this); } protected boolean isPrototype() { return target == null; } @@ -246,7 +246,7 @@ class FilterGeneric { protected Adapter(MethodHandle entryPoint, MethodHandle filter, MethodHandle target) { - super(Access.TOKEN, entryPoint); + super(entryPoint); this.filter = filter; this.target = target; } @@ -256,7 +256,7 @@ class FilterGeneric { MethodHandle filter, MethodHandle target); // { return new ThisType(entryPoint, filter, target); } - static private final String CLASS_PREFIX; // "sun.dyn.FilterGeneric$" + static private final String CLASS_PREFIX; // "java.lang.invoke.FilterGeneric$" static { String aname = Adapter.class.getName(); String sname = Adapter.class.getSimpleName(); diff --git a/src/share/classes/sun/dyn/FilterOneArgument.java b/src/share/classes/java/lang/invoke/FilterOneArgument.java similarity index 86% rename from src/share/classes/sun/dyn/FilterOneArgument.java rename to src/share/classes/java/lang/invoke/FilterOneArgument.java index 86c722f3c0ab7fbf09504b4c30935aa937f1d720..64a9f072797c717ff4d804fa7347e564058b2534 100644 --- a/src/share/classes/sun/dyn/FilterOneArgument.java +++ b/src/share/classes/java/lang/invoke/FilterOneArgument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,10 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; -import static sun.dyn.MemberName.uncaughtException; +import static java.lang.invoke.MethodHandleStatics.*; +import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /** * Unary function composition, useful for many small plumbing jobs. @@ -36,7 +36,7 @@ import static sun.dyn.MemberName.uncaughtException; * final method type is the responsibility of a JVM-level adapter. * @author jrose */ -public class FilterOneArgument extends BoundMethodHandle { +class FilterOneArgument extends BoundMethodHandle { protected final MethodHandle filter; // Object -> Object protected final MethodHandle target; // Object -> Object @@ -54,15 +54,15 @@ public class FilterOneArgument extends BoundMethodHandle { static { try { INVOKE = - MethodHandleImpl.IMPL_LOOKUP.findVirtual(FilterOneArgument.class, "invoke", - MethodType.genericMethodType(1)); + IMPL_LOOKUP.findVirtual(FilterOneArgument.class, "invoke", + MethodType.genericMethodType(1)); } catch (ReflectiveOperationException ex) { throw uncaughtException(ex); } } protected FilterOneArgument(MethodHandle filter, MethodHandle target) { - super(Access.TOKEN, INVOKE); + super(INVOKE); this.filter = filter; this.target = target; } diff --git a/src/share/classes/sun/dyn/FromGeneric.java b/src/share/classes/java/lang/invoke/FromGeneric.java similarity index 97% rename from src/share/classes/sun/dyn/FromGeneric.java rename to src/share/classes/java/lang/invoke/FromGeneric.java index b996a6b3ead1da51c1b1dbe2e8a83f3fde199e9c..1c0523a4a3668addb6b58944281ba7b245dd5a80 100644 --- a/src/share/classes/sun/dyn/FromGeneric.java +++ b/src/share/classes/java/lang/invoke/FromGeneric.java @@ -23,12 +23,13 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; +import sun.invoke.util.ValueConversions; +import sun.invoke.util.Wrapper; import java.lang.reflect.*; -import sun.dyn.util.*; -import static sun.dyn.MethodTypeImpl.invokers; +import static java.lang.invoke.MethodHandleStatics.*; +import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /** * Adapters which mediate between incoming calls which are generic @@ -82,8 +83,8 @@ class FromGeneric { } // outgoing primitive arguments will be wrapped; unwrap them - MethodType primsAsObj = MethodTypeImpl.of(targetType).primArgsAsBoxes(); - MethodType objArgsRawRet = MethodTypeImpl.of(primsAsObj).primsAsInts(); + MethodType primsAsObj = targetType.form().primArgsAsBoxes(); + MethodType objArgsRawRet = primsAsObj.form().primsAsInts(); if (objArgsRawRet != targetType) ad = findAdapter(internalType0 = objArgsRawRet); if (ad == null) { @@ -129,16 +130,16 @@ class FromGeneric { MethodType targetType, MethodType internalType) { // All the adapters we have here have reference-untyped internal calls. assert(internalType == internalType.erase()); - MethodHandle invoker = invokers(targetType).exactInvoker(); + MethodHandle invoker = targetType.invokers().exactInvoker(); // cast all narrow reference types, unbox all primitive arguments: MethodType fixArgsType = internalType.changeReturnType(targetType.returnType()); - MethodHandle fixArgs = AdapterMethodHandle.convertArguments(Access.TOKEN, + MethodHandle fixArgs = MethodHandleImpl.convertArguments( invoker, Invokers.invokerType(fixArgsType), invoker.type(), null); if (fixArgs == null) throw new InternalError("bad fixArgs"); // reinterpret the calling sequence as raw: - MethodHandle retyper = AdapterMethodHandle.makeRetypeRaw(Access.TOKEN, + MethodHandle retyper = AdapterMethodHandle.makeRetypeRaw( Invokers.invokerType(internalType), fixArgs); if (retyper == null) throw new InternalError("bad retyper"); @@ -171,7 +172,7 @@ class FromGeneric { /** Return the adapter information for this type's erasure. */ static FromGeneric of(MethodType type) { - MethodTypeImpl form = MethodTypeImpl.of(type); + MethodTypeForm form = type.form(); FromGeneric fromGen = form.fromGeneric; if (fromGen == null) form.fromGeneric = fromGen = new FromGeneric(form.erasedType()); @@ -185,7 +186,7 @@ class FromGeneric { /* Create an adapter that handles spreading calls for the given type. */ static Adapter findAdapter(MethodType internalType) { MethodType entryType = internalType.generic(); - MethodTypeImpl form = MethodTypeImpl.of(internalType); + MethodTypeForm form = internalType.form(); Class rtype = internalType.returnType(); int argc = form.parameterCount(); int lac = form.longPrimitiveParameterCount(); @@ -203,7 +204,7 @@ class FromGeneric { // see if it has the required invoke method MethodHandle entryPoint = null; try { - entryPoint = MethodHandleImpl.IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls); + entryPoint = IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls); } catch (ReflectiveOperationException ex) { } if (entryPoint == null) continue; @@ -257,7 +258,7 @@ class FromGeneric { @Override public String toString() { - return MethodHandleImpl.addTypeString(target, this); + return addTypeString(target, this); } protected boolean isPrototype() { return target == null; } @@ -272,7 +273,7 @@ class FromGeneric { protected Adapter(MethodHandle entryPoint, MethodHandle invoker, MethodHandle convert, MethodHandle target) { - super(Access.TOKEN, entryPoint); + super(entryPoint); this.invoker = invoker; this.convert = convert; this.target = target; @@ -290,7 +291,7 @@ class FromGeneric { protected Object convert_F(float result) throws Throwable { return convert.invokeExact(result); } protected Object convert_D(double result) throws Throwable { return convert.invokeExact(result); } - static private final String CLASS_PREFIX; // "sun.dyn.FromGeneric$" + static private final String CLASS_PREFIX; // "java.lang.invoke.FromGeneric$" static { String aname = Adapter.class.getName(); String sname = Adapter.class.getSimpleName(); diff --git a/src/share/classes/java/dyn/InvokeDynamic.java b/src/share/classes/java/lang/invoke/InvokeDynamic.java similarity index 93% rename from src/share/classes/java/dyn/InvokeDynamic.java rename to src/share/classes/java/lang/invoke/InvokeDynamic.java index 9c3ede1ee367cdb5f35e8a7eaba1833fc2aa2fd8..4668d741bbb77fdfbfe010f01f5bcf77c23667bf 100644 --- a/src/share/classes/java/dyn/InvokeDynamic.java +++ b/src/share/classes/java/lang/invoke/InvokeDynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ * questions. */ -package java.dyn; +package java.lang.invoke; /** * This is a place-holder class. Some HotSpot implementations need to see it. diff --git a/src/share/classes/sun/dyn/InvokeGeneric.java b/src/share/classes/java/lang/invoke/InvokeGeneric.java similarity index 86% rename from src/share/classes/sun/dyn/InvokeGeneric.java rename to src/share/classes/java/lang/invoke/InvokeGeneric.java index 0d1a5defce3abf84a350b9c934096d5e41c642a6..a235e7318da58638412e7e2ffee8782a168f99be 100644 --- a/src/share/classes/sun/dyn/InvokeGeneric.java +++ b/src/share/classes/java/lang/invoke/InvokeGeneric.java @@ -23,15 +23,13 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; -import java.lang.reflect.*; -import sun.dyn.util.*; -import static sun.dyn.MethodTypeImpl.invokers; +import sun.invoke.util.*; +import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /** - * Adapters which manage MethodHanndle.invokeGeneric calls. + * Adapters which manage MethodHandle.invokeGeneric calls. * The JVM calls one of these when the exact type match fails. * @author jrose */ @@ -44,7 +42,8 @@ class InvokeGeneric { /** Compute and cache information for this adapter, so that it can * call out to targets of the erasure-family of the given erased type. */ - private InvokeGeneric(MethodType erasedCallerType) throws ReflectiveOperationException { + /*non-public*/ InvokeGeneric(MethodType erasedCallerType) throws ReflectiveOperationException { + assert(erasedCallerType.equals(erasedCallerType.erase())); this.erasedCallerType = erasedCallerType; this.initialInvoker = makeInitialInvoker(); assert initialInvoker.type().equals(erasedCallerType @@ -53,22 +52,13 @@ class InvokeGeneric { } private static MethodHandles.Lookup lookup() { - return MethodHandleImpl.IMPL_LOOKUP; + return IMPL_LOOKUP; } /** Return the adapter information for this type's erasure. */ - static MethodHandle genericInvokerOf(MethodType type) { - MethodTypeImpl form = MethodTypeImpl.of(type); - MethodHandle genericInvoker = form.genericInvoker; - if (genericInvoker == null) { - try { - InvokeGeneric gen = new InvokeGeneric(form.erasedType()); - form.genericInvoker = genericInvoker = gen.initialInvoker; - } catch (ReflectiveOperationException ex) { - throw new RuntimeException(ex); - } - } - return genericInvoker; + /*non-public*/ static MethodHandle genericInvokerOf(MethodType erasedCallerType) throws ReflectiveOperationException { + InvokeGeneric gen = new InvokeGeneric(erasedCallerType); + return gen.initialInvoker; } private MethodHandle makeInitialInvoker() throws ReflectiveOperationException { @@ -88,7 +78,7 @@ class InvokeGeneric { private MethodHandle makePostDispatchInvoker() { // Take (MH'; MT, MH; A...) and run MH'(MT, MH; A...). MethodType invokerType = erasedCallerType.insertParameterTypes(0, EXTRA_ARGS); - return invokers(invokerType).exactInvoker(); + return invokerType.invokers().exactInvoker(); } private MethodHandle dropDispatchArguments(MethodHandle targetInvoker) { assert(targetInvoker.type().parameterType(0) == MethodHandle.class); @@ -112,7 +102,7 @@ class InvokeGeneric { if (USE_AS_TYPE_PATH || target.isVarargsCollector()) { MethodHandle newTarget = target.asType(callerType); targetType = callerType; - Invokers invokers = MethodTypeImpl.invokers(Access.TOKEN, targetType); + Invokers invokers = targetType.invokers(); MethodHandle invoker = invokers.erasedInvokerWithDrops; if (invoker == null) { invokers.erasedInvokerWithDrops = invoker = diff --git a/src/share/classes/sun/dyn/Invokers.java b/src/share/classes/java/lang/invoke/Invokers.java similarity index 87% rename from src/share/classes/sun/dyn/Invokers.java rename to src/share/classes/java/lang/invoke/Invokers.java index 55eef1911ba7b652a1fd4611940b78d847e85f55..4eeb36f76b767da10d3171c79ba9d949141cd0c5 100644 --- a/src/share/classes/sun/dyn/Invokers.java +++ b/src/share/classes/java/lang/invoke/Invokers.java @@ -23,16 +23,16 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; -import sun.dyn.empty.Empty; +import sun.invoke.empty.Empty; +import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /** * Construction and caching of often-used invokers. * @author jrose */ -public class Invokers { +class Invokers { // exact type (sans leading taget MH) for the outgoing call private final MethodType targetType; @@ -60,15 +60,15 @@ public class Invokers { this.spreadInvokers = new MethodHandle[targetType.parameterCount()+1]; } - public static MethodType invokerType(MethodType targetType) { + /*non-public*/ static MethodType invokerType(MethodType targetType) { return targetType.insertParameterTypes(0, MethodHandle.class); } - public MethodHandle exactInvoker() { + /*non-public*/ MethodHandle exactInvoker() { MethodHandle invoker = exactInvoker; if (invoker != null) return invoker; try { - invoker = MethodHandleImpl.IMPL_LOOKUP.findVirtual(MethodHandle.class, "invokeExact", targetType); + invoker = IMPL_LOOKUP.findVirtual(MethodHandle.class, "invokeExact", targetType); } catch (ReflectiveOperationException ex) { throw new InternalError("JVM cannot find invoker for "+targetType); } @@ -77,7 +77,7 @@ public class Invokers { return invoker; } - public MethodHandle genericInvoker() { + /*non-public*/ MethodHandle genericInvoker() { MethodHandle invoker1 = exactInvoker(); MethodHandle invoker = genericInvoker; if (invoker != null) return invoker; @@ -87,7 +87,7 @@ public class Invokers { return invoker; } - public MethodHandle erasedInvoker() { + /*non-public*/ MethodHandle erasedInvoker() { MethodHandle invoker1 = exactInvoker(); MethodHandle invoker = erasedInvoker; if (invoker != null) return invoker; @@ -100,7 +100,7 @@ public class Invokers { return invoker; } - public MethodHandle spreadInvoker(int objectArgCount) { + /*non-public*/ MethodHandle spreadInvoker(int objectArgCount) { MethodHandle vaInvoker = spreadInvokers[objectArgCount]; if (vaInvoker != null) return vaInvoker; MethodHandle gInvoker = genericInvoker(); @@ -111,12 +111,12 @@ public class Invokers { private static MethodHandle THROW_UCS = null; - public MethodHandle uninitializedCallSite() { + /*non-public*/ MethodHandle uninitializedCallSite() { MethodHandle invoker = uninitializedCallSite; if (invoker != null) return invoker; if (targetType.parameterCount() > 0) { MethodType type0 = targetType.dropParameterTypes(0, targetType.parameterCount()); - Invokers invokers0 = MethodTypeImpl.invokers(type0); + Invokers invokers0 = type0.invokers(); invoker = MethodHandles.dropArguments(invokers0.uninitializedCallSite(), 0, targetType.parameterList()); assert(invoker.type().equals(targetType)); @@ -125,14 +125,14 @@ public class Invokers { } if (THROW_UCS == null) { try { - THROW_UCS = MethodHandleImpl.IMPL_LOOKUP + THROW_UCS = IMPL_LOOKUP .findStatic(CallSite.class, "uninitializedCallSite", MethodType.methodType(Empty.class)); } catch (ReflectiveOperationException ex) { throw new RuntimeException(ex); } } - invoker = AdapterMethodHandle.makeRetypeRaw(Access.TOKEN, targetType, THROW_UCS); + invoker = AdapterMethodHandle.makeRetypeRaw(targetType, THROW_UCS); assert(invoker.type().equals(targetType)); uninitializedCallSite = invoker; return invoker; diff --git a/src/share/classes/sun/dyn/MemberName.java b/src/share/classes/java/lang/invoke/MemberName.java similarity index 93% rename from src/share/classes/sun/dyn/MemberName.java rename to src/share/classes/java/lang/invoke/MemberName.java index 5e98b85ca6030f134a5216569ee9decb65de489f..0300fe758cc301c43f10e5ebe9d008d821ffc0c8 100644 --- a/src/share/classes/sun/dyn/MemberName.java +++ b/src/share/classes/java/lang/invoke/MemberName.java @@ -23,10 +23,9 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import sun.dyn.util.BytecodeDescriptor; -import java.dyn.*; +import sun.invoke.util.BytecodeDescriptor; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -37,7 +36,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; -import static sun.dyn.MethodHandleNatives.Constants.*; +import static java.lang.invoke.MethodHandleNatives.Constants.*; +import static java.lang.invoke.MethodHandleStatics.*; /** * A {@code MemberName} is a compact symbolic datum which fully characterizes @@ -66,7 +66,7 @@ import static sun.dyn.MethodHandleNatives.Constants.*; * and those seven fields omit much of the information in Method. * @author jrose */ -public final class MemberName implements Member, Cloneable { +/*non-public*/ final class MemberName implements Member, Cloneable { private Class clazz; // class in which the method is defined private String name; // may be null if not yet materialized private Object type; // may be null if not yet materialized @@ -435,7 +435,7 @@ public final class MemberName implements Member, Cloneable { /** Query whether this member name is resolved to a non-static, non-final method. */ public boolean hasReceiverTypeDispatch() { - return (isMethod() && getVMIndex(Access.TOKEN) >= 0); + return (isMethod() && getVMIndex() >= 0); } /** Produce a string form of this member name. @@ -490,59 +490,38 @@ public final class MemberName implements Member, Cloneable { // Queries to the JVM: /** Document? */ - public int getVMIndex(Access token) { - Access.check(token); + /*non-public*/ int getVMIndex() { if (!isResolved()) - throw newIllegalStateException("not resolved"); + throw newIllegalStateException("not resolved", this); return vmindex; } -// public Object getVMTarget(Access token) { -// Access.check(token); +// /*non-public*/ Object getVMTarget() { // if (!isResolved()) -// throw newIllegalStateException("not resolved"); +// throw newIllegalStateException("not resolved", this); // return vmtarget; // } - private RuntimeException newIllegalStateException(String message) { - return new IllegalStateException(message+": "+this); - } - // handy shared exception makers (they simplify the common case code) - public static RuntimeException newIllegalArgumentException(String message) { - return new IllegalArgumentException(message); - } - public static IllegalAccessException newNoAccessException(MemberName name, Object from) { - return newNoAccessException("cannot access", name, from); - } - public static IllegalAccessException newNoAccessException(String message, - MemberName name, Object from) { - message += ": " + name; + public IllegalAccessException makeAccessException(String message, Object from) { + message = message + ": "+ toString(); if (from != null) message += ", from " + from; return new IllegalAccessException(message); } - public static ReflectiveOperationException newNoAccessException(MemberName name) { - if (name.isResolved()) - return new IllegalAccessException(name.toString()); - else if (name.isConstructor()) - return new NoSuchMethodException(name.toString()); - else if (name.isMethod()) - return new NoSuchMethodException(name.toString()); + public ReflectiveOperationException makeAccessException(String message) { + message = message + ": "+ toString(); + if (isResolved()) + return new IllegalAccessException(message); + else if (isConstructor()) + return new NoSuchMethodException(message); + else if (isMethod()) + return new NoSuchMethodException(message); else - return new NoSuchFieldException(name.toString()); - } - public static Error uncaughtException(Exception ex) { - Error err = new InternalError("uncaught exception"); - err.initCause(ex); - return err; + return new NoSuchFieldException(message); } /** Actually making a query requires an access check. */ - public static Factory getFactory(Access token) { - Access.check(token); + /*non-public*/ static Factory getFactory() { return Factory.INSTANCE; } - public static Factory getFactory() { - return getFactory(Access.getToken()); - } /** A factory type for resolving member names with the help of the VM. * TBD: Define access-safe public constructors for this factory. */ @@ -662,7 +641,7 @@ public final class MemberName implements Member, Cloneable { MemberName result = resolveOrNull(m, searchSupers, lookupClass); if (result != null) return result; - ReflectiveOperationException ex = newNoAccessException(m); + ReflectiveOperationException ex = m.makeAccessException("no access"); if (ex instanceof IllegalAccessException) throw (IllegalAccessException) ex; throw nsmClass.cast(ex); } diff --git a/src/share/classes/java/dyn/MethodHandle.java b/src/share/classes/java/lang/invoke/MethodHandle.java similarity index 88% rename from src/share/classes/java/dyn/MethodHandle.java rename to src/share/classes/java/lang/invoke/MethodHandle.java index b78b40248053f521214048a6b52230b42698a454..8165915c7bb7ece633bab771c5ad92c5f5d5d56c 100644 --- a/src/share/classes/java/dyn/MethodHandle.java +++ b/src/share/classes/java/lang/invoke/MethodHandle.java @@ -23,15 +23,10 @@ * questions. */ -package java.dyn; +package java.lang.invoke; -//import sun.dyn.*; -import sun.dyn.Access; -import sun.dyn.MethodHandleImpl; - -import static java.dyn.MethodHandles.invokers; // package-private API -import static sun.dyn.MemberName.newIllegalArgumentException; // utility +import static java.lang.invoke.MethodHandleStatics.*; /** * A method handle is a typed, directly executable reference to an underlying method, @@ -40,14 +35,8 @@ import static sun.dyn.MemberName.newIllegalArgumentException; // utility * These transformations are quite general, and include such patterns as * {@linkplain #asType conversion}, * {@linkplain #bindTo insertion}, - * {@linkplain java.dyn.MethodHandles#dropArguments deletion}, - * and {@linkplain java.dyn.MethodHandles#filterArguments substitution}. - *

- * Note: The super-class of MethodHandle is Object. - * Any other super-class visible in the Reference Implementation - * will be removed before the Proposed Final Draft. - * Also, the final version will not include any public or - * protected constructors. + * {@linkplain java.lang.invoke.MethodHandles#dropArguments deletion}, + * and {@linkplain java.lang.invoke.MethodHandles#filterArguments substitution}. * *

Method handle contents

* Method handles are dynamically and strongly typed according to type descriptor. @@ -56,7 +45,7 @@ import static sun.dyn.MemberName.newIllegalArgumentException; // utility * the method handle's own {@linkplain #type method type}. *

* Every method handle reports its type via the {@link #type type} accessor. - * This type descriptor is a {@link java.dyn.MethodType MethodType} object, + * This type descriptor is a {@link java.lang.invoke.MethodType MethodType} object, * whose structure is a series of classes, one of which is * the return type of the method (or {@code void.class} if none). *

@@ -156,7 +145,7 @@ import static sun.dyn.MemberName.newIllegalArgumentException; // utility * This allows a more powerful negotiation of method type * between caller and callee. *

- * (Note: The adjusted method handle {@code M2} is not directly observable, + * (Note: The adjusted method handle {@code M2} is not directly observable, * and implementations are therefore not required to materialize it.) * *

Invocation checking

@@ -204,11 +193,11 @@ import static sun.dyn.MemberName.newIllegalArgumentException; // utility * Java code can create a method handle that directly accesses * any method, constructor, or field that is accessible to that code. * This is done via a reflective, capability-based API called - * {@link java.dyn.MethodHandles.Lookup MethodHandles.Lookup} + * {@link java.lang.invoke.MethodHandles.Lookup MethodHandles.Lookup} * For example, a static method handle can be obtained - * from {@link java.dyn.MethodHandles.Lookup#findStatic Lookup.findStatic}. + * from {@link java.lang.invoke.MethodHandles.Lookup#findStatic Lookup.findStatic}. * There are also conversion methods from Core Reflection API objects, - * such as {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect}. + * such as {@link java.lang.invoke.MethodHandles.Lookup#unreflect Lookup.unreflect}. *

* Like classes and strings, method handles that correspond to accessible * fields, methods, and constructors can also be represented directly @@ -269,7 +258,7 @@ mh = mh.asType(mt); x = mh.invokeExact((Object)1, (Object)2, (Object)3); // invokeExact(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; assert(x.equals(java.util.Arrays.asList(1,2,3))); -// mt is { => int} +// mt is int() mt = MethodType.methodType(int.class); mh = lookup.findVirtual(java.util.List.class, "size", mt); i = (int) mh.invokeExact(java.util.Arrays.asList(1,2,3)); @@ -325,15 +314,15 @@ mh.invokeExact(System.out, "Hello, world."); *

* For the sake of tools (but not as a programming API), the signature polymorphic * methods are marked with a private yet standard annotation, - * {@code @java.dyn.MethodHandle.PolymorphicSignature}. + * {@code @java.lang.invoke.MethodHandle.PolymorphicSignature}. * The annotation's retention is {@code RUNTIME}, so that all tools can see it. * *

Formal rules for processing signature polymorphic methods

*

* The following methods (and no others) are signature polymorphic: *

    - *
  • {@link java.dyn.MethodHandle#invokeExact MethodHandle.invokeExact} - *
  • {@link java.dyn.MethodHandle#invokeGeneric MethodHandle.invokeGeneric} + *
  • {@link java.lang.invoke.MethodHandle#invokeExact MethodHandle.invokeExact} + *
  • {@link java.lang.invoke.MethodHandle#invokeGeneric MethodHandle.invokeGeneric} *
*

* A signature polymorphic method will be declared with the following properties: @@ -341,7 +330,7 @@ mh.invokeExact(System.out, "Hello, world."); *

  • It must be native. *
  • It must take a single varargs parameter of the form {@code Object...}. *
  • It must produce a return value of type {@code Object}. - *
  • It must be contained within the {@code java.dyn} package. + *
  • It must be contained within the {@code java.lang.invoke} package. * * Because of these requirements, a signature polymorphic method is able to accept * any number and type of actual arguments, and can, with a cast, produce a value of any type. @@ -354,7 +343,7 @@ mh.invokeExact(System.out, "Hello, world."); *

    * In an argument position of a method invocation on a signature polymorphic method, * a null literal has type {@code java.lang.Void}, unless cast to a reference type. - * (Note: This typing rule allows the null type to have its own encoding in linkage information + * (Note: This typing rule allows the null type to have its own encoding in linkage information * distinct from other types. *

    * The linkage information for the return type is derived from a context-dependent target typing convention. @@ -374,12 +363,12 @@ mh.invokeExact(System.out, "Hello, world."); * and without implicit boxing or unboxing. * *

    Interoperation between method handles and the Core Reflection API

    - * Using factory methods in the {@link java.dyn.MethodHandles.Lookup Lookup} API, + * Using factory methods in the {@link java.lang.invoke.MethodHandles.Lookup Lookup} API, * any class member represented by a Core Reflection API object * can be converted to a behaviorally equivalent method handle. * For example, a reflective {@link java.lang.reflect.Method Method} can * be converted to a method handle using - * {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect}. + * {@link java.lang.invoke.MethodHandles.Lookup#unreflect Lookup.unreflect}. * The resulting method handles generally provide more direct and efficient * access to the underlying class members. *

    @@ -398,9 +387,9 @@ mh.invokeExact(System.out, "Hello, world."); * they will throw {@code UnsupportedOperationException}. *

    * In order to obtain an invoker method for a particular type descriptor, - * use {@link java.dyn.MethodHandles#exactInvoker MethodHandles.exactInvoker}, - * or {@link java.dyn.MethodHandles#genericInvoker MethodHandles.genericInvoker}. - * The {@link java.dyn.MethodHandles.Lookup#findVirtual Lookup.findVirtual} + * use {@link java.lang.invoke.MethodHandles#exactInvoker MethodHandles.exactInvoker}, + * or {@link java.lang.invoke.MethodHandles#genericInvoker MethodHandles.genericInvoker}. + * The {@link java.lang.invoke.MethodHandles.Lookup#findVirtual Lookup.findVirtual} * API is also able to return a method handle * to call {@code invokeExact} or {@code invokeGeneric}, * for any specified type descriptor . @@ -436,12 +425,35 @@ mh.invokeExact(System.out, "Hello, world."); * @see MethodHandles * @author John Rose, JSR 292 EG */ -public abstract class MethodHandle - // Note: This is an implementation inheritance hack, and will be removed - // with a JVM change which moves the required hidden state onto this class. - extends MethodHandleImpl -{ - private static Access IMPL_TOKEN = Access.getToken(); +public abstract class MethodHandle { + // { JVM internals: + + private byte vmentry; // adapter stub or method entry point + //private int vmslots; // optionally, hoist type.form.vmslots + /*non-public*/ Object vmtarget; // VM-specific, class-specific target value + + // TO DO: vmtarget should be invisible to Java, since the JVM puts internal + // managed pointers into it. Making it visible exposes it to debuggers, + // which can cause errors when they treat the pointer as an Object. + + // These two dummy fields are present to force 'I' and 'J' signatures + // into this class's constant pool, so they can be transferred + // to vmentry when this class is loaded. + static final int INT_FIELD = 0; + static final long LONG_FIELD = 0; + + // vmentry (a void* field) is used *only* by the JVM. + // The JVM adjusts its type to int or long depending on system wordsize. + // Since it is statically typed as neither int nor long, it is impossible + // to use this field from Java bytecode. (Please don't try to, either.) + + // The vmentry is an assembly-language stub which is jumped to + // immediately after the method type is verified. + // For a direct MH, this stub loads the vmtarget's entry point + // and jumps to it. + + // } End of JVM internals. + static { MethodHandleImpl.initStatics(); } // interface MethodHandle @@ -458,7 +470,7 @@ public abstract class MethodHandle private MethodType type; /** - * Report the type of this method handle. + * Reports the type of this method handle. * Every invocation of this method handle via {@code invokeExact} must exactly match this type. * @return the method handle type */ @@ -467,39 +479,18 @@ public abstract class MethodHandle } /** - * CONSTRUCTOR WILL BE REMOVED FOR PFD: - * Temporary constructor in early versions of the Reference Implementation. - * Method handle inheritance (if any) will be contained completely within - * the {@code java.dyn} package. + * Package-private constructor for the method handle implementation hierarchy. + * Method handle inheritance will be contained completely within + * the {@code java.lang.invoke} package. */ - // The constructor for MethodHandle may only be called by privileged code. - // Subclasses may be in other packages, but must possess - // a token which they obtained from MH with a security check. - // @param token non-null object which proves access permission // @param type type (permanently assigned) of the new method handle - protected MethodHandle(Access token, MethodType type) { - super(token); - Access.check(token); - this.type = type; - } - - private void initType(MethodType type) { + /*non-public*/ MethodHandle(MethodType type) { type.getClass(); // elicit NPE - if (this.type != null) throw new InternalError(); this.type = type; } - static { - // This hack allows the implementation package special access to - // the internals of MethodHandle. In particular, the MTImpl has all sorts - // of cached information useful to the implementation code. - MethodHandleImpl.setMethodHandleFriend(IMPL_TOKEN, new MethodHandleImpl.MethodHandleFriend() { - public void initType(MethodHandle mh, MethodType type) { mh.initType(type); } - }); - } - /** - * Invoke the method handle, allowing any caller type descriptor, but requiring an exact type match. + * Invokes the method handle, allowing any caller type descriptor, but requiring an exact type match. * The type descriptor at the call site of {@code invokeExact} must * exactly match this method handle's {@link #type type}. * No conversions are allowed on arguments or return values. @@ -508,7 +499,7 @@ public abstract class MethodHandle * it will appear as a single native method, taking an object array and returning an object. * If this native method is invoked directly via * {@link java.lang.reflect.Method#invoke Method.invoke}, via JNI, - * or indirectly via {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect}, + * or indirectly via {@link java.lang.invoke.MethodHandles.Lookup#unreflect Lookup.unreflect}, * it will throw an {@code UnsupportedOperationException}. * @throws WrongMethodTypeException if the target's type is not identical with the caller's type descriptor * @throws Throwable anything thrown by the underlying method propagates unchanged through the method handle call @@ -516,7 +507,7 @@ public abstract class MethodHandle public final native @PolymorphicSignature Object invokeExact(Object... args) throws Throwable; /** - * Invoke the method handle, allowing any caller type descriptor, + * Invokes the method handle, allowing any caller type descriptor, * and optionally performing conversions on arguments and return values. *

    * If the call site type descriptor exactly matches this method handle's {@link #type type}, @@ -542,7 +533,7 @@ public abstract class MethodHandle * it will appear as a single native method, taking an object array and returning an object. * If this native method is invoked directly via * {@link java.lang.reflect.Method#invoke Method.invoke}, via JNI, - * or indirectly via {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect}, + * or indirectly via {@link java.lang.invoke.MethodHandles.Lookup#unreflect Lookup.unreflect}, * it will throw an {@code UnsupportedOperationException}. * @throws WrongMethodTypeException if the target's type cannot be adjusted to the caller's type descriptor * @throws ClassCastException if the target's type can be adjusted to the caller, but a reference cast fails @@ -551,7 +542,7 @@ public abstract class MethodHandle public final native @PolymorphicSignature Object invokeGeneric(Object... args) throws Throwable; /** - * Perform a varargs invocation, passing the arguments in the given array + * Performs a varargs invocation, passing the arguments in the given array * to the method handle, as if via {@link #invokeGeneric invokeGeneric} from a call site * which mentions only the type {@code Object}, and whose arity is the length * of the argument array. @@ -608,7 +599,7 @@ public abstract class MethodHandle return asType(MethodType.genericMethodType(argc)).invokeWithArguments(arguments); } if (argc <= 10) { - MethodHandle invoker = invokers(type).genericInvoker(); + MethodHandle invoker = type.invokers().genericInvoker(); switch (argc) { case 0: return invoker.invokeExact(this); case 1: return invoker.invokeExact(this, @@ -647,17 +638,34 @@ public abstract class MethodHandle } // more than ten arguments get boxed in a varargs list: - MethodHandle invoker = invokers(type).spreadInvoker(0); + MethodHandle invoker = type.invokers().spreadInvoker(0); return invoker.invokeExact(this, arguments); } - /** Equivalent to {@code invokeWithArguments(arguments.toArray())}. */ + + /** + * Performs a varargs invocation, passing the arguments in the given array + * to the method handle, as if via {@link #invokeGeneric invokeGeneric} from a call site + * which mentions only the type {@code Object}, and whose arity is the length + * of the argument array. + *

    + * This method is also equivalent to the following code: + *

    +     * {@link #invokeWithArguments(Object...) invokeWithArguments}(arguments.toArray())
    +     * 
    + * + * @param arguments the arguments to pass to the target + * @return the result returned by the target + * @throws ClassCastException if an argument cannot be converted by reference casting + * @throws WrongMethodTypeException if the target's type cannot be adjusted to take the given number of {@code Object} arguments + * @throws Throwable anything thrown by the target method invocation + */ public Object invokeWithArguments(java.util.List arguments) throws Throwable { return invokeWithArguments(arguments.toArray()); } /** - * Produce an adapter method handle which adapts the type of the - * current method handle to a new type + * Produces an adapter method handle which adapts the type of the + * current method handle to a new type. * The resulting method handle is guaranteed to report a type * which is equal to the desired new type. *

    @@ -685,7 +693,7 @@ public abstract class MethodHandle } /** - * Make an adapter which accepts a trailing array argument + * Makes an adapter which accepts a trailing array argument * and spreads its elements as positional arguments. * The new method handle adapts, as its target, * the current method handle. The type of the adapter will be @@ -733,7 +741,7 @@ public abstract class MethodHandle } /** - * Make an adapter which accepts a given number of trailing + * Makes an adapter which accepts a given number of trailing * positional arguments and collects them into an array argument. * The new method handle adapts, as its target, * the current method handle. The type of the adapter will be @@ -784,7 +792,7 @@ public abstract class MethodHandle } /** - * Make a variable arity adapter which is able to accept + * Makes a variable arity adapter which is able to accept * any number of trailing positional arguments and collect them * into an array argument. *

    @@ -942,12 +950,12 @@ assert(failed); } /** - * Determine if this method handle + * Determines if this method handle * supports {@linkplain #asVarargsCollector variable arity} calls. * Such method handles arise from the following sources: *

      *
    • a call to {@linkplain #asVarargsCollector asVarargsCollector} - *
    • a call to a {@linkplain java.dyn.MethodHandles.Lookup lookup method} + *
    • a call to a {@linkplain java.lang.invoke.MethodHandles.Lookup lookup method} * which resolves to a variable arity Java method or constructor *
    • an {@code ldc} instruction of a {@code CONSTANT_MethodHandle} * which resolves to a variable arity Java method or constructor @@ -960,9 +968,9 @@ assert(failed); } /** - * Bind a value {@code x} to the first argument of a method handle, without invoking it. + * Binds a value {@code x} to the first argument of a method handle, without invoking it. * The new method handle adapts, as its target, - * to the current method handle. + * the current method handle by binding it to the given argument. * The type of the bound handle will be * the same as the type of the target, except that a single leading * reference parameter will be omitted. @@ -974,9 +982,12 @@ assert(failed); *

      * The reference {@code x} must be convertible to the first parameter * type of the target. + *

      + * (Note: Because method handles are immutable, the target method handle + * retains its original type and behavior.) * @param x the value to bind to the first argument of the target - * @return a new method handle which collects some trailing argument - * into an array, before calling the original method handle + * @return a new method handle which prepends the given value to the incoming + * argument list, before calling the original method handle * @throws IllegalArgumentException if the target does not have a * leading parameter type that is a reference type * @throws ClassCastException if {@code x} cannot be converted @@ -984,7 +995,15 @@ assert(failed); * @see MethodHandles#insertArguments */ public MethodHandle bindTo(Object x) { - return MethodHandles.insertArguments(this, 0, x); + Class ptype; + if (type().parameterCount() == 0 || + (ptype = type().parameterType(0)).isPrimitive()) + throw newIllegalArgumentException("no leading reference parameter", x); + x = MethodHandles.checkValue(ptype, x); + // Cf. MethodHandles.insertArguments for the following logic: + MethodHandle bmh = MethodHandleImpl.bindReceiver(this, x); + if (bmh != null) return bmh; + return MethodHandleImpl.bindArgument(this, 0, x); } /** @@ -996,14 +1015,14 @@ assert(failed); * "MethodHandle" + type().toString() * *

      - * Note: Future releases of this API may add further information + * (Note: Future releases of this API may add further information * to the string representation. - * Therefore, the present syntax should not be parsed by applications. + * Therefore, the present syntax should not be parsed by applications.) * * @return a string representation of the method handle */ @Override public String toString() { - return MethodHandleImpl.getNameString(IMPL_TOKEN, this); + return getNameString(this); } } diff --git a/src/share/classes/sun/dyn/MethodHandleImpl.java b/src/share/classes/java/lang/invoke/MethodHandleImpl.java similarity index 78% rename from src/share/classes/sun/dyn/MethodHandleImpl.java rename to src/share/classes/java/lang/invoke/MethodHandleImpl.java index eab4923540e73672c69571b2a2da93480888375a..e82442092fe0b42001167fd36cb003eb0be45fa5 100644 --- a/src/share/classes/sun/dyn/MethodHandleImpl.java +++ b/src/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -23,136 +23,36 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; -import java.dyn.MethodHandles.Lookup; -import java.util.logging.Level; -import java.util.logging.Logger; -import sun.dyn.util.VerifyType; +import sun.invoke.util.VerifyType; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import sun.dyn.empty.Empty; -import sun.dyn.util.ValueConversions; -import sun.dyn.util.Wrapper; +import sun.invoke.empty.Empty; +import sun.invoke.util.ValueConversions; +import sun.invoke.util.Wrapper; import sun.misc.Unsafe; -import static sun.dyn.MemberName.newIllegalArgumentException; -import static sun.dyn.MemberName.newNoAccessException; -import static sun.dyn.MemberName.uncaughtException; +import static java.lang.invoke.MethodHandleStatics.*; +import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /** - * Base class for method handles, containing JVM-specific fields and logic. - * TO DO: It should not be a base class. + * Trusted implementation code for MethodHandle. * @author jrose */ -public abstract class MethodHandleImpl { - - // Fields which really belong in MethodHandle: - private byte vmentry; // adapter stub or method entry point - //private int vmslots; // optionally, hoist type.form.vmslots - protected Object vmtarget; // VM-specific, class-specific target value - //MethodType type; // defined in MethodHandle - - // TO DO: vmtarget should be invisible to Java, since the JVM puts internal - // managed pointers into it. Making it visible exposes it to debuggers, - // which can cause errors when they treat the pointer as an Object. - - // These two dummy fields are present to force 'I' and 'J' signatures - // into this class's constant pool, so they can be transferred - // to vmentry when this class is loaded. - static final int INT_FIELD = 0; - static final long LONG_FIELD = 0; - - /** Access methods for the internals of MethodHandle, supplied to - * MethodHandleImpl as a trusted agent. - */ - static public interface MethodHandleFriend { - void initType(MethodHandle mh, MethodType type); - } - public static void setMethodHandleFriend(Access token, MethodHandleFriend am) { - Access.check(token); - if (METHOD_HANDLE_FRIEND != null) - throw new InternalError(); // just once - METHOD_HANDLE_FRIEND = am; - } - static private MethodHandleFriend METHOD_HANDLE_FRIEND; - - // NOT public - static void initType(MethodHandle mh, MethodType type) { - METHOD_HANDLE_FRIEND.initType(mh, type); - } - - // type is defined in java.dyn.MethodHandle, which is platform-independent - - // vmentry (a void* field) is used *only* by by the JVM. - // The JVM adjusts its type to int or long depending on system wordsize. - // Since it is statically typed as neither int nor long, it is impossible - // to use this field from Java bytecode. (Please don't try to, either.) - - // The vmentry is an assembly-language stub which is jumped to - // immediately after the method type is verified. - // For a direct MH, this stub loads the vmtarget's entry point - // and jumps to it. - - /** - * VM-based method handles must have a security token. - * This security token can only be obtained by trusted code. - * Do not create method handles directly; use factory methods. - */ - public MethodHandleImpl(Access token) { - Access.check(token); - } - - /** Initialize the method type form to participate in JVM calls. - * This is done once for each erased type. - */ - public static void init(Access token, MethodType self) { - Access.check(token); - if (MethodHandleNatives.JVM_SUPPORT) - MethodHandleNatives.init(self); - } - +/*non-public*/ abstract class MethodHandleImpl { /// Factory methods to create method handles: private static final MemberName.Factory LOOKUP = MemberName.Factory.INSTANCE; - static private Lookup IMPL_LOOKUP_INIT; - - public static void initLookup(Access token, Lookup lookup) { - Access.check(token); - if (IMPL_LOOKUP_INIT != null) - throw new InternalError(); - IMPL_LOOKUP_INIT = lookup; - } - - public static Lookup getLookup(Access token) { - Access.check(token); - return IMPL_LOOKUP; - } - - static { - if (!MethodHandleNatives.JVM_SUPPORT) // force init of native API - throw new InternalError("No JVM support for JSR 292"); - // Force initialization of Lookup, so it calls us back as initLookup: - MethodHandles.publicLookup(); - if (IMPL_LOOKUP_INIT == null) - throw new InternalError(); - } - - public static void initStatics() { + static void initStatics() { // Trigger preceding sequence. } - /** Shared secret with MethodHandles.Lookup, a copy of Lookup.IMPL_LOOKUP. */ - static final Lookup IMPL_LOOKUP = IMPL_LOOKUP_INIT; - - /** Look up a given method. - * Callable only from java.dyn and related packages. + * Callable only from sun.invoke and related packages. *

      * The resulting method handle type will be of the given type, * with a receiver type {@code rcvc} prepended if the member is not static. @@ -170,10 +70,9 @@ public abstract class MethodHandleImpl { * @return a direct handle to the matching method * @throws IllegalAccessException if the given method cannot be accessed by the lookup class */ - public static - MethodHandle findMethod(Access token, MemberName method, + static + MethodHandle findMethod(MemberName method, boolean doDispatch, Class lookupClass) throws IllegalAccessException { - Access.check(token); // only trusted calls MethodType mtype = method.getMethodType(); if (!method.isStatic()) { // adjust the advertised receiver type to be exactly the one requested @@ -183,7 +82,7 @@ public abstract class MethodHandleImpl { } DirectMethodHandle mh = new DirectMethodHandle(mtype, method, doDispatch, lookupClass); if (!mh.isValid()) - throw newNoAccessException(method, lookupClass); + throw method.makeAccessException("no access", lookupClass); assert(mh.type() == mtype); if (!method.isVarargs()) return mh; @@ -191,13 +90,12 @@ public abstract class MethodHandleImpl { return mh.asVarargsCollector(mtype.parameterType(mtype.parameterCount()-1)); } - public static - MethodHandle makeAllocator(Access token, MethodHandle rawConstructor) { - Access.check(token); + static + MethodHandle makeAllocator(MethodHandle rawConstructor) { MethodType rawConType = rawConstructor.type(); // Wrap the raw (unsafe) constructor with the allocation of a suitable object. MethodHandle allocator - = AllocateObject.make(token, rawConType.parameterType(0), rawConstructor); + = AllocateObject.make(rawConType.parameterType(0), rawConstructor); assert(allocator.type() .equals(rawConType.dropParameterTypes(0, 1).changeReturnType(rawConType.parameterType(0)))); return allocator; @@ -211,13 +109,11 @@ public abstract class MethodHandleImpl { private AllocateObject(MethodHandle invoker, Class allocateClass, MethodHandle rawConstructor) { - super(Access.TOKEN, invoker); + super(invoker); this.allocateClass = allocateClass; this.rawConstructor = rawConstructor; } - static MethodHandle make(Access token, - Class allocateClass, MethodHandle rawConstructor) { - Access.check(token); + static MethodHandle make(Class allocateClass, MethodHandle rawConstructor) { MethodType rawConType = rawConstructor.type(); assert(rawConType.parameterType(0) == allocateClass); MethodType newType = rawConType.dropParameterTypes(0, 1).changeReturnType(allocateClass); @@ -225,18 +121,18 @@ public abstract class MethodHandleImpl { if (nargs < INVOKES.length) { MethodHandle invoke = INVOKES[nargs]; MethodType conType = CON_TYPES[nargs]; - MethodHandle gcon = convertArguments(token, rawConstructor, conType, rawConType, null); + MethodHandle gcon = convertArguments(rawConstructor, conType, rawConType, null); if (gcon == null) return null; MethodHandle galloc = new AllocateObject(invoke, allocateClass, gcon); assert(galloc.type() == newType.generic()); - return convertArguments(token, galloc, newType, galloc.type(), null); + return convertArguments(galloc, newType, galloc.type(), null); } else { MethodHandle invoke = VARARGS_INVOKE; MethodType conType = CON_TYPES[nargs]; - MethodHandle gcon = spreadArguments(token, rawConstructor, conType, 1); + MethodHandle gcon = spreadArguments(rawConstructor, conType, 1); if (gcon == null) return null; MethodHandle galloc = new AllocateObject(invoke, allocateClass, gcon); - return collectArguments(token, galloc, newType, 1, null); + return collectArguments(galloc, newType, 1, null); } } @Override @@ -338,20 +234,16 @@ public abstract class MethodHandleImpl { } } - public static - MethodHandle accessField(Access token, - MemberName member, boolean isSetter, + static + MethodHandle accessField(MemberName member, boolean isSetter, Class lookupClass) { - Access.check(token); // Use sun. misc.Unsafe to dig up the dirt on the field. - MethodHandle mh = new FieldAccessor(token, member, isSetter); + MethodHandle mh = new FieldAccessor(member, isSetter); return mh; } - public static - MethodHandle accessArrayElement(Access token, - Class arrayClass, boolean isSetter) { - Access.check(token); + static + MethodHandle accessArrayElement(Class arrayClass, boolean isSetter) { if (!arrayClass.isArray()) throw newIllegalArgumentException("not an array: "+arrayClass); Class elemClass = arrayClass.getComponentType(); @@ -379,12 +271,13 @@ public abstract class MethodHandleImpl { final long offset; final String name; - public FieldAccessor(Access token, MemberName field, boolean isSetter) { - super(Access.TOKEN, fhandle(field.getDeclaringClass(), field.getFieldType(), isSetter, field.isStatic())); - this.offset = (long) field.getVMIndex(token); + FieldAccessor(MemberName field, boolean isSetter) { + super(fhandle(field.getDeclaringClass(), field.getFieldType(), isSetter, field.isStatic())); + this.offset = (long) field.getVMIndex(); this.name = field.getName(); this.base = staticBase(field); } + @Override public String toString() { return addTypeString(name, this); } int getFieldI(C obj) { return unsafe.getInt(obj, offset); } @@ -560,10 +453,8 @@ public abstract class MethodHandleImpl { * @param receiver Receiver (or first static method argument) to pre-bind. * @return a BoundMethodHandle for the given DirectMethodHandle, or null if it does not exist */ - public static - MethodHandle bindReceiver(Access token, - MethodHandle target, Object receiver) { - Access.check(token); + static + MethodHandle bindReceiver(MethodHandle target, Object receiver) { if (target instanceof AdapterMethodHandle && ((AdapterMethodHandle)target).conversionOp() == MethodHandleNatives.Constants.OP_RETYPE_ONLY ) { @@ -574,7 +465,7 @@ public abstract class MethodHandleImpl { dmh.type().parameterType(0).isAssignableFrom(receiver.getClass())) { MethodHandle bmh = new BoundMethodHandle(dmh, receiver, 0); MethodType newType = target.type().dropParameterTypes(0, 1); - return convertArguments(token, bmh, newType, bmh.type(), null); + return convertArguments(bmh, newType, bmh.type(), null); } } } @@ -590,19 +481,15 @@ public abstract class MethodHandleImpl { * @param receiver Argument (which can be a boxed primitive) to pre-bind. * @return a suitable BoundMethodHandle */ - public static - MethodHandle bindArgument(Access token, - MethodHandle target, int argnum, Object receiver) { - Access.check(token); + static + MethodHandle bindArgument(MethodHandle target, int argnum, Object receiver) { return new BoundMethodHandle(target, receiver, argnum); } - public static MethodHandle convertArguments(Access token, - MethodHandle target, + static MethodHandle convertArguments(MethodHandle target, MethodType newType, MethodType oldType, int[] permutationOrNull) { - Access.check(token); assert(oldType.parameterCount() == target.type().parameterCount()); if (permutationOrNull != null) { int outargs = oldType.parameterCount(), inargs = newType.parameterCount(); @@ -613,7 +500,7 @@ public abstract class MethodHandleImpl { for (int i = 0; i < outargs; i++) callTypeArgs[i] = newType.parameterType(permutationOrNull[i]); MethodType callType = MethodType.methodType(oldType.returnType(), callTypeArgs); - target = convertArguments(token, target, callType, oldType, null); + target = convertArguments(target, callType, oldType, null); assert(target != null); oldType = target.type(); List goal = new ArrayList(); // i*TOKEN @@ -710,7 +597,7 @@ public abstract class MethodHandleImpl { Collections.rotate(ptypes.subList(rotBeg, rotEnd+1), -rotBy); MethodType rotType = MethodType.methodType(oldType.returnType(), ptypes); MethodHandle nextTarget - = AdapterMethodHandle.makeRotateArguments(token, rotType, target, + = AdapterMethodHandle.makeRotateArguments(rotType, target, rotBeg, rotSpan.size(), rotBy); if (nextTarget != null) { //System.out.println("Rot: "+rotSpan+" by "+rotBy); @@ -733,7 +620,7 @@ public abstract class MethodHandleImpl { int j = state.indexOf(arg); Collections.swap(ptypes, i, j); MethodType swapType = MethodType.methodType(oldType.returnType(), ptypes); - target = AdapterMethodHandle.makeSwapArguments(token, swapType, target, i, j); + target = AdapterMethodHandle.makeSwapArguments(swapType, target, i, j); if (target == null) throw newIllegalArgumentException("cannot swap"); assert(target.type() == swapType); oldType = swapType; @@ -760,7 +647,7 @@ public abstract class MethodHandleImpl { List> ptypes = oldType.parameterList(); ptypes = ptypes.subList(0, ptypes.size() - dupArgCount); MethodType dupType = MethodType.methodType(oldType.returnType(), ptypes); - target = AdapterMethodHandle.makeDupArguments(token, dupType, target, dupArgPos, dupArgCount); + target = AdapterMethodHandle.makeDupArguments(dupType, target, dupArgPos, dupArgCount); if (target == null) throw newIllegalArgumentException("cannot dup"); oldType = target.type(); @@ -778,7 +665,7 @@ public abstract class MethodHandleImpl { List> dropTypes = newType.parameterList() .subList(dropArgPos, dropArgPos + dropArgCount); MethodType dropType = oldType.insertParameterTypes(dropArgPos, dropTypes); - target = AdapterMethodHandle.makeDropArguments(token, dropType, target, dropArgPos, dropArgCount); + target = AdapterMethodHandle.makeDropArguments(dropType, target, dropArgPos, dropArgCount); if (target == null) throw newIllegalArgumentException("cannot drop"); oldType = target.type(); } @@ -787,7 +674,7 @@ public abstract class MethodHandleImpl { return target; if (oldType.parameterCount() != newType.parameterCount()) throw newIllegalArgumentException("mismatched parameter count"); - MethodHandle res = AdapterMethodHandle.makePairwiseConvert(token, newType, target); + MethodHandle res = AdapterMethodHandle.makePairwiseConvert(newType, target); if (res != null) return res; int argc = oldType.parameterCount(); @@ -797,26 +684,24 @@ public abstract class MethodHandleImpl { // then back to the desired types. We might have to use Java-based // method handles to do this. MethodType objType = MethodType.genericMethodType(argc); - MethodHandle objTarget = AdapterMethodHandle.makePairwiseConvert(token, objType, target); + MethodHandle objTarget = AdapterMethodHandle.makePairwiseConvert(objType, target); if (objTarget == null) objTarget = FromGeneric.make(target); - res = AdapterMethodHandle.makePairwiseConvert(token, newType, objTarget); + res = AdapterMethodHandle.makePairwiseConvert(newType, objTarget); if (res != null) return res; return ToGeneric.make(newType, objTarget); } - public static MethodHandle spreadArguments(Access token, - MethodHandle target, + static MethodHandle spreadArguments(MethodHandle target, MethodType newType, int spreadArg) { - Access.check(token); // TO DO: maybe allow the restarg to be Object and implicitly cast to Object[] MethodType oldType = target.type(); // spread the last argument of newType to oldType int spreadCount = oldType.parameterCount() - spreadArg; Class spreadArgType = Object[].class; - MethodHandle res = AdapterMethodHandle.makeSpreadArguments(token, newType, target, spreadArgType, spreadArg, spreadCount); + MethodHandle res = AdapterMethodHandle.makeSpreadArguments(newType, target, spreadArgType, spreadArg, spreadCount); if (res != null) return res; // try an intermediate adapter @@ -829,20 +714,19 @@ public abstract class MethodHandleImpl { ptypes[spreadArg + i] = VerifyType.spreadArgElementType(spreadType, i); MethodType midType = MethodType.methodType(newType.returnType(), ptypes); // after spreading, some arguments may need further conversion - MethodHandle target2 = convertArguments(token, target, midType, oldType, null); + MethodHandle target2 = convertArguments(target, midType, oldType, null); if (target2 == null) throw new UnsupportedOperationException("NYI: convert "+midType+" =calls=> "+oldType); - res = AdapterMethodHandle.makeSpreadArguments(token, newType, target2, spreadArgType, spreadArg, spreadCount); + res = AdapterMethodHandle.makeSpreadArguments(newType, target2, spreadArgType, spreadArg, spreadCount); if (res != null) return res; res = SpreadGeneric.make(target2, spreadCount); if (res != null) - res = convertArguments(token, res, newType, res.type(), null); + res = convertArguments(res, newType, res.type(), null); return res; } - public static MethodHandle collectArguments(Access token, - MethodHandle target, + static MethodHandle collectArguments(MethodHandle target, MethodType newType, int collectArg, MethodHandle collector) { @@ -856,29 +740,27 @@ public abstract class MethodHandleImpl { // oldType // (a..., b...)=>r assert(newType.parameterCount() == collectArg + colType.parameterCount()); assert(oldType.parameterCount() == collectArg + 1); - MethodHandle gtarget = convertArguments(token, target, oldType.generic(), oldType, null); - MethodHandle gcollector = convertArguments(token, collector, colType.generic(), colType, null); + MethodHandle gtarget = convertArguments(target, oldType.generic(), oldType, null); + MethodHandle gcollector = convertArguments(collector, colType.generic(), colType, null); if (gtarget == null || gcollector == null) return null; MethodHandle gresult = FilterGeneric.makeArgumentCollector(gcollector, gtarget); - MethodHandle result = convertArguments(token, gresult, newType, gresult.type(), null); + MethodHandle result = convertArguments(gresult, newType, gresult.type(), null); return result; } - public static MethodHandle filterArgument(Access token, - MethodHandle target, + static MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) { - Access.check(token); MethodType ttype = target.type(), gttype = ttype.generic(); if (ttype != gttype) { - target = convertArguments(token, target, gttype, ttype, null); + target = convertArguments(target, gttype, ttype, null); ttype = gttype; } MethodType ftype = filter.type(), gftype = ftype.generic(); if (ftype.parameterCount() != 1) throw new InternalError(); if (ftype != gftype) { - filter = convertArguments(token, filter, gftype, ftype, null); + filter = convertArguments(filter, gftype, ftype, null); ftype = gftype; } if (ftype == ttype) { @@ -888,27 +770,24 @@ public abstract class MethodHandleImpl { return FilterGeneric.makeArgumentFilter(pos, filter, target); } - public static MethodHandle foldArguments(Access token, - MethodHandle target, + static MethodHandle foldArguments(MethodHandle target, MethodType newType, MethodHandle combiner) { - Access.check(token); MethodType oldType = target.type(); MethodType ctype = combiner.type(); - MethodHandle gtarget = convertArguments(token, target, oldType.generic(), oldType, null); - MethodHandle gcombiner = convertArguments(token, combiner, ctype.generic(), ctype, null); + MethodHandle gtarget = convertArguments(target, oldType.generic(), oldType, null); + MethodHandle gcombiner = convertArguments(combiner, ctype.generic(), ctype, null); if (gtarget == null || gcombiner == null) return null; MethodHandle gresult = FilterGeneric.makeArgumentFolder(gcombiner, gtarget); - MethodHandle result = convertArguments(token, gresult, newType, gresult.type(), null); + MethodHandle result = convertArguments(gresult, newType, gresult.type(), null); return result; } - public static - MethodHandle dropArguments(Access token, MethodHandle target, + static + MethodHandle dropArguments(MethodHandle target, MethodType newType, int argnum) { - Access.check(token); int drops = newType.parameterCount() - target.type().parameterCount(); - MethodHandle res = AdapterMethodHandle.makeDropArguments(token, newType, target, argnum, drops); + MethodHandle res = AdapterMethodHandle.makeDropArguments(newType, target, argnum, drops); if (res != null) return res; throw new UnsupportedOperationException("NYI"); @@ -918,36 +797,34 @@ public abstract class MethodHandleImpl { private final MethodHandle test, target, fallback; private GuardWithTest(MethodHandle invoker, MethodHandle test, MethodHandle target, MethodHandle fallback) { - super(Access.TOKEN, invoker); + super(invoker); this.test = test; this.target = target; this.fallback = fallback; } - static MethodHandle make(Access token, - MethodHandle test, MethodHandle target, MethodHandle fallback) { - Access.check(token); + static MethodHandle make(MethodHandle test, MethodHandle target, MethodHandle fallback) { MethodType type = target.type(); int nargs = type.parameterCount(); if (nargs < INVOKES.length) { MethodHandle invoke = INVOKES[nargs]; MethodType gtype = type.generic(); assert(invoke.type().dropParameterTypes(0,1) == gtype); - MethodHandle gtest = convertArguments(token, test, gtype.changeReturnType(boolean.class), test.type(), null); - MethodHandle gtarget = convertArguments(token, target, gtype, type, null); - MethodHandle gfallback = convertArguments(token, fallback, gtype, type, null); + MethodHandle gtest = convertArguments(test, gtype.changeReturnType(boolean.class), test.type(), null); + MethodHandle gtarget = convertArguments(target, gtype, type, null); + MethodHandle gfallback = convertArguments(fallback, gtype, type, null); if (gtest == null || gtarget == null || gfallback == null) return null; MethodHandle gguard = new GuardWithTest(invoke, gtest, gtarget, gfallback); - return convertArguments(token, gguard, type, gtype, null); + return convertArguments(gguard, type, gtype, null); } else { MethodHandle invoke = VARARGS_INVOKE; MethodType gtype = MethodType.genericMethodType(1); assert(invoke.type().dropParameterTypes(0,1) == gtype); - MethodHandle gtest = spreadArguments(token, test, gtype.changeReturnType(boolean.class), 0); - MethodHandle gtarget = spreadArguments(token, target, gtype, 0); - MethodHandle gfallback = spreadArguments(token, fallback, gtype, 0); + MethodHandle gtest = spreadArguments(test, gtype.changeReturnType(boolean.class), 0); + MethodHandle gtarget = spreadArguments(target, gtype, 0); + MethodHandle gfallback = spreadArguments(fallback, gtype, 0); MethodHandle gguard = new GuardWithTest(invoke, gtest, gtarget, gfallback); if (gtest == null || gtarget == null || gfallback == null) return null; - return collectArguments(token, gguard, type, 0, null); + return collectArguments(gguard, type, 0, null); } } @Override @@ -1034,24 +911,23 @@ public abstract class MethodHandleImpl { } } - public static - MethodHandle makeGuardWithTest(Access token, - MethodHandle test, + static + MethodHandle makeGuardWithTest(MethodHandle test, MethodHandle target, MethodHandle fallback) { - return GuardWithTest.make(token, test, target, fallback); + return GuardWithTest.make(test, target, fallback); } private static class GuardWithCatch extends BoundMethodHandle { private final MethodHandle target; private final Class exType; private final MethodHandle catcher; - public GuardWithCatch(MethodHandle target, Class exType, MethodHandle catcher) { + GuardWithCatch(MethodHandle target, Class exType, MethodHandle catcher) { this(INVOKES[target.type().parameterCount()], target, exType, catcher); } - public GuardWithCatch(MethodHandle invoker, - MethodHandle target, Class exType, MethodHandle catcher) { - super(Access.TOKEN, invoker); + GuardWithCatch(MethodHandle invoker, + MethodHandle target, Class exType, MethodHandle catcher) { + super(invoker); this.target = target; this.exType = exType; this.catcher = catcher; @@ -1171,42 +1047,40 @@ public abstract class MethodHandleImpl { } - public static - MethodHandle makeGuardWithCatch(Access token, - MethodHandle target, + static + MethodHandle makeGuardWithCatch(MethodHandle target, Class exType, MethodHandle catcher) { - Access.check(token); MethodType type = target.type(); MethodType ctype = catcher.type(); int nargs = type.parameterCount(); if (nargs < GuardWithCatch.INVOKES.length) { MethodType gtype = type.generic(); MethodType gcatchType = gtype.insertParameterTypes(0, Throwable.class); - MethodHandle gtarget = convertArguments(token, target, gtype, type, null); - MethodHandle gcatcher = convertArguments(token, catcher, gcatchType, ctype, null); + MethodHandle gtarget = convertArguments(target, gtype, type, null); + MethodHandle gcatcher = convertArguments(catcher, gcatchType, ctype, null); MethodHandle gguard = new GuardWithCatch(gtarget, exType, gcatcher); if (gtarget == null || gcatcher == null || gguard == null) return null; - return convertArguments(token, gguard, type, gtype, null); + return convertArguments(gguard, type, gtype, null); } else { MethodType gtype = MethodType.genericMethodType(0, true); MethodType gcatchType = gtype.insertParameterTypes(0, Throwable.class); - MethodHandle gtarget = spreadArguments(token, target, gtype, 0); - MethodHandle gcatcher = spreadArguments(token, catcher, gcatchType, 1); + MethodHandle gtarget = spreadArguments(target, gtype, 0); + MethodHandle gcatcher = spreadArguments(catcher, gcatchType, 1); MethodHandle gguard = new GuardWithCatch(GuardWithCatch.VARARGS_INVOKE, gtarget, exType, gcatcher); if (gtarget == null || gcatcher == null || gguard == null) return null; - return collectArguments(token, gguard, type, 0, null); + return collectArguments(gguard, type, 0, null); } } - public static - MethodHandle throwException(Access token, MethodType type) { - Access.check(token); - return AdapterMethodHandle.makeRetypeRaw(token, type, THROW_EXCEPTION); + static + MethodHandle throwException(MethodType type) { + return AdapterMethodHandle.makeRetypeRaw(type, throwException()); } - static final MethodHandle THROW_EXCEPTION; - static { + static MethodHandle THROW_EXCEPTION; + static MethodHandle throwException() { + if (THROW_EXCEPTION != null) return THROW_EXCEPTION; try { THROW_EXCEPTION = IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "throwException", @@ -1214,71 +1088,19 @@ public abstract class MethodHandleImpl { } catch (ReflectiveOperationException ex) { throw new RuntimeException(ex); } + return THROW_EXCEPTION; } static Empty throwException(T t) throws T { throw t; } - public static String getNameString(Access token, MethodHandle target, Object type) { - Access.check(token); - if (!(type instanceof MethodType)) { - if (type == null) - type = target.type(); - else if (type instanceof MethodHandle) - type = ((MethodHandle)type).type(); - } - MemberName name = null; - if (target != null) - name = MethodHandleNatives.getMethodName(target); - if (name == null) - return "invoke" + type; - return name.getName() + type; - } - - public static String getNameString(Access token, MethodHandle target) { - return getNameString(token, target, null); - } - - static String addTypeString(Object obj, MethodHandle target) { - String str = String.valueOf(obj); - if (target == null) return str; - int paren = str.indexOf('('); - if (paren >= 0) str = str.substring(0, paren); - return str + target.type(); - } - - static void checkSpreadArgument(Object av, int n) { - if (av == null ? n != 0 : ((Object[])av).length != n) - throw newIllegalArgumentException("Array is not of length "+n); - } - - static void raiseException(int code, Object actual, Object required) { - String message; - // disregard the identity of the actual object, if it is not a class: - if (!(actual instanceof Class) && !(actual instanceof MethodType)) - actual = actual.getClass(); - if (actual != null) - message = "required "+required+" but encountered "+actual; - else - message = "required "+required; - switch (code) { - case 192: // checkcast - throw new ClassCastException(message); - default: - throw new InternalError("unexpected code "+code+": "+message); - } - } - // Linkage support: - public static void registerBootstrap(Access token, Class callerClass, MethodHandle bootstrapMethod) { - Access.check(token); + static void registerBootstrap(Class callerClass, MethodHandle bootstrapMethod) { MethodHandleNatives.registerBootstrap(callerClass, bootstrapMethod); } - public static MethodHandle getBootstrap(Access token, Class callerClass) { - Access.check(token); + static MethodHandle getBootstrap(Class callerClass) { return MethodHandleNatives.getBootstrap(callerClass); } - public static MethodHandle asVarargsCollector(Access token, MethodHandle target, Class arrayType) { - Access.check(token); - return AdapterMethodHandle.makeVarargsCollector(token, target, arrayType); + static MethodHandle asVarargsCollector(MethodHandle target, Class arrayType) { + return AdapterMethodHandle.makeVarargsCollector(target, arrayType); } } diff --git a/src/share/classes/sun/dyn/MethodHandleNatives.java b/src/share/classes/java/lang/invoke/MethodHandleNatives.java similarity index 89% rename from src/share/classes/sun/dyn/MethodHandleNatives.java rename to src/share/classes/java/lang/invoke/MethodHandleNatives.java index 5f1076bff6aa6143b8a158c6a2eb13f433fd67ef..82d5d898638f7e4a3a6969fbae7857b973bdc460 100644 --- a/src/share/classes/sun/dyn/MethodHandleNatives.java +++ b/src/share/classes/java/lang/invoke/MethodHandleNatives.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,14 +23,13 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; -import java.dyn.MethodHandles.Lookup; +import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; -import static sun.dyn.MethodHandleNatives.Constants.*; -import static sun.dyn.MethodHandleImpl.IMPL_LOOKUP; +import static java.lang.invoke.MethodHandleNatives.Constants.*; +import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /** * The JVM interface for the method handles package is all here. @@ -81,14 +80,12 @@ class MethodHandleNatives { * This routine is for debugging and reflection. */ static MemberName getMethodName(MethodHandle self) { - if (!JVM_SUPPORT) return null; return (MemberName) getTarget(self, ETF_METHOD_NAME); } /** Fetch the reflective version of the handled method, if available. */ static AccessibleObject getTargetMethod(MethodHandle self) { - if (!JVM_SUPPORT) return null; return (AccessibleObject) getTarget(self, ETF_REFLECT_METHOD); } @@ -97,7 +94,6 @@ class MethodHandleNatives { * If it is chained to another method handle, return that handle. */ static Object getTargetInfo(MethodHandle self) { - if (!JVM_SUPPORT) return null; return getTarget(self, ETF_HANDLE_OR_METHOD_NAME); } @@ -111,11 +107,6 @@ class MethodHandleNatives { */ static native int getConstant(int which); - /** True iff this HotSpot JVM has built-in support for method handles. - * If false, some test cases might run, but functionality will be missing. - */ - public static final boolean JVM_SUPPORT; - /** Java copy of MethodHandlePushLimit in range 2..255. */ static final int JVM_PUSH_LIMIT; /** JVM stack motion (in words) after one slot is pushed, usually -1. @@ -127,31 +118,24 @@ class MethodHandleNatives { private static native void registerNatives(); static { - boolean JVM_SUPPORT_; int JVM_PUSH_LIMIT_; int JVM_STACK_MOVE_UNIT_; int CONV_OP_IMPLEMENTED_MASK_; try { registerNatives(); - JVM_SUPPORT_ = true; JVM_PUSH_LIMIT_ = getConstant(Constants.GC_JVM_PUSH_LIMIT); JVM_STACK_MOVE_UNIT_ = getConstant(Constants.GC_JVM_STACK_MOVE_UNIT); CONV_OP_IMPLEMENTED_MASK_ = getConstant(Constants.GC_CONV_OP_IMPLEMENTED_MASK); //sun.reflect.Reflection.registerMethodsToFilter(MethodHandleImpl.class, "init"); } catch (UnsatisfiedLinkError ee) { // ignore; if we use init() methods later we'll see linkage errors - JVM_SUPPORT_ = false; JVM_PUSH_LIMIT_ = 3; // arbitrary JVM_STACK_MOVE_UNIT_ = -1; // arbitrary CONV_OP_IMPLEMENTED_MASK_ = 0; - //System.out.println("Warning: Running with JVM_SUPPORT=false"); - //System.out.println(ee); - JVM_SUPPORT = JVM_SUPPORT_; JVM_PUSH_LIMIT = JVM_PUSH_LIMIT_; JVM_STACK_MOVE_UNIT = JVM_STACK_MOVE_UNIT_; throw ee; // just die; hopeless to try to run with an older JVM } - JVM_SUPPORT = JVM_SUPPORT_; JVM_PUSH_LIMIT = JVM_PUSH_LIMIT_; JVM_STACK_MOVE_UNIT = JVM_STACK_MOVE_UNIT_; if (CONV_OP_IMPLEMENTED_MASK_ == 0) @@ -189,9 +173,15 @@ class MethodHandleNatives { MN_SEARCH_INTERFACES = 0x00200000, // for MHN.getMembers VM_INDEX_UNINITIALIZED = -99; + // BoundMethodHandle + /** Constants for decoding the vmargslot field, which contains 2 values. */ + static final int + ARG_SLOT_PUSH_SHIFT = 16, + ARG_SLOT_MASK = (1< rtype, Class[] ptypes) { - MethodType.genericMethodType(0); // trigger initialization - return MethodTypeImpl.makeImpl(Access.TOKEN, rtype, ptypes, true); + return MethodType.makeImpl(rtype, ptypes, true); } /** * The JVM wants to use a MethodType with invokeGeneric. Give the runtime fair warning. */ static void notifyGenericMethodType(MethodType type) { - try { - // Trigger adapter creation. - InvokeGeneric.genericInvokerOf(type); - } catch (Exception ex) { - Error err = new InternalError("Exception while resolving invokeGeneric"); - err.initCause(ex); - throw err; + type.form().notifyGenericMethodType(); + } + + /** + * The JVM wants to raise an exception. Here's the path. + */ + static void raiseException(int code, Object actual, Object required) { + String message; + // disregard the identity of the actual object, if it is not a class: + if (!(actual instanceof Class) && !(actual instanceof MethodType)) + actual = actual.getClass(); + if (actual != null) + message = "required "+required+" but encountered "+actual; + else + message = "required "+required; + switch (code) { + case 192: // checkcast + throw new ClassCastException(message); + default: + throw new InternalError("unexpected code "+code+": "+message); } } diff --git a/src/share/classes/java/lang/invoke/MethodHandleStatics.java b/src/share/classes/java/lang/invoke/MethodHandleStatics.java new file mode 100644 index 0000000000000000000000000000000000000000..6ea8f978b63f1c4b22cd3f74b3e61d40ca8ef073 --- /dev/null +++ b/src/share/classes/java/lang/invoke/MethodHandleStatics.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.invoke; + +/** + * This class consists exclusively of static names internal to the + * method handle implementation. + * Usage: {@code import static java.lang.invoke.MethodHandleStatics.*} + * @author John Rose, JSR 292 EG + */ +/*non-public*/ class MethodHandleStatics { + + private MethodHandleStatics() { } // do not instantiate + + /*non-public*/ static String getNameString(MethodHandle target, MethodType type) { + if (type == null) + type = target.type(); + MemberName name = null; + if (target != null) + name = MethodHandleNatives.getMethodName(target); + if (name == null) + return "invoke" + type; + return name.getName() + type; + } + + /*non-public*/ static String getNameString(MethodHandle target, MethodHandle typeHolder) { + return getNameString(target, typeHolder == null ? (MethodType) null : typeHolder.type()); + } + + /*non-public*/ static String getNameString(MethodHandle target) { + return getNameString(target, (MethodType) null); + } + + /*non-public*/ static String addTypeString(Object obj, MethodHandle target) { + String str = String.valueOf(obj); + if (target == null) return str; + int paren = str.indexOf('('); + if (paren >= 0) str = str.substring(0, paren); + return str + target.type(); + } + + static void checkSpreadArgument(Object av, int n) { + if (av == null ? n != 0 : ((Object[])av).length != n) + throw newIllegalArgumentException("Array is not of length "+n); + } + + // handy shared exception makers (they simplify the common case code) + /*non-public*/ static RuntimeException newIllegalStateException(String message) { + return new IllegalStateException(message); + } + /*non-public*/ static RuntimeException newIllegalStateException(String message, Object obj) { + return new IllegalStateException(message(message, obj)); + } + /*non-public*/ static RuntimeException newIllegalArgumentException(String message) { + return new IllegalArgumentException(message); + } + /*non-public*/ static RuntimeException newIllegalArgumentException(String message, Object obj) { + return new IllegalArgumentException(message(message, obj)); + } + /*non-public*/ static Error uncaughtException(Exception ex) { + Error err = new InternalError("uncaught exception"); + err.initCause(ex); + return err; + } + private static String message(String message, Object obj) { + if (obj != null) message = message + ": " + obj; + return message; + } +} diff --git a/src/share/classes/java/dyn/MethodHandles.java b/src/share/classes/java/lang/invoke/MethodHandles.java similarity index 90% rename from src/share/classes/java/dyn/MethodHandles.java rename to src/share/classes/java/lang/invoke/MethodHandles.java index 3bc9bd4a327e9462de0fe5a5c06319d4d23dd2ed..12e36da623a4c47bf59289f74e8f49bc1e642996 100644 --- a/src/share/classes/java/dyn/MethodHandles.java +++ b/src/share/classes/java/lang/invoke/MethodHandles.java @@ -23,24 +23,18 @@ * questions. */ -package java.dyn; +package java.lang.invoke; import java.lang.reflect.*; -import sun.dyn.Access; -import sun.dyn.MemberName; -import sun.dyn.MethodHandleImpl; -import sun.dyn.WrapperInstance; -import sun.dyn.util.ValueConversions; -import sun.dyn.util.VerifyAccess; -import sun.dyn.util.Wrapper; +import sun.invoke.WrapperInstance; +import sun.invoke.util.ValueConversions; +import sun.invoke.util.VerifyAccess; +import sun.invoke.util.Wrapper; import java.util.List; import java.util.ArrayList; import java.util.Arrays; -import sun.dyn.Invokers; -import sun.dyn.MethodTypeImpl; import sun.reflect.Reflection; -import static sun.dyn.MemberName.newIllegalArgumentException; -import static sun.dyn.MemberName.newNoAccessException; +import static java.lang.invoke.MethodHandleStatics.*; /** * This class consists exclusively of static methods that operate on or return @@ -49,7 +43,7 @@ import static sun.dyn.MemberName.newNoAccessException; *

    • Lookup methods which help create method handles for methods and fields. *
    • Combinator methods, which combine or transform pre-existing method handles into new ones. *
    • Other factory methods to create method handles that emulate other common JVM operations or control flow patterns. - *
    • Wrapper methods which can convert between method handles and other function-like "SAM types". + *
    • Wrapper methods which can convert between method handles and interface types. *
    *

    * @author John Rose, JSR 292 EG @@ -58,15 +52,14 @@ public class MethodHandles { private MethodHandles() { } // do not instantiate - private static final Access IMPL_TOKEN = Access.getToken(); - private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory(IMPL_TOKEN); + private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory(); static { MethodHandleImpl.initStatics(); } // See IMPL_LOOKUP below. //// Method handle creation from ordinary methods. /** - * Return a {@link Lookup lookup object} on the caller, + * Returns a {@link Lookup lookup object} on the caller, * which has the capability to access any method handle that the caller has access to, * including direct method handles to private fields and methods. * This lookup object is a capability which may be delegated to trusted agents. @@ -77,7 +70,7 @@ public class MethodHandles { } /** - * Return a {@link Lookup lookup object} which is trusted minimally. + * Returns a {@link Lookup lookup object} which is trusted minimally. * It can only be used to create method handles to * publicly accessible fields and methods. *

    @@ -120,55 +113,55 @@ public class MethodHandles { * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * * - * + * * * *
    lookup expressionmemberbehavior
    {@linkplain java.dyn.MethodHandles.Lookup#findGetter lookup.findGetter(C.class,"f",FT.class)}{@linkplain java.lang.invoke.MethodHandles.Lookup#findGetter lookup.findGetter(C.class,"f",FT.class)}FT f;(T) this.f;
    {@linkplain java.dyn.MethodHandles.Lookup#findStaticGetter lookup.findStaticGetter(C.class,"f",FT.class)}{@linkplain java.lang.invoke.MethodHandles.Lookup#findStaticGetter lookup.findStaticGetter(C.class,"f",FT.class)}static
    FT f;
    (T) C.f;
    {@linkplain java.dyn.MethodHandles.Lookup#findSetter lookup.findSetter(C.class,"f",FT.class)}{@linkplain java.lang.invoke.MethodHandles.Lookup#findSetter lookup.findSetter(C.class,"f",FT.class)}FT f;this.f = x;
    {@linkplain java.dyn.MethodHandles.Lookup#findStaticSetter lookup.findStaticSetter(C.class,"f",FT.class)}{@linkplain java.lang.invoke.MethodHandles.Lookup#findStaticSetter lookup.findStaticSetter(C.class,"f",FT.class)}static
    FT f;
    C.f = arg;
    {@linkplain java.dyn.MethodHandles.Lookup#findVirtual lookup.findVirtual(C.class,"m",MT)}{@linkplain java.lang.invoke.MethodHandles.Lookup#findVirtual lookup.findVirtual(C.class,"m",MT)}T m(A*);(T) this.m(arg*);
    {@linkplain java.dyn.MethodHandles.Lookup#findStatic lookup.findStatic(C.class,"m",MT)}{@linkplain java.lang.invoke.MethodHandles.Lookup#findStatic lookup.findStatic(C.class,"m",MT)}static
    T m(A*);
    (T) C.m(arg*);
    {@linkplain java.dyn.MethodHandles.Lookup#findSpecial lookup.findSpecial(C.class,"m",MT,this.class)}{@linkplain java.lang.invoke.MethodHandles.Lookup#findSpecial lookup.findSpecial(C.class,"m",MT,this.class)}T m(A*);(T) super.m(arg*);
    {@linkplain java.dyn.MethodHandles.Lookup#findConstructor lookup.findConstructor(C.class,MT)}{@linkplain java.lang.invoke.MethodHandles.Lookup#findConstructor lookup.findConstructor(C.class,MT)}C(A*);(T) new C(arg*);
    {@linkplain java.dyn.MethodHandles.Lookup#unreflectGetter lookup.unreflectGetter(aField)}{@linkplain java.lang.invoke.MethodHandles.Lookup#unreflectGetter lookup.unreflectGetter(aField)}(static)?
    FT f;
    (FT) aField.get(thisOrNull);
    {@linkplain java.dyn.MethodHandles.Lookup#unreflectSetter lookup.unreflectSetter(aField)}{@linkplain java.lang.invoke.MethodHandles.Lookup#unreflectSetter lookup.unreflectSetter(aField)}(static)?
    FT f;
    aField.set(thisOrNull, arg);
    {@linkplain java.dyn.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}{@linkplain java.lang.invoke.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}(static)?
    T m(A*);
    (T) aMethod.invoke(thisOrNull, arg*);
    {@linkplain java.dyn.MethodHandles.Lookup#unreflectConstructor lookup.unreflectConstructor(aConstructor)}{@linkplain java.lang.invoke.MethodHandles.Lookup#unreflectConstructor lookup.unreflectConstructor(aConstructor)}C(A*);(C) aConstructor.newInstance(arg*);
    {@linkplain java.dyn.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}{@linkplain java.lang.invoke.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}(static)?
    T m(A*);
    (T) aMethod.invoke(thisOrNull, arg*);
    @@ -383,10 +376,10 @@ public class MethodHandles { * and {@linkplain #PACKAGE PACKAGE (0x08)}. *

    * A freshly-created lookup object - * on the {@linkplain java.dyn.MethodHandles#lookup() caller's class} + * on the {@linkplain java.lang.invoke.MethodHandles#lookup() caller's class} * has all possible bits set, since the caller class can access all its own members. * A lookup object on a new lookup class - * {@linkplain java.dyn.MethodHandles.Lookup#in created from a previous lookup object} + * {@linkplain java.lang.invoke.MethodHandles.Lookup#in created from a previous lookup object} * may have some mode bits set to zero. * The purpose of this is to restrict access via the new lookup object, * so that it can access only names which can be reached by the original @@ -410,9 +403,8 @@ public class MethodHandles { checkUnprivilegedlookupClass(lookupClass); } - Lookup(Access token, Class lookupClass) { + Lookup(Class lookupClass) { this(lookupClass, ALL_MODES); - Access.check(token); } private Lookup(Class lookupClass, int allowedModes) { @@ -471,7 +463,7 @@ public class MethodHandles { } // Make sure outer class is initialized first. - static { IMPL_TOKEN.getClass(); } + static { IMPL_NAMES.getClass(); } /** Version of lookup which is trusted minimally. * It can only be used to create method handles to @@ -481,11 +473,10 @@ public class MethodHandles { /** Package-private version of lookup which is trusted. */ static final Lookup IMPL_LOOKUP = new Lookup(Object.class, TRUSTED); - static { MethodHandleImpl.initLookup(IMPL_TOKEN, IMPL_LOOKUP); } private static void checkUnprivilegedlookupClass(Class lookupClass) { String name = lookupClass.getName(); - if (name.startsWith("java.dyn.") || name.startsWith("sun.dyn.")) + if (name.startsWith("java.lang.invoke.")) throw newIllegalArgumentException("illegal lookupClass: "+lookupClass); } @@ -506,8 +497,8 @@ public class MethodHandles { * access (public, package, private, and protected) is allowed. * In this case, no suffix is added. * This is true only of an object obtained originally from - * {@link java.dyn.MethodHandles#lookup MethodHandles.lookup}. - * Objects created by {@link java.dyn.MethodHandles.Lookup#in Lookup.in} + * {@link java.lang.invoke.MethodHandles#lookup MethodHandles.lookup}. + * Objects created by {@link java.lang.invoke.MethodHandles.Lookup#in Lookup.in} * always have restricted access, and will display a suffix. *

    * (It may seem strange that protected access should be @@ -577,7 +568,7 @@ public class MethodHandles { MethodHandle findStatic(Class refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException { MemberName method = resolveOrFail(refc, name, type, true); checkMethod(refc, method, true); - return MethodHandleImpl.findMethod(IMPL_TOKEN, method, false, lookupClassOrNull()); + return MethodHandleImpl.findMethod(method, false, lookupClassOrNull()); } /** @@ -601,8 +592,8 @@ public class MethodHandles { * if the class is {@code MethodHandle} and the name string is * {@code invokeExact} or {@code invokeGeneric}, the resulting * method handle is equivalent to one produced by - * {@link java.dyn.MethodHandles#exactInvoker MethodHandles.exactInvoker} or - * {@link java.dyn.MethodHandles#genericInvoker MethodHandles.genericInvoker} + * {@link java.lang.invoke.MethodHandles#exactInvoker MethodHandles.exactInvoker} or + * {@link java.lang.invoke.MethodHandles#genericInvoker MethodHandles.genericInvoker} * with the same {@code type} argument. * * @param refc the class or interface from which the method is accessed @@ -618,7 +609,7 @@ public class MethodHandles { public MethodHandle findVirtual(Class refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException { MemberName method = resolveOrFail(refc, name, type, false); checkMethod(refc, method, false); - MethodHandle mh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, true, lookupClassOrNull()); + MethodHandle mh = MethodHandleImpl.findMethod(method, true, lookupClassOrNull()); return restrictProtectedReceiver(method, mh); } @@ -651,8 +642,8 @@ public class MethodHandles { MemberName ctor = resolveOrFail(refc, name, type, false, false, lookupClassOrNull()); assert(ctor.isConstructor()); checkAccess(refc, ctor); - MethodHandle rawMH = MethodHandleImpl.findMethod(IMPL_TOKEN, ctor, false, lookupClassOrNull()); - MethodHandle allocMH = MethodHandleImpl.makeAllocator(IMPL_TOKEN, rawMH); + MethodHandle rawMH = MethodHandleImpl.findMethod(ctor, false, lookupClassOrNull()); + MethodHandle allocMH = MethodHandleImpl.makeAllocator(rawMH); return fixVarargs(allocMH, rawMH); } @@ -708,7 +699,7 @@ public class MethodHandles { checkSpecialCaller(specialCaller); MemberName method = resolveOrFail(refc, name, type, false, false, specialCaller); checkMethod(refc, method, false); - MethodHandle mh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, false, specialCaller); + MethodHandle mh = MethodHandleImpl.findMethod(method, false, specialCaller); return restrictReceiver(method, mh, specialCaller); } @@ -839,17 +830,17 @@ return mh1; Class refc = receiver.getClass(); // may get NPE MemberName method = resolveOrFail(refc, name, type, false); checkMethod(refc, method, false); - MethodHandle dmh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, true, lookupClassOrNull()); - MethodHandle bmh = MethodHandleImpl.bindReceiver(IMPL_TOKEN, dmh, receiver); + MethodHandle dmh = MethodHandleImpl.findMethod(method, true, lookupClassOrNull()); + MethodHandle bmh = MethodHandleImpl.bindReceiver(dmh, receiver); if (bmh == null) - throw newNoAccessException(method, this); + throw method.makeAccessException("no access", this); if (dmh.type().parameterCount() == 0) return dmh; // bound the trailing parameter; no varargs possible return fixVarargs(bmh, dmh); } /** - * Make a direct method handle to m, if the lookup class has permission. + * Makes a direct method handle to m, if the lookup class has permission. * If m is non-static, the receiver argument is treated as an initial argument. * If m is virtual, overriding is respected on every call. * Unlike the Core Reflection API, exceptions are not wrapped. @@ -871,7 +862,7 @@ return mh1; MemberName method = new MemberName(m); assert(method.isMethod()); if (!m.isAccessible()) checkMethod(method.getDeclaringClass(), method, method.isStatic()); - MethodHandle mh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, true, lookupClassOrNull()); + MethodHandle mh = MethodHandleImpl.findMethod(method, true, lookupClassOrNull()); if (!m.isAccessible()) mh = restrictProtectedReceiver(method, mh); return mh; } @@ -901,7 +892,7 @@ return mh1; assert(method.isMethod()); // ignore m.isAccessible: this is a new kind of access checkMethod(m.getDeclaringClass(), method, false); - MethodHandle mh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, false, lookupClassOrNull()); + MethodHandle mh = MethodHandleImpl.findMethod(method, false, lookupClassOrNull()); return restrictReceiver(method, mh, specialCaller); } @@ -928,8 +919,8 @@ return mh1; MemberName ctor = new MemberName(c); assert(ctor.isConstructor()); if (!c.isAccessible()) checkAccess(c.getDeclaringClass(), ctor); - MethodHandle rawCtor = MethodHandleImpl.findMethod(IMPL_TOKEN, ctor, false, lookupClassOrNull()); - MethodHandle allocator = MethodHandleImpl.makeAllocator(IMPL_TOKEN, rawCtor); + MethodHandle rawCtor = MethodHandleImpl.findMethod(ctor, false, lookupClassOrNull()); + MethodHandle allocator = MethodHandleImpl.makeAllocator(rawCtor); return fixVarargs(allocator, rawCtor); } @@ -940,7 +931,7 @@ return mh1; * If the field is static, the method handle will take no arguments. * Otherwise, its single argument will be the instance containing * the field. - * If the method's {@code accessible} flag is not set, + * If the field's {@code accessible} flag is not set, * access checking is performed immediately on behalf of the lookup class. * @param f the reflected field * @return a method handle which can load values from the reflected field @@ -958,7 +949,7 @@ return mh1; * argument, of the field's value type, the value to be stored. * Otherwise, the two arguments will be the instance containing * the field, and the value to be stored. - * If the method's {@code accessible} flag is not set, + * If the field's {@code accessible} flag is not set, * access checking is performed immediately on behalf of the lookup class. * @param f the reflected field * @return a method handle which can store values into the reflected field @@ -999,7 +990,7 @@ return mh1; void checkSymbolicClass(Class refc) throws IllegalAccessException { Class caller = lookupClassOrNull(); if (caller != null && !VerifyAccess.isClassAccessible(refc, caller)) - throw newNoAccessException("symbolic reference class is not public", new MemberName(refc), this); + throw new MemberName(refc).makeAccessException("symbolic reference class is not public", this); } void checkMethod(Class refc, MemberName m, boolean wantStatic) throws IllegalAccessException { @@ -1012,7 +1003,7 @@ return mh1; message = wantStatic ? "expected a static method" : "expected a non-static method"; else { checkAccess(refc, m); return; } - throw newNoAccessException(message, m, this); + throw m.makeAccessException(message, this); } void checkAccess(Class refc, MemberName m) throws IllegalAccessException { @@ -1030,7 +1021,7 @@ return mh1; && VerifyAccess.isSamePackage(m.getDeclaringClass(), lookupClass())) // Protected members can also be checked as if they were package-private. return; - throw newNoAccessException(accessFailedMessage(refc, m), m, this); + throw m.makeAccessException(accessFailedMessage(refc, m), this); } String accessFailedMessage(Class refc, MemberName m) { @@ -1064,8 +1055,8 @@ return mh1; || (specialCaller != lookupClass() && !(ALLOW_NESTMATE_ACCESS && VerifyAccess.isSamePackageMember(specialCaller, lookupClass())))) - throw newNoAccessException("no private access for invokespecial", - new MemberName(specialCaller), this); + throw new MemberName(specialCaller). + makeAccessException("no private access for invokespecial", this); } MethodHandle restrictProtectedReceiver(MemberName method, MethodHandle mh) throws IllegalAccessException { @@ -1084,12 +1075,12 @@ return mh1; assert(!method.isStatic()); Class defc = method.getDeclaringClass(); // receiver type of mh is too wide if (defc.isInterface() || !defc.isAssignableFrom(caller)) { - throw newNoAccessException("caller class must be a subclass below the method", method, caller); + throw method.makeAccessException("caller class must be a subclass below the method", caller); } MethodType rawType = mh.type(); if (rawType.parameterType(0) == caller) return mh; MethodType narrowType = rawType.changeParameterType(0, caller); - MethodHandle narrowMH = MethodHandleImpl.convertArguments(IMPL_TOKEN, mh, narrowType, rawType, null); + MethodHandle narrowMH = MethodHandleImpl.convertArguments(mh, narrowType, rawType, null); return fixVarargs(narrowMH, mh); } @@ -1097,10 +1088,9 @@ return mh1; boolean isStatic, boolean isSetter) throws NoSuchFieldException, IllegalAccessException { MemberName field = resolveOrFail(refc, name, type, isStatic); if (isStatic != field.isStatic()) - throw newNoAccessException(isStatic - ? "expected a static field" - : "expected a non-static field", - field, this); + throw field.makeAccessException(isStatic + ? "expected a static field" + : "expected a non-static field", this); return makeAccessor(refc, field, false, isSetter); } @@ -1108,9 +1098,9 @@ return mh1; boolean trusted, boolean isSetter) throws IllegalAccessException { assert(field.isField()); if (trusted) - return MethodHandleImpl.accessField(IMPL_TOKEN, field, isSetter, lookupClassOrNull()); + return MethodHandleImpl.accessField(field, isSetter, lookupClassOrNull()); checkAccess(refc, field); - MethodHandle mh = MethodHandleImpl.accessField(IMPL_TOKEN, field, isSetter, lookupClassOrNull()); + MethodHandle mh = MethodHandleImpl.accessField(field, isSetter, lookupClassOrNull()); return restrictProtectedReceiver(field, mh); } } @@ -1127,7 +1117,7 @@ return mh1; */ public static MethodHandle arrayElementGetter(Class arrayClass) throws IllegalArgumentException { - return MethodHandleImpl.accessArrayElement(IMPL_TOKEN, arrayClass, false); + return MethodHandleImpl.accessArrayElement(arrayClass, false); } /** @@ -1141,7 +1131,7 @@ return mh1; */ public static MethodHandle arrayElementSetter(Class arrayClass) throws IllegalArgumentException { - return MethodHandleImpl.accessArrayElement(IMPL_TOKEN, arrayClass, true); + return MethodHandleImpl.accessArrayElement(arrayClass, true); } /// method handle invocation (reflective style) @@ -1191,7 +1181,7 @@ return invoker; MethodHandle spreadInvoker(MethodType type, int objectArgCount) { if (objectArgCount < 0 || objectArgCount > type.parameterCount()) throw new IllegalArgumentException("bad argument count "+objectArgCount); - return invokers(type).spreadInvoker(objectArgCount); + return type.invokers().spreadInvoker(objectArgCount); } /** @@ -1231,7 +1221,7 @@ publicLookup().findVirtual(MethodHandle.class, "invokeExact", type) */ static public MethodHandle exactInvoker(MethodType type) { - return invokers(type).exactInvoker(); + return type.invokers().exactInvoker(); } /** @@ -1258,11 +1248,7 @@ publicLookup().findVirtual(MethodHandle.class, "invokeGeneric", type) */ static public MethodHandle genericInvoker(MethodType type) { - return invokers(type).genericInvoker(); - } - - static Invokers invokers(MethodType type) { - return MethodTypeImpl.invokers(IMPL_TOKEN, type); + return type.invokers().genericInvoker(); } /** @@ -1387,7 +1373,7 @@ publicLookup().findVirtual(MethodHandle.class, "invokeGeneric", type) return target; MethodHandle res = null; try { - res = MethodHandleImpl.convertArguments(IMPL_TOKEN, target, + res = MethodHandleImpl.convertArguments(target, newType, oldType, null); } catch (IllegalArgumentException ex) { } @@ -1531,7 +1517,7 @@ assert((int)twice.invokeExact(21) == 42); MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) { MethodType oldType = target.type(); checkReorder(reorder, newType, oldType); - return MethodHandleImpl.convertArguments(IMPL_TOKEN, target, + return MethodHandleImpl.convertArguments(target, newType, oldType, reorder); } @@ -1574,7 +1560,7 @@ assert((int)twice.invokeExact(21) == 42); int numSpread = (outargs - spreadPos); MethodHandle res = null; if (spreadPos >= 0 && numSpread >= 0) { - res = MethodHandleImpl.spreadArguments(IMPL_TOKEN, target, newType, spreadPos); + res = MethodHandleImpl.spreadArguments(target, newType, spreadPos); } if (res == null) { throw newIllegalArgumentException("cannot spread "+newType+" to " +oldType); @@ -1607,7 +1593,7 @@ assert((int)twice.invokeExact(21) == 42); int numCollect = (inargs - collectPos); if (collectPos < 0 || numCollect < 0) throw newIllegalArgumentException("wrong number of arguments"); - MethodHandle res = MethodHandleImpl.collectArguments(IMPL_TOKEN, target, newType, collectPos, null); + MethodHandle res = MethodHandleImpl.collectArguments(target, newType, collectPos, null); if (res == null) { throw newIllegalArgumentException("cannot collect from "+newType+" to " +oldType); } @@ -1654,7 +1640,13 @@ assert((int)twice.invokeExact(21) == 42); MethodHandle identity(Class type) { if (type == void.class) throw newIllegalArgumentException("void type"); - return ValueConversions.identity(type); + else if (type == Object.class) + return ValueConversions.identity(); + else if (type.isPrimitive()) + return ValueConversions.identity(Wrapper.forPrimitiveType(type)); + else + return AdapterMethodHandle.makeRetypeRaw( + MethodType.methodType(type, type), ValueConversions.identity()); } /** @@ -1686,8 +1678,6 @@ assert((int)twice.invokeExact(21) == 42); MethodHandle insertArguments(MethodHandle target, int pos, Object... values) { int insCount = values.length; MethodType oldType = target.type(); - ArrayList> ptypes = - new ArrayList>(oldType.parameterList()); int outargs = oldType.parameterCount(); int inargs = outargs - insCount; if (inargs < 0) @@ -1701,14 +1691,14 @@ assert((int)twice.invokeExact(21) == 42); value = checkValue(valueType, value); if (pos == 0 && !valueType.isPrimitive()) { // At least for now, make bound method handles a special case. - MethodHandle bmh = MethodHandleImpl.bindReceiver(IMPL_TOKEN, result, value); + MethodHandle bmh = MethodHandleImpl.bindReceiver(result, value); if (bmh != null) { result = bmh; continue; } // else fall through to general adapter machinery } - result = MethodHandleImpl.bindArgument(IMPL_TOKEN, result, pos, value); + result = MethodHandleImpl.bindArgument(result, pos, value); } return result; } @@ -1726,20 +1716,21 @@ assert((int)twice.invokeExact(21) == 42); *

    * Example: *

    -import static java.dyn.MethodHandles.*;
    -import static java.dyn.MethodType.*;
    +import static java.lang.invoke.MethodHandles.*;
    +import static java.lang.invoke.MethodType.*;
     ...
     MethodHandle cat = lookup().findVirtual(String.class,
       "concat", methodType(String.class, String.class));
     assertEquals("xy", (String) cat.invokeExact("x", "y"));
    -MethodHandle d0 = dropArguments(cat, 0, String.class);
    -assertEquals("yz", (String) d0.invokeExact("x", "y", "z"));
    -MethodHandle d1 = dropArguments(cat, 1, String.class);
    -assertEquals("xz", (String) d1.invokeExact("x", "y", "z"));
    -MethodHandle d2 = dropArguments(cat, 2, String.class);
    -assertEquals("xy", (String) d2.invokeExact("x", "y", "z"));
    -MethodHandle d12 = dropArguments(cat, 1, int.class, boolean.class);
    -assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
    +MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class);
    +MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2));
    +assertEquals(bigType, d0.type());
    +assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
    +     * 
    + *

    + * This method is also equivalent to the following code: + *

    +     * {@link #dropArguments(MethodHandle,int,Class...) dropArguments}(target, pos, valueTypes.toArray(new Class[0]))
          * 
    * @param target the method handle to invoke after the arguments are dropped * @param valueTypes the type(s) of the argument(s) to drop @@ -1762,7 +1753,7 @@ assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z")); new ArrayList>(oldType.parameterList()); ptypes.addAll(pos, valueTypes); MethodType newType = MethodType.methodType(oldType.returnType(), ptypes); - return MethodHandleImpl.dropArguments(IMPL_TOKEN, target, newType, pos); + return MethodHandleImpl.dropArguments(target, newType, pos); } /** @@ -1770,10 +1761,34 @@ assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z")); * after dropping the given argument(s) at the given position. * The type of the new method handle will insert the given argument * type(s), at that position, into the original handle's type. - * This method is equivalent to the following code: - * + *

    + * The pos may range between zero and N, + * where N is the number of argument types in target, + * meaning to drop the first or last argument (respectively), + * or an argument somewhere in between. + *

    + * Example: + *

    +import static java.lang.invoke.MethodHandles.*;
    +import static java.lang.invoke.MethodType.*;
    +...
    +MethodHandle cat = lookup().findVirtual(String.class,
    +  "concat", methodType(String.class, String.class));
    +assertEquals("xy", (String) cat.invokeExact("x", "y"));
    +MethodHandle d0 = dropArguments(cat, 0, String.class);
    +assertEquals("yz", (String) d0.invokeExact("x", "y", "z"));
    +MethodHandle d1 = dropArguments(cat, 1, String.class);
    +assertEquals("xz", (String) d1.invokeExact("x", "y", "z"));
    +MethodHandle d2 = dropArguments(cat, 2, String.class);
    +assertEquals("xy", (String) d2.invokeExact("x", "y", "z"));
    +MethodHandle d12 = dropArguments(cat, 1, int.class, boolean.class);
    +assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
    +     * 
    + *

    + * This method is also equivalent to the following code: + *

          * {@link #dropArguments(MethodHandle,int,List) dropArguments}(target, pos, Arrays.asList(valueTypes))
    -     * 
    +     * 
    * @param target the method handle to invoke after the arguments are dropped * @param valueTypes the type(s) of the argument(s) to drop * @param pos position of first argument to drop (zero for the leftmost) @@ -1789,7 +1804,7 @@ assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z")); } /** - * Adapt a target method handle {@code target} by pre-processing + * Adapts a target method handle {@code target} by pre-processing * one or more of its arguments, each with its own unary filter function, * and then calling the target with each pre-processed argument * replaced by the result of its corresponding filter function. @@ -1812,8 +1827,8 @@ assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z")); * which do not correspond to argument positions in the target. * Example: *

    -import static java.dyn.MethodHandles.*;
    -import static java.dyn.MethodType.*;
    +import static java.lang.invoke.MethodHandles.*;
    +import static java.lang.invoke.MethodType.*;
     ...
     MethodHandle cat = lookup().findVirtual(String.class,
       "concat", methodType(String.class, String.class));
    @@ -1855,16 +1870,16 @@ assertEquals("XY", (String) f2.invokeExact("x", "y")); // XY
                     || filterType.returnType() != targetType.parameterType(curPos))
                     throw newIllegalArgumentException("target and filter types do not match");
                 adapterType = adapterType.changeParameterType(curPos, filterType.parameterType(0));
    -            adapter = MethodHandleImpl.filterArgument(IMPL_TOKEN, adapter, curPos, filter);
    +            adapter = MethodHandleImpl.filterArgument(adapter, curPos, filter);
             }
             MethodType midType = adapter.type();
             if (midType != adapterType)
    -            adapter = MethodHandleImpl.convertArguments(IMPL_TOKEN, adapter, adapterType, midType, null);
    +            adapter = MethodHandleImpl.convertArguments(adapter, adapterType, midType, null);
             return adapter;
         }
     
         /**
    -     * Adapt a target method handle {@code target} by post-processing
    +     * Adapts a target method handle {@code target} by post-processing
          * its return value with a unary filter function.
          * 

    * If a filter {@code F} applies to the return value of @@ -1876,8 +1891,8 @@ assertEquals("XY", (String) f2.invokeExact("x", "y")); // XY * return type of the target. * Example: *

    -import static java.dyn.MethodHandles.*;
    -import static java.dyn.MethodType.*;
    +import static java.lang.invoke.MethodHandles.*;
    +import static java.lang.invoke.MethodType.*;
     ...
     MethodHandle cat = lookup().findVirtual(String.class,
       "concat", methodType(String.class, String.class));
    @@ -1909,7 +1924,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
         }
     
         /**
    -     * Adapt a target method handle {@code target} by pre-processing
    +     * Adapts a target method handle {@code target} by pre-processing
          * some of its arguments, and then calling the target with
          * the result of the pre-processing, plus all original arguments.
          * 

    @@ -1966,11 +1981,11 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 if (!ok) throw misMatchedTypes("target and combiner types", targetType, combinerType); MethodType newType = targetType.dropParameterTypes(0, 1); - return MethodHandleImpl.foldArguments(IMPL_TOKEN, target, newType, combiner); + return MethodHandleImpl.foldArguments(target, newType, combiner); } /** - * Make a method handle which adapts a target method handle, + * Makes a method handle which adapts a target method handle, * by guarding it with a test, a boolean-valued method handle. * If the guard fails, a fallback handle is called instead. * All three method handles must have the same corresponding @@ -2021,7 +2036,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 test = dropArguments(test, gpc, targs.subList(gpc, tpc)); gtype = test.type(); } - return MethodHandleImpl.makeGuardWithTest(IMPL_TOKEN, test, target, fallback); + return MethodHandleImpl.makeGuardWithTest(test, target, fallback); } static RuntimeException misMatchedTypes(String what, MethodType t1, MethodType t2) { @@ -2029,7 +2044,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 } /** - * Make a method handle which adapts a target method handle, + * Makes a method handle which adapts a target method handle, * by running it inside an exception handler. * If the target returns normally, the adapter returns that value. * If an exception matching the specified type is thrown, the fallback @@ -2092,7 +2107,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 handler = dropArguments(handler, hpc, hargs.subList(hpc, tpc)); htype = handler.type(); } - return MethodHandleImpl.makeGuardWithCatch(IMPL_TOKEN, target, exType, handler); + return MethodHandleImpl.makeGuardWithCatch(target, exType, handler); } /** @@ -2107,51 +2122,45 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 */ public static MethodHandle throwException(Class returnType, Class exType) { - return MethodHandleImpl.throwException(IMPL_TOKEN, MethodType.methodType(returnType, exType)); + return MethodHandleImpl.throwException(MethodType.methodType(returnType, exType)); } /** - * Produces an instance of the given "SAM" interface which redirects + * Produces an instance of the given single-method interface which redirects * its calls to the given method handle. *

    - * A SAM interface is an interface which declares a single abstract method. - * When determining the unique abstract method of a SAM interface, + * A single-method interface is an interface which declares a unique method. + * When determining the unique method of a single-method interface, * the public {@code Object} methods ({@code toString}, {@code equals}, {@code hashCode}) - * are disregarded. For example, {@link java.util.Comparator} is a SAM interface, + * are disregarded. For example, {@link java.util.Comparator} is a single-method interface, * even though it re-declares the {@code Object.equals} method. - * Also, if the SAM interface has a supertype, - * the SAM interface may override an inherited method. - * Any such overrides are respected, and the method handle will be accessible - * by either the inherited method or the SAM method. - * In particular, a {@linkplain java.lang.reflect.Method#isBridge bridge method} - * may be created if the methods have different return types. *

    * The type must be public. No additional access checks are performed. *

    - * The resulting instance of the required SAM type will respond to - * invocation of the SAM type's single abstract method by calling + * The resulting instance of the required type will respond to + * invocation of the type's single abstract method by calling * the given {@code target} on the incoming arguments, * and returning or throwing whatever the {@code target} * returns or throws. The invocation will be as if by * {@code target.invokeGeneric}. - * The target's type will be checked before the SAM + * The target's type will be checked before the * instance is created, as if by a call to {@code asType}, * which may result in a {@code WrongMethodTypeException}. *

    - * The wrapper instance will implement the requested SAM interface - * and its super-types, but no other SAM types. - * This means that the SAM instance will not unexpectedly + * The wrapper instance will implement the requested interface + * and its super-types, but no other single-method interfaces. + * This means that the instance will not unexpectedly * pass an {@code instanceof} test for any unrequested type. *

    * Implementation Note: - * Therefore, each SAM instance must implement a unique SAM type. + * Therefore, each instance must implement a unique single-method interface. * Implementations may not bundle together - * multiple SAM types onto single implementation classes + * multiple single-method interfaces onto single implementation classes * in the style of {@link java.awt.AWTEventMulticaster}. *

    * The method handle may throw an undeclared exception, * which means any checked exception (or other checked throwable) - * not declared by the SAM type's single abstract method. + * not declared by the requested type's single abstract method. * If this happens, the throwable will be wrapped in an instance of * {@link java.lang.reflect.UndeclaredThrowableException UndeclaredThrowableException} * and thrown in that wrapped form. @@ -2161,28 +2170,37 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 * by their behavior. * It is not guaranteed to return a new instance for every call. *

    + * Because of the possibility of {@linkplain java.lang.reflect.Method#isBridge bridge methods} + * and other corner cases, the interface may also have several abstract methods + * with the same name but having distinct descriptors (types of returns and parameters). + * In this case, all the methods are bound in common to the one given {@code target}. + * The type check and effective {@code asType} conversion is applied to each + * method type descriptor, and all abstract methods are bound to the {@code target} in common. + * Beyond this type check, no further checks are made to determine that the + * abstract methods are related in any way. + *

    * Future versions of this API may accept additional types, * such as abstract classes with single abstract methods. * Future versions of this API may also equip wrapper instances * with one or more additional public "marker" interfaces. * * @param target the method handle to invoke from the wrapper - * @param samType the desired type of the wrapper, a SAM type + * @param smType the desired type of the wrapper, a single-method interface * @return a correctly-typed wrapper for the given {@code target} * @throws NullPointerException if either argument is null - * @throws IllegalArgumentException if the {@code samType} is not a + * @throws IllegalArgumentException if the {@code smType} is not a * valid argument to this method * @throws WrongMethodTypeException if the {@code target} cannot - * be converted to the type required by the SAM type + * be converted to the type required by the requested interface */ // Other notes to implementors: //

    - // No stable mapping is promised between the SAM type and + // No stable mapping is promised between the single-method interface and // the implementation class C. Over time, several implementation - // classes might be used for the same SAM type. + // classes might be used for the same type. //

    // If the implementation is able - // to prove that a wrapper of the required SAM type + // to prove that a wrapper of the required type // has already been created for a given // method handle, or for another method handle with the // same behavior, the implementation may return that wrapper in place of @@ -2191,34 +2209,34 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 // This method is designed to apply to common use cases // where a single method handle must interoperate with // an interface that implements a function-like - // API. Additional variations, such as SAM classes with + // API. Additional variations, such as single-abstract-method classes with // private constructors, or interfaces with multiple but related // entry points, must be covered by hand-written or automatically // generated adapter classes. // public static - T asInstance(final MethodHandle target, final Class samType) { + T asInstance(final MethodHandle target, final Class smType) { // POC implementation only; violates the above contract several ways - final Method sam = getSamMethod(samType); - if (sam == null) - throw new IllegalArgumentException("not a SAM type: "+samType.getName()); - MethodType samMT = MethodType.methodType(sam.getReturnType(), sam.getParameterTypes()); - MethodHandle checkTarget = target.asType(samMT); // make throw WMT + final Method sm = getSingleMethod(smType); + if (sm == null) + throw new IllegalArgumentException("not a single-method interface: "+smType.getName()); + MethodType smMT = MethodType.methodType(sm.getReturnType(), sm.getParameterTypes()); + MethodHandle checkTarget = target.asType(smMT); // make throw WMT checkTarget = checkTarget.asType(checkTarget.type().changeReturnType(Object.class)); - final MethodHandle vaTarget = checkTarget.asSpreader(Object[].class, samMT.parameterCount()); - return samType.cast(Proxy.newProxyInstance( - samType.getClassLoader(), - new Class[]{ samType, WrapperInstance.class }, + final MethodHandle vaTarget = checkTarget.asSpreader(Object[].class, smMT.parameterCount()); + return smType.cast(Proxy.newProxyInstance( + smType.getClassLoader(), + new Class[]{ smType, WrapperInstance.class }, new InvocationHandler() { private Object getArg(String name) { if ((Object)name == "getWrapperInstanceTarget") return target; - if ((Object)name == "getWrapperInstanceType") return samType; + if ((Object)name == "getWrapperInstanceType") return smType; throw new AssertionError(); } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getDeclaringClass() == WrapperInstance.class) return getArg(method.getName()); - if (method.equals(sam)) + if (method.equals(sm)) return vaTarget.invokeExact(args); if (isObjectMethod(method)) return callObjectMethod(this, method, args); @@ -2228,7 +2246,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 } /** - * Determine if the given object was produced by a call to {@link #asInstance asInstance}. + * Determines if the given object was produced by a call to {@link #asInstance asInstance}. * @param x any reference * @return true if the reference is not null and points to an object produced by {@code asInstance} */ @@ -2248,11 +2266,11 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 /** * Produces or recovers a target method handle which is behaviorally - * equivalent to the SAM method of this wrapper instance. + * equivalent to the unique method of this wrapper instance. * The object {@code x} must have been produced by a call to {@link #asInstance asInstance}. * This requirement may be tested via {@link #isWrapperInstance isWrapperInstance}. * @param x any reference - * @return a method handle implementing the SAM method + * @return a method handle implementing the unique method * @throws IllegalArgumentException if the reference x is not to a wrapper instance */ public static @@ -2261,11 +2279,11 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 } /** - * Recover the SAM type for which this wrapper instance was created. + * Recovers the unique single-method interface type for which this wrapper instance was created. * The object {@code x} must have been produced by a call to {@link #asInstance asInstance}. * This requirement may be tested via {@link #isWrapperInstance isWrapperInstance}. * @param x any reference - * @return the SAM type for which the wrapper was created + * @return the single-method interface type for which the wrapper was created * @throws IllegalArgumentException if the reference x is not to a wrapper instance */ public static @@ -2305,24 +2323,24 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 } private static - Method getSamMethod(Class samType) { - Method sam = null; - for (Method m : samType.getMethods()) { + Method getSingleMethod(Class smType) { + Method sm = null; + for (Method m : smType.getMethods()) { int mod = m.getModifiers(); if (Modifier.isAbstract(mod)) { - if (sam != null && !isObjectMethod(sam)) + if (sm != null && !isObjectMethod(sm)) return null; // too many abstract methods - sam = m; + sm = m; } } - if (!samType.isInterface() && getSamConstructor(samType) == null) + if (!smType.isInterface() && getSingleConstructor(smType) == null) return null; // wrong kind of constructor - return sam; + return sm; } private static - Constructor getSamConstructor(Class samType) { - for (Constructor c : samType.getDeclaredConstructors()) { + Constructor getSingleConstructor(Class smType) { + for (Constructor c : smType.getDeclaredConstructors()) { if (c.getParameterTypes().length == 0) { int mod = c.getModifiers(); if (Modifier.isPublic(mod) || Modifier.isProtected(mod)) @@ -2334,6 +2352,6 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 /*non-public*/ static MethodHandle asVarargsCollector(MethodHandle target, Class arrayType) { - return MethodHandleImpl.asVarargsCollector(IMPL_TOKEN, target, arrayType); + return MethodHandleImpl.asVarargsCollector(target, arrayType); } } diff --git a/src/share/classes/java/dyn/MethodType.java b/src/share/classes/java/lang/invoke/MethodType.java similarity index 93% rename from src/share/classes/java/dyn/MethodType.java rename to src/share/classes/java/lang/invoke/MethodType.java index a7baf7c634e7892233bb45e2d8ec9a7205872f90..a7fa147fa3296a195e49b6cd8f81f9580dcec100 100644 --- a/src/share/classes/java/dyn/MethodType.java +++ b/src/share/classes/java/lang/invoke/MethodType.java @@ -23,18 +23,14 @@ * questions. */ -package java.dyn; +package java.lang.invoke; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; -import sun.dyn.Access; -import sun.dyn.Invokers; -import sun.dyn.MethodHandleImpl; -import sun.dyn.MethodTypeImpl; -import sun.dyn.util.BytecodeDescriptor; -import static sun.dyn.MemberName.newIllegalArgumentException; +import sun.invoke.util.BytecodeDescriptor; +import static java.lang.invoke.MethodHandleStatics.*; /** * A method type represents the arguments and return type accepted and @@ -96,34 +92,6 @@ class MethodType implements java.io.Serializable { private MethodType wrapAlt; // alternative wrapped/unwrapped version private Invokers invokers; // cache of handy higher-order adapters - private static final Access IMPL_TOKEN = Access.getToken(); - - // share a cache with a friend in this package - Invokers getInvokers() { return invokers; } - void setInvokers(Invokers inv) { invokers = inv; } - - static { - // This hack allows the implementation package special access to - // the internals of MethodType. In particular, the MTImpl has all sorts - // of cached information useful to the implementation code. - MethodTypeImpl.setMethodTypeFriend(IMPL_TOKEN, new MethodTypeImpl.MethodTypeFriend() { - public Class[] ptypes(MethodType mt) { return mt.ptypes; } - public MethodTypeImpl form(MethodType mt) { return mt.form; } - public void setForm(MethodType mt, MethodTypeImpl form) { - assert(mt.form == null); - mt.form = (MethodTypeForm) form; - } - public MethodType makeImpl(Class rtype, Class[] ptypes, boolean trusted) { - return MethodType.makeImpl(rtype, ptypes, trusted); - } - public MethodTypeImpl newMethodTypeForm(MethodType mt) { - return new MethodTypeForm(mt); - } - public Invokers getInvokers(MethodType mt) { return mt.invokers; } - public void setInvokers(MethodType mt, Invokers inv) { mt.invokers = inv; } - }); - } - /** * Check the given parameters for validity and store them into the final fields. */ @@ -134,6 +102,10 @@ class MethodType implements java.io.Serializable { this.ptypes = ptypes; } + /*trusted*/ MethodTypeForm form() { return form; } + /*trusted*/ Class rtype() { return rtype; } + /*trusted*/ Class[] ptypes() { return ptypes; } + private static void checkRtype(Class rtype) { rtype.equals(rtype); // null check } @@ -168,7 +140,7 @@ class MethodType implements java.io.Serializable { static final Class[] NO_PTYPES = {}; /** - * Find or create an instance of the given method type. + * Finds or creates an instance of the given method type. * @param rtype the return type * @param ptypes the parameter types * @return a method type with the given components @@ -253,7 +225,7 @@ class MethodType implements java.io.Serializable { * @param trusted whether the ptypes can be used without cloning * @return the unique method type of the desired structure */ - private static + /*trusted*/ static MethodType makeImpl(Class rtype, Class[] ptypes, boolean trusted) { if (ptypes == null || ptypes.length == 0) { ptypes = NO_PTYPES; trusted = true; @@ -269,7 +241,12 @@ class MethodType implements java.io.Serializable { // defensively copy the array passed in by the user mt1 = new MethodType(rtype, ptypes.clone()); // promote the object to the Real Thing, and reprobe - MethodTypeImpl.initForm(IMPL_TOKEN, mt1); + MethodTypeForm form = MethodTypeForm.findForm(mt1); + mt1.form = form; + if (form.erasedType == mt1) { + // This is a principal (erased) type; show it to the JVM. + MethodHandleNatives.init(mt1); + } synchronized (internTable) { mt0 = internTable.get(mt1); if (mt0 != null) @@ -279,12 +256,6 @@ class MethodType implements java.io.Serializable { return mt1; } - // Entry point from JVM. TODO: Change the name & signature. - private static MethodType makeImpl(Class rtype, Class[] ptypes, - boolean ignore1, boolean ignore2) { - return makeImpl(rtype, ptypes, true); - } - private static final MethodType[] objectOnlyTypes = new MethodType[20]; /** @@ -519,7 +490,7 @@ class MethodType implements java.io.Serializable { } /** - * Convert all wrapper types to their corresponding primitive types. + * Converts all wrapper types to their corresponding primitive types. * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}. * All primitive types (including {@code void}) will remain unchanged. * A return type of {@code java.lang.Void} is changed to {@code void}. @@ -535,7 +506,7 @@ class MethodType implements java.io.Serializable { MethodType wt = pt.wrapAlt; if (wt == null) { // fill in lazily - wt = MethodTypeImpl.canonicalize(pt, MethodTypeImpl.WRAP, MethodTypeImpl.WRAP); + wt = MethodTypeForm.canonicalize(pt, MethodTypeForm.WRAP, MethodTypeForm.WRAP); assert(wt != null); pt.wrapAlt = wt; } @@ -547,7 +518,7 @@ class MethodType implements java.io.Serializable { MethodType uwt = wt.wrapAlt; if (uwt == null) { // fill in lazily - uwt = MethodTypeImpl.canonicalize(wt, MethodTypeImpl.UNWRAP, MethodTypeImpl.UNWRAP); + uwt = MethodTypeForm.canonicalize(wt, MethodTypeForm.UNWRAP, MethodTypeForm.UNWRAP); if (uwt == null) uwt = wt; // type has no wrappers or prims at all wt.wrapAlt = uwt; @@ -658,7 +629,7 @@ class MethodType implements java.io.Serializable { /// Queries which have to do with the bytecode architecture /** Reports the number of JVM stack slots required to invoke a method - * of this type. Note that (for historic reasons) the JVM requires + * of this type. Note that (for historical reasons) the JVM requires * a second stack slot to pass long and double arguments. * So this method returns {@link #parameterCount() parameterCount} plus the * number of long and double parameters (if any). @@ -666,12 +637,18 @@ class MethodType implements java.io.Serializable { * This method is included for the benfit of applications that must * generate bytecodes that process method handles and invokedynamic. * @return the number of JVM stack slots for this type's parameters - * @deprecated Will be removed for PFD. */ - public int parameterSlotCount() { + /*non-public*/ int parameterSlotCount() { return form.parameterSlotCount(); } + /*non-public*/ Invokers invokers() { + Invokers inv = invokers; + if (inv != null) return inv; + invokers = inv = new Invokers(this); + return inv; + } + /** Reports the number of JVM stack slots which carry all parameters including and after * the given position, which must be in the range of 0 to * {@code parameterCount} inclusive. Successive parameters are @@ -694,9 +671,8 @@ class MethodType implements java.io.Serializable { * @return the index of the (shallowest) JVM stack slot transmitting the * given parameter * @throws IllegalArgumentException if {@code num} is negative or greater than {@code parameterCount()} - * @deprecated Will be removed for PFD. */ - public int parameterSlotDepth(int num) { + /*non-public*/ int parameterSlotDepth(int num) { if (num < 0 || num > ptypes.length) parameterType(num); // force a range check return form.parameterToArgSlot(num-1); @@ -710,14 +686,14 @@ class MethodType implements java.io.Serializable { * This method is included for the benfit of applications that must * generate bytecodes that process method handles and invokedynamic. * @return the number of JVM stack slots (0, 1, or 2) for this type's return value - * @deprecated Will be removed for PFD. + * Will be removed for PFD. */ - public int returnSlotCount() { + /*non-public*/ int returnSlotCount() { return form.returnSlotCount(); } /** - * Find or create an instance of a method type, given the spelling of its bytecode descriptor. + * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor. * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}. * Any class or interface name embedded in the descriptor string * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)} diff --git a/src/share/classes/sun/dyn/MethodTypeImpl.java b/src/share/classes/java/lang/invoke/MethodTypeForm.java similarity index 85% rename from src/share/classes/sun/dyn/MethodTypeImpl.java rename to src/share/classes/java/lang/invoke/MethodTypeForm.java index 700ed307f74be0f7dd3cbbc9a6cbdc144a9121e4..db73b24d06759f937e4ca3102c4bfcfaa46ef4e1 100644 --- a/src/share/classes/sun/dyn/MethodTypeImpl.java +++ b/src/share/classes/java/lang/invoke/MethodTypeForm.java @@ -23,11 +23,10 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; -import sun.dyn.util.Wrapper; -import static sun.dyn.MemberName.newIllegalArgumentException; +import sun.invoke.util.Wrapper; +import static java.lang.invoke.MethodHandleStatics.*; /** * Shared information for a group of method types, which differ @@ -42,7 +41,7 @@ import static sun.dyn.MemberName.newIllegalArgumentException; * No more than half of these are likely to be loaded at once. * @author John Rose */ -public class MethodTypeImpl { +class MethodTypeForm { final int[] argToSlotTable, slotToArgTable; final long argCounts; // packed slot & value counts final long primCounts; // packed prim & double counts @@ -66,39 +65,10 @@ public class MethodTypeImpl { return erasedType; } - public static MethodTypeImpl of(MethodType type) { - return METHOD_TYPE_FRIEND.form(type); - } - - /** Access methods for the internals of MethodType, supplied to - * MethodTypeImpl as a trusted agent. - */ - static public interface MethodTypeFriend { - Class[] ptypes(MethodType mt); - MethodTypeImpl form(MethodType mt); - void setForm(MethodType mt, MethodTypeImpl form); - MethodType makeImpl(Class rtype, Class[] ptypes, boolean trusted); - MethodTypeImpl newMethodTypeForm(MethodType mt); - Invokers getInvokers(MethodType mt); - void setInvokers(MethodType mt, Invokers inv); - } - public static void setMethodTypeFriend(Access token, MethodTypeFriend am) { - Access.check(token); - if (METHOD_TYPE_FRIEND != null) - throw new InternalError(); // just once - METHOD_TYPE_FRIEND = am; - } - static private MethodTypeFriend METHOD_TYPE_FRIEND; - - static MethodType makeImpl(Access token, Class rtype, Class[] ptypes, boolean trusted) { - Access.check(token); - return METHOD_TYPE_FRIEND.makeImpl(rtype, ptypes, trusted); - } - - protected MethodTypeImpl(MethodType erasedType) { + protected MethodTypeForm(MethodType erasedType) { this.erasedType = erasedType; - Class[] ptypes = METHOD_TYPE_FRIEND.ptypes(erasedType); + Class[] ptypes = erasedType.ptypes(); int ptypeCount = ptypes.length; int pslotCount = ptypeCount; // temp. estimate int rtypeCount = 1; // temp. estimate @@ -260,7 +230,7 @@ public class MethodTypeImpl { * the type {@code (Object,int)Object} produces {@code null}. */ public static int[] primsAtEndOrder(MethodType mt) { - MethodTypeImpl form = METHOD_TYPE_FRIEND.form(mt); + MethodTypeForm form = mt.form(); if (form.primsAtEnd == form.erasedType) // quick check shows no reordering is necessary return null; @@ -273,7 +243,7 @@ public class MethodTypeImpl { int lac = form.longPrimitiveParameterCount(); int rfill = 0, ifill = argc - pac, lfill = argc - lac; - Class[] ptypes = METHOD_TYPE_FRIEND.ptypes(mt); + Class[] ptypes = mt.ptypes(); boolean changed = false; for (int i = 0; i < ptypes.length; i++) { Class pt = ptypes[i]; @@ -300,7 +270,7 @@ public class MethodTypeImpl { */ public static MethodType reorderParameters(MethodType mt, int[] newParamOrder, Class[] moreParams) { if (newParamOrder == null) return mt; // no-op reordering - Class[] ptypes = METHOD_TYPE_FRIEND.ptypes(mt); + Class[] ptypes = mt.ptypes(); Class[] ntypes = new Class[newParamOrder.length]; int maxParam = ptypes.length + (moreParams == null ? 0 : moreParams.length); boolean changed = (ntypes.length != ptypes.length); @@ -314,7 +284,7 @@ public class MethodTypeImpl { ntypes[i] = nt; } if (!changed) return mt; - return METHOD_TYPE_FRIEND.makeImpl(mt.returnType(), ntypes, true); + return MethodType.makeImpl(mt.returnType(), ntypes, true); } private static boolean hasTwoArgSlots(Class type) { @@ -376,28 +346,18 @@ public class MethodTypeImpl { return slotToArgTable[argSlot] - 1; } - public static void initForm(Access token, MethodType mt) { - Access.check(token); - MethodTypeImpl form = findForm(mt); - METHOD_TYPE_FRIEND.setForm(mt, form); - if (form.erasedType == mt) { - // This is a principal (erased) type; show it to the JVM. - MethodHandleImpl.init(token, mt); - } - } - - static MethodTypeImpl findForm(MethodType mt) { + static MethodTypeForm findForm(MethodType mt) { MethodType erased = canonicalize(mt, ERASE, ERASE); if (erased == null) { - // It is already erased. Make a new MethodTypeImpl. - return METHOD_TYPE_FRIEND.newMethodTypeForm(mt); + // It is already erased. Make a new MethodTypeForm. + return new MethodTypeForm(mt); } else { - // Share the MethodTypeImpl with the erased version. - return METHOD_TYPE_FRIEND.form(erased); + // Share the MethodTypeForm with the erased version. + return erased.form(); } } - /** Codes for {@link #canonicalize(java.lang.Class, int). + /** Codes for {@link #canonicalize(java.lang.Class, int)}. * ERASE means change every reference to {@code Object}. * WRAP means convert primitives (including {@code void} to their * corresponding wrapper types. UNWRAP means the reverse of WRAP. @@ -414,10 +374,10 @@ public class MethodTypeImpl { * Otherwise return null. */ public static MethodType canonicalize(MethodType mt, int howRet, int howArgs) { - Class[] ptypes = METHOD_TYPE_FRIEND.ptypes(mt); - Class[] ptc = MethodTypeImpl.canonicalizes(ptypes, howArgs); + Class[] ptypes = mt.ptypes(); + Class[] ptc = MethodTypeForm.canonicalizes(ptypes, howArgs); Class rtype = mt.returnType(); - Class rtc = MethodTypeImpl.canonicalize(rtype, howRet); + Class rtc = MethodTypeForm.canonicalize(rtype, howRet); if (ptc == null && rtc == null) { // It is already canonical. return null; @@ -425,7 +385,7 @@ public class MethodTypeImpl { // Find the erased version of the method type: if (rtc == null) rtc = rtype; if (ptc == null) ptc = ptypes; - return METHOD_TYPE_FRIEND.makeImpl(rtc, ptc, true); + return MethodType.makeImpl(rtc, ptc, true); } /** Canonicalize the given return or param type. @@ -496,16 +456,16 @@ public class MethodTypeImpl { return cs; } - public static Invokers invokers(Access token, MethodType type) { - Access.check(token); - return invokers(type); - } - /*non-public*/ static Invokers invokers(MethodType type) { - Invokers inv = METHOD_TYPE_FRIEND.getInvokers(type); - if (inv != null) return inv; - inv = new Invokers(type); - METHOD_TYPE_FRIEND.setInvokers(type, inv); - return inv; + /*non-public*/ void notifyGenericMethodType() { + if (genericInvoker != null) return; + try { + // Trigger adapter creation. + genericInvoker = InvokeGeneric.genericInvokerOf(erasedType); + } catch (Exception ex) { + Error err = new InternalError("Exception while resolving invokeGeneric"); + err.initCause(ex); + throw err; + } } @Override diff --git a/src/share/classes/java/dyn/MutableCallSite.java b/src/share/classes/java/lang/invoke/MutableCallSite.java similarity index 99% rename from src/share/classes/java/dyn/MutableCallSite.java rename to src/share/classes/java/lang/invoke/MutableCallSite.java index 95df7a6a6d1b5428dcba527a5426e008bf09ee9c..fe18237bb38aa5bb56bcc7a6c887b75ba5f3d056 100644 --- a/src/share/classes/java/dyn/MutableCallSite.java +++ b/src/share/classes/java/lang/invoke/MutableCallSite.java @@ -23,10 +23,8 @@ * questions. */ -package java.dyn; +package java.lang.invoke; -import sun.dyn.*; -import sun.dyn.empty.Empty; import java.util.concurrent.atomic.AtomicInteger; /** diff --git a/src/share/classes/sun/dyn/SpreadGeneric.java b/src/share/classes/java/lang/invoke/SpreadGeneric.java similarity index 98% rename from src/share/classes/sun/dyn/SpreadGeneric.java rename to src/share/classes/java/lang/invoke/SpreadGeneric.java index 4c6a0800bcc45fe066610abc27fbb1c50ae5d275..a862723e0250d8aa1322e77a9c742dd3a271b4eb 100644 --- a/src/share/classes/sun/dyn/SpreadGeneric.java +++ b/src/share/classes/java/lang/invoke/SpreadGeneric.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,14 +23,14 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; +import sun.invoke.util.ValueConversions; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; -import sun.dyn.util.ValueConversions; -import static sun.dyn.MemberName.newIllegalArgumentException; +import static java.lang.invoke.MethodHandleStatics.*; +import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /** * Generic spread adapter. @@ -110,7 +110,7 @@ class SpreadGeneric { static SpreadGeneric of(MethodType targetType, int spreadCount) { if (targetType != targetType.generic()) throw new UnsupportedOperationException("NYI type="+targetType); - MethodTypeImpl form = MethodTypeImpl.of(targetType); + MethodTypeForm form = targetType.form(); int outcount = form.parameterCount(); assert(spreadCount <= outcount); SpreadGeneric[] spreadGens = form.spreadGeneric; @@ -129,7 +129,7 @@ class SpreadGeneric { // This mini-api is called from an Adapter to manage the spread. /** A check/coercion that happens once before any selections. */ protected Object check(Object av, int n) { - MethodHandleImpl.checkSpreadArgument(av, n); + checkSpreadArgument(av, n); return av; } @@ -166,7 +166,7 @@ class SpreadGeneric { // see if it has the required invoke method MethodHandle entryPoint = null; try { - entryPoint = MethodHandleImpl.IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls); + entryPoint = IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls); } catch (ReflectiveOperationException ex) { } if (entryPoint == null) continue; @@ -221,21 +221,21 @@ class SpreadGeneric { @Override public String toString() { - return MethodHandleImpl.addTypeString(target, this); + return addTypeString(target, this); } static final MethodHandle NO_ENTRY = ValueConversions.identity(); protected boolean isPrototype() { return target == null; } protected Adapter(SpreadGeneric outer) { - super(Access.TOKEN, NO_ENTRY); + super(NO_ENTRY); this.outer = outer; this.target = null; assert(isPrototype()); } protected Adapter(SpreadGeneric outer, MethodHandle target) { - super(Access.TOKEN, outer.entryPoint); + super(outer.entryPoint); this.outer = outer; this.target = target; } @@ -251,7 +251,7 @@ class SpreadGeneric { return outer.select(av, n); } - static private final String CLASS_PREFIX; // "sun.dyn.SpreadGeneric$" + static private final String CLASS_PREFIX; // "java.lang.invoke.SpreadGeneric$" static { String aname = Adapter.class.getName(); String sname = Adapter.class.getSimpleName(); diff --git a/src/share/classes/java/dyn/SwitchPoint.java b/src/share/classes/java/lang/invoke/SwitchPoint.java similarity index 96% rename from src/share/classes/java/dyn/SwitchPoint.java rename to src/share/classes/java/lang/invoke/SwitchPoint.java index 642e194b863614ef7041dd2a9e3a95775c1fb137..d81db187c8877dace889ab75d245bdbbf560f2f5 100644 --- a/src/share/classes/java/dyn/SwitchPoint.java +++ b/src/share/classes/java/lang/invoke/SwitchPoint.java @@ -23,7 +23,7 @@ * questions. */ -package java.dyn; +package java.lang.invoke; /** *

    @@ -73,6 +73,10 @@ assertEquals("hodmet", (String) worker.invokeExact("met", "hod")); * Switch points are useful without subclassing. They may also be subclassed. * This may be useful in order to associate application-specific invalidation logic * with the switch point. + * Notice that there is no permanent association between a switch point and + * the method handles it produces and consumes. + * The garbage collector may collect method handles produced or consumed + * by a switch point independently of the lifetime of the switch point itself. *

    * Implementation Note: * A switch point behaves as if implemented on top of {@link MutableCallSite}, diff --git a/src/share/classes/sun/dyn/ToGeneric.java b/src/share/classes/java/lang/invoke/ToGeneric.java similarity index 95% rename from src/share/classes/sun/dyn/ToGeneric.java rename to src/share/classes/java/lang/invoke/ToGeneric.java index 38db3fea42fe2434c61c613047ea9cf781d0da7b..22723975d5bfbe158fa08407d9bb5f573c9e1d5c 100644 --- a/src/share/classes/sun/dyn/ToGeneric.java +++ b/src/share/classes/java/lang/invoke/ToGeneric.java @@ -23,15 +23,14 @@ * questions. */ -package sun.dyn; +package java.lang.invoke; -import java.dyn.*; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import sun.dyn.util.ValueConversions; -import sun.dyn.util.Wrapper; -import static sun.dyn.MemberName.newIllegalArgumentException; -import static sun.dyn.MethodTypeImpl.invokers; +import sun.invoke.util.ValueConversions; +import sun.invoke.util.Wrapper; +import static java.lang.invoke.MethodHandleStatics.*; +import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /** * Adapters which mediate between incoming calls which are not generic @@ -73,7 +72,7 @@ class ToGeneric { assert(entryType.erase() == entryType); // for now // incoming call will first "forget" all reference types except Object this.entryType = entryType; - MethodHandle invoker0 = invokers(entryType.generic()).exactInvoker(); + MethodHandle invoker0 = entryType.generic().invokers().exactInvoker(); MethodType rawEntryTypeInit; Adapter ad = findAdapter(rawEntryTypeInit = entryType); if (ad != null) { @@ -89,15 +88,15 @@ class ToGeneric { } // next, it will reorder primitives after references - MethodType primsAtEnd = MethodTypeImpl.of(entryType).primsAtEnd(); + MethodType primsAtEnd = entryType.form().primsAtEnd(); // at the same time, it will "forget" all primitive types except int/long - this.primsAtEndOrder = MethodTypeImpl.primsAtEndOrder(entryType); + this.primsAtEndOrder = MethodTypeForm.primsAtEndOrder(entryType); if (primsAtEndOrder != null) { // reordering is required; build on top of a simpler ToGeneric ToGeneric va2 = ToGeneric.of(primsAtEnd); this.adapter = va2.adapter; if (true) throw new UnsupportedOperationException("NYI: primitive parameters must follow references; entryType = "+entryType); - this.entryPoint = MethodHandleImpl.convertArguments(Access.TOKEN, + this.entryPoint = MethodHandleImpl.convertArguments( va2.entryPoint, primsAtEnd, entryType, primsAtEndOrder); // example: for entryType of (int,Object,Object), the reordered // type is (Object,Object,int) and the order is {1,2,0}, @@ -107,7 +106,7 @@ class ToGeneric { // after any needed argument reordering, it will reinterpret // primitive arguments according to their "raw" types int/long - MethodType intsAtEnd = MethodTypeImpl.of(primsAtEnd).primsAsInts(); + MethodType intsAtEnd = primsAtEnd.form().primsAsInts(); ad = findAdapter(rawEntryTypeInit = intsAtEnd); MethodHandle rawEntryPoint; if (ad != null) { @@ -116,7 +115,7 @@ class ToGeneric { // Perhaps the adapter is available only for longs. // If so, we can use it, but there will have to be a little // more stack motion on each call. - MethodType longsAtEnd = MethodTypeImpl.of(primsAtEnd).primsAsLongs(); + MethodType longsAtEnd = primsAtEnd.form().primsAsLongs(); ad = findAdapter(rawEntryTypeInit = longsAtEnd); if (ad != null) { MethodType eptWithLongs = longsAtEnd.insertParameterTypes(0, ad.getClass()); @@ -128,7 +127,7 @@ class ToGeneric { assert(midType.parameterType(i) == long.class); assert(eptWithInts.parameterType(i) == int.class); MethodType nextType = midType.changeParameterType(i, int.class); - rawEntryPoint = MethodHandle.convertArguments(Access.TOKEN, + rawEntryPoint = MethodHandleImpl.convertArguments( rawEntryPoint, nextType, midType, null); midType = nextType; } @@ -143,7 +142,7 @@ class ToGeneric { } MethodType tepType = entryType.insertParameterTypes(0, ad.getClass()); this.entryPoint = - AdapterMethodHandle.makeRetypeRaw(Access.TOKEN, tepType, rawEntryPoint); + AdapterMethodHandle.makeRetypeRaw(tepType, rawEntryPoint); if (this.entryPoint == null) throw new UnsupportedOperationException("cannot retype to "+entryType +" from "+rawEntryPoint.type().dropParameterTypes(0, 1)); @@ -168,7 +167,7 @@ class ToGeneric { assert(src.isPrimitive() && dst.isPrimitive()); if (filteredInvoker == null) { filteredInvoker = - AdapterMethodHandle.makeCheckCast(Access.TOKEN, + AdapterMethodHandle.makeCheckCast( invoker.type().generic(), invoker, 0, MethodHandle.class); if (filteredInvoker == null) throw new UnsupportedOperationException("NYI"); } @@ -177,7 +176,7 @@ class ToGeneric { if (filteredInvoker == null) throw new InternalError(); } if (filteredInvoker == null) return invoker; - return AdapterMethodHandle.makeRetypeOnly(Access.TOKEN, invoker.type(), filteredInvoker); + return AdapterMethodHandle.makeRetypeOnly(invoker.type(), filteredInvoker); } /** @@ -227,7 +226,7 @@ class ToGeneric { // retype erased reference arguments (the cast makes it safe to do this) MethodType tepType = type.insertParameterTypes(0, adapter.getClass()); MethodHandle typedEntryPoint = - AdapterMethodHandle.makeRetypeRaw(Access.TOKEN, tepType, entryPoint); + AdapterMethodHandle.makeRetypeRaw(tepType, entryPoint); return adapter.makeInstance(typedEntryPoint, invoker, convert, genericTarget); } @@ -248,7 +247,7 @@ class ToGeneric { /** Return the adapter information for this type's erasure. */ static ToGeneric of(MethodType type) { - MethodTypeImpl form = MethodTypeImpl.of(type); + MethodTypeForm form = type.form(); ToGeneric toGen = form.toGeneric; if (toGen == null) form.toGeneric = toGen = new ToGeneric(form.erasedType()); @@ -262,7 +261,7 @@ class ToGeneric { /* Create an adapter for the given incoming call type. */ static Adapter findAdapter(MethodType entryPointType) { - MethodTypeImpl form = MethodTypeImpl.of(entryPointType); + MethodTypeForm form = entryPointType.form(); Class rtype = entryPointType.returnType(); int argc = form.parameterCount(); int lac = form.longPrimitiveParameterCount(); @@ -283,7 +282,7 @@ class ToGeneric { for (String iname : inames) { MethodHandle entryPoint = null; try { - entryPoint = MethodHandleImpl.IMPL_LOOKUP. + entryPoint = IMPL_LOOKUP. findSpecial(acls, iname, entryPointType, acls); } catch (ReflectiveOperationException ex) { } @@ -338,13 +337,13 @@ class ToGeneric { @Override public String toString() { - return target == null ? "prototype:"+convert : MethodHandleImpl.addTypeString(target, this); + return target == null ? "prototype:"+convert : addTypeString(target, this); } protected boolean isPrototype() { return target == null; } /* Prototype constructor. */ protected Adapter(MethodHandle entryPoint) { - super(Access.TOKEN, entryPoint); + super(entryPoint); this.invoker = null; this.convert = entryPoint; this.target = null; @@ -356,7 +355,7 @@ class ToGeneric { } protected Adapter(MethodHandle entryPoint, MethodHandle invoker, MethodHandle convert, MethodHandle target) { - super(Access.TOKEN, entryPoint); + super(entryPoint); this.invoker = invoker; this.convert = convert; this.target = target; @@ -396,7 +395,7 @@ class ToGeneric { protected float return_F(Object res) throws Throwable { return (float) convert.invokeExact(res); } protected double return_D(Object res) throws Throwable { return (double)convert.invokeExact(res); } - static private final String CLASS_PREFIX; // "sun.dyn.ToGeneric$" + static private final String CLASS_PREFIX; // "java.lang.invoke.ToGeneric$" static { String aname = Adapter.class.getName(); String sname = Adapter.class.getSimpleName(); @@ -452,14 +451,15 @@ class genclasses { static String[] TCHARS = { "L", "I", "J", "F", "D", "A" }; static String[][] TEMPLATES = { { "@for@ arity=0..3 rcat<=4 nrefs<=99 nints<=99 nlongs<=99", - "@for@ arity=4..5 rcat<=2 nrefs<=99 nints<=99 nlongs<=99", + "@for@ arity=4..4 rcat<=4 nrefs<=99 nints<=99 nlongs<=99", + "@for@ arity=5..5 rcat<=2 nrefs<=99 nints<=99 nlongs<=99", "@for@ arity=6..10 rcat<=2 nrefs<=99 nints=0 nlongs<=99", " //@each-cat@", " static class @cat@ extends Adapter {", " protected @cat@(MethodHandle entryPoint) { super(entryPoint); } // to build prototype", " protected @cat@(MethodHandle e, MethodHandle i, MethodHandle c, MethodHandle t) { super(e, i, c, t); }", " protected @cat@ makeInstance(MethodHandle e, MethodHandle i, MethodHandle c, MethodHandle t) { return new @cat@(e, i, c, t); }", - " protected Object target(@Ovav@) throws Throwable { return invoker.invokeExact(target, @av@); }", + " protected Object target(@Ovav@) throws Throwable { return invoker.invokeExact(target@comma@@av@); }", " //@each-Tv@", " protected Object target@cat@(@Tvav@) throws Throwable { return target(@av@); }", " //@end-Tv@", @@ -471,7 +471,7 @@ class genclasses { " }", } }; enum VAR { - cat, R, Rc, Tv, av, Tvav, Ovav; + cat, R, Rc, Tv, av, comma, Tvav, Ovav; public final String pattern = "@"+toString().replace('_','.')+"@"; public String binding; static void makeBindings(boolean topLevel, int rcat, int nrefs, int nints, int nlongs) { @@ -493,12 +493,13 @@ class genclasses { } VAR.Tv.binding = comma(Tv); VAR.av.binding = comma(av); + VAR.comma.binding = (av.length == 0 ? "" : ", "); VAR.Tvav.binding = comma(Tvav); VAR.Ovav.binding = comma(Ovav); } static String arg(int i) { return "a"+i; } static String param(String t, String a) { return t+" "+a; } - static String comma(String[] v) { return comma(v, ""); } + static String comma(String[] v) { return comma("", v); } static String comma(String sep, String[] v) { if (v.length == 0) return ""; String res = sep+v[0]; @@ -735,7 +736,7 @@ class genclasses { protected float invoke_F(long a0, long a1, long a2) throws Throwable { return return_F(targetA3(a0, a1, a2)); } protected double invoke_D(long a0, long a1, long a2) throws Throwable { return return_D(targetA3(a0, a1, a2)); } } -//params=[4, 5, 2, 99, 99, 99] +//params=[4, 4, 4, 99, 99, 99] static class A4 extends Adapter { protected A4(MethodHandle entryPoint) { super(entryPoint); } // to build prototype protected A4(MethodHandle e, MethodHandle i, MethodHandle c, MethodHandle t) { super(e, i, c, t); } @@ -753,31 +754,50 @@ class genclasses { protected Object invoke_L(Object a0, Object a1, Object a2, Object a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); } protected int invoke_I(Object a0, Object a1, Object a2, Object a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); } protected long invoke_J(Object a0, Object a1, Object a2, Object a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); } + protected float invoke_F(Object a0, Object a1, Object a2, Object a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); } + protected double invoke_D(Object a0, Object a1, Object a2, Object a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); } protected Object invoke_L(Object a0, Object a1, Object a2, int a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); } protected int invoke_I(Object a0, Object a1, Object a2, int a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); } protected long invoke_J(Object a0, Object a1, Object a2, int a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); } + protected float invoke_F(Object a0, Object a1, Object a2, int a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); } + protected double invoke_D(Object a0, Object a1, Object a2, int a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); } protected Object invoke_L(Object a0, Object a1, int a2, int a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); } protected int invoke_I(Object a0, Object a1, int a2, int a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); } protected long invoke_J(Object a0, Object a1, int a2, int a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); } + protected float invoke_F(Object a0, Object a1, int a2, int a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); } + protected double invoke_D(Object a0, Object a1, int a2, int a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); } protected Object invoke_L(Object a0, int a1, int a2, int a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); } protected int invoke_I(Object a0, int a1, int a2, int a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); } protected long invoke_J(Object a0, int a1, int a2, int a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); } + protected float invoke_F(Object a0, int a1, int a2, int a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); } + protected double invoke_D(Object a0, int a1, int a2, int a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); } protected Object invoke_L(int a0, int a1, int a2, int a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); } protected int invoke_I(int a0, int a1, int a2, int a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); } protected long invoke_J(int a0, int a1, int a2, int a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); } + protected float invoke_F(int a0, int a1, int a2, int a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); } + protected double invoke_D(int a0, int a1, int a2, int a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); } protected Object invoke_L(Object a0, Object a1, Object a2, long a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); } protected int invoke_I(Object a0, Object a1, Object a2, long a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); } protected long invoke_J(Object a0, Object a1, Object a2, long a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); } + protected float invoke_F(Object a0, Object a1, Object a2, long a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); } + protected double invoke_D(Object a0, Object a1, Object a2, long a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); } protected Object invoke_L(Object a0, Object a1, long a2, long a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); } protected int invoke_I(Object a0, Object a1, long a2, long a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); } protected long invoke_J(Object a0, Object a1, long a2, long a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); } + protected float invoke_F(Object a0, Object a1, long a2, long a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); } + protected double invoke_D(Object a0, Object a1, long a2, long a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); } protected Object invoke_L(Object a0, long a1, long a2, long a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); } protected int invoke_I(Object a0, long a1, long a2, long a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); } protected long invoke_J(Object a0, long a1, long a2, long a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); } + protected float invoke_F(Object a0, long a1, long a2, long a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); } + protected double invoke_D(Object a0, long a1, long a2, long a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); } protected Object invoke_L(long a0, long a1, long a2, long a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); } protected int invoke_I(long a0, long a1, long a2, long a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); } protected long invoke_J(long a0, long a1, long a2, long a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); } + protected float invoke_F(long a0, long a1, long a2, long a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); } + protected double invoke_D(long a0, long a1, long a2, long a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); } } +//params=[5, 5, 2, 99, 99, 99] static class A5 extends Adapter { protected A5(MethodHandle entryPoint) { super(entryPoint); } // to build prototype protected A5(MethodHandle e, MethodHandle i, MethodHandle c, MethodHandle t) { super(e, i, c, t); } diff --git a/src/share/classes/java/dyn/VolatileCallSite.java b/src/share/classes/java/lang/invoke/VolatileCallSite.java similarity index 99% rename from src/share/classes/java/dyn/VolatileCallSite.java rename to src/share/classes/java/lang/invoke/VolatileCallSite.java index 616813ce2f5a55f40b629262758b1212aaecb3ae..de88f36bbb3b45c5db85d0c5fd09fa486f7558e3 100644 --- a/src/share/classes/java/dyn/VolatileCallSite.java +++ b/src/share/classes/java/lang/invoke/VolatileCallSite.java @@ -23,9 +23,7 @@ * questions. */ -package java.dyn; - -import java.util.List; +package java.lang.invoke; /** * A {@code VolatileCallSite} is a {@link CallSite} whose target acts like a volatile variable. diff --git a/src/share/classes/java/dyn/WrongMethodTypeException.java b/src/share/classes/java/lang/invoke/WrongMethodTypeException.java similarity index 96% rename from src/share/classes/java/dyn/WrongMethodTypeException.java rename to src/share/classes/java/lang/invoke/WrongMethodTypeException.java index 2455432e858be4721fe36e8938b441cc2d0af770..7d538dc809679553b78a27844d5c5b1c2ee8b222 100644 --- a/src/share/classes/java/dyn/WrongMethodTypeException.java +++ b/src/share/classes/java/lang/invoke/WrongMethodTypeException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ * questions. */ -package java.dyn; +package java.lang.invoke; /** * Thrown to indicate that code has attempted to call a method handle diff --git a/src/share/classes/java/dyn/package-info.java b/src/share/classes/java/lang/invoke/package-info.java similarity index 86% rename from src/share/classes/java/dyn/package-info.java rename to src/share/classes/java/lang/invoke/package-info.java index d01c644f312959b7351f3b1ab09ae0c9235a9dd2..0eac856d218fe797e77a29b105544deb8a760ac6 100644 --- a/src/share/classes/java/dyn/package-info.java +++ b/src/share/classes/java/lang/invoke/package-info.java @@ -27,21 +27,18 @@ * The {@code java.lang.invoke} package contains dynamic language support provided directly by * the Java core class libraries and virtual machine. * - *

    - * Historic Note: In some early versions of Java SE 7, - * the name of this package is {@code java.dyn}. *

    * Certain types in this package have special relations to dynamic * language support in the virtual machine: *

      - *
    • The class {@link java.dyn.MethodHandle MethodHandle} contains + *
    • The class {@link java.lang.invoke.MethodHandle MethodHandle} contains * signature polymorphic methods * which can be linked regardless of their type descriptor. * Normally, method linkage requires exact matching of type descriptors. *
    • * *
    • The JVM bytecode format supports immediate constants of - * the classes {@link java.dyn.MethodHandle MethodHandle} and {@link java.dyn.MethodType MethodType}. + * the classes {@link java.lang.invoke.MethodHandle MethodHandle} and {@link java.lang.invoke.MethodType MethodType}. *
    • *
    * @@ -59,7 +56,7 @@ * with tag {@code CONSTANT_InvokeDynamic} (decimal 18). See below for its format. * The entry specifies the following information: *
      - *
    • a bootstrap method (a {@link java.dyn.MethodHandle MethodHandle} constant)
    • + *
    • a bootstrap method (a {@link java.lang.invoke.MethodHandle MethodHandle} constant)
    • *
    • the dynamic invocation name (a UTF8 string)
    • *
    • the argument and return types of the call (encoded as a type descriptor in a UTF8 string)
    • *
    • optionally, a sequence of additional static arguments to the bootstrap method ({@code ldc}-type constants)
    • @@ -75,11 +72,6 @@ * A dynamic call site is linked by means of a bootstrap method, * as described below. * - *

      - * Historic Note: Some older JVMs may allow the index of a {@code CONSTANT_NameAndType} - * instead of a {@code CONSTANT_InvokeDynamic}. In earlier, obsolete versions of this API, the - * bootstrap method was specified dynamically, in a per-class basis, during class initialization. - * *

      constant pool entries for {@code invokedynamic} instructions

      * If a constant pool entry has the tag {@code CONSTANT_InvokeDynamic} (decimal 18), * it must contain exactly four more bytes after the tag. @@ -95,20 +87,20 @@ * except that the bootstrap method specifier reference replaces * the {@code CONSTANT_Class} reference of a {@code CONSTANT_Methodref} entry. * - *

      constant pool entries for {@linkplain java.dyn.MethodType method types}

      + *

      constant pool entries for {@linkplain java.lang.invoke.MethodType method types}

      * If a constant pool entry has the tag {@code CONSTANT_MethodType} (decimal 16), * it must contain exactly two more bytes, which must be an index to a {@code CONSTANT_Utf8} * entry which represents a method type descriptor. *

      * The JVM will ensure that on first - * execution of an {@code ldc} instruction for this entry, a {@link java.dyn.MethodType MethodType} + * execution of an {@code ldc} instruction for this entry, a {@link java.lang.invoke.MethodType MethodType} * will be created which represents the type descriptor. * Any classes mentioned in the {@code MethodType} will be loaded if necessary, * but not initialized. * Access checking and error reporting is performed exactly as it is for * references by {@code ldc} instructions to {@code CONSTANT_Class} constants. * - *

      constant pool entries for {@linkplain java.dyn.MethodHandle method handles}

      + *

      constant pool entries for {@linkplain java.lang.invoke.MethodHandle method handles}

      * If a constant pool entry has the tag {@code CONSTANT_MethodHandle} (decimal 15), * it must contain exactly three more bytes. The first byte after the tag is a subtag * value which must be in the range 1 through 9, and the last two must be an index to a @@ -119,7 +111,7 @@ * must agree according to the table below. *

      * The JVM will ensure that on first execution of an {@code ldc} instruction - * for this entry, a {@link java.dyn.MethodHandle MethodHandle} will be created which represents + * for this entry, a {@link java.lang.invoke.MethodHandle MethodHandle} will be created which represents * the field or method reference, according to the specific mode implied by the subtag. *

      * As with {@code CONSTANT_Class} and {@code CONSTANT_MethodType} constants, @@ -135,23 +127,23 @@ * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * *
      Nsubtag namememberMH typebytecode behaviorlookup expression
      1REF_getFieldC.f:T(C)Tgetfield C.f:T{@linkplain java.dyn.MethodHandles.Lookup#findGetter findGetter(C.class,"f",T.class)}
      {@linkplain java.lang.invoke.MethodHandles.Lookup#findGetter findGetter(C.class,"f",T.class)}
      2REF_getStaticC.f:T( )Tgetstatic C.f:T{@linkplain java.dyn.MethodHandles.Lookup#findStaticGetter findStaticGetter(C.class,"f",T.class)}
      {@linkplain java.lang.invoke.MethodHandles.Lookup#findStaticGetter findStaticGetter(C.class,"f",T.class)}
      3REF_putFieldC.f:T(C,T)voidputfield C.f:T{@linkplain java.dyn.MethodHandles.Lookup#findSetter findSetter(C.class,"f",T.class)}
      {@linkplain java.lang.invoke.MethodHandles.Lookup#findSetter findSetter(C.class,"f",T.class)}
      4REF_putStaticC.f:T(T)voidputstatic C.f:T{@linkplain java.dyn.MethodHandles.Lookup#findStaticSetter findStaticSetter(C.class,"f",T.class)}
      {@linkplain java.lang.invoke.MethodHandles.Lookup#findStaticSetter findStaticSetter(C.class,"f",T.class)}
      5REF_invokeVirtualC.m(A*)T(C,A*)Tinvokevirtual C.m(A*)T{@linkplain java.dyn.MethodHandles.Lookup#findVirtual findVirtual(C.class,"m",MT)}
      {@linkplain java.lang.invoke.MethodHandles.Lookup#findVirtual findVirtual(C.class,"m",MT)}
      6REF_invokeStaticC.m(A*)T(C,A*)Tinvokestatic C.m(A*)T{@linkplain java.dyn.MethodHandles.Lookup#findStatic findStatic(C.class,"m",MT)}
      {@linkplain java.lang.invoke.MethodHandles.Lookup#findStatic findStatic(C.class,"m",MT)}
      7REF_invokeSpecialC.m(A*)T(C,A*)Tinvokespecial C.m(A*)T{@linkplain java.dyn.MethodHandles.Lookup#findSpecial findSpecial(C.class,"m",MT,this.class)}
      {@linkplain java.lang.invoke.MethodHandles.Lookup#findSpecial findSpecial(C.class,"m",MT,this.class)}
      8REF_newInvokeSpecialC.<init>(A*)void(A*)Cnew C; dup; invokespecial C.<init>(A*)void{@linkplain java.dyn.MethodHandles.Lookup#findConstructor findConstructor(C.class,MT)}
      {@linkplain java.lang.invoke.MethodHandles.Lookup#findConstructor findConstructor(C.class,MT)}
      9REF_invokeInterfaceC.m(A*)T(C,A*)Tinvokeinterface C.m(A*)T{@linkplain java.dyn.MethodHandles.Lookup#findVirtual findVirtual(C.class,"m",MT)}
      {@linkplain java.lang.invoke.MethodHandles.Lookup#findVirtual findVirtual(C.class,"m",MT)}
      * * Here, the type {@code C} is taken from the {@code CONSTANT_Class} reference associated @@ -169,7 +161,7 @@ * and returns the same result (if any) as the corresponding bytecode behavior. *

      * Each method handle constant also has an equivalent reflective lookup expression, - * which is a query to a method in {@link java.dyn.MethodHandles.Lookup}. + * which is a query to a method in {@link java.lang.invoke.MethodHandles.Lookup}. * In the example lookup method expression given in the table above, the name {@code MT} * stands for a {@code MethodType} built from {@code T} and the sequence of argument types {@code A*}. * (Note that the type {@code C} is not prepended to the query type {@code MT} even if the member is non-static.) @@ -191,7 +183,7 @@ * A constant may refer to a method or constructor with the {@code varargs} * bit (hexadecimal {@code 0x0080}) set in its modifier bitmask. * The method handle constant produced for such a method behaves as if - * it were created by {@link java.dyn.MethodHandle#asVarargsCollector asVarargsCollector}. + * it were created by {@link java.lang.invoke.MethodHandle#asVarargsCollector asVarargsCollector}. * In other words, the constant method handle will exhibit variable arity, * when invoked via {@code invokeGeneric}. * On the other hand, its behavior with respect to {@code invokeExact} will be the same @@ -225,7 +217,7 @@ * the call site must first be linked. * Linking is accomplished by calling a bootstrap method * which is given the static information content of the call site, - * and which must produce a {@link java.dyn.MethodHandle method handle} + * and which must produce a {@link java.lang.invoke.MethodHandle method handle} * that gives the behavior of the call site. *

      * Each {@code invokedynamic} instruction statically specifies its own @@ -234,7 +226,7 @@ * just like {@code invokevirtual} and the other invoke instructions. *

      * Linking starts with resolving the constant pool entry for the - * bootstrap method, and resolving a {@link java.dyn.MethodType MethodType} object for + * bootstrap method, and resolving a {@link java.lang.invoke.MethodType MethodType} object for * the type descriptor of the dynamic call site. * This resolution process may trigger class loading. * It may therefore throw an error if a class fails to load. @@ -251,8 +243,8 @@ *

    • optionally, one or more additional static arguments
    • *
    * The method handle is then applied to the other values as if by - * {@link java.dyn.MethodHandle#invokeGeneric invokeGeneric}. - * The returned result must be a {@link java.dyn.CallSite CallSite} (or a subclass). + * {@link java.lang.invoke.MethodHandle#invokeGeneric invokeGeneric}. + * The returned result must be a {@link java.lang.invoke.CallSite CallSite} (or a subclass). * The type of the call site's target must be exactly equal to the type * derived from the dynamic call site's type descriptor and passed to * the bootstrap method. @@ -263,18 +255,12 @@ * For example, the first argument could be {@code Object} * instead of {@code MethodHandles.Lookup}, and the return type * could also be {@code Object} instead of {@code CallSite}. - *

    - * As with any method handle constant, a {@code varargs} modifier bit - * on the bootstrap method is ignored. - *

    - * Note that the first argument of the bootstrap method cannot be - * a simple {@code Class} reference. (This is a change from earlier - * versions of this specification. If the caller class is needed, - * it is easy to {@linkplain java.dyn.MethodHandles.Lookup#lookupClass() extract it} - * from the {@code Lookup} object.) + * (Note that the types and number of the stacked arguments limit + * the legal kinds of bootstrap methods to appropriately typed + * static methods and constructors of {@code CallSite} subclasses.) *

    * After resolution, the linkage process may fail in a variety of ways. - * All failures are reported by an {@link java.dyn.InvokeDynamicBootstrapError InvokeDynamicBootstrapError}, + * All failures are reported by a {@link java.lang.BootstrapMethodError BootstrapMethodError}, * which is thrown as the abnormal termination of the dynamic call * site execution. * The following circumstances will cause this: @@ -290,7 +276,7 @@ *

  • the bootstrap method has a wrong argument or return type
  • *
  • the bootstrap method invocation completes abnormally
  • *
  • the result from the bootstrap invocation is not a reference to - * an object of type {@link java.dyn.CallSite CallSite}
  • + * an object of type {@link java.lang.invoke.CallSite CallSite}
  • *
  • the target of the {@code CallSite} does not have a target of * the expected {@code MethodType}
  • * @@ -309,7 +295,7 @@ *

    * In an application which requires dynamic call sites with individually * mutable behaviors, their bootstrap methods should produce distinct - * {@link java.dyn.CallSite CallSite} objects, one for each linkage request. + * {@link java.lang.invoke.CallSite CallSite} objects, one for each linkage request. * Alternatively, an application can link a single {@code CallSite} object * to several {@code invokedynamic} instructions, in which case * a change to the target method will become visible at each of @@ -322,11 +308,12 @@ * chosen target object. * *

    - * Historic Note: Unlike some previous versions of this specification, - * these rules do not enable the JVM to duplicate dynamic call sites, + * Discussion: + * These rules do not enable the JVM to duplicate dynamic call sites, * or to issue “causeless” bootstrap method calls. * Every dynamic call site transitions at most once from unlinked to linked, * just before its first invocation. + * There is no way to undo the effect of a completed bootstrap method call. * *

    the {@code BootstrapMethods} attribute

    * Each {@code CONSTANT_InvokeDynamic} entry contains an index which references @@ -354,7 +341,7 @@ *

    static arguments to the bootstrap method

    * An {@code invokedynamic} instruction specifies at least three arguments * to pass to its bootstrap method: - * The caller class (expressed as a {@link java.dyn.MethodHandles.Lookup Lookup object}, + * The caller class (expressed as a {@link java.lang.invoke.MethodHandles.Lookup Lookup object}, * the name (extracted from the {@code CONSTANT_NameAndType} entry), * and the type (also extracted from the {@code CONSTANT_NameAndType} entry). * The {@code invokedynamic} instruction may specify additional metadata values @@ -382,8 +369,8 @@ * CONSTANT_Longjava.lang.Longthe indexed long value * CONSTANT_Floatjava.lang.Floatthe indexed float value * CONSTANT_Doublejava.lang.Doublethe indexed double value - * CONSTANT_MethodHandlejava.dyn.MethodHandlethe indexed method handle constant - * CONSTANT_MethodTypejava.dyn.MethodTypethe indexed method type constant + * CONSTANT_MethodHandlejava.lang.invoke.MethodHandlethe indexed method handle constant + * CONSTANT_MethodTypejava.lang.invoke.MethodTypethe indexed method type constant * * *

    @@ -403,7 +390,7 @@ * then some or all of the arguments specified here may be collected into a trailing array parameter. * (This is not a special rule, but rather a useful consequence of the interaction * between {@code CONSTANT_MethodHandle} constants, the modifier bit for variable arity methods, - * and the {@code java.dyn.MethodHandle#asVarargsCollector asVarargsCollector} transformation.) + * and the {@code java.lang.invoke.MethodHandle#asVarargsCollector asVarargsCollector} transformation.) *

    * Given these rules, here are examples of legal bootstrap method declarations, * given various numbers {@code N} of extra arguments. @@ -436,7 +423,7 @@ * constant as an {@code Object}, but the type matching machinery of {@code invokeGeneric} * will cast the reference back to {@code MethodHandle} before invoking the bootstrap method. * (If a string constant were passed instead, by badly generated code, that cast would then fail, - * resulting in an {@code InvokeDynamicBootstrapError}.) + * resulting in a {@code BootstrapMethodError}.) *

    * Extra bootstrap method arguments are intended to allow language implementors * to safely and compactly encode metadata. @@ -473,6 +460,7 @@ struct BootstrapMethods_attr { * * * @author John Rose, JSR 292 EG + * @since 1.7 */ -package java.dyn; +package java.lang.invoke; diff --git a/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java b/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java index 522fa3956b91705f87431d129df24d0e1ba8a913..004cd408110e2a6bb1bfead8fe3ee7a482587047 100644 --- a/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java +++ b/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java @@ -28,6 +28,7 @@ import java.io.FileDescriptor; import java.io.IOException; import java.io.InterruptedIOException; import java.util.Enumeration; +import sun.net.ResourceManager; /** * Abstract datagram and multicast socket implementation base class. @@ -66,7 +67,14 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl */ protected synchronized void create() throws SocketException { fd = new FileDescriptor(); - datagramSocketCreate(); + ResourceManager.beforeUdpCreate(); + try { + datagramSocketCreate(); + } catch (SocketException ioe) { + ResourceManager.afterUdpClose(); + fd = null; + throw ioe; + } } /** @@ -211,6 +219,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl protected void close() { if (fd != null) { datagramSocketClose(); + ResourceManager.afterUdpClose(); fd = null; } } diff --git a/src/share/classes/java/net/AbstractPlainSocketImpl.java b/src/share/classes/java/net/AbstractPlainSocketImpl.java index 6d73cbc242cf3a526dea39fe701de0190a34452c..f61fb34bdf1770afeb8be978f2dcc3afae653c7d 100644 --- a/src/share/classes/java/net/AbstractPlainSocketImpl.java +++ b/src/share/classes/java/net/AbstractPlainSocketImpl.java @@ -32,6 +32,7 @@ import java.io.FileDescriptor; import sun.net.ConnectionResetException; import sun.net.NetHooks; +import sun.net.ResourceManager; /** * Default Socket Implementation. This implementation does @@ -68,6 +69,10 @@ abstract class AbstractPlainSocketImpl extends SocketImpl private int resetState; private final Object resetLock = new Object(); + /* whether this Socket is a stream (TCP) socket or not (UDP) + */ + private boolean stream; + /** * Load net library into runtime. */ @@ -82,7 +87,19 @@ abstract class AbstractPlainSocketImpl extends SocketImpl */ protected synchronized void create(boolean stream) throws IOException { fd = new FileDescriptor(); - socketCreate(stream); + this.stream = stream; + if (!stream) { + ResourceManager.beforeUdpCreate(); + try { + socketCreate(false); + } catch (IOException ioe) { + ResourceManager.afterUdpClose(); + fd = null; + throw ioe; + } + } else { + socketCreate(true); + } if (socket != null) socket.setCreated(); if (serverSocket != null) @@ -479,6 +496,9 @@ abstract class AbstractPlainSocketImpl extends SocketImpl protected void close() throws IOException { synchronized(fdLock) { if (fd != null) { + if (!stream) { + ResourceManager.afterUdpClose(); + } if (fdUseCount == 0) { if (closePending) { return; diff --git a/src/share/classes/java/security/AccessControlContext.java b/src/share/classes/java/security/AccessControlContext.java index e80953b66963e300945ad3853b0a332ca470b059..940aff6377041d17856d5eab05012a3827db8517 100644 --- a/src/share/classes/java/security/AccessControlContext.java +++ b/src/share/classes/java/security/AccessControlContext.java @@ -29,6 +29,9 @@ import java.util.ArrayList; import java.util.List; import sun.security.util.Debug; import sun.security.util.SecurityConstants; +import sun.misc.JavaSecurityAccess; +import sun.misc.SharedSecrets; + /** * An AccessControlContext is used to make system resource access decisions @@ -196,6 +199,24 @@ public final class AccessControlContext { this.isPrivileged = isPrivileged; } + /** + * Constructor for JavaSecurityAccess.doIntersectionPrivilege() + */ + AccessControlContext(ProtectionDomain[] context, + AccessControlContext privilegedContext) + { + this.context = context; + this.privilegedContext = privilegedContext; + this.isPrivileged = true; + } + + /** + * Returns this context's context. + */ + ProtectionDomain[] getContext() { + return context; + } + /** * Returns true if this context is privileged. */ diff --git a/src/share/classes/java/security/ProtectionDomain.java b/src/share/classes/java/security/ProtectionDomain.java index 43a39028e3df5cc0f2df2a2153095c783ada5113..9025e81b5dcb215747a216bd5da16d9d7c66f365 100644 --- a/src/share/classes/java/security/ProtectionDomain.java +++ b/src/share/classes/java/security/ProtectionDomain.java @@ -36,6 +36,8 @@ import static sun.misc.JavaSecurityProtectionDomainAccess.ProtectionDomainCache; import sun.misc.SharedSecrets; import sun.security.util.Debug; import sun.security.util.SecurityConstants; +import sun.misc.JavaSecurityAccess; +import sun.misc.SharedSecrets; /** * @@ -59,6 +61,36 @@ import sun.security.util.SecurityConstants; public class ProtectionDomain { + static { + // Set up JavaSecurityAccess in SharedSecrets + SharedSecrets.setJavaSecurityAccess( + new JavaSecurityAccess() { + public T doIntersectionPrivilege( + PrivilegedAction action, + final AccessControlContext stack, + final AccessControlContext context) + { + if (action == null) { + throw new NullPointerException(); + } + return AccessController.doPrivileged( + action, + new AccessControlContext( + stack.getContext(), context).optimize() + ); + } + + public T doIntersectionPrivilege( + PrivilegedAction action, + AccessControlContext context) + { + return doIntersectionPrivilege(action, + AccessController.getContext(), context); + } + } + ); + } + /* CodeSource */ private CodeSource codesource ; diff --git a/src/share/classes/java/text/SimpleDateFormat.java b/src/share/classes/java/text/SimpleDateFormat.java index fd2876aca056bc2bdf13279c613ff8aa4e961524..a91a2344eca1ad3fc3897fbfbbcaaf06c4f4d254 100644 --- a/src/share/classes/java/text/SimpleDateFormat.java +++ b/src/share/classes/java/text/SimpleDateFormat.java @@ -504,8 +504,8 @@ public class SimpleDateFormat extends DateFormat { /** * Cache to hold the DateTimePatterns of a Locale. */ - private static final ConcurrentMap cachedLocaleData - = new ConcurrentHashMap(3); + private static final ConcurrentMap cachedLocaleData + = new ConcurrentHashMap(3); /** * Cache NumberFormat instances with Locale key. @@ -619,8 +619,7 @@ public class SimpleDateFormat extends DateFormat { initializeCalendar(loc); /* try the cache first */ - String key = getKey(); - String[] dateTimePatterns = cachedLocaleData.get(key); + String[] dateTimePatterns = cachedLocaleData.get(loc); if (dateTimePatterns == null) { /* cache miss */ ResourceBundle r = LocaleData.getDateFormatData(loc); if (!isGregorianCalendar()) { @@ -633,7 +632,7 @@ public class SimpleDateFormat extends DateFormat { dateTimePatterns = r.getStringArray("DateTimePatterns"); } /* update cache */ - cachedLocaleData.putIfAbsent(key, dateTimePatterns); + cachedLocaleData.putIfAbsent(loc, dateTimePatterns); } formatData = DateFormatSymbols.getInstanceRef(loc); if ((timeStyle >= 0) && (dateStyle >= 0)) { @@ -684,13 +683,6 @@ public class SimpleDateFormat extends DateFormat { } } - private String getKey() { - StringBuilder sb = new StringBuilder(); - sb.append(getCalendarName()).append('.'); - sb.append(locale.getLanguage()).append('_').append(locale.getCountry()).append('_').append(locale.getVariant()); - return sb.toString(); - } - /** * Returns the compiled form of the given pattern. The syntax of * the compiled pattern is: diff --git a/src/share/classes/javax/swing/JOptionPane.java b/src/share/classes/javax/swing/JOptionPane.java index 66154cf39b533760a30ebf5be8a2cc766010ff5d..307d834b4e6bedecd8649080b140cfe20b8e5d78 100644 --- a/src/share/classes/javax/swing/JOptionPane.java +++ b/src/share/classes/javax/swing/JOptionPane.java @@ -987,11 +987,33 @@ public class JOptionPane extends JComponent implements Accessible } dialog.pack(); dialog.setLocationRelativeTo(parentComponent); + + final PropertyChangeListener listener = new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + // Let the defaultCloseOperation handle the closing + // if the user closed the window without selecting a button + // (newValue = null in that case). Otherwise, close the dialog. + if (dialog.isVisible() && event.getSource() == JOptionPane.this && + (event.getPropertyName().equals(VALUE_PROPERTY) || + event.getPropertyName().equals(INPUT_VALUE_PROPERTY)) && + event.getNewValue() != null && + event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) { + dialog.setVisible(false); + } + } + }; + WindowAdapter adapter = new WindowAdapter() { private boolean gotFocus = false; public void windowClosing(WindowEvent we) { setValue(null); } + + public void windowClosed(WindowEvent e) { + removePropertyChangeListener(listener); + dialog.getContentPane().removeAll(); + } + public void windowGainedFocus(WindowEvent we) { // Once window gets focus, set initial focus if (!gotFocus) { @@ -1008,20 +1030,8 @@ public class JOptionPane extends JComponent implements Accessible setValue(JOptionPane.UNINITIALIZED_VALUE); } }); - addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - // Let the defaultCloseOperation handle the closing - // if the user closed the window without selecting a button - // (newValue = null in that case). Otherwise, close the dialog. - if (dialog.isVisible() && event.getSource() == JOptionPane.this && - (event.getPropertyName().equals(VALUE_PROPERTY) || - event.getPropertyName().equals(INPUT_VALUE_PROPERTY)) && - event.getNewValue() != null && - event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) { - dialog.setVisible(false); - } - } - }); + + addPropertyChangeListener(listener); } diff --git a/src/share/classes/javax/swing/Timer.java b/src/share/classes/javax/swing/Timer.java index 9e98d5f920e87490c687939f4c8e63bd4878de8c..c6c80baeda9299708dec103a64900e0cad40084e 100644 --- a/src/share/classes/javax/swing/Timer.java +++ b/src/share/classes/javax/swing/Timer.java @@ -35,6 +35,10 @@ import java.util.concurrent.locks.*; import java.awt.*; import java.awt.event.*; import java.io.Serializable; +import java.io.*; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedAction; import javax.swing.event.EventListenerList; @@ -208,6 +212,22 @@ public class Timer implements Serializable } } + /* + * The timer's AccessControlContext. + */ + private transient volatile AccessControlContext acc = + AccessController.getContext(); + + /** + * Returns the acc this timer was constructed with. + */ + final AccessControlContext getAccessControlContext() { + if (acc == null) { + throw new SecurityException( + "Timer is missing AccessControlContext"); + } + return acc; + } /** * DoPostEvent is a runnable class that fires actionEvents to @@ -587,8 +607,13 @@ public class Timer implements Serializable void post() { - if (notify.compareAndSet(false, true) || !coalesce) { - SwingUtilities.invokeLater(doPostEvent); + if (notify.compareAndSet(false, true) || !coalesce) { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { + SwingUtilities.invokeLater(doPostEvent); + return null; + } + }, getAccessControlContext()); } } @@ -596,6 +621,13 @@ public class Timer implements Serializable return lock; } + private void readObject(ObjectInputStream in) + throws ClassNotFoundException, IOException + { + this.acc = AccessController.getContext(); + in.defaultReadObject(); + } + /* * We have to use readResolve because we can not initialize final * fields for deserialized object otherwise diff --git a/src/share/classes/javax/swing/TransferHandler.java b/src/share/classes/javax/swing/TransferHandler.java index eb7f8d1a644a3678d3bb7e5374d2b92e780f8619..dd54b259eef06c386d986e838bdf7ba148401f65 100644 --- a/src/share/classes/javax/swing/TransferHandler.java +++ b/src/share/classes/javax/swing/TransferHandler.java @@ -42,6 +42,16 @@ import sun.awt.AppContext; import sun.swing.*; import sun.awt.SunToolkit; +import java.security.AccessController; +import java.security.PrivilegedAction; + +import java.security.AccessControlContext; +import java.security.ProtectionDomain; +import sun.misc.SharedSecrets; +import sun.misc.JavaSecurityAccess; + +import sun.awt.AWTAccessor; + /** * This class is used to handle the transfer of a Transferable * to and from Swing components. The Transferable is used to @@ -1686,7 +1696,37 @@ public class TransferHandler implements Serializable { return true; } - public void actionPerformed(ActionEvent e) { + private static final JavaSecurityAccess javaSecurityAccess = + SharedSecrets.getJavaSecurityAccess(); + + public void actionPerformed(final ActionEvent e) { + final Object src = e.getSource(); + + final PrivilegedAction action = new PrivilegedAction() { + public Void run() { + actionPerformedImpl(e); + return null; + } + }; + + final AccessControlContext stack = AccessController.getContext(); + final AccessControlContext srcAcc = AWTAccessor.getComponentAccessor().getAccessControlContext((Component)src); + final AccessControlContext eventAcc = AWTAccessor.getAWTEventAccessor().getAccessControlContext(e); + + if (srcAcc == null) { + javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc); + } else { + javaSecurityAccess.doIntersectionPrivilege( + new PrivilegedAction() { + public Void run() { + javaSecurityAccess.doIntersectionPrivilege(action, eventAcc); + return null; + } + }, stack, srcAcc); + } + } + + private void actionPerformedImpl(ActionEvent e) { Object src = e.getSource(); if (src instanceof JComponent) { JComponent c = (JComponent) src; diff --git a/src/share/classes/overview-core.html b/src/share/classes/overview-core.html index 86f33fe6ce9c1e9a51c209699b5c149841fb0e00..c4b518c57b8e29567b8e44c7d39c56e0f95dcb74 100644 --- a/src/share/classes/overview-core.html +++ b/src/share/classes/overview-core.html @@ -33,7 +33,7 @@ questions. -This document is the API specification for version 6 of the Java™ +This document is the API specification for the Java™ Platform, Standard Edition. diff --git a/src/share/classes/sun/applet/resources/MsgAppletViewer.java b/src/share/classes/sun/applet/resources/MsgAppletViewer.java index 015bcd3f442ffec2cd843fbd44b009459fa77c66..af1f3d5a60994b60ee67e9d9760de166c6efaff8 100644 --- a/src/share/classes/sun/applet/resources/MsgAppletViewer.java +++ b/src/share/classes/sun/applet/resources/MsgAppletViewer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,7 +103,6 @@ public class MsgAppletViewer extends ListResourceBundle { {"appletclassloader.fileexception", "{0} exception when loading: {1}"}, {"appletclassloader.filedeath", "{0} killed when loading: {1}"}, {"appletclassloader.fileerror", "{0} error when loading: {1}"}, - {"appletclassloader.findclass.verbose.findclass", "{0} find class {1}"}, {"appletclassloader.findclass.verbose.openstream", "Opening stream to: {0} to get {1}"}, {"appletclassloader.getresource.verbose.forname", "AppletClassLoader.getResource for name: {0}"}, {"appletclassloader.getresource.verbose.found", "Found resource: {0} as a system resource"}, diff --git a/src/share/classes/sun/awt/AWTAccessor.java b/src/share/classes/sun/awt/AWTAccessor.java index 0e38de6df6fdfb26d2dfeaed02caafe0c5c42258..b88531dfcd21efb09ed08403ec81497acb130947 100644 --- a/src/share/classes/sun/awt/AWTAccessor.java +++ b/src/share/classes/sun/awt/AWTAccessor.java @@ -33,6 +33,9 @@ import java.awt.image.BufferedImage; import sun.misc.Unsafe; import java.awt.peer.ComponentPeer; +import java.security.AccessController; +import java.security.AccessControlContext; + /** * The AWTAccessor utility class. * The main purpose of this class is to enable accessing @@ -221,6 +224,13 @@ public final class AWTAccessor { * Processes events occurring on this component. */ void processEvent(Component comp, AWTEvent e); + + + /* + * Returns the acc this component was constructed with. + */ + AccessControlContext getAccessControlContext(Component comp); + } /* @@ -323,6 +333,13 @@ public final class AWTAccessor { * Indicates whether this AWTEvent was generated by the system. */ boolean isSystemGenerated(AWTEvent ev); + + + /* + * Returns the acc this event was constructed with. + */ + AccessControlContext getAccessControlContext(AWTEvent ev); + } public interface InputEventAccessor { diff --git a/src/share/classes/sun/dyn/Access.java b/src/share/classes/sun/dyn/Access.java deleted file mode 100644 index 931303b03b6e23ebec15736cad7281ce34266c71..0000000000000000000000000000000000000000 --- a/src/share/classes/sun/dyn/Access.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.dyn; - -import sun.reflect.Reflection; - -/** - * Access control to this package. - * Classes in other packages can attempt to acquire the access token, - * but will fail if they are not recognized as friends. - * Certain methods in this package, although public, require a non-null - * access token in order to proceed; they act like package-private methods. - * @author jrose - */ - -public class Access { - - private Access() { } - - /** - * The heart of this pattern: The list of classes which are - * permitted to acquire the access token, and become honorary - * members of this package. - */ - private static final String[] FRIENDS = { - "java.dyn.", "sun.dyn." - }; - - /** - * The following object is NOT public. That's the point of the pattern. - * It is package-private, so that any member of this package - * can acquire the access token, and give it away to trusted friends. - */ - static final Access TOKEN = new Access(); - - /** - * @return Access.TOKEN, if the caller is a friend of this package - */ - public static Access getToken() { - Class callc = Reflection.getCallerClass(2); - if (isFriend(callc)) - return TOKEN; - else - throw new IllegalAccessError("bad caller: " + callc); - } - - /** Is the given name the name of a class which could be our friend? */ - public static boolean isFriendName(String name) { - for (String friend : FRIENDS) { - if (name.startsWith(friend)) - return true; - } - return false; - } - - /** Is the given class a friend? True if {@link #isFriendName}, - * and the given class also shares a class loader with us. - */ - public static boolean isFriend(Class c) { - return isFriendName(c.getName()) && c.getClassLoader() == CLASS_LOADER; - } - - private static final ClassLoader CLASS_LOADER = Access.class.getClassLoader(); - - /** - * Throw an IllegalAccessError if the caller does not possess - * the Access.TOKEN. - * @param must be Access.TOKEN - */ - public static void check(Access token) { - if (token == null) - fail(); - // else it must be the unique Access.TOKEN - assert(token == Access.TOKEN); - } - private static void fail() { - final int CALLER_DEPTH = 3; - // 0: Reflection.getCC, 1: this.fail, 2: Access.*, 3: caller - Class callc = Reflection.getCallerClass(CALLER_DEPTH); - throw new IllegalAccessError("bad caller: " + callc); - } - - static { - //sun.reflect.Reflection.registerMethodsToFilter(MH.class, "getToken"); - } -} diff --git a/src/share/classes/sun/dyn/CallSiteImpl.java b/src/share/classes/sun/dyn/CallSiteImpl.java deleted file mode 100644 index 703788ff48440306eabc79b7c7843fb3529b2b1b..0000000000000000000000000000000000000000 --- a/src/share/classes/sun/dyn/CallSiteImpl.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.dyn; - -import java.dyn.*; -import static sun.dyn.MemberName.uncaughtException; - -/** - * Parts of CallSite known to the JVM. - * @author jrose - */ -public class CallSiteImpl { - // this implements the upcall from the JVM, MethodHandleNatives.makeDynamicCallSite: - static CallSite makeSite(MethodHandle bootstrapMethod, - // Callee information: - String name, MethodType type, - // Extra arguments for BSM, if any: - Object info, - // Caller information: - MemberName callerMethod, int callerBCI) { - Class callerClass = callerMethod.getDeclaringClass(); - Object caller; - if (bootstrapMethod.type().parameterType(0) == Class.class && TRANSITIONAL_BEFORE_PFD) - caller = callerClass; // remove for PFD - else - caller = MethodHandleImpl.IMPL_LOOKUP.in(callerClass); - if (bootstrapMethod == null && TRANSITIONAL_BEFORE_PFD) { - // If there is no bootstrap method, throw IncompatibleClassChangeError. - // This is a valid generic error type for resolution (JLS 12.3.3). - throw new IncompatibleClassChangeError - ("Class "+callerClass.getName()+" has not declared a bootstrap method for invokedynamic"); - } - CallSite site; - try { - Object binding; - info = maybeReBox(info); - if (info == null) { - binding = bootstrapMethod.invokeGeneric(caller, name, type); - } else if (!info.getClass().isArray()) { - binding = bootstrapMethod.invokeGeneric(caller, name, type, info); - } else { - Object[] argv = (Object[]) info; - if (3 + argv.length > 255) - new InvokeDynamicBootstrapError("too many bootstrap method arguments"); - MethodType bsmType = bootstrapMethod.type(); - if (bsmType.parameterCount() == 4 && bsmType.parameterType(3) == Object[].class) - binding = bootstrapMethod.invokeGeneric(caller, name, type, argv); - else - binding = MethodHandles.spreadInvoker(bsmType, 3) - .invokeGeneric(bootstrapMethod, caller, name, type, argv); - } - //System.out.println("BSM for "+name+type+" => "+binding); - if (binding instanceof CallSite) { - site = (CallSite) binding; - } else if (binding instanceof MethodHandle && TRANSITIONAL_BEFORE_PFD) { - // Transitional! - MethodHandle target = (MethodHandle) binding; - site = new ConstantCallSite(target); - } else { - throw new ClassCastException("bootstrap method failed to produce a CallSite"); - } - if (TRANSITIONAL_BEFORE_PFD) - PRIVATE_INITIALIZE_CALL_SITE.invokeExact(site, name, type, - callerMethod, callerBCI); - assert(site.getTarget() != null); - assert(site.getTarget().type().equals(type)); - } catch (Throwable ex) { - InvokeDynamicBootstrapError bex; - if (ex instanceof InvokeDynamicBootstrapError) - bex = (InvokeDynamicBootstrapError) ex; - else - bex = new InvokeDynamicBootstrapError("call site initialization exception", ex); - throw bex; - } - return site; - } - - private static boolean TRANSITIONAL_BEFORE_PFD = true; // FIXME: remove for PFD - - private static Object maybeReBox(Object x) { - if (x instanceof Integer) { - int xi = (int) x; - if (xi == (byte) xi) - x = xi; // must rebox; see JLS 5.1.7 - return x; - } else if (x instanceof Object[]) { - Object[] xa = (Object[]) x; - for (int i = 0; i < xa.length; i++) { - if (xa[i] instanceof Integer) - xa[i] = maybeReBox(xa[i]); - } - return xa; - } else { - return x; - } - } - - // This method is private in CallSite because it touches private fields in CallSite. - // These private fields (vmmethod, vmindex) are specific to the JVM. - private static final MethodHandle PRIVATE_INITIALIZE_CALL_SITE; - static { - try { - PRIVATE_INITIALIZE_CALL_SITE = - !TRANSITIONAL_BEFORE_PFD ? null : - MethodHandleImpl.IMPL_LOOKUP.findVirtual(CallSite.class, "initializeFromJVM", - MethodType.methodType(void.class, - String.class, MethodType.class, - MemberName.class, int.class)); - } catch (ReflectiveOperationException ex) { - throw uncaughtException(ex); - } - } - - public static void setCallSiteTarget(Access token, CallSite site, MethodHandle target) { - Access.check(token); - MethodHandleNatives.setCallSiteTarget(site, target); - } -} diff --git a/src/share/classes/sun/font/FileFont.java b/src/share/classes/sun/font/FileFont.java index 22096dda2eb7cda9d8e7eaca8b157e6928fced4c..1c63e9f11596d67a3fea685bdee8c55affa39287 100644 --- a/src/share/classes/sun/font/FileFont.java +++ b/src/share/classes/sun/font/FileFont.java @@ -32,22 +32,13 @@ import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.File; import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; import sun.java2d.Disposer; import sun.java2d.DisposerRecord; -import java.lang.ref.WeakReference; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.RandomAccessFile; -import java.io.UnsupportedEncodingException; -import java.nio.ByteOrder; -import java.nio.MappedByteBuffer; -import java.nio.BufferUnderflowException; -import java.nio.channels.ClosedChannelException; -import java.util.HashSet; -import java.util.HashMap; -import java.awt.Font; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; public abstract class FileFont extends PhysicalFont { @@ -286,4 +277,49 @@ public abstract class FileFont extends PhysicalFont { }); } } + + protected String getPublicFileName() { + SecurityManager sm = System.getSecurityManager(); + if (sm == null) { + return platName; + } + boolean canReadProperty = true; + + try { + sm.checkPropertyAccess("java.io.tmpdir"); + } catch (SecurityException e) { + canReadProperty = false; + } + + if (canReadProperty) { + return platName; + } + + final File f = new File(platName); + + Boolean isTmpFile = Boolean.FALSE; + try { + isTmpFile = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Boolean run() { + File tmp = new File(System.getProperty("java.io.tmpdir")); + try { + String tpath = tmp.getCanonicalPath(); + String fpath = f.getCanonicalPath(); + + return (fpath == null) || fpath.startsWith(tpath); + } catch (IOException e) { + return Boolean.TRUE; + } + } + } + ); + } catch (PrivilegedActionException e) { + // unable to verify whether value of java.io.tempdir will be + // exposed, so return only a name of the font file. + isTmpFile = Boolean.TRUE; + } + + return isTmpFile ? "temp file" : platName; + } } diff --git a/src/share/classes/sun/font/TrueTypeFont.java b/src/share/classes/sun/font/TrueTypeFont.java index e448338a3f30898ebf2a86f1af40eda704babfc3..84cbd2c9a34c3cab90cdb3aa0c88804cfea122cd 100644 --- a/src/share/classes/sun/font/TrueTypeFont.java +++ b/src/share/classes/sun/font/TrueTypeFont.java @@ -519,7 +519,8 @@ public class TrueTypeFont extends FileFont { break; default: - throw new FontFormatException("Unsupported sfnt " + platName); + throw new FontFormatException("Unsupported sfnt " + + getPublicFileName()); } /* Now have the offset of this TT font (possibly within a TTC) @@ -1680,7 +1681,6 @@ public class TrueTypeFont extends FileFont { @Override public String toString() { return "** TrueType Font: Family="+familyName+ " Name="+fullName+ - " style="+style+" fileName="+platName; + " style="+style+" fileName="+getPublicFileName(); } - } diff --git a/src/share/classes/sun/font/Type1Font.java b/src/share/classes/sun/font/Type1Font.java index 48821dd94e55a3b515e8a1a1d75608ff6d1d4737..5fa49bd132d7a0757ccab72734247d856d1ee40c 100644 --- a/src/share/classes/sun/font/Type1Font.java +++ b/src/share/classes/sun/font/Type1Font.java @@ -677,6 +677,6 @@ public class Type1Font extends FileFont { public String toString() { return "** Type1 Font: Family="+familyName+ " Name="+fullName+ - " style="+style+" fileName="+platName; + " style="+style+" fileName="+getPublicFileName(); } } diff --git a/src/share/classes/sun/dyn/WrapperInstance.java b/src/share/classes/sun/invoke/WrapperInstance.java similarity index 90% rename from src/share/classes/sun/dyn/WrapperInstance.java rename to src/share/classes/sun/invoke/WrapperInstance.java index d6e91fd0d03b5ebe86d444fdaa20be878ebccc4b..ba918b4d9d2ae8863e37db25271baddd89a47245 100644 --- a/src/share/classes/sun/dyn/WrapperInstance.java +++ b/src/share/classes/sun/invoke/WrapperInstance.java @@ -23,14 +23,14 @@ * questions. */ -package sun.dyn; +package sun.invoke; -import java.dyn.MethodHandle; +import java.lang.invoke.MethodHandle; /** - * Private API used inside of java.dyn.MethodHandles. + * Private API used inside of java.lang.invoke.MethodHandles. * Interface implemented by every object which is produced by - * {@link java.dyn.MethodHandles#asInstance MethodHandles.asInstance}. + * {@link java.lang.invoke.MethodHandles#asInstance MethodHandles.asInstance}. * The methods of this interface allow a caller to recover the parameters * to {@code asInstance}. * This allows applications to repeatedly convert between method handles diff --git a/src/share/classes/sun/dyn/anon/AnonymousClassLoader.java b/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java similarity index 99% rename from src/share/classes/sun/dyn/anon/AnonymousClassLoader.java rename to src/share/classes/sun/invoke/anon/AnonymousClassLoader.java index bd7c5cb59dd7442238fa36f9128c49039c434b07..3005a452f71e39716b7727660e09e09b273941c1 100644 --- a/src/share/classes/sun/dyn/anon/AnonymousClassLoader.java +++ b/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ * questions. */ -package sun.dyn.anon; +package sun.invoke.anon; import java.io.IOException; import java.lang.reflect.InvocationTargetException; diff --git a/src/share/classes/sun/dyn/anon/ConstantPoolParser.java b/src/share/classes/sun/invoke/anon/ConstantPoolParser.java similarity index 99% rename from src/share/classes/sun/dyn/anon/ConstantPoolParser.java rename to src/share/classes/sun/invoke/anon/ConstantPoolParser.java index b68b3f650c947f7659128258e7b39649d6826e95..441ba9573365b0b1961f84ae297f8fc09c948b87 100644 --- a/src/share/classes/sun/dyn/anon/ConstantPoolParser.java +++ b/src/share/classes/sun/invoke/anon/ConstantPoolParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,14 +23,14 @@ * questions. */ -package sun.dyn.anon; +package sun.invoke.anon; import java.io.IOException; import java.io.OutputStream; import java.nio.BufferUnderflowException; import java.nio.ByteBuffer; -import static sun.dyn.anon.ConstantPoolVisitor.*; +import static sun.invoke.anon.ConstantPoolVisitor.*; /** A constant pool parser. */ diff --git a/src/share/classes/sun/dyn/anon/ConstantPoolPatch.java b/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java similarity index 99% rename from src/share/classes/sun/dyn/anon/ConstantPoolPatch.java rename to src/share/classes/sun/invoke/anon/ConstantPoolPatch.java index 87dc97f6025696c82e31cf7775b0858bbcd6729d..259d4b2336e5f819225124d275e8ed60bd72a54f 100644 --- a/src/share/classes/sun/dyn/anon/ConstantPoolPatch.java +++ b/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ * questions. */ -package sun.dyn.anon; +package sun.invoke.anon; import java.io.IOException; import java.io.OutputStream; @@ -32,7 +32,7 @@ import java.util.HashSet; import java.util.IdentityHashMap; import java.util.Map; -import static sun.dyn.anon.ConstantPoolVisitor.*; +import static sun.invoke.anon.ConstantPoolVisitor.*; /** A class and its patched constant pool. * diff --git a/src/share/classes/sun/dyn/anon/ConstantPoolVisitor.java b/src/share/classes/sun/invoke/anon/ConstantPoolVisitor.java similarity index 98% rename from src/share/classes/sun/dyn/anon/ConstantPoolVisitor.java rename to src/share/classes/sun/invoke/anon/ConstantPoolVisitor.java index e882b7d672417fdb31f62de063059128b51f7b0c..dfec8b41151e22664f6d41c2932bae26c2301202 100644 --- a/src/share/classes/sun/dyn/anon/ConstantPoolVisitor.java +++ b/src/share/classes/sun/invoke/anon/ConstantPoolVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ * questions. */ -package sun.dyn.anon; +package sun.invoke.anon; /** * A visitor called by {@link ConstantPoolParser#parse(ConstantPoolVisitor)} diff --git a/src/share/classes/sun/dyn/anon/InvalidConstantPoolFormatException.java b/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java similarity index 94% rename from src/share/classes/sun/dyn/anon/InvalidConstantPoolFormatException.java rename to src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java index 555bb428f3fc5957779e55dc750c8f1f5cc54a6c..d420d34b0d610ee928efb613dae309148d80c5d8 100644 --- a/src/share/classes/sun/dyn/anon/InvalidConstantPoolFormatException.java +++ b/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ * questions. */ -package sun.dyn.anon; +package sun.invoke.anon; /** Exception used when there is an error in the constant pool * format. diff --git a/src/share/classes/sun/dyn/empty/Empty.java b/src/share/classes/sun/invoke/empty/Empty.java similarity index 90% rename from src/share/classes/sun/dyn/empty/Empty.java rename to src/share/classes/sun/invoke/empty/Empty.java index 416a6f128e88aca645aacd8bbb8889cbe41b1e1d..f75d2b3d01604479beb5591b5b2c4b7a86c90b0e 100644 --- a/src/share/classes/sun/dyn/empty/Empty.java +++ b/src/share/classes/sun/invoke/empty/Empty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,14 +23,14 @@ * questions. */ -package sun.dyn.empty; +package sun.invoke.empty; /** * An empty class in an empty package. * Used as a proxy for unprivileged code, since making access checks * against it will only succeed against public methods in public types. *

    - * This class also stands (internally to sun.dyn) for the type of a + * This class also stands (internally to sun.invoke) for the type of a * value that cannot be produced, because the expression of this type * always returns abnormally. (Cf. Nothing in the closures proposal.) * @author jrose diff --git a/src/share/classes/sun/dyn/package-info.java b/src/share/classes/sun/invoke/package-info.java similarity index 93% rename from src/share/classes/sun/dyn/package-info.java rename to src/share/classes/sun/invoke/package-info.java index d129b0f5a27a8ddb2358e63941240501ee20e6db..74999fe6c7e827602732bdb9fbdaddd076d7003d 100644 --- a/src/share/classes/sun/dyn/package-info.java +++ b/src/share/classes/sun/invoke/package-info.java @@ -24,8 +24,8 @@ */ /** - * Implementation details for JSR 292 RI, package java.dyn. + * Implementation details for JSR 292 RI, package java.lang.invoke. * @author jrose */ -package sun.dyn; +package sun.invoke; diff --git a/src/share/classes/sun/dyn/util/BytecodeDescriptor.java b/src/share/classes/sun/invoke/util/BytecodeDescriptor.java similarity index 97% rename from src/share/classes/sun/dyn/util/BytecodeDescriptor.java rename to src/share/classes/sun/invoke/util/BytecodeDescriptor.java index 2c59b9183388a1520610b8d09d1736e21a24d0d6..ccc313cd41bed0ce0ee7fa242e849b4f789ba644 100644 --- a/src/share/classes/sun/dyn/util/BytecodeDescriptor.java +++ b/src/share/classes/sun/invoke/util/BytecodeDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,9 @@ * questions. */ -package sun.dyn.util; +package sun.invoke.util; -import java.dyn.MethodType; +import java.lang.invoke.MethodType; import java.util.ArrayList; import java.util.List; diff --git a/src/share/classes/sun/dyn/util/BytecodeName.java b/src/share/classes/sun/invoke/util/BytecodeName.java similarity index 99% rename from src/share/classes/sun/dyn/util/BytecodeName.java rename to src/share/classes/sun/invoke/util/BytecodeName.java index 73be3fb13617818430119b2408f03a1997ea877b..9b8fa35cb70b022a174828e36a2be0056b5561f2 100644 --- a/src/share/classes/sun/dyn/util/BytecodeName.java +++ b/src/share/classes/sun/invoke/util/BytecodeName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ * questions. */ -package sun.dyn.util; +package sun.invoke.util; /** * Utility routines for dealing with bytecode-level names. diff --git a/src/share/classes/sun/dyn/util/ValueConversions.java b/src/share/classes/sun/invoke/util/ValueConversions.java similarity index 94% rename from src/share/classes/sun/dyn/util/ValueConversions.java rename to src/share/classes/sun/invoke/util/ValueConversions.java index 374bd245058a473b396868c98566b7433badc4af..c6a56abf665ffe54b28f82831e6c73099c74cfc7 100644 --- a/src/share/classes/sun/dyn/util/ValueConversions.java +++ b/src/share/classes/sun/invoke/util/ValueConversions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,22 +23,19 @@ * questions. */ -package sun.dyn.util; +package sun.invoke.util; -import java.dyn.*; -import java.dyn.MethodHandles.Lookup; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; +import java.lang.invoke.MethodType; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumMap; import java.util.List; -import sun.dyn.Access; -import sun.dyn.AdapterMethodHandle; -import sun.dyn.MethodHandleImpl; -import static sun.dyn.MemberName.uncaughtException; public class ValueConversions { - private static final Access IMPL_TOKEN = Access.getToken(); - private static final Lookup IMPL_LOOKUP = MethodHandleImpl.getLookup(IMPL_TOKEN); + private static final Lookup IMPL_LOOKUP = MethodHandles.lookup(); private static EnumMap[] newWrapperCaches(int n) { @SuppressWarnings("unchecked") @@ -157,7 +154,7 @@ public class ValueConversions { mh = null; } } else { - mh = retype(type, unbox(wrap, !exact, raw)); + mh = unbox(wrap, !exact, raw).asType(type); } if (mh != null) { cache.put(wrap, mh); @@ -293,7 +290,7 @@ public class ValueConversions { mh = null; } } else { - mh = retype(type.erase(), box(wrap, !exact, raw)); + mh = box(wrap, !exact, raw).asType(type.erase()); } if (mh != null) { cache.put(wrap, mh); @@ -412,7 +409,7 @@ public class ValueConversions { mh = null; } } else { - mh = retype(IDENTITY.type(), rebox(wrap, !exact)); + mh = rebox(wrap, !exact).asType(IDENTITY.type()); } if (mh != null) { cache.put(wrap, mh); @@ -504,8 +501,8 @@ public class ValueConversions { // use the raw method Wrapper rawWrap = wrap.rawPrimitive(); - if (rawWrap != wrap) { - mh = retype(type, zeroConstantFunction(rawWrap)); + if (mh == null && rawWrap != wrap) { + mh = MethodHandles.explicitCastArguments(zeroConstantFunction(rawWrap), type); } if (mh != null) { cache.put(wrap, mh); @@ -552,6 +549,22 @@ public class ValueConversions { return x; } + static byte identity(byte x) { + return x; + } + + static short identity(short x) { + return x; + } + + static boolean identity(boolean x) { + return x; + } + + static char identity(char x) { + return x; + } + /** * Identity function on longs. * @param x an arbitrary long value @@ -561,6 +574,14 @@ public class ValueConversions { return x; } + static float identity(float x) { + return x; + } + + static double identity(double x) { + return x; + } + /** * Identity function, with reference cast. * @param t an arbitrary reference type @@ -590,7 +611,9 @@ public class ValueConversions { IGNORE = IMPL_LOOKUP.findStatic(ValueConversions.class, "ignore", ignoreType); EMPTY = IMPL_LOOKUP.findStatic(ValueConversions.class, "empty", ignoreType.dropParameterTypes(0, 1)); } catch (Exception ex) { - throw uncaughtException(ex); + Error err = new InternalError("uncaught exception"); + err.initCause(ex); + throw err; } } @@ -622,7 +645,8 @@ public class ValueConversions { mh = MethodHandles.insertArguments(CAST_REFERENCE, 0, type); if (exact) { MethodType xmt = MethodType.methodType(type, Object.class); - mh = AdapterMethodHandle.makeRetypeRaw(IMPL_TOKEN, xmt, mh); + mh = MethodHandles.explicitCastArguments(mh, xmt); + //mh = AdapterMethodHandle.makeRetypeRaw(IMPL_TOKEN, xmt, mh); } if (cache != null) cache.put(wrap, mh); @@ -634,15 +658,11 @@ public class ValueConversions { } public static MethodHandle identity(Class type) { - if (type == Object.class) - return IDENTITY; - else if (!type.isPrimitive()) - return retype(MethodType.methodType(type, type), IDENTITY); - else - return identity(Wrapper.forPrimitiveType(type)); + // This stuff has been moved into MethodHandles: + return MethodHandles.identity(type); } - static MethodHandle identity(Wrapper wrap) { + public static MethodHandle identity(Wrapper wrap) { EnumMap cache = CONSTANT_FUNCTIONS[1]; MethodHandle mh = cache.get(wrap); if (mh != null) { @@ -665,12 +685,6 @@ public class ValueConversions { return mh; } - // use a raw conversion - if (wrap.isSingleWord() && wrap != Wrapper.INT) { - mh = retype(type, identity(Wrapper.INT)); - } else if (wrap.isDoubleWord() && wrap != Wrapper.LONG) { - mh = retype(type, identity(Wrapper.LONG)); - } if (mh != null) { cache.put(wrap, mh); return mh; @@ -678,10 +692,6 @@ public class ValueConversions { throw new IllegalArgumentException("cannot find identity for " + wrap); } - private static MethodHandle retype(MethodType type, MethodHandle mh) { - return AdapterMethodHandle.makeRetypeRaw(IMPL_TOKEN, type, mh); - } - private static final Object[] NO_ARGS_ARRAY = {}; private static Object[] makeArray(Object... args) { return args; } private static Object[] array() { return NO_ARGS_ARRAY; } diff --git a/src/share/classes/sun/dyn/util/VerifyAccess.java b/src/share/classes/sun/invoke/util/VerifyAccess.java similarity index 98% rename from src/share/classes/sun/dyn/util/VerifyAccess.java rename to src/share/classes/sun/invoke/util/VerifyAccess.java index 1114bad269509788a0c747bb068155b6a07a4f55..657aeec23d8393ef8a723cb948216763a7977550 100644 --- a/src/share/classes/sun/dyn/util/VerifyAccess.java +++ b/src/share/classes/sun/invoke/util/VerifyAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,12 +23,9 @@ * questions. */ -package sun.dyn.util; +package sun.invoke.util; import java.lang.reflect.Modifier; -import sun.dyn.MemberName; -import sun.dyn.MethodHandleImpl; -import sun.dyn.empty.Empty; import static java.lang.reflect.Modifier.*; /** diff --git a/src/share/classes/sun/dyn/util/VerifyType.java b/src/share/classes/sun/invoke/util/VerifyType.java similarity index 98% rename from src/share/classes/sun/dyn/util/VerifyType.java rename to src/share/classes/sun/invoke/util/VerifyType.java index b6277e4a8a97ea1e7f8c6f5464c6438612b59bc9..39286d09ca4aa26433111ce7d81227f94e15afd5 100644 --- a/src/share/classes/sun/dyn/util/VerifyType.java +++ b/src/share/classes/sun/invoke/util/VerifyType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,10 @@ * questions. */ -package sun.dyn.util; +package sun.invoke.util; -import java.dyn.MethodType; -import sun.dyn.empty.Empty; +import java.lang.invoke.MethodType; +import sun.invoke.empty.Empty; /** * This class centralizes information about the JVM verifier diff --git a/src/share/classes/sun/dyn/util/Wrapper.java b/src/share/classes/sun/invoke/util/Wrapper.java similarity index 99% rename from src/share/classes/sun/dyn/util/Wrapper.java rename to src/share/classes/sun/invoke/util/Wrapper.java index 91b599e8c648fdf99986622bdb1d46dea8e54098..8e2ce57838607f90450b4054a770b60cad278e56 100644 --- a/src/share/classes/sun/dyn/util/Wrapper.java +++ b/src/share/classes/sun/invoke/util/Wrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ * questions. */ -package sun.dyn.util; +package sun.invoke.util; public enum Wrapper { BOOLEAN(Boolean.class, boolean.class, 'Z', (Boolean)false, Format.unsigned(1)), @@ -267,7 +267,7 @@ public enum Wrapper { FROM_WRAP[wi] = w; FROM_CHAR[ci] = w; } - //assert(jdk.sun.dyn.util.WrapperTest.test(false)); + //assert(jdk.sun.invoke.util.WrapperTest.test(false)); } /** What is the primitive type wrapped by this wrapper? */ diff --git a/src/share/classes/sun/dyn/util/package-info.java b/src/share/classes/sun/invoke/util/package-info.java similarity index 88% rename from src/share/classes/sun/dyn/util/package-info.java rename to src/share/classes/sun/invoke/util/package-info.java index 0977b22ef9440544a7bb971f3a0b59bf1f2bfeb2..785ca8043020e3beb334803bc5af80ba6494ea5c 100644 --- a/src/share/classes/sun/dyn/util/package-info.java +++ b/src/share/classes/sun/invoke/util/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,8 +24,8 @@ */ /** - * Extra support for using JSR 292 RI, package java.dyn. + * Extra support for using JSR 292 RI, package java.lang.invoke. * @author jrose */ -package sun.dyn.util; +package sun.invoke.util; diff --git a/src/share/classes/sun/java2d/pisces/Helpers.java b/src/share/classes/sun/java2d/pisces/Helpers.java index b91bc6a400a3740f179403d5a639f7a194dab452..42c7f2654d3badf13cb208537656db7c29112008 100644 --- a/src/share/classes/sun/java2d/pisces/Helpers.java +++ b/src/share/classes/sun/java2d/pisces/Helpers.java @@ -154,9 +154,6 @@ final class Helpers { // These use a hardcoded factor of 2 for increasing sizes. Perhaps this // should be provided as an argument. static float[] widenArray(float[] in, final int cursize, final int numToAdd) { - if (in == null) { - return new float[5 * numToAdd]; - } if (in.length >= cursize + numToAdd) { return in; } diff --git a/src/share/classes/sun/java2d/pisces/PiscesTileGenerator.java b/src/share/classes/sun/java2d/pisces/PiscesTileGenerator.java index ba91edb9819b99e3a05a3b4e278ff6e7f70e05f2..3d6046bed6964c3151a50c2d87fa074ea3f650a1 100644 --- a/src/share/classes/sun/java2d/pisces/PiscesTileGenerator.java +++ b/src/share/classes/sun/java2d/pisces/PiscesTileGenerator.java @@ -191,8 +191,7 @@ final class PiscesTileGenerator implements AATileGenerator { System.out.println("len = "+runLen); System.out.print(cache.toString()); e0.printStackTrace(); - System.exit(1); - return; + throw e0; } int rx0 = cx; @@ -215,8 +214,7 @@ final class PiscesTileGenerator implements AATileGenerator { System.out.println("len = "+runLen); System.out.print(cache.toString()); e.printStackTrace(); - System.exit(1); - return; + throw e; } } pos += 2; @@ -250,4 +248,5 @@ final class PiscesTileGenerator implements AATileGenerator { * No further calls will be made on this instance. */ public void dispose() {} -} \ No newline at end of file +} + diff --git a/src/share/classes/sun/java2d/pisces/Renderer.java b/src/share/classes/sun/java2d/pisces/Renderer.java index cbfa2897d941d36c409701950110ded3b51a22b4..6d07b532e08122c2552cfd92fb1505d4c3636b0f 100644 --- a/src/share/classes/sun/java2d/pisces/Renderer.java +++ b/src/share/classes/sun/java2d/pisces/Renderer.java @@ -47,16 +47,16 @@ final class Renderer implements PathConsumer2D { private static final int INIT_CROSSINGS_SIZE = 10; - private ScanlineIterator() { + // Preconditions: Only subpixel scanlines in the range + // (start <= subpixel_y <= end) will be evaluated. No + // edge may have a valid (i.e. inside the supplied clip) + // crossing that would be generated outside that range. + private ScanlineIterator(int start, int end) { crossings = new int[INIT_CROSSINGS_SIZE]; edgePtrs = new int[INIT_CROSSINGS_SIZE]; - // We don't care if we clip some of the line off with ceil, since - // no scan line crossings will be eliminated (in fact, the ceil is - // the y of the first scan line crossing). - final int minY = getFirstScanLineCrossing(); - nextY = minY; - maxY = getScanLineCrossingEnd()-1; + nextY = start; + maxY = end; edgeCount = 0; } @@ -148,6 +148,7 @@ final class Renderer implements PathConsumer2D { // don't just set NULL to -1, because we want NULL+NEXT to be negative. private static final int NULL = -SIZEOF_EDGE; private float[] edges = null; + private static final int INIT_NUM_EDGES = 8; private int[] edgeBuckets = null; private int[] edgeBucketCounts = null; // 2*newedges + (1 if pruning needed) private int numEdges; @@ -156,7 +157,7 @@ final class Renderer implements PathConsumer2D { private static final float INC_BND = 8f; // each bucket is a linked list. this method adds eptr to the - // start "bucket"th linked list. + // start of the "bucket"th linked list. private void addEdgeToBucket(final int eptr, final int bucket) { edges[eptr+NEXT] = edgeBuckets[bucket]; edgeBuckets[bucket] = eptr; @@ -168,7 +169,8 @@ final class Renderer implements PathConsumer2D { // X0, Y0, D*[X|Y], COUNT; not variables used for computing scanline crossings). private void quadBreakIntoLinesAndAdd(float x0, float y0, final Curve c, - final float x2, final float y2) { + final float x2, final float y2) + { final float QUAD_DEC_BND = 32; final int countlg = 4; int count = 1 << countlg; @@ -204,7 +206,8 @@ final class Renderer implements PathConsumer2D { // here, but then too many numbers are passed around. private void curveBreakIntoLinesAndAdd(float x0, float y0, final Curve c, - final float x3, final float y3) { + final float x3, final float y3) + { final int countlg = 3; int count = 1 << countlg; @@ -259,8 +262,6 @@ final class Renderer implements PathConsumer2D { } } - // Preconditions: y2 > y1 and the curve must cross some scanline - // i.e.: y1 <= y < y2 for some y such that boundsMinY <= y < boundsMaxY private void addLine(float x1, float y1, float x2, float y2) { float or = 1; // orientation of the line. 1 if y increases, 0 otherwise. if (y2 < y1) { @@ -272,12 +273,11 @@ final class Renderer implements PathConsumer2D { x1 = or; or = 0; } - final int firstCrossing = Math.max((int) Math.ceil(y1), boundsMinY); + final int firstCrossing = Math.max((int)Math.ceil(y1), boundsMinY); final int lastCrossing = Math.min((int)Math.ceil(y2), boundsMaxY); if (firstCrossing >= lastCrossing) { return; } - if (y1 < edgeMinY) { edgeMinY = y1; } if (y2 > edgeMaxY) { edgeMaxY = y2; } @@ -297,22 +297,10 @@ final class Renderer implements PathConsumer2D { edges[ptr+OR] = or; edges[ptr+CURX] = x1 + (firstCrossing - y1) * slope; edges[ptr+SLOPE] = slope; - edges[ptr+YMAX] = y2; + edges[ptr+YMAX] = lastCrossing; final int bucketIdx = firstCrossing - boundsMinY; addEdgeToBucket(ptr, bucketIdx); - if (lastCrossing < boundsMaxY) { - edgeBucketCounts[lastCrossing - boundsMinY] |= 1; - } - } - - // preconditions: should not be called before the last line has been added - // to the edge list (even though it will return a correct answer at that - // point in time, it's not meant to be used that way). - private int getFirstScanLineCrossing() { - return Math.max(boundsMinY, (int)Math.ceil(edgeMinY)); - } - private int getScanLineCrossingEnd() { - return Math.min(boundsMaxY, (int)Math.ceil(edgeMaxY)); + edgeBucketCounts[lastCrossing - boundsMinY] |= 1; } // END EDGE LIST @@ -366,9 +354,11 @@ final class Renderer implements PathConsumer2D { this.boundsMaxX = (pix_boundsX + pix_boundsWidth) * SUBPIXEL_POSITIONS_X; this.boundsMaxY = (pix_boundsY + pix_boundsHeight) * SUBPIXEL_POSITIONS_Y; + edges = new float[INIT_NUM_EDGES * SIZEOF_EDGE]; + numEdges = 0; edgeBuckets = new int[boundsMaxY - boundsMinY]; java.util.Arrays.fill(edgeBuckets, NULL); - edgeBucketCounts = new int[edgeBuckets.length]; + edgeBucketCounts = new int[edgeBuckets.length + 1]; } private float tosubpixx(float pix_x) { @@ -394,7 +384,7 @@ final class Renderer implements PathConsumer2D { y0 = y1; } - Curve c = new Curve(); + private Curve c = new Curve(); @Override public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) @@ -431,8 +421,8 @@ final class Renderer implements PathConsumer2D { throw new InternalError("Renderer does not use a native consumer."); } - private void _endRendering(final int pix_bboxx0, final int pix_bboxy0, - final int pix_bboxx1, final int pix_bboxy1) + private void _endRendering(final int pix_bboxx0, final int pix_bboxx1, + int ymin, int ymax) { // Mask to determine the relevant bit of the crossing sum // 0x1 if EVEN_ODD, all bits if NON_ZERO @@ -455,7 +445,7 @@ final class Renderer implements PathConsumer2D { int pix_minX = Integer.MAX_VALUE; int y = boundsMinY; // needs to be declared here so we emit the last row properly. - ScanlineIterator it = this.new ScanlineIterator(); + ScanlineIterator it = this.new ScanlineIterator(ymin, ymax); for ( ; it.hasNext(); ) { int numCrossings = it.next(); int[] crossings = it.crossings; @@ -477,7 +467,7 @@ final class Renderer implements PathConsumer2D { int curxo = crossings[i]; int curx = curxo >> 1; // to turn {0, 1} into {-1, 1}, multiply by 2 and subtract 1. - int crorientation = ((curxo & 0x1) << 1) -1; + int crorientation = ((curxo & 0x1) << 1) - 1; if ((sum & mask) != 0) { int x0 = Math.max(prev, bboxx0); int x1 = Math.min(curx, bboxx1); @@ -541,7 +531,7 @@ final class Renderer implements PathConsumer2D { } this.cache = new PiscesCache(pminX, pminY, pmaxX, pmaxY); - _endRendering(pminX, pminY, pmaxX, pmaxY); + _endRendering(pminX, pmaxX, spminY, spmaxY); } public PiscesCache getCache() { diff --git a/src/share/classes/sun/java2d/pisces/Stroker.java b/src/share/classes/sun/java2d/pisces/Stroker.java index b898febc4c2662d0f95c0c5eb272644f968ebb33..f7323f95adb579341e00cd102c77c849b05b193e 100644 --- a/src/share/classes/sun/java2d/pisces/Stroker.java +++ b/src/share/classes/sun/java2d/pisces/Stroker.java @@ -764,6 +764,11 @@ final class Stroker implements PathConsumer2D { private static final int MAX_N_CURVES = 11; private float[] subdivTs = new float[MAX_N_CURVES - 1]; + // If this class is compiled with ecj, then Hotspot crashes when OSR + // compiling this function. See bugs 7004570 and 6675699 + // TODO: until those are fixed, we should work around that by + // manually inlining this into curveTo and quadTo. +/******************************* WORKAROUND ********************************** private void somethingTo(final int type) { // need these so we can update the state at the end of this method final float xf = middle[type-2], yf = middle[type-1]; @@ -866,6 +871,7 @@ final class Stroker implements PathConsumer2D { this.cy0 = yf; this.prev = DRAWING_OP_TO; } +****************************** END WORKAROUND *******************************/ // finds values of t where the curve in pts should be subdivided in order // to get good offset curves a distance of w away from the middle curve. @@ -932,18 +938,168 @@ final class Stroker implements PathConsumer2D { middle[2] = x1; middle[3] = y1; middle[4] = x2; middle[5] = y2; middle[6] = x3; middle[7] = y3; - somethingTo(8); - } - @Override public long getNativeConsumer() { - throw new InternalError("Stroker doesn't use a native consumer"); + // inlined version of somethingTo(8); + // See the TODO on somethingTo + + // need these so we can update the state at the end of this method + final float xf = middle[6], yf = middle[7]; + float dxs = middle[2] - middle[0]; + float dys = middle[3] - middle[1]; + float dxf = middle[6] - middle[4]; + float dyf = middle[7] - middle[5]; + + boolean p1eqp2 = (dxs == 0f && dys == 0f); + boolean p3eqp4 = (dxf == 0f && dyf == 0f); + if (p1eqp2) { + dxs = middle[4] - middle[0]; + dys = middle[5] - middle[1]; + if (dxs == 0f && dys == 0f) { + dxs = middle[6] - middle[0]; + dys = middle[7] - middle[1]; + } + } + if (p3eqp4) { + dxf = middle[6] - middle[2]; + dyf = middle[7] - middle[3]; + if (dxf == 0f && dyf == 0f) { + dxf = middle[6] - middle[0]; + dyf = middle[7] - middle[1]; + } + } + if (dxs == 0f && dys == 0f) { + // this happens iff the "curve" is just a point + lineTo(middle[0], middle[1]); + return; + } + + // if these vectors are too small, normalize them, to avoid future + // precision problems. + if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) { + float len = (float)Math.sqrt(dxs*dxs + dys*dys); + dxs /= len; + dys /= len; + } + if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) { + float len = (float)Math.sqrt(dxf*dxf + dyf*dyf); + dxf /= len; + dyf /= len; + } + + computeOffset(dxs, dys, lineWidth2, offset[0]); + final float mx = offset[0][0]; + final float my = offset[0][1]; + drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, mx, my); + + int nSplits = findSubdivPoints(middle, subdivTs, 8, lineWidth2); + + int kind = 0; + Iterator it = Curve.breakPtsAtTs(middle, 8, subdivTs, nSplits); + while(it.hasNext()) { + int curCurveOff = it.next(); + + kind = computeOffsetCubic(middle, curCurveOff, lp, rp); + if (kind != 0) { + emitLineTo(lp[0], lp[1]); + switch(kind) { + case 8: + emitCurveTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], lp[6], lp[7], false); + emitCurveTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7], true); + break; + case 4: + emitLineTo(lp[2], lp[3]); + emitLineTo(rp[0], rp[1], true); + break; + } + emitLineTo(rp[kind - 2], rp[kind - 1], true); + } + } + + this.cmx = (lp[kind - 2] - rp[kind - 2]) / 2; + this.cmy = (lp[kind - 1] - rp[kind - 1]) / 2; + this.cdx = dxf; + this.cdy = dyf; + this.cx0 = xf; + this.cy0 = yf; + this.prev = DRAWING_OP_TO; } @Override public void quadTo(float x1, float y1, float x2, float y2) { middle[0] = cx0; middle[1] = cy0; middle[2] = x1; middle[3] = y1; middle[4] = x2; middle[5] = y2; - somethingTo(6); + + // inlined version of somethingTo(8); + // See the TODO on somethingTo + + // need these so we can update the state at the end of this method + final float xf = middle[4], yf = middle[5]; + float dxs = middle[2] - middle[0]; + float dys = middle[3] - middle[1]; + float dxf = middle[4] - middle[2]; + float dyf = middle[5] - middle[3]; + if ((dxs == 0f && dys == 0f) || (dxf == 0f && dyf == 0f)) { + dxs = dxf = middle[4] - middle[0]; + dys = dyf = middle[5] - middle[1]; + } + if (dxs == 0f && dys == 0f) { + // this happens iff the "curve" is just a point + lineTo(middle[0], middle[1]); + return; + } + // if these vectors are too small, normalize them, to avoid future + // precision problems. + if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) { + float len = (float)Math.sqrt(dxs*dxs + dys*dys); + dxs /= len; + dys /= len; + } + if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) { + float len = (float)Math.sqrt(dxf*dxf + dyf*dyf); + dxf /= len; + dyf /= len; + } + + computeOffset(dxs, dys, lineWidth2, offset[0]); + final float mx = offset[0][0]; + final float my = offset[0][1]; + drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, mx, my); + + int nSplits = findSubdivPoints(middle, subdivTs, 6, lineWidth2); + + int kind = 0; + Iterator it = Curve.breakPtsAtTs(middle, 6, subdivTs, nSplits); + while(it.hasNext()) { + int curCurveOff = it.next(); + + kind = computeOffsetQuad(middle, curCurveOff, lp, rp); + if (kind != 0) { + emitLineTo(lp[0], lp[1]); + switch(kind) { + case 6: + emitQuadTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], false); + emitQuadTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], true); + break; + case 4: + emitLineTo(lp[2], lp[3]); + emitLineTo(rp[0], rp[1], true); + break; + } + emitLineTo(rp[kind - 2], rp[kind - 1], true); + } + } + + this.cmx = (lp[kind - 2] - rp[kind - 2]) / 2; + this.cmy = (lp[kind - 1] - rp[kind - 1]) / 2; + this.cdx = dxf; + this.cdy = dyf; + this.cx0 = xf; + this.cy0 = yf; + this.prev = DRAWING_OP_TO; + } + + @Override public long getNativeConsumer() { + throw new InternalError("Stroker doesn't use a native consumer"); } // a stack of polynomial curves where each curve shares endpoints with diff --git a/src/share/classes/java/dyn/MethodTypeForm.java b/src/share/classes/sun/misc/JavaSecurityAccess.java similarity index 68% rename from src/share/classes/java/dyn/MethodTypeForm.java rename to src/share/classes/sun/misc/JavaSecurityAccess.java index 35c59a45c0c994ec8d7a2caeff1eae9510eb025b..5a3aa513fb80521b0bba11aed6a2841da82615e9 100644 --- a/src/share/classes/java/dyn/MethodTypeForm.java +++ b/src/share/classes/sun/misc/JavaSecurityAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,17 +23,18 @@ * questions. */ -package java.dyn; +package sun.misc; -/** - * TO DO: Temporary shim; remove after refactoring effects are complete in JVM. - * @author John Rose - */ -import sun.dyn.MethodTypeImpl; +import java.security.AccessControlContext; +import java.security.PrivilegedAction; + +public interface JavaSecurityAccess { + + T doIntersectionPrivilege(PrivilegedAction action, + AccessControlContext stack, + AccessControlContext context); -class MethodTypeForm extends MethodTypeImpl { + T doIntersectionPrivilege(PrivilegedAction action, + AccessControlContext context); - MethodTypeForm(MethodType erasedType) { - super(erasedType); - } } diff --git a/src/share/classes/sun/misc/SharedSecrets.java b/src/share/classes/sun/misc/SharedSecrets.java index 2335b2d68b58b97e12734d4971e4b07f6d9055c3..0bd39b4a5d42f0b12478143bad17dce21db3ba11 100644 --- a/src/share/classes/sun/misc/SharedSecrets.java +++ b/src/share/classes/sun/misc/SharedSecrets.java @@ -30,6 +30,8 @@ import java.io.Console; import java.io.FileDescriptor; import java.security.ProtectionDomain; +import java.security.AccessController; + /** A repository of "shared secrets", which are a mechanism for calling implementation-private methods in another package without using reflection. A package-private class implements a public @@ -48,6 +50,7 @@ public class SharedSecrets { private static JavaNioAccess javaNioAccess; private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess; private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess; + private static JavaSecurityAccess javaSecurityAccess; public static JavaUtilJarAccess javaUtilJarAccess() { if (javaUtilJarAccess == null) { @@ -125,4 +128,15 @@ public class SharedSecrets { unsafe.ensureClassInitialized(ProtectionDomain.class); return javaSecurityProtectionDomainAccess; } + + public static void setJavaSecurityAccess(JavaSecurityAccess jsa) { + javaSecurityAccess = jsa; + } + + public static JavaSecurityAccess getJavaSecurityAccess() { + if (javaSecurityAccess == null) { + unsafe.ensureClassInitialized(AccessController.class); + } + return javaSecurityAccess; + } } diff --git a/src/share/classes/sun/net/ResourceManager.java b/src/share/classes/sun/net/ResourceManager.java new file mode 100644 index 0000000000000000000000000000000000000000..11bfc46481950da1521c239327084208e424a5aa --- /dev/null +++ b/src/share/classes/sun/net/ResourceManager.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.net; + +import java.net.SocketException; +import java.util.concurrent.atomic.AtomicInteger; +import sun.security.action.GetPropertyAction; + +/** + * Manages count of total number of UDP sockets and ensures + * that exception is thrown if we try to create more than the + * configured limit. + * + * This functionality could be put in NetHooks some time in future. + */ + +public class ResourceManager { + + /* default maximum number of udp sockets per VM + * when a security manager is enabled. + * The default is 1024 which is high enough to be useful + * but low enough to be well below the maximum number + * of port numbers actually available on all OSes for + * such sockets (5000 on some versions of windows) + */ + + private static final int DEFAULT_MAX_SOCKETS = 1024; + private static final int maxSockets; + private static final AtomicInteger numSockets; + + static { + String prop = java.security.AccessController.doPrivileged( + new GetPropertyAction("sun.net.maxDatagramSockets") + ); + int defmax = DEFAULT_MAX_SOCKETS; + try { + if (prop != null) { + defmax = Integer.parseInt(prop); + } + } catch (NumberFormatException e) {} + maxSockets = defmax; + numSockets = new AtomicInteger(0); + } + + public static void beforeUdpCreate() throws SocketException { + if (System.getSecurityManager() != null) { + if (numSockets.incrementAndGet() > maxSockets) { + numSockets.decrementAndGet(); + throw new SocketException("maximum number of DatagramSockets reached"); + } + } + } + + public static void afterUdpClose() { + if (System.getSecurityManager() != null) { + numSockets.decrementAndGet(); + } + } +} diff --git a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 69f12a5c601117c4931afd8a82da3bcabbc47aab..afc8cea03082acd542de21e81c31430c5492ce62 100644 --- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -2173,6 +2173,13 @@ public class HttpURLConnection extends java.net.HttpURLConnection { if (tryTransparentNTLMServer) { tryTransparentNTLMServer = NTLMAuthenticationProxy.proxy.supportsTransparentAuth; + /* If the platform supports transparent authentication + * then check if we are in a secure environment + * whether, or not, we should try transparent authentication.*/ + if (tryTransparentNTLMServer) { + tryTransparentNTLMServer = + NTLMAuthenticationProxy.proxy.isTrustedSite(url); + } } a = null; if (tryTransparentNTLMServer) { diff --git a/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java b/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java index a998d2b1226e726c4c739d1a8d05779982f1815f..b235a0bed175f71e5b77a367b1ccabd3ddf5cc9a 100644 --- a/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java +++ b/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java @@ -36,12 +36,14 @@ import sun.util.logging.PlatformLogger; */ class NTLMAuthenticationProxy { private static Method supportsTA; + private static Method isTrustedSite; private static final String clazzStr = "sun.net.www.protocol.http.ntlm.NTLMAuthentication"; private static final String supportsTAStr = "supportsTransparentAuth"; + private static final String isTrustedSiteStr = "isTrustedSite"; static final NTLMAuthenticationProxy proxy = tryLoadNTLMAuthentication(); static final boolean supported = proxy != null ? true : false; - static final boolean supportsTransparentAuth = supported ? supportsTransparentAuth(supportsTA) : false; + static final boolean supportsTransparentAuth = supported ? supportsTransparentAuth() : false; private final Constructor threeArgCtr; private final Constructor fiveArgCtr; @@ -82,9 +84,22 @@ class NTLMAuthenticationProxy { * authentication (try with the current users credentials before * prompting for username and password, etc). */ - private static boolean supportsTransparentAuth(Method method) { + private static boolean supportsTransparentAuth() { try { - return (Boolean)method.invoke(null); + return (Boolean)supportsTA.invoke(null); + } catch (ReflectiveOperationException roe) { + finest(roe); + } + + return false; + } + + /* Transparent authentication should only be tried with a trusted + * site ( when running in a secure environment ). + */ + public static boolean isTrustedSite(URL url) { + try { + return (Boolean)isTrustedSite.invoke(null, url); } catch (ReflectiveOperationException roe) { finest(roe); } @@ -112,6 +127,7 @@ class NTLMAuthenticationProxy { int.class, PasswordAuthentication.class); supportsTA = cl.getDeclaredMethod(supportsTAStr); + isTrustedSite = cl.getDeclaredMethod(isTrustedSiteStr, java.net.URL.class); return new NTLMAuthenticationProxy(threeArg, fiveArg); } diff --git a/src/share/classes/sun/net/www/protocol/http/ntlm/NTLMAuthenticationCallback.java b/src/share/classes/sun/net/www/protocol/http/ntlm/NTLMAuthenticationCallback.java new file mode 100644 index 0000000000000000000000000000000000000000..92886311e0973b9cf7b277c27f13f2dc6a1752d2 --- /dev/null +++ b/src/share/classes/sun/net/www/protocol/http/ntlm/NTLMAuthenticationCallback.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.net.www.protocol.http.ntlm; + +import java.net.URL; + +/** + * This class is used to call back to deployment to determine if a given + * URL is trusted. Transparent authentication (try with logged in users + * credentials without prompting) should only be tried with trusted sites. + */ +public abstract class NTLMAuthenticationCallback { + private static volatile NTLMAuthenticationCallback callback = + new DefaultNTLMAuthenticationCallback(); + + public static void setNTLMAuthenticationCallback( + NTLMAuthenticationCallback callback) { + NTLMAuthenticationCallback.callback = callback; + } + + public static NTLMAuthenticationCallback getNTLMAuthenticationCallback() { + return callback; + } + + /** + * Returns true if the given site is trusted, i.e. we can try + * transparent Authentication. + */ + public abstract boolean isTrustedSite(URL url); + + static class DefaultNTLMAuthenticationCallback extends NTLMAuthenticationCallback { + @Override + public boolean isTrustedSite(URL url) { return true; } + } +} + diff --git a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java index e63e473ef86d03c2c596d06f47f7160a77f4efbe..de712d6b64f96f4810b77a7428e7c6d22a4b3bc0 100644 --- a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java +++ b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java @@ -32,6 +32,7 @@ import java.nio.ByteBuffer; import java.nio.channels.*; import java.nio.channels.spi.*; import java.util.*; +import sun.net.ResourceManager; /** @@ -101,14 +102,22 @@ class DatagramChannelImpl throws IOException { super(sp); - this.family = Net.isIPv6Available() ? - StandardProtocolFamily.INET6 : StandardProtocolFamily.INET; - this.fd = Net.socket(family, false); - this.fdVal = IOUtil.fdVal(fd); - this.state = ST_UNCONNECTED; + ResourceManager.beforeUdpCreate(); + try { + this.family = Net.isIPv6Available() ? + StandardProtocolFamily.INET6 : StandardProtocolFamily.INET; + this.fd = Net.socket(family, false); + this.fdVal = IOUtil.fdVal(fd); + this.state = ST_UNCONNECTED; + } catch (IOException ioe) { + ResourceManager.afterUdpClose(); + throw ioe; + } } - public DatagramChannelImpl(SelectorProvider sp, ProtocolFamily family) { + public DatagramChannelImpl(SelectorProvider sp, ProtocolFamily family) + throws IOException + { super(sp); if ((family != StandardProtocolFamily.INET) && (family != StandardProtocolFamily.INET6)) @@ -957,6 +966,7 @@ class DatagramChannelImpl protected void implCloseSelectableChannel() throws IOException { synchronized (stateLock) { nd.preClose(fd); + ResourceManager.afterUdpClose(); // if member of mulitcast group then invalidate all keys if (registry != null) diff --git a/src/share/classes/sun/nio/ch/Net.java b/src/share/classes/sun/nio/ch/Net.java index 4324350e6393f3eca9fe4ae2158f9a1fe3d3e407..58cfe3b1a5b0adcdef7d3949dd126adb7f21f6fb 100644 --- a/src/share/classes/sun/nio/ch/Net.java +++ b/src/share/classes/sun/nio/ch/Net.java @@ -312,11 +312,12 @@ class Net { // package-private private static native boolean canJoin6WithIPv4Group0(); - static FileDescriptor socket(boolean stream) { + static FileDescriptor socket(boolean stream) throws IOException { return socket(UNSPEC, stream); } - static FileDescriptor socket(ProtocolFamily family, boolean stream) { + static FileDescriptor socket(ProtocolFamily family, boolean stream) + throws IOException { boolean preferIPv6 = isIPv6Available() && (family != StandardProtocolFamily.INET); return IOUtil.newFD(socket0(preferIPv6, stream, false)); diff --git a/src/share/classes/sun/text/resources/CollationData_sr_Latn.java b/src/share/classes/sun/text/resources/CollationData_sr_Latn.java new file mode 100644 index 0000000000000000000000000000000000000000..1c7c5e1e9491520801482763125592caafaa3f2f --- /dev/null +++ b/src/share/classes/sun/text/resources/CollationData_sr_Latn.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2005, 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. + */ + +/* + */ + +/* + * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved + * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved + * + * The original version of this source code and documentation + * is copyrighted and owned by Taligent, Inc., a wholly-owned + * subsidiary of IBM. These materials are provided under terms + * of a License Agreement between Taligent and Sun. This technology + * is protected by multiple US and International patents. + * + * This notice and attribution to Taligent may not be removed. + * Taligent is a registered trademark of Taligent, Inc. + * + */ + +package sun.text.resources; + +import java.util.ListResourceBundle; + +public class CollationData_sr_Latn extends ListResourceBundle { + + protected final Object[][] getContents() { + return new Object[][] { + { "Rule", + /* for sr-Latin, default sorting except for the following: */ + + /* add dz "ligature" between d and d. */ + /* add d between d and e. */ + /* add lj "ligature" between l and l. */ + /* add l between l and m. */ + /* add nj "ligature" between n and o. */ + /* add z after z. */ + "& \u200f = \u030c " + + "& \u0306 = \u030d " + + "& C < c\u030c , C\u030c " // C < c-caron + + "< c\u0301 , C\u0301 " // c-acute + + "& D < \u01f3 , \u01f2 , \u01f1 " // dz + + "< dz , dZ , Dz , DZ " // dz ligature + + "< \u01c6 , \u01c5 , \u01c4 " // dz-caron + + "< \u0111 , \u0110 " // d-stroke + + "& L < lj , lJ , Lj , LJ " // l < lj ligature + + "& N < nj , nJ , Nj , NJ " // n < nj ligature + + "& S < s\u030c , S\u030c " // s < s-caron + + "& Z < z\u030c , Z\u030c " // z < z-caron + } + }; + } +} diff --git a/src/share/classes/sun/text/resources/FormatData_sr_Latn.java b/src/share/classes/sun/text/resources/FormatData_sr_Latn.java new file mode 100644 index 0000000000000000000000000000000000000000..aa9bca860b692503e562d84926df9840880b4cb9 --- /dev/null +++ b/src/share/classes/sun/text/resources/FormatData_sr_Latn.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. + * Distributed under the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of the Unicode data files and any associated documentation (the + * "Data Files") or Unicode software and any associated documentation + * (the "Software") to deal in the Data Files or Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, and/or sell copies of the Data + * Files or Software, and to permit persons to whom the Data Files or + * Software are furnished to do so, provided that (a) the above copyright + * notice(s) and this permission notice appear with all copies of the + * Data Files or Software, (b) both the above copyright notice(s) and + * this permission notice appear in associated documentation, and (c) + * there is clear notice in each modified Data File or in the Software as + * well as in the documentation associated with the Data File(s) or + * Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF + * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR + * ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR + * SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in these Data Files or Software without prior + * written authorization of the copyright holder. + */ + +// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +package sun.text.resources; + +import java.util.ListResourceBundle; + +public class FormatData_sr_Latn extends ListResourceBundle { + protected final Object[][] getContents() { + return new Object[][] { + { "MonthNames", + new String[] { + "januar", + "februar", + "mart", + "april", + "maj", + "jun", + "jul", + "avgust", + "septembar", + "oktobar", + "novembar", + "decembar", + "", + } + }, + { "MonthAbbreviations", + new String[] { + "jan", + "feb", + "mar", + "apr", + "maj", + "jun", + "jul", + "avg", + "sep", + "okt", + "nov", + "dec", + "", + } + }, + { "DayNames", + new String[] { + "nedelja", + "ponedeljak", + "utorak", + "sreda", + "\u010detvrtak", + "petak", + "subota", + } + }, + { "DayAbbreviations", + new String[] { + "ned", + "pon", + "uto", + "sre", + "\u010det", + "pet", + "sub", + } + }, + { "Eras", + new String[] { + "p. n. e.", + "n. e", + } + }, + { "NumberPatterns", + new String[] { + "#,##0.###", + "\u00a4\u00a0#,##0.00", + "#,##0%", + } + }, + { "NumberElements", + new String[] { + ".", + ",", + ";", + "%", + "0", + "#", + "-", + "E", + "\u2030", + "\u221e", + "NaN", + } + }, + { "DateTimePatterns", + new String[] { + "HH.mm.ss zzzz", + "HH.mm.ss z", + "HH.mm.ss", + "HH.mm", + "EEEE, dd. MMMM y.", + "dd. MMMM y.", + "dd.MM.y.", + "d.M.yy.", + "{1} {0}", + } + }, + }; + } +} diff --git a/src/share/classes/sun/text/resources/FormatData_sr_Latn_BA.java b/src/share/classes/sun/text/resources/FormatData_sr_Latn_BA.java new file mode 100644 index 0000000000000000000000000000000000000000..0bdc0061cf98193907cc28c4fab6ffdee819d4bc --- /dev/null +++ b/src/share/classes/sun/text/resources/FormatData_sr_Latn_BA.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. + * Distributed under the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of the Unicode data files and any associated documentation (the + * "Data Files") or Unicode software and any associated documentation + * (the "Software") to deal in the Data Files or Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, and/or sell copies of the Data + * Files or Software, and to permit persons to whom the Data Files or + * Software are furnished to do so, provided that (a) the above copyright + * notice(s) and this permission notice appear with all copies of the + * Data Files or Software, (b) both the above copyright notice(s) and + * this permission notice appear in associated documentation, and (c) + * there is clear notice in each modified Data File or in the Software as + * well as in the documentation associated with the Data File(s) or + * Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF + * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR + * ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR + * SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in these Data Files or Software without prior + * written authorization of the copyright holder. + */ + +// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +package sun.text.resources; + +import sun.util.EmptyListResourceBundle; + +public class FormatData_sr_Latn_BA extends EmptyListResourceBundle { +} diff --git a/src/share/classes/sun/text/resources/FormatData_sr_Latn_ME.java b/src/share/classes/sun/text/resources/FormatData_sr_Latn_ME.java new file mode 100644 index 0000000000000000000000000000000000000000..dcd50585f0a637fe89484631a9fff7fd4f9d5605 --- /dev/null +++ b/src/share/classes/sun/text/resources/FormatData_sr_Latn_ME.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. + * Distributed under the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of the Unicode data files and any associated documentation (the + * "Data Files") or Unicode software and any associated documentation + * (the "Software") to deal in the Data Files or Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, and/or sell copies of the Data + * Files or Software, and to permit persons to whom the Data Files or + * Software are furnished to do so, provided that (a) the above copyright + * notice(s) and this permission notice appear with all copies of the + * Data Files or Software, (b) both the above copyright notice(s) and + * this permission notice appear in associated documentation, and (c) + * there is clear notice in each modified Data File or in the Software as + * well as in the documentation associated with the Data File(s) or + * Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF + * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR + * ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR + * SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in these Data Files or Software without prior + * written authorization of the copyright holder. + */ + +// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +package sun.text.resources; + +import java.util.ListResourceBundle; + +public class FormatData_sr_Latn_ME extends ListResourceBundle { + protected final Object[][] getContents() { + return new Object[][] { + { "DateTimePatterns", + new String[] { + "HH.mm.ss zzzz", + "HH.mm.ss z", + "HH.mm.ss", + "HH.mm", + "EEEE, dd. MMMM y.", + "d.MM.yyyy.", + "dd.MM.y.", + "d.M.yy.", + "{1} {0}", + } + } + }; + } +} diff --git a/src/share/classes/sun/text/resources/FormatData_sr_Latn_RS.java b/src/share/classes/sun/text/resources/FormatData_sr_Latn_RS.java new file mode 100644 index 0000000000000000000000000000000000000000..80fba9f0960cf885e11c73c093a7d9be040e6542 --- /dev/null +++ b/src/share/classes/sun/text/resources/FormatData_sr_Latn_RS.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. + * Distributed under the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of the Unicode data files and any associated documentation (the + * "Data Files") or Unicode software and any associated documentation + * (the "Software") to deal in the Data Files or Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, and/or sell copies of the Data + * Files or Software, and to permit persons to whom the Data Files or + * Software are furnished to do so, provided that (a) the above copyright + * notice(s) and this permission notice appear with all copies of the + * Data Files or Software, (b) both the above copyright notice(s) and + * this permission notice appear in associated documentation, and (c) + * there is clear notice in each modified Data File or in the Software as + * well as in the documentation associated with the Data File(s) or + * Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF + * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR + * ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR + * SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in these Data Files or Software without prior + * written authorization of the copyright holder. + */ + +// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +package sun.text.resources; + +import sun.util.EmptyListResourceBundle; + +public class FormatData_sr_Latn_RS extends EmptyListResourceBundle { +} diff --git a/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_ja.java b/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_ja.java index 35e7286db224cb1afbda8921cfd322d74101c62a..452e620d7f3958f4659ecf5c1af8910dca77ce9c 100644 --- a/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_ja.java +++ b/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_ja.java @@ -44,7 +44,7 @@ import static java.awt.event.KeyEvent.*; * or if the keys ends with ".mnemonic", an element * representing a mnemomic keycode int or char. */ -public class JConsoleResources_ja extends ListResourceBundle { +public class JConsoleResources_ja extends JConsoleResources { /** * Returns the contents of this ResourceBundle. diff --git a/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_zh_CN.java b/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_zh_CN.java index a29aaaf4032279368069c83ba6b754ef51064156..b101429d83c8eaf887010259a2577e5a2fc2a2f9 100644 --- a/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_zh_CN.java +++ b/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_zh_CN.java @@ -44,7 +44,7 @@ import static java.awt.event.KeyEvent.*; * or if the keys ends with ".mnemonic", an element * representing a mnemomic keycode int or char. */ -public class JConsoleResources_zh_CN extends ListResourceBundle { +public class JConsoleResources_zh_CN extends JConsoleResources { /** * Returns the contents of this ResourceBundle. diff --git a/src/share/classes/sun/util/logging/resources/logging.properties b/src/share/classes/sun/util/logging/resources/logging.properties index 2cd2bf53ae768ecd4839005333a4e54f27d8bd44..2595b5e1b03f67f673c1e03931fd3e7fa8b14e1e 100644 --- a/src/share/classes/sun/util/logging/resources/logging.properties +++ b/src/share/classes/sun/util/logging/resources/logging.properties @@ -25,13 +25,22 @@ # Localizations for Level names. For the US locale # these are the same as the non-localized level name. + +# The following ALL CAPS words should be translated. ALL=ALL +# The following ALL CAPS words should be translated. SEVERE=SEVERE +# The following ALL CAPS words should be translated. WARNING=WARNING +# The following ALL CAPS words should be translated. INFO=INFO +# The following ALL CAPS words should be translated. CONFIG= CONFIG +# The following ALL CAPS words should be translated. FINE=FINE +# The following ALL CAPS words should be translated. FINER=FINER +# The following ALL CAPS words should be translated. FINEST=FINEST +# The following ALL CAPS words should be translated. OFF=OFF - diff --git a/src/share/classes/sun/util/resources/CalendarData_sr_Latn_BA.properties b/src/share/classes/sun/util/resources/CalendarData_sr_Latn_BA.properties new file mode 100644 index 0000000000000000000000000000000000000000..7d29a94e698efaa3420f146b8cb79f9977e37c59 --- /dev/null +++ b/src/share/classes/sun/util/resources/CalendarData_sr_Latn_BA.properties @@ -0,0 +1,66 @@ +# +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# COPYRIGHT AND PERMISSION NOTICE +# +# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. +# Distributed under the Terms of Use in http://www.unicode.org/copyright.html. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of the Unicode data files and any associated documentation (the +# "Data Files") or Unicode software and any associated documentation +# (the "Software") to deal in the Data Files or Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, and/or sell copies of the Data +# Files or Software, and to permit persons to whom the Data Files or +# Software are furnished to do so, provided that (a) the above copyright +# notice(s) and this permission notice appear with all copies of the +# Data Files or Software, (b) both the above copyright notice(s) and +# this permission notice appear in associated documentation, and (c) +# there is clear notice in each modified Data File or in the Software as +# well as in the documentation associated with the Data File(s) or +# Software that the data or software has been modified. +# +# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR +# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR +# SOFTWARE. +# +# Except as contained in this notice, the name of a copyright holder +# shall not be used in advertising or otherwise to promote the sale, use +# or other dealings in these Data Files or Software without prior +# written authorization of the copyright holder. + +# +# Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +# +minimalDaysInFirstWeek=4 diff --git a/src/share/classes/sun/util/resources/CalendarData_sr_Latn_ME.properties b/src/share/classes/sun/util/resources/CalendarData_sr_Latn_ME.properties new file mode 100644 index 0000000000000000000000000000000000000000..7d29a94e698efaa3420f146b8cb79f9977e37c59 --- /dev/null +++ b/src/share/classes/sun/util/resources/CalendarData_sr_Latn_ME.properties @@ -0,0 +1,66 @@ +# +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# COPYRIGHT AND PERMISSION NOTICE +# +# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. +# Distributed under the Terms of Use in http://www.unicode.org/copyright.html. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of the Unicode data files and any associated documentation (the +# "Data Files") or Unicode software and any associated documentation +# (the "Software") to deal in the Data Files or Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, and/or sell copies of the Data +# Files or Software, and to permit persons to whom the Data Files or +# Software are furnished to do so, provided that (a) the above copyright +# notice(s) and this permission notice appear with all copies of the +# Data Files or Software, (b) both the above copyright notice(s) and +# this permission notice appear in associated documentation, and (c) +# there is clear notice in each modified Data File or in the Software as +# well as in the documentation associated with the Data File(s) or +# Software that the data or software has been modified. +# +# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR +# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR +# SOFTWARE. +# +# Except as contained in this notice, the name of a copyright holder +# shall not be used in advertising or otherwise to promote the sale, use +# or other dealings in these Data Files or Software without prior +# written authorization of the copyright holder. + +# +# Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +# +minimalDaysInFirstWeek=4 diff --git a/src/share/classes/sun/util/resources/CalendarData_sr_Latn_RS.properties b/src/share/classes/sun/util/resources/CalendarData_sr_Latn_RS.properties new file mode 100644 index 0000000000000000000000000000000000000000..7d29a94e698efaa3420f146b8cb79f9977e37c59 --- /dev/null +++ b/src/share/classes/sun/util/resources/CalendarData_sr_Latn_RS.properties @@ -0,0 +1,66 @@ +# +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# COPYRIGHT AND PERMISSION NOTICE +# +# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. +# Distributed under the Terms of Use in http://www.unicode.org/copyright.html. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of the Unicode data files and any associated documentation (the +# "Data Files") or Unicode software and any associated documentation +# (the "Software") to deal in the Data Files or Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, and/or sell copies of the Data +# Files or Software, and to permit persons to whom the Data Files or +# Software are furnished to do so, provided that (a) the above copyright +# notice(s) and this permission notice appear with all copies of the +# Data Files or Software, (b) both the above copyright notice(s) and +# this permission notice appear in associated documentation, and (c) +# there is clear notice in each modified Data File or in the Software as +# well as in the documentation associated with the Data File(s) or +# Software that the data or software has been modified. +# +# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR +# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR +# SOFTWARE. +# +# Except as contained in this notice, the name of a copyright holder +# shall not be used in advertising or otherwise to promote the sale, use +# or other dealings in these Data Files or Software without prior +# written authorization of the copyright holder. + +# +# Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +# +minimalDaysInFirstWeek=4 diff --git a/src/share/classes/sun/util/resources/CurrencyNames_pt.properties b/src/share/classes/sun/util/resources/CurrencyNames_pt.properties new file mode 100644 index 0000000000000000000000000000000000000000..5adb677a5dd84c031e5862a135f1d28815577449 --- /dev/null +++ b/src/share/classes/sun/util/resources/CurrencyNames_pt.properties @@ -0,0 +1,250 @@ +# +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# + +# +# COPYRIGHT AND PERMISSION NOTICE +# +# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. +# Distributed under the Terms of Use in http://www.unicode.org/copyright.html. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of the Unicode data files and any associated documentation (the "Data +# Files") or Unicode software and any associated documentation (the +# "Software") to deal in the Data Files or Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, and/or sell copies of the Data Files or Software, and +# to permit persons to whom the Data Files or Software are furnished to do +# so, provided that (a) the above copyright notice(s) and this permission +# notice appear with all copies of the Data Files or Software, (b) both the +# above copyright notice(s) and this permission notice appear in associated +# documentation, and (c) there is clear notice in each modified Data File or +# in the Software as well as in the documentation associated with the Data +# File(s) or Software that the data or software has been modified. +# +# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF +# THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS +# INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR +# CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THE DATA FILES OR SOFTWARE. +# +# Except as contained in this notice, the name of a copyright holder shall not +# be used in advertising or otherwise to promote the sale, use or other +# dealings in these Data Files or Software without prior written +# authorization of the copyright holder. +# + +# Generated automatically from the Common Locale Data Repository. DO NOT EDIT! + +adp=Peseta de Andorra +aed=Dir\u00e9m dos Emirados \u00c1rabes Unidos +afa=Afegane (1927-2002) +afn=Afegane +all=Lek Alban\u00eas +amd=Dram arm\u00eanio +ang=Guilder das Antilhas Holandesas +aoa=Cuanza angolano +ars=Peso argentino +ats=Xelim austr\u00edaco +aud=D\u00f3lar australiano +awg=Guilder de Aruba +azm=Manat azerbaijano +azn=Manat do Azerbaij\u00e3o +bam=Marco b\u00f3snio-herzegovino convers\u00edvel +bbd=D\u00f3lar de Barbados +bdt=Taka de Bangladesh +bef=Franco belga +bgl=Lev forte b\u00falgaro +bgn=Lev novo b\u00falgaro +bhd=Dinar bareinita +bif=Franco do Burundi +bmd=D\u00f3lar das Bermudas +bnd=D\u00f3lar do Brunei +bov=Mvdol boliviano +brl=Real brasileiro +bsd=D\u00f3lar das Bahamas +btn=Ngultrum do But\u00e3o +bwp=Pula botsuanesa +byb=Rublo novo bielo-russo (1994-1999) +byr=Rublo bielo-russo +bzd=D\u00f3lar do Belize +cad=D\u00f3lar canadense +cdf=Franco congol\u00eas +chf=Franco su\u00ed\u00e7o +clf=Unidades de Fomento chilenas +clp=Peso chileno +cny=Yuan Renminbi chin\u00eas +cop=Peso colombiano +crc=Colon da Costa Rica +csd=Dinar s\u00e9rvio antigo +cup=Peso cubano +cve=Escudo cabo-verdiano +cyp=Libra cipriota +czk=Coroa checa +dem=Marco alem\u00e3o +djf=Franco do Djibuti +dkk=Coroa dinamarquesa +dop=Peso dominicano +dzd=Dinar argelino +eek=Coroa estoniana +egp=Libra eg\u00edpcia +ern=Nakfa da Eritreia +esp=Peseta espanhola +etb=Birr et\u00edope +fim=Marca finlandesa +fjd=D\u00f3lar de Fiji +fkp=Libra das Malvinas +frf=Franco franc\u00eas +gbp=Libra esterlina brit\u00e2nica +gel=Lari georgiano +ghc=Cedi de Gana (1979-2007) +ghs=Cedi gan\u00eas +gip=Libra de Gibraltar +gmd=Dalasi de G\u00e2mbia +gnf=Franco de Guin\u00e9 +grd=Dracma grego +gtq=Quet\u00e7al da Guatemala +gwp=Peso da Guin\u00e9-Bissau +gyd=D\u00f3lar da Guiana +hkd=D\u00f3lar de Hong Kong +hnl=Lempira de Honduras +hrk=Kuna croata +htg=Gurde do Haiti +huf=Forinte h\u00fangaro +idr=Rupia indon\u00e9sia +iep=Libra irlandesa +ils=Sheqel Novo israelita +inr=R\u00fapia indiana +iqd=Dinar iraquiano +irr=Rial iraniano +isk=Coroa islandesa +itl=Lira italiana +jmd=D\u00f3lar jamaicano +jod=Dinar jordaniano +jpy=Iene japon\u00eas +kes=Xelim queniano +kgs=Som quirguiz +khr=Riel cambojano +kmf=Franco de Comores +kpw=Won norte-coreano +krw=Won sul-coreano +kwd=Dinar coveitiano +kyd=D\u00f3lar das Ilhas Caiman +kzt=Tenge do Cazaquist\u00e3o +lak=Kip de Laos +lbp=Libra libanesa +lkr=Rupia do Sri Lanka +lrd=D\u00f3lar liberiano +lsl=Loti do Lesoto +ltl=Lita lituano +luf=Franco luxemburgu\u00eas +lvl=Lats let\u00e3o +lyd=Dinar l\u00edbio +mad=Dir\u00e9m marroquino +mdl=Leu mold\u00e1vio +mga=Ariary de Madagascar +mgf=Franco de Madagascar +mkd=Dinar maced\u00f4nio +mmk=Kyat de Mianmar +mnt=Tugrik mongol +mop=Pataca macaense +mro=Ouguiya da Maurit\u00e2nia +mtl=Lira maltesa +mur=Rupia de Maur\u00edcio +mvr=Rupias das Ilhas Maldivas +mwk=Cuacha do Mal\u00e1ui +mxn=Peso mexicano +mxv=Unidade Mexicana de Investimento (UDI) +myr=Ringgit malaio +mzm=Metical antigo de Mo\u00e7ambique +mzn=Metical do Mo\u00e7ambique +nad=D\u00f3lar da Nam\u00edbia +ngn=Naira nigeriana +nio=C\u00f3rdoba Ouro nicaraguense +nlg=Florim holand\u00eas +nok=Coroa norueguesa +npr=Rupia nepalesa +nzd=D\u00f3lar da Nova Zel\u00e2ndia +omr=Rial de Om\u00e3 +pab=Balboa panamenho +pen=Sol Novo peruano +pgk=Kina da Papua-Nova Guin\u00e9 +php=Peso filipino +pkr=Rupia paquistanesa +pln=Zloti polon\u00eas +pte=Escudo portugu\u00eas +pyg=Guarani paraguaio +qar=Rial catariano +rol=Leu romeno antigo +ron=Leu romeno +rsd=Dinar s\u00e9rvio +rub=Rublo russo +rur=Rublo russo (1991-1998) +rwf=Franco ruand\u00eas +sar=Rial saudita +sbd=D\u00f3lar das Ilhas Salom\u00e3o +scr=Rupia das Seychelles +sdd=Dinar sudan\u00eas +sdg=Libra sudanesa +sek=Coroa sueca +sgd=D\u00f3lar de Cingapura +shp=Libra de Santa Helena +sit=Tolar Bons esloveno +skk=Coroa eslovaca +sll=Leone de Serra Leoa +sos=Xelim somali +srd=D\u00f3lar do Suriname +srg=Florim do Suriname +std=Dobra de S\u00e3o Tom\u00e9 e Pr\u00edncipe +svc=Colom salvadorenho +syp=Libra s\u00edria +szl=Lilangeni da Suazil\u00e2ndia +thb=Baht tailand\u00eas +tjs=Somoni tadjique +tmm=Manat do Turcomenist\u00e3o +tnd=Dinar tunisiano +top=Pa\u02bbanga de Tonga +tpe=Escudo timorense +trl=Lira turca antiga +try=Lira turca +ttd=D\u00f3lar de Trinidad e Tobago +twd=D\u00f3lar Novo de Taiwan +tzs=Xelim da Tanz\u00e2nia +uah=Hryvnia ucraniano +ugx=Xelim ugandense +usd=D\u00f3lar norte-americano +usn=D\u00f3lar norte-americano (Dia seguinte) +uss=D\u00f3lar norte-americano (Mesmo dia) +uyu=Peso uruguaio +uzs=Sum do Usbequist\u00e3o +veb=Bol\u00edvar venezuelano +vef=Bol\u00edvar v enezuelano forte +vnd=Dong vietnamita +vuv=Vatu de Vanuatu +wst=Tala samoano +xaf=Franco CFA BEAC +xag=Prata +xau=Ouro +xba=Unidade Composta Europeia +xbb=Unidade Monet\u00e1ria Europeia +xbc=Unidade de Conta Europeia (XBC) +xbd=Unidade de Conta Europeia (XBD) +xcd=D\u00f3lar do Caribe Oriental +xdr=Direitos Especiais de Giro +xfo=Franco-ouro franc\u00eas +xfu=Franco UIC franc\u00eas +xof=Franco CFA BCEAO +xpd=Pal\u00e1dio +xpf=Franco CFP +xpt=Platina +xts=C\u00f3digo de Moeda de Teste +xxx=Moeda Desconhecida ou Inv\u00e1lida +yer=Rial iemenita +yum=Dinar noviy iugoslavo +zar=Rand sul-africano +zmk=Cuacha zambiano +zwd=D\u00f3lar do Zimb\u00e1bue diff --git a/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_BA.properties b/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_BA.properties new file mode 100644 index 0000000000000000000000000000000000000000..a5f63a940da460e5385849372d2313fc863fc2d8 --- /dev/null +++ b/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_BA.properties @@ -0,0 +1,69 @@ +# +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# COPYRIGHT AND PERMISSION NOTICE +# +# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. +# Distributed under the Terms of Use in http://www.unicode.org/copyright.html. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of the Unicode data files and any associated documentation (the +# "Data Files") or Unicode software and any associated documentation +# (the "Software") to deal in the Data Files or Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, and/or sell copies of the Data +# Files or Software, and to permit persons to whom the Data Files or +# Software are furnished to do so, provided that (a) the above copyright +# notice(s) and this permission notice appear with all copies of the +# Data Files or Software, (b) both the above copyright notice(s) and +# this permission notice appear in associated documentation, and (c) +# there is clear notice in each modified Data File or in the Software as +# well as in the documentation associated with the Data File(s) or +# Software that the data or software has been modified. +# +# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR +# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR +# SOFTWARE. +# +# Except as contained in this notice, the name of a copyright holder +# shall not be used in advertising or otherwise to promote the sale, use +# or other dealings in these Data Files or Software without prior +# written authorization of the copyright holder. + +# +# Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +# +BAM=KM +bam=bosansko-hercegova\u010dkih konvertibilnih maraka +EUR=\u20ac +eur=evra diff --git a/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_ME.properties b/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_ME.properties new file mode 100644 index 0000000000000000000000000000000000000000..2746103ca98a8022cd01f16b9a47edb74e15cf3b --- /dev/null +++ b/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_ME.properties @@ -0,0 +1,67 @@ +# +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# COPYRIGHT AND PERMISSION NOTICE +# +# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. +# Distributed under the Terms of Use in http://www.unicode.org/copyright.html. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of the Unicode data files and any associated documentation (the +# "Data Files") or Unicode software and any associated documentation +# (the "Software") to deal in the Data Files or Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, and/or sell copies of the Data +# Files or Software, and to permit persons to whom the Data Files or +# Software are furnished to do so, provided that (a) the above copyright +# notice(s) and this permission notice appear with all copies of the +# Data Files or Software, (b) both the above copyright notice(s) and +# this permission notice appear in associated documentation, and (c) +# there is clear notice in each modified Data File or in the Software as +# well as in the documentation associated with the Data File(s) or +# Software that the data or software has been modified. +# +# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR +# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR +# SOFTWARE. +# +# Except as contained in this notice, the name of a copyright holder +# shall not be used in advertising or otherwise to promote the sale, use +# or other dealings in these Data Files or Software without prior +# written authorization of the copyright holder. + +# +# Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +# +EUR=\u20ac +eur=evra diff --git a/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_RS.properties b/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_RS.properties new file mode 100644 index 0000000000000000000000000000000000000000..34992f0e310df2f7e3a41bc8a67464aeb459c229 --- /dev/null +++ b/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_RS.properties @@ -0,0 +1,67 @@ +# +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# COPYRIGHT AND PERMISSION NOTICE +# +# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. +# Distributed under the Terms of Use in http://www.unicode.org/copyright.html. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of the Unicode data files and any associated documentation (the +# "Data Files") or Unicode software and any associated documentation +# (the "Software") to deal in the Data Files or Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, and/or sell copies of the Data +# Files or Software, and to permit persons to whom the Data Files or +# Software are furnished to do so, provided that (a) the above copyright +# notice(s) and this permission notice appear with all copies of the +# Data Files or Software, (b) both the above copyright notice(s) and +# this permission notice appear in associated documentation, and (c) +# there is clear notice in each modified Data File or in the Software as +# well as in the documentation associated with the Data File(s) or +# Software that the data or software has been modified. +# +# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR +# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR +# SOFTWARE. +# +# Except as contained in this notice, the name of a copyright holder +# shall not be used in advertising or otherwise to promote the sale, use +# or other dealings in these Data Files or Software without prior +# written authorization of the copyright holder. + +# +# Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +# +RSD=din. +rsd=srpski dinari diff --git a/src/share/classes/sun/util/resources/CurrencyNames_sr_RS.properties b/src/share/classes/sun/util/resources/CurrencyNames_sr_RS.properties new file mode 100644 index 0000000000000000000000000000000000000000..b6153c86f64f2e0cc0b8b7a8dc428b9d3eb7d902 --- /dev/null +++ b/src/share/classes/sun/util/resources/CurrencyNames_sr_RS.properties @@ -0,0 +1,43 @@ +# +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# + +# +# COPYRIGHT AND PERMISSION NOTICE +# +# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. +# Distributed under the Terms of Use in http://www.unicode.org/copyright.html. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of the Unicode data files and any associated documentation (the "Data +# Files") or Unicode software and any associated documentation (the +# "Software") to deal in the Data Files or Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, and/or sell copies of the Data Files or Software, and +# to permit persons to whom the Data Files or Software are furnished to do +# so, provided that (a) the above copyright notice(s) and this permission +# notice appear with all copies of the Data Files or Software, (b) both the +# above copyright notice(s) and this permission notice appear in associated +# documentation, and (c) there is clear notice in each modified Data File or +# in the Software as well as in the documentation associated with the Data +# File(s) or Software that the data or software has been modified. +# +# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF +# THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS +# INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR +# CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THE DATA FILES OR SOFTWARE. +# +# Except as contained in this notice, the name of a copyright holder shall not +# be used in advertising or otherwise to promote the sale, use or other +# dealings in these Data Files or Software without prior written +# authorization of the copyright holder. +# + +# Generated automatically from the Common Locale Data Repository. DO NOT EDIT! + +RSD=\u0434\u0438\u043d. diff --git a/src/share/classes/sun/util/resources/LocaleData.java b/src/share/classes/sun/util/resources/LocaleData.java index 9686abc8e2ffb1a0efeb376849b598aa2bd79e6d..86d6e92d8bfefa0150ef808289e0668052237d47 100644 --- a/src/share/classes/sun/util/resources/LocaleData.java +++ b/src/share/classes/sun/util/resources/LocaleData.java @@ -171,16 +171,21 @@ public class LocaleData { /* Get the locale string list from LocaleDataMetaInfo class. */ String localeString = LocaleDataMetaInfo.getSupportedLocaleString(baseName); - if (localeString.length() == 0) { + if (localeString.length() == 0) { return candidates; } for (Iterator l = candidates.iterator(); l.hasNext(); ) { - String lstr = l.next().toString(); - /* truncate extra segment introduced by Java 7 for script and extesions */ - int idx = lstr.indexOf("_#"); - if (idx >= 0) { - lstr = lstr.substring(0, idx); + Locale loc = l.next(); + String lstr = null; + if (loc.getScript().length() > 0) { + lstr = loc.toLanguageTag().replace('-', '_'); + } else { + lstr = loc.toString(); + int idx = lstr.indexOf("_#"); + if (idx >= 0) { + lstr = lstr.substring(0, idx); + } } /* Every locale string in the locale string list returned from the above getSupportedLocaleString is enclosed @@ -265,28 +270,15 @@ public class LocaleData { Locale[] locales = new Locale[localeStringTokenizer.countTokens()]; for (int i = 0; i < locales.length; i++) { - String currentToken = localeStringTokenizer.nextToken(); - int p2 = 0; - int p1 = currentToken.indexOf('_'); - String language = ""; - String country = ""; - String variant = ""; - - if (p1 == -1) { - language = currentToken; - } else { - language = currentToken.substring(0, p1); - p2 = currentToken.indexOf('_', p1 + 1); - if (p2 == -1) { - country = currentToken.substring(p1 + 1); - } else { - country = currentToken.substring(p1 + 1, p2); - if (p2 < currentToken.length()) { - variant = currentToken.substring(p2 + 1); - } - } + String currentToken = localeStringTokenizer.nextToken().replace('_','-'); + if (currentToken.equals("ja-JP-JP")) { + currentToken = "ja-JP-u-ca-japanese-x-lvariant-JP"; + } else if (currentToken.equals("th-TH-TH")) { + currentToken = "th-TH-u-nu-thai-x-lvariant-TH"; + } else if (currentToken.equals("no-NO-NY")) { + currentToken = "no-NO-x-lvariant-NY"; } - locales[i] = new Locale(language, country, variant); + locales[i] = Locale.forLanguageTag(currentToken); } return locales; } diff --git a/src/share/classes/sun/util/resources/LocaleNames_sr_Latn.properties b/src/share/classes/sun/util/resources/LocaleNames_sr_Latn.properties new file mode 100644 index 0000000000000000000000000000000000000000..7cc1c2477c7c1c0842e5614cde6376bbfc16daf9 --- /dev/null +++ b/src/share/classes/sun/util/resources/LocaleNames_sr_Latn.properties @@ -0,0 +1,471 @@ +# +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# COPYRIGHT AND PERMISSION NOTICE +# +# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. +# Distributed under the Terms of Use in http://www.unicode.org/copyright.html. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of the Unicode data files and any associated documentation (the +# "Data Files") or Unicode software and any associated documentation +# (the "Software") to deal in the Data Files or Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, and/or sell copies of the Data +# Files or Software, and to permit persons to whom the Data Files or +# Software are furnished to do so, provided that (a) the above copyright +# notice(s) and this permission notice appear with all copies of the +# Data Files or Software, (b) both the above copyright notice(s) and +# this permission notice appear in associated documentation, and (c) +# there is clear notice in each modified Data File or in the Software as +# well as in the documentation associated with the Data File(s) or +# Software that the data or software has been modified. +# +# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR +# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR +# SOFTWARE. +# +# Except as contained in this notice, the name of a copyright holder +# shall not be used in advertising or otherwise to promote the sale, use +# or other dealings in these Data Files or Software without prior +# written authorization of the copyright holder. + +# +# Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +# +aa=Afarski +ab=Abkazijski +ae=Avestanski +af=Afrikanerski +am=Amharski +an=Aragone\u017eanski +ar=Arapski +as=Asemijski +av=Avarski +ay=Ajmara +az=Azerbejd\u017eanski +ba=Ba\u0161kir +be=Beloruski +bg=Bugarski +bh=Biharski +bn=Bengalski +bo=Tibetanski +br=Bretonski +bs=Bosanski +ca=Katalonski +ce=\u010ce\u010denski +ch=\u010camoro +co=Korzikanski +cr=Kri +cs=\u010ce\u0161ki +cu=Staroslovenski +cv=\u010cuva\u0161ki +cy=Vel\u0161ki +da=Danski +de=Nema\u010dki +dv=Divehijski +dz=D\u017eonga +ee=Eve +el=Gr\u010dki +en=Engleski +eo=Esperanto +es=\u0160panski +et=Estonski +eu=Baskijski +fa=Persijski +fi=Finski +fj=Fid\u017eijski +fo=Farski +fr=Francuski +fy=Frizijski +ga=Irski +gd=\u0160kotski Galski +gl=Galski +gn=Gvarani +gu=Gud\u017earati +gv=Manks +he=Hebrejski +hi=Hindi +hr=Hrvatski +ht=Hai\u0107anski +hu=Ma\u0111arski +hy=Jermenski +ia=Interlingva +id=Indonezijski +ie=Interlingve +ii=Si\u010duan ji +ik=Inupiak +in=Indonezijski +is=Islandski +it=Italijanski +iw=Hebrejski +ja=Japanski +ji=Jidi\u0161 +jv=Javanski +ka=Gruzijski +ki=Kikuju +kj=Kuanjama +kk=Koza\u010dki +kl=Kalalisutski +km=Kmerski +kn=Kanada +ko=Korejski +ks=Ka\u0161miri +ku=Kurdski +kw=Korni\u0161ki +ky=Kirgiski +la=Latinski +lb=Luksembur\u0161ki +li=Limburgi\u0161 +lo=Lao\u0161ki +lt=Litvanski +lu=Luba-katanga +lv=Letonski +mg=Malagazijski +mh=Mar\u0161alski +mi=Maorski +mk=Makedonski +ml=Malajalam +mn=Mongolski +mo=Moldavski +mr=Marati +ms=Malajski +mt=Melte\u0161ki +my=Burmanski +nb=Norve\u0161ki bokm\u00e5l +nd=Severni ndebele +ne=Nepalski +nl=Holandski +nn=Norve\u0161ki njorsk +no=Norve\u0161ki +nr=Ju\u017eni ndebele +nv=Navaho +ny=Njanja +oc=Provansalski +oj=Ojibva +or=Orijski +os=Osetski +pa=Pand\u017eabski +pl=Poljski +ps=Pa\u0161tunski +pt=Portugalski +qu=Kven\u010da +rm=Reto-Romanski +ro=Rumunski +ru=Ruski +rw=Kinjarvanda +sa=Sanskrit +sc=Sardinijski +sd=Sindi +se=Severni sami +si=Singaleski +sk=Slova\u010dki +sl=Slovena\u010dki +sm=Samoanski +sn=\u0160ona +so=Somalski +sq=Albanski +sr=Srpski +ss=Svati +st=Sesoto +su=Sudanski +sv=\u0160vedski +sw=Svahili +ta=Tamilski +tg=Ta\u0111ik +th=Tajlandski +ti=Tigrinja +tk=Turkmenski +tl=Tagalski +tn=Tsvana +tr=Turski +tt=Tatarski +tw=Tvi +ty=Tahi\u0107anski +ug=Ujgurski +uk=Ukrajinski +uz=Uzbe\u010dki +vi=Vijetnamski +wa=Valun +wo=Volof +xh=Khosa +yi=Jidi\u0161 +yo=Jorubanski +za=Zuang +zh=Kineski +AD=Andora +AE=Ujedinjeni Arapski Emirati +AF=Avganistan +AG=Antigva i Barbuda +AI=Angvila +AL=Albanija +AM=Armenija +AN=Holandski Antili +AO=Angola +AQ=Antarktika +AR=Argentina +AS=Ameri\u010dka Samoa +AT=Austrija +AU=Australija +AW=Aruba +AX=Alandska ostrva +AZ=Azerbejd\u017ean +BA=Bosna i Hercegovina +BB=Barbados +BD=Banglade\u0161 +BE=Belgija +BF=Burkina Faso +BG=Bugarska +BH=Bahrein +BI=Burundi +BJ=Benin +BL=Sv. Bartolomej +BM=Bermuda +BN=Brunej +BO=Bolivija +BR=Brazil +BS=Bahami +BT=Butan +BV=Buve Ostrva +BW=Bocvana +BY=Belorusija +BZ=Belise +CA=Kanada +CC=Kokos (Keling) Ostrva +CD=Demokratska Republika Kongo +CF=Centralno Afri\u010dka Republika +CG=Kongo +CH=\u0160vajcarska +CI=Obala Slonova\u010de +CK=Kukova Ostrva +CL=\u010cile +CM=Kamerun +CN=Kina +CO=Kolumbija +CR=Kostarika +CU=Kuba +CV=Kape Verde +CX=Bo\u017ei\u0107na Ostrva +CY=Kipar +CZ=\u010ce\u0161ka +DE=Nema\u010dka +DJ=D\u017eibuti +DK=Danska +DM=Dominika +DO=Dominikanska Republika +DZ=Al\u017eir +EC=Ekvador +EE=Estonija +EG=Egipat +EH=Zapadna Sahara +ER=Eritreja +ES=\u0160panija +ET=Etiopija +FI=Finska +FJ=Fid\u017ei +FK=Folklandska Ostrva +FM=Mikronezija +FO=Farska Ostrva +FR=Francuska +GA=Gabon +GB=Velika Britanija +GD=Grenada +GE=Gruzija +GF=Francuska Gvajana +GG=Gurnsi +GH=Gana +GI=Gibraltar +GL=Grenland +GM=Gambija +GN=Gvineja +GP=Gvadelupe +GQ=Ekvatorijalna Gvineja +GR=Gr\u010dka +GS=Ju\u017ena D\u017eord\u017eija i Ju\u017ena Sendvi\u010d Ostrva +GT=Gvatemala +GU=Guam +GW=Gvineja-Bisao +GY=Gvajana +HK=Hong Kong (S. A. R. Kina) +HM=Herd i Mekdonald Ostrva +HN=Honduras +HR=Hrvatska +HT=Haiti +HU=Ma\u0111arska +ID=Indonezija +IE=Irska +IL=Izrael +IM=Ostrvo Man +IN=Indija +IO=Britansko Indijska Okeanska Teritorija +IQ=Irak +IR=Iran +IS=Island +IT=Italija +JE=D\u017eersi +JM=Jamajka +JO=Jordan +JP=Japan +KE=Kenija +KG=Kirgizstan +KH=Kambod\u017ea +KI=Kiribati +KM=Komorska Ostrva +KN=Sent Kits i Nevis +KP=Severna Koreja +KR=Ju\u017ena Koreja +KW=Kuvajt +KY=Kajmanska Ostrva +KZ=Kazahstan +LA=Laos +LB=Liban +LC=Sent Lucija +LI=Lihten\u0161tajn +LK=\u0160ri Lanka +LR=Liberija +LS=Lesoto +LT=Litvanija +LU=Luksemburg +LV=Letonija +LY=Libija +MA=Maroko +MC=Monako +MD=Moldavija +ME=Crna Gora +MF=Sv. Martin +MG=Madagaskar +MH=Mar\u0161alska Ostrva +MK=Makedonija +ML=Mali +MM=Mijanmar +MN=Mongolija +MO=Makao (S. A. R. Kina) +MP=Severna Marijanska Ostrva +MQ=Martinik +MR=Mauritanija +MS=Monserat +MT=Malta +MU=Mauricius +MV=Maldivi +MW=Malavi +MX=Meksiko +MY=Malezija +MZ=Mozambik +NA=Namibija +NC=Nova Kaledonija +NE=Niger +NF=Norfolk Ostrvo +NG=Nigerija +NI=Nikaragva +NL=Holandija +NO=Norve\u0161ka +NP=Nepal +NR=Nauru +NU=Niue +NZ=Novi Zeland +OM=Oman +PA=Panama +PE=Peru +PF=Francuska Polinezija +PG=Papua Nova Gvineja +PH=Filipini +PK=Pakistan +PL=Poljska +PM=Sen Pjer i Mikelon +PN=Pitcairn +PR=Porto Riko +PS=Palestinska Teritorija +PT=Portugal +PW=Palau +PY=Paragvaj +QA=Katar +RE=Rejunion +RO=Rumunija +RS=Srbija +RU=Rusija +RW=Ruanda +SA=Saudijska Arabija +SB=Solomonska Ostrva +SC=Sej\u0161eli +SD=Sudan +SE=\u0160vedska +SG=Singapur +SH=Sveta Jelena +SI=Slovenija +SJ=Svalbard i Janmajen Ostrva +SK=Slova\u010dka +SL=Sijera Leone +SM=San Marino +SN=Senegal +SO=Somalija +SR=Surinam +ST=Sao Tome i Principe +SV=Salvador +SY=Sirija +SZ=Svazilend +TC=Turks i Kajkos Ostrva +TD=\u010cad +TF=Francuske Ju\u017ene Teritorije +TG=Togo +TH=Tajland +TJ=Tad\u017eikistan +TK=Tokelau +TL=Isto\u010dni Timor +TM=Turkmenistan +TN=Tunis +TO=Tonga +TR=Turska +TT=Trinidad i Tobago +TV=Tuvalu +TW=Tajvan +TZ=Tanzanija +UA=Ukrajina +UG=Uganda +UM=Manja Udaljena Ostrva SAD +US=Sjedinjene Ameri\u010dke Dr\u017eave +UY=Urugvaj +UZ=Uzbekistan +VA=Vatikan +VC=Sent Vinsent i Grenadini +VE=Venecuela +VG=Britanska Devi\u010danska Ostrva +VI=S.A.D. Devi\u010danska Ostrva +VN=Vijetnam +VU=Vanuatu +WF=Valis i Futuna Ostrva +WS=Samoa +YE=Jemen +YT=Majote +ZA=Ju\u017enoafri\u010dka Republika +ZM=Zambija +ZW=Zimbabve diff --git a/src/share/classes/sun/util/resources/TimeZoneNames.java b/src/share/classes/sun/util/resources/TimeZoneNames.java index a5c73549809116fa322aaec2347605f67aef6161..0016ae24d20a85dec4e6df99984d339b01d3a182 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames.java @@ -216,6 +216,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"Pierre & Miquelon Standard Time", "PMST", "Pierre & Miquelon Daylight Time", "PMDT"}}, diff --git a/src/share/classes/sun/util/resources/TimeZoneNames_de.java b/src/share/classes/sun/util/resources/TimeZoneNames_de.java index b3cb23224fadb61f3858f4eab98a836193e4c1f2..0e4d91d94f7f54d6df336d450bf19317bf103f60 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames_de.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames_de.java @@ -216,6 +216,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"Pierre & Miquelon Normalzeit", "PMST", "Pierre & Miquelon Sommerzeit", "PMDT"}}, diff --git a/src/share/classes/sun/util/resources/TimeZoneNames_es.java b/src/share/classes/sun/util/resources/TimeZoneNames_es.java index 613cc6419fb1309315025f3424a4e539214f1bd1..711afc4556311fc466b38a3035d862ea2b8d0801 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames_es.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames_es.java @@ -216,6 +216,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"Hora est\u00e1ndar de Pierre & Miquelon", "PMST", "Hora de verano de Pierre & Miquelon", "PMDT"}}, diff --git a/src/share/classes/sun/util/resources/TimeZoneNames_fr.java b/src/share/classes/sun/util/resources/TimeZoneNames_fr.java index f1dc5300c25815ae7cbe70a0af6754c852eb28e3..090820b67429267fb0c1783042c1abe48c375c1d 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames_fr.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames_fr.java @@ -216,6 +216,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"Heure normale de Saint-Pierre et Miquelon", "PMST", "Heure avanc\u00e9e de Saint-Pierre et Miquelon", "PMDT"}}, diff --git a/src/share/classes/sun/util/resources/TimeZoneNames_it.java b/src/share/classes/sun/util/resources/TimeZoneNames_it.java index e983872e7a169656012273a9540980f6b048bc65..6413104ba74065322563cbc70158a17a93be012a 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames_it.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames_it.java @@ -216,6 +216,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"Ora solare di Saint-Pierre e Miquelon", "PMST", "Ora legale di Saint-Pierre e Miquelon", "PMDT"}}, diff --git a/src/share/classes/sun/util/resources/TimeZoneNames_ja.java b/src/share/classes/sun/util/resources/TimeZoneNames_ja.java index 56330acf91dd54f2d25b92e7d430cd5db720dd11..4c1226666c8fda4c44c2e0b0c1a97c03c686d4d4 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames_ja.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames_ja.java @@ -216,6 +216,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"\u30b5\u30f3\u30d4\u30a8\u30fc\u30eb\u30fb\u30df\u30af\u30ed\u30f3\u8af8\u5cf6\u6a19\u6e96\u6642", "PMST", "\u30b5\u30f3\u30d4\u30a8\u30fc\u30eb\u30fb\u30df\u30af\u30ed\u30f3\u8af8\u5cf6\u590f\u6642\u9593", "PMDT"}}, diff --git a/src/share/classes/sun/util/resources/TimeZoneNames_ko.java b/src/share/classes/sun/util/resources/TimeZoneNames_ko.java index 82edcce1ec58a038f988ce31b833a1a0383bfbab..486e1bdd9a5e5f5dca98ca0d7d25b48d485a5ab6 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames_ko.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames_ko.java @@ -216,6 +216,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"\ud53c\uc5d0\ub974 \ubbf8\ud06c\ub860 \ud45c\uc900\uc2dc", "PMST", "\ud53c\uc5d0\ub974 \ubbf8\ud06c\ub860 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "PMDT"}}, diff --git a/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java b/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java index d9b83fe04912aadec05858760fefd10899ff4f73..7eab4bb48b4e50c9cefb53ae1be39aa171080d00 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java @@ -217,6 +217,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"Fuso hor\u00e1rio padr\u00e3o de S\u00e3o Pedro e Miquelon", "PMST", "Hor\u00e1rio de luz natural de S\u00e3o Pedro e Miquelon", "PMDT"}}, diff --git a/src/share/classes/sun/util/resources/TimeZoneNames_sv.java b/src/share/classes/sun/util/resources/TimeZoneNames_sv.java index 14108065241cdb438ef418ad291110b37cd6616f..63b5e0845234ee346d6b2c3ec69f89c531cf7aad 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames_sv.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames_sv.java @@ -216,6 +216,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"Saint-Pierre-et-Miquelon, normaltid", "PMST", "Saint-Pierre-et-Miquelon, sommartid", "PMDT"}}, diff --git a/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java b/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java index 4f80a1b739cf8cc4d2cab35e0e20f588159baf1a..b215a186e9a9983102bf146c4fb4d746b77acc81 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java @@ -216,6 +216,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"\u76ae\u57c3\u5c14\u5c9b\u53ca\u5bc6\u514b\u9686\u5c9b\u6807\u51c6\u65f6\u95f4", "PMST", "\u76ae\u57c3\u5c14\u5c9b\u53ca\u5bc6\u514b\u9686\u5c9b\u590f\u4ee4\u65f6", "PMDT"}}, diff --git a/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java b/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java index 5218bed7ed6b097ebd0e3af1e3b114f61d1755fe..7a638641e898db9e4c318df3e645b84d6de0bcc7 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java @@ -216,6 +216,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { {"America/Anchorage", AKST}, {"AST", AKST}, {"America/Halifax", AST}, + {"America/Sitka", AKST}, {"America/St_Johns", NST}, {"CNT", NST}, {"Europe/Paris", CET}, @@ -392,6 +393,8 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { {"America/Mendoza", AGT}, {"America/Menominee", CST}, {"America/Merida", CST}, + {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST", + "Metlakatla Daylight Time", "MeDT"}}, {"America/Mexico_City", CST}, {"America/Miquelon", new String[] {"\u76ae\u57c3\u723e\u5cf6\u53ca\u5bc6\u514b\u9686\u5cf6\u6a19\u6e96\u6642\u9593", "PMST", "\u76ae\u57c3\u723e\u5cf6\u53ca\u5bc6\u514b\u9686\u5cf6\u65e5\u5149\u7bc0\u7d04\u6642\u9593", "PMDT"}}, diff --git a/src/share/demo/jfc/Notepad/resources/Notepad.properties b/src/share/demo/jfc/Notepad/resources/Notepad.properties index fdd5c5a22468817d64b832b8cf4712f7f39c139d..ef61d6fd3c461689b567627e34d9e875f9cadc20 100644 --- a/src/share/demo/jfc/Notepad/resources/Notepad.properties +++ b/src/share/demo/jfc/Notepad/resources/Notepad.properties @@ -3,12 +3,15 @@ Title=Notepad ElementTreeFrameTitle=Elements +# The following string should NOT be translated: ViewportBackingStore ViewportBackingStore=false # menubar definition # # Each of the strings that follow form a key to be # used to the actual menu definition. + +# The following string should NOT be translated: menubar menubar=file edit debug # file Menu definition @@ -20,6 +23,8 @@ menubar=file edit debug # new -> Notepad.newAction # save -> Notepad.saveAction # exit -> Notepad.exitAction + +# The following string should NOT be translated: file file=new open save - exit fileLabel=File openLabel=Open @@ -36,28 +41,38 @@ exitLabel=Exit # cut -> JTextComponent.cutAction # copy -> JTextComponent.copyAction # paste -> JTextComponent.pasteAction + +# The following string should NOT be translated: edit edit=cut copy paste - undo redo editLabel=Edit cutLabel=Cut +# The following string should NOT be translated: cutAction cutAction=cut-to-clipboard cutImage=resources/cut.gif copyLabel=Copy +# The following string should NOT be translated: copyAction copyAction=copy-to-clipboard copyImage=resources/copy.gif pasteLabel=Paste +# The following string should NOT be translated: pasteAction pasteAction=paste-from-clipboard pasteImage=resources/paste.gif undoLabel=Undo +# The following string should NOT be translated: undoAction undoAction=Undo redoLabel=Redo +# The following string should NOT be translated: redoAction redoAction=Redo # # debug Menu definition # + +# The following string should NOT be translated: debug debug=dump showElementTree debugLabel=Debug dumpLabel=Dump model to System.err +# The following string should NOT be translated: dumpAction dumpAction=dump-model showElementTreeLabel=Show Elements @@ -67,6 +82,8 @@ showElementTreeLabel=Show Elements # used as the basis of the tool definition. Actions # are of course sharable, and in this case are shared # with the menu items. + +# The following string should NOT be translated: toolbar toolbar=new open save - cut copy paste newTooltip=Create a new file openTooltip=Open a file diff --git a/src/share/demo/jfc/Notepad/resources/Notepad_ja.properties b/src/share/demo/jfc/Notepad/resources/Notepad_ja.properties index 8a40242b9ec8550bc2cf2ce2ae1619d8e02a17a7..777e1cf72f97c631ce60e89b3a6b4060a0f251a0 100644 --- a/src/share/demo/jfc/Notepad/resources/Notepad_ja.properties +++ b/src/share/demo/jfc/Notepad/resources/Notepad_ja.properties @@ -9,7 +9,7 @@ ViewportBackingStore=false # # Each of the strings that follow form a key to be # used to the actual menu definition. -menubar=\u30D5\u30A1\u30A4\u30EB \u7DE8\u96C6 \u30C7\u30D0\u30C3\u30B0 +menubar=file edit debug # file Menu definition # @@ -20,7 +20,7 @@ menubar=\u30D5\u30A1\u30A4\u30EB \u7DE8\u96C6 \u30C7\u30D0\u30C3\u30B0 # new -> Notepad.newAction # save -> Notepad.saveAction # exit -> Notepad.exitAction -file=\u65B0\u898F \u958B\u304F \u4FDD\u5B58 - \u7D42\u4E86 +file=new open save - exit fileLabel=\u30D5\u30A1\u30A4\u30EB openLabel=\u958B\u304F openImage=resources/open.gif @@ -36,7 +36,7 @@ exitLabel=\u7D42\u4E86 # cut -> JTextComponent.cutAction # copy -> JTextComponent.copyAction # paste -> JTextComponent.pasteAction -edit=\u5207\u53D6\u308A \u30B3\u30D4\u30FC \u8CBC\u4ED8\u3051 - \u5143\u306B\u623B\u3059 \u518D\u5B9F\u884C +edit=cut copy paste - undo redo editLabel=\u7DE8\u96C6 cutLabel=\u5207\u53D6\u308A cutAction=cut-to-clipboard @@ -48,14 +48,14 @@ pasteLabel=\u8CBC\u4ED8\u3051 pasteAction=paste-from-clipboard pasteImage=resources/paste.gif undoLabel=\u5143\u306B\u623B\u3059 -undoAction=\u5143\u306B\u623B\u3059 +undoAction=Undo redoLabel=\u518D\u5B9F\u884C -redoAction=\u518D\u5B9F\u884C +redoAction=Redo # # debug Menu definition # -debug=showElementTree\u306E\u30C0\u30F3\u30D7 +debug=dump showElementTree debugLabel=\u30C7\u30D0\u30C3\u30B0 dumpLabel=\u30E2\u30C7\u30EB\u3092System.err\u306B\u30C0\u30F3\u30D7 dumpAction=dump-model @@ -67,7 +67,7 @@ showElementTreeLabel=\u8981\u7D20\u306E\u8868\u793A # used as the basis of the tool definition. Actions # are of course sharable, and in this case are shared # with the menu items. -toolbar=\u65B0\u898F \u958B\u304F \u4FDD\u5B58 - \u5207\u53D6\u308A \u30B3\u30D4\u30FC \u8CBC\u4ED8\u3051 +toolbar=new open save - cut copy paste newTooltip=\u30D5\u30A1\u30A4\u30EB\u3092\u65B0\u898F\u4F5C\u6210\u3059\u308B openTooltip=\u30D5\u30A1\u30A4\u30EB\u3092\u958B\u304F saveTooltip=\u30D5\u30A1\u30A4\u30EB\u306B\u4FDD\u5B58 diff --git a/src/share/demo/jfc/Notepad/resources/Notepad_zh_CN.properties b/src/share/demo/jfc/Notepad/resources/Notepad_zh_CN.properties index 9706f903dadd5a86d8b8d9d63e91a8b1b345d653..be6ec0692c14804885290bc3902a03ad3b438c6c 100644 --- a/src/share/demo/jfc/Notepad/resources/Notepad_zh_CN.properties +++ b/src/share/demo/jfc/Notepad/resources/Notepad_zh_CN.properties @@ -48,9 +48,9 @@ pasteLabel=\u7C98\u8D34 pasteAction=paste-from-clipboard pasteImage=resources/paste.gif undoLabel=\u64A4\u6D88 -undoAction=\u64A4\u6D88 +undoAction=Undo redoLabel=\u91CD\u505A -redoAction=\u91CD\u505A +redoAction=Redo # # debug Menu definition diff --git a/src/share/native/common/check_code.c b/src/share/native/common/check_code.c index 00dcdf163b3986f30cce944bd3b4632d283b566e..dcdaeda58bfebe31c2a530161d3e5305bc487275 100644 --- a/src/share/native/common/check_code.c +++ b/src/share/native/common/check_code.c @@ -2685,11 +2685,11 @@ push_stack(context_type *context, unsigned int inumber, stack_info_type *new_sta switch (type_table[operand]) { case JVM_CONSTANT_MethodType: full_info = make_class_info_from_name(context, - "java/dyn/MethodType"); + "java/lang/invoke/MethodType"); break; default: //JVM_CONSTANT_MethodHandle full_info = make_class_info_from_name(context, - "java/dyn/MethodHandle"); + "java/lang/invoke/MethodHandle"); break; } break; diff --git a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c index 04a87fd1cac8ac663f69976e39a214547924e28a..84b91889725b401c40f113075977ed5baba448b2 100644 --- a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c +++ b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c @@ -40,7 +40,7 @@ #include #include #include - +#include /* java native interface headers */ #include "jni.h" @@ -2657,7 +2657,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage (destWidth < 0) || (destWidth > srcWidth) || (destHeight < 0) || (stepX < 0) || (stepY < 0) || - ((scanLineSize / numBands) < destWidth)) /* destWidth causes an integer overflow */ + ((INT_MAX / numBands) < destWidth)) /* destWidth causes an integer overflow */ { JNU_ThrowByName(env, "javax/imageio/IIOException", "Invalid argument to native writeImage"); diff --git a/src/share/native/sun/font/layout/KernTable.cpp b/src/share/native/sun/font/layout/KernTable.cpp index 8d368211309a65b9966144bde281a32bfc47b4ee..3a9987eb6b90f648e20c778375e4cc3dad2a6f2d 100644 --- a/src/share/native/sun/font/layout/KernTable.cpp +++ b/src/share/native/sun/font/layout/KernTable.cpp @@ -210,7 +210,7 @@ void KernTable::process(LEGlyphStorage& storage) // all the elements ahead of time and store them in the font const PairInfo* p = pairs; - const PairInfo* tp = (const PairInfo*)(p + rangeShift); + const PairInfo* tp = (const PairInfo*)(p + (rangeShift/KERN_PAIRINFO_SIZE)); /* rangeshift is in original table bytes */ if (key > tp->key) { p = tp; } @@ -222,7 +222,7 @@ void KernTable::process(LEGlyphStorage& storage) le_uint32 probe = searchRange; while (probe > 1) { probe >>= 1; - tp = (const PairInfo*)(p + probe); + tp = (const PairInfo*)(p + (probe/KERN_PAIRINFO_SIZE)); le_uint32 tkey = tp->key; #if DEBUG fprintf(stdout, " %.3d (%0.8x)\n", (tp - pairs), tkey); diff --git a/src/share/native/sun/font/layout/LayoutEngine.cpp b/src/share/native/sun/font/layout/LayoutEngine.cpp index 6b0aa1baa58111fd37d20529f5603bac568c08fc..90aafde2a80e18e8ffc5a3fc1f81cf94c3823a46 100644 --- a/src/share/native/sun/font/layout/LayoutEngine.cpp +++ b/src/share/native/sun/font/layout/LayoutEngine.cpp @@ -251,6 +251,10 @@ le_int32 LayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 off return 0; } + if ((fTypoFlags & 0x4) == 0) { // no canonical processing + return count; + } + const GlyphSubstitutionTableHeader *canonGSUBTable = (GlyphSubstitutionTableHeader *) CanonShaping::glyphSubstitutionTable; LETag scriptTag = OpenTypeLayoutEngine::getScriptTag(fScriptCode); LETag langSysTag = OpenTypeLayoutEngine::getLangSysTag(fLanguageCode); diff --git a/src/share/native/sun/java2d/loops/ProcessPath.c b/src/share/native/sun/java2d/loops/ProcessPath.c index b4f724752dcef17906792164441edfcfb47c344a..5131a3e22c768b73793288d2e66f6e5095bfe564 100644 --- a/src/share/native/sun/java2d/loops/ProcessPath.c +++ b/src/share/native/sun/java2d/loops/ProcessPath.c @@ -118,19 +118,25 @@ jint Y1 = (fY1) >> MDP_PREC; \ jint res; \ \ - /* Checking bounds and clipping if necessary */ \ + /* Checking bounds and clipping if necessary. \ + * REMIND: It's temporary solution to avoid OOB in rendering code. \ + * Current approach uses float equations which are unreliable for \ + * clipping and makes assumptions about the line biases of the \ + * rendering algorithm. Also, clipping code should be moved down \ + * into only those output renderers that need it. \ + */ \ if (checkBounds) { \ - TESTANDCLIP(hnd->dhnd->yMin, hnd->dhnd->yMax, Y0, X0, Y1, X1, \ - jint, res); \ + jfloat xMinf = hnd->dhnd->xMinf + 0.5f; \ + jfloat yMinf = hnd->dhnd->yMinf + 0.5f; \ + jfloat xMaxf = hnd->dhnd->xMaxf + 0.5f; \ + jfloat yMaxf = hnd->dhnd->yMaxf + 0.5f; \ + TESTANDCLIP(yMinf, yMaxf, Y0, X0, Y1, X1, jint, res); \ if (res == CRES_INVISIBLE) break; \ - TESTANDCLIP(hnd->dhnd->yMin, hnd->dhnd->yMax, Y1, X1, Y0, X0, \ - jint, res); \ + TESTANDCLIP(yMinf, yMaxf, Y1, X1, Y0, X0, jint, res); \ if (res == CRES_INVISIBLE) break; \ - TESTANDCLIP(hnd->dhnd->xMin, hnd->dhnd->xMax, X0, Y0, X1, Y1, \ - jint, res); \ + TESTANDCLIP(xMinf, xMaxf, X0, Y0, X1, Y1, jint, res); \ if (res == CRES_INVISIBLE) break; \ - TESTANDCLIP(hnd->dhnd->xMin, hnd->dhnd->xMax, X1, Y1, X0, Y0, \ - jint, res); \ + TESTANDCLIP(xMinf, xMaxf, X1, Y1, X0, Y0, jint, res); \ if (res == CRES_INVISIBLE) break; \ } \ \ diff --git a/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java b/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java index 5ad8b8d54d80aebf2a09012c325b061a771fffaa..be2426d7f722cb9bb3ca60e47d2cd0a12fa9fcbe 100644 --- a/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java +++ b/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java @@ -68,6 +68,9 @@ import sun.net.www.protocol.http.HttpURLConnection; public class NTLMAuthentication extends AuthenticationInfo { private static final long serialVersionUID = 170L; + private static final NTLMAuthenticationCallback NTLMAuthCallback = + NTLMAuthenticationCallback.getNTLMAuthenticationCallback(); + private String hostname; private static String defaultDomain; /* Domain to use if not specified by user */ @@ -81,6 +84,14 @@ public class NTLMAuthentication extends AuthenticationInfo { return false; } + /** + * Returns true if the given site is trusted, i.e. we can try + * transparent Authentication. + */ + public static boolean isTrustedSite(URL url) { + return NTLMAuthCallback.isTrustedSite(url); + } + private void init0() { hostname = java.security.AccessController.doPrivileged( diff --git a/src/solaris/native/sun/awt/awt_DrawingSurface.c b/src/solaris/native/sun/awt/awt_DrawingSurface.c index 0c1275b3bc20663eace1d983e4b28241b0ee811a..f84c08edf66c393eba1a00b05bedf571725d10af 100644 --- a/src/solaris/native/sun/awt/awt_DrawingSurface.c +++ b/src/solaris/native/sun/awt/awt_DrawingSurface.c @@ -302,6 +302,7 @@ awt_DrawingSurface_FreeDrawingSurfaceInfo(JAWT_DrawingSurfaceInfo* dsi) #ifdef DEBUG fprintf(stderr, "Drawing Surface Info is NULL\n"); #endif + return; } free(dsi->platformInfo); free(dsi); diff --git a/src/solaris/native/sun/awt/awt_GraphicsEnv.c b/src/solaris/native/sun/awt/awt_GraphicsEnv.c index 451849509318b0acb587a043f04cd668aaa1dc31..b548df4bf5d577399adbb1dfdb66c06d09e1118f 100644 --- a/src/solaris/native/sun/awt/awt_GraphicsEnv.c +++ b/src/solaris/native/sun/awt/awt_GraphicsEnv.c @@ -240,7 +240,7 @@ makeDefaultConfig(JNIEnv *env, int screen) { AwtGraphicsConfigDataPtr defaultConfig; int xinawareScreen = 0; - VisualID forcedVisualID, defaultVisualID; + VisualID forcedVisualID = 0, defaultVisualID; char *forcedVisualStr; XVisualInfo vinfo; long mask; @@ -254,7 +254,7 @@ makeDefaultConfig(JNIEnv *env, int screen) { if ((forcedVisualStr = getenv("FORCEDEFVIS"))) { mask = VisualIDMask | VisualScreenMask; - if (sscanf(forcedVisualStr, "%x", &forcedVisualID) > 0 && + if (sscanf(forcedVisualStr, "%lx", &forcedVisualID) > 0 && forcedVisualID > 0) { vinfo.visualid = forcedVisualID; diff --git a/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java b/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java index 65969a877d57cffe59e22080f786f0bb8bc86454..5590523b6aeda1573fc3583b7a22537a90bb4f6a 100644 --- a/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java +++ b/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java @@ -26,6 +26,7 @@ package java.net; import java.io.IOException; import java.io.FileDescriptor; +import sun.net.ResourceManager; /** * This class defines the plain DatagramSocketImpl that is used for all @@ -108,6 +109,7 @@ class TwoStacksPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl protected void close() { if (fd != null || fd1 != null) { datagramSocketClose(); + ResourceManager.afterUdpClose(); fd = null; fd1 = null; } diff --git a/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java b/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java index c9c26517d9b8a99fb8af4fa613a7d9e7dfd96139..c4b20db6495695d830e040395db5671291e07016 100644 --- a/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java +++ b/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java @@ -45,6 +45,9 @@ public class NTLMAuthentication extends AuthenticationInfo { private static final long serialVersionUID = 100L; + private static final NTLMAuthenticationCallback NTLMAuthCallback = + NTLMAuthenticationCallback.getNTLMAuthenticationCallback(); + private String hostname; private static String defaultDomain; /* Domain to use if not specified by user */ @@ -142,6 +145,14 @@ public class NTLMAuthentication extends AuthenticationInfo { return true; } + /** + * Returns true if the given site is trusted, i.e. we can try + * transparent Authentication. + */ + public static boolean isTrustedSite(URL url) { + return NTLMAuthCallback.isTrustedSite(url); + } + /** * Not supported. Must use the setHeaders() method */ diff --git a/src/windows/native/sun/windows/awt_PrintJob.cpp b/src/windows/native/sun/windows/awt_PrintJob.cpp index df0f263ddfc2f904727e389056394fa9dcae8504..1deff60252a52e993bbe806792bcb8bb29de0076 100644 --- a/src/windows/native/sun/windows/awt_PrintJob.cpp +++ b/src/windows/native/sun/windows/awt_PrintJob.cpp @@ -3699,7 +3699,9 @@ static void matchPaperSize(HDC printDC, HGLOBAL hDevMode, HGLOBAL hDevNames, double* newWid, double *newHgt, WORD* paperSize) { - const double epsilon = 0.50; + // Tolerated differences in comparing page dimensions between passed in + // "orig" media with that of Windows' device. + const double epsilon = 3.6; // (1/72) of an inch const double tolerance = (1.0 * 72.0); // # inches * 72 *newWid = origWid; diff --git a/test/java/awt/font/TextLayout/CombiningPerf.java b/test/java/awt/font/TextLayout/CombiningPerf.java new file mode 100644 index 0000000000000000000000000000000000000000..d51e586e507657e6a8db6e05600594cd10a0e458 --- /dev/null +++ b/test/java/awt/font/TextLayout/CombiningPerf.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 6328154 6962082 + * @summary ensure that ascii, and latin-1 text without combining marks, both layout faster + * than latin-1 text with combining marks. The presumption is then that the canonical + * GSUB table is being run only on the latter and not on either of the former. + */ + +import java.awt.Font; +import java.awt.GraphicsEnvironment; +import java.awt.font.FontRenderContext; +import java.awt.font.TextLayout; + +import static java.awt.Font.*; + +public class CombiningPerf { + private static Font font; + private static FontRenderContext frc; + + public static void main(String[] args) throws Exception { + System.err.println("start"); + + GraphicsEnvironment.getLocalGraphicsEnvironment(); + + font = new Font("Lucida Sans Regular", PLAIN, 12); + frc = new FontRenderContext(null, false, false); + + String ascii = "the characters are critical noodles?"; + String french = "l'aper\u00e7u caract\u00e8re one \u00e9t\u00e9 cr\u00e9\u00e9s"; + String frenchX = "l'aper\u00e7u caracte\u0300re one e\u0301te\u0301 ere\u0301e\u0301s"; + + // warmup + for (int i = 0; i < 100; ++i) { + TextLayout tl = new TextLayout(french, font, frc); + tl = new TextLayout(ascii, font, frc); + tl = new TextLayout(frenchX, font, frc); + } + /**/ + long atime = test(ascii); + System.err.println("atime: " + (atime/1000000.0) + " length: " + ascii.length()); + + long ftime = test(french); + System.err.println("ftime: " + (ftime/1000000.0) + " length: " + french.length()); + + long xtime = test(frenchX); + System.err.println("xtime: " + (xtime/1000000.0) + " length: " + frenchX.length()); + + long limit = xtime * 2 / 3; + if (atime > limit || ftime > limit) { + throw new Exception("took too long"); + } + /**/ + } + + private static long test(String text) { + long start = System.nanoTime(); + for (int i = 0; i < 2000; ++i) { + TextLayout tl = new TextLayout(text, font, frc); + } + return System.nanoTime() - start; + } +} diff --git a/test/java/awt/font/TextLayout/KernCrash.java b/test/java/awt/font/TextLayout/KernCrash.java new file mode 100644 index 0000000000000000000000000000000000000000..50e44d4c30d50a6985acf0e86bdc2be24edd4274 --- /dev/null +++ b/test/java/awt/font/TextLayout/KernCrash.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.*; +import java.awt.*; +import java.awt.font.*; +import java.util.*; + +/** + * Shows (top) with kerning, (middle) without, (bottom) also without. + * + * @bug 7017324 + */ +public class KernCrash extends Frame { + private static Font font0; + private static Font font1; + private static Font font2; + + public static void main(String[] args) throws Exception { + HashMap attrs = new HashMap(); + font0 = Font.createFont(Font.TRUETYPE_FONT, new File("Vera.ttf")); + System.out.println("using " + font0); + attrs.put(TextAttribute.SIZE, new Float(58f)); + font1 = font0.deriveFont(attrs); + attrs.put(TextAttribute.KERNING, TextAttribute.KERNING_ON); + font2 = font0.deriveFont(attrs); + + KernCrash f = new KernCrash(); + f.setTitle("Kerning Crash"); + f.setSize(600, 300); + f.setForeground(Color.black); + f.show(); + } + + public void paint(Graphics g) { + Graphics2D g2 = (Graphics2D)g; + FontRenderContext frc = g2.getFontRenderContext(); + TextLayout layout = new TextLayout("text", font2, frc); + layout.draw(g2, 10, 150); + + String s = "WAVATastic"; + TextLayout layout2 = new TextLayout(s, font1, frc); + layout2.draw(g2, 10, 200); + TextLayout layout3 = new TextLayout(s, font2, frc); + layout3.draw(g2, 10, 100); + } +} diff --git a/test/java/lang/invoke/6987555/Test6987555.java b/test/java/lang/invoke/6987555/Test6987555.java new file mode 100644 index 0000000000000000000000000000000000000000..465da236d7c0a6ca58539dc8fec208ca75002075 --- /dev/null +++ b/test/java/lang/invoke/6987555/Test6987555.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 6987555 + * @summary JSR 292 unboxing to a boolean value fails on big-endian SPARC + * + * @run main/othervm -Xint -ea -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic -XX:+UnlockDiagnosticVMOptions -XX:+VerifyMethodHandles Test6987555 + */ + +import java.lang.invoke.*; + +public class Test6987555 { + private static final Class CLASS = Test6987555.class; + private static final String NAME = "foo"; + private static final boolean DEBUG = false; + + public static void main(String[] args) throws Throwable { + testboolean(); + testbyte(); + testchar(); + testshort(); + testint(); + } + + // boolean + static void testboolean() throws Throwable { + doboolean(false); + doboolean(true); + } + static void doboolean(boolean x) throws Throwable { + if (DEBUG) System.out.println("boolean=" + x); + MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(boolean.class, boolean.class)); + MethodHandle mh2 = mh1.asType(MethodType.methodType(boolean.class, Boolean.class)); + boolean a = (boolean) mh1.invokeExact(x); + boolean b = (boolean) mh2.invokeExact(Boolean.valueOf(x)); + assert a == b : a + " != " + b; + } + + // byte + static void testbyte() throws Throwable { + byte[] a = new byte[] { + Byte.MIN_VALUE, + Byte.MIN_VALUE + 1, + -0x0F, + -1, + 0, + 1, + 0x0F, + Byte.MAX_VALUE - 1, + Byte.MAX_VALUE + }; + for (int i = 0; i < a.length; i++) { + dobyte(a[i]); + } + } + static void dobyte(byte x) throws Throwable { + if (DEBUG) System.out.println("byte=" + x); + MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(byte.class, byte.class)); + MethodHandle mh2 = mh1.asType(MethodType.methodType(byte.class, Byte.class)); + byte a = (byte) mh1.invokeExact(x); + byte b = (byte) mh2.invokeExact(Byte.valueOf(x)); + assert a == b : a + " != " + b; + } + + // char + static void testchar() throws Throwable { + char[] a = new char[] { + Character.MIN_VALUE, + Character.MIN_VALUE + 1, + 0x000F, + 0x00FF, + 0x0FFF, + Character.MAX_VALUE - 1, + Character.MAX_VALUE + }; + for (int i = 0; i < a.length; i++) { + dochar(a[i]); + } + } + static void dochar(char x) throws Throwable { + if (DEBUG) System.out.println("char=" + x); + MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(char.class, char.class)); + MethodHandle mh2 = mh1.asType(MethodType.methodType(char.class, Character.class)); + char a = (char) mh1.invokeExact(x); + char b = (char) mh2.invokeExact(Character.valueOf(x)); + assert a == b : a + " != " + b; + } + + // short + static void testshort() throws Throwable { + short[] a = new short[] { + Short.MIN_VALUE, + Short.MIN_VALUE + 1, + -0x0FFF, + -0x00FF, + -0x000F, + -1, + 0, + 1, + 0x000F, + 0x00FF, + 0x0FFF, + Short.MAX_VALUE - 1, + Short.MAX_VALUE + }; + for (int i = 0; i < a.length; i++) { + doshort(a[i]); + } + } + static void doshort(short x) throws Throwable { + if (DEBUG) System.out.println("short=" + x); + MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(short.class, short.class)); + MethodHandle mh2 = mh1.asType(MethodType.methodType(short.class, Short.class)); + short a = (short) mh1.invokeExact(x); + short b = (short) mh2.invokeExact(Short.valueOf(x)); + assert a == b : a + " != " + b; + } + + // int + static void testint() throws Throwable { + int[] a = new int[] { + Integer.MIN_VALUE, + Integer.MIN_VALUE + 1, + -0x00000FFF, + -0x000000FF, + -0x0000000F, + -1, + 0, + 1, + 0x0000000F, + 0x000000FF, + 0x00000FFF, + Integer.MAX_VALUE - 1, + Integer.MAX_VALUE + }; + for (int i = 0; i < a.length; i++) { + doint(a[i]); + } + } + static void doint(int x) throws Throwable { + if (DEBUG) System.out.println("int=" + x); + MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(int.class, int.class)); + MethodHandle mh2 = mh1.asType(MethodType.methodType(int.class, Integer.class)); + int a = (int) mh1.invokeExact(x); + int b = (int) mh2.invokeExact(Integer.valueOf(x)); + assert a == b : a + " != " + b; + } + + public static boolean foo(boolean i) { return i; } + public static byte foo(byte i) { return i; } + public static char foo(char i) { return i; } + public static short foo(short i) { return i; } + public static int foo(int i) { return i; } +} diff --git a/test/java/lang/invoke/6991596/Test6991596.java b/test/java/lang/invoke/6991596/Test6991596.java new file mode 100644 index 0000000000000000000000000000000000000000..e02bcfc819ea036e74263317db97d51549ad96f6 --- /dev/null +++ b/test/java/lang/invoke/6991596/Test6991596.java @@ -0,0 +1,465 @@ +/* + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 6991596 + * @summary JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC + * + * @run main/othervm -ea -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic -XX:+UnlockDiagnosticVMOptions -XX:+VerifyMethodHandles Test6991596 + */ + +import java.lang.invoke.*; + +public class Test6991596 { + private static final Class CLASS = Test6991596.class; + private static final String NAME = "foo"; + private static final boolean DEBUG = System.getProperty("DEBUG", "false").equals("true"); + + public static void main(String[] args) throws Throwable { + testboolean(); + testbyte(); + testchar(); + testshort(); + testint(); + testlong(); + } + + // Helpers to get various methods. + static MethodHandle getmh1(Class ret, Class arg) throws ReflectiveOperationException { + return MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(ret, arg)); + } + static MethodHandle getmh2(MethodHandle mh1, Class ret, Class arg) { + return MethodHandles.convertArguments(mh1, MethodType.methodType(ret, arg)); + } + static MethodHandle getmh3(MethodHandle mh1, Class ret, Class arg) { + return MethodHandles.convertArguments(mh1, MethodType.methodType(ret, arg)); + } + + // test adapter_opt_i2i + static void testboolean() throws Throwable { + boolean[] a = new boolean[] { + true, + false + }; + for (int i = 0; i < a.length; i++) { + doboolean(a[i]); + } + } + static void doboolean(boolean x) throws Throwable { + if (DEBUG) System.out.println("boolean=" + x); + + // boolean + { + MethodHandle mh1 = getmh1( boolean.class, boolean.class); + MethodHandle mh2 = getmh2(mh1, boolean.class, boolean.class); + // TODO add this for all cases when the bugs are fixed. + //MethodHandle mh3 = getmh3(mh1, boolean.class, boolean.class); + boolean a = (boolean) mh1.invokeExact((boolean) x); + boolean b = (boolean) mh2.invokeExact(x); + //boolean c = mh3.invokeExact((boolean) x); + check(x, a, b); + //check(x, c, x); + } + + // byte + { + MethodHandle mh1 = getmh1( byte.class, byte.class ); + MethodHandle mh2 = getmh2(mh1, byte.class, boolean.class); + byte a = (byte) mh1.invokeExact((byte) (x ? 1 : 0)); + byte b = (byte) mh2.invokeExact(x); + check(x, a, b); + } + + // char + { + MethodHandle mh1 = getmh1( char.class, char.class); + MethodHandle mh2 = getmh2(mh1, char.class, boolean.class); + char a = (char) mh1.invokeExact((char) (x ? 1 : 0)); + char b = (char) mh2.invokeExact(x); + check(x, a, b); + } + + // short + { + MethodHandle mh1 = getmh1( short.class, short.class); + MethodHandle mh2 = getmh2(mh1, short.class, boolean.class); + short a = (short) mh1.invokeExact((short) (x ? 1 : 0)); + short b = (short) mh2.invokeExact(x); + check(x, a, b); + } + } + + static void testbyte() throws Throwable { + byte[] a = new byte[] { + Byte.MIN_VALUE, + Byte.MIN_VALUE + 1, + -0x0F, + -1, + 0, + 1, + 0x0F, + Byte.MAX_VALUE - 1, + Byte.MAX_VALUE + }; + for (int i = 0; i < a.length; i++) { + dobyte(a[i]); + } + } + static void dobyte(byte x) throws Throwable { + if (DEBUG) System.out.println("byte=" + x); + + // boolean + { + MethodHandle mh1 = getmh1( boolean.class, boolean.class); + MethodHandle mh2 = getmh2(mh1, boolean.class, byte.class); + boolean a = (boolean) mh1.invokeExact((x & 1) == 1); + boolean b = (boolean) mh2.invokeExact(x); + check(x, a, b); + } + + // byte + { + MethodHandle mh1 = getmh1( byte.class, byte.class); + MethodHandle mh2 = getmh2(mh1, byte.class, byte.class); + byte a = (byte) mh1.invokeExact((byte) x); + byte b = (byte) mh2.invokeExact(x); + check(x, a, b); + } + + // char + { + MethodHandle mh1 = getmh1( char.class, char.class); + MethodHandle mh2 = getmh2(mh1, char.class, byte.class); + char a = (char) mh1.invokeExact((char) x); + char b = (char) mh2.invokeExact(x); + check(x, a, b); + } + + // short + { + MethodHandle mh1 = getmh1( short.class, short.class); + MethodHandle mh2 = getmh2(mh1, short.class, byte.class); + short a = (short) mh1.invokeExact((short) x); + short b = (short) mh2.invokeExact(x); + check(x, a, b); + } + } + + static void testchar() throws Throwable { + char[] a = new char[] { + Character.MIN_VALUE, + Character.MIN_VALUE + 1, + 0x000F, + 0x00FF, + 0x0FFF, + Character.MAX_VALUE - 1, + Character.MAX_VALUE + }; + for (int i = 0; i < a.length; i++) { + dochar(a[i]); + } + } + static void dochar(char x) throws Throwable { + if (DEBUG) System.out.println("char=" + x); + + // boolean + { + MethodHandle mh1 = getmh1( boolean.class, boolean.class); + MethodHandle mh2 = getmh2(mh1, boolean.class, char.class); + boolean a = (boolean) mh1.invokeExact((x & 1) == 1); + boolean b = (boolean) mh2.invokeExact(x); + check(x, a, b); + } + + // byte + { + MethodHandle mh1 = getmh1( byte.class, byte.class); + MethodHandle mh2 = getmh2(mh1, byte.class, char.class); + byte a = (byte) mh1.invokeExact((byte) x); + byte b = (byte) mh2.invokeExact(x); + check(x, a, b); + } + + // char + { + MethodHandle mh1 = getmh1( char.class, char.class); + MethodHandle mh2 = getmh2(mh1, char.class, char.class); + char a = (char) mh1.invokeExact((char) x); + char b = (char) mh2.invokeExact(x); + check(x, a, b); + } + + // short + { + MethodHandle mh1 = getmh1( short.class, short.class); + MethodHandle mh2 = getmh2(mh1, short.class, char.class); + short a = (short) mh1.invokeExact((short) x); + short b = (short) mh2.invokeExact(x); + check(x, a, b); + } + } + + static void testshort() throws Throwable { + short[] a = new short[] { + Short.MIN_VALUE, + Short.MIN_VALUE + 1, + -0x0FFF, + -0x00FF, + -0x000F, + -1, + 0, + 1, + 0x000F, + 0x00FF, + 0x0FFF, + Short.MAX_VALUE - 1, + Short.MAX_VALUE + }; + for (int i = 0; i < a.length; i++) { + doshort(a[i]); + } + } + static void doshort(short x) throws Throwable { + if (DEBUG) System.out.println("short=" + x); + + // boolean + { + MethodHandle mh1 = getmh1( boolean.class, boolean.class); + MethodHandle mh2 = getmh2(mh1, boolean.class, short.class); + boolean a = (boolean) mh1.invokeExact((x & 1) == 1); + boolean b = (boolean) mh2.invokeExact(x); + check(x, a, b); + } + + // byte + { + MethodHandle mh1 = getmh1( byte.class, byte.class); + MethodHandle mh2 = getmh2(mh1, byte.class, short.class); + byte a = (byte) mh1.invokeExact((byte) x); + byte b = (byte) mh2.invokeExact(x); + check(x, a, b); + } + + // char + { + MethodHandle mh1 = getmh1( char.class, char.class); + MethodHandle mh2 = getmh2(mh1, char.class, short.class); + char a = (char) mh1.invokeExact((char) x); + char b = (char) mh2.invokeExact(x); + check(x, a, b); + } + + // short + { + MethodHandle mh1 = getmh1( short.class, short.class); + MethodHandle mh2 = getmh2(mh1, short.class, short.class); + short a = (short) mh1.invokeExact((short) x); + short b = (short) mh2.invokeExact(x); + check(x, a, b); + } + } + + static void testint() throws Throwable { + int[] a = new int[] { + Integer.MIN_VALUE, + Integer.MIN_VALUE + 1, + -0x0FFFFFFF, + -0x00FFFFFF, + -0x000FFFFF, + -0x0000FFFF, + -0x00000FFF, + -0x000000FF, + -0x0000000F, + -1, + 0, + 1, + 0x0000000F, + 0x000000FF, + 0x00000FFF, + 0x0000FFFF, + 0x000FFFFF, + 0x00FFFFFF, + 0x0FFFFFFF, + Integer.MAX_VALUE - 1, + Integer.MAX_VALUE + }; + for (int i = 0; i < a.length; i++) { + doint(a[i]); + } + } + static void doint(int x) throws Throwable { + if (DEBUG) System.out.println("int=" + x); + + // boolean + { + MethodHandle mh1 = getmh1( boolean.class, boolean.class); + MethodHandle mh2 = getmh2(mh1, boolean.class, int.class); + boolean a = (boolean) mh1.invokeExact((x & 1) == 1); + boolean b = (boolean) mh2.invokeExact(x); + check(x, a, b); + } + + // byte + { + MethodHandle mh1 = getmh1( byte.class, byte.class); + MethodHandle mh2 = getmh2(mh1, byte.class, int.class); + byte a = (byte) mh1.invokeExact((byte) x); + byte b = (byte) mh2.invokeExact(x); + check(x, a, b); + } + + // char + { + MethodHandle mh1 = getmh1( char.class, char.class); + MethodHandle mh2 = getmh2(mh1, char.class, int.class); + char a = (char) mh1.invokeExact((char) x); + char b = (char) mh2.invokeExact(x); + check(x, a, b); + } + + // short + { + MethodHandle mh1 = getmh1( short.class, short.class); + MethodHandle mh2 = getmh2(mh1, short.class, int.class); + short a = (short) mh1.invokeExact((short) x); + short b = (short) mh2.invokeExact(x); + assert a == b : a + " != " + b; + check(x, a, b); + } + + // int + { + MethodHandle mh1 = getmh1( int.class, int.class); + MethodHandle mh2 = getmh2(mh1, int.class, int.class); + int a = (int) mh1.invokeExact((int) x); + int b = (int) mh2.invokeExact(x); + check(x, a, b); + } + } + + // test adapter_opt_l2i + static void testlong() throws Throwable { + long[] a = new long[] { + Long.MIN_VALUE, + Long.MIN_VALUE + 1, + -0x000000000FFFFFFFL, + -0x0000000000FFFFFFL, + -0x00000000000FFFFFL, + -0x000000000000FFFFL, + -0x0000000000000FFFL, + -0x00000000000000FFL, + -0x000000000000000FL, + -1L, + 0L, + 1L, + 0x000000000000000FL, + 0x00000000000000FFL, + 0x0000000000000FFFL, + 0x0000000000000FFFL, + 0x000000000000FFFFL, + 0x00000000000FFFFFL, + 0x0000000000FFFFFFL, + 0x000000000FFFFFFFL, + Long.MAX_VALUE - 1, + Long.MAX_VALUE + }; + for (int i = 0; i < a.length; i++) { + dolong(a[i]); + } + } + static void dolong(long x) throws Throwable { + if (DEBUG) System.out.println("long=" + x); + + // boolean + { + MethodHandle mh1 = getmh1( boolean.class, boolean.class); + MethodHandle mh2 = getmh2(mh1, boolean.class, long.class); + boolean a = (boolean) mh1.invokeExact((x & 1L) == 1L); + boolean b = (boolean) mh2.invokeExact(x); + check(x, a, b); + } + + // byte + { + MethodHandle mh1 = getmh1( byte.class, byte.class); + MethodHandle mh2 = getmh2(mh1, byte.class, long.class); + byte a = (byte) mh1.invokeExact((byte) x); + byte b = (byte) mh2.invokeExact(x); + check(x, a, b); + } + + // char + { + MethodHandle mh1 = getmh1( char.class, char.class); + MethodHandle mh2 = getmh2(mh1, char.class, long.class); + char a = (char) mh1.invokeExact((char) x); + char b = (char) mh2.invokeExact(x); + check(x, a, b); + } + + // short + { + MethodHandle mh1 = getmh1( short.class, short.class); + MethodHandle mh2 = getmh2(mh1, short.class, long.class); + short a = (short) mh1.invokeExact((short) x); + short b = (short) mh2.invokeExact(x); + check(x, a, b); + } + + // int + { + MethodHandle mh1 = getmh1( int.class, int.class); + MethodHandle mh2 = getmh2(mh1, int.class, long.class); + int a = (int) mh1.invokeExact((int) x); + int b = (int) mh2.invokeExact(x); + check(x, a, b); + } + } + + static void check(boolean x, boolean e, boolean a) { p(z2h(x), z2h(e), z2h(a)); assert e == a : z2h(x) + ": " + z2h(e) + " != " + z2h(a); } + static void check(boolean x, byte e, byte a) { p(z2h(x), i2h(e), i2h(a)); assert e == a : z2h(x) + ": " + i2h(e) + " != " + i2h(a); } + static void check(boolean x, int e, int a) { p(z2h(x), i2h(e), i2h(a)); assert e == a : z2h(x) + ": " + i2h(e) + " != " + i2h(a); } + + static void check(int x, boolean e, boolean a) { p(i2h(x), z2h(e), z2h(a)); assert e == a : i2h(x) + ": " + z2h(e) + " != " + z2h(a); } + static void check(int x, byte e, byte a) { p(i2h(x), i2h(e), i2h(a)); assert e == a : i2h(x) + ": " + i2h(e) + " != " + i2h(a); } + static void check(int x, int e, int a) { p(i2h(x), i2h(e), i2h(a)); assert e == a : i2h(x) + ": " + i2h(e) + " != " + i2h(a); } + + static void check(long x, boolean e, boolean a) { p(l2h(x), z2h(e), z2h(a)); assert e == a : l2h(x) + ": " + z2h(e) + " != " + z2h(a); } + static void check(long x, byte e, byte a) { p(l2h(x), i2h(e), i2h(a)); assert e == a : l2h(x) + ": " + i2h(e) + " != " + i2h(a); } + static void check(long x, int e, int a) { p(l2h(x), i2h(e), i2h(a)); assert e == a : l2h(x) + ": " + i2h(e) + " != " + i2h(a); } + + static void p(String x, String e, String a) { if (DEBUG) System.out.println(x + ": expected: " + e + ", actual: " + a); } + + static String z2h(boolean x) { return x ? "1" : "0"; } + static String i2h(int x) { return Integer.toHexString(x); } + static String l2h(long x) { return Long.toHexString(x); } + + // to int + public static boolean foo(boolean i) { return i; } + public static byte foo(byte i) { return i; } + public static char foo(char i) { return i; } + public static short foo(short i) { return i; } + public static int foo(int i) { return i; } +} diff --git a/test/java/dyn/ClassValueTest.java b/test/java/lang/invoke/ClassValueTest.java similarity index 94% rename from test/java/dyn/ClassValueTest.java rename to test/java/lang/invoke/ClassValueTest.java index f917e9581da62aed9c40a462771d438674002fcc..59c5a658c7e70fcaf98a884f0368d3722774b634 100644 --- a/test/java/dyn/ClassValueTest.java +++ b/test/java/lang/invoke/ClassValueTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,21 +26,21 @@ /* @test * @summary tests for class-specific values * @compile ClassValueTest.java - * @run junit/othervm test.java.dyn.ClassValueTest + * @run junit/othervm test.java.lang.invoke.ClassValueTest */ /* Manually: - $ $JAVA7X_HOME/bin/javac -d foo -cp $JUNIT4_JAR test/java/dyn/ClassValueTest.java - $ $JAVA7X_HOME/bin/java -cp foo:$JUNIT4_JAR org.junit.runner.JUnitCore test.java.dyn.ClassValueTest + $ $JAVA7X_HOME/bin/javac -d foo -cp $JUNIT4_JAR test/java/lang/invoke/ClassValueTest.java + $ $JAVA7X_HOME/bin/java -cp foo:$JUNIT4_JAR org.junit.runner.JUnitCore test.java.lang.invoke.ClassValueTest Output: .testAdd => 1000 : Integer */ -package test.java.dyn; +package test.java.lang.invoke; import java.util.*; -import java.dyn.*; +import java.lang.invoke.*; import org.junit.*; import static org.junit.Assert.*; diff --git a/test/java/dyn/InvokeDynamicPrintArgs.java b/test/java/lang/invoke/InvokeDynamicPrintArgs.java similarity index 89% rename from test/java/dyn/InvokeDynamicPrintArgs.java rename to test/java/lang/invoke/InvokeDynamicPrintArgs.java index 233c4fc316cf9b30ba0f77af8d5238f5d336a58e..7089e9592235f41e1a8e5d7f4ec8c24fbd381c1f 100644 --- a/test/java/dyn/InvokeDynamicPrintArgs.java +++ b/test/java/lang/invoke/InvokeDynamicPrintArgs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,19 +29,19 @@ * indify.Indify * --verify-specifier-count=3 --transitionalJSR292=false * --expand-properties --classpath ${test.classes} - * --java test.java.dyn.InvokeDynamicPrintArgs --check-output + * --java test.java.lang.invoke.InvokeDynamicPrintArgs --check-output */ -package test.java.dyn; +package test.java.lang.invoke; import org.junit.Test; import java.util.*; import java.io.*; -import java.dyn.*; -import static java.dyn.MethodHandles.*; -import static java.dyn.MethodType.*; +import java.lang.invoke.*; +import static java.lang.invoke.MethodHandles.*; +import static java.lang.invoke.MethodType.*; public class InvokeDynamicPrintArgs { public static void main(String... av) throws Throwable { @@ -65,7 +65,7 @@ public class InvokeDynamicPrintArgs { String[] args = new String[]{ "--verify-specifier-count=3", "--transitionalJSR292=false", "--expand-properties", "--classpath", testClassPath, - "--java", "test.java.dyn.InvokeDynamicPrintArgs", "--check-output" + "--java", "test.java.lang.invoke.InvokeDynamicPrintArgs", "--check-output" }; System.err.println("Indify: "+Arrays.toString(args)); indify.Indify.main(args); @@ -97,11 +97,11 @@ public class InvokeDynamicPrintArgs { } private static final String[] EXPECT_OUTPUT = { "Printing some argument lists, starting with a empty one:", - "[test.java.dyn.InvokeDynamicPrintArgs, nothing, ()void][]", - "[test.java.dyn.InvokeDynamicPrintArgs, bar, (String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar arg, 1]", - "[test.java.dyn.InvokeDynamicPrintArgs, bar2, (String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar2 arg, 222]", - "[test.java.dyn.InvokeDynamicPrintArgs, baz, (String,int,double)void, 1234.5][baz arg, 2, 3.14]", - "[test.java.dyn.InvokeDynamicPrintArgs, foo, (String)void][foo arg]", + "[test.java.lang.invoke.InvokeDynamicPrintArgs, nothing, ()void][]", + "[test.java.lang.invoke.InvokeDynamicPrintArgs, bar, (String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar arg, 1]", + "[test.java.lang.invoke.InvokeDynamicPrintArgs, bar2, (String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar2 arg, 222]", + "[test.java.lang.invoke.InvokeDynamicPrintArgs, baz, (String,int,double)void, 1234.5][baz arg, 2, 3.14]", + "[test.java.lang.invoke.InvokeDynamicPrintArgs, foo, (String)void][foo arg]", "Done printing argument lists." }; diff --git a/test/java/dyn/InvokeGenericTest.java b/test/java/lang/invoke/InvokeGenericTest.java similarity index 97% rename from test/java/dyn/InvokeGenericTest.java rename to test/java/lang/invoke/InvokeGenericTest.java index bae888060a0e8cdab125ac61123f99723e6558e3..f1aaf9eaa71aa00d94e11b1b8ed373ecf14d4fb8 100644 --- a/test/java/dyn/InvokeGenericTest.java +++ b/test/java/lang/invoke/InvokeGenericTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,16 +24,16 @@ */ /* @test - * @summary unit tests for java.dyn.MethodHandle.invokeGeneric + * @summary unit tests for java.lang.invoke.MethodHandle.invokeGeneric * @compile -XDallowTransitionalJSR292=no -target 7 InvokeGenericTest.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.dyn.InvokeGenericTest + * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.lang.invoke.InvokeGenericTest */ -package test.java.dyn; +package test.java.lang.invoke; -import java.dyn.*; -import static java.dyn.MethodHandles.*; -import static java.dyn.MethodType.*; +import java.lang.invoke.*; +import static java.lang.invoke.MethodHandles.*; +import static java.lang.invoke.MethodType.*; import java.lang.reflect.*; import java.util.*; import org.junit.*; @@ -49,7 +49,7 @@ public class InvokeGenericTest { // How much output? static int verbosity = 0; static { - String vstr = System.getProperty("test.java.dyn.InvokeGenericTest.verbosity"); + String vstr = System.getProperty("test.java.lang.invoke.InvokeGenericTest.verbosity"); if (vstr != null) verbosity = Integer.parseInt(vstr); } @@ -216,7 +216,7 @@ public class InvokeGenericTest { if (wrap != null) { return wrap; } -// import sun.dyn.util.Wrapper; +// import sun.invoke.util.Wrapper; // Wrapper wrap = Wrapper.forBasicType(dst); // if (wrap == Wrapper.OBJECT && Wrapper.isWrapperType(dst)) // wrap = Wrapper.forWrapperType(dst); diff --git a/test/java/dyn/JavaDocExamplesTest.java b/test/java/lang/invoke/JavaDocExamplesTest.java similarity index 88% rename from test/java/dyn/JavaDocExamplesTest.java rename to test/java/lang/invoke/JavaDocExamplesTest.java index 72a62851f82ed505a6476ff0e8e01ba9c1876dcb..7093ea2005a1c5cf0403b3bdb153679fcb66466b 100644 --- a/test/java/dyn/JavaDocExamplesTest.java +++ b/test/java/lang/invoke/JavaDocExamplesTest.java @@ -24,27 +24,27 @@ */ /* @test - * @summary example code used in javadoc for java.dyn API + * @summary example code used in javadoc for java.lang.invoke API * @compile -XDallowTransitionalJSR292=no JavaDocExamplesTest.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.dyn.JavaDocExamplesTest + * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.lang.invoke.JavaDocExamplesTest */ /* ---- To run outside jtreg: $ $JAVA7X_HOME/bin/javac -cp $JUNIT4_JAR -d /tmp/Classes \ - $DAVINCI/sources/jdk/test/java/dyn/JavaDocExamplesTest.java + $DAVINCI/sources/jdk/test/java/lang/invoke/JavaDocExamplesTest.java $ $JAVA7X_HOME/bin/java -cp $JUNIT4_JAR:/tmp/Classes \ -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles \ - -Dtest.java.dyn.JavaDocExamplesTest.verbosity=1 \ - test.java.dyn.JavaDocExamplesTest + -Dtest.java.lang.invoke.JavaDocExamplesTest.verbosity=1 \ + test.java.lang.invoke.JavaDocExamplesTest ---- */ -package test.java.dyn; +package test.java.lang.invoke; -import java.dyn.*; -import static java.dyn.MethodHandles.*; -import static java.dyn.MethodType.*; +import java.lang.invoke.*; +import static java.lang.invoke.MethodHandles.*; +import static java.lang.invoke.MethodType.*; import java.lang.reflect.*; import java.util.*; @@ -65,7 +65,7 @@ public class JavaDocExamplesTest { org.junit.runner.JUnitCore.runClasses(JavaDocExamplesTest.class); } // How much output? - static int verbosity = Integer.getInteger("test.java.dyn.JavaDocExamplesTest.verbosity", 0); + static int verbosity = Integer.getInteger("test.java.lang.invoke.JavaDocExamplesTest.verbosity", 0); {} static final private Lookup LOOKUP = lookup(); @@ -108,6 +108,16 @@ assertEquals("xy".hashCode(), (int) HASHCODE_3.invokeExact((Object)"xy")); MethodHandle cat = lookup().findVirtual(String.class, "concat", methodType(String.class, String.class)); assertEquals("xy", (String) cat.invokeExact("x", "y")); +MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class); +MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2)); +assertEquals(bigType, d0.type()); +assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z")); + }} + {{ +{} /// JAVADOC +MethodHandle cat = lookup().findVirtual(String.class, + "concat", methodType(String.class, String.class)); +assertEquals("xy", (String) cat.invokeExact("x", "y")); MethodHandle d0 = dropArguments(cat, 0, String.class); assertEquals("yz", (String) d0.invokeExact("x", "y", "z")); MethodHandle d1 = dropArguments(cat, 1, String.class); diff --git a/test/java/dyn/MethodHandlesTest.java b/test/java/lang/invoke/MethodHandlesTest.java similarity index 99% rename from test/java/dyn/MethodHandlesTest.java rename to test/java/lang/invoke/MethodHandlesTest.java index b44f262fa024cf387138aa911b83b70e92d36b21..bae38f766bc7f5eb6103cdb85372789cbeb7332d 100644 --- a/test/java/dyn/MethodHandlesTest.java +++ b/test/java/lang/invoke/MethodHandlesTest.java @@ -24,15 +24,15 @@ */ /* @test - * @summary unit tests for java.dyn.MethodHandles + * @summary unit tests for java.lang.invoke.MethodHandles * @compile -source 7 -target 7 -XDallowTransitionalJSR292=no MethodHandlesTest.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.dyn.MethodHandlesTest + * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.lang.invoke.MethodHandlesTest */ -package test.java.dyn; +package test.java.lang.invoke; -import java.dyn.*; -import java.dyn.MethodHandles.Lookup; +import java.lang.invoke.*; +import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.*; import java.util.*; import org.junit.*; @@ -48,7 +48,7 @@ public class MethodHandlesTest { // How much output? static int verbosity = 0; static { - String vstr = System.getProperty("test.java.dyn.MethodHandlesTest.verbosity"); + String vstr = System.getProperty("test.java.lang.invoke.MethodHandlesTest.verbosity"); if (vstr != null) verbosity = Integer.parseInt(vstr); } @@ -258,7 +258,7 @@ public class MethodHandlesTest { if (wrap != null) { return wrap; } -// import sun.dyn.util.Wrapper; +// import sun.invoke.util.Wrapper; // Wrapper wrap = Wrapper.forBasicType(dst); // if (wrap == Wrapper.OBJECT && Wrapper.isWrapperType(dst)) // wrap = Wrapper.forWrapperType(dst); @@ -2264,7 +2264,7 @@ public class MethodHandlesTest { } } } -// Local abbreviated copy of sun.dyn.util.ValueConversions +// Local abbreviated copy of sun.invoke.util.ValueConversions class ValueConversions { private static final Lookup IMPL_LOOKUP = MethodHandles.lookup(); private static final Object[] NO_ARGS_ARRAY = {}; diff --git a/test/java/dyn/MethodTypeTest.java b/test/java/lang/invoke/MethodTypeTest.java similarity index 82% rename from test/java/dyn/MethodTypeTest.java rename to test/java/lang/invoke/MethodTypeTest.java index caadaa04a333a807aa3cf4bb988846029d1b341e..5cc32771624b5ef3fa93d2743b64f0bed6ba1eef 100644 --- a/test/java/dyn/MethodTypeTest.java +++ b/test/java/lang/invoke/MethodTypeTest.java @@ -24,15 +24,14 @@ */ /* @test - * @summary unit tests for java.dyn.MethodType + * @summary unit tests for java.lang.invoke.MethodType * @compile MethodTypeTest.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.dyn.MethodTypeTest + * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.lang.invoke.MethodTypeTest */ -package test.java.dyn; +package test.java.lang.invoke; -import sun.dyn.MemberName; -import java.dyn.MethodType; +import java.lang.invoke.MethodType; import java.lang.reflect.Method; import java.util.*; @@ -163,18 +162,6 @@ public class MethodTypeTest { assertSame(expResult, result); } - /** - * Test of make method, of class MethodType. - */ - @Test - public void testMake_Method() { - System.out.println("make (via MemberName.getMethodType)"); - MethodType expResult = MethodType.methodType(int.class, String.class); - MemberName name = new MemberName(compareTo); - MethodType result = name.getMethodType(); - assertSame(expResult, result); - } - /** * Test of make method, of class MethodType. */ @@ -476,10 +463,13 @@ public class MethodTypeTest { @Test public void testPortableSerialFormat() throws Throwable { System.out.println("portable serial format"); + boolean generateData = false; + //generateData = true; // set this true to generate the following input data: Object[][] cases = { { mt_vv, new byte[] { // ()void - (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x13, - (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x64, (byte)0x79, (byte)0x6e, + (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x1b, + (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, + (byte)0x67, (byte)0x2e, (byte)0x69, (byte)0x6e, (byte)0x76, (byte)0x6f, (byte)0x6b, (byte)0x65, (byte)0x2e, (byte)0x4d, (byte)0x65, (byte)0x74, (byte)0x68, (byte)0x6f, (byte)0x64, (byte)0x54, (byte)0x79, (byte)0x70, (byte)0x65, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x24, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, @@ -493,8 +483,9 @@ public class MethodTypeTest { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78, } }, { mt_OO, new byte[] { // (Object)Object - (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x13, - (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x64, (byte)0x79, (byte)0x6e, + (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x1b, + (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, + (byte)0x67, (byte)0x2e, (byte)0x69, (byte)0x6e, (byte)0x76, (byte)0x6f, (byte)0x6b, (byte)0x65, (byte)0x2e, (byte)0x4d, (byte)0x65, (byte)0x74, (byte)0x68, (byte)0x6f, (byte)0x64, (byte)0x54, (byte)0x79, (byte)0x70, (byte)0x65, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x24, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, @@ -509,14 +500,47 @@ public class MethodTypeTest { (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x71, (byte)0x00, (byte)0x7e, (byte)0x00, (byte)0x03, (byte)0x78, } }, + { mt_vOiSzA, new byte[] { // (Object,int,String,boolean,Object[])void + (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x1b, + (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, + (byte)0x67, (byte)0x2e, (byte)0x69, (byte)0x6e, (byte)0x76, (byte)0x6f, (byte)0x6b, (byte)0x65, + (byte)0x2e, (byte)0x4d, (byte)0x65, (byte)0x74, (byte)0x68, (byte)0x6f, (byte)0x64, (byte)0x54, + (byte)0x79, (byte)0x70, (byte)0x65, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x01, (byte)0x24, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, + (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x04, (byte)0x76, (byte)0x6f, (byte)0x69, (byte)0x64, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, (byte)0x75, (byte)0x72, (byte)0x00, + (byte)0x12, (byte)0x5b, (byte)0x4c, (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, + (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2e, (byte)0x43, (byte)0x6c, (byte)0x61, + (byte)0x73, (byte)0x73, (byte)0x3b, (byte)0xab, (byte)0x16, (byte)0xd7, (byte)0xae, (byte)0xcb, + (byte)0xcd, (byte)0x5a, (byte)0x99, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x05, (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x10, + (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, + (byte)0x67, (byte)0x2e, (byte)0x4f, (byte)0x62, (byte)0x6a, (byte)0x65, (byte)0x63, (byte)0x74, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, (byte)0x76, (byte)0x72, (byte)0x00, + (byte)0x03, (byte)0x69, (byte)0x6e, (byte)0x74, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78, + (byte)0x70, (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x10, (byte)0x6a, (byte)0x61, (byte)0x76, + (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2e, (byte)0x53, + (byte)0x74, (byte)0x72, (byte)0x69, (byte)0x6e, (byte)0x67, (byte)0xa0, (byte)0xf0, (byte)0xa4, + (byte)0x38, (byte)0x7a, (byte)0x3b, (byte)0xb3, (byte)0x42, (byte)0x02, (byte)0x00, (byte)0x00, + (byte)0x78, (byte)0x70, (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x07, (byte)0x62, (byte)0x6f, + (byte)0x6f, (byte)0x6c, (byte)0x65, (byte)0x61, (byte)0x6e, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x78, (byte)0x70, (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x13, (byte)0x5b, (byte)0x4c, + (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, + (byte)0x67, (byte)0x2e, (byte)0x4f, (byte)0x62, (byte)0x6a, (byte)0x65, (byte)0x63, (byte)0x74, + (byte)0x3b, (byte)0x90, (byte)0xce, (byte)0x58, (byte)0x9f, (byte)0x10, (byte)0x73, (byte)0x29, + (byte)0x6c, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, (byte)0x78, + } }, }; - boolean generateData = false; - //generateData = true; for (Object[] c : cases) { MethodType mt = (MethodType) c[0]; System.out.println("deserialize "+mt); byte[] wire = (byte[]) c[1]; if (generateData) { + System.out.println(""); wire = writeSerial(mt); final String INDENT = " "; System.out.print("{ // "+mt); @@ -528,6 +552,7 @@ public class MethodTypeTest { } System.out.println(); System.out.println(INDENT+"}"); + System.out.println(""); System.out.flush(); } Object decode; diff --git a/test/java/dyn/indify/Indify.java b/test/java/lang/invoke/indify/Indify.java similarity index 98% rename from test/java/dyn/indify/Indify.java rename to test/java/lang/invoke/indify/Indify.java index ba24b79a9d96fec797291eb2d92001889f302c42..ac0485a5ebc61d4ec4d6e72c53b0eec379ff8400 100644 --- a/test/java/dyn/indify/Indify.java +++ b/test/java/lang/invoke/indify/Indify.java @@ -47,9 +47,9 @@ import java.util.regex.*; * and {@code CONSTANT_MethodType} "ldc" instructions. * The stereotyped code must create method types by calls to {@code methodType} or * {@code fromMethodDescriptorString}. The "lookup" argument must be created - * by calls to {@code java.dyn.MethodHandles#lookup MethodHandles.lookup}. + * by calls to {@code java.lang.invoke.MethodHandles#lookup MethodHandles.lookup}. * The class and string arguments must be constant. - * The following methods of {@code java.dyn.MethodHandle.Lookup Lookup} are + * The following methods of {@code java.lang.invoke.MethodHandle.Lookup Lookup} are * allowed for method handle creation: {@code findStatic}, {@code findVirtual}, * {@code findConstructor}, {@code findSpecial}, * {@code findGetter}, {@code findSetter}, @@ -350,10 +350,15 @@ public class Indify { } protected Class findClass(String name) throws ClassNotFoundException { try { - return transformAndLoadClass(findClassInPath(name)); + File f = findClassInPath(name); + if (f != null) { + Class c = transformAndLoadClass(f); + if (c != null) return c; + } } catch (IOException ex) { throw new ClassNotFoundException("IO error", ex); } + throw new ClassNotFoundException(); } private Class transformAndLoadClass(File f) throws ClassNotFoundException, IOException { if (verbose) System.err.println("Loading class from "+f); @@ -592,7 +597,9 @@ public class Indify { if (s.startsWith("MT_")) return 'T'; else if (s.startsWith("MH_")) return 'H'; else if (s.startsWith("INDY_")) return 'I'; - else if (s.startsWith("java/dyn/")) return 'D'; + else if (transitionalJSR292 && + s.startsWith("java/dyn/")) return 'D'; + else if (s.startsWith("java/lang/invoke/")) return 'D'; else if (s.startsWith("java/lang/")) return 'J'; return 0; } @@ -605,15 +612,24 @@ public class Indify { String descr = cf.pool.getString(CONSTANT_Utf8, n2); String requiredType; switch (poolMarks[(char)n1]) { - case 'H': requiredType = "()Ljava/dyn/MethodHandle;"; break; - case 'T': requiredType = "()Ljava/dyn/MethodType;"; break; - case 'I': requiredType = "()Ljava/dyn/MethodHandle;"; break; + case 'H': requiredType = "()Ljava/lang/invoke/MethodHandle;"; break; + case 'T': requiredType = "()Ljava/lang/invoke/MethodType;"; break; + case 'I': requiredType = "()Ljava/lang/invoke/MethodHandle;"; break; default: return 0; } - if (descr.equals(requiredType)) return mark; + if (matchType(descr, requiredType)) return mark; return 0; } + boolean matchType(String descr, String requiredType) { + if (descr.equals(requiredType)) return true; + if (transitionalJSR292) { + String oldType = requiredType.replace("Ljava/lang/invoke/", "Ljava/dyn/"); + if (descr.equals(oldType)) return true; + } + return false; + } + private class JVMState { final List stack = new ArrayList<>(); int sp() { return stack.size(); } diff --git a/test/javax/swing/JOptionPane/6464022/bug6464022.java b/test/javax/swing/JOptionPane/6464022/bug6464022.java new file mode 100644 index 0000000000000000000000000000000000000000..9554ae9828e3c68973b2fba02b2745cfa12d800a --- /dev/null +++ b/test/javax/swing/JOptionPane/6464022/bug6464022.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6464022 + * @summary Memory leak in JOptionPane.createDialog + * @author Pavel Porvatov + * @library ../../regtesthelpers + * @build Util + * @run main bug6464022 + */ + +import javax.swing.*; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; + +public class bug6464022 { + private static JOptionPane pane; + + public static void main(String[] args) throws Exception { + final List> references = new ArrayList>(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + pane = new JOptionPane(null, JOptionPane.UNDEFINED_CONDITION); + + for (int i = 0; i < 10; i++) { + JDialog dialog = pane.createDialog(null, "Test " + i); + + references.add(new WeakReference(dialog)); + + dialog.dispose(); + + System.out.println("Disposing Dialog:" + dialog.hashCode()); + } + } + }); + + Util.generateOOME(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + int allocatedCount = 0; + + for (WeakReference ref : references) { + if (ref.get() != null) { + allocatedCount++; + + System.out.println(ref.get().hashCode() + " is still allocated"); + } + } + + if (allocatedCount > 0) { + throw new RuntimeException("Some dialogs still exist in memory. Test failed"); + } else { + System.out.println("All dialogs were GCed. Test passed."); + } + } + }); + } +} diff --git a/test/javax/swing/UIDefaults/6795356/bug6795356.java b/test/javax/swing/UIDefaults/6795356/bug6795356.java index 781f57d38723fca91dc8a03d7b37c598c8a5b830..698dc00e22fb59b14d74154e4ae8566bf12ba02a 100644 --- a/test/javax/swing/UIDefaults/6795356/bug6795356.java +++ b/test/javax/swing/UIDefaults/6795356/bug6795356.java @@ -26,6 +26,8 @@ * @bug 6795356 * @summary Leak caused by javax.swing.UIDefaults.ProxyLazyValue.acc * @author Alexander Potochkin + * @library ../../regtesthelpers + * @build Util * @run main bug6795356 */ @@ -58,43 +60,11 @@ public class bug6795356 { weakRef = new WeakReference(domain); domain = null; - // Generate OutOfMemory and check the weak ref - generateOOME(); + Util.generateOOME(); if (weakRef.get() != null) { throw new RuntimeException("Memory leak found!"); } System.out.println("Test passed"); } - - static void generateOOME() { - List bigLeak = new LinkedList(); - boolean oome = false; - System.out.print("Filling the heap"); - try { - for(int i = 0; true ; i++) { - // Now, use up all RAM - bigLeak.add(new byte[1024 * 1024]); - System.out.print("."); - - // Give the GC a change at that weakref - if (i % 10 == 0) { - System.gc(); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } catch (OutOfMemoryError e) { - bigLeak = null; - oome = true; - } - System.out.println(""); - if (!oome) { - throw new RuntimeException("Problem with test case - never got OOME"); - } - System.out.println("Got OOME"); - } } diff --git a/test/javax/swing/regtesthelpers/Util.java b/test/javax/swing/regtesthelpers/Util.java index 5da14b9396a6d26faf997ea25e7dd0b557e268bb..76217ae86870a64cfddd61e974c61d6a899263c2 100644 --- a/test/javax/swing/regtesthelpers/Util.java +++ b/test/javax/swing/regtesthelpers/Util.java @@ -24,6 +24,8 @@ import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; +import java.util.LinkedList; +import java.util.List; /** *

    This class contains utilities useful for regression testing. @@ -72,4 +74,46 @@ public class Util { return true; } + + /** + * Fills the heap until OutOfMemoryError occurs. This method is useful for + * WeakReferences removing. + */ + public static void generateOOME() { + List bigLeak = new LinkedList(); + + boolean oome = false; + + System.out.print("Filling the heap"); + + try { + for(int i = 0; true ; i++) { + // Now, use up all RAM + bigLeak.add(new byte[1024 * 1024]); + + System.out.print("."); + + // Give the GC a change at that weakref + if (i % 10 == 0) { + System.gc(); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } catch (OutOfMemoryError e) { + bigLeak = null; + oome = true; + } + + System.out.println(""); + + if (!oome) { + throw new RuntimeException("Problem with test case - never got OOME"); + } + + System.out.println("Got OOME"); + } } diff --git a/test/sun/java2d/pipe/Test7027667.java b/test/sun/java2d/pipe/Test7027667.java new file mode 100644 index 0000000000000000000000000000000000000000..08f478f60b132937fca5175bd87b99925606216b --- /dev/null +++ b/test/sun/java2d/pipe/Test7027667.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 7027667, 7023591 + * + * @summary Verifies that aa clipped rectangles are drawn, not filled. + * + * @run main Test7027667 + */ + +import java.awt.*; +import java.awt.geom.*; +import java.awt.image.*; +import static java.awt.RenderingHints.*; + +public class Test7027667 { + public static void main(String[] args) throws Exception { + BufferedImage bImg = new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = (Graphics2D) bImg.getGraphics(); + g2d.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); + g2d.setClip(new Ellipse2D.Double(0, 0, 100, 100)); + g2d.drawRect(10, 10, 100, 100); + if (new Color(bImg.getRGB(50, 50)).equals(Color.white)) { + throw new Exception("Rectangle should be drawn, not filled"); + } + } +} diff --git a/test/sun/java2d/pisces/Renderer/Test7019861.java b/test/sun/java2d/pisces/Renderer/Test7019861.java new file mode 100644 index 0000000000000000000000000000000000000000..7c262b961cf18b570425529ba9533c940075f853 --- /dev/null +++ b/test/sun/java2d/pisces/Renderer/Test7019861.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 7019861 + * + * @summary Verifies that the last scanline isn't skipped when doing + * antialiased rendering. + * + * @run main Test7019861 + */ + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.geom.Path2D; +import java.awt.image.BufferedImage; +import java.util.Arrays; + +import static java.awt.RenderingHints.*; + +public class Test7019861 { + + public static void main(String[] argv) throws Exception { + BufferedImage im = getWhiteImage(30, 30); + Graphics2D g2 = (Graphics2D)im.getGraphics(); + g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); + g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE); + g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); + g2.setBackground(Color.white); + g2.setColor(Color.black); + + Path2D p = getPath(0, 0, 20); + g2.draw(p); + + if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) { + throw new Exception("This pixel should be black"); + } + } + + private static Path2D getPath(int x, int y, int len) { + Path2D p = new Path2D.Double(); + p.moveTo(x, y); + p.quadTo(x + len, y, x + len, y + len); + return p; + } + + private static BufferedImage getWhiteImage(int w, int h) { + BufferedImage ret = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + final int[] white = new int[w * h]; + Arrays.fill(white, 0xffffff); + ret.setRGB(0, 0, w, h, white, 0, w); + return ret; + } +} diff --git a/test/sun/text/resources/LocaleData b/test/sun/text/resources/LocaleData index 090b73c8d12c7388725c0d468d99da7e00ce6782..36f17917d12efafa8eb91ac176b471097b98834e 100644 --- a/test/sun/text/resources/LocaleData +++ b/test/sun/text/resources/LocaleData @@ -6101,3 +6101,258 @@ LocaleNames/nl/ZM=Zambia # bug 6919624 CalendarData/hu/minimalDaysInFirstWeek=4 + +# bug 6998391 +CalendarData/sr-Latn/firstDayOfWeek=2 +CalendarData/sr-Latn-BA/firstDayOfWeek=2 +CalendarData/sr-Latn-ME/firstDayOfWeek=2 +CalendarData/sr-Latn-RS/firstDayOfWeek=2 +# +CalendarData/sr-Latn/minimalDaysInFirstWeek=1 +CalendarData/sr-Latn-BA/minimalDaysInFirstWeek=4 +CalendarData/sr-Latn-ME/minimalDaysInFirstWeek=4 +CalendarData/sr-Latn-RS/minimalDaysInFirstWeek=4 +# +LocaleNames/sr-Latn/SR=Surinam +LocaleNames/sr-Latn-BA/SR=Surinam +LocaleNames/sr-Latn-ME/SR=Surinam +LocaleNames/sr-Latn-RS/SR=Surinam +# +FormatData/sr-Latn/MonthNames/2=mart +FormatData/sr-Latn-BA/MonthNames/4=maj +FormatData/sr-Latn-ME/MonthNames/7=avgust +FormatData/sr-Latn-RS/MonthNames/8=septembar +# +FormatData/sr-Latn/DayNames/1=ponedeljak +FormatData/sr-Latn-BA/DayNames/2=utorak +FormatData/sr-Latn-ME/DayNames/3=sreda +FormatData/sr-Latn-RS/DayNames/4=\u010detvrtak +# +FormatData/sr-Latn/DayAbbreviations/1=pon +FormatData/sr-Latn-BA/DayAbbreviations/2=uto +FormatData/sr-Latn-ME/DayAbbreviations/3=sre +FormatData/sr-Latn-RS/DayAbbreviations/4=\u010det +# +CurrencyNames/sr-Latn/EUR=EUR +CurrencyNames/sr-Latn-BA/EUR=\u20ac +CurrencyNames/sr-Latn-BA/BAM=KM +CurrencyNames/sr-Latn-ME/EUR=\u20ac +CurrencyNames/sr-Latn-RS/EUR=EUR +# +FormatData/sr-Latn/DateTimePatterns/1=HH.mm.ss z +FormatData/sr-Latn-BA/DateTimePatterns/2=HH.mm.ss +FormatData/sr-Latn-ME/DateTimePatterns/5=d.MM.yyyy. +FormatData/sr-Latn-RS/DateTimePatterns/5=dd. MMMM y. + +# bug 7019267 +CurrencyNames/pt/adp=Peseta de Andorra +CurrencyNames/pt/aed=Dir\u00e9m dos Emirados \u00c1rabes Unidos +CurrencyNames/pt/afa=Afegane (1927-2002) +CurrencyNames/pt/afn=Afegane +CurrencyNames/pt/all=Lek Alban\u00eas +CurrencyNames/pt/amd=Dram arm\u00eanio +CurrencyNames/pt/ang=Guilder das Antilhas Holandesas +CurrencyNames/pt/aoa=Cuanza angolano +CurrencyNames/pt/ars=Peso argentino +CurrencyNames/pt/ats=Xelim austr\u00edaco +CurrencyNames/pt/aud=D\u00f3lar australiano +CurrencyNames/pt/awg=Guilder de Aruba +CurrencyNames/pt/azm=Manat azerbaijano +CurrencyNames/pt/azn=Manat do Azerbaij\u00e3o +CurrencyNames/pt/bam=Marco b\u00f3snio-herzegovino convers\u00edvel +CurrencyNames/pt/bbd=D\u00f3lar de Barbados +CurrencyNames/pt/bdt=Taka de Bangladesh +CurrencyNames/pt/bef=Franco belga +CurrencyNames/pt/bgl=Lev forte b\u00falgaro +CurrencyNames/pt/bgn=Lev novo b\u00falgaro +CurrencyNames/pt/bhd=Dinar bareinita +CurrencyNames/pt/bif=Franco do Burundi +CurrencyNames/pt/bmd=D\u00f3lar das Bermudas +CurrencyNames/pt/bnd=D\u00f3lar do Brunei +CurrencyNames/pt/bov=Mvdol boliviano +CurrencyNames/pt/brl=Real brasileiro +CurrencyNames/pt/bsd=D\u00f3lar das Bahamas +CurrencyNames/pt/btn=Ngultrum do But\u00e3o +CurrencyNames/pt/bwp=Pula botsuanesa +CurrencyNames/pt/byb=Rublo novo bielo-russo (1994-1999) +CurrencyNames/pt/byr=Rublo bielo-russo +CurrencyNames/pt/bzd=D\u00f3lar do Belize +CurrencyNames/pt/cad=D\u00f3lar canadense +CurrencyNames/pt/cdf=Franco congol\u00eas +CurrencyNames/pt/chf=Franco su\u00ed\u00e7o +CurrencyNames/pt/clf=Unidades de Fomento chilenas +CurrencyNames/pt/clp=Peso chileno +CurrencyNames/pt/cny=Yuan Renminbi chin\u00eas +CurrencyNames/pt/cop=Peso colombiano +CurrencyNames/pt/crc=Colon da Costa Rica +CurrencyNames/pt/csd=Dinar s\u00e9rvio antigo +CurrencyNames/pt/cup=Peso cubano +CurrencyNames/pt/cve=Escudo cabo-verdiano +CurrencyNames/pt/cyp=Libra cipriota +CurrencyNames/pt/czk=Coroa checa +CurrencyNames/pt/dem=Marco alem\u00e3o +CurrencyNames/pt/djf=Franco do Djibuti +CurrencyNames/pt/dkk=Coroa dinamarquesa +CurrencyNames/pt/dop=Peso dominicano +CurrencyNames/pt/dzd=Dinar argelino +CurrencyNames/pt/eek=Coroa estoniana +CurrencyNames/pt/egp=Libra eg\u00edpcia +CurrencyNames/pt/ern=Nakfa da Eritreia +CurrencyNames/pt/esp=Peseta espanhola +CurrencyNames/pt/etb=Birr et\u00edope +CurrencyNames/pt/fim=Marca finlandesa +CurrencyNames/pt/fjd=D\u00f3lar de Fiji +CurrencyNames/pt/fkp=Libra das Malvinas +CurrencyNames/pt/frf=Franco franc\u00eas +CurrencyNames/pt/gbp=Libra esterlina brit\u00e2nica +CurrencyNames/pt/gel=Lari georgiano +CurrencyNames/pt/ghc=Cedi de Gana (1979-2007) +CurrencyNames/pt/ghs=Cedi gan\u00eas +CurrencyNames/pt/gip=Libra de Gibraltar +CurrencyNames/pt/gmd=Dalasi de G\u00e2mbia +CurrencyNames/pt/gnf=Franco de Guin\u00e9 +CurrencyNames/pt/grd=Dracma grego +CurrencyNames/pt/gtq=Quet\u00e7al da Guatemala +CurrencyNames/pt/gwp=Peso da Guin\u00e9-Bissau +CurrencyNames/pt/gyd=D\u00f3lar da Guiana +CurrencyNames/pt/hkd=D\u00f3lar de Hong Kong +CurrencyNames/pt/hnl=Lempira de Honduras +CurrencyNames/pt/hrk=Kuna croata +CurrencyNames/pt/htg=Gurde do Haiti +CurrencyNames/pt/huf=Forinte h\u00fangaro +CurrencyNames/pt/idr=Rupia indon\u00e9sia +CurrencyNames/pt/iep=Libra irlandesa +CurrencyNames/pt/ils=Sheqel Novo israelita +CurrencyNames/pt/inr=R\u00fapia indiana +CurrencyNames/pt/iqd=Dinar iraquiano +CurrencyNames/pt/irr=Rial iraniano +CurrencyNames/pt/isk=Coroa islandesa +CurrencyNames/pt/itl=Lira italiana +CurrencyNames/pt/jmd=D\u00f3lar jamaicano +CurrencyNames/pt/jod=Dinar jordaniano +CurrencyNames/pt/jpy=Iene japon\u00eas +CurrencyNames/pt/kes=Xelim queniano +CurrencyNames/pt/kgs=Som quirguiz +CurrencyNames/pt/khr=Riel cambojano +CurrencyNames/pt/kmf=Franco de Comores +CurrencyNames/pt/kpw=Won norte-coreano +CurrencyNames/pt/krw=Won sul-coreano +CurrencyNames/pt/kwd=Dinar coveitiano +CurrencyNames/pt/kyd=D\u00f3lar das Ilhas Caiman +CurrencyNames/pt/kzt=Tenge do Cazaquist\u00e3o +CurrencyNames/pt/lak=Kip de Laos +CurrencyNames/pt/lbp=Libra libanesa +CurrencyNames/pt/lkr=Rupia do Sri Lanka +CurrencyNames/pt/lrd=D\u00f3lar liberiano +CurrencyNames/pt/lsl=Loti do Lesoto +CurrencyNames/pt/ltl=Lita lituano +CurrencyNames/pt/luf=Franco luxemburgu\u00eas +CurrencyNames/pt/lvl=Lats let\u00e3o +CurrencyNames/pt/lyd=Dinar l\u00edbio +CurrencyNames/pt/mad=Dir\u00e9m marroquino +CurrencyNames/pt/mdl=Leu mold\u00e1vio +CurrencyNames/pt/mga=Ariary de Madagascar +CurrencyNames/pt/mgf=Franco de Madagascar +CurrencyNames/pt/mkd=Dinar maced\u00f4nio +CurrencyNames/pt/mmk=Kyat de Mianmar +CurrencyNames/pt/mnt=Tugrik mongol +CurrencyNames/pt/mop=Pataca macaense +CurrencyNames/pt/mro=Ouguiya da Maurit\u00e2nia +CurrencyNames/pt/mtl=Lira maltesa +CurrencyNames/pt/mur=Rupia de Maur\u00edcio +CurrencyNames/pt/mvr=Rupias das Ilhas Maldivas +CurrencyNames/pt/mwk=Cuacha do Mal\u00e1ui +CurrencyNames/pt/mxn=Peso mexicano +CurrencyNames/pt/mxv=Unidade Mexicana de Investimento (UDI) +CurrencyNames/pt/myr=Ringgit malaio +CurrencyNames/pt/mzm=Metical antigo de Mo\u00e7ambique +CurrencyNames/pt/mzn=Metical do Mo\u00e7ambique +CurrencyNames/pt/nad=D\u00f3lar da Nam\u00edbia +CurrencyNames/pt/ngn=Naira nigeriana +CurrencyNames/pt/nio=C\u00f3rdoba Ouro nicaraguense +CurrencyNames/pt/nlg=Florim holand\u00eas +CurrencyNames/pt/nok=Coroa norueguesa +CurrencyNames/pt/npr=Rupia nepalesa +CurrencyNames/pt/nzd=D\u00f3lar da Nova Zel\u00e2ndia +CurrencyNames/pt/omr=Rial de Om\u00e3 +CurrencyNames/pt/pab=Balboa panamenho +CurrencyNames/pt/pen=Sol Novo peruano +CurrencyNames/pt/pgk=Kina da Papua-Nova Guin\u00e9 +CurrencyNames/pt/php=Peso filipino +CurrencyNames/pt/pkr=Rupia paquistanesa +CurrencyNames/pt/pln=Zloti polon\u00eas +CurrencyNames/pt/pte=Escudo portugu\u00eas +CurrencyNames/pt/pyg=Guarani paraguaio +CurrencyNames/pt/qar=Rial catariano +CurrencyNames/pt/rol=Leu romeno antigo +CurrencyNames/pt/ron=Leu romeno +CurrencyNames/pt/rsd=Dinar s\u00e9rvio +CurrencyNames/pt/rub=Rublo russo +CurrencyNames/pt/rur=Rublo russo (1991-1998) +CurrencyNames/pt/rwf=Franco ruand\u00eas +CurrencyNames/pt/sar=Rial saudita +CurrencyNames/pt/sbd=D\u00f3lar das Ilhas Salom\u00e3o +CurrencyNames/pt/scr=Rupia das Seychelles +CurrencyNames/pt/sdd=Dinar sudan\u00eas +CurrencyNames/pt/sdg=Libra sudanesa +CurrencyNames/pt/sek=Coroa sueca +CurrencyNames/pt/sgd=D\u00f3lar de Cingapura +CurrencyNames/pt/shp=Libra de Santa Helena +CurrencyNames/pt/sit=Tolar Bons esloveno +CurrencyNames/pt/skk=Coroa eslovaca +CurrencyNames/pt/sll=Leone de Serra Leoa +CurrencyNames/pt/sos=Xelim somali +CurrencyNames/pt/srd=D\u00f3lar do Suriname +CurrencyNames/pt/srg=Florim do Suriname +CurrencyNames/pt/std=Dobra de S\u00e3o Tom\u00e9 e Pr\u00edncipe +CurrencyNames/pt/svc=Colom salvadorenho +CurrencyNames/pt/syp=Libra s\u00edria +CurrencyNames/pt/szl=Lilangeni da Suazil\u00e2ndia +CurrencyNames/pt/thb=Baht tailand\u00eas +CurrencyNames/pt/tjs=Somoni tadjique +CurrencyNames/pt/tmm=Manat do Turcomenist\u00e3o +CurrencyNames/pt/tnd=Dinar tunisiano +CurrencyNames/pt/top=Pa\u02bbanga de Tonga +CurrencyNames/pt/tpe=Escudo timorense +CurrencyNames/pt/trl=Lira turca antiga +CurrencyNames/pt/try=Lira turca +CurrencyNames/pt/ttd=D\u00f3lar de Trinidad e Tobago +CurrencyNames/pt/twd=D\u00f3lar Novo de Taiwan +CurrencyNames/pt/tzs=Xelim da Tanz\u00e2nia +CurrencyNames/pt/uah=Hryvnia ucraniano +CurrencyNames/pt/ugx=Xelim ugandense +CurrencyNames/pt/usd=D\u00f3lar norte-americano +CurrencyNames/pt/usn=D\u00f3lar norte-americano (Dia seguinte) +CurrencyNames/pt/uss=D\u00f3lar norte-americano (Mesmo dia) +CurrencyNames/pt/uyu=Peso uruguaio +CurrencyNames/pt/uzs=Sum do Usbequist\u00e3o +CurrencyNames/pt/veb=Bol\u00edvar venezuelano +CurrencyNames/pt/vef=Bol\u00edvar v enezuelano forte +CurrencyNames/pt/vnd=Dong vietnamita +CurrencyNames/pt/vuv=Vatu de Vanuatu +CurrencyNames/pt/wst=Tala samoano +CurrencyNames/pt/xaf=Franco CFA BEAC +CurrencyNames/pt/xag=Prata +CurrencyNames/pt/xau=Ouro +CurrencyNames/pt/xba=Unidade Composta Europeia +CurrencyNames/pt/xbb=Unidade Monet\u00e1ria Europeia +CurrencyNames/pt/xbc=Unidade de Conta Europeia (XBC) +CurrencyNames/pt/xbd=Unidade de Conta Europeia (XBD) +CurrencyNames/pt/xcd=D\u00f3lar do Caribe Oriental +CurrencyNames/pt/xdr=Direitos Especiais de Giro +CurrencyNames/pt/xfo=Franco-ouro franc\u00eas +CurrencyNames/pt/xfu=Franco UIC franc\u00eas +CurrencyNames/pt/xof=Franco CFA BCEAO +CurrencyNames/pt/xpd=Pal\u00e1dio +CurrencyNames/pt/xpf=Franco CFP +CurrencyNames/pt/xpt=Platina +CurrencyNames/pt/xts=C\u00f3digo de Moeda de Teste +CurrencyNames/pt/xxx=Moeda Desconhecida ou Inv\u00e1lida +CurrencyNames/pt/yer=Rial iemenita +CurrencyNames/pt/yum=Dinar noviy iugoslavo +CurrencyNames/pt/zar=Rand sul-africano +CurrencyNames/pt/zmk=Cuacha zambiano +CurrencyNames/pt/zwd=D\u00f3lar do Zimb\u00e1bue + +# bug 7020960 +CurrencyNames/sr_RS/RSD=\u0434\u0438\u043d. diff --git a/test/sun/text/resources/LocaleDataTest.java b/test/sun/text/resources/LocaleDataTest.java index 2a04cd973db2372a4b96e2d79ddbab6bb59dac01..5cf693cc1aabb7aa30da2af1aff7d11e7310a46f 100644 --- a/test/sun/text/resources/LocaleDataTest.java +++ b/test/sun/text/resources/LocaleDataTest.java @@ -33,7 +33,7 @@ * 6379214 6485516 6486607 4225362 4494727 6533691 6531591 6531593 6570259 * 6509039 6609737 6610748 6645271 6507067 6873931 6450945 6645268 6646611 * 6645405 6650730 6910489 6573250 6870908 6585666 6716626 6914413 6916787 - * 6919624 + * 6919624 6998391 7019267 7020960 * @summary Verify locale data * */ @@ -91,6 +91,10 @@ * LocaleNames/fr_FR/US=\u00c9tats-Unis * LocaleNames/fr_FR/FR=France * + * You can use language tag with '-' in locale field like this:
    + *        LocaleNames/sr-Latn/SR=Surinam
    + *        FormatData/sr-Latn-BA/DayNames/2=utorak
    + * * The command-line syntax of this test is * java LocaleDataTest [-w] [{ -s | }] * @@ -242,7 +246,9 @@ public class LocaleDataTest if (index == -1 || index + 1 == key.length()) throw new Exception("Malformed input file: \"" + key + "\" is missing locale name"); localeName = key.substring(oldIndex, index); - if (localeName.length() > 0) { + boolean use_tag = localeName.indexOf("-") != -1; + + if (use_tag == false && localeName.length() > 0) { language = localeName.substring(0, 2); if (localeName.length() > 3) { country = localeName.substring(3, 5); @@ -283,8 +289,14 @@ public class LocaleDataTest } else { fullName = "sun.text.resources." + rbName; } + Locale locale; + if (use_tag) { + locale = Locale.forLanguageTag(localeName); + } else { + locale = new Locale(language, country, variant); + } ResourceBundle bundle = ResourceBundle.getBundle(fullName, - new Locale(language, country, variant), + locale, ResourceBundle.Control.getNoFallbackControl(Control.FORMAT_DEFAULT)); resource = bundle.getObject(resTag); }