This commit is contained in:
Lana Steuck 2013-04-01 21:40:54 -07:00
commit 6c50b0bfe1
187 changed files with 4947 additions and 10074 deletions
jdk
make
makefiles
src
macosx
share
classes
javavm/export
lib/security
native
solaris

@ -45,7 +45,7 @@ SUBDIRS_management = jmx
SUBDIRS_desktop = image
SUBDIRS_enterprise = crypto/provider jndi \
org rowset net/httpserver
SUBDIRS_misc = $(SCRIPT_SUBDIR) tracing servicetag nio demo
SUBDIRS_misc = $(SCRIPT_SUBDIR) tracing nio demo
SUBDIRS_tools = tools

@ -1,80 +0,0 @@
# 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
BUILDDIR = ../../..
PACKAGE = com.sun.servicetag
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
#
# Files to compile
#
AUTO_FILES_JAVA_DIRS = com/sun/servicetag
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
SERVICETAG_LIBDIR = $(LIBDIR)/servicetag
SERVICETAG_RESOURCES_DIR = $(CLASSDESTDIR)/com/sun/servicetag/resources
FILES_copy = $(SERVICETAG_RESOURCES_DIR)/product_registration.xsd \
$(SERVICETAG_RESOURCES_DIR)/register.html \
$(SERVICETAG_RESOURCES_DIR)/register_ja.html \
$(SERVICETAG_RESOURCES_DIR)/register_zh_CN.html \
$(SERVICETAG_LIBDIR)/jdk_header.png
# Add all properties files to the FILES_copy list
SWORDFISH_properties := $(shell \
$(CD) $(SHARE_SRC)/classes/com/sun/servicetag/resources; \
$(FIND) . -name 'javase_*.properties' -print ; \
)
FILES_copy += $(shell \
for f in $(SWORDFISH_properties) ; do \
echo $(SERVICETAG_RESOURCES_DIR)/$$f ; \
done \
)
#
#OTHER_JAVACFLAGS += -Xlint:unchecked
build: install-servicetag-lib copy-files
copy-files: $(FILES_copy)
$(CLASSBINDIR)/%: $(SHARE_SRC)/classes/%
$(install-file)
$(SERVICETAG_LIBDIR)/jdk_header.png: $(SHARE_SRC)/classes/com/sun/servicetag/resources/jdk_header.png
$(install-file)
$(call chmod-file, 444)
install-servicetag-lib:
@$(RM) -rf $(SERVICETAG_LIBDIR)
$(MKDIR) $(SERVICETAG_LIBDIR)
clean clobber::
@$(RM) $(FILES_copy)
.PHONY: copy-files

@ -59,8 +59,7 @@ EXCLUDE_PROPWARN_PKGS = com.sun.java.swing.plaf.windows \
# This is an interim solution until the ct.sym is replaced
# with a new module system (being discussed for JDK 8).
#
EXPORTED_PRIVATE_PKGS = com.sun.servicetag \
com.oracle.net \
EXPORTED_PRIVATE_PKGS = com.oracle.net \
com.oracle.nio
# 64-bit solaris has a few special cases. We define the variable

@ -209,6 +209,7 @@ JAVA_JAVA_java = \
sun/util/locale/provider/CalendarDataProviderImpl.java \
sun/util/locale/provider/CalendarDataUtility.java \
sun/util/locale/provider/CalendarNameProviderImpl.java \
sun/util/locale/provider/CalendarProviderImpl.java \
sun/util/locale/provider/CollationRules.java \
sun/util/locale/provider/CollatorProviderImpl.java \
sun/util/locale/provider/CurrencyNameProviderImpl.java \
@ -232,6 +233,7 @@ JAVA_JAVA_java = \
sun/util/locale/provider/SPILocaleProviderAdapter.java \
sun/util/locale/provider/TimeZoneNameProviderImpl.java \
sun/util/locale/provider/TimeZoneNameUtility.java \
sun/util/spi/CalendarProvider.java \
java/util/LocaleISOData.java \
sun/util/cldr/CLDRLocaleProviderAdapter.java \
java/util/MissingResourceException.java \

@ -133,6 +133,7 @@ SUNWprivate_1.1 {
Java_java_lang_ClassLoader_00024NativeLibrary_find;
Java_java_lang_ClassLoader_00024NativeLibrary_load;
Java_java_lang_ClassLoader_00024NativeLibrary_unload;
Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib;
Java_java_lang_ClassLoader_getCaller;
Java_java_lang_ClassLoader_registerNatives;
Java_java_lang_Compiler_registerNatives;

@ -1,5 +1,5 @@
#
# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2000, 2013, 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
@ -384,9 +384,7 @@ OTHER_INCLUDES += \
ifeq ($(PLATFORM),windows)
OTHER_LDLIBS += $(JVMLIB) ws2_32.lib \
-libpath:$(LIBDIR) java.lib \
$(OBJDIR)/../../../../sun/java.net/net/$(OBJDIRNAME)/net.lib \
$(OBJDIR)/../../../java.lang/java/$(OBJDIRNAME)/io_util.obj \
$(OBJDIR)/../../../java.lang/java/$(OBJDIRNAME)/FileDescriptor_md.obj
$(OBJDIR)/../../../../sun/java.net/net/$(OBJDIRNAME)/net.lib
endif
ifeq ($(PLATFORM), linux)
OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -ljava -lnet -lpthread $(LIBDL)

@ -1,5 +1,5 @@
#
# Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2002, 2013, 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
@ -76,6 +76,7 @@ FILES_c = \
debug_trace.c \
debug_util.c \
awt_Plugin.c \
gnome_interface.c \
gtk2_interface.c \
swing_GTKEngine.c \
swing_GTKStyle.c \

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2013, 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
@ -843,6 +843,7 @@ LIBAWT_XAWT_FILES:=\
debug_trace.c \
debug_util.c \
awt_Plugin.c \
gnome_interface.c \
gtk2_interface.c \
swing_GTKEngine.c \
swing_GTKStyle.c \
@ -1959,8 +1960,6 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBNIO,\
-lsendfile -ljava -lnet -lc,\
LDFLAGS_SUFFIX_windows:=jvm.lib ws2_32.lib $(WIN_JAVA_LIB) \
$(JDK_OUTPUTDIR)/objs/libnet/net.lib \
$(JDK_OUTPUTDIR)/objs/libjava/io_util.obj \
$(JDK_OUTPUTDIR)/objs/libjava/FileDescriptor_md.obj \
advapi32.lib,\
LDFLAGS_SUFFIX_macosx:=-ljava -lnet -pthread -framework CoreFoundation,\
LDFLAGS_SUFFIX:=,\

@ -81,17 +81,6 @@ endif
##########################################################################################
LIBDIR = $(JDK_OUTPUTDIR)/lib
SERVICETAG_LIBDIR = $(LIBDIR)/servicetag
$(SERVICETAG_LIBDIR)/jdk_header.png: $(JDK_TOPDIR)/src/share/classes/com/sun/servicetag/resources/jdk_header.png
$(MKDIR) -p $(@D)
$(RM) $@
$(CP) $< $@
$(CHMOD) 444 $@
COPY_FILES += $(SERVICETAG_LIBDIR)/jdk_header.png
##########################################################################################
MGMT_LIBDIR = $(LIBDIR)/management
MGMT_LIB_SRC = $(JDK_TOPDIR)/src/share/lib/management

@ -59,15 +59,6 @@ COPY_FILES += \
COPY_FILES += \
$(JDK_TOPDIR)/src/share/classes/sun/jvmstat/perfdata/resources/aliasmap
# Servicetag resources
SERVICETAG_RESOURCES_DIR = $(JDK_TOPDIR)/src/share/classes/com/sun/servicetag/resources
COPY_FILES += \
$(SERVICETAG_RESOURCES_DIR)/product_registration.xsd \
$(SERVICETAG_RESOURCES_DIR)/register.html \
$(SERVICETAG_RESOURCES_DIR)/register_ja.html \
$(SERVICETAG_RESOURCES_DIR)/register_zh_CN.html \
$(wildcard $(SERVICETAG_RESOURCES_DIR)/javase_*.properties)
# JConsole resources
JCONSOLE_RESOURCES_DIR = $(JDK_TOPDIR)/src/share/classes/sun/tools/jconsole/resources
COPY_FILES += \

@ -76,8 +76,6 @@ $(eval $(call SetupArchive,BUILD_DNS_JAR,,\
$(IMAGES_OUTPUTDIR)/lib/tzdb.jar: $(JDK_OUTPUTDIR)/lib/tzdb.jar
$(install-file)
JARS += $(IMAGES_OUTPUTDIR)/lib/tzdb.jar
##########################################################################################
LOCALEDATA_INCLUDE_LOCALES := ar be bg ca cs da de el es et fi fr ga hi hr hu in is it \
@ -213,28 +211,28 @@ RT_JAR_EXCLUDES += \
org/relaxng/datatype \
sun/awt/HKSCS.class \
sun/awt/motif/X11GB2312.class \
sun/awt/motif/X11GB2312\$$Decoder.class \
sun/awt/motif/X11GB2312\$$Encoder.class \
sun/awt/motif/X11GB2312\$$$$Decoder.class \
sun/awt/motif/X11GB2312\$$$$Encoder.class \
sun/awt/motif/X11GBK.class \
sun/awt/motif/X11GBK\$$Encoder.class \
sun/awt/motif/X11GBK\$$$$Encoder.class \
sun/awt/motif/X11KSC5601.class \
sun/awt/motif/X11KSC5601\$$Decoder.class \
sun/awt/motif/X11KSC5601\$$Encoder.class \
sun/awt/motif/X11KSC5601\$$$$Decoder.class \
sun/awt/motif/X11KSC5601\$$$$Encoder.class \
sun/jvmstat \
sun/net/spi/nameservice/dns \
sun/nio/cs/ext \
sun/rmi/rmic \
sun/security/ec/ECDHKeyAgreement.class \
sun/security/ec/ECDSASignature.class \
sun/security/ec/ECDSASignature\$$Raw.class \
sun/security/ec/ECDSASignature\$$SHA1.class \
sun/security/ec/ECDSASignature\$$SHA224.class \
sun/security/ec/ECDSASignature\$$SHA256.class \
sun/security/ec/ECDSASignature\$$SHA384.class \
sun/security/ec/ECDSASignature\$$SHA512.class \
sun/security/ec/ECDSASignature\$$$$Raw.class \
sun/security/ec/ECDSASignature\$$$$SHA1.class \
sun/security/ec/ECDSASignature\$$$$SHA224.class \
sun/security/ec/ECDSASignature\$$$$SHA256.class \
sun/security/ec/ECDSASignature\$$$$SHA384.class \
sun/security/ec/ECDSASignature\$$$$SHA512.class \
sun/security/ec/ECKeyFactory.class \
sun/security/ec/ECKeyPairGenerator.class \
sun/security/ec/SunEC\$$1.class \
sun/security/ec/SunEC\$$$$1.class \
sun/security/ec/SunEC.class \
sun/security/ec/SunECEntries.class \
sun/security/internal \
@ -357,23 +355,25 @@ $(PROFILE_VERSION_CLASS_TARGETS) : $(PROFILE_VERSION_JAVA_TARGETS)
# Support for removing the addPropertyChangeListener and removePropertyChangeListener
# methods from classes that only go into the profile builds. For now the Pack200.Packer
# and Packer200.Unpacker classes have special handling because of the $ in the file
# name.
# methods from classes that only go into the profile builds.
BEANLESS_CLASSES = $(IMAGES_OUTPUTDIR)/beanless
# When there are $ characters in filenames we have some very subtle interactions between
# make expansion and shell expansion. In this particular case $< will contain a single $ while
# $@ will contain \$. So we have to pass $< in single-quotes to avoid shell expansion
$(BEANLESS_CLASSES)/%: $(JDK_OUTPUTDIR)/classes/%
$(MKDIR) -p $(@D)
$(TOOL_REMOVEMETHODS) $< $@ addPropertyChangeListener removePropertyChangeListener
$(TOOL_REMOVEMETHODS) '$<' $@ addPropertyChangeListener removePropertyChangeListener
CLASSES_TO_DEBEAN = \
java/util/logging/LogManager.class \
java/util/jar/Pack200\$$Packer.class \
java/util/jar/Pack200\$$Unpacker.class \
com/sun/java/util/jar/pack/PackerImpl.class \
com/sun/java/util/jar/pack/UnpackerImpl.class
com/sun/java/util/jar/pack/UnpackerImpl.class
BEANLESS_CLASSES_TARGETS =
ifneq ($(PROFILE),)
BEANLESS_CLASSES_TARGETS := $(foreach c, $(CLASSES_TO_DEBEAN), $(BEANLESS_CLASSES)/$c)
BEANLESS_CLASSES_TARGETS := $(addprefix $(BEANLESS_CLASSES)/, $(CLASSES_TO_DEBEAN))
endif
@ -400,13 +400,8 @@ $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/rt.jar: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the
$(ECHO) Updating rt.jar $(PROFILE) && \
$(CD) $(patsubst %$(VERSION_CLASS_PATH),%,$(CLASS_FILE)) && \
$(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(VERSION_CLASS_PATH); \
$(MKDIR) -p $(BEANLESS_CLASSES)/java/util/jar; \
$(TOOL_REMOVEMETHODS) $(JDK_OUTPUTDIR)/classes/java/util/jar/Pack200\$$Packer.class \
$(BEANLESS_CLASSES)/java/util/jar/Pack200\$$Packer.class addPropertyChangeListener removePropertyChangeListener; \
$(TOOL_REMOVEMETHODS) $(JDK_OUTPUTDIR)/classes/java/util/jar/Pack200\$$Unpacker.class \
$(BEANLESS_CLASSES)/java/util/jar/Pack200\$$Unpacker.class addPropertyChangeListener removePropertyChangeListener; \
$(CD) $(BEANLESS_CLASSES) && \
$(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(CLASSES_TO_DEBEAN) java/util/jar/* ; \
$(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(CLASSES_TO_DEBEAN); \
fi
$(MV) $@.tmp $@
@ -871,8 +866,7 @@ EXCLUDE_PROPWARN_PKGS = com.sun.java.swing.plaf.windows \
# This is an interim solution until the ct.sym is replaced
# with a new module system (being discussed for JDK 8).
#
EXPORTED_PRIVATE_PKGS = com.sun.servicetag \
com.oracle.net \
EXPORTED_PRIVATE_PKGS = com.oracle.net \
com.oracle.nio
$(IMAGES_OUTPUTDIR)/symbols/_the.symbols: $(IMAGES_OUTPUTDIR)/lib/rt.jar
@ -1123,8 +1117,6 @@ endif
$(IMAGES_OUTPUTDIR)/lib/ext/nashorn.jar: $(NASHORN_DIST)/nashorn.jar
$(install-file)
JARS += $(IMAGES_OUTPUTDIR)/lib/ext/nashorn.jar
##########################################################################################
-include $(CUSTOM_MAKE_DIR)/CreateJars.gmk

@ -194,7 +194,6 @@ $(eval $(call add_properties_to_clean,COM_SUN_ROWSET_HK,\
$(call CacheFind,$(JDK_TOPDIR)/src/share/classes/com/sun/rowset)),\
%zh_TW,%zh_HK))
#com/sun/servicetag/resources
#com/sun/swing/internal/plaf/basic/resources
$(eval $(call add_properties_to_compile,COM_SUN_SWING_PLAF_BASIC,\
$(filter %.properties,\

@ -30,9 +30,8 @@
PROFILE_NAMES := compact1 compact2 compact3
# The include files use 1,2,3,4 for simplicity and conciseness. Internally we
# use profile_1, profile_2 and profile_3. Note that profile_4 is a full JRE so
# we never have to use it directly.
# The include files use 1,2,3 for simplicity and conciseness. Internally we
# use profile_1, profile_2 and profile_3.
ALL_PROFILES := profile_1 profile_2 profile_3

@ -74,19 +74,19 @@ PROFILE_3_JARS := \
$(PROFILE_2_JARS)
ifdef OPENJDK
PROFILE_4_JRE_JAR_FILES := $(filter-out alt-rt.jar, $(PROFILE_4_JRE_JAR_FILES))
FULL_JRE_JAR_FILES := $(filter-out alt-rt.jar, $(FULL_JRE_JAR_FILES))
endif
PROFILE_4_JARS := \
$(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_4_JRE_JAR_FILES)) \
FULL_JRE_JARS := \
$(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(FULL_JRE_JAR_FILES)) \
$(PROFILE_3_JARS)
# The full set of "jar" files needed for a complete JDK (ct.sym and src.zip
# are also included.)
# Note we need to add back the regular form of all the custom profile jars e.g.
# rt.jar and resources.jar
# rt.jar and resources.jar that we filtered out above
ALL_JARS := $(PROFILE_4_JARS) \
ALL_JARS := $(FULL_JRE_JARS) \
$(IMAGES_OUTPUTDIR)/lib/rt.jar \
$(IMAGES_OUTPUTDIR)/lib/resources.jar \
$(IMAGES_OUTPUTDIR)/lib/jconsole.jar \
@ -94,7 +94,6 @@ ALL_JARS := $(PROFILE_4_JARS) \
$(IMAGES_OUTPUTDIR)/lib/tools.jar \
$(IMAGES_OUTPUTDIR)/lib/ct.sym \
$(IMAGES_OUTPUTDIR)/src.zip \
$(IMAGES_OUTPUTDIR)/lib/ext/cldrdata.jar \
$(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar
ifeq ($(OPENJDK_TARGET_OS),solaris)
@ -140,7 +139,7 @@ ALL_JRE_BIN_FILES := \
$(PROFILE_1_JRE_BIN_FILES) \
$(PROFILE_2_JRE_BIN_FILES) \
$(PROFILE_3_JRE_BIN_FILES) \
$(PROFILE_4_JRE_BIN_FILES)
$(FULL_JRE_BIN_FILES)
NOT_JRE_BIN_FILES := $(filter-out $(ALL_JRE_BIN_FILES), $(NEW_ALL_BIN_LIST))
@ -149,18 +148,18 @@ ifeq ($(PROFILE), profile_1)
NOT_JRE_BIN_FILES += \
$(PROFILE_2_JRE_BIN_FILES) \
$(PROFILE_3_JRE_BIN_FILES) \
$(PROFILE_4_JRE_BIN_FILES)
$(FULL_JRE_BIN_FILES)
endif
ifeq ($(PROFILE), profile_2)
NOT_JRE_BIN_FILES += \
$(PROFILE_3_JRE_BIN_FILES) \
$(PROFILE_4_JRE_BIN_FILES)
$(FULL_JRE_BIN_FILES)
endif
ifeq ($(PROFILE), profile_3)
NOT_JRE_BIN_FILES += \
$(PROFILE_4_JRE_BIN_FILES)
$(FULL_JRE_BIN_FILES)
endif
NOT_JRE_BIN_FILES := $(addprefix $(JDK_OUTPUTDIR)/bin/, $(NOT_JRE_BIN_FILES))
@ -173,7 +172,7 @@ ALL_JRE_LIB_FILES := \
$(PROFILE_1_JRE_LIB_FILES) \
$(PROFILE_2_JRE_LIB_FILES) \
$(PROFILE_3_JRE_LIB_FILES) \
$(PROFILE_4_JRE_LIB_FILES)
$(FULL_JRE_LIB_FILES)
NOT_JRE_LIB_FILES := $(filter-out $(ALL_JRE_LIB_FILES), $(NEW_ALL_LIB_LIST))
@ -189,18 +188,18 @@ ifeq ($(PROFILE), profile_1)
NOT_JRE_LIB_FILES += \
$(PROFILE_2_JRE_LIB_FILES) \
$(PROFILE_3_JRE_LIB_FILES) \
$(PROFILE_4_JRE_LIB_FILES)
$(FULL_JRE_LIB_FILES)
endif
ifeq ($(PROFILE), profile_2)
NOT_JRE_LIB_FILES += \
$(PROFILE_3_JRE_LIB_FILES) \
$(PROFILE_4_JRE_LIB_FILES)
$(FULL_JRE_LIB_FILES)
endif
ifeq ($(PROFILE), profile_3)
NOT_JRE_LIB_FILES += \
$(PROFILE_4_JRE_LIB_FILES)
$(FULL_JRE_LIB_FILES)
endif
# Exclude the custom jar files as these will be added back via a special rule
@ -279,13 +278,13 @@ class_list = $(patsubst $(JDK_OUTPUTDIR)/classes/%,%,\
ifeq ($(PROFILE), profile_1)
RT_JAR_EXCLUDES += \
$(PROFILE_1_RTJAR_EXCLUDE_TYPES) \
$(call class_list, $(PROFILE_1_RTJAR_EXCLUDE_TYPES)) \
$(PROFILE_2_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES)) \
$(PROFILE_3_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES)) \
$(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
$(FULL_JRE_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(FULL_JRE_RTJAR_INCLUDE_TYPES))
RT_JAR_INCLUDE_TYPES := \
$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES))
PROFILE_INCLUDE_METAINF_SERVICES := \
@ -293,11 +292,11 @@ ifeq ($(PROFILE), profile_1)
endif
ifeq ($(PROFILE), profile_2)
RT_JAR_EXCLUDES += \
$(PROFILE_2_RTJAR_EXCLUDE_TYPES) \
$(call class_list, $(PROFILE_2_RTJAR_EXCLUDE_TYPES)) \
$(PROFILE_3_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES)) \
$(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
$(FULL_JRE_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(FULL_JRE_RTJAR_INCLUDE_TYPES))
RT_JAR_INCLUDE_TYPES := \
$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES)) \
$(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES))
@ -307,9 +306,9 @@ ifeq ($(PROFILE), profile_2)
endif
ifeq ($(PROFILE), profile_3)
RT_JAR_EXCLUDES += \
$(PROFILE_3_RTJAR_EXCLUDE_TYPES) \
$(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
$(call class_list, $(PROFILE_3_RTJAR_EXCLUDE_TYPES)) \
$(FULL_JRE_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(FULL_JRE_RTJAR_INCLUDE_TYPES))
RT_JAR_INCLUDE_TYPES := \
$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES)) \
$(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES)) \

@ -133,6 +133,7 @@ SUNWprivate_1.1 {
Java_java_lang_ClassLoader_00024NativeLibrary_find;
Java_java_lang_ClassLoader_00024NativeLibrary_load;
Java_java_lang_ClassLoader_00024NativeLibrary_unload;
Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib;
Java_java_lang_ClassLoader_getCaller;
Java_java_lang_ClassLoader_registerNatives;
Java_java_lang_Compiler_registerNatives;

@ -27,6 +27,7 @@ PROFILE_1_JRE_BIN_FILES := \
keytool$(EXE_SUFFIX)
PROFILE_1_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)j2pkcs11$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsig.diz \
@ -34,6 +35,7 @@ PROFILE_1_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)nio$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)sunec$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)verify$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)verify.diz \
@ -61,7 +63,9 @@ PROFILE_1_JRE_LIB_FILES := \
currency.data \
ext/localedata.jar \
ext/meta-index \
ext/sunec.jar \
ext/sunjce_provider.jar \
ext/sunpkcs11.jar \
jce.jar \
jsse.jar \
logging.properties \
@ -88,7 +92,9 @@ PROFILE_1_JRE_OTHER_FILES := \
PROFILE_1_JRE_JAR_FILES := \
ext/localedata.jar \
ext/sunec.jar \
ext/sunjce_provider.jar \
ext/sunpkcs11.jar \
jce.jar \
jsse.jar \
resources.jar \
@ -142,7 +148,7 @@ PROFILE_3_JRE_JAR_FILES := \
management-agent.jar
PROFILE_4_JRE_BIN_FILES := \
FULL_JRE_BIN_FILES := \
orbd$(EXE_SUFFIX) \
pack200$(EXE_SUFFIX) \
policytool$(EXE_SUFFIX) \
@ -150,7 +156,7 @@ PROFILE_4_JRE_BIN_FILES := \
tnameserv$(EXE_SUFFIX) \
unpack200$(EXE_SUFFIX)
PROFILE_4_JRE_LIB_FILES := \
FULL_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt_xawt$(SHARED_LIBRARY_SUFFIX) \
@ -158,7 +164,6 @@ PROFILE_4_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)dt_socket$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)dt_socket.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)fontmanager$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)j2pkcs11$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jawt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jdwp$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jpeg$(SHARED_LIBRARY_SUFFIX) \
@ -167,7 +172,6 @@ PROFILE_4_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)kcms$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)mlib_image$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)splashscreen$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)sunec$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)t2k$(SHARED_LIBRARY_SUFFIX) \
alt-rt.jar \
charsets.jar \
@ -178,8 +182,7 @@ PROFILE_4_JRE_LIB_FILES := \
cmm/sRGB.pf \
ext/cldrdata.jar \
ext/dnsns.jar \
ext/sunec.jar \
ext/sunpkcs11.jar \
ext/nashorn.jar \
ext/zipfs.jar \
flavormap.properties \
fontconfig.RedHat.5.bfc \
@ -219,10 +222,9 @@ PROFILE_4_JRE_LIB_FILES := \
oblique-fonts/fonts.dir \
psfont.properties.ja \
psfontj2d.properties \
servicetag/jdk_header.png \
sound.properties
PROFILE_4_JRE_OTHER_FILES := \
FULL_JRE_OTHER_FILES := \
man/ja_JP.UTF-8/man1/java.1 \
man/ja_JP.UTF-8/man1/javaws.1 \
man/ja_JP.UTF-8/man1/keytool.1 \
@ -246,13 +248,12 @@ PROFILE_4_JRE_OTHER_FILES := \
man/man1/tnameserv.1 \
man/man1/unpack200.1
PROFILE_4_JRE_JAR_FILES := \
FULL_JRE_JAR_FILES := \
alt-rt.jar \
charsets.jar \
ext/cldrdata.jar \
ext/dnsns.jar \
ext/sunec.jar \
ext/sunpkcs11.jar \
ext/nashorn.jar \
ext/zipfs.jar

@ -22,119 +22,55 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# Included or excluded types must take one of two forms
# - *.class to indicate all classes; or else
# - a full single type name e.g.
# com/sun/security/auth/callback/DialogCallbackHandler$$1.class
# You can not use arbitrary wildcards like DialogCallbackHandler*.class.
#
# Notes:
# - Nested types must use $$ in place of $ as $ is the make meta-character
# - If a package is not listed in any profile's inclusion list then it will
# not appear in any profile. But if a package is also missing from the
# full JRE's inclusion list then it will still be part of the full JRE.
# This is because the full JRE's inclusion lists are only used to define
# the exclusion lists for profiles; they are not used to define the full
# JRE contents - that is still done with the pre-profile legacy mechanism
# (all packagesthat can be found, less those not intended for rt.jar).
# This was done to minimize the impact of profiles on the regular
# non-profile build.
#
PROFILE_1_RTJAR_INCLUDE_PACKAGES := \
com/sun/demo/jvmti/hprof \
com/sun/java/util/jar/pack \
com/sun/net/ssl \
com/sun/net/ssl/internal/www/protocol/https \
com/sun/nio/file \
com/sun/security/cert/internal/x509 \
java/io \
java/lang \
java/lang/annotation \
java/lang/invoke \
java/lang/ref \
java/lang/reflect \
java/math \
java/net \
java/nio \
java/nio/channels \
java/nio/channels/spi \
java/nio/charset \
java/nio/charset/spi \
java/nio/file \
java/nio/file/attribute \
java/nio/file/spi \
java/security \
java/security/cert \
java/security/interfaces \
java/security/spec \
java/text \
java/text/spi \
java/time \
java/util \
java/util/concurrent \
java/util/concurrent/atomic \
java/util/concurrent/locks \
java/util/function \
java/util/jar \
java/util/logging \
java/util/regex \
java/util/spi \
java/util/zip \
javax/net \
javax/net/ssl \
javax/security/auth \
javax/security/auth/callback \
javax/security/auth/login \
javax/security/auth/spi \
javax/security/auth/x500 \
javax/security/cert \
jdk/internal \
javax/security \
jdk \
sun/invoke \
sun/invoke/anon \
sun/invoke/empty \
sun/invoke/util \
sun/launcher \
sun/launcher/resources \
sun/misc \
sun/misc/resources \
sun/net/ \
sun/net/idn \
sun/net/sdp \
sun/net/spi \
sun/net/spi/nameservice \
sun/net/util \
sun/net/www \
sun/net/www/http \
sun/net/www/protocol/file \
sun/net/www/protocol/http/ \
sun/net/www/protocol/http/logging \
sun/net/www/protocol/https \
sun/net/www/protocol/jar \
sun/nio \
sun/nio/ch \
sun/nio/cs \
sun/nio/fs \
sun/reflect \
sun/reflect/annotation \
sun/reflect/generics/factory \
sun/reflect/generics/parser \
sun/reflect/generics/reflectiveObjects \
sun/reflect/generics/repository \
sun/reflect/generics/scope \
sun/reflect/generics/tree \
sun/reflect/generics/visitor \
sun/reflect/misc \
sun/security/action \
sun/security/ec \
sun/security/jca \
sun/security/pkcs \
sun/security/pkcs10 \
sun/security/pkcs12 \
sun/security/provider \
sun/security/provider/certpath \
sun/security/provider/certpath/ssl \
sun/security/rsa \
sun/security/timestamp \
sun/security/tools \
sun/security/tools/keytool \
sun/security/util \
sun/security/validator \
sun/security/x509 \
sun/security \
sun/text \
sun/text/bidi \
sun/text/normalizer \
sun/text/resources \
sun/usagetracker \
sun/util \
sun/util/calendar \
sun/util/locale \
sun/util/logging \
sun/util/logging/resources \
sun/util/resources
sun/util
PROFILE_1_RTJAR_INCLUDE_TYPES :=
PROFILE_1_RTJAR_INCLUDE_TYPES :=
PROFILE_1_RTJAR_EXCLUDE_TYPES :=
@ -144,139 +80,19 @@ PROFILE_1_INCLUDE_METAINF_SERVICES :=
PROFILE_2_RTJAR_INCLUDE_PACKAGES := \
com/sun/java_cup/internal/runtime \
com/sun/net/httpserver \
com/sun/net/httpserver/spi \
com/sun/org/apache/bcel/internal \
com/sun/org/apache/bcel/internal/classfile \
com/sun/org/apache/bcel/internal/generic \
com/sun/org/apache/bcel/internal/util \
com/sun/org/apache/regexp/internal \
com/sun/org/apache/xalan/internal \
com/sun/org/apache/xalan/internal/extensions \
com/sun/org/apache/xalan/internal/lib \
com/sun/org/apache/xalan/internal/res \
com/sun/org/apache/xalan/internal/templates \
com/sun/org/apache/xalan/internal/utils \
com/sun/org/apache/xalan/internal/xslt \
com/sun/org/apache/xalan/internal/xsltc \
com/sun/org/apache/xalan/internal/xsltc/cmdline \
com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt \
com/sun/org/apache/xalan/internal/xsltc/compiler \
com/sun/org/apache/xalan/internal/xsltc/compiler/util \
com/sun/org/apache/xalan/internal/xsltc/dom \
com/sun/org/apache/xalan/internal/xsltc/runtime \
com/sun/org/apache/xalan/internal/xsltc/runtime/output \
com/sun/org/apache/xalan/internal/xsltc/trax \
com/sun/org/apache/xalan/internal/xsltc/util \
com/sun/org/apache/xerces/internal/dom \
com/sun/org/apache/xerces/internal/dom/events \
com/sun/org/apache/xerces/internal/impl \
com/sun/org/apache/xerces/internal/impl/dtd \
com/sun/org/apache/xerces/internal/impl/dtd/models \
com/sun/org/apache/xerces/internal/impl/dv \
com/sun/org/apache/xerces/internal/impl/dv/dtd \
com/sun/org/apache/xerces/internal/impl/dv/util \
com/sun/org/apache/xerces/internal/impl/dv/xs \
com/sun/org/apache/xerces/internal/impl/io \
com/sun/org/apache/xerces/internal/impl/msg \
com/sun/org/apache/xerces/internal/impl/validation \
com/sun/org/apache/xerces/internal/impl/xpath \
com/sun/org/apache/xerces/internal/impl/xpath/regex \
com/sun/org/apache/xerces/internal/impl/xs \
com/sun/org/apache/xerces/internal/impl/xs/identity \
com/sun/org/apache/xerces/internal/impl/xs/models \
com/sun/org/apache/xerces/internal/impl/xs/opti \
com/sun/org/apache/xerces/internal/impl/xs/traversers \
com/sun/org/apache/xerces/internal/impl/xs/util \
com/sun/org/apache/xerces/internal/jaxp \
com/sun/org/apache/xerces/internal/jaxp/datatype \
com/sun/org/apache/xerces/internal/jaxp/validation \
com/sun/org/apache/xerces/internal/parsers \
com/sun/org/apache/xerces/internal/util \
com/sun/org/apache/xerces/internal/utils \
com/sun/org/apache/xerces/internal/xinclude \
com/sun/org/apache/xerces/internal/xni \
com/sun/org/apache/xerces/internal/xni/grammars \
com/sun/org/apache/xerces/internal/xni/parser \
com/sun/org/apache/xerces/internal/xpointer \
com/sun/org/apache/xerces/internal/xs \
com/sun/org/apache/xerces/internal/xs/datatypes \
com/sun/org/apache/xml/internal/dtm \
com/sun/org/apache/xml/internal/dtm/ref \
com/sun/org/apache/xml/internal/dtm/ref/dom2dtm \
com/sun/org/apache/xml/internal/dtm/ref/sax2dtm \
com/sun/org/apache/xml/internal/res \
com/sun/org/apache/xml/internal/resolver \
com/sun/org/apache/xml/internal/resolver/helpers \
com/sun/org/apache/xml/internal/resolver/readers \
com/sun/org/apache/xml/internal/resolver/tools \
com/sun/org/apache/xml/internal/serialize \
com/sun/org/apache/xml/internal/serializer \
com/sun/org/apache/xml/internal/serializer/utils \
com/sun/org/apache/xml/internal/utils \
com/sun/org/apache/xml/internal/utils/res \
com/sun/org/apache/xpath/internal \
com/sun/org/apache/xpath/internal/axes \
com/sun/org/apache/xpath/internal/compiler \
com/sun/org/apache/xpath/internal/domapi \
com/sun/org/apache/xpath/internal/functions \
com/sun/org/apache/xpath/internal/jaxp \
com/sun/org/apache/xpath/internal/objects \
com/sun/org/apache/xpath/internal/operations \
com/sun/org/apache/xpath/internal/patterns \
com/sun/org/apache/xpath/internal/res \
com/sun/org/apache \
com/sun/rmi/rmid \
com/sun/xml/internal/stream/ \
com/sun/xml/internal/stream/dtd \
com/sun/xml/internal/stream/dtd/nonvalidating \
com/sun/xml/internal/stream/events \
com/sun/xml/internal/stream/util \
com/sun/xml/internal/stream/writers \
com/sun/xml/internal/stream \
java/rmi \
java/rmi/activation \
java/rmi/dgc \
java/rmi/registry \
java/rmi/server \
java/sql \
javax/rmi/ssl \
javax/sql \
javax/transaction \
javax/transaction/xa \
javax/xml \
javax/xml/datatype \
javax/xml/namespace \
javax/xml/parsers \
javax/xml/stream \
javax/xml/stream/events \
javax/xml/stream/util \
javax/xml/transform \
javax/xml/transform/dom \
javax/xml/transform/sax \
javax/xml/transform/stax \
javax/xml/transform/stream \
javax/xml/validation \
javax/xml/xpath \
org/w3c/dom \
org/w3c/dom/bootstrap \
org/w3c/dom/css \
org/w3c/dom/events \
org/w3c/dom/html \
org/w3c/dom/ls \
org/w3c/dom/ranges \
org/w3c/dom/stylesheets \
org/w3c/dom/traversal \
org/w3c/dom/views \
org/w3c/dom/xpath \
org/w3c \
org/xml/sax \
org/xml/sax/ext \
org/xml/sax/helpers \
sun/net/httpserver \
sun/rmi/log \
sun/rmi/registry \
sun/rmi/runtime \
sun/rmi/server \
sun/rmi/transport \
sun/rmi/transport/proxy \
sun/rmi/transport/tcp \
sun/rmi \
sun/util/xml
PROFILE_2_RTJAR_INCLUDE_TYPES :=
@ -284,287 +100,83 @@ PROFILE_2_RTJAR_INCLUDE_TYPES :=
PROFILE_2_RTJAR_EXCLUDE_TYPES :=
PROFILE_2_INCLUDE_METAINF_SERVICES := \
META-INF/services/sun.util.spi.XmlPropertiesProvider
META-INF/services/sun.util.spi.XmlPropertiesProvider
PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
com/sun/jmx/defaults \
com/sun/jmx/interceptor \
com/sun/jmx/mbeanserver \
com/sun/jmx/remote/internal \
com/sun/jmx/remote/protocol/rmi \
com/sun/jmx/remote/security \
com/sun/jmx/remote/util \
com/sun/jmx/snmp \
com/sun/jmx/snmp/IPAcl \
com/sun/jmx/snmp/agent \
com/sun/jmx/snmp/daemon \
com/sun/jmx/snmp/defaults \
com/sun/jmx/snmp/internal \
com/sun/jmx/snmp/mpm \
com/sun/jmx/snmp/tasks \
com/sun/jmx/trace \
com/sun/jndi/dns \
com/sun/jndi/ldap \
com/sun/jndi/ldap/ext \
com/sun/jndi/ldap/pool \
com/sun/jndi/ldap/sasl \
com/sun/jndi/rmi/registry \
com/sun/jndi/toolkit/ctx \
com/sun/jndi/toolkit/dir \
com/sun/jndi/toolkit/url \
com/sun/jndi/url/dns \
com/sun/jndi/url/ldap \
com/sun/jndi/url/ldaps \
com/sun/jndi/url/rmi \
com/sun/jmx \
com/sun/jndi \
com/sun/management \
com/sun/management/jmx \
com/sun/naming/internal \
com/sun/nio/sctp \
com/sun/org/apache/xml/internal/security \
com/sun/org/apache/xml/internal/security/algorithms \
com/sun/org/apache/xml/internal/security/algorithms/implementations \
com/sun/org/apache/xml/internal/security/c14n \
com/sun/org/apache/xml/internal/security/c14n/helper \
com/sun/org/apache/xml/internal/security/c14n/implementations \
com/sun/org/apache/xml/internal/security/encryption \
com/sun/org/apache/xml/internal/security/exceptions \
com/sun/org/apache/xml/internal/security/keys \
com/sun/org/apache/xml/internal/security/keys/content \
com/sun/org/apache/xml/internal/security/keys/content/keyvalues \
com/sun/org/apache/xml/internal/security/keys/content/x509 \
com/sun/org/apache/xml/internal/security/keys/keyresolver \
com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations \
com/sun/org/apache/xml/internal/security/keys/storage \
com/sun/org/apache/xml/internal/security/keys/storage/implementations \
com/sun/org/apache/xml/internal/security/signature \
com/sun/org/apache/xml/internal/security/transforms \
com/sun/org/apache/xml/internal/security/transforms/implementations \
com/sun/org/apache/xml/internal/security/transforms/params \
com/sun/org/apache/xml/internal/security/utils \
com/sun/org/apache/xml/internal/security/utils/resolver \
com/sun/org/apache/xml/internal/security/utils/resolver/implementations \
com/sun/rowset \
com/sun/rowset/internal \
com/sun/rowset/providers \
com/sun/script/javascript \
com/sun/script/util \
com/sun/script \
com/sun/security/auth \
com/sun/security/auth/callback \
com/sun/security/auth/login \
com/sun/security/auth/module \
com/sun/security/jgss \
com/sun/security/ntlm \
com/sun/security/sasl \
com/sun/security/sasl/digest \
com/sun/security/sasl/gsskerb \
com/sun/security/sasl/ntlm \
com/sun/security/sasl/util \
com/sun/tracing \
com/sun/tracing/dtrace \
java/lang/instrument \
java/lang/management \
java/security/acl \
java/util/prefs \
javax/annotation/processing \
javax/lang/model \
javax/lang/model/element \
javax/lang/model/type \
javax/lang/model/util \
javax/management \
javax/management/loading \
javax/management/modelmbean \
javax/management/monitor \
javax/management/openmbean \
javax/management/relation \
javax/management/remote \
javax/management/remote/rmi \
javax/management/timer \
javax/naming \
javax/naming/directory \
javax/naming/event \
javax/naming/ldap \
javax/naming/spi \
javax/script \
javax/security/auth/kerberos \
javax/security/sasl \
javax/smartcardio \
javax/sql/rowset \
javax/sql/rowset/serial \
javax/sql/rowset/spi \
javax/tools \
javax/tools/annotation \
javax/xml/crypto \
javax/xml/crypto/dom \
javax/xml/crypto/dsig \
javax/xml/crypto/dsig/dom \
javax/xml/crypto/dsig/keyinfo \
javax/xml/crypto/dsig/spec \
org/ietf/jgss \
org/jcp/xml/dsig/internal \
org/jcp/xml/dsig/internal/dom \
org/jcp/xml \
sun/instrument \
sun/management \
sun/management/counter \
sun/management/counter/perf \
sun/management/jmxremote \
sun/management/resources \
sun/management/snmp \
sun/management/snmp/jvminstr \
sun/management/snmp/jvmmib \
sun/management/snmp/util \
sun/net/dns \
sun/net/www/protocol/http/ntlm \
sun/net/www/protocol/http/spnego \
sun/nio/ch/sctp \
sun/org/mozilla/classfile/internal \
sun/org/mozilla/javascript/internal \
sun/org/mozilla/javascript/internal/annotations \
sun/org/mozilla/javascript/internal/ast \
sun/org/mozilla/javascript/internal/debug \
sun/org/mozilla/javascript/internal/jdk13 \
sun/org/mozilla/javascript/internal/jdk15 \
sun/org/mozilla/javascript/internal/json \
sun/org/mozilla/javascript/internal/optimizer \
sun/org/mozilla/javascript/internal/regexp \
sun/org/mozilla/javascript/internal/serialize \
sun/org/mozilla/javascript/internal/xml \
sun/org/mozilla/javascript/internal/xmlimpl \
sun/org/mozilla \
sun/security/acl \
sun/security/jgss \
sun/security/jgss/krb5 \
sun/security/jgss/spi \
sun/security/jgss/spnego \
sun/security/jgss/wrapper \
sun/security/krb5 \
sun/security/krb5/internal \
sun/security/krb5/internal/ccache \
sun/security/krb5/internal/crypto \
sun/security/krb5/internal/crypto/dk \
sun/security/krb5/internal/ktab \
sun/security/krb5/internal/rcache \
sun/security/krb5/internal/util \
sun/security/provider/certpath/ldap \
sun/security/smartcardio \
sun/tracing \
sun/tracing/dtrace
sun/tracing
PROFILE_3_RTJAR_INCLUDE_TYPES :=
PROFILE_3_RTJAR_INCLUDE_TYPES :=
PROFILE_3_RTJAR_EXCLUDE_TYPES := \
com/sun/security/auth/callback/DialogCallbackHandler$$1.class \
com/sun/security/auth/callback/DialogCallbackHandler$$2.class \
com/sun/security/auth/callback/DialogCallbackHandler$$Action.class \
com/sun/security/auth/callback/DialogCallbackHandler$$ConfirmationInfo.class \
com/sun/security/auth/callback/DialogCallbackHandler.class \
javax/management/remote/rmi/_RMIConnectionImpl_Tie.class \
javax/management/remote/rmi/_RMIConnection_Stub.class \
javax/management/remote/rmi/_RMIServerImpl_Tie.class \
javax/management/remote/rmi/_RMIServer_Stub.class \
com/sun/security/auth/callback/DialogCallbackHandler.class \
com/sun/security/auth/callback/DialogCallbackHandler\$$1.class \
com/sun/security/auth/callback/DialogCallbackHandler\$$2.class \
com/sun/security/auth/callback/DialogCallbackHandler\$$Action.class \
com/sun/security/auth/callback/DialogCallbackHandler\$$ConfirmationInfo.class
javax/management/remote/rmi/_RMIServer_Stub.class
PROFILE_3_INCLUDE_METAINF_SERVICES := \
META-INF/services/javax.script.ScriptEngineFactory
PROFILE_4_RTJAR_INCLUDE_PACKAGES := \
com/oracle/net \
com/oracle/nio \
com/oracle/util \
FULL_JRE_RTJAR_INCLUDE_PACKAGES := \
com/oracle \
com/sun/accessibility/internal/resources \
com/sun/activation/registries \
com/sun/awt \
com/sun/beans \
com/sun/beans/decoder \
com/sun/beans/finder \
com/sun/corba/se/impl/activation \
com/sun/corba/se/impl/copyobject \
com/sun/corba/se/impl/corba \
com/sun/corba/se/impl/dynamicany \
com/sun/corba/se/impl/encoding \
com/sun/corba/se/impl/interceptors \
com/sun/corba/se/impl/io \
com/sun/corba/se/impl/ior \
com/sun/corba/se/impl/ior/iiop \
com/sun/corba/se/impl/javax/rmi \
com/sun/corba/se/impl/javax/rmi/CORBA \
com/sun/corba/se/impl/legacy/connection \
com/sun/corba/se/impl/logging \
com/sun/corba/se/impl/monitoring \
com/sun/corba/se/impl/naming/cosnaming \
com/sun/corba/se/impl/naming/namingutil \
com/sun/corba/se/impl/naming/pcosnaming \
com/sun/corba/se/impl/oa \
com/sun/corba/se/impl/oa/poa \
com/sun/corba/se/impl/oa/toa \
com/sun/corba/se/impl/orb \
com/sun/corba/se/impl/orbutil \
com/sun/corba/se/impl/orbutil/closure \
com/sun/corba/se/impl/orbutil/concurrent \
com/sun/corba/se/impl/orbutil/fsm \
com/sun/corba/se/impl/orbutil/graph \
com/sun/corba/se/impl/orbutil/threadpool \
com/sun/corba/se/impl/presentation/rmi \
com/sun/corba/se/impl/protocol \
com/sun/corba/se/impl/protocol/giopmsgheaders \
com/sun/corba/se/impl/resolver \
com/sun/corba/se/impl/transport \
com/sun/corba/se/impl/util \
com/sun/corba/se/internal/CosNaming \
com/sun/corba/se/internal/Interceptors \
com/sun/corba/se/internal/POA \
com/sun/corba/se/internal/corba \
com/sun/corba/se/internal/iiop \
com/sun/corba/se/org/omg/CORBA \
com/sun/corba/se/pept/broker \
com/sun/corba/se/pept/encoding \
com/sun/corba/se/pept/protocol \
com/sun/corba/se/pept/transport \
com/sun/corba/se/spi/activation \
com/sun/corba/se/spi/activation/InitialNameServicePackage \
com/sun/corba/se/spi/activation/LocatorPackage \
com/sun/corba/se/spi/activation/RepositoryPackage \
com/sun/corba/se/spi/copyobject \
com/sun/corba/se/spi/encoding \
com/sun/corba/se/spi/extension \
com/sun/corba/se/spi/ior \
com/sun/corba/se/spi/ior/iiop \
com/sun/corba/se/spi/legacy/connection \
com/sun/corba/se/spi/legacy/interceptor \
com/sun/corba/se/spi/logging \
com/sun/corba/se/spi/monitoring \
com/sun/corba/se/spi/oa \
com/sun/corba/se/spi/orb \
com/sun/corba/se/spi/orbutil/closure \
com/sun/corba/se/spi/orbutil/fsm \
com/sun/corba/se/spi/orbutil/proxy \
com/sun/corba/se/spi/orbutil/threadpool \
com/sun/corba/se/spi/presentation/rmi \
com/sun/corba/se/spi/protocol \
com/sun/corba/se/spi/resolver \
com/sun/corba/se/spi/servicecontext \
com/sun/corba/se/spi/transport \
com/sun/corba \
com/sun/image/codec/jpeg \
com/sun/imageio/plugins/bmp \
com/sun/imageio/plugins/common \
com/sun/imageio/plugins/gif \
com/sun/imageio/plugins/jpeg \
com/sun/imageio/plugins/png \
com/sun/imageio/plugins/wbmp \
com/sun/imageio/spi \
com/sun/imageio/stream \
com/sun/istack/internal \
com/sun/istack/internal/localization \
com/sun/istack/internal/logging \
com/sun/java/browser/dom \
com/sun/java/browser/net \
com/sun/imageio \
com/sun/istack \
com/sun/java/browser \
com/sun/java/swing \
com/sun/java/swing/plaf/gtk \
com/sun/java/swing/plaf/gtk/resources \
com/sun/java/swing/plaf/motif \
com/sun/java/swing/plaf/motif/resources \
com/sun/java/swing/plaf/nimbus \
com/sun/java/swing/plaf/windows \
com/sun/java/swing/plaf/windows/resources \
com/sun/jmx/remote/protocol/iiop \
com/sun/jndi/cosnaming \
com/sun/jndi/toolkit/corba \
@ -572,313 +184,40 @@ PROFILE_4_RTJAR_INCLUDE_PACKAGES := \
com/sun/jndi/url/iiop \
com/sun/jndi/url/iiopname \
com/sun/media/sound \
com/sun/org/glassfish/external/amx \
com/sun/org/glassfish/external/arc \
com/sun/org/glassfish/external/probe/provider \
com/sun/org/glassfish/external/probe/provider/annotations \
com/sun/org/glassfish/external/statistics \
com/sun/org/glassfish/external/statistics/annotations \
com/sun/org/glassfish/external/statistics/impl \
com/sun/org/glassfish/gmbal \
com/sun/org/glassfish/gmbal/util \
com/sun/org/omg/CORBA \
com/sun/org/omg/CORBA/ValueDefPackage \
com/sun/org/omg/CORBA/portable \
com/sun/org/omg/SendingContext \
com/sun/org/omg/SendingContext/CodeBasePackage \
com/sun/servicetag \
com/sun/swing/internal/plaf/basic/resources \
com/sun/swing/internal/plaf/metal/resources \
com/sun/swing/internal/plaf/synth/resources \
com/sun/org/glassfish \
com/sun/org/omg \
com/sun/swing \
com/sun/xml/internal/bind \
com/sun/xml/internal/bind/annotation \
com/sun/xml/internal/bind/api \
com/sun/xml/internal/bind/api/impl \
com/sun/xml/internal/bind/marshaller \
com/sun/xml/internal/bind/unmarshaller \
com/sun/xml/internal/bind/util \
com/sun/xml/internal/bind/v2 \
com/sun/xml/internal/bind/v2/bytecode \
com/sun/xml/internal/bind/v2/model/annotation \
com/sun/xml/internal/bind/v2/model/core \
com/sun/xml/internal/bind/v2/model/impl \
com/sun/xml/internal/bind/v2/model/nav \
com/sun/xml/internal/bind/v2/model/runtime \
com/sun/xml/internal/bind/v2/runtime \
com/sun/xml/internal/bind/v2/runtime/output \
com/sun/xml/internal/bind/v2/runtime/property \
com/sun/xml/internal/bind/v2/runtime/reflect \
com/sun/xml/internal/bind/v2/runtime/reflect/opt \
com/sun/xml/internal/bind/v2/runtime/unmarshaller \
com/sun/xml/internal/bind/v2/schemagen \
com/sun/xml/internal/bind/v2/schemagen/episode \
com/sun/xml/internal/bind/v2/schemagen/xmlschema \
com/sun/xml/internal/bind/v2/util \
com/sun/xml/internal/fastinfoset \
com/sun/xml/internal/fastinfoset/algorithm \
com/sun/xml/internal/fastinfoset/alphabet \
com/sun/xml/internal/fastinfoset/dom \
com/sun/xml/internal/fastinfoset/org/apache/xerces/util \
com/sun/xml/internal/fastinfoset/sax \
com/sun/xml/internal/fastinfoset/stax \
com/sun/xml/internal/fastinfoset/stax/events \
com/sun/xml/internal/fastinfoset/stax/factory \
com/sun/xml/internal/fastinfoset/stax/util \
com/sun/xml/internal/fastinfoset/tools \
com/sun/xml/internal/fastinfoset/util \
com/sun/xml/internal/fastinfoset/vocab \
com/sun/xml/internal/messaging/saaj \
com/sun/xml/internal/messaging/saaj/client/p2p \
com/sun/xml/internal/messaging/saaj/packaging/mime \
com/sun/xml/internal/messaging/saaj/packaging/mime/internet \
com/sun/xml/internal/messaging/saaj/packaging/mime/util \
com/sun/xml/internal/messaging/saaj/soap \
com/sun/xml/internal/messaging/saaj/soap/dynamic \
com/sun/xml/internal/messaging/saaj/soap/impl \
com/sun/xml/internal/messaging/saaj/soap/name \
com/sun/xml/internal/messaging/saaj/soap/ver1_1 \
com/sun/xml/internal/messaging/saaj/soap/ver1_2 \
com/sun/xml/internal/messaging/saaj/util \
com/sun/xml/internal/messaging/saaj/util/transform \
com/sun/xml/internal/org/jvnet/fastinfoset \
com/sun/xml/internal/org/jvnet/fastinfoset/sax \
com/sun/xml/internal/org/jvnet/fastinfoset/sax/helpers \
com/sun/xml/internal/org/jvnet/fastinfoset/stax \
com/sun/xml/internal/org/jvnet/mimepull \
com/sun/xml/internal/org/jvnet/staxex \
com/sun/xml/internal/org/jvnet/ws \
com/sun/xml/internal/org/jvnet/ws/databinding \
com/sun/xml/internal/org/jvnet/ws/message \
com/sun/xml/internal/messaging \
com/sun/xml/internal/org \
com/sun/xml/internal/stream/buffer \
com/sun/xml/internal/stream/buffer/sax \
com/sun/xml/internal/stream/buffer/stax \
com/sun/xml/internal/txw2 \
com/sun/xml/internal/txw2/annotation \
com/sun/xml/internal/txw2/output \
com/sun/xml/internal/ws/addressing \
com/sun/xml/internal/ws/addressing/model \
com/sun/xml/internal/ws/addressing/policy \
com/sun/xml/internal/ws/addressing/v200408 \
com/sun/xml/internal/ws/api \
com/sun/xml/internal/ws/api/addressing \
com/sun/xml/internal/ws/api/client \
com/sun/xml/internal/ws/api/config/management \
com/sun/xml/internal/ws/api/config/management/policy \
com/sun/xml/internal/ws/api/databinding \
com/sun/xml/internal/ws/api/fastinfoset \
com/sun/xml/internal/ws/api/ha \
com/sun/xml/internal/ws/api/handler \
com/sun/xml/internal/ws/api/message \
com/sun/xml/internal/ws/api/message/saaj \
com/sun/xml/internal/ws/api/message/stream \
com/sun/xml/internal/ws/api/model \
com/sun/xml/internal/ws/api/model/soap \
com/sun/xml/internal/ws/api/model/wsdl \
com/sun/xml/internal/ws/api/pipe \
com/sun/xml/internal/ws/api/pipe/helper \
com/sun/xml/internal/ws/api/policy \
com/sun/xml/internal/ws/api/policy/subject \
com/sun/xml/internal/ws/api/server \
com/sun/xml/internal/ws/api/streaming \
com/sun/xml/internal/ws/api/wsdl/parser \
com/sun/xml/internal/ws/api/wsdl/writer \
com/sun/xml/internal/ws/binding \
com/sun/xml/internal/ws/client \
com/sun/xml/internal/ws/client/dispatch \
com/sun/xml/internal/ws/client/sei \
com/sun/xml/internal/ws/config/management/policy \
com/sun/xml/internal/ws/db \
com/sun/xml/internal/ws/db/glassfish \
com/sun/xml/internal/ws/developer \
com/sun/xml/internal/ws/encoding \
com/sun/xml/internal/ws/encoding/fastinfoset \
com/sun/xml/internal/ws/encoding/policy \
com/sun/xml/internal/ws/encoding/soap \
com/sun/xml/internal/ws/encoding/soap/streaming \
com/sun/xml/internal/ws/encoding/xml \
com/sun/xml/internal/ws/fault \
com/sun/xml/internal/ws/handler \
com/sun/xml/internal/ws/message \
com/sun/xml/internal/ws/message/jaxb \
com/sun/xml/internal/ws/message/saaj \
com/sun/xml/internal/ws/message/source \
com/sun/xml/internal/ws/message/stream \
com/sun/xml/internal/ws/model \
com/sun/xml/internal/ws/model/soap \
com/sun/xml/internal/ws/model/wsdl \
com/sun/xml/internal/ws/org/objectweb/asm \
com/sun/xml/internal/ws/policy \
com/sun/xml/internal/ws/policy/jaxws \
com/sun/xml/internal/ws/policy/jaxws/spi \
com/sun/xml/internal/ws/policy/privateutil \
com/sun/xml/internal/ws/policy/sourcemodel \
com/sun/xml/internal/ws/policy/sourcemodel/attach \
com/sun/xml/internal/ws/policy/sourcemodel/wspolicy \
com/sun/xml/internal/ws/policy/spi \
com/sun/xml/internal/ws/policy/subject \
com/sun/xml/internal/ws/protocol/soap \
com/sun/xml/internal/ws/protocol/xml \
com/sun/xml/internal/ws/resources \
com/sun/xml/internal/ws/server \
com/sun/xml/internal/ws/server/provider \
com/sun/xml/internal/ws/server/sei \
com/sun/xml/internal/ws/spi \
com/sun/xml/internal/ws/spi/db \
com/sun/xml/internal/ws/streaming \
com/sun/xml/internal/ws/transport \
com/sun/xml/internal/ws/transport/http \
com/sun/xml/internal/ws/transport/http/client \
com/sun/xml/internal/ws/transport/http/server \
com/sun/xml/internal/ws/util \
com/sun/xml/internal/ws/util/exception \
com/sun/xml/internal/ws/util/localization \
com/sun/xml/internal/ws/util/pipe \
com/sun/xml/internal/ws/util/xml \
com/sun/xml/internal/ws/wsdl \
com/sun/xml/internal/ws/wsdl/parser \
com/sun/xml/internal/ws/wsdl/writer \
com/sun/xml/internal/ws/wsdl/writer/document \
com/sun/xml/internal/ws/wsdl/writer/document/http \
com/sun/xml/internal/ws/wsdl/writer/document/soap \
com/sun/xml/internal/ws/wsdl/writer/document/soap12 \
com/sun/xml/internal/ws/wsdl/writer/document/xsd \
com/sun/xml/internal/ws \
java/applet \
java/awt \
java/awt/color \
java/awt/datatransfer \
java/awt/dnd \
java/awt/dnd/peer \
java/awt/event \
java/awt/font \
java/awt/geom \
java/awt/im \
java/awt/im/spi \
java/awt/image \
java/awt/image/renderable \
java/awt/peer \
java/awt/print \
java/beans \
javax/accessibility \
javax/activation \
javax/activity \
javax/imageio \
javax/imageio/event \
javax/imageio/metadata \
javax/imageio/plugins/bmp \
javax/imageio/plugins/jpeg \
javax/imageio/spi \
javax/imageio/stream \
javax/jws \
javax/jws/soap \
javax/print \
javax/print/attribute \
javax/print/attribute/standard \
javax/print/event \
javax/rmi/CORBA \
javax/sound/midi \
javax/sound/midi/spi \
javax/sound/sampled \
javax/sound/sampled/spi \
javax/sound \
javax/swing \
javax/swing/border \
javax/swing/colorchooser \
javax/swing/event \
javax/swing/filechooser \
javax/swing/plaf \
javax/swing/plaf/basic \
javax/swing/plaf/metal \
javax/swing/plaf/multi \
javax/swing/plaf/nimbus \
javax/swing/plaf/synth \
javax/swing/table \
javax/swing/text \
javax/swing/text/html \
javax/swing/text/html/parser \
javax/swing/text/rtf \
javax/swing/tree \
javax/swing/undo \
javax/xml/bind \
javax/xml/bind/annotation \
javax/xml/bind/annotation/adapters \
javax/xml/bind/attachment \
javax/xml/bind/helpers \
javax/xml/bind/util \
javax/xml/soap \
javax/xml/ws \
javax/xml/ws/handler \
javax/xml/ws/handler/soap \
javax/xml/ws/http \
javax/xml/ws/soap \
javax/xml/ws/spi \
javax/xml/ws/spi/http \
javax/xml/ws/wsaddressing \
org/omg/CORBA \
org/omg/CORBA/DynAnyPackage \
org/omg/CORBA/ORBPackage \
org/omg/CORBA/TypeCodePackage \
org/omg/CORBA/portable \
org/omg/CORBA_2_3 \
org/omg/CORBA_2_3/portable \
org/omg/CosNaming \
org/omg/CosNaming/NamingContextExtPackage \
org/omg/CosNaming/NamingContextPackage \
org/omg/Dynamic \
org/omg/DynamicAny \
org/omg/DynamicAny/DynAnyFactoryPackage \
org/omg/DynamicAny/DynAnyPackage \
org/omg/IOP \
org/omg/IOP/CodecFactoryPackage \
org/omg/IOP/CodecPackage \
org/omg/Messaging \
org/omg/PortableInterceptor \
org/omg/PortableInterceptor/ORBInitInfoPackage \
org/omg/PortableServer \
org/omg/PortableServer/CurrentPackage \
org/omg/PortableServer/POAManagerPackage \
org/omg/PortableServer/POAPackage \
org/omg/PortableServer/ServantLocatorPackage \
org/omg/PortableServer/portable \
org/omg/SendingContext \
org/omg/stub/java/rmi \
org/omg/stub/javax/management/remote/rmi \
org/omg \
sun/applet \
sun/applet/resources \
sun/audio \
sun/awt \
sun/awt/X11 \
sun/awt/datatransfer \
sun/awt/dnd \
sun/awt/event \
sun/awt/geom \
sun/awt/im \
sun/awt/image \
sun/awt/image/codec \
sun/awt/motif \
sun/awt/resources \
sun/awt/shell \
sun/awt/util \
sun/awt/windows \
sun/beans/editors \
sun/beans/infos \
sun/corba \
sun/dc \
sun/dc/path \
sun/dc/pr \
sun/font \
sun/java2d \
sun/java2d/cmm \
sun/java2d/cmm/kcms \
sun/java2d/cmm/lcms \
sun/java2d/jules \
sun/java2d/loops \
sun/java2d/opengl \
sun/java2d/pipe \
sun/java2d/pipe/hw \
sun/java2d/pisces \
sun/java2d/x11 \
sun/java2d/xr \
sun/net/ftp \
sun/net/ftp/impl \
sun/net/smtp \
sun/net/www/content/audio \
sun/net/www/content/image \
@ -887,27 +226,26 @@ PROFILE_4_RTJAR_INCLUDE_PACKAGES := \
sun/net/www/protocol/mailto \
sun/net/www/protocol/netdoc \
sun/print \
sun/print/resources \
sun/security/tools/policytool \
sun/swing \
sun/swing/icon \
sun/swing/plaf \
sun/swing/plaf/synth \
sun/swing/plaf/windows \
sun/swing/table \
sun/swing/text \
sun/swing/text/html \
sun/tools/jar \
sun/tools/jar/resources
sun/tools/jar
PROFILE_4_RTJAR_INCLUDE_TYPES := \
com/sun/xml/internal/ws/*.class \
FULL_JRE_RTJAR_INCLUDE_TYPES := \
com/sun/security/auth/callback/DialogCallbackHandler$$1.class \
com/sun/security/auth/callback/DialogCallbackHandler$$2.class \
com/sun/security/auth/callback/DialogCallbackHandler$$Action.class \
com/sun/security/auth/callback/DialogCallbackHandler$$ConfirmationInfo.class \
com/sun/security/auth/callback/DialogCallbackHandler.class \
javax/annotation/*.class \
javax/management/remote/rmi/_RMIConnectionImpl_Tie.class \
javax/management/remote/rmi/_RMIConnection_Stub.class \
javax/management/remote/rmi/_RMIServerImpl_Tie.class \
javax/management/remote/rmi/_RMIServer_Stub.class \
javax/rmi/*.class
PROFILE_4_RTJAR_EXCLUDE_TYPES :=
FULL_JRE_RTJAR_EXCLUDE_TYPES :=
PROFILE_4_INCLUDE_METAINF_SERVICES := \
FULL_JRE_INCLUDE_METAINF_SERVICES := \
META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \
META-INF/services/com.sun.tools.internal.xjc.Plugin \
META-INF/services/javax.print.PrintServiceLookup \

@ -83,14 +83,19 @@ public abstract class AquaButtonBorder extends AquaBorder implements Border, UIR
painter.state.set(state);
painter.state.set((state != State.DISABLED && state != State.INACTIVE) && b.isFocusPainted() && isFocused(b) ? Focused.YES : Focused.NO);
// Full border size of the component.
// g.setColor(new Color(0, 255, 0, 70));
// g.drawRect(x, y, width - 1, height - 1);
final Insets subInsets = sizeVariant.insets;
x += subInsets.left;
y += subInsets.top;
width -= (subInsets.left + subInsets.right);
height -= (subInsets.top + subInsets.bottom);
// g.setColor(Color.magenta);
// g.drawRect(x, y, width - 1, height - 1);
// Where the native border should start to paint.
// g.setColor(new Color(255, 0, 255, 70));
// g.drawRect(x, y, width - 1, height - 1);
doButtonPaint(b, model, g, x, y, width, height);
}

@ -184,30 +184,30 @@ public class AquaButtonExtendedTypes {
new BorderDefinedTypeSpecifier("round", Widget.BUTTON_ROUND, new SizeVariant().alterInsets(2, 0, 0, 0).alterMinSize(28, 28), -3, -3, -3, -3),
new BorderDefinedTypeSpecifier("texturedRound", Widget.BUTTON_ROUND_INSET, new SizeVariant().alterInsets(0, 0, 0, 0).alterMinSize(26, 26), -2, -2, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmented-first", Widget.BUTTON_SEGMENTED, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 16, 6, 10).alterInsets(5, 3, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-middle", Widget.BUTTON_SEGMENTED, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 9, 6, 10).alterInsets(5, 0, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-last", Widget.BUTTON_SEGMENTED, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 9, 6, 16).alterInsets(5, 0, 5, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-only", Widget.BUTTON_SEGMENTED, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 16, 6, 16).alterInsets(5, 3, 5, 3).alterMinSize(34, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-first", Widget.BUTTON_SEGMENTED, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 16, 6, 10).alterInsets(2, 3, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-middle", Widget.BUTTON_SEGMENTED, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 9, 6, 10).alterInsets(2, 0, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-last", Widget.BUTTON_SEGMENTED, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 9, 6, 16).alterInsets(2, 0, 2, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmented-only", Widget.BUTTON_SEGMENTED, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 16, 6, 16).alterInsets(2, 3, 2, 3).alterMinSize(34, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-first", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(5, 2, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-middle", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(5, 0, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-last", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(5, 0, 5, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-only", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(5, 2, 5, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-first", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(2, 2, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-middle", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(2, 0, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-last", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(2, 0, 2, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedRoundRect-only", Widget.BUTTON_SEGMENTED_INSET, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(2, 2, 2, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-first", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(5, 2, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-middle", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(5, 0, 5, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-last", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(5, 0, 5, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-only", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(5, 2, 5, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-first", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(2, 2, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-middle", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(2, 0, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-last", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(2, 0, 2, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTexturedRounded-only", Widget.BUTTON_SEGMENTED_SCURVE, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(2, 2, 2, 2).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-first", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(6, 3, 6, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-middle", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(6, 0, 6, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-last", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(6, 0, 6, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-only", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(6, 3, 6, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-first", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(2, 3, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-middle", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(2, 0, 2, 0).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-last", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(2, 0, 2, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedTextured-only", Widget.BUTTON_SEGMENTED_TEXTURED, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(2, 3, 2, 3).alterMinSize(0, 28), 0, -3, 0, -3),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-first", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(5, 2, 5, 0).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-middle", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(5, 0, 5, 0).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-last", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(5, 0, 5, 2).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-only", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(5, 2, 5, 2).alterMinSize(34, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-first", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.FIRST, new SizeVariant().alterMargins(6, 12, 6, 8).alterInsets(2, 2, 2, 0).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-middle", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.MIDDLE, new SizeVariant().alterMargins(6, 8, 6, 8).alterInsets(2, 0, 2, 0).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-last", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.LAST, new SizeVariant().alterMargins(6, 8, 6, 12).alterInsets(2, 0, 2, 2).alterMinSize(0, 28), 0, 0, 0, 0),
new SegmentedBorderDefinedTypeSpecifier("segmentedCapsule-only", Widget.BUTTON_SEGMENTED_TOOLBAR, SegmentPosition.ONLY, new SizeVariant().alterMargins(6, 12, 6, 12).alterInsets(2, 2, 2, 2).alterMinSize(34, 28), 0, 0, 0, 0),
new BorderDefinedTypeSpecifier("segmentedGradient-first", Widget.BUTTON_BEVEL_INSET, new SizeVariant(18, 18).alterMargins(4, 5, 4, 5).replaceInsets(new Insets(-2,-0,-2,-0))),
new BorderDefinedTypeSpecifier("segmentedGradient-middle", Widget.BUTTON_BEVEL_INSET, new SizeVariant(18, 18).alterMargins(4, 5, 4, 5).replaceInsets(new Insets(-2,-1,-2,-0))),

@ -32,11 +32,13 @@ import java.text.spi.DateFormatSymbolsProvider;
import java.text.spi.DecimalFormatSymbolsProvider;
import java.text.spi.NumberFormatProvider;
import java.util.Collections;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle.Control;
import java.util.Set;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicReferenceArray;
@ -45,6 +47,7 @@ import java.util.spi.CalendarNameProvider;
import java.util.spi.CurrencyNameProvider;
import java.util.spi.LocaleNameProvider;
import java.util.spi.TimeZoneNameProvider;
import sun.util.spi.CalendarProvider;
/**
* LocaleProviderAdapter implementation for the Mac OS X locale data
@ -94,17 +97,56 @@ public class HostLocaleProviderAdapterImpl {
private static final Set<Locale> supportedLocaleSet;
static {
Set<Locale> tmpSet = new HashSet<Locale>();
Set<Locale> tmpSet = new HashSet<>();
// Assuming the default locales do not include any extensions, so
// no stripping is needed here.
Locale l = Locale.forLanguageTag(getDefaultLocale(CAT_FORMAT).replaceAll("_","-"));
Locale l = convertMacOSXLocaleToJavaLocale(getDefaultLocale(CAT_FORMAT));
tmpSet.addAll(Control.getNoFallbackControl(Control.FORMAT_DEFAULT).getCandidateLocales("", l));
l = Locale.forLanguageTag(getDefaultLocale(CAT_DISPLAY).replaceAll("_","-"));
l = convertMacOSXLocaleToJavaLocale(getDefaultLocale(CAT_DISPLAY));
tmpSet.addAll(Control.getNoFallbackControl(Control.FORMAT_DEFAULT).getCandidateLocales("", l));
supportedLocaleSet = Collections.unmodifiableSet(tmpSet);
}
private final static Locale[] supportedLocale = supportedLocaleSet.toArray(new Locale[0]);
@SuppressWarnings("fallthrough")
private static Locale convertMacOSXLocaleToJavaLocale(String macosxloc) {
// MacOSX may return ICU notation, here is the quote from CFLocale doc:
// "The corresponding value is a CFString containing the POSIX locale
// identifier as used by ICU, such as "ja_JP". If you have a variant
// locale or a different currency or calendar, it can be as complex as
// "en_US_POSIX@calendar=japanese;currency=EUR" or
// "az_Cyrl_AZ@calendar=buddhist;currency=JPY".
String[] tmp = macosxloc.split("@");
String langTag = tmp[0].replace('_', '-');
if (tmp.length > 1) {
String[] ext = tmp[1].split(";");
for (String keyval : ext) {
// We are only interested in "calendar" value for now.
if (keyval.startsWith("calendar=")) {
String calid = keyval.substring(keyval.indexOf('=')+1);
switch (calid) {
case "gregorian":
langTag += "-u-ca-gregory";
break;
case "japanese":
// Tweak for ja_JP_JP
if (tmp[0].equals("ja_JP")) {
return JRELocaleConstants.JA_JP_JP;
}
// fall through
default:
langTag += "-u-ca-" + calid;
break;
}
}
}
}
return Locale.forLanguageTag(langTag);
}
public static DateFormatProvider getDateFormatProvider() {
return new DateFormatProvider() {
@ -170,9 +212,8 @@ public class HostLocaleProviderAdapterImpl {
if (isSupportedLocale(Locale.getDefault(Locale.Category.FORMAT))) {
return supportedLocale;
}
return new Locale[0];
}
return new Locale[0];
}
@Override
public boolean isSupportedLocale(Locale locale) {
@ -362,6 +403,30 @@ public class HostLocaleProviderAdapterImpl {
};
}
public static CalendarProvider getCalendarProvider() {
return new CalendarProvider() {
@Override
public Locale[] getAvailableLocales() {
return getSupportedCalendarLocales();
}
@Override
public boolean isSupportedLocale(Locale locale) {
return isSupportedCalendarLocale(locale);
}
@Override
public Calendar getInstance(TimeZone zone, Locale locale) {
return new Calendar.Builder()
.setLocale(locale)
.setCalendarType(getCalendarID(locale.toLanguageTag()))
.setTimeZone(zone)
.setInstant(System.currentTimeMillis())
.build();
}
};
}
public static CurrencyNameProvider getCurrencyNameProvider() {
return new CurrencyNameProvider() {
@Override
@ -455,23 +520,20 @@ public class HostLocaleProviderAdapterImpl {
}
private static boolean isSupportedCalendarLocale(Locale locale) {
// special case for ja_JP_JP
if (JRELocaleConstants.JA_JP_JP.equals(locale)) {
return isJapaneseCalendar();
}
Locale base = locale.stripExtensions();
if (!supportedLocaleSet.contains(base)) {
return false;
}
String caltype = locale.getUnicodeLocaleType("ca");
if (caltype == null) {
return true;
}
String requestedCalType = locale.getUnicodeLocaleType("ca");
String nativeCalType =
getCalendarID(locale.toLanguageTag()).replaceFirst("gregorian", "gregory");
return caltype.replaceFirst("gregory", "gregorian").equals(
getCalendarID(locale.toLanguageTag()));
if (requestedCalType == null) {
return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
} else {
return requestedCalType.equals(nativeCalType);
}
}
private static boolean isJapaneseCalendar() {
@ -479,18 +541,15 @@ public class HostLocaleProviderAdapterImpl {
}
private static Locale getCalendarLocale(Locale locale) {
Locale.Builder lb = new Locale.Builder().setLocale(locale);
String calid = getCalendarID(locale.toLanguageTag());
switch (calid) {
case "gregorian":
calid = "gregory";
// FALL THROUGH!
case "japanese":
case "buddhist":
lb.setUnicodeLocaleKeyword("ca", calid);
return lb.build();
default:
return locale;
String nativeCalType = getCalendarID(locale.toLanguageTag())
.replaceFirst("gregorian", "gregory");
if (Calendar.getAvailableCalendarTypes().contains(nativeCalType)) {
return new Locale.Builder()
.setLocale(locale)
.setUnicodeLocaleKeyword("ca", nativeCalType)
.build();
} else {
return locale;
}
}

@ -49,6 +49,42 @@ static int getBPPFromModeString(CFStringRef mode)
return 0;
}
static BOOL isValidDisplayMode(CGDisplayModeRef mode){
return (1 < CGDisplayModeGetWidth(mode) && 1 < CGDisplayModeGetHeight(mode));
}
static CFMutableArrayRef getAllValidDisplayModes(jint displayID){
CFArrayRef allModes = CGDisplayCopyAllDisplayModes(displayID, NULL);
CFIndex numModes = CFArrayGetCount(allModes);
CFMutableArrayRef validModes = CFArrayCreateMutable(kCFAllocatorDefault, numModes + 1, NULL);
CFIndex n;
for (n=0; n < numModes; n++) {
CGDisplayModeRef cRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(allModes, n);
if (cRef != NULL && isValidDisplayMode(cRef)) {
CFArrayAppendValue(validModes, cRef);
}
}
CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(displayID);
BOOL containsCurrentMode = NO;
numModes = CFArrayGetCount(validModes);
for (n=0; n < numModes; n++) {
if(CFArrayGetValueAtIndex(validModes, n) == currentMode){
containsCurrentMode = YES;
break;
}
}
if (!containsCurrentMode) {
CFArrayAppendValue(validModes, currentMode);
}
return validModes;
}
/*
* Find the best possible match in the list of display modes that we can switch to based on
* the provided parameters.
@ -198,28 +234,30 @@ Java_sun_awt_CGraphicsDevice_nativeSetDisplayMode
(JNIEnv *env, jclass class, jint displayID, jint w, jint h, jint bpp, jint refrate)
{
JNF_COCOA_ENTER(env);
CFArrayRef allModes = CGDisplayCopyAllDisplayModes(displayID, NULL);
CFArrayRef allModes = getAllValidDisplayModes(displayID);
CGDisplayModeRef closestMatch = getBestModeForParameters(allModes, (int)w, (int)h, (int)bpp, (int)refrate);
__block CGError retCode = kCGErrorSuccess;
if (closestMatch != NULL) {
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
CGDisplayConfigRef config;
CGError retCode = CGBeginDisplayConfiguration(&config);
retCode = CGBeginDisplayConfiguration(&config);
if (retCode == kCGErrorSuccess) {
CGConfigureDisplayWithDisplayMode(config, displayID, closestMatch, NULL);
CGCompleteDisplayConfiguration(config, kCGConfigureForAppOnly);
if (config != NULL) {
CFRelease(config);
}
retCode = CGCompleteDisplayConfiguration(config, kCGConfigureForAppOnly);
}
}];
} else {
[JNFException raise:env as:kIllegalArgumentException reason:"Invalid display mode"];
}
if (retCode != kCGErrorSuccess){
[JNFException raise:env as:kIllegalArgumentException reason:"Unable to set display mode!"];
}
CFRelease(allModes);
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_awt_CGraphicsDevice
* Method: nativeGetDisplayMode
@ -247,7 +285,8 @@ Java_sun_awt_CGraphicsDevice_nativeGetDisplayModes
{
jobjectArray jreturnArray = NULL;
JNF_COCOA_ENTER(env);
CFArrayRef allModes = CGDisplayCopyAllDisplayModes(displayID, NULL);
CFArrayRef allModes = getAllValidDisplayModes(displayID);
CFIndex numModes = CFArrayGetCount(allModes);
static JNF_CLASS_CACHE(jc_DisplayMode, "java/awt/DisplayMode");

@ -32,8 +32,11 @@ import javax.security.auth.spi.*;
import javax.naming.*;
import javax.naming.directory.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Map;
import java.util.LinkedList;
import java.util.ResourceBundle;
import com.sun.security.auth.UnixPrincipal;
import com.sun.security.auth.UnixNumericUserPrincipal;
@ -150,8 +153,14 @@ import com.sun.security.auth.UnixNumericGroupPrincipal;
*/
public class JndiLoginModule implements LoginModule {
static final java.util.ResourceBundle rb =
java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
private static final ResourceBundle rb = AccessController.doPrivileged(
new PrivilegedAction<ResourceBundle>() {
public ResourceBundle run() {
return ResourceBundle.getBundle(
"sun.security.util.AuthResources");
}
}
);
/** JNDI Provider */
public final String USER_PROVIDER = "user.provider.url";

@ -30,22 +30,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.AuthProvider;
import java.security.GeneralSecurityException;
import java.security.Key;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.UnrecoverableKeyException;
import java.security.*;
import java.security.cert.*;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.*;
import javax.security.auth.Destroyable;
import javax.security.auth.DestroyFailedException;
import javax.security.auth.Subject;
@ -123,8 +112,14 @@ import sun.security.util.Password;
*/
public class KeyStoreLoginModule implements LoginModule {
static final java.util.ResourceBundle rb =
java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
private static final ResourceBundle rb = AccessController.doPrivileged(
new PrivilegedAction<ResourceBundle>() {
public ResourceBundle run() {
return ResourceBundle.getBundle(
"sun.security.util.AuthResources");
}
}
);
/* -- Fields -- */

@ -27,6 +27,8 @@
package com.sun.security.auth.module;
import java.io.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.MessageFormat;
import java.util.*;
@ -429,8 +431,14 @@ public class Krb5LoginModule implements LoginModule {
private static final String NAME = "javax.security.auth.login.name";
private static final String PWD = "javax.security.auth.login.password";
static final java.util.ResourceBundle rb =
java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
private static final ResourceBundle rb = AccessController.doPrivileged(
new PrivilegedAction<ResourceBundle>() {
public ResourceBundle run() {
return ResourceBundle.getBundle(
"sun.security.util.AuthResources");
}
}
);
/**
* Initialize this <code>LoginModule</code>.

@ -1,176 +0,0 @@
/*
* 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
* 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 com.sun.servicetag;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.io.IOException;
import java.net.URI;
/**
* BrowserSupport class.
*
* The implementation of the com.sun.servicetag API needs to be
* compiled with JDK 5 as well since the consumer of this API
* may require to support JDK 5 (e.g. NetBeans).
*
* The Desktop.browse() method can be backported in this class
* if needed. The current implementation only supports JDK 6.
*/
class BrowserSupport {
private static boolean isBrowseSupported = false;
private static Method browseMethod = null;
private static Object desktop = null;
private static volatile Boolean result = false;
private static void initX() {
if (desktop != null) {
return;
}
boolean supported = false;
Method browseM = null;
Object desktopObj = null;
try {
// Determine if java.awt.Desktop is supported
Class<?> desktopCls = Class.forName("java.awt.Desktop", true, null);
Method getDesktopM = desktopCls.getMethod("getDesktop");
browseM = desktopCls.getMethod("browse", URI.class);
Class<?> actionCls = Class.forName("java.awt.Desktop$Action", true, null);
final Method isDesktopSupportedMethod = desktopCls.getMethod("isDesktopSupported");
Method isSupportedMethod = desktopCls.getMethod("isSupported", actionCls);
Field browseField = actionCls.getField("BROWSE");
// isDesktopSupported calls getDefaultToolkit which can block
// infinitely, see 6636099 for details, to workaround we call
// in a thread and time it out, noting that the issue is specific
// to X11, it does not hurt for Windows.
Thread xthread = new Thread() {
public void run() {
try {
// support only if Desktop.isDesktopSupported() and
// Desktop.isSupported(Desktop.Action.BROWSE) return true.
result = (Boolean) isDesktopSupportedMethod.invoke(null);
} catch (IllegalAccessException e) {
// should never reach here
throw new InternalError("Desktop.getDesktop() method not found", e);
} catch (InvocationTargetException e) {
// browser not supported
if (Util.isVerbose()) {
e.printStackTrace();
}
}
}
};
// set it to daemon, so that the vm will exit.
xthread.setDaemon(true);
xthread.start();
try {
xthread.join(5 * 1000);
} catch (InterruptedException ie) {
// ignore the exception
}
if (result.booleanValue()) {
desktopObj = getDesktopM.invoke(null);
result = (Boolean) isSupportedMethod.invoke(desktopObj, browseField.get(null));
supported = result.booleanValue();
}
} catch (IllegalAccessException e) {
// should never reach here
throw new InternalError("Desktop.getDesktop() method not found", e);
} catch (ReflectiveOperationException e) {
// browser not supported
if (Util.isVerbose()) {
e.printStackTrace();
}
}
isBrowseSupported = supported;
browseMethod = browseM;
desktop = desktopObj;
}
static boolean isSupported() {
initX();
return isBrowseSupported;
}
/**
* Launches the default browser to display a {@code URI}.
* If the default browser is not able to handle the specified
* {@code URI}, the application registered for handling
* {@code URIs} of the specified type is invoked. The application
* is determined from the protocol and path of the {@code URI}, as
* defined by the {@code URI} class.
* <p>
* This method calls the Desktop.getDesktop().browse() method.
* <p>
* @param uri the URI to be displayed in the user default browser
*
* @throws NullPointerException if {@code uri} is {@code null}
* @throws UnsupportedOperationException if the current platform
* does not support the {@link Desktop.Action#BROWSE} action
* @throws IOException if the user default browser is not found,
* or it fails to be launched, or the default handler application
* failed to be launched
* @throws IllegalArgumentException if the necessary permissions
* are not available and the URI can not be converted to a {@code URL}
*/
static void browse(URI uri) throws IOException {
if (uri == null) {
throw new NullPointerException("null uri");
}
if (!isSupported()) {
throw new UnsupportedOperationException("Browse operation is not supported");
}
// Call Desktop.browse() method
try {
if (Util.isVerbose()) {
System.out.println("desktop: " + desktop + ":browsing..." + uri);
}
browseMethod.invoke(desktop, uri);
} catch (IllegalAccessException e) {
// should never reach here
throw new InternalError("Desktop.getDesktop() method not found", e);
} catch (InvocationTargetException e) {
Throwable x = e.getCause();
if (x != null) {
if (x instanceof UnsupportedOperationException) {
throw (UnsupportedOperationException) x;
} else if (x instanceof IllegalArgumentException) {
throw (IllegalArgumentException) x;
} else if (x instanceof IOException) {
throw (IOException) x;
} else if (x instanceof SecurityException) {
throw (SecurityException) x;
} else {
// ignore
}
}
}
}
}

@ -1,937 +0,0 @@
/*
* 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
* 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 com.sun.servicetag;
import java.io.*;
import java.util.HashSet;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.List;
import java.util.ArrayList;
import static com.sun.servicetag.Util.*;
/**
* Service Tag Installer for Java SE.
*/
public class Installer {
// System properties for testing
private static String SVCTAG_DIR_PATH =
"servicetag.dir.path";
private static String SVCTAG_ENABLE_REGISTRATION =
"servicetag.registration.enabled";
private final static String ORACLE = "Oracle";
private final static String SUN = "Sun Microsystems";
private final static String REGISTRATION_XML = "registration.xml";
private final static String SERVICE_TAG_FILE = "servicetag";
private final static String REGISTRATION_HTML_NAME = "register";
private final static Locale[] knownSupportedLocales =
new Locale[] { Locale.ENGLISH,
Locale.JAPANESE,
Locale.SIMPLIFIED_CHINESE};
private final static String javaHome = System.getProperty("java.home");
private static File svcTagDir;
private static File serviceTagFile;
private static File regXmlFile;
private static RegistrationData registration;
private static boolean supportRegistration;
private static String registerHtmlParent;
private static Set<Locale> supportedLocales = new HashSet<>();
private static Properties svcTagProps = null;
private static String[] jreArchs = null;
static {
String dir = System.getProperty(SVCTAG_DIR_PATH);
if (dir == null) {
svcTagDir = new File(getJrePath(), "lib" + File.separator + SERVICE_TAG_FILE);
} else {
svcTagDir = new File(dir);
}
serviceTagFile = new File(svcTagDir, SERVICE_TAG_FILE);
regXmlFile = new File(svcTagDir, REGISTRATION_XML);
if (System.getProperty(SVCTAG_ENABLE_REGISTRATION) == null) {
supportRegistration = isJdk();
} else {
supportRegistration = true;
}
}
private Installer() {
}
// Implementation of ServiceTag.getJavaServiceTag(String) method
static ServiceTag getJavaServiceTag(String source) throws IOException {
String vendor = System.getProperty("java.vendor", "");
if (!vendor.startsWith(SUN) && !vendor.startsWith(ORACLE)) {
// Products bundling this implementation may run on
// Mac OS which is not a Sun/Oracle JDK
return null;
}
boolean cleanup = false;
try {
// Check if we have the swordfish entries for this JRE version
if (loadServiceTagProps() == null) {
return null;
}
ServiceTag st = getJavaServiceTag();
// Check if the service tag created by this bundle owner
if (st != null && st.getSource().equals(source)) {
// Install the system service tag if supported
// stclient may be installed after the service tag creation
if (Registry.isSupported()) {
installSystemServiceTag();
}
return st;
}
// in case any exception thrown during the cleanup
cleanup = true;
// re-create a new one for this bundle owner
// first delete the registration data
deleteRegistrationData();
cleanup = false;
// create service tag and generate new register.html pages
return createServiceTag(source);
} finally {
if (cleanup) {
if (regXmlFile.exists()) {
regXmlFile.delete();
}
if (serviceTagFile.exists()) {
serviceTagFile.delete();
}
}
}
}
/**
* Returns the Java SE registration data located in
* the <JRE>/lib/servicetag/registration.xml by default.
*
* @throws IllegalArgumentException if the registration data
* is of invalid format.
*/
private static synchronized RegistrationData getRegistrationData()
throws IOException {
if (registration != null) {
return registration;
}
if (regXmlFile.exists()) {
try (BufferedInputStream in =
new BufferedInputStream(new FileInputStream(regXmlFile)))
{
registration = RegistrationData.loadFromXML(in);
} catch (IllegalArgumentException ex) {
System.err.println("Error: Bad registration data \"" +
regXmlFile + "\":" + ex.getMessage());
throw ex;
}
} else {
registration = new RegistrationData();
}
return registration;
}
/**
* Write the registration data to the registration.xml file.
*
* The offline registration page has to be regenerated with
* the new registration data.
*
* @throws java.io.IOException
*/
private static synchronized void writeRegistrationXml()
throws IOException {
if (!svcTagDir.exists()) {
// This check is for NetBeans or other products that
// bundles this com.sun.servicetag implementation for
// pre-6u5 release.
if (!svcTagDir.mkdir()) {
throw new IOException("Failed to create directory: " + svcTagDir);
}
}
// regenerate the new offline registration page
deleteRegistrationHtmlPage();
getRegistrationHtmlPage();
try (BufferedOutputStream out =
new BufferedOutputStream(new FileOutputStream(regXmlFile)))
{
getRegistrationData().storeToXML(out);
} catch (IllegalArgumentException ex) {
System.err.println("Error: Bad registration data \"" +
regXmlFile + "\":" + ex.getMessage());
throw ex;
}
}
/**
* Returns the instance urn(s) stored in the servicetag file
* or empty set if file not exists.
*/
private static Set<String> getInstalledURNs() throws IOException {
Set<String> urnSet = new HashSet<>();
if (serviceTagFile.exists()) {
try (BufferedReader in = new BufferedReader(new FileReader(serviceTagFile))) {
String urn;
while ((urn = in.readLine()) != null) {
urn = urn.trim();
if (urn.length() > 0) {
urnSet.add(urn);
}
}
}
}
return urnSet;
}
/**
* Return the Java SE service tag(s) if it exists.
* Typically only one Java SE service tag but it could have two for
* Solaris 32-bit and 64-bit on the same install directory.
*
* @return the service tag(s) for Java SE
*/
private static ServiceTag[] getJavaServiceTagArray() throws IOException {
RegistrationData regData = getRegistrationData();
Set<ServiceTag> svcTags = regData.getServiceTags();
Set<ServiceTag> result = new HashSet<>();
Properties props = loadServiceTagProps();
String jdkUrn = props.getProperty("servicetag.jdk.urn");
String jreUrn = props.getProperty("servicetag.jre.urn");
for (ServiceTag st : svcTags) {
if (st.getProductURN().equals(jdkUrn) ||
st.getProductURN().equals(jreUrn)) {
result.add(st);
}
}
return result.toArray(new ServiceTag[0]);
}
/**
* Returns the Java SE service tag for this running platform;
* or null if not exist.
* This method will return the 64-bit service tag if the JDK
* supports both 32-bit and 64-bit if already created.
*/
private static ServiceTag getJavaServiceTag() throws IOException {
String definedId = getProductDefinedId();
for (ServiceTag st : getJavaServiceTagArray()) {
if (st.getProductDefinedInstanceID().equals(definedId)) {
return st;
}
}
return null;
}
/**
* Create a service tag for Java SE and install in the system
* service tag registry if supported.
*
* A registration data <JRE>/lib/servicetag/registration.xml
* will be created to storeToXML the XML entry for Java SE service tag.
* If the system supports service tags, this method will install
* the Java SE service tag in the system service tag registry and
* its <tt>instance_urn</tt> will be stored to <JRE>/lib/servicetag/servicetag.
*
* If <JRE>/lib/servicetag/registration.xml exists but is not installed
* in the system service tag registry (i.e. servicetag doesn't exist),
* this method will install it as described above.
*
* If the system supports service tag, stclient will be used
* to create the Java SE service tag.
*
* A Solaris 32-bit and 64-bit JDK will be installed in the same
* directory but the registration.xml will have 2 service tags.
* The servicetag file will also contain 2 instance_urns for that case.
*/
private static ServiceTag createServiceTag(String svcTagSource)
throws IOException {
// determine if a new service tag is needed to be created
ServiceTag newSvcTag = null;
if (getJavaServiceTag() == null) {
newSvcTag = newServiceTag(svcTagSource);
}
// Add the new service tag in the registration data
if (newSvcTag != null) {
RegistrationData regData = getRegistrationData();
// Add the service tag to the registration data in JDK/JRE
newSvcTag = regData.addServiceTag(newSvcTag);
// add if there is a service tag for the OS
ServiceTag osTag = SolarisServiceTag.getServiceTag();
if (osTag != null && regData.getServiceTag(osTag.getInstanceURN()) == null) {
regData.addServiceTag(osTag);
}
// write to the registration.xml
writeRegistrationXml();
}
// Install the system service tag if supported
if (Registry.isSupported()) {
installSystemServiceTag();
}
return newSvcTag;
}
private static void installSystemServiceTag() throws IOException {
// only install the service tag in the registry if
// it has permission to write the servicetag file.
if ((!serviceTagFile.exists() && !svcTagDir.canWrite()) ||
(serviceTagFile.exists() && !serviceTagFile.canWrite())) {
return;
}
Set<String> urns = getInstalledURNs();
ServiceTag[] javaSvcTags = getJavaServiceTagArray();
if (urns.size() < javaSvcTags.length) {
for (ServiceTag st : javaSvcTags) {
// Add the service tag in the system service tag registry
// if not installed
String instanceURN = st.getInstanceURN();
if (!urns.contains(instanceURN)) {
Registry.getSystemRegistry().addServiceTag(st);
}
}
}
writeInstalledUrns();
}
private static ServiceTag newServiceTag(String svcTagSource) throws IOException {
Properties props = loadServiceTagProps();
// Determine the product URN and name
String productURN;
String productName;
if (isJdk()) {
// <HOME>/jre exists which implies it's a JDK
productURN = props.getProperty("servicetag.jdk.urn");
productName = props.getProperty("servicetag.jdk.name");
} else {
// Otherwise, it's a JRE
productURN = props.getProperty("servicetag.jre.urn");
productName = props.getProperty("servicetag.jre.name");
}
return ServiceTag.newInstance(ServiceTag.generateInstanceURN(),
productName,
System.getProperty("java.version"),
productURN,
props.getProperty("servicetag.parent.name"),
props.getProperty("servicetag.parent.urn"),
getProductDefinedId(),
System.getProperty("java.vendor"),
System.getProperty("os.arch"),
getZoneName(),
svcTagSource);
}
/**
* Delete the registration data, the offline registration pages and
* the service tags in the system service tag registry if installed.
*
* The registration.xml and servicetag file will be removed.
*/
private static synchronized void deleteRegistrationData()
throws IOException {
try {
// delete the offline registration page
deleteRegistrationHtmlPage();
// Remove the service tag from the system ST registry if exists
Set<String> urns = getInstalledURNs();
if (urns.size() > 0 && Registry.isSupported()) {
for (String u : urns) {
Registry.getSystemRegistry().removeServiceTag(u);
}
}
registration = null;
} finally {
// Delete the registration.xml and servicetag files if exists
if (regXmlFile.exists()) {
if (!regXmlFile.delete()) {
throw new IOException("Failed to delete " + regXmlFile);
}
}
if (serviceTagFile.exists()) {
if (!serviceTagFile.delete()) {
throw new IOException("Failed to delete " + serviceTagFile);
}
}
}
}
/**
* Updates the registration data to contain one single service tag
* for the running Java runtime.
*/
private static synchronized void updateRegistrationData(String svcTagSource)
throws IOException {
RegistrationData regData = getRegistrationData();
ServiceTag curSvcTag = newServiceTag(svcTagSource);
ServiceTag[] javaSvcTags = getJavaServiceTagArray();
Set<String> urns = getInstalledURNs();
for (ServiceTag st : javaSvcTags) {
if (!st.getProductDefinedInstanceID().equals(curSvcTag.getProductDefinedInstanceID())) {
String instanceURN = st.getInstanceURN();
regData.removeServiceTag(instanceURN);
// remove it from the system service tag registry if exists
if (urns.contains(instanceURN) && Registry.isSupported()) {
Registry.getSystemRegistry().removeServiceTag(instanceURN);
}
}
}
writeRegistrationXml();
writeInstalledUrns();
}
private static void writeInstalledUrns() throws IOException {
// if the Registry is not supported,
// remove the servicetag file
if (!Registry.isSupported() && serviceTagFile.exists()) {
serviceTagFile.delete();
return;
}
try (PrintWriter out = new PrintWriter(serviceTagFile)) {
ServiceTag[] javaSvcTags = getJavaServiceTagArray();
for (ServiceTag st : javaSvcTags) {
// Write the instance_run to the servicetag file
String instanceURN = st.getInstanceURN();
out.println(instanceURN);
}
}
}
/**
* Load the properties for generating Java SE service tags.
*
* @param version Version of Java SE
*/
private static synchronized Properties loadServiceTagProps() throws IOException {
if (svcTagProps != null) {
return svcTagProps;
}
// For Java SE 8 and later releases, JDK and JRE both use
// the same product number. The sworRDFish metadata were
// for legacy Sun part number.
String filename = "/com/sun/servicetag/resources/javase_servicetag.properties";
try (InputStream in = Installer.class.getResourceAsStream(filename)) {
svcTagProps = new Properties();
svcTagProps.load(in);
}
return svcTagProps;
}
/**
* Returns the product defined instance ID for Java SE.
* It is a list of comma-separated name/value pairs:
* "id=<full-version> <arch> [<arch>]*"
* "dir=<java.home system property value>"
*
* where <full-version> is the full version string of the JRE,
* <arch> is the architecture that the runtime supports
* (i.e. "sparc", "sparcv9", "i386", "amd64" (ISA list))
*
* For Solaris, it can be dual mode that can support both
* 32-bit and 64-bit. the "id" will be set to
* "1.6.0_03-b02 sparc sparcv9"
*
* The "dir" property is included in the service tag to enable
* the Service Tag software to determine if a service tag for
* Java SE is invalid and perform appropriate service tag
* cleanup if necessary. See RFE# 6574781 Service Tags Enhancement.
*
*/
private static String getProductDefinedId() {
StringBuilder definedId = new StringBuilder();
definedId.append("id=");
definedId.append(System.getProperty("java.runtime.version"));
String[] archs = getJreArchs();
for (String name : archs) {
definedId.append(" " + name);
}
String location = ",dir=" + javaHome;
if ((definedId.length() + location.length()) < 256) {
definedId.append(",dir=");
definedId.append(javaHome);
} else {
// if it exceeds the limit, we will not include the location
if (isVerbose()) {
System.err.println("Warning: Product defined instance ID exceeds the field limit:");
}
}
return definedId.toString();
}
/**
* Returns the architectures that the runtime supports
* (i.e. "sparc", "sparcv9", "i386", "amd64" (ISA list))
* The directory name where libjava.so is located.
*
* On Windows, returns the "os.arch" system property value.
*/
private synchronized static String[] getJreArchs() {
if (jreArchs != null) {
return jreArchs;
}
Set<String> archs = new HashSet<>();
String os = System.getProperty("os.name");
if (os.equals("SunOS") || os.equals("Linux")) {
// Traverse the directories under <JRE>/lib.
// If <JRE>/lib/<arch>/libjava.so exists, add <arch>
// to the product defined ID
File dir = new File(getJrePath() + File.separator + "lib");
if (dir.isDirectory()) {
String[] children = dir.list();
for (String name : children) {
File f = new File(dir, name + File.separator + "libjava.so");
if (f.exists()) {
archs.add(name);
}
}
}
} else {
// Windows - append the os.arch
archs.add(System.getProperty("os.arch"));
}
jreArchs = archs.toArray(new String[0]);
return jreArchs;
}
/**
* Return the zonename if zone is supported; otherwise, return
* "global".
*/
private static String getZoneName() throws IOException {
String zonename = "global";
String command = "/usr/bin/zonename";
File f = new File(command);
// com.sun.servicetag package has to be compiled with JDK 5 as well
// JDK 5 doesn't support the File.canExecute() method.
// Risk not checking isExecute() for the zonename command is very low.
if (f.exists()) {
ProcessBuilder pb = new ProcessBuilder(command);
Process p = pb.start();
String output = commandOutput(p);
if (p.exitValue() == 0) {
zonename = output.trim();
}
}
return zonename;
}
private synchronized static String getRegisterHtmlParent() throws IOException {
if (registerHtmlParent == null) {
File htmlDir; // register.html is put under the JDK directory
if (getJrePath().endsWith(File.separator + "jre")) {
htmlDir = new File(getJrePath(), "..");
} else {
// j2se non-image build
htmlDir = new File(getJrePath());
}
// initialize the supported locales
initSupportedLocales(htmlDir);
// Determine the location of the offline registration page
String path = System.getProperty(SVCTAG_DIR_PATH);
if (path == null) {
// Default is <JDK>/register.html
registerHtmlParent = htmlDir.getCanonicalPath();
} else {
File f = new File(path);
registerHtmlParent = f.getCanonicalPath();
if (!f.isDirectory()) {
throw new InternalError("Path " + path + " set in \"" +
SVCTAG_DIR_PATH + "\" property is not a directory");
}
}
}
return registerHtmlParent;
}
/**
* Returns the File object of the offline registration page localized
* for the default locale in the JDK directory.
*/
static synchronized File getRegistrationHtmlPage() throws IOException {
if (!supportRegistration) {
// No register.html page generated if JRE
return null;
}
String parent = getRegisterHtmlParent();
// check if the offline registration page is already generated
File f = new File(parent, REGISTRATION_HTML_NAME + ".html");
if (!f.exists()) {
// Generate the localized version of the offline registration Page
generateRegisterHtml(parent);
}
String name = REGISTRATION_HTML_NAME;
Locale locale = getDefaultLocale();
if (!locale.equals(Locale.ENGLISH) && supportedLocales.contains(locale)) {
// if the locale is not English and is supported by JDK
// set to the appropriate offline registration page;
// otherwise,set to register.html.
name = REGISTRATION_HTML_NAME + "_" + locale.toString();
}
File htmlFile = new File(parent, name + ".html");
if (isVerbose()) {
System.out.print("Offline registration page: " + htmlFile);
System.out.println((htmlFile.exists() ?
"" : " not exist. Use register.html"));
}
if (htmlFile.exists()) {
return htmlFile;
} else {
return new File(parent,
REGISTRATION_HTML_NAME + ".html");
}
}
private static Locale getDefaultLocale() {
List<Locale> candidateLocales = getCandidateLocales(Locale.getDefault());
for (Locale l : candidateLocales) {
if (supportedLocales.contains(l)) {
return l;
}
}
return Locale.getDefault();
}
private static List<Locale> getCandidateLocales(Locale locale) {
String language = locale.getLanguage();
String country = locale.getCountry();
String variant = locale.getVariant();
List<Locale> locales = new ArrayList<>(3);
if (variant.length() > 0) {
locales.add(locale);
}
if (country.length() > 0) {
locales.add((locales.isEmpty()) ?
locale : new Locale(language, country, ""));
}
if (language.length() > 0) {
locales.add((locales.isEmpty()) ?
locale : new Locale(language, "", ""));
}
return locales;
}
// Remove the offline registration pages
private static void deleteRegistrationHtmlPage() throws IOException {
String parent = getRegisterHtmlParent();
if (parent == null) {
return;
}
for (Locale locale : supportedLocales) {
String name = REGISTRATION_HTML_NAME;
if (!locale.equals(Locale.ENGLISH)) {
name += "_" + locale.toString();
}
File f = new File(parent, name + ".html");
if (f.exists()) {
if (!f.delete()) {
throw new IOException("Failed to delete " + f);
}
}
}
}
private static void initSupportedLocales(File jdkDir) {
if (supportedLocales.isEmpty()) {
// initialize with the known supported locales
for (Locale l : knownSupportedLocales) {
supportedLocales.add(l);
}
}
// Determine unknown supported locales if any
// by finding the localized version of README.html
// This prepares if a new locale in JDK is supported in
// e.g. in the OpenSource world
FilenameFilter ff = new FilenameFilter() {
public boolean accept(File dir, String name) {
String fname = name.toLowerCase();
if (fname.startsWith("readme") && fname.endsWith(".html")) {
return true;
}
return false;
}
};
String[] readmes = jdkDir.list(ff);
for (String name : readmes) {
String basename = name.substring(0, name.length() - ".html".length());
String[] ss = basename.split("_");
switch (ss.length) {
case 1:
// English version
break;
case 2:
supportedLocales.add(new Locale(ss[1]));
break;
case 3:
supportedLocales.add(new Locale(ss[1], ss[2]));
break;
default:
// ignore
break;
}
}
if (isVerbose()) {
System.out.println("Supported locales: ");
for (Locale l : supportedLocales) {
System.out.println(l);
}
}
}
private static final String JDK_HEADER_PNG_KEY = "@@JDK_HEADER_PNG@@";
private static final String JDK_VERSION_KEY = "@@JDK_VERSION@@";
private static final String REGISTRATION_URL_KEY = "@@REGISTRATION_URL@@";
private static final String REGISTRATION_PAYLOAD_KEY = "@@REGISTRATION_PAYLOAD@@";
@SuppressWarnings("unchecked")
private static void generateRegisterHtml(String parent) throws IOException {
int version = Util.getJdkVersion();
int update = Util.getUpdateVersion();
String jdkVersion = "Version " + version;
if (update > 0) {
// product name is not translated
jdkVersion += " Update " + update;
}
RegistrationData regData = getRegistrationData();
// Make sure it uses the canonical path before getting the URI.
File img = new File(svcTagDir.getCanonicalPath(), "jdk_header.png");
String headerImageSrc = img.toURI().toString();
// Format the registration data in one single line
StringBuilder payload = new StringBuilder();
String xml = regData.toString().replaceAll("\"", "%22");
try (BufferedReader reader = new BufferedReader(new StringReader(xml))) {
String line = null;
while ((line = reader.readLine()) != null) {
payload.append(line.trim());
}
}
String resourceFilename = "/com/sun/servicetag/resources/register";
for (Locale locale : supportedLocales) {
String name = REGISTRATION_HTML_NAME;
String resource = resourceFilename;
if (!locale.equals(Locale.ENGLISH)) {
name += "_" + locale.toString();
resource += "_" + locale.toString();
}
File f = new File(parent, name + ".html");
InputStream in = null;
BufferedReader br = null;
PrintWriter pw = null;
String registerURL = SunConnection.
getRegistrationURL(regData.getRegistrationURN(),
locale,
String.valueOf(version)).toString();
try {
in = Installer.class.getResourceAsStream(resource + ".html");
if (in == null) {
// if the resource file is missing
if (isVerbose()) {
System.out.println("Missing resouce file: " + resource + ".html");
}
continue;
}
if (isVerbose()) {
System.out.println("Generating " + f + " from " + resource + ".html");
}
try {
br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
pw = new PrintWriter(f, "UTF-8");
String line = null;
while ((line = br.readLine()) != null) {
String output = line;
if (line.contains(JDK_VERSION_KEY)) {
output = line.replace(JDK_VERSION_KEY, jdkVersion);
} else if (line.contains(JDK_HEADER_PNG_KEY)) {
output = line.replace(JDK_HEADER_PNG_KEY, headerImageSrc);
} else if (line.contains(REGISTRATION_URL_KEY)) {
output = line.replace(REGISTRATION_URL_KEY, registerURL);
} else if (line.contains(REGISTRATION_PAYLOAD_KEY)) {
output = line.replace(REGISTRATION_PAYLOAD_KEY, payload.toString());
}
pw.println(output);
}
f.setReadOnly();
pw.flush();
} finally {
// It's safe for this finally block to have two close statements
// consecutively as PrintWriter.close doesn't throw IOException.
if (pw != null) {
pw.close();
}
if (br!= null) {
br.close();
}
}
} finally {
if (in != null) {
in.close();
}
}
}
}
private static final int MAX_SOURCE_LEN = 63;
/**
* A utility class to create a service tag for Java SE.
* <p>
* <b>Usage:</b><br>
* <blockquote><tt>
* &lt;JAVA_HOME&gt;/bin/java com.sun.servicetag.Installer
* </tt></blockquote>
* <p>
*/
public static void main(String[] args) {
String source = "Manual ";
String runtimeName = System.getProperty("java.runtime.name");
if (runtimeName.startsWith("OpenJDK")) {
source = "OpenJDK ";
}
source += System.getProperty("java.runtime.version");
if (source.length() > MAX_SOURCE_LEN) {
source = source.substring(0, MAX_SOURCE_LEN);
}
// Parse the options (arguments starting with "-" )
boolean delete = false;
boolean update = false;
boolean register = false;
int count = 0;
while (count < args.length) {
String arg = args[count];
if (arg.trim().length() == 0) {
// skip empty arguments
count++;
continue;
}
if (arg.equals("-source")) {
source = args[++count];
} else if (arg.equals("-delete")) {
delete = true;
} else if (arg.equals("-register")) {
register = true;
} else {
usage();
return;
}
count++;
}
try {
if (delete) {
deleteRegistrationData();
} else {
ServiceTag[] javaSvcTags = getJavaServiceTagArray();
String[] archs = getJreArchs();
if (javaSvcTags.length > archs.length) {
// 64-bit has been uninstalled
// so remove the service tag
updateRegistrationData(source);
} else {
// create the service tag
createServiceTag(source);
}
}
if (register) {
// Registration is only supported by JDK
// For testing purpose, override with a "servicetag.enable.registration" property
RegistrationData regData = getRegistrationData();
if (supportRegistration && !regData.getServiceTags().isEmpty()) {
SunConnection.register(regData,
getDefaultLocale(),
String.valueOf(Util.getJdkVersion()));
}
}
System.exit(0);
} catch (IOException e) {
System.err.println("I/O Error: " + e.getMessage());
if (isVerbose()) {
e.printStackTrace();
}
} catch (IllegalArgumentException ex) {
if (isVerbose()) {
ex.printStackTrace();
}
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
if (isVerbose()) {
e.printStackTrace();
}
}
System.exit(1);
}
private static void usage() {
System.out.println("Usage:");
System.out.print(" " + Installer.class.getName());
System.out.println(" [-delete|-source <source>|-register]");
System.out.println(" to create a service tag for the Java platform");
System.out.println("");
System.out.println("Internal Options:");
System.out.println(" -source: to specify the source of the service tag to be created");
System.out.println(" -delete: to delete the service tag ");
System.out.println(" -register: to register the JDK");
System.out.println(" -help: to print this help message");
}
}

@ -1,193 +0,0 @@
/*
* Copyright (c) 2008, 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 com.sun.servicetag;
// This class is a copy of the com.sun.scn.servicetags.LinuxSystemEnvironment
// class from the Sun Connection source.
//
// The Service Tags team maintains the latest version of the implementation
// for system environment data collection. JDK will include a copy of
// the most recent released version for a JDK release. We rename
// the package to com.sun.servicetag so that the Sun Connection
// product always uses the latest version from the com.sun.scn.servicetags
// package. JDK and users of the com.sun.servicetag API
// (e.g. NetBeans and SunStudio) will use the version in JDK.
//
// So we keep this class in src/share/classes instead of src/<os>/classes.
import java.io.*;
/**
* Linux implementation of the SystemEnvironment class.
*/
class LinuxSystemEnvironment extends SystemEnvironment {
LinuxSystemEnvironment() {
setHostId(getLinuxHostId());
setSystemModel(getCommandOutput("/bin/uname", "-i"));
setSystemManufacturer(getLinuxSystemManufacturer());
setCpuManufacturer(getLinuxCpuManufacturer());
setSerialNumber(getLinuxSN());
}
private String dmiInfo = null;
private static final int SN = 1;
private static final int SYS = 2;
private static final int CPU = 3;
private String getLinuxHostId() {
String output = getCommandOutput("/usr/bin/hostid");
// trim off the leading 0x
if (output.startsWith("0x")) {
output = output.substring(2);
}
return output;
}
/**
* Tries to obtain and return the cpu manufacturer.
* @return The cpu manufacturer (an empty string if not found or an error occurred)
*/
private String getLinuxCpuManufacturer() {
String tmp = getLinuxPSNInfo(CPU);
if (tmp.length() > 0) {
return tmp;
}
String contents = getFileContent("/proc/cpuinfo");
for (String line : contents.split("\n")) {
if (line.contains("vendor_id")) {
String[] ss = line.split(":", 2);
if (ss.length > 1) {
return ss[1].trim();
}
}
}
// returns an empty string if it can't be found or an error happened
return getLinuxDMIInfo("dmi type 4", "manufacturer");
}
/**
* Tries to obtain and return the system manufacturer.
* @return The system manufacturer (an empty string if not found or an error occurred)
*/
private String getLinuxSystemManufacturer() {
String tmp = getLinuxPSNInfo(SYS);
if (tmp.length() > 0) {
return tmp;
}
// returns an empty string if it can't be found or an error happened
return getLinuxDMIInfo("dmi type 1", "manufacturer");
}
/**
* Tries to obtain and return the serial number of the system.
* @return The serial number (an empty string if not found or an error occurred)
*/
private String getLinuxSN() {
String tmp = getLinuxPSNInfo(SN);
if (tmp.length() > 0) {
return tmp;
}
// returns an empty string if it can't be found or an error happened
return getLinuxDMIInfo("dmi type 1", "serial number");
}
private String getLinuxPSNInfo(int target) {
// try to read from the psn file if it exists
String contents = getFileContent("/var/run/psn");
String[] ss = contents.split("\n");
if (target <= ss.length) {
return ss[target-1];
}
// default case is to return ""
return "";
}
// reads from dmidecode with the given type and target
// returns an empty string if nothing was found or an error occurred
//
// Sample output segment:
// Handle 0x0001
// DMI type 1, 25 bytes.
// System Information
// Manufacturer: System manufacturer
// Product Name: System Product Name
// Version: System Version
// Serial Number: System Serial Number
// UUID: 3091D719-B25B-D911-959D-6D1B12C7686E
// Wake-up Type: Power Switch
private synchronized String getLinuxDMIInfo(String dmiType, String target) {
// only try to get dmidecode information once, after that, we can
// reuse the output
if (dmiInfo == null) {
Thread dmidecodeThread = new Thread() {
public void run() {
dmiInfo = getCommandOutput("/usr/sbin/dmidecode");
}
};
dmidecodeThread.start();
try {
dmidecodeThread.join(2000);
if (dmidecodeThread.isAlive()) {
dmidecodeThread.interrupt();
dmiInfo = "";
}
} catch (InterruptedException ie) {
dmidecodeThread.interrupt();
}
}
if (dmiInfo.length() == 0) {
return "";
}
boolean dmiFlag = false;
for (String s : dmiInfo.split("\n")) {
String line = s.toLowerCase();
if (dmiFlag) {
if (line.contains(target)) {
String key = target + ":";
int indx = line.indexOf(key) + key.length();
if (line.contains(key) && indx < line.length()) {
return line.substring(indx).trim();
}
String[] ss = line.split(":");
return ss[ss.length-1];
}
} else if (line.contains(dmiType)) {
dmiFlag = true;
}
}
return "";
}
}

@ -1,475 +0,0 @@
/*
* Copyright (c) 2008, 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 com.sun.servicetag;
import java.io.*;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import static com.sun.servicetag.RegistrationDocument.*;
/**
* A {@code RegistrationData} object is a container of one or more
* {@link #getServiceTags service tags} that identify the
* components for product registration.
* Each {@code RegistrationData} object has a {@link #getRegistrationURN
* uniform resource name} (URN) as its identifier.
* <a name="EnvMap"></a>
* It also has an <i>environment map</i> with
* the following elements:
* <blockquote>
* <table border=0>
* <tr>
* <td><tt>hostname</tt></td>
* <td>Hostname of the system</td>
* <td>e.g. woody</td>
* </tr>
* <tr>
* <td><tt>hostId</tt></td>
* <td>Host ID of the system</td>
* <td>e.g. 83abc1ab</td>
* </tr>
* <tr>
* <td><tt>osName</tt></td>
* <td>Operating system name</td>
* <td> e.g. SunOS</td>
* </tr>
* <tr>
* <td><tt>osVersion</tt></td>
* <td>Operating system version</td>
* <td> e.g. 5.10</td>
* </tr>
* <tr>
* <td><tt>osArchitecture</tt></td>
* <td>Operating system architecture</td>
* <td> e.g. sparc</td>
* </tr>
* <tr>
* <td><tt>systemModel</tt></td>
* <td>System model</td>
* <td> e.g. SUNW,Sun-Fire-V440</td>
* </tr>
* <tr>
* <td><tt>systemManufacturer</tt></td>
* <td>System manufacturer</td>
* <td> e.g. Oracle Corporation</td>
* </tr>
* <tr>
* <td><tt>cpuManufacturer</tt></td>
* <td>CPU manufacturer</td>
* <td> e.g. Oracle Corporation</td>
* </tr>
* <tr>
* <td><tt>serialNumber</tt></td>
* <td>System serial number</td>
* <td> e.g. BEL078932</td>
* </tr>
* </table>
* </blockquote>
* The <tt>hostname</tt> and <tt>osName</tt> element must have a non-empty value.
* If an element is not available on a system and their value will be
* empty.
* <p>
* <a name="XMLSchema">
* <b>Registration XML Schema</b></a>
* <p>
* A {@code RegistrationData} object can be {@link #loadFromXML loaded} from
* and {@link #storeToXML stored} into an XML file in the format described
* by the
* <a href="https://sn-tools.central.sun.com/twiki/pub/ServiceTags/RegistrationRelayService/product_registration.xsd">
* registration data schema</a>. The registration data schema is defined by the
* Service Tags Technology.
* <p>
* Typically the registration data is constructed at installation time
* and stored in an XML file for later service tag lookup or registration.
*
* <p>
* <b>Example Usage</b>
* <p>
* The examples below show how the {@code RegistrationData} can be
* used for product registration.
* Exception handling is not shown in these examples for clarity.
* <ol>
* <li>This example shows how the JDK creates a JDK service tag, installs it
* in the system service tag registry and adds it to the registration data.
* <br>
* <blockquote><pre>
* // create a service tag object with an instance_urn
* ServiceTag st = ServiceTag.newInstance(ServiceTag.generateInstanceURN(),
* ....);
* // Adds to the system service tag registry if supported
* if (Registry.isSupported()) {
* Registry.getSystemRegistry().addServiceTag(st);
* }
*
* // add to the registration data
* RegistrationData registration = new RegistrationData();
* registration.addServiceTag(st);
* </pre></blockquote>
* </li>
* <li>At this point, the registration data is ready to
* send to Sun Connection for registration. This example shows how to register
* the JDK via the <i>Registration Relay Service</i>.
* <p>
* There are several registration services for Sun Connection. For example,
* the <a href="https://sn-tools.central.sun.com/twiki/bin/view/ServiceTags/RegistrationRelayService">
* Registration Relay Service</a> is a web application interface that
* processes the registration data payload sent via HTTP post
* and hosts the registration user interface for a specified
* registration URL. Refer to the
* Registration Relay Service Specification for details.
* <p>
* <blockquote><pre>
* // Open the connection to the URL of the registration service
* HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
* con.setDoInput(true);
* con.setDoOutput(true);
* con.setUseCaches(false);
* con.setAllowUserInteraction(false);
* con.setRequestMethod("POST");
* con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\"");
* con.connect();
*
* // send the registration data to the registration service
* OutputStream out = con.getOutputStream();
* registration.storeToXML(out);
* out.close();
* </pre></blockquote>
* </li>
* <li>This example shows how to store the registration data in an XML file.
* for later service tag lookup or registration.
* <br>
* <blockquote><pre>
* BufferedOutputStream out = new BufferedOutputStream(
* new FileOutputStream(""&lt;JAVA_HOME&gt;/lib/servicetag/registration.xml"));
* registration.storeToXML(out);
* out.close();
* </pre></blockquote>
* </li>
* <li>This example shows how to install service tags that are in the
* registration data in the system service tag registry when determined
* to be available. The system service tag registry might not have existed
* when the registration data was constructed.
* <br>
* <blockquote><pre>
* if (Registry.isSupported()) {
* Set&lt;ServiceTag&gt; svctags = registration.getServiceTags();
* for (ServiceTag st : svctags) {
* Registry.getSystemRegistry().addServiceTag(st);
* }
* }
* </pre></blockquote>
* </li>
* </ol>
*
* @see <a href="https://sunconnection.sun.com/inventory">Sun Connection Inventory Channel</a>
*/
public class RegistrationData {
private final Map<String, String> environment = initEnvironment();
private final Map<String, ServiceTag> svcTagMap =
new LinkedHashMap<String, ServiceTag>();
private final String urn;
/**
* Creates a {@code RegistrationData} object with a generated
* {@link #getRegistrationURN registration URN}.
* The following keys in the {@link #getEnvironmentMap environment map}
* will be initialized for the configuration of the
* running system:
* <blockquote>
* <tt>hostname</tt>, <tt>osName</tt>, <tt>osVersion</tt> and
* <tt>osArchitecture</tt>
* </blockquote>
* and the value of other keys may be empty.
*/
public RegistrationData() {
this(Util.generateURN());
SystemEnvironment sysEnv = SystemEnvironment.getSystemEnvironment();
setEnvironment(ST_NODE_HOSTNAME, sysEnv.getHostname());
setEnvironment(ST_NODE_HOST_ID, sysEnv.getHostId());
setEnvironment(ST_NODE_OS_NAME, sysEnv.getOsName());
setEnvironment(ST_NODE_OS_VERSION, sysEnv.getOsVersion());
setEnvironment(ST_NODE_OS_ARCH, sysEnv.getOsArchitecture());
setEnvironment(ST_NODE_SYSTEM_MODEL, sysEnv.getSystemModel());
setEnvironment(ST_NODE_SYSTEM_MANUFACTURER, sysEnv.getSystemManufacturer());
setEnvironment(ST_NODE_CPU_MANUFACTURER, sysEnv.getCpuManufacturer());
setEnvironment(ST_NODE_SERIAL_NUMBER, sysEnv.getSerialNumber());
}
// package private
RegistrationData(String urn) {
this.urn = urn;
}
private Map<String, String> initEnvironment() {
Map<String, String> map = new LinkedHashMap<String, String>();
map.put(ST_NODE_HOSTNAME, "");
map.put(ST_NODE_HOST_ID, "");
map.put(ST_NODE_OS_NAME, "");
map.put(ST_NODE_OS_VERSION, "");
map.put(ST_NODE_OS_ARCH, "");
map.put(ST_NODE_SYSTEM_MODEL, "");
map.put(ST_NODE_SYSTEM_MANUFACTURER, "");
map.put(ST_NODE_CPU_MANUFACTURER, "");
map.put(ST_NODE_SERIAL_NUMBER, "");
return map;
}
/**
* Returns the uniform resource name of this registration data
* in this format:
* <tt>urn:st:&lt;32-char {@link java.util.UUID uuid}&gt;</tt>
*
* @return the URN of this registration data.
*/
public String getRegistrationURN() {
return urn;
}
/**
* Returns a map containing the environment information for this
* registration data. See the set of <a href="#EnvMap">keys</a>
* in the environment map. Subsequent update to the environment
* map via the {@link #setEnvironment setEnvironment} method will not be reflected
* in the returned map.
*
* @return an environment map for this registration data.
*/
public Map<String, String> getEnvironmentMap() {
return new LinkedHashMap<String,String>(environment);
}
/**
* Sets an element of the specified {@code name} in the environment map
* with the given {@code value}.
*
* @throws IllegalArgumentException if {@code name} is not a valid key
* in the environment map, or {@code value} is not valid.
*/
public void setEnvironment(String name, String value) {
if (name == null) {
throw new NullPointerException("name is null");
}
if (value == null) {
throw new NullPointerException("value is null");
}
if (environment.containsKey(name)) {
if (name.equals(ST_NODE_HOSTNAME) || name.equals(ST_NODE_OS_NAME)) {
if (value.length() == 0) {
throw new IllegalArgumentException("\"" +
name + "\" requires non-empty value.");
}
}
environment.put(name, value);
} else {
throw new IllegalArgumentException("\"" +
name + "\" is not an environment element.");
}
}
/**
* Returns all service tags in this registration data.
*
* @return a {@link Set Set} of the service tags
* in this registration data.
*/
public Set<ServiceTag> getServiceTags() {
return new HashSet<ServiceTag>(svcTagMap.values());
}
/**
* Adds a service tag to this registration data.
* If the given service tag has an empty <tt>instance_urn</tt>,
* this method will generate a URN and place it in the copy
* of the service tag in this registration data.
* This method will return the {@code ServiceTag} object
* added to this registration data.
*
* @param st {@code ServiceTag} object to be added.
* @return a {@code ServiceTag} object added to this registration data.
*
* @throws IllegalArgumentException if
* a service tag of the same {@link ServiceTag#getInstanceURN
* <tt>instance_urn</tt>} already exists in the registry.
*/
public synchronized ServiceTag addServiceTag(ServiceTag st) {
ServiceTag svcTag = ServiceTag.newInstanceWithUrnTimestamp(st);
String instanceURN = svcTag.getInstanceURN();
if (svcTagMap.containsKey(instanceURN)) {
throw new IllegalArgumentException("Instance_urn = " + instanceURN +
" already exists in the registration data.");
} else {
svcTagMap.put(instanceURN, svcTag);
}
return svcTag;
}
/**
* Returns a service tag of the given <tt>instance_urn</tt> in this registration
* data.
*
* @param instanceURN the <tt>instance_urn</tt> of the service tag
* @return the {@code ServiceTag} object of the given <tt>instance_urn</tt>
* if exists; otherwise return {@code null}.
*/
public synchronized ServiceTag getServiceTag(String instanceURN) {
if (instanceURN == null) {
throw new NullPointerException("instanceURN is null");
}
return svcTagMap.get(instanceURN);
}
/**
* Removes a service tag of the given <tt>instance_urn</tt> from this
* registration data.
*
* @param instanceURN the <tt>instance_urn</tt> of
* the service tag to be removed.
*
* @return the removed {@code ServiceTag} object;
* or {@code null} if the service tag does not exist in this
* registration data.
*/
public synchronized ServiceTag removeServiceTag(String instanceURN) {
if (instanceURN == null) {
throw new NullPointerException("instanceURN is null");
}
ServiceTag svcTag = null;
if (svcTagMap.containsKey(instanceURN)) {
svcTag = svcTagMap.remove(instanceURN);
}
return svcTag;
}
/**
* Updates the <tt>product_defined_instance_id</tt> in the service tag
* of the given <tt>instance_urn</tt> in this registration data.
*
* @param instanceURN the <tt>instance_urn</tt> of the service tag to be updated.
* @param productDefinedInstanceID the value of the
* <tt>product_defined_instance_id</tt> to be set.
*
* @return the updated {@code ServiceTag} object;
* or {@code null} if the service tag does not exist in this
* registration data.
*/
public synchronized ServiceTag updateServiceTag(String instanceURN,
String productDefinedInstanceID) {
ServiceTag svcTag = getServiceTag(instanceURN);
if (svcTag == null) {
return null;
}
svcTag = ServiceTag.newInstanceWithUrnTimestamp(svcTag);
// update the product defined instance ID field
svcTag.setProductDefinedInstanceID(productDefinedInstanceID);
svcTagMap.put(instanceURN, svcTag);
return svcTag;
}
/**
* Reads the registration data from the XML document on the
* specified input stream. The XML document must be
* in the format described by the <a href="#XMLSchema">
* registration data schema</a>.
* The specified stream is closed after this method returns.
*
* @param in the input stream from which to read the XML document.
* @return a {@code RegistrationData} object read from the input
* stream.
*
* @throws IllegalArgumentException if the input stream
* contains an invalid registration data.
*
* @throws IOException if an error occurred when reading from the input stream.
*/
public static RegistrationData loadFromXML(InputStream in) throws IOException {
try {
return RegistrationDocument.load(in);
} finally {
in.close();
}
}
/**
* Writes the registration data to the specified output stream
* in the format described by the <a href="#XMLSchema">
* registration data schema</a> with "UTF-8" encoding.
* The specified stream remains open after this method returns.
*
* @param os the output stream on which to write the XML document.
*
* @throws IOException if an error occurred when writing to the output stream.
*/
public void storeToXML(OutputStream os) throws IOException {
RegistrationDocument.store(os, this);
os.flush();
}
/**
* Returns a newly allocated byte array containing the registration
* data in XML format.
*
* @return a newly allocated byte array containing the registration
* data in XML format.
*/
public byte[] toXML() {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
storeToXML(out);
return out.toByteArray();
} catch (IOException e) {
// should not reach here
return new byte[0];
}
}
/**
* Returns a string representation of this registration data in XML
* format.
*
* @return a string representation of this registration data in XML
* format.
*/
@Override
public String toString() {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
storeToXML(out);
return out.toString("UTF-8");
} catch (IOException e) {
// should not reach here
return "Error creating the return string.";
}
}
}

@ -1,358 +0,0 @@
/*
* 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
* 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 com.sun.servicetag;
import java.io.*;
import java.net.URL;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
// For write operation
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
/**
* XML Support Class for Product Registration.
*/
class RegistrationDocument {
private static final String REGISTRATION_DATA_SCHEMA =
"/com/sun/servicetag/resources/product_registration.xsd";
private static final String REGISTRATION_DATA_VERSION = "1.0";
private static final String SERVICE_TAG_VERSION = "1.0";
final static String ST_NODE_REGISTRATION_DATA = "registration_data";
final static String ST_ATTR_REGISTRATION_VERSION = "version";
final static String ST_NODE_ENVIRONMENT = "environment";
final static String ST_NODE_HOSTNAME = "hostname";
final static String ST_NODE_HOST_ID = "hostId";
final static String ST_NODE_OS_NAME = "osName";
final static String ST_NODE_OS_VERSION = "osVersion";
final static String ST_NODE_OS_ARCH = "osArchitecture";
final static String ST_NODE_SYSTEM_MODEL = "systemModel";
final static String ST_NODE_SYSTEM_MANUFACTURER = "systemManufacturer";
final static String ST_NODE_CPU_MANUFACTURER = "cpuManufacturer";
final static String ST_NODE_SERIAL_NUMBER = "serialNumber";
final static String ST_NODE_REGISTRY = "registry";
final static String ST_ATTR_REGISTRY_URN = "urn";
final static String ST_ATTR_REGISTRY_VERSION = "version";
final static String ST_NODE_SERVICE_TAG = "service_tag";
final static String ST_NODE_INSTANCE_URN = "instance_urn";
final static String ST_NODE_PRODUCT_NAME = "product_name";
final static String ST_NODE_PRODUCT_VERSION = "product_version";
final static String ST_NODE_PRODUCT_URN = "product_urn";
final static String ST_NODE_PRODUCT_PARENT_URN = "product_parent_urn";
final static String ST_NODE_PRODUCT_PARENT = "product_parent";
final static String ST_NODE_PRODUCT_DEFINED_INST_ID = "product_defined_inst_id";
final static String ST_NODE_PRODUCT_VENDOR = "product_vendor";
final static String ST_NODE_PLATFORM_ARCH = "platform_arch";
final static String ST_NODE_TIMESTAMP = "timestamp";
final static String ST_NODE_CONTAINER = "container";
final static String ST_NODE_SOURCE = "source";
final static String ST_NODE_INSTALLER_UID = "installer_uid";
static RegistrationData load(InputStream in) throws IOException {
Document document = initializeDocument(in);
// Gets the registration URN
Element root = getRegistrationDataRoot(document);
Element registryRoot =
getSingletonElementFromRoot(root, ST_NODE_REGISTRY);
String urn = registryRoot.getAttribute(ST_ATTR_REGISTRY_URN);
// Construct a new RegistrationData object from the DOM tree
// Initialize the environment map and service tags
RegistrationData regData = new RegistrationData(urn);
addServiceTags(registryRoot, regData);
Element envRoot = getSingletonElementFromRoot(root, ST_NODE_ENVIRONMENT);
buildEnvironmentMap(envRoot, regData);
return regData;
}
static void store(OutputStream os, RegistrationData registration)
throws IOException {
// create a new document with the root node
Document document = initializeDocument();
// create the nodes for the environment map and the service tags
// in the registration data
addEnvironmentNodes(document,
registration.getEnvironmentMap());
addServiceTagRegistry(document,
registration.getRegistrationURN(),
registration.getServiceTags());
transform(document, os);
}
// initialize a document from an input stream
private static Document initializeDocument(InputStream in) throws IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
// XML schema for validation
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA);
Schema schema = sf.newSchema(xsdUrl);
Validator validator = schema.newValidator();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(in));
validator.validate(new DOMSource(doc));
return doc;
} catch (SAXException sxe) {
IllegalArgumentException e = new IllegalArgumentException("Error generated in parsing");
e.initCause(sxe);
throw e;
} catch (ParserConfigurationException pce) {
// Parser with specific options can't be built
// should not reach here
throw new InternalError("Error in creating the new document", pce);
}
}
// initialize a new document for the registration data
private static Document initializeDocument() throws IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.newDocument();
// initialize the document with the registration_data root
Element root = doc.createElement(ST_NODE_REGISTRATION_DATA);
doc.appendChild(root);
root.setAttribute(ST_ATTR_REGISTRATION_VERSION, REGISTRATION_DATA_VERSION);
return doc;
} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built
// should not reach here
throw new InternalError("Error in creating the new document", pce);
}
}
// Transform the current DOM tree with the given output stream.
private static void transform(Document document, OutputStream os) {
try {
// Use a Transformer for output
TransformerFactory tFactory = TransformerFactory.newInstance();
tFactory.setAttribute("indent-number", new Integer(3));
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
transformer.transform(new DOMSource(document),
new StreamResult(new BufferedWriter(new OutputStreamWriter(os, "UTF-8"))));
} catch (UnsupportedEncodingException ue) {
// Should not reach here
throw new InternalError("Error generated during transformation", ue);
} catch (TransformerConfigurationException tce) {
// Error generated by the parser
// Should not reach here
throw new InternalError("Error in creating the new document", tce);
} catch (TransformerException te) {
// Error generated by the transformer
throw new InternalError("Error generated during transformation", te);
}
}
private static void addServiceTagRegistry(Document document,
String registryURN,
Set<ServiceTag> svcTags) {
// add service tag registry node and its attributes
Element reg = document.createElement(ST_NODE_REGISTRY);
reg.setAttribute(ST_ATTR_REGISTRY_URN, registryURN);
reg.setAttribute(ST_ATTR_REGISTRY_VERSION, SERVICE_TAG_VERSION);
Element root = getRegistrationDataRoot(document);
root.appendChild(reg);
// adds the elements for the service tags
for (ServiceTag st : svcTags) {
addServiceTagElement(document, reg, st);
}
}
private static void addServiceTagElement(Document document,
Element registryRoot,
ServiceTag st) {
Element svcTag = document.createElement(ST_NODE_SERVICE_TAG);
registryRoot.appendChild(svcTag);
addChildElement(document, svcTag,
ST_NODE_INSTANCE_URN, st.getInstanceURN());
addChildElement(document, svcTag,
ST_NODE_PRODUCT_NAME, st.getProductName());
addChildElement(document, svcTag,
ST_NODE_PRODUCT_VERSION, st.getProductVersion());
addChildElement(document, svcTag,
ST_NODE_PRODUCT_URN, st.getProductURN());
addChildElement(document, svcTag,
ST_NODE_PRODUCT_PARENT_URN, st.getProductParentURN());
addChildElement(document, svcTag,
ST_NODE_PRODUCT_PARENT, st.getProductParent());
addChildElement(document, svcTag,
ST_NODE_PRODUCT_DEFINED_INST_ID,
st.getProductDefinedInstanceID());
addChildElement(document, svcTag,
ST_NODE_PRODUCT_VENDOR, st.getProductVendor());
addChildElement(document, svcTag,
ST_NODE_PLATFORM_ARCH, st.getPlatformArch());
addChildElement(document, svcTag,
ST_NODE_TIMESTAMP, Util.formatTimestamp(st.getTimestamp()));
addChildElement(document, svcTag,
ST_NODE_CONTAINER, st.getContainer());
addChildElement(document, svcTag,
ST_NODE_SOURCE, st.getSource());
addChildElement(document, svcTag,
ST_NODE_INSTALLER_UID,
String.valueOf(st.getInstallerUID()));
}
private static void addChildElement(Document document, Element root,
String element, String text) {
Element node = document.createElement(element);
node.appendChild(document.createTextNode(text));
root.appendChild(node);
}
// Constructs service tags from the document
private static void addServiceTags(Element registryRoot,
RegistrationData registration) {
NodeList children = registryRoot.getElementsByTagName(ST_NODE_SERVICE_TAG);
int length = (children == null ? 0 : children.getLength());
for (int i = 0; i < length; i++) {
Element svcTagElement = (Element) children.item(i);
ServiceTag st = getServiceTag(svcTagElement);
registration.addServiceTag(st);
}
}
// build environment map from the document
private static void buildEnvironmentMap(Element envRoot,
RegistrationData registration) {
registration.setEnvironment(ST_NODE_HOSTNAME, getTextValue(envRoot, ST_NODE_HOSTNAME));
registration.setEnvironment(ST_NODE_HOST_ID, getTextValue(envRoot, ST_NODE_HOST_ID));
registration.setEnvironment(ST_NODE_OS_NAME, getTextValue(envRoot, ST_NODE_OS_NAME));
registration.setEnvironment(ST_NODE_OS_VERSION, getTextValue(envRoot, ST_NODE_OS_VERSION));
registration.setEnvironment(ST_NODE_OS_ARCH, getTextValue(envRoot, ST_NODE_OS_ARCH));
registration.setEnvironment(ST_NODE_SYSTEM_MODEL, getTextValue(envRoot, ST_NODE_SYSTEM_MODEL));
registration.setEnvironment(ST_NODE_SYSTEM_MANUFACTURER, getTextValue(envRoot, ST_NODE_SYSTEM_MANUFACTURER));
registration.setEnvironment(ST_NODE_CPU_MANUFACTURER, getTextValue(envRoot, ST_NODE_CPU_MANUFACTURER));
registration.setEnvironment(ST_NODE_SERIAL_NUMBER, getTextValue(envRoot, ST_NODE_SERIAL_NUMBER));
}
// add the nodes representing the environment map in the document
private static void addEnvironmentNodes(Document document,
Map<String, String> envMap) {
Element root = getRegistrationDataRoot(document);
Element env = document.createElement(ST_NODE_ENVIRONMENT);
root.appendChild(env);
Set<Map.Entry<String, String>> keys = envMap.entrySet();
for (Map.Entry<String, String> entry : keys) {
addChildElement(document, env, entry.getKey(), entry.getValue());
}
}
private static Element getRegistrationDataRoot(Document doc) {
Element root = doc.getDocumentElement();
if (!root.getNodeName().equals(ST_NODE_REGISTRATION_DATA)) {
throw new IllegalArgumentException("Not a " +
ST_NODE_REGISTRATION_DATA +
" node \"" + root.getNodeName() + "\"");
}
return root;
}
private static Element getSingletonElementFromRoot(Element root, String name) {
NodeList children = root.getElementsByTagName(name);
int length = (children == null ? 0 : children.getLength());
if (length != 1) {
throw new IllegalArgumentException("Invalid number of " + name +
" nodes = " + length);
}
Element e = (Element) children.item(0);
if (!e.getNodeName().equals(name)) {
throw new IllegalArgumentException("Not a " + name +
" node \"" + e.getNodeName() + "\"");
}
return e;
}
// Constructs one ServiceTag instance from a service tag element root
private static ServiceTag getServiceTag(Element svcTagElement) {
return new ServiceTag(
getTextValue(svcTagElement, ST_NODE_INSTANCE_URN),
getTextValue(svcTagElement, ST_NODE_PRODUCT_NAME),
getTextValue(svcTagElement, ST_NODE_PRODUCT_VERSION),
getTextValue(svcTagElement, ST_NODE_PRODUCT_URN),
getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT),
getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT_URN),
getTextValue(svcTagElement, ST_NODE_PRODUCT_DEFINED_INST_ID),
getTextValue(svcTagElement, ST_NODE_PRODUCT_VENDOR),
getTextValue(svcTagElement, ST_NODE_PLATFORM_ARCH),
getTextValue(svcTagElement, ST_NODE_CONTAINER),
getTextValue(svcTagElement, ST_NODE_SOURCE),
Util.getIntValue(getTextValue(svcTagElement, ST_NODE_INSTALLER_UID)),
Util.parseTimestamp(getTextValue(svcTagElement, ST_NODE_TIMESTAMP))
);
}
private static String getTextValue(Element e, String tagName) {
String value = "";
NodeList nl = e.getElementsByTagName(tagName);
if (nl != null && nl.getLength() > 0) {
Element el = (Element) nl.item(0);
Node node = el.getFirstChild();
if (node != null) {
value = node.getNodeValue();
}
}
return value;
}
}

@ -1,556 +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 com.sun.servicetag;
import java.io.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import static com.sun.servicetag.Util.*;
import static com.sun.servicetag.RegistrationDocument.*;
/**
* A service tag registry is a XML-based registry containing
* the list of {@link ServiceTag service tags} installed in the system.
* The {@code Registry} class provides interfaces
* to add, remove, update, and get a service tag from a service tag
* registry.
* This {@code Registry} class may not be supported
* on all systems. The {@link #isSupported} method
* can be called to determine if it is supported.
* <p>
* A registry may implement restrictions to only allow certain users
* to {@link #updateServiceTag update} and
* to {@link #removeServiceTag remove} a service tag record. Typically,
* only the owner of the service tag, the owner of the registry
* and superuser are authorized to update or remove a service tag in
* the registry.
*
* @see <a href="https://sn-tools.central.sun.com/twiki/bin/view/ServiceTags/ServiceTagDevGuideHelper">
* Service Tag User Guide</a>
*/
public class Registry {
private static final String STCLIENT_SOLARIS = "/usr/bin/stclient";
private static final String STCLIENT_LINUX = "/opt/sun/servicetag/bin/stclient";
// stclient exit value (see sthelper.h)
private static final int ST_ERR_NOT_AUTH = 245;
private static final int ST_ERR_REC_NOT_FOUND = 225;
// The stclient output has to be an exported interface
private static final String INSTANCE_URN_DESC = "Product instance URN=";
private static boolean initialized = false;
private static File stclient = null;
private static String stclientPath = null;
private static Registry registry = new Registry();
// System properties for testing
private static String SVCTAG_STCLIENT_CMD = "servicetag.stclient.cmd";
private static String SVCTAG_STHELPER_SUPPORTED = "servicetag.sthelper.supported";
private Registry() {
}
private synchronized static String getSTclient() {
if (!initialized) {
// Initialization to determine the platform's stclient pathname
String os = System.getProperty("os.name");
if (os.equals("SunOS")) {
stclient = new File(STCLIENT_SOLARIS);
} else if (os.equals("Linux")) {
stclient = new File(STCLIENT_LINUX);
} else if (os.startsWith("Windows")) {
stclient = getWindowsStClientFile();
} else {
if (isVerbose()) {
System.out.println("Running on unsupported platform");
}
}
initialized = true;
}
boolean supportsHelperClass = true; // default
if (System.getProperty(SVCTAG_STHELPER_SUPPORTED) != null) {
// the system property always overrides the default setting
supportsHelperClass = Boolean.getBoolean(SVCTAG_STHELPER_SUPPORTED);
}
if (!supportsHelperClass) {
// disable system registry
return null;
}
// This is only used for testing
String path = System.getProperty(SVCTAG_STCLIENT_CMD);
if (path != null) {
return path;
}
// com.sun.servicetag package has to be compiled with JDK 5 as well
// JDK 5 doesn't support the File.canExecute() method.
// Risk not checking isExecute() for the stclient command is very low.
if (stclientPath == null && stclient != null && stclient.exists()) {
stclientPath = stclient.getAbsolutePath();
}
return stclientPath;
}
/**
* Returns the system service tag registry. The {@code Registry} class
* may not be supported on some platforms; use the {@link #isSupported}
* method to determine if it is supported.
*
* @return the {@code Registry} object for the system service tag registry.
*
* @throws UnsupportedOperationException if the {@code Registry} class is
* not supported.
*/
public static Registry getSystemRegistry() {
if (isSupported()) {
return registry;
} else {
throw new UnsupportedOperationException("Registry class is not supported");
}
}
/**
* Returns {@code true} if the {@code Registry} class is supported on this system.
*
* @return {@code true} if the {@code Registry} class is supported;
* otherwise, return {@code false}.
*/
public static synchronized boolean isSupported() {
return getSTclient() != null;
}
private static List<String> getCommandList() {
// Set up the arguments to call stclient
List<String> command = new ArrayList<String>();
if (System.getProperty(SVCTAG_STCLIENT_CMD) != null) {
// This is for jtreg testing use. This will be set to something
// like:
// $JAVA_HOME/bin/java -cp $TEST_DIR \
// -Dstclient.registry.path=$TEST_DIR/registry.xml \
// SvcTagClient
//
// On Windows, the JAVA_HOME and TEST_DIR path could contain
// space e.g. c:\Program Files\Java\jdk1.6.0_05\bin\java.
// The SVCTAG_STCLIENT_CMD must be set with a list of
// space-separated parameters. If a parameter contains spaces,
// it must be quoted with '"'.
String cmd = getSTclient();
int len = cmd.length();
int i = 0;
while (i < len) {
char separator = ' ';
if (cmd.charAt(i) == '"') {
separator = '"';
i++;
}
// look for the separator or matched the closing '"'
int j;
for (j = i+1; j < len; j++) {
if (cmd.charAt(j) == separator) {
break;
}
}
if (i == j-1) {
// add an empty parameter
command.add("\"\"");
} else {
// double quotes and space are not included
command.add(cmd.substring(i,j));
}
// skip spaces
for (i = j+1; i < len; i++) {
if (!Character.isSpaceChar(cmd.charAt(i))) {
break;
}
}
}
if (isVerbose()) {
System.out.println("Command list:");
for (String s : command) {
System.out.println(s);
}
}
} else {
command.add(getSTclient());
}
return command;
}
// Returns null if the service tag record not found;
// or throw UnauthorizedAccessException or IOException
// based on the exitValue.
private static ServiceTag checkReturnError(int exitValue,
String output,
ServiceTag st) throws IOException {
switch (exitValue) {
case ST_ERR_REC_NOT_FOUND:
return null;
case ST_ERR_NOT_AUTH:
if (st != null) {
throw new UnauthorizedAccessException(
"Not authorized to access " + st.getInstanceURN() +
" installer_uid=" + st.getInstallerUID());
} else {
throw new UnauthorizedAccessException(
"Not authorized:" + output);
}
default:
throw new IOException("stclient exits with error" +
" (" + exitValue + ")\n" + output);
}
}
/**
* Adds a service tag to this registry.
* If the given service tag has an empty <tt>instance_urn</tt>,
* this helper class will generate a URN and place it in the
* copy of the service tag in this registry.
* This method will return the {@code ServiceTag} representing
* the service tag entry to this registry.
*
* @param st {@code ServiceTag} object
* @return a {@code ServiceTag} object representing the service tag
* entry to this registry.
*
* @throws IllegalArgumentException if a service tag of the same
* <tt>instance_urn</tt> already exists in this registry.
*
* @throws java.io.IOException if an I/O error occurs in this operation.
*/
public ServiceTag addServiceTag(ServiceTag st) throws IOException {
List<String> command = getCommandList();
command.add("-a");
if (st.getInstanceURN().length() > 0) {
ServiceTag sysSvcTag = getServiceTag(st.getInstanceURN());
if (sysSvcTag != null) {
throw new IllegalArgumentException("Instance_urn = " +
st.getInstanceURN() + " already exists");
}
command.add("-i");
command.add(st.getInstanceURN());
}
command.add("-p");
command.add(st.getProductName());
command.add("-e");
command.add(st.getProductVersion());
command.add("-t");
command.add(st.getProductURN());
if (st.getProductParentURN().length() > 0) {
command.add("-F");
command.add(st.getProductParentURN());
}
command.add("-P");
command.add(st.getProductParent());
if (st.getProductDefinedInstanceID().length() > 0) {
command.add("-I");
command.add(st.getProductDefinedInstanceID());
}
command.add("-m");
command.add(st.getProductVendor());
command.add("-A");
command.add(st.getPlatformArch());
command.add("-z");
command.add(st.getContainer());
command.add("-S");
command.add(st.getSource());
BufferedReader in = null;
try {
ProcessBuilder pb = new ProcessBuilder(command);
Process p = pb.start();
String output = commandOutput(p);
if (isVerbose()) {
System.out.println("Output from stclient -a command:");
System.out.println(output);
}
String urn = "";
if (p.exitValue() == 0) {
// Obtain the instance urn from the stclient output
in = new BufferedReader(new StringReader(output));
String line = null;
while ((line = in.readLine()) != null) {
line = line.trim();
if (line.startsWith(INSTANCE_URN_DESC)) {
urn = line.substring(INSTANCE_URN_DESC.length());
break;
}
}
if (urn.length() == 0) {
throw new IOException("Error in creating service tag:\n" +
output);
}
return getServiceTag(urn);
} else {
return checkReturnError(p.exitValue(), output, st);
}
} finally {
if (in != null) {
in.close();
}
}
}
/**
* Removes a service tag of the given <tt>instance_urn</tt> from this
* registry.
*
* @param instanceURN the <tt>instance_urn</tt> of the service tag
* to be removed.
*
* @return the {@code ServiceTag} object removed from this registry;
* or {@code null} if the service tag does not exist in this registry.
*
* @throws UnauthorizedAccessException if the user is not authorized to
* remove the service tag of the given <tt>instance_urn</tt>
* from this registry.
*
* @throws java.io.IOException if an I/O error occurs in this operation.
*/
public ServiceTag removeServiceTag(String instanceURN) throws IOException {
ServiceTag st = getServiceTag(instanceURN);
if (st == null) {
return null;
}
List<String> command = getCommandList();
command.add("-d");
command.add("-i");
command.add(instanceURN);
ProcessBuilder pb = new ProcessBuilder(command);
Process p = pb.start();
String output = commandOutput(p);
if (isVerbose()) {
System.out.println("Output from stclient -d command:");
System.out.println(output);
}
if (p.exitValue() == 0) {
return st;
} else {
return checkReturnError(p.exitValue(), output, st);
}
}
/**
* Updates the <tt>product_defined_instance_id</tt> in the service tag
* of the specified <tt>instance_urn</tt> in this registry.
*
* @param instanceURN the <tt>instance_urn</tt> of the service tag to be updated.
* @param productDefinedInstanceID the value of the
* <tt>product_defined_instance_id</tt> to be set.
*
* @return the updated {@code ServiceTag} object;
* or {@code null} if the service tag does not exist in this
* registry.
*
* @throws UnauthorizedAccessException if the user is not authorized to
* update the service tag from this registry.
*
* @throws IOException if an I/O error occurs in this operation.
*/
public ServiceTag updateServiceTag(String instanceURN,
String productDefinedInstanceID)
throws IOException {
ServiceTag svcTag = getServiceTag(instanceURN);
if (svcTag == null) {
return null;
}
List<String> command = getCommandList();
command.add("-u");
command.add("-i");
command.add(instanceURN);
command.add("-I");
if (productDefinedInstanceID.length() > 0) {
command.add(productDefinedInstanceID);
} else {
command.add("\"\"");
}
ProcessBuilder pb = new ProcessBuilder(command);
Process p = pb.start();
String output = commandOutput(p);
if (isVerbose()) {
System.out.println("Output from stclient -u command:");
System.out.println(output);
}
if (p.exitValue() == 0) {
return getServiceTag(instanceURN);
} else {
return checkReturnError(p.exitValue(), output, svcTag);
}
}
/**
* Returns a {@code ServiceTag} object of the given <tt>instance_urn</tt>
* in this registry.
*
* @param instanceURN the <tt>instance_urn</tt> of the service tag
* @return a {@code ServiceTag} object of the given <tt>instance_urn</tt>
* in this registry; or {@code null} if not found.
*
* @throws java.io.IOException if an I/O error occurs in this operation.
*/
public ServiceTag getServiceTag(String instanceURN) throws IOException {
if (instanceURN == null) {
throw new NullPointerException("instanceURN is null");
}
List<String> command = getCommandList();
command.add("-g");
command.add("-i");
command.add(instanceURN);
ProcessBuilder pb = new ProcessBuilder(command);
Process p = pb.start();
String output = commandOutput(p);
if (isVerbose()) {
System.out.println("Output from stclient -g command:");
System.out.println(output);
}
if (p.exitValue() == 0) {
return parseServiceTag(output);
} else {
return checkReturnError(p.exitValue(), output, null);
}
}
private ServiceTag parseServiceTag(String output) throws IOException {
BufferedReader in = null;
try {
Properties props = new Properties();
// parse the service tag output from stclient
in = new BufferedReader(new StringReader(output));
String line = null;
while ((line = in.readLine()) != null) {
if ((line = line.trim()).length() > 0) {
String[] ss = line.trim().split("=", 2);
if (ss.length == 2) {
props.setProperty(ss[0].trim(), ss[1].trim());
} else {
props.setProperty(ss[0].trim(), "");
}
}
}
String urn = props.getProperty(ST_NODE_INSTANCE_URN);
String productName = props.getProperty(ST_NODE_PRODUCT_NAME);
String productVersion = props.getProperty(ST_NODE_PRODUCT_VERSION);
String productURN = props.getProperty(ST_NODE_PRODUCT_URN);
String productParent = props.getProperty(ST_NODE_PRODUCT_PARENT);
String productParentURN = props.getProperty(ST_NODE_PRODUCT_PARENT_URN);
String productDefinedInstanceID =
props.getProperty(ST_NODE_PRODUCT_DEFINED_INST_ID);
String productVendor = props.getProperty(ST_NODE_PRODUCT_VENDOR);
String platformArch = props.getProperty(ST_NODE_PLATFORM_ARCH);
String container = props.getProperty(ST_NODE_CONTAINER);
String source = props.getProperty(ST_NODE_SOURCE);
int installerUID =
Util.getIntValue(props.getProperty(ST_NODE_INSTALLER_UID));
Date timestamp =
Util.parseTimestamp(props.getProperty(ST_NODE_TIMESTAMP));
return new ServiceTag(urn,
productName,
productVersion,
productURN,
productParent,
productParentURN,
productDefinedInstanceID,
productVendor,
platformArch,
container,
source,
installerUID,
timestamp);
} finally {
if (in != null) {
in.close();
}
}
}
/**
* Returns the service tags of the specified
* <tt>product_urn</tt> in this registry.
*
* @param productURN the <tt>product_urn</tt> to look up
* @return a {@code Set} of {@code ServiceTag} objects
* of the specified <tt>product_urn</tt> in this registry.
*
* @throws java.io.IOException if an I/O error occurs in this operation.
*/
public Set<ServiceTag> findServiceTags(String productURN) throws IOException {
if (productURN == null) {
throw new NullPointerException("productURN is null");
}
List<String> command = getCommandList();
command.add("-f");
command.add("-t");
command.add(productURN);
BufferedReader in = null;
try {
ProcessBuilder pb = new ProcessBuilder(command);
Process p = pb.start();
String output = commandOutput(p);
Set<ServiceTag> instances = new HashSet<ServiceTag>();
if (p.exitValue() == 0) {
// parse the service tag output from stclient
in = new BufferedReader(new StringReader(output));
String line = null;
while ((line = in.readLine()) != null) {
String s = line.trim();
if (s.startsWith("urn:st:")) {
instances.add(getServiceTag(s));
}
}
} else {
checkReturnError(p.exitValue(), output, null);
}
return instances;
} finally {
if (in != null) {
in.close();
}
}
}
}

@ -1,634 +0,0 @@
/*
* Copyright (c) 2008, 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 com.sun.servicetag;
import java.util.Date;
import java.io.IOException;
import static com.sun.servicetag.RegistrationDocument.*;
/**
* A service tag is an XML-based data structure that identifies a product or
* a component on a system. The service tag schema is defined by the
* Service Tags Technology. The location of the DTD file is platform dependent.
* On Solaris, see <tt>/usr/share/lib/xml/dtd/servicetag.dtd</tt>.
* <p>
* A valid {@code ServiceTag} instance must comply to the service tag schema
* and contain the following fields:
* <ul>
* <li>{@link #getInstanceURN <tt>instance_urn</tt>}</li>
* <li>{@link #getProductName <tt>product_name</tt>}</li>
* <li>{@link #getProductVersion <tt>product_version</tt>}</li>
* <li>{@link #getProductURN <tt>product_urn</tt>}</li>
* <li>{@link #getProductParent <tt>product_parent</tt>}</li>
* <li>{@link #getProductParentURN <tt>product_parent_urn</tt>}</li>
* <li>{@link #getProductDefinedInstanceID <tt>product_defined_inst_id</tt>}</li>
* <li>{@link #getProductVendor <tt>product_vendor</tt>}</li>
* <li>{@link #getPlatformArch <tt>platform_arch</tt>}</li>
* <li>{@link #getContainer <tt>container</tt>}</li>
* <li>{@link #getSource <tt>source</tt>}</li>
* <li>{@link #getInstallerUID <tt>installer_uid</tt>}</li>
* <li>{@link #getTimestamp <tt>timestamp</tt>}</li>
* </ul>
*
* The <tt>instance_urn</tt> can be specified when a {@code ServiceTag}
* object is created, or it can be generated when it is added to
* a {@link RegistrationData} object, or {@link Registry
* system service tag registry}. The <tt>installer_uid</tt> and
* <tt>timestamp</tt> are set when a {@code ServiceTag} object
* is added to a {@link RegistrationData} object, or {@link Registry
* system service tag registry}.
*
* @see <a href="https://sunconnection.sun.com/FAQ/sc_faq.html">Service Tags FAQ</a>
*/
public class ServiceTag {
private String instanceURN;
private String productName;
private String productVersion;
private String productURN;
private String productParent;
private String productParentURN;
private String productDefinedInstanceID;
private String productVendor;
private String platformArch;
private String container;
private String source;
private int installerUID;
private Date timestamp;
// Service Tag Field Lengths (defined in sthelper.h)
// Since the constants defined in sthelper.h includes the null-terminated
// character, so minus 1 from the sthelper.h defined values.
private final int MAX_URN_LEN = 256 - 1;
private final int MAX_PRODUCT_NAME_LEN = 256 - 1;
private final int MAX_PRODUCT_VERSION_LEN = 64 - 1;
private final int MAX_PRODUCT_PARENT_LEN = 256 - 1;
private final int MAX_PRODUCT_VENDOR_LEN = 64 - 1;
private final int MAX_PLATFORM_ARCH_LEN = 64 - 1;
private final int MAX_CONTAINER_LEN = 64 - 1;
private final int MAX_SOURCE_LEN = 64 - 1;
// private constructors
private ServiceTag() {
}
// package private
ServiceTag(String instanceURN,
String productName,
String productVersion,
String productURN,
String productParent,
String productParentURN,
String productDefinedInstanceID,
String productVendor,
String platformArch,
String container,
String source,
int installerUID,
Date timestamp) {
setInstanceURN(instanceURN);
setProductName(productName);
setProductVersion(productVersion);
setProductURN(productURN);
setProductParentURN(productParentURN);
setProductParent(productParent);
setProductDefinedInstanceID(productDefinedInstanceID);
setProductVendor(productVendor);
setPlatformArch(platformArch);
setContainer(container);
setSource(source);
setInstallerUID(installerUID);
setTimestamp(timestamp);
}
/**
* Creates a service tag object with no <tt>instance_urn</tt>.
*
* @param productName the name of the product.
* @param productVersion the version of the product.
* @param productURN the uniform resource name of the product
* @param productParent the name of the product's parent.
* @param productParentURN the uniform resource name of the product's parent.
* @param productDefinedInstanceID the instance identifier.
* @param productVendor the vendor of the product.
* @param platformArch the operating system architecture.
* @param container the container of the product.
* @param source the source of the product.
*
* @throws IllegalArgumentException if any value of the input fields
* does not conform to the service tag XML schema.
*/
public static ServiceTag newInstance(String productName,
String productVersion,
String productURN,
String productParent,
String productParentURN,
String productDefinedInstanceID,
String productVendor,
String platformArch,
String container,
String source) {
return new ServiceTag("", /* empty instance_urn */
productName,
productVersion,
productURN,
productParent,
productParentURN,
productDefinedInstanceID,
productVendor,
platformArch,
container,
source,
-1,
null);
}
/**
* Creates a service tag object with a specified <tt>instance_urn</tt>.
*
* @param instanceURN the uniform resource name of this instance.
* @param productName the name of the product.
* @param productVersion the version of the product.
* @param productURN the uniform resource name of the product
* @param productParent the name of the product's parent.
* @param productParentURN the uniform resource name of the product's parent.
* @param productDefinedInstanceID the instance identifier.
* @param productVendor the vendor of the product.
* @param platformArch the operating system architecture.
* @param container the container of the product.
* @param source the source of the product.
*
* @throws IllegalArgumentException if any value of the input fields
* does not conform to the service tag XML schema.
*/
public static ServiceTag newInstance(String instanceURN,
String productName,
String productVersion,
String productURN,
String productParent,
String productParentURN,
String productDefinedInstanceID,
String productVendor,
String platformArch,
String container,
String source) {
return new ServiceTag(instanceURN,
productName,
productVersion,
productURN,
productParent,
productParentURN,
productDefinedInstanceID,
productVendor,
platformArch,
container,
source,
-1,
null);
}
// Creates a copy of the ServiceTag instance
// with instance_urn and timestamp initialized
static ServiceTag newInstanceWithUrnTimestamp(ServiceTag st) {
String instanceURN =
(st.getInstanceURN().length() == 0 ? Util.generateURN() :
st.getInstanceURN());
ServiceTag svcTag = new ServiceTag(instanceURN,
st.getProductName(),
st.getProductVersion(),
st.getProductURN(),
st.getProductParent(),
st.getProductParentURN(),
st.getProductDefinedInstanceID(),
st.getProductVendor(),
st.getPlatformArch(),
st.getContainer(),
st.getSource(),
st.getInstallerUID(),
new Date());
return svcTag;
}
/**
* Returns a uniform resource name (URN) in this format:
* <blockquote>
* "<tt>urn:st:<32-char {@link java.util.UUID uuid}></tt>"
* </blockquote>
* @return a URN.
*/
public static String generateInstanceURN() {
return Util.generateURN();
}
/**
* Returns the uniform resource name of this service tag instance.
*
* @return the <tt>instance_urn</tt> of this service tag.
*/
public String getInstanceURN() {
return instanceURN;
}
/**
* Returns the name of the product.
*
* @return the product name.
*/
public String getProductName() {
return productName;
}
/**
* Returns the version of the product.
*
* @return the product version.
*/
public String getProductVersion() {
return productVersion;
}
/**
* Returns the uniform resource name of the product.
*
* @return the product URN.
*/
public String getProductURN() {
return productURN;
}
/**
* Returns the uniform resource name of the product's parent.
*
* @return the product's parent URN.
*/
public String getProductParentURN() {
return productParentURN;
}
/**
* Returns the name of the product's parent.
*
* @return the product's parent name.
*/
public String getProductParent() {
return productParent;
}
/**
* Returns the identifier defined for this product instance.
*
* @return the identifier defined for this product instance.
*/
public String getProductDefinedInstanceID() {
return productDefinedInstanceID;
}
/**
* Returns the vendor of the product.
*
* @return the product vendor.
*/
public String getProductVendor() {
return productVendor;
}
/**
* Returns the platform architecture on which the product
* is running on.
*
* @return the platform architecture on which the product is running on.
*/
public String getPlatformArch() {
return platformArch;
}
/**
* Returns the timestamp. This timestamp is set when this service tag
* is added to or updated in a {@code RegistrationData} object or
* the system service tag registry.
* This method may return {@code null}.
*
* @return timestamp when this service tag
* is added to or updated in a {@code RegistrationData} object or
* the system service tag registry, or {@code null}.
*/
public Date getTimestamp() {
if (timestamp != null) {
return (Date) timestamp.clone();
} else {
return null;
}
}
/**
* Returns the container of the product.
*
* @return the container of the product.
*/
public String getContainer() {
return container;
}
/**
* Returns the source of this service tag.
*
* @return source of this service tag.
*/
public String getSource() {
return source;
}
/**
* Returns the UID. The UID is set when this service tag
* is added to or updated in the system service tag registry.
* This is platform dependent whose default value is {@code -1}.
* When this service tag is added to a {@code RegistrationData},
* the UID is not set.
*
* @return the UID of whom this service tag
* is added to or updated in the system service tag registry,
* or {@code -1}.
*/
public int getInstallerUID() {
return installerUID;
}
// The following setter methods are used to validate the
// input field when constructing a ServiceTag instance
private void setInstanceURN(String instanceURN) {
if (instanceURN == null) {
throw new NullPointerException("Parameter instanceURN cannot be null");
}
if (instanceURN.length() > MAX_URN_LEN) {
throw new IllegalArgumentException("instanceURN \"" + instanceURN +
"\" exceeds maximum length " + MAX_URN_LEN);
}
this.instanceURN = instanceURN;
}
private void setProductName(String productName) {
if (productName == null) {
throw new NullPointerException("Parameter productName cannot be null");
}
if (productName.length() == 0) {
throw new IllegalArgumentException("product name cannot be empty");
}
if (productName.length() > MAX_PRODUCT_NAME_LEN) {
throw new IllegalArgumentException("productName \"" + productName +
"\" exceeds maximum length " + MAX_PRODUCT_NAME_LEN);
}
this.productName = productName;
}
private void setProductVersion(String productVersion) {
if (productVersion == null) {
throw new NullPointerException("Parameter productVersion cannot be null");
}
if (productVersion.length() == 0) {
throw new IllegalArgumentException("product version cannot be empty");
}
if (productVersion.length() > MAX_PRODUCT_VERSION_LEN) {
throw new IllegalArgumentException("productVersion \"" +
productVersion + "\" exceeds maximum length " +
MAX_PRODUCT_VERSION_LEN);
}
this.productVersion = productVersion;
}
private void setProductURN(String productURN) {
if (productURN == null) {
throw new NullPointerException("Parameter productURN cannot be null");
}
if (productURN.length() == 0) {
throw new IllegalArgumentException("product URN cannot be empty");
}
if (productURN.length() > MAX_URN_LEN) {
throw new IllegalArgumentException("productURN \"" + productURN +
"\" exceeds maximum length " + MAX_URN_LEN);
}
this.productURN = productURN;
}
private void setProductParentURN(String productParentURN) {
if (productParentURN == null) {
throw new NullPointerException("Parameter productParentURN cannot be null");
}
// optional field - can be empty
if (productParentURN.length() > MAX_URN_LEN) {
throw new IllegalArgumentException("productParentURN \"" +
productParentURN + "\" exceeds maximum length " +
MAX_URN_LEN);
}
this.productParentURN = productParentURN;
}
private void setProductParent(String productParent) {
if (productParent == null) {
throw new NullPointerException("Parameter productParent cannot be null");
}
if (productParent.length() == 0) {
throw new IllegalArgumentException("product parent cannot be empty");
}
if (productParent.length() > MAX_PRODUCT_PARENT_LEN) {
throw new IllegalArgumentException("productParent \"" +
productParent + "\" exceeds maximum length " +
MAX_PRODUCT_PARENT_LEN);
}
this.productParent = productParent;
}
void setProductDefinedInstanceID(String productDefinedInstanceID) {
if (productDefinedInstanceID == null) {
throw new NullPointerException("Parameter productDefinedInstanceID cannot be null");
}
if (productDefinedInstanceID.length() > MAX_URN_LEN) {
throw new IllegalArgumentException("productDefinedInstanceID \"" +
productDefinedInstanceID + "\" exceeds maximum length " +
MAX_URN_LEN);
}
// optional field - can be empty
this.productDefinedInstanceID = productDefinedInstanceID;
}
private void setProductVendor(String productVendor) {
if (productVendor == null) {
throw new NullPointerException("Parameter productVendor cannot be null");
}
if (productVendor.length() == 0) {
throw new IllegalArgumentException("product vendor cannot be empty");
}
if (productVendor.length() > MAX_PRODUCT_VENDOR_LEN) {
throw new IllegalArgumentException("productVendor \"" +
productVendor + "\" exceeds maximum length " +
MAX_PRODUCT_VENDOR_LEN);
}
this.productVendor = productVendor;
}
private void setPlatformArch(String platformArch) {
if (platformArch == null) {
throw new NullPointerException("Parameter platformArch cannot be null");
}
if (platformArch.length() == 0) {
throw new IllegalArgumentException("platform architecture cannot be empty");
}
if (platformArch.length() > MAX_PLATFORM_ARCH_LEN) {
throw new IllegalArgumentException("platformArch \"" +
platformArch + "\" exceeds maximum length " +
MAX_PLATFORM_ARCH_LEN);
}
this.platformArch = platformArch;
}
private void setTimestamp(Date timestamp) {
// can be null
this.timestamp = timestamp;
}
private void setContainer(String container) {
if (container == null) {
throw new NullPointerException("Parameter container cannot be null");
}
if (container.length() == 0) {
throw new IllegalArgumentException("container cannot be empty");
}
if (container.length() > MAX_CONTAINER_LEN) {
throw new IllegalArgumentException("container \"" +
container + "\" exceeds maximum length " +
MAX_CONTAINER_LEN);
}
this.container = container;
}
private void setSource(String source) {
if (source == null) {
throw new NullPointerException("Parameter source cannot be null");
}
if (source.length() == 0) {
throw new IllegalArgumentException("source cannot be empty");
}
if (source.length() > MAX_SOURCE_LEN) {
throw new IllegalArgumentException("source \"" + source +
"\" exceeds maximum length " + MAX_SOURCE_LEN);
}
this.source = source;
}
private void setInstallerUID(int installerUID) {
this.installerUID = installerUID;
}
/**
* Compares this service tag to the specified object.
* The result is {@code true} if and only if the argument is
* not {@code null} and is a {@code ServiceTag} object whose
* <tt>instance_urn</tt> is the same as the
* <tt>instance_urn</tt> of this service tag.
*
* @return {@code true} if this service tag is the same as
* the specified object.
*/
@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof ServiceTag)) {
return false;
}
ServiceTag st = (ServiceTag) obj;
if (st == this) {
return true;
}
return st.getInstanceURN().equals(getInstanceURN());
}
/**
* Returns the hash code value for this service tag.
* @return the hash code value for this service tag.
*/
@Override
public int hashCode() {
int hash = 7;
hash = 19 * hash + (this.instanceURN != null ? this.instanceURN.hashCode() : 0);
return hash;
}
/**
* Returns the string representation of this service tag.
* The format is implementation specific.
*
* @return the string representation of this service tag.
*/
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(ST_NODE_INSTANCE_URN).append("=").append(instanceURN).append("\n");
sb.append(ST_NODE_PRODUCT_NAME).append("=").append(productName).append("\n");
sb.append(ST_NODE_PRODUCT_VERSION).append("=").append(productVersion).append("\n");
sb.append(ST_NODE_PRODUCT_URN).append("=").append(productURN).append("\n");
sb.append(ST_NODE_PRODUCT_PARENT_URN).append("=").append(productParentURN).append("\n");
sb.append(ST_NODE_PRODUCT_PARENT).append("=").append(productParent).append("\n");
sb.append(ST_NODE_PRODUCT_DEFINED_INST_ID).append("=").append(productDefinedInstanceID).append("\n");
sb.append(ST_NODE_PRODUCT_VENDOR).append("=").append(productVendor).append("\n");
sb.append(ST_NODE_PLATFORM_ARCH).append("=").append(platformArch).append("\n");
sb.append(ST_NODE_TIMESTAMP).append("=").append(Util.formatTimestamp(timestamp)).append("\n");
sb.append(ST_NODE_CONTAINER).append("=").append(container).append("\n");
sb.append(ST_NODE_SOURCE).append("=").append(source).append("\n");
sb.append(ST_NODE_INSTALLER_UID).append("=").append(String.valueOf(installerUID)).append("\n");
return sb.toString();
}
/**
* Returns the {@link ServiceTag} instance for the running Java
* platform. The {@link ServiceTag#setSource source} field
* of the {@code ServiceTag} will be set to the given {@code source}.
* This method will return {@code null} if there is no service tag
* for the running Java platform.
* <p>
* This method is designed for Sun software that bundles the JDK
* or the JRE to use. It is recommended that the {@code source}
* string contains information about the bundling software
* such as the name and the version of the software bundle,
* for example,
* <blockquote>
* <tt>NetBeans IDE 6.0 with JDK 6 Update 5 Bundle</tt>
* </blockquote>
* in a NetBeans/JDK bundle.
* <p>
* At the first time to call this method the application
* is required to have the write permission to the installed
* directory of this running JDK or JRE instance.
*
* @param source the source that bundles the JDK or the JRE.
* @return a {@code ServiceTag} object for the Java platform,
* or {@code null} if not supported.
* @throws IOException if an error occurs in this operation.
*/
public static ServiceTag getJavaServiceTag(String source) throws IOException {
return Installer.getJavaServiceTag(source);
}
}

@ -1,62 +0,0 @@
/*
* Copyright (c) 2008, 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 com.sun.servicetag;
import java.io.IOException;
import java.util.Set;
/**
* Utility class to obtain the service tag for the Solaris Operating System.
*/
class SolarisServiceTag {
private final static String[] SolarisProductURNs = new String[] {
"urn:uuid:a7a38948-2bd5-11d6-98ce-9d3ac1c0cfd7", /* Solaris 8 */
"urn:uuid:4f82caac-36f3-11d6-866b-85f428ef944e", /* Solaris 9 */
"urn:uuid:a19de03b-48bc-11d9-9607-080020a9ed93", /* Solaris 9 sparc */
"urn:uuid:4c35c45b-4955-11d9-9607-080020a9ed93", /* Solaris 9 x86 */
"urn:uuid:5005588c-36f3-11d6-9cec-fc96f718e113", /* Solaris 10 */
"urn:uuid:6df19e63-7ef5-11db-a4bd-080020a9ed93" /* Solaris 11 */
};
/**
* Returns null if not found.
*
* There is only one service tag for the operating system.
*/
static ServiceTag getServiceTag() throws IOException {
if (Registry.isSupported()) {
Registry streg = Registry.getSystemRegistry();
for (String parentURN : SolarisProductURNs) {
Set<ServiceTag> instances = streg.findServiceTags(parentURN);
for (ServiceTag st : instances) {
// there should have only one service tag for the OS
return st;
}
}
}
return null;
}
}

@ -1,159 +0,0 @@
/*
* Copyright (c) 2008, 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 com.sun.servicetag;
// This class is a copy of the com.sun.scn.servicetags.SolarisSystemEnvironment
// class from the Sun Connection source.
//
// The Service Tags team maintains the latest version of the implementation
// for system environment data collection. JDK will include a copy of
// the most recent released version for a JDK release. We rename
// the package to com.sun.servicetag so that the Sun Connection
// product always uses the latest version from the com.sun.scn.servicetags
// package. JDK and users of the com.sun.servicetag API
// (e.g. NetBeans and SunStudio) will use the version in JDK.
//
// So we keep this class in src/share/classes instead of src/<os>/classes.
import java.io.*;
/**
* Solaris implementation of the SystemEnvironment class.
*/
class SolarisSystemEnvironment extends SystemEnvironment {
private static final String ORACLE = "Oracle Corporation";
SolarisSystemEnvironment() {
setHostId(getCommandOutput("/usr/bin/hostid"));
setSystemModel(getCommandOutput("/usr/bin/uname", "-i"));
setSystemManufacturer(getSolarisSystemManufacturer());
setCpuManufacturer(getSolarisCpuManufacturer());
setSerialNumber(getSolarisSN());
}
/**
* Tries to obtain the cpu manufacturer.
* @return The cpu manufacturer (an empty string if not found or an error occurred)
*/
private String getSolarisCpuManufacturer() {
// not fully accurate, this could be another manufacturer (fujitsu for example)
if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) {
return ORACLE;
}
// if we're here, then we'll try smbios (type 4)
return getSmbiosData("4", "Manufacturer: ");
}
/**
* Tries to obtain the system manufacturer.
* @return The system manufacturer (an empty string if not found or an error occurred)
*/
private String getSolarisSystemManufacturer() {
// not fully accurate, this could be another manufacturer (fujitsu for example)
if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) {
return ORACLE;
}
// if we're here, then we'll try smbios (type 1)
return getSmbiosData("1", "Manufacturer: ");
}
/**
* Tries to obtain the serial number.
* @return The serial number (empty string if not found or an error occurred)
*/
private String getSolarisSN() {
// try to read from the psn file if it exists
String tmp = getFileContent("/var/run/psn");
if (tmp.length() > 0) {
return tmp.trim();
}
// if we're here, then we'll try sneep
String tmpSN = getSneepSN();
if (tmpSN.length() > 0) {
return tmpSN;
}
// if we're here, then we'll try smbios (type 1)
tmpSN = getSmbiosData("1", "Serial Number: ");
if (tmpSN.length() > 0) {
return tmpSN;
}
// if we're here, then we'll try smbios (type 3)
tmpSN = getSmbiosData("3", "Serial Number: ");
if (tmpSN.length() > 0) {
return tmpSN;
}
// give up and return
return "";
}
// Sample smbios output segment:
// ID SIZE TYPE
// 1 150 SMB_TYPE_SYSTEM (system information)
//
// Manufacturer: Oracle Corporation
// Product: Sun Fire X4600
// Version: To Be Filled By O.E.M.
// Serial Number: 00:14:4F:45:0C:2A
private String getSmbiosData(String type, String target) {
String output = getCommandOutput("/usr/sbin/smbios", "-t", type);
for (String s : output.split("\n")) {
if (s.contains(target)) {
int indx = s.indexOf(target) + target.length();
if (indx < s.length()) {
String tmp = s.substring(indx).trim();
String lowerCaseStr = tmp.toLowerCase();
if (!lowerCaseStr.startsWith("not available")
&& !lowerCaseStr.startsWith("to be filled by o.e.m")) {
return tmp;
}
}
}
}
return "";
}
private String getSneepSN() {
String basedir = getCommandOutput("pkgparam","SUNWsneep","BASEDIR");
File f = new File(basedir + "/bin/sneep");
if (f.exists()) {
String sneepSN = getCommandOutput(basedir + "/bin/sneep");
if (sneepSN.equalsIgnoreCase("unknown")) {
return "";
} else {
return sneepSN;
}
} else {
return "";
}
}
}

@ -1,297 +0,0 @@
/*
* 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
* 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 com.sun.servicetag;
import java.io.*;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.io.OutputStreamWriter;
import java.util.Locale;
import javax.net.ssl.HttpsURLConnection;
/**
* Sun Connection Class for Product Registration.
*
* Registration Web Application Interface
* 1) POST the product registry to the output stream of the registration
* relay service.
* 2) Open the webapp URL from a browser with the following parameters:
* registry-urn
* product=jdk
* locale=<default-locale>
* version=<version>
*
* @see https://sn-tools.central.sun.com/twiki/pub/ServiceTags/RegistrationRelayService/
*
*/
class SunConnection {
private static String JDK_REGISTRATION_URL = "https://hs-ws1.oracle.com/";
private static String SANDBOX_TESTING_URL = "https://hs-ws1-tst.oracle.com/";
private static String REGISTRATION_WEB_PATH = "RegistrationWeb/register";
// System properties for testing
private static String SVCTAG_REGISTER_TESTING = "servicetag.register.testing";
private static String SVCTAG_REGISTRATION_URL = "servicetag.registration.url";
private static String SVCTAG_CONNECTION_TIMEOUT = "servicetag.connection.timeout";
private SunConnection() {
}
/**
* Returns a URL for JDK registration interfacing with the Sun Connection
* registration relay service in this form:
* <registration-url>/<registry_urn>?product=jdk&locale=<locale>
*
* The <registration-url> can be overridden by an environment
* variable or a system property.
*
* 1) "servicetag.register.testing" system property to switch to the
* Sun Connection registration sandbox testing.
* 2) "servicetag.registration.url" system property to override
* the URL
* 3) Default production URL
*
*/
static URL getRegistrationURL(String registrationURN, Locale locale, String version) {
String url = System.getProperty(SVCTAG_REGISTRATION_URL);
if (url == null) {
if (System.getProperty(SVCTAG_REGISTER_TESTING) != null) {
url = SANDBOX_TESTING_URL;
} else {
url = JDK_REGISTRATION_URL;
}
}
url += REGISTRATION_WEB_PATH;
// trim whitespaces
url = url.trim();
if (url.length() == 0) {
throw new InternalError("Empty registration url set");
}
// Add the registry_urn in the URL's query
String registerURL = rewriteURL(url, registrationURN, locale, version);
try {
return new URL(registerURL);
} catch (MalformedURLException ex) {
// should never reach here
throw new InternalError(ex.getMessage(), ex);
}
}
private static String rewriteURL(String url, String registryURN, Locale locale, String version) {
StringBuilder sb = new StringBuilder(url.trim());
int len = sb.length();
if (sb.charAt(len-1) != '/') {
sb.append('/');
}
sb.append(registryURN);
sb.append("?");
sb.append("product=jdk");
sb.append("&");
sb.append("locale=").append(locale.toString());
sb.append("&");
sb.append("version=").append(version);
return sb.toString();
}
/**
* Registers all products in the given product registry. If it fails
* to post the service tag registry, open the browser with the offline
* registration page.
*
* @param regData registration data to be posted to the Sun Connection
* for registration.
* @param locale Locale
* @param version JDK version
*
* @throws IOException if I/O error occurs in this operation
*/
public static void register(RegistrationData regData,
Locale locale,
String version) throws IOException {
// Gets the URL for SunConnection registration relay service
URL url = getRegistrationURL(regData.getRegistrationURN(),
locale,
version);
// Post the Product Registry to Sun Connection
boolean succeed = postRegistrationData(url, regData);
if (succeed) {
// service tags posted successfully
// now prompt for registration
openBrowser(url);
} else {
// open browser with the offline registration page
openOfflineRegisterPage();
}
}
/**
* Opens a browser for JDK product registration.
* @param url Registration Webapp URL
*/
private static void openBrowser(URL url) throws IOException {
if (!BrowserSupport.isSupported()) {
if (Util.isVerbose()) {
System.out.println("Browser is not supported");
}
return;
}
try {
BrowserSupport.browse(url.toURI());
} catch (URISyntaxException ex) {
throw new InternalError("Error in registering: " + ex.getMessage(), ex);
} catch (IllegalArgumentException ex) {
if (Util.isVerbose()) {
ex.printStackTrace();
}
} catch (UnsupportedOperationException ex) {
// ignore if not supported
if (Util.isVerbose()) {
ex.printStackTrace();
}
}
}
/**
* POST service tag registry to Sun Connection
* @param loc the URL of the webapp to handle the POST request
* @param streg the Service Tag registry
* @return true if posting succeeds; otherwise, false.
*/
private static boolean postRegistrationData(URL url,
RegistrationData registration) {
try {
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setAllowUserInteraction(false);
// default 10 seconds timeout
String timeout = System.getProperty(SVCTAG_CONNECTION_TIMEOUT, "10");
con.setConnectTimeout(Util.getIntValue(timeout) * 1000);
if (Util.isVerbose()) {
System.out.println("Connecting to post registration data at " + url);
}
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\"");
con.connect();
OutputStream out = null;
try {
out = con.getOutputStream();
registration.storeToXML(out);
out.flush();
} finally {
if (out != null) {
out.close();
}
}
int returnCode = con.getResponseCode();
if (Util.isVerbose()) {
System.out.println("POST return status = " + returnCode);
printReturnData(con, returnCode);
}
return (returnCode == HttpURLConnection.HTTP_OK);
} catch (MalformedURLException me) {
// should never reach here
throw new InternalError("Error in registering: " + me.getMessage(), me);
} catch (Exception ioe) {
// SocketTimeoutException, IOException or UnknownHostException
if (Util.isVerbose()) {
ioe.printStackTrace();
}
return false;
}
}
/**
* Opens the offline registratioin page in the browser.
*
*/
private static void openOfflineRegisterPage()
throws IOException {
if (!BrowserSupport.isSupported()) {
if (Util.isVerbose()) {
System.out.println("Browser is not supported");
}
return;
}
File registerPage = Installer.getRegistrationHtmlPage();
try {
BrowserSupport.browse(registerPage.toURI());
} catch (FileNotFoundException ex) {
// should never reach here
throw new InternalError(
"Error in launching " + registerPage + ": " + ex.getMessage()
, ex);
} catch (IllegalArgumentException ex) {
if (Util.isVerbose()) {
ex.printStackTrace();
}
} catch (UnsupportedOperationException ex) {
// ignore if not supported
if (Util.isVerbose()) {
ex.printStackTrace();
}
}
}
private static void printReturnData(HttpURLConnection con, int returnCode)
throws IOException {
BufferedReader reader = null;
try {
if (returnCode < 400) {
reader = new BufferedReader(
new InputStreamReader(con.getInputStream()));
} else {
reader = new BufferedReader(
new InputStreamReader(con.getErrorStream()));
}
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
System.out.println("Response is : ");
System.out.println(sb.toString());
} finally {
if (reader != null) {
reader.close();
}
}
}
}

@ -1,338 +0,0 @@
/*
* Copyright (c) 2008, 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 com.sun.servicetag;
// This class is a copy of the com.sun.scn.servicetags.SystemEnvironment
// class from the Sun Connection source.
//
// The Service Tags team maintains the latest version of the implementation
// for system environment data collection. JDK will include a copy of
// the most recent released version for a JDK release. We rename
// the package to com.sun.servicetag so that the Sun Connection
// product always uses the latest version from the com.sun.scn.servicetags
// package. JDK and users of the com.sun.servicetag API
// (e.g. NetBeans and SunStudio) will use the version in JDK.
import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* SystemEnvironment class collects the environment data with the
* best effort from the underlying platform.
*/
public class SystemEnvironment {
private String hostname;
private String hostId;
private String osName;
private String osVersion;
private String osArchitecture;
private String systemModel;
private String systemManufacturer;
private String cpuManufacturer;
private String serialNumber;
private static SystemEnvironment sysEnv = null;
public static synchronized SystemEnvironment getSystemEnvironment() {
if (sysEnv == null) {
String os = System.getProperty("os.name");
if (os.equals("SunOS")) {
sysEnv = new SolarisSystemEnvironment();
} else if (os.equals("Linux")) {
sysEnv = new LinuxSystemEnvironment();
} else if (os.startsWith("Windows")) {
sysEnv = new WindowsSystemEnvironment();
} else {
sysEnv = new SystemEnvironment();
}
}
return sysEnv;
}
// package-private
SystemEnvironment() {
try {
this.hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException ex) {
this.hostname = "Unknown host";
}
this.hostId = "";
this.osName = System.getProperty("os.name");
this.osVersion = System.getProperty("os.version");
this.osArchitecture = System.getProperty("os.arch");
this.systemModel = "";
this.systemManufacturer = "";
this.cpuManufacturer = "";
this.serialNumber = "";
}
/**
* Sets the hostname.
* @param hostname The hostname to set.
*/
public void setHostname(String hostname) {
this.hostname = hostname;
}
/**
* Sets the OS name.
* @param osName The osName to set.
*/
public void setOsName(String osName) {
this.osName = osName;
}
/**
* Sets the OS version.
* @param osVersion The osVersion to set.
*/
public void setOsVersion(String osVersion) {
this.osVersion = osVersion;
}
/**
* Sets the OS architecture.
* @param osArchitecture The osArchitecture to set.
*/
public void setOsArchitecture(String osArchitecture) {
this.osArchitecture = osArchitecture;
}
/**
* Sets the system model.
* @param systemModel The systemModel to set.
*/
public void setSystemModel(String systemModel) {
this.systemModel = systemModel;
}
/**
* Sets the system manufacturer.
* @param systemManufacturer The systemManufacturer to set.
*/
public void setSystemManufacturer(String systemManufacturer) {
this.systemManufacturer = systemManufacturer;
}
/**
* Sets the cpu manufacturer.
* @param cpuManufacturer The cpuManufacturer to set.
*/
public void setCpuManufacturer(String cpuManufacturer) {
this.cpuManufacturer = cpuManufacturer;
}
/**
* Sets the serial number.
* @param serialNumber The serialNumber to set.
*/
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
/**
* Sets the hostid. Truncates to a max length of 16 chars.
* @param hostId The hostid to set.
*/
public void setHostId(String hostId) {
if (hostId == null || hostId.equals("null")) {
hostId = "";
}
if (hostId.length() > 16) {
hostId = hostId.substring(0,16);
}
this.hostId = hostId;
}
/**
* Returns the hostname.
* @return The hostname.
*/
public String getHostname() {
return hostname;
}
/**
* Returns the osName.
* @return The osName.
*/
public String getOsName() {
return osName;
}
/**
* Returns the osVersion.
* @return The osVersion.
*/
public String getOsVersion() {
return osVersion;
}
/**
* Returns the osArchitecture.
* @return The osArchitecture.
*/
public String getOsArchitecture() {
return osArchitecture;
}
/**
* Returns the systemModel.
* @return The systemModel.
*/
public String getSystemModel() {
return systemModel;
}
/**
* Returns the systemManufacturer.
* @return The systemManufacturer.
*/
public String getSystemManufacturer() {
return systemManufacturer;
}
/**
* Returns the serialNumber.
* @return The serialNumber.
*/
public String getSerialNumber() {
return serialNumber;
}
/**
* Returns the hostId.
* @return The hostId.
*/
public String getHostId() {
return hostId;
}
/**
* Returns the cpuManufacturer.
* @return The cpuManufacturer.
*/
public String getCpuManufacturer() {
return cpuManufacturer;
}
protected String getCommandOutput(String... command) {
StringBuilder sb = new StringBuilder();
BufferedReader br = null;
Process p = null;
try {
ProcessBuilder pb = new ProcessBuilder(command);
p = pb.start();
p.waitFor();
if (p.exitValue() == 0) {
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
line = line.trim();
if (line.length() > 0) {
if (sb.length() > 0) {
sb.append("\n");
}
sb.append(line);
}
}
}
return sb.toString();
} catch (InterruptedException ie) {
// in case the command hangs
if (p != null) {
p.destroy();
}
return "";
} catch (Exception e) {
// ignore exception
return "";
} finally {
if (p != null) {
try {
p.getErrorStream().close();
} catch (IOException e) {
// ignore
}
try {
p.getInputStream().close();
} catch (IOException e) {
// ignore
}
try {
p.getOutputStream().close();
} catch (IOException e) {
// ignore
}
p = null;
}
if (br != null) {
try {
br.close();
} catch (IOException e) {
// ignore
}
}
}
}
protected String getFileContent(String filename) {
File f = new File(filename);
if (!f.exists()) {
return "";
}
StringBuilder sb = new StringBuilder();
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(f));
String line = null;
while ((line = br.readLine()) != null) {
line = line.trim();
if (line.length() > 0) {
if (sb.length() > 0) {
sb.append("\n");
}
sb.append(line);
}
}
return sb.toString();
} catch (Exception e) {
// ignore exception
return "";
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
// ignore
}
}
}
}
}

@ -1,339 +0,0 @@
/*
* Copyright (c) 2008, 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 com.sun.servicetag;
import java.io.*;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.TimeZone;
import java.util.UUID;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
// Utility class for com.sun.servicetag package
class Util {
private static boolean verbose = (System.getProperty("servicetag.verbose") != null);
private static String jrepath = null;
private static final String REGKEY_TAIL =
"microsoft\\windows\\currentversion\\app paths\\stclient.exe";
private static final String STCLIENT_TAIL = "sun\\servicetag\\stclient.exe";
private static final String WIN32_STCLIENT =
"c:\\Program Files (x86)\\" + STCLIENT_TAIL;
// for debugging and tracing
static boolean isVerbose() {
return verbose;
}
/**
* Gets the pathname of JRE in the running platform
* This can be a JDK or JRE.
*/
static synchronized String getJrePath() {
if (jrepath == null) {
// Determine the JRE path by checking the existence of
// <HOME>/jre/lib and <HOME>/lib.
String javaHome = System.getProperty("java.home");
jrepath = javaHome + File.separator + "jre";
File f = new File(jrepath, "lib");
if (!f.exists()) {
// java.home usually points to the JRE path
jrepath = javaHome;
}
}
return jrepath;
}
/**
* Tests if the running platform is a JDK.
*/
static boolean isJdk() {
// <HOME>/jre exists which implies it's a JDK
return getJrePath().endsWith(File.separator + "jre");
}
/**
* Generates the URN string of "urn:st" namespace
*/
static String generateURN() {
return "urn:st:" + UUID.randomUUID().toString();
}
static int getIntValue(String value) {
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("\"" + value + "\"" +
" expected to be an integer");
}
}
/**
* Formats the Date into a timestamp string in YYYY-MM-dd HH:mm:ss GMT.
* @param timestamp Date
* @return a string representation of the timestamp
* in the YYYY-MM-dd HH:mm:ss GMT format.
*/
static String formatTimestamp(Date timestamp) {
if (timestamp == null) {
return "[No timestamp]";
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
return df.format(timestamp);
}
/**
* Parses a timestamp string in YYYY-MM-dd HH:mm:ss GMT format.
* @param timestamp Timestamp in the YYYY-MM-dd HH:mm:ss GMT format.
* @return Date
*/
static Date parseTimestamp(String timestamp) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
try {
return df.parse(timestamp);
} catch (ParseException e) {
// should not reach here
e.printStackTrace();
return new Date();
}
}
static String commandOutput(Process p) throws IOException {
Reader r = null;
Reader err = null;
try {
r = new InputStreamReader(p.getInputStream());
err = new InputStreamReader(p.getErrorStream());
String output = commandOutput(r);
String errorMsg = commandOutput(err);
p.waitFor();
return output + errorMsg.trim();
} catch (InterruptedException e) {
if (isVerbose()) {
e.printStackTrace();
}
return e.getMessage();
} finally {
try {
if (r != null) {
r.close();
}
} finally {
if (err != null) {
err.close();
}
}
}
}
static String commandOutput(Reader r) throws IOException {
StringBuilder sb = new StringBuilder();
int c;
while ((c = r.read()) > 0) {
if (c != '\r') {
sb.append((char) c);
}
}
return sb.toString();
}
static int getJdkVersion() {
parseVersion();
return jdkVersion;
}
static int getUpdateVersion() {
parseVersion();
return jdkUpdate;
}
private static int jdkVersion = 0;
private static int jdkUpdate = 0;
private static synchronized void parseVersion() {
if (jdkVersion > 0) {
return;
}
// parse java.runtime.version
// valid format of the version string is:
// n.n.n[_uu[c]][-<identifer>]-bxx
String cs = System.getProperty("java.runtime.version");
if (cs.length() >= 5 &&
Character.isDigit(cs.charAt(0)) && cs.charAt(1) == '.' &&
Character.isDigit(cs.charAt(2)) && cs.charAt(3) == '.' &&
Character.isDigit(cs.charAt(4))) {
jdkVersion = Character.digit(cs.charAt(2), 10);
cs = cs.substring(5, cs.length());
if (cs.charAt(0) == '_' && cs.length() >= 3 &&
Character.isDigit(cs.charAt(1)) &&
Character.isDigit(cs.charAt(2))) {
int nextChar = 3;
try {
String uu = cs.substring(1, 3);
jdkUpdate = Integer.valueOf(uu).intValue();
} catch (NumberFormatException e) {
// not conforming to the naming convention
return;
}
}
} else {
throw new InternalError("Invalid java.runtime.version" + cs);
}
}
/**
* Returns this java string as a null-terminated byte array
*/
private static byte[] stringToByteArray(String str) {
return (str + "\u0000").getBytes();
}
/**
* Converts a null-terminated byte array to java string
*/
private static String byteArrayToString(byte[] array) {
return new String(array, 0, array.length -1);
}
/**
* Gets the stclient path using a well known location from
* the Windows platform Registry, ensuring the path returned
* by the registry is really the one we are looking for,
* otherwise it will return null.
*/
private static File getWindowsStClientFile(boolean wow64) {
File out = null;
String regKey = (wow64 == true)
? "software\\Wow6432Node\\" + REGKEY_TAIL
: "software\\" + REGKEY_TAIL;
String keyName = "" ; // use the default key
String path = getRegistryKey(regKey, keyName);
if (path != null
&& (new File(path)).exists()
&& path.toLowerCase().endsWith(STCLIENT_TAIL.toLowerCase())) {
out = new File(path);
}
if (isVerbose()) {
System.out.println("stclient=" + out);
}
return out;
}
/**
* Finds a stclient in 32 and 64 bit environments, first by querying
* the windows registry, if not then get the well known paths for
* 64bit see http://support.microsoft.com/kb/896459
*/
static File getWindowsStClientFile() {
File stclient = null;
if (System.getProperty("os.arch").equals("x86")) {
// try to get the default entry
stclient = getWindowsStClientFile(false);
if (stclient != null) {
return stclient;
}
} else { // we are on 64-bit system
// try the wow64 area
stclient = getWindowsStClientFile(true);
if (stclient != null) {
return stclient;
}
// try the default hard coded path, maybe wow64 registry is missing
stclient = new File(WIN32_STCLIENT);
if (stclient.canExecute()) {
if (isVerbose()) {
System.out.println("stclient(default)=" + stclient);
}
return stclient;
}
}
if (isVerbose()) {
System.out.println("stclient not found");
}
return null;
}
/**
* This uses reflection to access a private java windows registry
* interface, any changes to that Class must be appropriately adjusted.
* Returns a null if unsuccessful.
*/
private static String getRegistryKey(String regKey, String keyName) {
String out = null;
try {
Class<?> clazz = Class.forName("java.util.prefs.WindowsPreferences");
// Get the registry methods
Method winRegOpenKeyM = clazz.getDeclaredMethod("WindowsRegOpenKey",
int.class, byte[].class, int.class);
winRegOpenKeyM.setAccessible(true);
Method winRegCloseKeyM = clazz.getDeclaredMethod("WindowsRegCloseKey",
int.class);
winRegCloseKeyM.setAccessible(true);
Method winRegQueryValueM = clazz.getDeclaredMethod("WindowsRegQueryValueEx",
int.class, byte[].class);
winRegQueryValueM.setAccessible(true);
// Get all the constants we need
int HKLM = getValueFromStaticField("HKEY_LOCAL_MACHINE", clazz);
int KEY_READ = getValueFromStaticField("KEY_READ", clazz);
int ERROR_CODE = getValueFromStaticField("ERROR_CODE", clazz);
int NATIVE_HANDLE = getValueFromStaticField("NATIVE_HANDLE", clazz);
int ERROR_SUCCESS = getValueFromStaticField("ERROR_SUCCESS", clazz);
// Convert keys
byte[] reg = stringToByteArray(regKey);
byte[] key = stringToByteArray(keyName);
// Open the registry
int[] result = (int[]) winRegOpenKeyM.invoke(null, HKLM, reg, KEY_READ);
if (result[ERROR_CODE] == ERROR_SUCCESS) {
byte[] stvalue = (byte[]) winRegQueryValueM.invoke(null,
result[NATIVE_HANDLE], key);
out = byteArrayToString(stvalue);
winRegCloseKeyM.invoke(null, result[NATIVE_HANDLE]);
}
} catch (Exception ex) {
if (isVerbose()) {
ex.printStackTrace();
}
}
return out;
}
private static int getValueFromStaticField(String fldName, Class<?> klass) throws Exception {
Field f = klass.getDeclaredField(fldName);
f.setAccessible(true);
return f.getInt(null);
}
}

@ -1,150 +0,0 @@
/*
* Copyright (c) 2008, 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 com.sun.servicetag;
// This class is a copy of the com.sun.scn.servicetags.WindowsSystemEnvironment
// class from the Sun Connection source.
//
// The Service Tags team maintains the latest version of the implementation
// for system environment data collection. JDK will include a copy of
// the most recent released version for a JDK release. We rename
// the package to com.sun.servicetag so that the Sun Connection
// product always uses the latest version from the com.sun.scn.servicetags
// package. JDK and users of the com.sun.servicetag API
// (e.g. NetBeans and SunStudio) will use the version in JDK.
//
// So we keep this class in src/share/classes instead of src/<os>/classes.
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* Windows implementation of the SystemEnvironment class.
*/
class WindowsSystemEnvironment extends SystemEnvironment {
WindowsSystemEnvironment() {
super();
// run a call to make sure things are initialized
// ignore the first call result as the system may
// give inconsistent data on the first invocation ever
getWmicResult("computersystem", "get", "model");
setSystemModel(getWmicResult("computersystem", "get", "model"));
setSystemManufacturer(getWmicResult("computersystem", "get", "manufacturer"));
setSerialNumber(getWmicResult("bios", "get", "serialnumber"));
String cpuMfr = getWmicResult("cpu", "get", "manufacturer");
// this isn't as good an option, but if we couldn't get anything
// from wmic, try the processor_identifier
if (cpuMfr.length() == 0) {
String procId = System.getenv("processor_identifer");
if (procId != null) {
String[] s = procId.split(",");
cpuMfr = s[s.length - 1].trim();
}
}
setCpuManufacturer(cpuMfr);
// try to remove the temp file that gets created from running wmic cmds
try {
// look in the current working directory
File f = new File("TempWmicBatchFile.bat");
if (f.exists()) {
f.delete();
}
} catch (Exception e) {
// ignore the exception
}
}
/**
* This method invokes wmic outside of the normal environment
* collection routines.
*
* An initial call to wmic can be costly in terms of time.
*
* <code>
* Details of why the first call is costly can be found at:
*
* http://support.microsoft.com/kb/290216/en-us
*
* "When you run the Wmic.exe utility for the first time, the utility
* compiles its .mof files into the repository. To save time during
* Windows installation, this operation takes place as necessary."
* </code>
*/
private String getWmicResult(String alias, String verb, String property) {
String res = "";
BufferedReader in = null;
try {
ProcessBuilder pb = new ProcessBuilder("cmd", "/C", "WMIC", alias, verb, property);
Process p = pb.start();
// need this for executing windows commands (at least
// needed for executing wmic command)
BufferedWriter bw = null;
try {
bw = new BufferedWriter(
new OutputStreamWriter(p.getOutputStream()));
bw.write(13);
bw.flush();
} finally {
if (bw != null) {
bw.close();
}
}
p.waitFor();
if (p.exitValue() == 0) {
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
line = line.trim();
if (line.length() == 0) {
continue;
}
res = line;
}
// return the *last* line read
return res;
}
} catch (Exception e) {
// ignore the exception
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
// ignore
}
}
}
return res.trim();
}
}

@ -1,71 +0,0 @@
CTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
Copyright (c) 2008, 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.
-->
</head>
<body bgcolor="white">
This package contains classes that allow the creation
and manipulation of service tags.
This com.sun.servicetag package is intended for
<b>Sun internal use</b> only.
<p>
<dl>
<dt><b>Service Tag</b></dt>
<dd>A service tag is an XML-based data structure that contains identifying
information about an instance of a product or component on a system.
</dd>
</dl>
<dl>
<dt><b>Service Tag Registry</b></dt>
<dd>A service tag registry is a XML-based registry that contains
the service tags of all the tagged components on a system. The
service tag registry is present on systems that have the
Service Tags software installed.
</dd>
</dl>
<dl>
<dt><b>Registration Data</b></dt>
<dd>A registration data is a container of one or more
service tags that identify the
components for product registration and will be used to interface
with the Sun Connection registration services.
</dd>
</dl>
This package contains the methods to create service tags, set up the
registration data for product registration, add service tags to and
remove them from the system service tag registry.
<p>
All methods defined in this package will throw {@code NullPointerException}
if {@code null} is passed in any input parameter unless it is stated otherwise.
In addition, they are multi-thread safe.
</body>
</html>

@ -1,25 +0,0 @@
README for auto-generating of the offline registration page.
1. register.html is defined by the xDesign team.
2. Before putback in the workspace, we need to modify the
register.html to contain the following:
(a) replace the pathname of the jdk_header.png image to
<img src="@@JDK_HEADER_PNG@@" ....>
(b) replace the product name from:
Java Development Kit Version 6 Update 5 (e.g.)
to:
Java Development Kit @@JDK_VERSION@@
(c) replace the form action for the "Register My JDK" button with:
<form name="form1" method="post" action="@@REGISTRATION_URL@@" enctype="text/xml">
(d) Add this input in the form for posting data after
the <form name=....> line:
<input type="hidden" name="servicetag_payload" value="@@REGISTRATION_PAYLOAD@@">
3. The jdk_header.png is located under <JRE>/lib/servicetag directory.

@ -1,29 +0,0 @@
# Copyright (c) 2008, 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.
servicetag.jdk.urn = urn:uuid:d5bed446-05f2-42ed-ba0a-153105a52413
servicetag.jdk.name = J2SE 5.0 Development Kit
servicetag.jre.urn = urn:uuid:5c6686aa-fd05-46a6-ba3e-700e2d5f7043
servicetag.jre.name = J2SE 5.0 Runtime Environment
servicetag.parent.urn = urn:uuid:f3c20172-557a-11d7-93d0-d6a41ea318df
servicetag.parent.name = Java 2 Platform, Standard Edition 5.0

@ -1,29 +0,0 @@
# Copyright (c) 2008, 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.
servicetag.jdk.urn = urn:uuid:b58ef9a8-5ae8-11db-a023-080020a9ed93
servicetag.jdk.name = Java SE 6 Development Kit
servicetag.jre.urn = urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc
servicetag.jre.name = Java SE 6 Runtime Environment
servicetag.parent.urn = urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
servicetag.parent.name = Java Platform Standard Edition 6 (Java SE 6)

@ -1,29 +0,0 @@
# Copyright (c) 2008, 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.
servicetag.jdk.urn = JSEZ9-007-ZZZZ
servicetag.jdk.name = Java SE 7 Development Kit
servicetag.jre.urn = JSERE-007-ZZZZ
servicetag.jre.name = Java SE 7 Runtime Environment
servicetag.parent.urn = urn:uuid:dc1704fe-264f-11dc-9482-080020a9ed93
servicetag.parent.name = Java Platform Standard Edition 7 (Java SE 7)

@ -1,29 +0,0 @@
# 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.
servicetag.jdk.urn = Q8549
servicetag.jdk.name = Java Development Kit
servicetag.jre.urn = Q8549
servicetag.jre.name = Java Runtime Environment
servicetag.parent.urn = Q8549
servicetag.parent.name = Java Platform, Standard Edition

Binary file not shown.

Before

(image error) Size: 8.5 KiB

@ -1,301 +0,0 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="registration_data">
<xs:complexType>
<xs:sequence>
<xs:element name="environment"
minOccurs="1"
maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element ref="hostname"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="hostId"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="osName"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="osVersion"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="osArchitecture"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="systemModel"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="systemManufacturer"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="cpuManufacturer"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="serialNumber"
minOccurs='1'
maxOccurs='1'/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="registry"
minOccurs="1"
maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="service_tag"
minOccurs="0"
maxOccurs="1024">
<xs:complexType>
<xs:sequence>
<xs:element ref="instance_urn"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="product_name"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="product_version"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="product_urn"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="product_parent_urn"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="product_parent"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="product_defined_inst_id"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="product_vendor"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="platform_arch"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="timestamp"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="container"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="source"
minOccurs='1'
maxOccurs='1'/>
<xs:element ref="installer_uid"
minOccurs='1'
maxOccurs='1'/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="urn"
type="xs:string"
use="required"/>
<xs:attribute name="version"
type="xs:string"
use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="version"
type="xs:string"
use="required"/>
</xs:complexType>
</xs:element>
<!-- definition of simple elements -->
<xs:element name="hostname">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="hostId">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="16"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="osName">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="256"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="osVersion">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="osArchitecture">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="256"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="systemModel">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="systemManufacturer">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="cpuManufacturer">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="serialNumber">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="256"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="instance_urn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="product_name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="product_version">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="63"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="product_urn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="product_parent_urn">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="product_parent">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="product_defined_inst_id">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="product_vendor">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="63"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="platform_arch">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="63"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="timestamp">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="24"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="container">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="63"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="source">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="63"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="installer_uid">
<xs:simpleType>
<xs:restriction base="xs:integer">
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>

@ -1,105 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Register your JDK</title>
<!--
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.
-->
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
.style3 {font-family: Arial, Helvetica, sans-serif; font-size: small; }
input.buttonblue,input.defbutton{ background: #3F6580;border-right:1px solid #304C60;border-bottom:1px solid #304C60;border-left:1px solid #BACDD9;border-top:1px solid #BACDD9; font-weight:bold; color:#FFFFFF; font-size:.8em; height:1.9em}
input.buttonblue:hover{color:#fbe249;}
a:link,a.named:visited{color:#3E6B8A}
a:hover{text-decoration:underline}
a{text-decoration:none}
a:visited,a:visited code{color:#917E9C}
-->
</style>
</head>
<body>
<table width="813" border="0" cellpadding="3" cellspacing="0">
<tr>
<td width="7" height="78">&nbsp;</td>
<td width="794" align="left" valign="top">
<img src="@@JDK_HEADER_PNG@@" width="783" height="63"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><p class="style1">Thank you for installing the
<strong> Java Development Kit @@JDK_VERSION@@ </strong>
from Oracle Corporation. </p>
<p class="style1">Registering your product will give you the following benefits:</p>
<ul class="style1">
<li> Notification of new versions, patches, and updates</li>
<li> Special offers on Oracle developer products, services and training </li>
<li> Access to early releases and documentation </li>
</ul>
<p class="style1">Product registration is FREE, quick and easy!</p>
<blockquote>
<p class="style1">All you need is an Oracle.com account. If you don't already have one, you will be prompted to create one. </p>
<table width="708" border="0" cellspacing="0" cellpadding="3">
<tr valign="top">
<td width="126" height="35">
<form name="form1" method="post" action="@@REGISTRATION_URL@@" enctype="text/xml">
<input type="hidden" name="servicetag_payload" value="@@REGISTRATION_PAYLOAD@@">
<input type="submit" name="Submit"border="0" class="buttonblue" onmouseover="this.style.color='#fbe249';" onmouseout="this.style.color='#FFF';" value="Register My JDK">
</form></td>
<td width="570"><span class="style3">You need to be connected to the Internet to register this Oracle product. </span></td>
</tr>
</table>
</blockquote>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td bgcolor="#f1f7df">
<p class="style3">Oracle Corporation respects your privacy.
We will use your personal information for communications
and management of your Oracle.com account, the services
and applications you access using your Oracle.com account,
and the products and systems you register with your Oracle.com account.</p>
<p class="style3">For more information on the data that will be collected as
part of the registration process and how it will be managed <br>
see <a href="http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html</a>. <br>
<br>
For more information on Oracle's Privacy Policy see <a href="http://www.oracle.com/html/privacy.html">http://www.oracle.com/html/privacy.html</a> or contact <a class="moz-txt-link-rfc2396E" href="mailto:privacy_ww@oracle.com">privacy_ww@oracle.com.</a></p></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>

@ -1,91 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.or
g/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>JDK 製品登録</title>
<!--
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.
-->
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
.style3 {font-family: Arial, Helvetica, sans-serif; font-size: small; }
input.buttonblue,input.defbutton{ background: #3F6580;border-right:1px solid #304C60;border-bottom:1px solid #304C60;border-left:1px solid #BACDD9;border-top:1px solid #BACDD9; font-weight:bold; color:#FFFFFF; font-size:.8em; height:1.9em}
input.buttonblue:hover{color:#fbe249;}
a:link,a.named:visited{color:#3E6B8A}
a:hover{text-decoration:underline}
a{text-decoration:none}
a:visited,a:visited code{color:#917E9C}
-->
</style></head><body>
<table border="0" cellpadding="3" cellspacing="0" width="813">
<tbody><tr>
<td height="78" width="7">&nbsp;</td>
<td align="left" valign="top" width="794"><img src="@@JDK_HEADER_PNG@@" height="63" width="783"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><p class="style1">Oracle Corporation の<strong> Java Development Kit @@JDK_VERSION@@ </strong>をインストールしていただき、ありがとうございます。 </p>
<p class="style1">製品登録をすると、次のような特典を受けることができます。</p>
<ul class="style1">
<li> 最新のバージョン、パッチ、および更新についての通知</li>
<li> Oracle の開発者向け製品、サービス、およびトレーニングの特別販売 </li>
<li> アーリーリリースおよびドキュメントへのアクセス </li>
</ul>
<p class="style1">製品登録は無料であり、迅速で簡単です。</p>
<blockquote>
<p class="style1">必要になるのは、Oracle.com アカウントだけです。 まだアカウントがない場合は、アカウントの作成が求められます。 </p>
<table width="708" border="0" cellspacing="0" cellpadding="3">
<tr valign="top">
<td width="126" height="35"><form name="form1" method="post" action="@@REGISTRATION_URL@@" enctype="text/xml">
<input type="hidden" name="servicetag_payload" value="@@REGISTRATION_PAYLOAD@@">
<input type="submit" name="Submit"border="0" class="buttonblue" onmouseover="this.style.color='#fbe249';" onmouseout="this.style.color='#FFF';" value="JDK 製品登録">
</form></td>
<td width="570"><span class="style3">この Oracle 製品を登録するには、インターネットに接続している必要があります。 </span></td>
</tr>
</table>
</blockquote>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td bgcolor="#f1f7df">
<p class="style3">Oracle Corporation は、お客様のプライバシーを尊重します。 お客様の個人情報は、お客様の Oracle.com アカウント、お客様が Oracle.com アカウントを使用してアクセスするサービスとアプリケーション、およびお客様が Oracle.com アカウントで登録する製品とシステムの通信と管理に使用します。</p>
<p class="style3">登録の際に収集されるデータや、それらがどのように管理されるかについての詳細は、<br><a href="http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html</a> を参照してください。 <br> <br> Oracle のプライバシーポリシーについての詳細は、<a href="http://www.oracle.com/html/privacy.html">http://www.oracle.com/html/privacy.html</a> を参照するか、<a class="moz-txt-link-rfc2396E" href="mailto:privacy_ww@oracle.com">お問い合わせフォーム</a>からお問い合わせください。</p></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>

@ -1,92 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册您的 JDK</title>
<!--
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.
-->
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
.style3 {font-family: Arial, Helvetica, sans-serif; font-size: small; }
input.buttonblue,input.defbutton{ background: #3F6580;border-right:1px solid #304C60;border-bottom:1px solid #304C60;border-left:1px solid #BACDD9;border-top:1px solid #BACDD9; font-weight:bold; color:#FFFFFF; font-size:.8em; height:1.9em}
input.buttonblue:hover{color:#fbe249;}
a:link,a.named:visited{color:#3E6B8A}
a:hover{text-decoration:underline}
a{text-decoration:none}
a:visited,a:visited code{color:#917E9C}
-->
</style></head><body>
<table border="0" cellpadding="3" cellspacing="0" width="813">
<tbody><tr>
<td height="78" width="7">&nbsp;</td>
<td align="left" valign="top" width="794"><img src="@@JDK_HEADER_PNG@@" height="63" width="783"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><p class="style1">感谢您安装 Oracle Corporation 的 <strong>Java Development Kit @@JDK_VERSION@@</strong></p>
<p class="style1">注册产品后您将获得如下增值服务:</p>
<ul class="style1">
<li> 获得新版本、修补程序和更新的通知服务</li>
<li> 获得有关 Oracle 开发者产品、服务和培训的优惠 </li>
<li> 获得对早期版本和文档的访问权限 </li>
</ul>
<p class="style1">产品注册是免费的,即快速又轻松!</p>
<blockquote>
<p class="style1">您需要具有 Oracle.com 帐户。如果您没有,系统将提示您创建一个。 </p>
<table width="708" border="0" cellspacing="0" cellpadding="3">
<tr valign="top">
<td width="126" height="35"><form name="form1" method="post" action="@@REGISTRATION_URL@@" enctype="text/xml">
<input type="hidden" name="servicetag_payload" value="@@REGISTRATION_PAYLOAD@@">
<input type="submit" name="Submit"border="0" class="buttonblue" onmouseover="this.style.color='#fbe249';" onmouseout="this.style.color='#FFF';" value="注册我的 JDK">
</form></td>
<td width="570"><span class="style3">您需要连接到 Internet 来注册此 Oracle 产品。 </span></td>
</tr>
</table>
</blockquote>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td bgcolor="#f1f7df">
<p class="style3">Oracle 尊重您的隐私。我们会将您的个人信息用于通信和 Oracle.com 帐户的管理、Oracle.com 帐户访问的服务和应用程序以及用于使用 Oracle.com 帐户注册的产品和系统。</p>
<p class="style3">有关注册过程中收集的数据以及这些数据的管理方式的更多信息,<br>请访问 <a href="http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html</a><br> <br>有关 Oracle 隐私政策的更多信息,请访问 <a href="http://www.oracle.com/html/privacy.html">http://www.oracle.com/html/privacy.html</a> 或与 <a class="moz-txt-link-rfc2396E" href="mailto:privacy_ww@oracle.com">privacy_ww@oracle.com</a> 联系。</p></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>

File diff suppressed because it is too large Load Diff

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@ -1683,22 +1683,29 @@ public abstract class ClassLoader {
private int jniVersion;
// the class from which the library is loaded, also indicates
// the loader this native library belongs.
private Class<?> fromClass;
private final Class<?> fromClass;
// the canonicalized name of the native library.
// or static library name
String name;
// Indicates if the native library is linked into the VM
boolean isBuiltin;
// Indicates if the native library is loaded
boolean loaded;
native void load(String name, boolean isBuiltin);
native void load(String name);
native long find(String name);
native void unload();
native void unload(String name, boolean isBuiltin);
static native String findBuiltinLib(String name);
public NativeLibrary(Class<?> fromClass, String name) {
public NativeLibrary(Class<?> fromClass, String name, boolean isBuiltin) {
this.name = name;
this.fromClass = fromClass;
this.isBuiltin = isBuiltin;
}
protected void finalize() {
synchronized (loadedLibraryNames) {
if (fromClass.getClassLoader() != null && handle != 0) {
if (fromClass.getClassLoader() != null && loaded) {
/* remove the native library name */
int size = loadedLibraryNames.size();
for (int i = 0; i < size; i++) {
@ -1710,7 +1717,7 @@ public abstract class ClassLoader {
/* unload the library. */
ClassLoader.nativeLibraryContext.push(this);
try {
unload();
unload(name, isBuiltin);
} finally {
ClassLoader.nativeLibraryContext.pop();
}
@ -1830,20 +1837,24 @@ public abstract class ClassLoader {
}
private static boolean loadLibrary0(Class<?> fromClass, final File file) {
boolean exists = AccessController.doPrivileged(
new PrivilegedAction<Object>() {
public Object run() {
return file.exists() ? Boolean.TRUE : null;
}})
!= null;
if (!exists) {
return false;
}
String name;
try {
name = file.getCanonicalPath();
} catch (IOException e) {
return false;
// Check to see if we're attempting to access a static library
String name = NativeLibrary.findBuiltinLib(file.getName());
boolean isBuiltin = (name != null);
if (!isBuiltin) {
boolean exists = AccessController.doPrivileged(
new PrivilegedAction<Object>() {
public Object run() {
return file.exists() ? Boolean.TRUE : null;
}})
!= null;
if (!exists) {
return false;
}
try {
name = file.getCanonicalPath();
} catch (IOException e) {
return false;
}
}
ClassLoader loader =
(fromClass == null) ? null : fromClass.getClassLoader();
@ -1891,14 +1902,14 @@ public abstract class ClassLoader {
}
}
}
NativeLibrary lib = new NativeLibrary(fromClass, name);
NativeLibrary lib = new NativeLibrary(fromClass, name, isBuiltin);
nativeLibraryContext.push(lib);
try {
lib.load(name);
lib.load(name, isBuiltin);
} finally {
nativeLibraryContext.pop();
}
if (lib.handle != 0) {
if (lib.loaded) {
loadedLibraryNames.addElement(name);
libs.addElement(lib);
return true;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2013, 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
@ -749,10 +749,21 @@ public class Runtime {
public native void traceMethodCalls(boolean on);
/**
* Loads the specified filename as a dynamic library. The filename
* argument must be a complete path name,
* Loads the native library specified by the filename argument. The filename
* argument must be an absolute path name.
* (for example
* <code>Runtime.getRuntime().load("/home/avh/lib/libX11.so");</code>).
*
* If the filename argument, when stripped of any platform-specific library
* prefix, path, and file extension, indicates a library whose name is,
* for example, L, and a native library called L is statically linked
* with the VM, then the JNI_OnLoad_L function exported by the library
* is invoked rather than attempting to load a dynamic library.
* A filename matching the argument does not have to exist in the file
* system. See the JNI Specification for more details.
*
* Otherwise, the filename argument is mapped to a native library image in
* an implementation-dependent manner.
* <p>
* First, if there is a security manager, its <code>checkLink</code>
* method is called with the <code>filename</code> as its argument.
@ -769,7 +780,10 @@ public class Runtime {
* @exception SecurityException if a security manager exists and its
* <code>checkLink</code> method doesn't allow
* loading of the specified dynamic library
* @exception UnsatisfiedLinkError if the file does not exist.
* @exception UnsatisfiedLinkError if either the filename is not an
* absolute path name, the native library is not statically
* linked with the VM, or the library cannot be mapped to
* a native library image by the host system.
* @exception NullPointerException if <code>filename</code> is
* <code>null</code>
* @see java.lang.Runtime#getRuntime()
@ -793,12 +807,16 @@ public class Runtime {
}
/**
* Loads the dynamic library with the specified library name.
* A file containing native code is loaded from the local file system
* from a place where library files are conventionally obtained. The
* details of this process are implementation-dependent. The
* mapping from a library name to a specific filename is done in a
* system-specific manner.
* Loads the native library specified by the <code>libname</code>
* argument. The <code>libname</code> argument must not contain any platform
* specific prefix, file extension or path. If a native library
* called <code>libname</code> is statically linked with the VM, then the
* JNI_OnLoad_<code>libname</code> function exported by the library is invoked.
* See the JNI Specification for more details.
*
* Otherwise, the libname argument is loaded from a system library
* location and mapped to a native library image in an implementation-
* dependent manner.
* <p>
* First, if there is a security manager, its <code>checkLink</code>
* method is called with the <code>libname</code> as its argument.
@ -823,7 +841,10 @@ public class Runtime {
* @exception SecurityException if a security manager exists and its
* <code>checkLink</code> method doesn't allow
* loading of the specified dynamic library
* @exception UnsatisfiedLinkError if the library does not exist.
* @exception UnsatisfiedLinkError if either the libname argument
* contains a file path, the native library is not statically
* linked with the VM, or the library cannot be mapped to a
* native library image by the host system.
* @exception NullPointerException if <code>libname</code> is
* <code>null</code>
* @see java.lang.SecurityException

@ -1037,9 +1037,21 @@ public final class System {
}
/**
* Loads a code file with the specified filename from the local file
* system as a dynamic library. The filename
* argument must be a complete path name.
* Loads the native library specified by the filename argument. The filename
* argument must be an absolute path name.
*
* If the filename argument, when stripped of any platform-specific library
* prefix, path, and file extension, indicates a library whose name is,
* for example, L, and a native library called L is statically linked
* with the VM, then the JNI_OnLoad_L function exported by the library
* is invoked rather than attempting to load a dynamic library.
* A filename matching the argument does not have to exist in the
* file system.
* See the JNI Specification for more details.
*
* Otherwise, the filename argument is mapped to a native library image in
* an implementation-dependent manner.
*
* <p>
* The call <code>System.load(name)</code> is effectively equivalent
* to the call:
@ -1051,7 +1063,10 @@ public final class System {
* @exception SecurityException if a security manager exists and its
* <code>checkLink</code> method doesn't allow
* loading of the specified dynamic library
* @exception UnsatisfiedLinkError if the file does not exist.
* @exception UnsatisfiedLinkError if either the filename is not an
* absolute path name, the native library is not statically
* linked with the VM, or the library cannot be mapped to
* a native library image by the host system.
* @exception NullPointerException if <code>filename</code> is
* <code>null</code>
* @see java.lang.Runtime#load(java.lang.String)
@ -1062,9 +1077,16 @@ public final class System {
}
/**
* Loads the system library specified by the <code>libname</code>
* argument. The manner in which a library name is mapped to the
* actual system library is system dependent.
* Loads the native library specified by the <code>libname</code>
* argument. The <code>libname</code> argument must not contain any platform
* specific prefix, file extension or path. If a native library
* called <code>libname</code> is statically linked with the VM, then the
* JNI_OnLoad_<code>libname</code> function exported by the library is invoked.
* See the JNI Specification for more details.
*
* Otherwise, the libname argument is loaded from a system library
* location and mapped to a native library image in an implementation-
* dependent manner.
* <p>
* The call <code>System.loadLibrary(name)</code> is effectively
* equivalent to the call
@ -1076,7 +1098,10 @@ public final class System {
* @exception SecurityException if a security manager exists and its
* <code>checkLink</code> method doesn't allow
* loading of the specified dynamic library
* @exception UnsatisfiedLinkError if the library does not exist.
* @exception UnsatisfiedLinkError if either the libname argument
* contains a file path, the native library is not statically
* linked with the VM, or the library cannot be mapped to a
* native library image by the host system.
* @exception NullPointerException if <code>libname</code> is
* <code>null</code>
* @see java.lang.Runtime#loadLibrary(java.lang.String)

@ -52,7 +52,8 @@ class DirectMethodHandle extends MethodHandle {
super(mtype, form);
if (!member.isResolved()) throw new InternalError();
if (member.getDeclaringClass().isInterface() && !member.isAbstract()) {
if (member.getDeclaringClass().isInterface() &&
member.isMethod() && !member.isAbstract()) {
// Check for corner case: invokeinterface of Object method
MemberName m = new MemberName(Object.class, member.getName(), member.getMethodType(), member.getReferenceKind());
m = MemberName.getFactory().resolveOrNull(m.getReferenceKind(), m, null);

@ -522,16 +522,19 @@ public final class Method extends Executable {
* Returns {@code true} if this method is a default
* method; returns {@code false} otherwise.
*
* A default method is a non-abstract method, that is, a method
* with a body, declared in an interface type.
* A default method is a public non-abstract instance method, that
* is, a non-static method with a body, declared in an interface
* type.
*
* @return true if and only if this method is a default
* method as defined by the Java Language Specification.
* @since 1.8
*/
public boolean isDefault() {
return (getModifiers() & Modifier.ABSTRACT) == 0 &&
getDeclaringClass().isInterface();
// Default methods are public non-abstract instance methods
// declared in an interface.
return ((getModifiers() & (Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC)) ==
Modifier.PUBLIC) && getDeclaringClass().isInterface();
}
// NOTE that there is no synchronization used here. It is correct

@ -57,6 +57,8 @@ import java.util.concurrent.ConcurrentMap;
import sun.util.BuddhistCalendar;
import sun.util.calendar.ZoneInfo;
import sun.util.locale.provider.CalendarDataUtility;
import sun.util.locale.provider.LocaleProviderAdapter;
import sun.util.spi.CalendarProvider;
/**
* The <code>Calendar</code> class is an abstract class that provides methods
@ -1608,9 +1610,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
*/
public static Calendar getInstance()
{
Calendar cal = createCalendar(TimeZone.getDefaultRef(), Locale.getDefault(Locale.Category.FORMAT));
cal.sharedZone = true;
return cal;
return createCalendar(TimeZone.getDefault(), Locale.getDefault(Locale.Category.FORMAT));
}
/**
@ -1637,9 +1637,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
*/
public static Calendar getInstance(Locale aLocale)
{
Calendar cal = createCalendar(TimeZone.getDefaultRef(), aLocale);
cal.sharedZone = true;
return cal;
return createCalendar(TimeZone.getDefault(), aLocale);
}
/**
@ -1660,6 +1658,17 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
private static Calendar createCalendar(TimeZone zone,
Locale aLocale)
{
CalendarProvider provider =
LocaleProviderAdapter.getAdapter(CalendarProvider.class, aLocale)
.getCalendarProvider();
if (provider != null) {
try {
return provider.getInstance(zone, aLocale);
} catch (IllegalArgumentException iae) {
// fall back to the default instantiation
}
}
Calendar cal = null;
if (aLocale.hasExtensions()) {

@ -0,0 +1,243 @@
/*
* Copyright (c) 2012, 2013, 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.util;
import java.util.function.Consumer;
import java.util.function.Supplier;
/**
* A container object which may or may not contain a non-null value.
* If a value is present, {@code isPresent()} will return {@code true} and
* {@code get()} will return the value.
*
* <p>Additional methods that depend on the presence or absence of a contained
* value are provided, such as {@link #orElse(java.lang.Object) orElse()}
* (return a default value if value not present) and
* {@link #ifPresent(java.util.function.Consumer) ifPresent()} (execute a block
* of code if the value is present).
*
* @since 1.8
*/
public final class Optional<T> {
/**
* Common instance for {@code empty()}.
*/
private static final Optional<?> EMPTY = new Optional<>();
/**
* If non-null, the value; if null, indicates no value is present
*/
private final T value;
/**
* Construct an empty instance.
*
* @implNote Generally only one empty instance, {@link Optional#EMPTY},
* should exist per VM.
*/
private Optional() {
this.value = null;
}
/**
* Returns an empty {@code Optional} instance. No value is present for this
* Optional.
*
* @apiNote Though it may be tempting to do so, avoid testing if an object
* is empty by comparing with {@code ==} against instances returned by
* {@code Option.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
* @param <T> Type of the non-existent value
* @return an empty {@code Optional}
*/
public static<T> Optional<T> empty() {
@SuppressWarnings("unchecked")
Optional<T> t = (Optional<T>) EMPTY;
return t;
}
/**
* Construct an instance with the value present.
*
* @param value the non-null value to be present
*/
private Optional(T value) {
this.value = Objects.requireNonNull(value);
}
/**
* Return an {@code Optional} with the specified present value.
*
* @param value the value to be present, which must be non-null
* @return an {@code Optional} with the value present
*/
public static <T> Optional<T> of(T value) {
return new Optional<>(value);
}
/**
* If a value is present in this {@code Optional}, returns the value,
* otherwise throws {@code NoSuchElementException}.
*
* @return the non-null value held by this {@code Optional}
* @throws NoSuchElementException if there is no value present
*
* @see Optional#isPresent()
*/
public T get() {
if (value == null) {
throw new NoSuchElementException("No value present");
}
return value;
}
/**
* Return {@code true} if there is a value present, otherwise {@code false}.
*
* @return {@code true} if there is a value present, otherwise {@code false}
*/
public boolean isPresent() {
return value != null;
}
/**
* Have the specified consumer accept the value if a value is present,
* otherwise do nothing.
*
* @param consumer block to be executed if a value is present
* @throws NullPointerException if value is present and {@code consumer} is
* null
*/
public void ifPresent(Consumer<? super T> consumer) {
if (value != null)
consumer.accept(value);
}
/**
* Return the value if present, otherwise return {@code other}.
*
* @param other the value to be returned if there is no value present, may
* be null
* @return the value, if present, otherwise {@code other}
*/
public T orElse(T other) {
return value != null ? value : other;
}
/**
* Return the value if present, otherwise invoke {@code other} and return
* the result of that invocation.
*
* @param other a {@code Supplier} whose result is returned if no value
* is present
* @return the value if present otherwise the result of {@code other.get()}
* @throws NullPointerException if value is not present and {@code other} is
* null
*/
public T orElseGet(Supplier<? extends T> other) {
return value != null ? value : other.get();
}
/**
* Return the contained value, if present, otherwise throw an exception
* to be created by the provided supplier.
*
* @apiNote A method reference to the exception constructor with an empty
* argument list can be used as the supplier. For example,
* {@code IllegalStateException::new}
*
* @param <X> Type of the exception to be thrown
* @param exceptionSupplier The supplier which will return the exception to
* be thrown
* @return the present value
* @throws X if there is no value present
* @throws NullPointerException if no value is present and
* {@code exceptionSupplier} is null
*/
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
if (value != null) {
return value;
} else {
throw exceptionSupplier.get();
}
}
/**
* Indicates whether some other object is "equal to" this Optional. The
* other object is considered equal if:
* <ul>
* <li>it is also an {@code Optional} and;
* <li>both instances have no value present or;
* <li>the present values are "equal to" each other via {@code equals()}.
* </ul>
*
* @param obj an object to be tested for equality
* @return {code true} if the other object is "equal to" this object
* otherwise {@code false}
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Optional)) {
return false;
}
Optional other = (Optional) obj;
return Objects.equals(value, other.value);
}
/**
* Returns the hash code value of the present value, if any, or 0 (zero) if
* no value is present.
*
* @return hash code value of the present value or 0 if no value is present
*/
@Override
public int hashCode() {
return Objects.hashCode(value);
}
/**
* Returns a non-empty string representation of this Optional suitable for
* debugging. The exact presentation format is unspecified and may vary
* between implementations and versions.
*
* @implSpec If a value is present the result must include its string
* representation in the result. Empty and present Optionals must be
* unambiguously differentiable.
*
* @return the string representation of this instance
*/
@Override
public String toString() {
return value != null
? String.format("Optional[%s]", value)
: "Optional.empty";
}
}

@ -0,0 +1,245 @@
/*
* Copyright (c) 2012, 2013, 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.util;
import java.util.function.DoubleConsumer;
import java.util.function.DoubleSupplier;
import java.util.function.Supplier;
/**
* A container object which may or may not contain a {@code double} value.
* If a value is present, {@code isPresent()} will return {@code true} and
* {@code get()} will return the value.
*
* <p>Additional methods that depend on the presence or absence of a contained
* value are provided, such as {@link #orElse(double) orElse()}
* (return a default value if value not present) and
* {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (execute a block
* of code if the value is present).
*
* @since 1.8
*/
public final class OptionalDouble {
/**
* Common instance for {@code empty()}.
*/
private static final OptionalDouble EMPTY = new OptionalDouble();
/**
* If true then the value is present, otherwise indicates no value is present
*/
private final boolean isPresent;
private final double value;
/**
* Construct an empty instance.
*
* @implNote generally only one empty instance, {@link OptionalDouble#EMPTY},
* should exist per VM.
*/
private OptionalDouble() {
this.isPresent = false;
this.value = Double.NaN;
}
/**
* Returns an empty {@code OptionalDouble} instance. No value is present for this
* OptionalDouble.
*
* @apiNote Though it may be tempting to do so, avoid testing if an object
* is empty by comparing with {@code ==} against instances returned by
* {@code Option.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
* @return an empty {@code OptionalDouble}.
*/
public static OptionalDouble empty() {
return EMPTY;
}
/**
* Construct an instance with the value present.
*
* @param value the double value to be present.
*/
private OptionalDouble(double value) {
this.isPresent = true;
this.value = value;
}
/**
* Return an {@code OptionalDouble} with the specified value present.
*
* @param value the value to be present
* @return an {@code OptionalDouble} with the value present
*/
public static OptionalDouble of(double value) {
return new OptionalDouble(value);
}
/**
* If a value is present in this {@code OptionalDouble}, returns the value,
* otherwise throws {@code NoSuchElementException}.
*
* @return the value held by this {@code OptionalDouble}
* @throws NoSuchElementException if there is no value present
*
* @see OptionalDouble#isPresent()
*/
public double getAsDouble() {
if (!isPresent) {
throw new NoSuchElementException("No value present");
}
return value;
}
/**
* Return {@code true} if there is a value present, otherwise {@code false}.
*
* @return {@code true} if there is a value present, otherwise {@code false}
*/
public boolean isPresent() {
return isPresent;
}
/**
* Have the specified consumer accept the value if a value is present,
* otherwise do nothing.
*
* @param consumer block to be executed if a value is present
* @throws NullPointerException if value is present and {@code consumer} is
* null
*/
public void ifPresent(DoubleConsumer consumer) {
if (isPresent)
consumer.accept(value);
}
/**
* Return the value if present, otherwise return {@code other}.
*
* @param other the value to be returned if there is no value present
* @return the value, if present, otherwise {@code other}
*/
public double orElse(double other) {
return isPresent ? value : other;
}
/**
* Return the value if present, otherwise invoke {@code other} and return
* the result of that invocation.
*
* @param other a {@code DoubleSupplier} whose result is returned if no value
* is present
* @return the value if present otherwise the result of {@code other.getAsDouble()}
* @throws NullPointerException if value is not present and {@code other} is
* null
*/
public double orElseGet(DoubleSupplier other) {
return isPresent ? value : other.getAsDouble();
}
/**
* Return the contained value, if present, otherwise throw an exception
* to be created by the provided supplier.
*
* @apiNote A method reference to the exception constructor with an empty
* argument list can be used as the supplier. For example,
* {@code IllegalStateException::new}
*
* @param <X> Type of the exception to be thrown
* @param exceptionSupplier The supplier which will return the exception to
* be thrown
* @return the present value
* @throws X if there is no value present
* @throws NullPointerException if no value is present and
* {@code exceptionSupplier} is null
*/
public<X extends Throwable> double orElseThrow(Supplier<X> exceptionSupplier) throws X {
if (isPresent) {
return value;
} else {
throw exceptionSupplier.get();
}
}
/**
* Indicates whether some other object is "equal to" this Optional. The
* other object is considered equal if:
* <ul>
* <li>it is also an {@code OptionalInt} and;
* <li>both instances have no value present or;
* <li>the present values are "equal to" each other via {@code Double.compare() == 0}.
* </ul>
*
* @param obj an object to be tested for equality
* @return {code true} if the other object is "equal to" this object
* otherwise {@code false}
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof OptionalDouble)) {
return false;
}
OptionalDouble other = (OptionalDouble) obj;
return (isPresent && other.isPresent)
? Double.compare(value, other.value) == 0
: isPresent == other.isPresent;
}
/**
* Returns the hash code value of the present value, if any, or 0 (zero) if
* no value is present.
*
* @return hash code value of the present value or 0 if no value is present
*/
@Override
public int hashCode() {
return isPresent ? Double.hashCode(value) : 0;
}
/**
* Returns a non-empty string representation of this OptionalDouble suitable for
* debugging. The exact presentation format is unspecified and may vary
* between implementations and versions.
*
* @implSpec If a value is present the result must include its string
* representation in the result. Empty and present OptionalDoubless must be
* unambiguously differentiable.
*
* @return the string representation of this instance
*/
@Override
public String toString() {
return isPresent
? String.format("OptionalDouble[%s]", value)
: "OptionalDouble.empty";
}
}

@ -0,0 +1,245 @@
/*
* Copyright (c) 2012, 2013, 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.util;
import java.util.function.IntConsumer;
import java.util.function.IntSupplier;
import java.util.function.Supplier;
/**
* A container object which may or may not contain a {@code int} value.
* If a value is present, {@code isPresent()} will return {@code true} and
* {@code get()} will return the value.
*
* <p>Additional methods that depend on the presence or absence of a contained
* value are provided, such as {@link #orElse(int) orElse()}
* (return a default value if value not present) and
* {@link #ifPresent(java.util.function.IntConsumer) ifPresent()} (execute a block
* of code if the value is present).
*
* @since 1.8
*/
public final class OptionalInt {
/**
* Common instance for {@code empty()}.
*/
private static final OptionalInt EMPTY = new OptionalInt();
/**
* If true then the value is present, otherwise indicates no value is present
*/
private final boolean isPresent;
private final int value;
/**
* Construct an empty instance.
*
* @implNote Generally only one empty instance, {@link OptionalInt#EMPTY},
* should exist per VM.
*/
private OptionalInt() {
this.isPresent = false;
this.value = 0;
}
/**
* Returns an empty {@code OptionalInt} instance. No value is present for this
* OptionalInt.
*
* @apiNote Though it may be tempting to do so, avoid testing if an object
* is empty by comparing with {@code ==} against instances returned by
* {@code Option.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
* @return an empty {@code OptionalInt}
*/
public static OptionalInt empty() {
return EMPTY;
}
/**
* Construct an instance with the value present.
*
* @param value the int value to be present
*/
private OptionalInt(int value) {
this.isPresent = true;
this.value = value;
}
/**
* Return an {@code OptionalInt} with the specified value present.
*
* @param value the value to be present
* @return an {@code OptionalInt} with the value present
*/
public static OptionalInt of(int value) {
return new OptionalInt(value);
}
/**
* If a value is present in this {@code OptionalInt}, returns the value,
* otherwise throws {@code NoSuchElementException}.
*
* @return the value held by this {@code OptionalInt}
* @throws NoSuchElementException if there is no value present
*
* @see OptionalInt#isPresent()
*/
public int getAsInt() {
if (!isPresent) {
throw new NoSuchElementException("No value present");
}
return value;
}
/**
* Return {@code true} if there is a value present, otherwise {@code false}.
*
* @return {@code true} if there is a value present, otherwise {@code false}
*/
public boolean isPresent() {
return isPresent;
}
/**
* Have the specified consumer accept the value if a value is present,
* otherwise do nothing.
*
* @param consumer block to be executed if a value is present
* @throws NullPointerException if value is present and {@code consumer} is
* null
*/
public void ifPresent(IntConsumer consumer) {
if (isPresent)
consumer.accept(value);
}
/**
* Return the value if present, otherwise return {@code other}.
*
* @param other the value to be returned if there is no value present
* @return the value, if present, otherwise {@code other}
*/
public int orElse(int other) {
return isPresent ? value : other;
}
/**
* Return the value if present, otherwise invoke {@code other} and return
* the result of that invocation.
*
* @param other a {@code IntSupplier} whose result is returned if no value
* is present
* @return the value if present otherwise the result of {@code other.getAsInt()}
* @throws NullPointerException if value is not present and {@code other} is
* null
*/
public int orElseGet(IntSupplier other) {
return isPresent ? value : other.getAsInt();
}
/**
* Return the contained value, if present, otherwise throw an exception
* to be created by the provided supplier.
*
* @apiNote A method reference to the exception constructor with an empty
* argument list can be used as the supplier. For example,
* {@code IllegalStateException::new}
*
* @param <X> Type of the exception to be thrown
* @param exceptionSupplier The supplier which will return the exception to
* be thrown
* @return the present value
* @throws X if there is no value present
* @throws NullPointerException if no value is present and
* {@code exceptionSupplier} is null
*/
public<X extends Throwable> int orElseThrow(Supplier<X> exceptionSupplier) throws X {
if (isPresent) {
return value;
} else {
throw exceptionSupplier.get();
}
}
/**
* Indicates whether some other object is "equal to" this Optional. The
* other object is considered equal if:
* <ul>
* <li>it is also an {@code OptionalInt} and;
* <li>both instances have no value present or;
* <li>the present values are "equal to" each other via {@code ==}.
* </ul>
*
* @param obj an object to be tested for equality
* @return {code true} if the other object is "equal to" this object
* otherwise {@code false}
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof OptionalInt)) {
return false;
}
OptionalInt other = (OptionalInt) obj;
return (isPresent && other.isPresent)
? value == other.value
: isPresent == other.isPresent;
}
/**
* Returns the hash code value of the present value, if any, or 0 (zero) if
* no value is present.
*
* @return hash code value of the present value or 0 if no value is present
*/
@Override
public int hashCode() {
return isPresent ? Integer.hashCode(value) : 0;
}
/**
* Returns a non-empty string representation of this OptionalInt suitable for
* debugging. The exact presentation format is unspecified and may vary
* between implementations and versions.
*
* @implSpec If a value is present the result must include its string
* representation in the result. Empty and present OptionalInts must be
* unambiguously differentiable.
*
* @return the string representation of this instance
*/
@Override
public String toString() {
return isPresent
? String.format("OptionalInt[%s]", value)
: "OptionalInt.empty";
}
}

@ -0,0 +1,245 @@
/*
* Copyright (c) 2012, 2013, 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.util;
import java.util.function.LongConsumer;
import java.util.function.LongSupplier;
import java.util.function.Supplier;
/**
* A container object which may or may not contain a {@code long} value.
* If a value is present, {@code isPresent()} will return {@code true} and
* {@code get()} will return the value.
*
* <p>Additional methods that depend on the presence or absence of a contained
* value are provided, such as {@link #orElse(long) orElse()}
* (return a default value if value not present) and
* {@link #ifPresent(java.util.function.LongConsumer) ifPresent()} (execute a block
* of code if the value is present).
*
* @since 1.8
*/
public final class OptionalLong {
/**
* Common instance for {@code empty()}.
*/
private static final OptionalLong EMPTY = new OptionalLong();
/**
* If true then the value is present, otherwise indicates no value is present
*/
private final boolean isPresent;
private final long value;
/**
* Construct an empty instance.
*
* @implNote generally only one empty instance, {@link OptionalLong#EMPTY},
* should exist per VM.
*/
private OptionalLong() {
this.isPresent = false;
this.value = 0;
}
/**
* Returns an empty {@code OptionalLong} instance. No value is present for this
* OptionalLong.
*
* @apiNote Though it may be tempting to do so, avoid testing if an object
* is empty by comparing with {@code ==} against instances returned by
* {@code Option.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
* @return an empty {@code OptionalLong}.
*/
public static OptionalLong empty() {
return EMPTY;
}
/**
* Construct an instance with the value present.
*
* @param value the long value to be present
*/
private OptionalLong(long value) {
this.isPresent = true;
this.value = value;
}
/**
* Return an {@code OptionalLong} with the specified value present.
*
* @param value the value to be present
* @return an {@code OptionalLong} with the value present
*/
public static OptionalLong of(long value) {
return new OptionalLong(value);
}
/**
* If a value is present in this {@code OptionalLong}, returns the value,
* otherwise throws {@code NoSuchElementException}.
*
* @return the value held by this {@code OptionalLong}
* @throws NoSuchElementException if there is no value present
*
* @see OptionalLong#isPresent()
*/
public long getAsLong() {
if (!isPresent) {
throw new NoSuchElementException("No value present");
}
return value;
}
/**
* Return {@code true} if there is a value present, otherwise {@code false}.
*
* @return {@code true} if there is a value present, otherwise {@code false}
*/
public boolean isPresent() {
return isPresent;
}
/**
* Have the specified consumer accept the value if a value is present,
* otherwise do nothing.
*
* @param consumer block to be executed if a value is present
* @throws NullPointerException if value is present and {@code consumer} is
* null
*/
public void ifPresent(LongConsumer consumer) {
if (isPresent)
consumer.accept(value);
}
/**
* Return the value if present, otherwise return {@code other}.
*
* @param other the value to be returned if there is no value present
* @return the value, if present, otherwise {@code other}
*/
public long orElse(long other) {
return isPresent ? value : other;
}
/**
* Return the value if present, otherwise invoke {@code other} and return
* the result of that invocation.
*
* @param other a {@code LongSupplier} whose result is returned if no value
* is present
* @return the value if present otherwise the result of {@code other.getAsLong()}
* @throws NullPointerException if value is not present and {@code other} is
* null
*/
public long orElseGet(LongSupplier other) {
return isPresent ? value : other.getAsLong();
}
/**
* Return the contained value, if present, otherwise throw an exception
* to be created by the provided supplier.
*
* @apiNote A method reference to the exception constructor with an empty
* argument list can be used as the supplier. For example,
* {@code IllegalStateException::new}
*
* @param <X> Type of the exception to be thrown
* @param exceptionSupplier The supplier which will return the exception to
* be thrown
* @return the present value
* @throws X if there is no value present
* @throws NullPointerException if no value is present and
* {@code exceptionSupplier} is null
*/
public<X extends Throwable> long orElseThrow(Supplier<X> exceptionSupplier) throws X {
if (isPresent) {
return value;
} else {
throw exceptionSupplier.get();
}
}
/**
* Indicates whether some other object is "equal to" this Optional. The
* other object is considered equal if:
* <ul>
* <li>it is also an {@code OptionalInt} and;
* <li>both instances have no value present or;
* <li>the present values are "equal to" each other via {@code ==}.
* </ul>
*
* @param obj an object to be tested for equality
* @return {code true} if the other object is "equal to" this object
* otherwise {@code false}
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof OptionalLong)) {
return false;
}
OptionalLong other = (OptionalLong) obj;
return (isPresent && other.isPresent)
? value == other.value
: isPresent == other.isPresent;
}
/**
* Returns the hash code value of the present value, if any, or 0 (zero) if
* no value is present.
*
* @return hash code value of the present value or 0 if no value is present
*/
@Override
public int hashCode() {
return isPresent ? Long.hashCode(value) : 0;
}
/**
* Returns a non-empty string representation of this OptionalLong suitable for
* debugging. The exact presentation format is unspecified and may vary
* between implementations and versions.
*
* @implSpec If a value is present the result must include its string
* representation in the result. Empty and present OptionalLongs must be
* unambiguously differentiable.
*
* @return the string representation of this instance
*/
@Override
public String toString() {
return isPresent
? String.format("OptionalLong[%s]", value)
: "OptionalLong.empty";
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2013, 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,10 +26,15 @@
package java.util.logging;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.security.*;
import java.lang.ref.WeakReference;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Supplier;
/**
@ -104,7 +109,7 @@ import java.util.function.Supplier;
* unnecessary message construction. For example, if the developer wants to
* log system health status for diagnosis, with the String-accepting version,
* the code would look like:
<code><pre>
<pre><code>
class DiagnosisMessages {
static String systemHealthStatus() {
@ -114,26 +119,20 @@ import java.util.function.Supplier;
}
...
logger.log(Level.FINER, DiagnosisMessages.systemHealthStatus());
</pre></code>
</code></pre>
* With the above code, the health status is collected unnecessarily even when
* the log level FINER is disabled. With the Supplier-accepting version as
* below, the status will only be collected when the log level FINER is
* enabled.
<code><pre>
<pre><code>
logger.log(Level.FINER, DiagnosisMessages::systemHealthStatus);
</pre></code>
</code></pre>
* <p>
* When mapping ResourceBundle names to ResourceBundles, the Logger
* will first try to use the Thread's ContextClassLoader. If that
* is null it will try the SystemClassLoader instead. As a temporary
* transition feature in the initial implementation, if the Logger is
* unable to locate a ResourceBundle from the ContextClassLoader or
* SystemClassLoader the Logger will also search up the class stack
* and use successive calling ClassLoaders to try to locate a ResourceBundle.
* (This call stack search is to allow containers to transition to
* using ContextClassLoaders and is likely to be removed in future
* versions.)
* is null it will try the
* {@linkplain java.lang.ClassLoader#getSystemClassLoader() system ClassLoader} instead.
* <p>
* Formatting (including localization) is the responsibility of
* the output Handler, which will typically call a Formatter.
@ -1584,12 +1583,6 @@ public class Logger {
return useParentHandlers;
}
// Private utility method to map a resource bundle name to an
// actual resource bundle, using a simple one-entry cache.
// Returns null for a null name.
// May also return null if we can't find the resource bundle and
// there is no suitable previous cached value.
static final String SYSTEM_LOGGER_RB_NAME = "sun.util.logging.resources.logging";
private static ResourceBundle findSystemResourceBundle(final Locale locale) {
@ -1607,6 +1600,16 @@ public class Logger {
});
}
/**
* Private utility method to map a resource bundle name to an
* actual resource bundle, using a simple one-entry cache.
* Returns null for a null name.
* May also return null if we can't find the resource bundle and
* there is no suitable previous cached value.
*
* @param name the ResourceBundle to locate
* @return ResourceBundle specified by name or null if not found
*/
private synchronized ResourceBundle findResourceBundle(String name) {
// Return a null bundle for a null name.
if (name == null) {
@ -1616,8 +1619,8 @@ public class Logger {
Locale currentLocale = Locale.getDefault();
// Normally we should hit on our simple one entry cache.
if (catalog != null && currentLocale == catalogLocale
&& name == catalogName) {
if (catalog != null && currentLocale.equals(catalogLocale)
&& name.equals(catalogName)) {
return catalog;
}
@ -1628,8 +1631,8 @@ public class Logger {
return catalog;
}
// Use the thread's context ClassLoader. If there isn't one,
// use the SystemClassloader.
// Use the thread's context ClassLoader. If there isn't one, use the
// {@linkplain java.lang.ClassLoader#getSystemClassLoader() system ClassLoader}.
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) {
cl = ClassLoader.getSystemClassLoader();
@ -1640,44 +1643,8 @@ public class Logger {
catalogLocale = currentLocale;
return catalog;
} catch (MissingResourceException ex) {
// Woops. We can't find the ResourceBundle in the default
// ClassLoader. Drop through.
return null;
}
// Fall back to searching up the call stack and trying each
// calling ClassLoader.
for (int ix = 0; ; ix++) {
Class clz = sun.reflect.Reflection.getCallerClass(ix);
if (clz == null) {
break;
}
ClassLoader cl2 = clz.getClassLoader();
if (cl2 == null) {
cl2 = ClassLoader.getSystemClassLoader();
}
if (cl == cl2) {
// We've already checked this classloader.
continue;
}
cl = cl2;
try {
catalog = ResourceBundle.getBundle(name, currentLocale, cl);
catalogName = name;
catalogLocale = currentLocale;
return catalog;
} catch (MissingResourceException ex) {
// Ok, this one didn't work either.
// Drop through, and try the next one.
}
}
if (name.equals(catalogName)) {
// Return the previous cached value for that name.
// This may be null.
return catalog;
}
// Sorry, we're out of luck.
return null;
}
// Private utility method to initialize our one entry
@ -1704,8 +1671,7 @@ public class Logger {
resourceBundleName + " != " + name);
}
ResourceBundle rb = findResourceBundle(name);
if (rb == null) {
if (findResourceBundle(name) == null) {
// We've failed to find an expected ResourceBundle.
throw new MissingResourceException("Can't find " + name + " bundle", name, "");
}

@ -57,6 +57,7 @@ public class SynthScrollBarUI extends BasicScrollBarUI
*/
@Override
protected void installDefaults() {
super.installDefaults();
trackHighlight = NO_HIGHLIGHT;
if (scrollbar.getLayout() == null ||
(scrollbar.getLayout() instanceof UIResource)) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2013, 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
@ -46,7 +46,7 @@ public class HttpClient extends NetworkClient {
// whether this httpclient comes from the cache
protected boolean cachedHttpClient = false;
private boolean inCache;
protected boolean inCache;
// Http requests we send
MessageHeader requests;
@ -121,7 +121,14 @@ public class HttpClient extends NetworkClient {
public boolean reuse = false;
// Traffic capture tool, if configured. See HttpCapture class for info
private HttpCapture capture = null;
private HttpCapture capture = null;
private static final PlatformLogger logger = HttpURLConnection.getHttpLogger();
private static void logFinest(String msg) {
if (logger.isLoggable(PlatformLogger.FINEST)) {
logger.finest(msg);
}
}
/**
* A NOP method kept for backwards binary compatibility
@ -266,8 +273,11 @@ public class HttpClient extends NetworkClient {
if (ret != null && httpuc != null &&
httpuc.streaming() &&
httpuc.getRequestMethod() == "POST") {
if (!ret.available())
if (!ret.available()) {
ret.inCache = false;
ret.closeServer();
ret = null;
}
}
if (ret != null) {
@ -279,10 +289,7 @@ public class HttpClient extends NetworkClient {
ret.inCache = false;
if (httpuc != null && ret.needsTunneling())
httpuc.setTunnelState(TUNNELING);
PlatformLogger logger = HttpURLConnection.getHttpLogger();
if (logger.isLoggable(PlatformLogger.FINEST)) {
logger.finest("KeepAlive stream retrieved from the cache, " + ret);
}
logFinest("KeepAlive stream retrieved from the cache, " + ret);
}
} else {
// We cannot return this connection to the cache as it's
@ -360,30 +367,33 @@ public class HttpClient extends NetworkClient {
}
}
protected synchronized boolean available() throws IOException {
protected synchronized boolean available() {
boolean available = true;
int old = serverSocket.getSoTimeout();
serverSocket.setSoTimeout(1);
BufferedInputStream tmpbuf =
new BufferedInputStream(serverSocket.getInputStream());
int old = -1;
PlatformLogger logger = HttpURLConnection.getHttpLogger();
try {
int r = tmpbuf.read();
if (r == -1) {
if (logger.isLoggable(PlatformLogger.FINEST)) {
logger.finest("HttpClient.available(): " +
"read returned -1: not available");
try {
old = serverSocket.getSoTimeout();
serverSocket.setSoTimeout(1);
BufferedInputStream tmpbuf =
new BufferedInputStream(serverSocket.getInputStream());
int r = tmpbuf.read();
if (r == -1) {
logFinest("HttpClient.available(): " +
"read returned -1: not available");
available = false;
}
available = false;
} catch (SocketTimeoutException e) {
logFinest("HttpClient.available(): " +
"SocketTimeout: its available");
} finally {
if (old != -1)
serverSocket.setSoTimeout(old);
}
} catch (SocketTimeoutException e) {
if (logger.isLoggable(PlatformLogger.FINEST)) {
logger.finest("HttpClient.available(): " +
"SocketTimeout: its available");
}
} finally {
serverSocket.setSoTimeout(old);
} catch (IOException e) {
logFinest("HttpClient.available(): " +
"SocketException: not available");
available = false;
}
return available;
}
@ -865,10 +875,7 @@ public class HttpClient extends NetworkClient {
if (isKeepingAlive()) {
// Wrap KeepAliveStream if keep alive is enabled.
PlatformLogger logger = HttpURLConnection.getHttpLogger();
if (logger.isLoggable(PlatformLogger.FINEST)) {
logger.finest("KeepAlive stream used: " + url);
}
logFinest("KeepAlive stream used: " + url);
serverInput = new KeepAliveStream(serverInput, pi, cl, this);
failedOnce = false;
}

@ -96,7 +96,7 @@ public abstract class AbstractDelegateHttpsURLConnection extends
http = HttpsClient.New (getSSLSocketFactory(),
url,
getHostnameVerifier(),
useCache);
useCache, this);
((HttpsClient)http).afterConnect();
}
@ -149,7 +149,7 @@ public abstract class AbstractDelegateHttpsURLConnection extends
http = HttpsClient.New (getSSLSocketFactory(),
url,
getHostnameVerifier(),
proxyHost, proxyPort, useCache);
proxyHost, proxyPort, useCache, this);
connected = true;
}
@ -189,7 +189,8 @@ public abstract class AbstractDelegateHttpsURLConnection extends
protected HttpClient getNewHttpClient(URL url, Proxy p, int connectTimeout)
throws IOException {
return HttpsClient.New(getSSLSocketFactory(), url,
getHostnameVerifier(), p, true, connectTimeout);
getHostnameVerifier(), p, true, connectTimeout,
this);
}
// will open new connection
@ -198,7 +199,7 @@ public abstract class AbstractDelegateHttpsURLConnection extends
throws IOException {
return HttpsClient.New(getSSLSocketFactory(), url,
getHostnameVerifier(), p,
useCache, connectTimeout);
useCache, connectTimeout, this);
}
/**

@ -30,6 +30,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.PrintStream;
import java.io.BufferedOutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketException;
import java.net.URL;
@ -46,11 +47,15 @@ import javax.security.auth.x500.X500Principal;
import javax.net.ssl.*;
import sun.net.www.http.HttpClient;
import sun.net.www.protocol.http.HttpURLConnection;
import sun.security.action.*;
import sun.security.util.HostnameChecker;
import sun.security.ssl.SSLSocketImpl;
import sun.util.logging.PlatformLogger;
import static sun.net.www.protocol.http.HttpURLConnection.TunnelState.*;
/**
* This class provides HTTPS client URL support, building on the standard
@ -274,15 +279,17 @@ final class HttpsClient extends HttpClient
// This code largely ripped off from HttpClient.New, and
// it uses the same keepalive cache.
static HttpClient New(SSLSocketFactory sf, URL url, HostnameVerifier hv)
static HttpClient New(SSLSocketFactory sf, URL url, HostnameVerifier hv,
HttpURLConnection httpuc)
throws IOException {
return HttpsClient.New(sf, url, hv, true);
return HttpsClient.New(sf, url, hv, true, httpuc);
}
/** See HttpClient for the model for this method. */
static HttpClient New(SSLSocketFactory sf, URL url,
HostnameVerifier hv, boolean useCache) throws IOException {
return HttpsClient.New(sf, url, hv, (String)null, -1, useCache);
HostnameVerifier hv, boolean useCache,
HttpURLConnection httpuc) throws IOException {
return HttpsClient.New(sf, url, hv, (String)null, -1, useCache, httpuc);
}
/**
@ -290,37 +297,74 @@ final class HttpsClient extends HttpClient
* the specified proxy server.
*/
static HttpClient New(SSLSocketFactory sf, URL url, HostnameVerifier hv,
String proxyHost, int proxyPort) throws IOException {
return HttpsClient.New(sf, url, hv, proxyHost, proxyPort, true);
String proxyHost, int proxyPort,
HttpURLConnection httpuc) throws IOException {
return HttpsClient.New(sf, url, hv, proxyHost, proxyPort, true, httpuc);
}
static HttpClient New(SSLSocketFactory sf, URL url, HostnameVerifier hv,
String proxyHost, int proxyPort, boolean useCache)
String proxyHost, int proxyPort, boolean useCache,
HttpURLConnection httpuc)
throws IOException {
return HttpsClient.New(sf, url, hv, proxyHost, proxyPort, useCache, -1);
return HttpsClient.New(sf, url, hv, proxyHost, proxyPort, useCache, -1,
httpuc);
}
static HttpClient New(SSLSocketFactory sf, URL url, HostnameVerifier hv,
String proxyHost, int proxyPort, boolean useCache,
int connectTimeout)
int connectTimeout, HttpURLConnection httpuc)
throws IOException {
return HttpsClient.New(sf, url, hv,
(proxyHost == null? null :
HttpsClient.newHttpProxy(proxyHost, proxyPort)),
useCache, connectTimeout);
useCache, connectTimeout, httpuc);
}
static HttpClient New(SSLSocketFactory sf, URL url, HostnameVerifier hv,
Proxy p, boolean useCache,
int connectTimeout)
throws IOException {
int connectTimeout, HttpURLConnection httpuc)
throws IOException
{
if (p == null) {
p = Proxy.NO_PROXY;
}
HttpsClient ret = null;
if (useCache) {
/* see if one's already around */
ret = (HttpsClient) kac.get(url, sf);
if (ret != null && httpuc != null &&
httpuc.streaming() &&
httpuc.getRequestMethod() == "POST") {
if (!ret.available())
ret = null;
}
if (ret != null) {
ret.cachedHttpClient = true;
if ((ret.proxy != null && ret.proxy.equals(p)) ||
(ret.proxy == null && p == null)) {
synchronized (ret) {
ret.cachedHttpClient = true;
assert ret.inCache;
ret.inCache = false;
if (httpuc != null && ret.needsTunneling())
httpuc.setTunnelState(TUNNELING);
PlatformLogger logger = HttpURLConnection.getHttpLogger();
if (logger.isLoggable(PlatformLogger.FINEST)) {
logger.finest("KeepAlive stream retrieved from the cache, " + ret);
}
}
} else {
// We cannot return this connection to the cache as it's
// KeepAliveTimeout will get reset. We simply close the connection.
// This should be fine as it is very rare that a connection
// to the same host will not use the same proxy.
synchronized(ret) {
ret.inCache = false;
ret.closeServer();
}
ret = null;
}
}
}
if (ret == null) {
@ -328,7 +372,11 @@ final class HttpsClient extends HttpClient
} else {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkConnect(url.getHost(), url.getPort());
if (ret.proxy == Proxy.NO_PROXY || ret.proxy == null) {
security.checkConnect(InetAddress.getByName(url.getHost()).getHostAddress(), url.getPort());
} else {
security.checkConnect(url.getHost(), url.getPort());
}
}
ret.url = url;
}
@ -607,6 +655,11 @@ final class HttpsClient extends HttpClient
@Override
protected void putInKeepAliveCache() {
if (inCache) {
assert false : "Duplicate put to keep alive cache";
return;
}
inCache = true;
kac.put(url, sslSocketFactory, this);
}

@ -51,7 +51,7 @@ public class JarURLConnection extends java.net.JarURLConnection {
/* the Jar file factory. It handles both retrieval and caching.
*/
private static JarFileFactory factory = new JarFileFactory();
private static final JarFileFactory factory = JarFileFactory.getInstance();
/* the url for the Jar file */
private URL jarFileURL;

@ -138,7 +138,7 @@ public final class KdcComm {
int timeout = -1;
int max_retries = -1;
int udf_pref_limit = -1;
int udp_pref_limit = -1;
try {
Config cfg = Config.getInstance();
@ -147,7 +147,7 @@ public final class KdcComm {
temp = cfg.get("libdefaults", "max_retries");
max_retries = parsePositiveIntString(temp);
temp = cfg.get("libdefaults", "udp_preference_limit");
udf_pref_limit = parsePositiveIntString(temp);
udp_pref_limit = parsePositiveIntString(temp);
} catch (Exception exc) {
// ignore any exceptions; use default values
if (DEBUG) {
@ -159,7 +159,14 @@ public final class KdcComm {
defaultKdcTimeout = timeout > 0 ? timeout : 30*1000; // 30 seconds
defaultKdcRetryLimit =
max_retries > 0 ? max_retries : Krb5.KDC_RETRY_LIMIT;
defaultUdpPrefLimit = udf_pref_limit;
if (udp_pref_limit < 0) {
defaultUdpPrefLimit = Krb5.KDC_DEFAULT_UDP_PREF_LIMIT;
} else if (udp_pref_limit > Krb5.KDC_HARD_UDP_LIMIT) {
defaultUdpPrefLimit = Krb5.KDC_HARD_UDP_LIMIT;
} else {
defaultUdpPrefLimit = udp_pref_limit;
}
KdcAccessibility.reset();
}

@ -130,6 +130,8 @@ public class Krb5 {
// number of retries before giving up
public static final int KDC_RETRY_LIMIT = 3;
public static final int KDC_DEFAULT_UDP_PREF_LIMIT = 1465;
public static final int KDC_HARD_UDP_LIMIT = 32700;
//OSI authentication mechanism OID

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, 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,8 +29,10 @@ import java.io.IOException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import javax.security.auth.x500.X500Principal;
import sun.misc.HexDumpEncoder;
import sun.security.x509.*;
import sun.security.util.*;
@ -70,6 +72,13 @@ public class CertId {
public CertId(X509Certificate issuerCert, SerialNumber serialNumber)
throws IOException {
this(issuerCert.getSubjectX500Principal(),
issuerCert.getPublicKey(), serialNumber);
}
public CertId(X500Principal issuerName, PublicKey issuerKey,
SerialNumber serialNumber) throws IOException {
// compute issuerNameHash
MessageDigest md = null;
try {
@ -78,11 +87,11 @@ public class CertId {
throw new IOException("Unable to create CertId", nsae);
}
hashAlgId = SHA1_ALGID;
md.update(issuerCert.getSubjectX500Principal().getEncoded());
md.update(issuerName.getEncoded());
issuerNameHash = md.digest();
// compute issuerKeyHash (remove the tag and length)
byte[] pubKey = issuerCert.getPublicKey().getEncoded();
byte[] pubKey = issuerKey.getEncoded();
DerValue val = new DerValue(pubKey);
DerValue[] seq = new DerValue[2];
seq[0] = val.data.getDerValue(); // AlgorithmID
@ -94,7 +103,7 @@ public class CertId {
if (debug) {
HexDumpEncoder encoder = new HexDumpEncoder();
System.out.println("Issuer Certificate is " + issuerCert);
System.out.println("Issuer Name is " + issuerName);
System.out.println("issuerNameHash is " +
encoder.encodeBuffer(issuerNameHash));
System.out.println("issuerKeyHash is " +

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2013, 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
@ -345,10 +345,8 @@ class DistributionPointFetcher {
return false;
} else {
// in case of self-issued indirect CRL issuer.
byte[] certAKID = certImpl.getExtensionValue(
AuthorityKey_Id.toString());
byte[] crlAKID = crlImpl.getExtensionValue(
AuthorityKey_Id.toString());
KeyIdentifier certAKID = certImpl.getAuthKeyId();
KeyIdentifier crlAKID = crlImpl.getAuthKeyId();
if (certAKID == null || crlAKID == null) {
// cannot recognize indirect CRL without AKID
@ -359,7 +357,7 @@ class DistributionPointFetcher {
// reset the public key used to verify the CRL's signature
prevKey = certImpl.getPublicKey();
}
} else if (!Arrays.equals(certAKID, crlAKID)) {
} else if (!certAKID.equals(crlAKID)) {
// we accept the case that a CRL issuer provide status
// information for itself.
if (issues(certImpl, crlImpl, provider)) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013, 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
@ -643,7 +643,14 @@ class RevocationChecker extends PKIXRevocationChecker {
OCSPResponse response = null;
CertId certId = null;
try {
certId = new CertId(issuerCert, currCert.getSerialNumberObject());
if (issuerCert != null) {
certId = new CertId(issuerCert,
currCert.getSerialNumberObject());
} else {
// must be an anchor name and key
certId = new CertId(anchor.getCA(), anchor.getCAPublicKey(),
currCert.getSerialNumberObject());
}
// check if there is a cached OCSP response available
byte[] responseBytes = ocspResponses.get(cert);

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2013, 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
@ -1095,6 +1095,18 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
}
}
public KeyIdentifier getAuthKeyId() {
AuthorityKeyIdentifierExtension aki
= getAuthorityKeyIdentifierExtension();
if (aki != null) {
try {
return (KeyIdentifier)aki.get(
AuthorityKeyIdentifierExtension.KEY_ID);
} catch (IOException ioe) {} // not possible
}
return null;
}
/**
* Get AuthorityKeyIdentifier extension
* @return AuthorityKeyIdentifier object or null (if no such object

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, 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
@ -50,7 +50,7 @@ public class JMap {
// These options imply the use of a SA tool
private static String SA_TOOL_OPTIONS =
"-heap|-heap:format=b|-permstat|-finalizerinfo";
"-heap|-heap:format=b|-clstats|-finalizerinfo";
// The -F (force) option is currently not passed through to SA
private static String FORCE_SA_OPTION = "-F";
@ -147,12 +147,12 @@ public class JMap {
// Invoke SA tool with the given arguments
private static void runTool(String option, String args[]) throws Exception {
String[][] tools = {
{ "-pmap", "sun.jvm.hotspot.tools.PMap" },
{ "-heap", "sun.jvm.hotspot.tools.HeapSummary" },
{ "-heap:format=b", "sun.jvm.hotspot.tools.HeapDumper" },
{ "-histo", "sun.jvm.hotspot.tools.ObjectHistogram" },
{ "-permstat", "sun.jvm.hotspot.tools.PermStat" },
{ "-finalizerinfo", "sun.jvm.hotspot.tools.FinalizerInfo" },
{ "-pmap", "sun.jvm.hotspot.tools.PMap" },
{ "-heap", "sun.jvm.hotspot.tools.HeapSummary" },
{ "-heap:format=b", "sun.jvm.hotspot.tools.HeapDumper" },
{ "-histo", "sun.jvm.hotspot.tools.ObjectHistogram" },
{ "-clstats", "sun.jvm.hotspot.tools.ClassLoaderStats" },
{ "-finalizerinfo", "sun.jvm.hotspot.tools.FinalizerInfo" },
};
String tool = null;
@ -356,7 +356,7 @@ public class JMap {
System.out.println(" -heap to print java heap summary");
System.out.println(" -histo[:live] to print histogram of java object heap; if the \"live\"");
System.out.println(" suboption is specified, only count live objects");
System.out.println(" -permstat to print permanent generation statistics");
System.out.println(" -clstats to print class loader statistics");
System.out.println(" -finalizerinfo to print information on objects awaiting finalization");
System.out.println(" -dump:<dump-options> to dump java heap in hprof binary format");
System.out.println(" dump-options:");

@ -192,16 +192,16 @@ option gc {
format "0.0"
}
column {
header "^PC^" /* Perm Space Capacity - Current */
data sun.gc.generation.2.space.0.capacity
header "^MC^" /* Metaspace Capacity - Current */
data sun.gc.metaspace.capacity
align center
width 6
scale K
format "0.0"
}
column {
header "^PU^" /* Perm Space Used */
data sun.gc.generation.2.space.0.used
header "^MU^" /* Metaspae Used */
data sun.gc.metaspace.used
align center
width 6
scale K
@ -330,32 +330,24 @@ option gccapacity {
format "0.0"
}
column {
header "^PGCMN^" /* Perm Generation Capacity - Minimum */
data sun.gc.generation.2.minCapacity
header "^MCMN^" /* Metaspace Capacity - Minimum */
data sun.gc.metaspace.minCapacity
scale K
align right
width 8
format "0.0"
}
column {
header "^PGCMX^" /* Perm Generation Capacity - Maximum */
data sun.gc.generation.2.maxCapacity
header "^MCMX^" /* Metaspace Capacity - Maximum */
data sun.gc.metaspace.maxCapacity
scale K
align right
width 8
format "0.0"
}
column {
header "^PGC^" /* Perm Generation Capacity - Current */
data sun.gc.generation.2.capacity
scale K
align right
width 8
format "0.0"
}
column {
header "^PC^" /* Perm Space Capacity - Current */
data sun.gc.generation.2.space.0.capacity
header "^MC^" /* Metaspace Capacity - Current */
data sun.gc.metaspace.capacity
scale K
align right
width 8
@ -412,8 +404,8 @@ option gccause {
format "0.00"
}
column {
header "^P^" /* Perm Space - Percent Used */
data (1-((sun.gc.generation.2.space.0.capacity - sun.gc.generation.2.space.0.used)/sun.gc.generation.2.space.0.capacity)) * 100
header "^M^" /* Metaspace - Percent Used */
data (1-((sun.gc.metaspace.capacity - sun.gc.metaspace.used)/sun.gc.metaspace.capacity)) * 100
align right
width 6
scale raw
@ -654,16 +646,16 @@ option gcnewcapacity {
option gcold {
column {
header "^PC^" /* Perm Space Capacity - Current */
data sun.gc.generation.2.space.0.capacity
header "^MC^" /* Metaspace Capacity - Current */
data sun.gc.metaspace.capacity
width 8
align right
scale K
format "0.0"
}
column {
header "^PU^" /* Perm Space Used */
data sun.gc.generation.2.space.0.used
header "^MU^" /* Metaspace Space Used */
data sun.gc.metaspace.used
width 8
align right
scale K
@ -784,34 +776,26 @@ option gcoldcapacity {
}
}
option gcpermcapacity {
option gcmetacapacity {
column {
header "^PGCMN^" /* Perm Generation Capacity - Minumum */
data sun.gc.generation.2.minCapacity
header "^MCMN^" /* Metaspace Capacity - Minimum */
data sun.gc.metaspace.minCapacity
scale K
align right
width 10
format "0.0"
}
column {
header "^PGCMX^" /* Perm Generation Capacity - Maximum */
data sun.gc.generation.2.maxCapacity
header "^MCMX^" /* Metaspace Capacity - Maximum */
data sun.gc.metaspace.maxCapacity
scale K
align right
width 10
format "0.0"
}
column {
header "^PGC^" /* Perm Generation Capacity - Current */
data sun.gc.generation.2.capacity
scale K
align right
width 10
format "0.0"
}
column {
header "^PC^" /* Perm Space Capacity - Current */
data sun.gc.generation.2.space.0.capacity
header "^MC^" /* Metaspace Capacity - Current */
data sun.gc.metaspace.capacity
scale K
align right
width 10
@ -884,8 +868,8 @@ option gcutil {
format "0.00"
}
column {
header "^P^" /* Perm Space - Percent Used */
data (1-((sun.gc.generation.2.space.0.capacity - sun.gc.generation.2.space.0.used)/sun.gc.generation.2.space.0.capacity)) * 100
header "^M^" /* Metaspace Space - Percent Used */
data (1-((sun.gc.metaspace.capacity - sun.gc.metaspace.used)/sun.gc.metaspace.capacity)) * 100
align right
width 6
scale raw

@ -134,7 +134,7 @@ public class LanguageTag {
}
/*
* BNF in RFC5464
* BNF in RFC5646
*
* Language-Tag = langtag ; normal language tags
* / privateuse ; private use tag

@ -43,6 +43,7 @@ import java.util.spi.CurrencyNameProvider;
import java.util.spi.LocaleNameProvider;
import java.util.spi.LocaleServiceProvider;
import java.util.spi.TimeZoneNameProvider;
import sun.util.spi.CalendarProvider;
/**
* An abstract parent class for the
@ -140,6 +141,14 @@ public abstract class AuxLocaleProviderAdapter extends LocaleProviderAdapter {
return getLocaleServiceProvider(CalendarNameProvider.class);
}
/**
* Getter methods for sun.util.spi.* providers
*/
@Override
public CalendarProvider getCalendarProvider() {
return getLocaleServiceProvider(CalendarProvider.class);
}
@Override
public LocaleResources getLocaleResources(Locale locale) {
return null;

@ -0,0 +1,95 @@
/*
* Copyright (c) 2013, 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.util.locale.provider;
import java.util.Calendar;
import java.util.Calendar.Builder;
import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;
import sun.util.spi.CalendarProvider;
/**
* Concrete implementation of the {@link sun.util.spi.CalendarProvider
* CalendarProvider} class for the JRE LocaleProviderAdapter.
*
* @author Naoto Sato
*/
public class CalendarProviderImpl extends CalendarProvider implements AvailableLanguageTags {
private final LocaleProviderAdapter.Type type;
private final Set<String> langtags;
public CalendarProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags) {
this.type = type;
this.langtags = langtags;
}
/**
* Returns an array of all locales for which this locale service provider
* can provide localized objects or names.
*
* @return An array of all locales for which this locale service provider
* can provide localized objects or names.
*/
@Override
public Locale[] getAvailableLocales() {
return LocaleProviderAdapter.toLocaleArray(langtags);
}
@Override
public boolean isSupportedLocale(Locale locale) {
// Support any locales.
return true;
}
/**
* Returns a new <code>Calendar</code> instance for the
* specified locale.
*
* @param zone the time zone
* @param locale the desired locale
* @exception NullPointerException if <code>locale</code> is null
* @exception IllegalArgumentException if <code>locale</code> isn't
* one of the locales returned from
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
* getAvailableLocales()}.
* @return a <code>Calendar</code> instance.
* @see java.util.Calendar#getInstance(java.util.Locale)
*/
@Override
public Calendar getInstance(TimeZone zone, Locale locale) {
return new Calendar.Builder()
.setLocale(locale)
.setTimeZone(zone)
.setInstant(System.currentTimeMillis())
.build();
}
@Override
public Set<String> getAvailableLanguageTags() {
return langtags;
}
}

@ -34,10 +34,12 @@ import java.text.spi.DateFormatProvider;
import java.text.spi.DateFormatSymbolsProvider;
import java.text.spi.DecimalFormatSymbolsProvider;
import java.text.spi.NumberFormatProvider;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.spi.CalendarDataProvider;
@ -47,6 +49,7 @@ import java.util.spi.LocaleNameProvider;
import java.util.spi.LocaleServiceProvider;
import java.util.spi.TimeZoneNameProvider;
import sun.util.resources.LocaleData;
import sun.util.spi.CalendarProvider;
/**
* LocaleProviderAdapter implementation for the legacy JRE locale data.
@ -104,6 +107,8 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
return (P) getCalendarDataProvider();
case "CalendarNameProvider":
return (P) getCalendarNameProvider();
case "CalendarProvider":
return (P) getCalendarProvider();
default:
throw new InternalError("should not come down here");
}
@ -122,6 +127,8 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
private volatile CalendarDataProvider calendarDataProvider = null;
private volatile CalendarNameProvider calendarNameProvider = null;
private volatile CalendarProvider calendarProvider = null;
/*
* Getter methods for java.text.spi.* providers
*/
@ -283,6 +290,23 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
return calendarNameProvider;
}
/**
* Getter methods for sun.util.spi.* providers
*/
@Override
public CalendarProvider getCalendarProvider() {
if (calendarProvider == null) {
CalendarProvider provider = new CalendarProviderImpl(getAdapterType(),
getLanguageTagSet("CalendarData"));
synchronized (this) {
if (calendarProvider == null) {
calendarProvider = provider;
}
}
}
return calendarProvider;
}
@Override
public LocaleResources getLocaleResources(Locale locale) {
LocaleResources lr = localeResourcesMap.get(locale);

@ -47,6 +47,7 @@ import java.util.spi.LocaleNameProvider;
import java.util.spi.LocaleServiceProvider;
import java.util.spi.TimeZoneNameProvider;
import sun.util.cldr.CLDRLocaleProviderAdapter;
import sun.util.spi.CalendarProvider;
/**
* The LocaleProviderAdapter abstract class.
@ -295,7 +296,10 @@ public abstract class LocaleProviderAdapter {
}
if (type == Type.JRE) {
String oldname = locale.toString().replace('_', '-');
return langtags.contains(oldname);
return langtags.contains(oldname) ||
"ja-JP-JP".equals(oldname) ||
"th-TH-TH".equals(oldname) ||
"no-NO-NY".equals(oldname);
}
return false;
}
@ -422,6 +426,14 @@ public abstract class LocaleProviderAdapter {
*/
public abstract CalendarNameProvider getCalendarNameProvider();
/**
* Returns a CalendarProvider for this LocaleProviderAdapter, or null if no
* CalendarProvider is available.
*
* @return a CalendarProvider
*/
public abstract CalendarProvider getCalendarProvider();
public abstract LocaleResources getLocaleResources(Locale locale);
public abstract Locale[] getAvailableLocales();

@ -0,0 +1,64 @@
/*
* Copyright (c) 2013, 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.util.spi;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
import java.util.spi.LocaleServiceProvider;
/**
* An abstract class for service providers that
* provide instances of the
* {@link java.util.Calendar Calendar} class.
*
* @since 1.8
*/
public abstract class CalendarProvider extends LocaleServiceProvider {
/**
* Sole constructor. (For invocation by subclass constructors, typically
* implicit.)
*/
protected CalendarProvider() {
}
/**
* Returns a new <code>Calendar</code> instance for the
* specified locale.
*
* @param zone the time zone
* @param locale the desired locale
* @exception NullPointerException if <code>locale</code> is null
* @exception IllegalArgumentException if <code>locale</code> isn't
* one of the locales returned from
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
* getAvailableLocales()}.
* @return a <code>Calendar</code> instance.
* @see java.util.Calendar#getInstance(java.util.Locale)
*/
public abstract Calendar getInstance(TimeZone zone, Locale locale);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2013, 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
@ -1951,6 +1951,7 @@ JNI_OnUnload(JavaVM *vm, void *reserved);
#define JNI_VERSION_1_2 0x00010002
#define JNI_VERSION_1_4 0x00010004
#define JNI_VERSION_1_6 0x00010006
#define JNI_VERSION_1_8 0x00010008
#ifdef __cplusplus
} /* extern "C" */

@ -157,7 +157,9 @@ package.access=sun.,\
com.sun.org.apache.xalan.internal.utils.,\
com.sun.org.glassfish.external.,\
com.sun.org.glassfish.gmbal.,\
jdk.internal.
jdk.internal.,\
jdk.nashorn.internal.,\
jdk.nashorn.tools.
#
# List of comma-separated packages that start with or equal this string
@ -181,7 +183,9 @@ package.definition=sun.,\
com.sun.org.apache.xalan.internal.utils.,\
com.sun.org.glassfish.external.,\
com.sun.org.glassfish.gmbal.,\
jdk.internal.
jdk.internal.,\
jdk.nashorn.internal.,\
jdk.nashorn.tools.
#
# Determines whether this properties file can be appended to

@ -159,6 +159,8 @@ package.access=sun.,\
com.sun.org.glassfish.external.,\
com.sun.org.glassfish.gmbal.,\
jdk.internal.,\
jdk.nashorn.internal.,\
jdk.nashorn.tools.,\
apple.
#
@ -184,6 +186,8 @@ package.definition=sun.,\
com.sun.org.glassfish.external.,\
com.sun.org.glassfish.gmbal.,\
jdk.internal.,\
jdk.nashorn.internal.,\
jdk.nashorn.tools.,\
apple.
#

@ -159,7 +159,9 @@ package.access=sun.,\
com.sun.org.apache.xalan.internal.utils.,\
com.sun.org.glassfish.external.,\
com.sun.org.glassfish.gmbal.,\
jdk.internal.
jdk.internal.,\
jdk.nashorn.internal.,\
jdk.nashorn.tools.
#
# List of comma-separated packages that start with or equal this string
@ -183,7 +185,9 @@ package.definition=sun.,\
com.sun.org.apache.xalan.internal.utils.,\
com.sun.org.glassfish.external.,\
com.sun.org.glassfish.gmbal.,\
jdk.internal.
jdk.internal.,\
jdk.nashorn.internal.,\
jdk.nashorn.tools.
#
# Determines whether this properties file can be appended to

@ -158,7 +158,9 @@ package.access=sun.,\
com.sun.org.apache.xalan.internal.utils.,\
com.sun.org.glassfish.external.,\
com.sun.org.glassfish.gmbal.,\
jdk.internal.
jdk.internal.,\
jdk.nashorn.internal.,\
jdk.nashorn.tools.
#
# List of comma-separated packages that start with or equal this string
@ -182,7 +184,9 @@ package.definition=sun.,\
com.sun.org.apache.xalan.internal.utils.,\
com.sun.org.glassfish.external.,\
com.sun.org.glassfish.gmbal.,\
jdk.internal.
jdk.internal.,\
jdk.nashorn.internal.,\
jdk.nashorn.tools.
#
# Determines whether this properties file can be appended to

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, 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
@ -339,6 +339,10 @@ int getFastEncoding();
void initializeEncoding();
void* getProcessHandle();
void buildJniFunctionName(const char *sym, const char *cname,
char *jniEntryName);
#ifdef __cplusplus
} /* extern "C" */

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2000, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, 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,8 @@
* questions.
*/
#include "jni.h"
#include "jvm.h"
#include "jni_util.h"
#include "jlong.h"
#include "jdk_util.h"
#include "java_lang_Float.h"
#include "java_lang_Double.h"
@ -88,7 +86,7 @@ Java_java_io_ObjectOutputStream_floatsToBytes(JNIEnv *env,
srcend = srcpos + nfloats;
for ( ; srcpos < srcend; srcpos++) {
fval = (float) floats[srcpos];
if (JVM_IsNaN(fval)) { /* collapse NaNs */
if (ISNANF(fval)) { /* collapse NaNs */
ival = 0x7fc00000;
} else {
u.f = fval;
@ -160,7 +158,7 @@ Java_java_io_ObjectOutputStream_doublesToBytes(JNIEnv *env,
srcend = srcpos + ndoubles;
for ( ; srcpos < srcend; srcpos++) {
dval = doubles[srcpos];
if (JVM_IsNaN((double) dval)) { /* collapse NaNs */
if (ISNAND((double) dval)) { /* collapse NaNs */
lval = jint_to_jlong(0x7ff80000);
lval = jlong_shl(lval, 32);
} else {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2013, 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
@ -47,10 +47,8 @@ readSingle(JNIEnv *env, jobject this, jfieldID fid) {
nread = IO_Read(fd, &ret, 1);
if (nread == 0) { /* EOF */
return -1;
} else if (nread == JVM_IO_ERR) { /* error */
} else if (nread == -1) { /* error */
JNU_ThrowIOExceptionWithLastError(env, "Read error");
} else if (nread == JVM_IO_INTR) {
JNU_ThrowByName(env, "java/io/InterruptedIOException", NULL);
}
return ret & 0xFF;
}
@ -111,10 +109,8 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes,
nread = IO_Read(fd, buf, len);
if (nread > 0) {
(*env)->SetByteArrayRegion(env, bytes, off, nread, (jbyte *)buf);
} else if (nread == JVM_IO_ERR) {
} else if (nread == -1) {
JNU_ThrowIOExceptionWithLastError(env, "Read error");
} else if (nread == JVM_IO_INTR) {
JNU_ThrowByName(env, "java/io/InterruptedIOException", NULL);
} else { /* EOF */
nread = -1;
}
@ -141,10 +137,8 @@ writeSingle(JNIEnv *env, jobject this, jint byte, jboolean append, jfieldID fid)
} else {
n = IO_Write(fd, &c, 1);
}
if (n == JVM_IO_ERR) {
if (n == -1) {
JNU_ThrowIOExceptionWithLastError(env, "Write error");
} else if (n == JVM_IO_INTR) {
JNU_ThrowByName(env, "java/io/InterruptedIOException", NULL);
}
}
@ -194,12 +188,9 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes,
} else {
n = IO_Write(fd, buf+off, len);
}
if (n == JVM_IO_ERR) {
if (n == -1) {
JNU_ThrowIOExceptionWithLastError(env, "Write error");
break;
} else if (n == JVM_IO_INTR) {
JNU_ThrowByName(env, "java/io/InterruptedIOException", NULL);
break;
}
off += n;
len -= n;
@ -214,11 +205,11 @@ void
throwFileNotFoundException(JNIEnv *env, jstring path)
{
char buf[256];
jint n;
size_t n;
jobject x;
jstring why = NULL;
n = JVM_GetLastErrorString(buf, sizeof(buf));
n = getLastErrorString(buf, sizeof(buf));
if (n > 0) {
why = JNU_NewStringPlatform(env, buf);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, 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
@ -54,7 +54,7 @@ void writeBytes(JNIEnv *env, jobject this, jbyteArray bytes, jint off,
jint len, jboolean append, jfieldID fid);
void fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags);
void throwFileNotFoundException(JNIEnv *env, jstring path);
size_t getLastErrorString(char *buf, size_t len);
/*
* Macros for managing platform strings. The typical usage pattern is:

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,6 +32,7 @@
#include "jvm.h"
#include "java_lang_ClassLoader.h"
#include "java_lang_ClassLoader_NativeLibrary.h"
#include <string.h>
/* defined in libverify.so/verify.dll (src file common/check_format.c) */
extern jboolean VerifyClassname(char *utf_name, jboolean arrayAllowed);
@ -286,6 +287,8 @@ Java_java_lang_ClassLoader_findLoadedClass0(JNIEnv *env, jobject loader,
static jfieldID handleID;
static jfieldID jniVersionID;
static jfieldID loadedID;
static void *procHandle;
static jboolean initIDs(JNIEnv *env)
{
@ -300,6 +303,10 @@ static jboolean initIDs(JNIEnv *env)
jniVersionID = (*env)->GetFieldID(env, this, "jniVersion", "I");
if (jniVersionID == 0)
return JNI_FALSE;
loadedID = (*env)->GetFieldID(env, this, "loaded", "Z");
if (loadedID == 0)
return JNI_FALSE;
procHandle = getProcessHandle();
}
return JNI_TRUE;
}
@ -307,14 +314,60 @@ static jboolean initIDs(JNIEnv *env)
typedef jint (JNICALL *JNI_OnLoad_t)(JavaVM *, void *);
typedef void (JNICALL *JNI_OnUnload_t)(JavaVM *, void *);
/*
* Support for finding JNI_On(Un)Load_<lib_name> if it exists.
* If cname == NULL then just find normal JNI_On(Un)Load entry point
*/
static void *findJniFunction(JNIEnv *env, void *handle,
const char *cname, jboolean isLoad) {
const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
const char *onUnloadSymbols[] = JNI_ONUNLOAD_SYMBOLS;
const char **syms;
int symsLen;
void *entryName = NULL;
char *jniFunctionName;
int i;
int len;
// Check for JNI_On(Un)Load<_libname> function
if (isLoad) {
syms = onLoadSymbols;
symsLen = sizeof(onLoadSymbols) / sizeof(char *);
} else {
syms = onUnloadSymbols;
symsLen = sizeof(onUnloadSymbols) / sizeof(char *);
}
for (i = 0; i < symsLen; i++) {
// cname + sym + '_' + '\0'
if ((len = (cname != NULL ? strlen(cname) : 0) + strlen(syms[i]) + 2) >
FILENAME_MAX) {
goto done;
}
jniFunctionName = malloc(len);
if (jniFunctionName == NULL) {
JNU_ThrowOutOfMemoryError(env, NULL);
goto done;
}
buildJniFunctionName(syms[i], cname, jniFunctionName);
entryName = JVM_FindLibraryEntry(handle, jniFunctionName);
free(jniFunctionName);
if(entryName) {
break;
}
}
done:
return entryName;
}
/*
* Class: java_lang_ClassLoader_NativeLibrary
* Method: load
* Signature: (Ljava/lang/String;)J
* Signature: (Ljava/lang/String;Z)V
*/
JNIEXPORT void JNICALL
Java_java_lang_ClassLoader_00024NativeLibrary_load
(JNIEnv *env, jobject this, jstring name)
(JNIEnv *env, jobject this, jstring name, jboolean isBuiltin)
{
const char *cname;
jint jniVersion;
@ -327,18 +380,12 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load
cname = JNU_GetStringPlatformChars(env, name, 0);
if (cname == 0)
return;
handle = JVM_LoadLibrary(cname);
handle = isBuiltin ? procHandle : JVM_LoadLibrary(cname);
if (handle) {
const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
JNI_OnLoad_t JNI_OnLoad;
unsigned int i;
for (i = 0; i < sizeof(onLoadSymbols) / sizeof(char *); i++) {
JNI_OnLoad = (JNI_OnLoad_t)
JVM_FindLibraryEntry(handle, onLoadSymbols[i]);
if (JNI_OnLoad) {
break;
}
}
JNI_OnLoad = (JNI_OnLoad_t)findJniFunction(env, handle,
isBuiltin ? cname : NULL,
JNI_TRUE);
if (JNI_OnLoad) {
JavaVM *jvm;
(*env)->GetJavaVM(env, &jvm);
@ -351,17 +398,22 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load
if (cause) {
(*env)->ExceptionClear(env);
(*env)->Throw(env, cause);
JVM_UnloadLibrary(handle);
if (!isBuiltin) {
JVM_UnloadLibrary(handle);
}
goto done;
}
if (!JVM_IsSupportedJNIVersion(jniVersion)) {
if (!JVM_IsSupportedJNIVersion(jniVersion) ||
(isBuiltin && jniVersion < JNI_VERSION_1_8)) {
char msg[256];
jio_snprintf(msg, sizeof(msg),
"unsupported JNI version 0x%08X required by %s",
jniVersion, cname);
JNU_ThrowByName(env, "java/lang/UnsatisfiedLinkError", msg);
JVM_UnloadLibrary(handle);
if (!isBuiltin) {
JVM_UnloadLibrary(handle);
}
goto done;
}
(*env)->SetIntField(env, this, jniVersionID, jniVersion);
@ -375,6 +427,7 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load
goto done;
}
(*env)->SetLongField(env, this, handleID, ptr_to_jlong(handle));
(*env)->SetBooleanField(env, this, loadedID, JNI_TRUE);
done:
JNU_ReleaseStringPlatformChars(env, name, cname);
@ -383,41 +436,42 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load
/*
* Class: java_lang_ClassLoader_NativeLibrary
* Method: unload
* Signature: ()V
* Signature: (Z)V
*/
JNIEXPORT void JNICALL
Java_java_lang_ClassLoader_00024NativeLibrary_unload
(JNIEnv *env, jobject this)
(JNIEnv *env, jobject this, jstring name, jboolean isBuiltin)
{
const char *onUnloadSymbols[] = JNI_ONUNLOAD_SYMBOLS;
void *handle;
JNI_OnUnload_t JNI_OnUnload;
unsigned int i;
const char *cname;
if (!initIDs(env))
return;
handle = jlong_to_ptr((*env)->GetLongField(env, this, handleID));
for (i = 0; i < sizeof(onUnloadSymbols) / sizeof(char *); i++) {
JNI_OnUnload = (JNI_OnUnload_t )
JVM_FindLibraryEntry(handle, onUnloadSymbols[i]);
if (JNI_OnUnload) {
break;
}
cname = JNU_GetStringPlatformChars(env, name, 0);
if (cname == NULL) {
return;
}
handle = jlong_to_ptr((*env)->GetLongField(env, this, handleID));
JNI_OnUnload = (JNI_OnUnload_t )findJniFunction(env, handle,
isBuiltin ? cname : NULL,
JNI_FALSE);
if (JNI_OnUnload) {
JavaVM *jvm;
(*env)->GetJavaVM(env, &jvm);
(*JNI_OnUnload)(jvm, NULL);
}
JVM_UnloadLibrary(handle);
if (!isBuiltin) {
JVM_UnloadLibrary(handle);
}
JNU_ReleaseStringPlatformChars(env, name, cname);
}
/*
* Class: java_lang_ClassLoader_NativeLibrary
* Method: find
* Signature: (Ljava/lang/String;J)J
* Signature: (Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL
Java_java_lang_ClassLoader_00024NativeLibrary_find
@ -456,3 +510,63 @@ Java_java_lang_ClassLoader_getCaller(JNIEnv *env, jclass cls, jint index)
return NULL;
}
/*
* Class: java_lang_ClassLoader_NativeLibrary
* Method: findBuiltinLib
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib
(JNIEnv *env, jclass cls, jstring name)
{
const char *cname;
char *libName;
int prefixLen = (int) strlen(JNI_LIB_PREFIX);
int suffixLen = (int) strlen(JNI_LIB_SUFFIX);
int len;
jstring lib;
void *ret;
const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
if (name == NULL) {
JNU_ThrowInternalError(env, "NULL filename for native library");
return NULL;
}
// Can't call initIDs because it will recurse into NativeLibrary via
// FindClass to check context so set prochandle here as well.
procHandle = getProcessHandle();
cname = JNU_GetStringPlatformChars(env, name, 0);
if (cname == NULL) {
JNU_ThrowOutOfMemoryError(env, NULL);
return NULL;
}
// Copy name Skipping PREFIX
len = strlen(cname);
if (len <= (prefixLen+suffixLen)) {
JNU_ReleaseStringPlatformChars(env, name, cname);
return NULL;
}
libName = malloc(len + 1); //+1 for null if prefix+suffix == 0
if (libName == NULL) {
JNU_ReleaseStringPlatformChars(env, name, cname);
JNU_ThrowOutOfMemoryError(env, NULL);
return NULL;
}
if (len > prefixLen) {
strcpy(libName, cname+prefixLen);
}
JNU_ReleaseStringPlatformChars(env, name, cname);
// Strip SUFFIX
libName[strlen(libName)-suffixLen] = '\0';
// Check for JNI_OnLoad_libname function
ret = findJniFunction(env, procHandle, libName, JNI_TRUE);
if (ret != NULL) {
lib = JNU_NewStringPlatform(env, libName);
free(libName);
return lib;
}
free(libName);
return NULL;
}

@ -27,8 +27,22 @@
#include "NativeUtil.h"
#include "NativeFunc.h"
#include "jlong.h"
#include <jni.h>
/* Constants for indicating what type of info is needed for inqueries */
/* Throws a Java Exception by name */
void throwByName(JNIEnv *env, const char *name, const char *msg) {
jclass cls = (*env)->FindClass(env, name);
if (cls != 0) /* Otherwise an exception has already been thrown */
(*env)->ThrowNew(env, cls, msg);
}
void throwOutOfMemoryError(JNIEnv *env, const char *message) {
throwByName(env, "java/lang/OutOfMemoryError", message);
}
/* Constants for indicating what type of info is needed for inquiries */
const int TYPE_CRED_NAME = 10;
const int TYPE_CRED_TIME = 11;
const int TYPE_CRED_USAGE = 12;
@ -117,7 +131,14 @@ gss_channel_bindings_t getGSSCB(JNIEnv *env, jobject jcb) {
if (jcb == NULL) {
return GSS_C_NO_CHANNEL_BINDINGS;
}
cb = malloc(sizeof(struct gss_channel_bindings_struct));
if (cb == NULL) {
throwOutOfMemoryError(env,NULL);
return NULL;
}
/* set up initiator address */
jinetAddr =
(*env)->CallObjectMethod(env, jcb,
@ -301,12 +322,15 @@ Java_sun_security_jgss_wrapper_GSSLibStub_importName(JNIEnv *env,
gss_buffer_desc nameVal;
gss_OID nameType;
gss_name_t nameHdl;
nameHdl = GSS_C_NO_NAME;
debug(env, "[GSSLibStub_importName]");
initGSSBuffer(env, jnameVal, &nameVal);
nameType = newGSSOID(env, jnameType);
nameHdl = GSS_C_NO_NAME;
if ((*env)->ExceptionCheck(env)) {
return jlong_zero;
}
/* gss_import_name(...) => GSS_S_BAD_NAMETYPE, GSS_S_BAD_NAME,
GSS_S_BAD_MECH */
@ -509,15 +533,18 @@ Java_sun_security_jgss_wrapper_GSSLibStub_acquireCred(JNIEnv *env,
gss_cred_usage_t credUsage;
gss_name_t nameHdl;
gss_cred_id_t credHdl;
credHdl = GSS_C_NO_CREDENTIAL;
debug(env, "[GSSLibStub_acquireCred]");
mech = (gss_OID) jlong_to_ptr((*env)->GetLongField(env, jobj, FID_GSSLibStub_pMech));
mechs = newGSSOIDSet(env, mech);
if ((*env)->ExceptionCheck(env)) {
return jlong_zero;
}
credUsage = (gss_cred_usage_t) usage;
nameHdl = (gss_name_t) jlong_to_ptr(pName);
credHdl = GSS_C_NO_CREDENTIAL;
sprintf(debugBuf, "[GSSLibStub_acquireCred] pName=%ld, usage=%d",
(long) pName, usage);
@ -628,7 +655,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_getCredName(JNIEnv *env,
/* return immediately if an exception has occurred */
if ((*env)->ExceptionCheck(env)) {
return 0;
return jlong_zero;
}
sprintf(debugBuf, "[GSSLibStub_getCredName] pName=%ld", (long) nameHdl);
@ -795,6 +822,10 @@ Java_sun_security_jgss_wrapper_GSSLibStub_initContext(JNIEnv *env,
time = getGSSTime((*env)->GetIntField(env, jcontextSpi,
FID_NativeGSSContext_lifetime));
cb = getGSSCB(env, jcb);
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
initGSSBuffer(env, jinToken, &inToken);
sprintf(debugBuf,
@ -895,6 +926,9 @@ Java_sun_security_jgss_wrapper_GSSLibStub_acceptContext(JNIEnv *env,
credHdl = (gss_cred_id_t) jlong_to_ptr(pCred);
initGSSBuffer(env, jinToken, &inToken);
cb = getGSSCB(env, jcb);
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
srcName = GSS_C_NO_NAME;
delCred = GSS_C_NO_CREDENTIAL;
setTarget = (credHdl == GSS_C_NO_CREDENTIAL);
@ -1130,7 +1164,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_getContextName(JNIEnv *env,
checkStatus(env, jobj, major, minor, "[GSSLibStub_inquireContextAll]");
/* return immediately if an exception has occurred */
if ((*env)->ExceptionCheck(env)) {
return ptr_to_jlong(NULL);
return jlong_zero;
}
sprintf(debugBuf, "[GSSLibStub_getContextName] pName=%ld", (long) nameHdl);

@ -26,6 +26,9 @@
#include "NativeUtil.h"
#include "NativeFunc.h"
#include "jlong.h"
#include <jni.h>
extern void throwOutOfMemoryError(JNIEnv *env, const char *message);
const int JAVA_DUPLICATE_TOKEN_CODE = 19; /* DUPLICATE_TOKEN */
const int JAVA_OLD_TOKEN_CODE = 20; /* OLD_TOKEN */
@ -615,8 +618,17 @@ gss_OID newGSSOID(JNIEnv *env, jobject jOid) {
(*env)->Throw(env, gssEx);
}
cOid = malloc(sizeof(struct gss_OID_desc_struct));
if (cOid == NULL) {
throwOutOfMemoryError(env,NULL);
return GSS_C_NO_OID;
}
cOid->length = (*env)->GetArrayLength(env, jbytes) - 2;
cOid->elements = malloc(cOid->length);
if (cOid->elements == NULL) {
throwOutOfMemoryError(env,NULL);
free(cOid);
return GSS_C_NO_OID;
}
(*env)->GetByteArrayRegion(env, jbytes, 2, cOid->length,
cOid->elements);
(*env)->DeleteLocalRef(env, jbytes);

@ -43,13 +43,24 @@ import sun.net.util.URLUtil;
class JarFileFactory implements URLJarFile.URLJarFileCloseController {
/* the url to file cache */
private static HashMap<String, JarFile> fileCache = new HashMap<String, JarFile>();
private static final HashMap<String, JarFile> fileCache = new HashMap<>();
/* the file to url cache */
private static HashMap<JarFile, URL> urlCache = new HashMap<JarFile, URL>();
private static final HashMap<JarFile, URL> urlCache = new HashMap<>();
private static final JarFileFactory instance = new JarFileFactory();
private JarFileFactory() { }
public static JarFileFactory getInstance() {
return instance;
}
URLConnection getConnection(JarFile jarFile) throws IOException {
URL u = urlCache.get(jarFile);
URL u;
synchronized (instance) {
u = urlCache.get(jarFile);
}
if (u != null)
return u.openConnection();
@ -62,16 +73,16 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
JarFile get(URL url, boolean useCaches) throws IOException {
JarFile result = null;
JarFile local_result = null;
JarFile result;
JarFile local_result;
if (useCaches) {
synchronized (this) {
synchronized (instance) {
result = getCachedJarFile(url);
}
if (result == null) {
local_result = URLJarFile.getJarFile(url, this);
synchronized (this) {
synchronized (instance) {
result = getCachedJarFile(url);
if (result == null) {
fileCache.put(URLUtil.urlNoFragString(url), local_result);
@ -99,14 +110,15 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
* remove the JarFile from the cache
*/
public void close(JarFile jarFile) {
URL urlRemoved = urlCache.remove(jarFile);
if( urlRemoved != null) {
synchronized (instance) {
URL urlRemoved = urlCache.remove(jarFile);
if (urlRemoved != null)
fileCache.remove(URLUtil.urlNoFragString(urlRemoved));
}
}
private JarFile getCachedJarFile(URL url) {
assert Thread.holdsLock(instance);
JarFile result = fileCache.get(URLUtil.urlNoFragString(url));
/* if the JAR file is cached, the permission will always be there */

@ -26,9 +26,9 @@
package sun.nio.ch;
import java.io.IOException;
import java.util.LinkedList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;
/**
* Manipulates a native array of epoll_event structs on Linux:
@ -52,37 +52,78 @@ import java.util.Iterator;
* this implementation we set data.fd to be the file descriptor that we
* register. That way, we have the file descriptor available when we
* process the events.
*
* All file descriptors registered with epoll have the POLLHUP and POLLERR
* events enabled even when registered with an event set of 0. To ensure
* that epoll_wait doesn't poll an idle file descriptor when the underlying
* connection is closed or reset then its registration is deleted from
* epoll (it will be re-added again if the event set is changed)
*/
class EPollArrayWrapper {
// EPOLL_EVENTS
static final int EPOLLIN = 0x001;
private static final int EPOLLIN = 0x001;
// opcodes
static final int EPOLL_CTL_ADD = 1;
static final int EPOLL_CTL_DEL = 2;
static final int EPOLL_CTL_MOD = 3;
private static final int EPOLL_CTL_ADD = 1;
private static final int EPOLL_CTL_DEL = 2;
private static final int EPOLL_CTL_MOD = 3;
// Miscellaneous constants
static final int SIZE_EPOLLEVENT = sizeofEPollEvent();
static final int EVENT_OFFSET = 0;
static final int DATA_OFFSET = offsetofData();
static final int FD_OFFSET = DATA_OFFSET;
static final int NUM_EPOLLEVENTS = Math.min(IOUtil.fdLimit(), 8192);
private static final int SIZE_EPOLLEVENT = sizeofEPollEvent();
private static final int EVENT_OFFSET = 0;
private static final int DATA_OFFSET = offsetofData();
private static final int FD_OFFSET = DATA_OFFSET;
private static final int OPEN_MAX = IOUtil.fdLimit();
private static final int NUM_EPOLLEVENTS = Math.min(OPEN_MAX, 8192);
// Base address of the native pollArray
// Special value to indicate that an update should be ignored
private static final byte KILLED = (byte)-1;
// Initial size of arrays for fd registration changes
private static final int INITIAL_PENDING_UPDATE_SIZE = 64;
// maximum size of updatesLow
private static final int MAX_UPDATE_ARRAY_SIZE = Math.min(OPEN_MAX, 64*1024);
// The fd of the epoll driver
private final int epfd;
// The epoll_event array for results from epoll_wait
private final AllocatedNativeObject pollArray;
// Base address of the epoll_event array
private final long pollArrayAddress;
// Set of "idle" channels
private final HashSet<SelChImpl> idleSet;
// The fd of the interrupt line going out
private int outgoingInterruptFD;
EPollArrayWrapper() {
// The fd of the interrupt line coming in
private int incomingInterruptFD;
// The index of the interrupt FD
private int interruptedIndex;
// Number of updated pollfd entries
int updated;
// object to synchronize fd registration changes
private final Object updateLock = new Object();
// number of file descriptors with registration changes pending
private int updateCount;
// file descriptors with registration changes pending
private int[] updateDescriptors = new int[INITIAL_PENDING_UPDATE_SIZE];
// events for file descriptors with registration changes pending, indexed
// by file descriptor and stored as bytes for efficiency reasons. For
// file descriptors higher than MAX_UPDATE_ARRAY_SIZE (unlimited case at
// least) then the update is stored in a map.
private final byte[] eventsLow = new byte[MAX_UPDATE_ARRAY_SIZE];
private Map<Integer,Byte> eventsHigh;
// Used by release and updateRegistrations to track whether a file
// descriptor is registered with epoll.
private final BitSet registered = new BitSet();
EPollArrayWrapper() throws IOException {
// creates the epoll file descriptor
epfd = epollCreate();
@ -91,50 +132,11 @@ class EPollArrayWrapper {
pollArray = new AllocatedNativeObject(allocationSize, true);
pollArrayAddress = pollArray.address();
for (int i=0; i<NUM_EPOLLEVENTS; i++) {
putEventOps(i, 0);
putData(i, 0L);
}
// create idle set
idleSet = new HashSet<SelChImpl>();
// eventHigh needed when using file descriptors > 64k
if (OPEN_MAX > MAX_UPDATE_ARRAY_SIZE)
eventsHigh = new HashMap<>();
}
// Used to update file description registrations
private static class Updator {
SelChImpl channel;
int opcode;
int events;
Updator(SelChImpl channel, int opcode, int events) {
this.channel = channel;
this.opcode = opcode;
this.events = events;
}
Updator(SelChImpl channel, int opcode) {
this(channel, opcode, 0);
}
}
private LinkedList<Updator> updateList = new LinkedList<Updator>();
// The epoll_event array for results from epoll_wait
private AllocatedNativeObject pollArray;
// The fd of the epoll driver
final int epfd;
// The fd of the interrupt line going out
int outgoingInterruptFD;
// The fd of the interrupt line coming in
int incomingInterruptFD;
// The index of the interrupt FD
int interruptedIndex;
// Number of updated pollfd entries
int updated;
void initInterrupt(int fd0, int fd1) {
outgoingInterruptFD = fd1;
incomingInterruptFD = fd0;
@ -146,11 +148,6 @@ class EPollArrayWrapper {
pollArray.putInt(offset, event);
}
void putData(int i, long value) {
int offset = SIZE_EPOLLEVENT * i + DATA_OFFSET;
pollArray.putLong(offset, value);
}
void putDescriptor(int i, int fd) {
int offset = SIZE_EPOLLEVENT * i + FD_OFFSET;
pollArray.putInt(offset, fd);
@ -167,51 +164,83 @@ class EPollArrayWrapper {
}
/**
* Update the events for a given channel.
* Sets the pending update events for the given file descriptor. This
* method has no effect if the update events is already set to KILLED,
* unless {@code force} is {@code true}.
*/
void setInterest(SelChImpl channel, int mask) {
synchronized (updateList) {
// if the previous pending operation is to add this file descriptor
// to epoll then update its event set
if (updateList.size() > 0) {
Updator last = updateList.getLast();
if (last.channel == channel && last.opcode == EPOLL_CTL_ADD) {
last.events = mask;
return;
}
private void setUpdateEvents(int fd, byte events, boolean force) {
if (fd < MAX_UPDATE_ARRAY_SIZE) {
if ((eventsLow[fd] != KILLED) || force) {
eventsLow[fd] = events;
}
} else {
Integer key = Integer.valueOf(fd);
if ((eventsHigh.get(key) != KILLED) || force) {
eventsHigh.put(key, Byte.valueOf(events));
}
// update existing registration
updateList.add(new Updator(channel, EPOLL_CTL_MOD, mask));
}
}
/**
* Add a channel's file descriptor to epoll
* Returns the pending update events for the given file descriptor.
*/
void add(SelChImpl channel) {
synchronized (updateList) {
updateList.add(new Updator(channel, EPOLL_CTL_ADD));
private byte getUpdateEvents(int fd) {
if (fd < MAX_UPDATE_ARRAY_SIZE) {
return eventsLow[fd];
} else {
Byte result = eventsHigh.get(Integer.valueOf(fd));
// result should never be null
return result.byteValue();
}
}
/**
* Remove a channel's file descriptor from epoll
* Update the events for a given file descriptor
*/
void release(SelChImpl channel) {
synchronized (updateList) {
// flush any pending updates
for (Iterator<Updator> it = updateList.iterator(); it.hasNext();) {
if (it.next().channel == channel) {
it.remove();
}
void setInterest(int fd, int mask) {
synchronized (updateLock) {
// record the file descriptor and events
int oldCapacity = updateDescriptors.length;
if (updateCount == oldCapacity) {
int newCapacity = oldCapacity + INITIAL_PENDING_UPDATE_SIZE;
int[] newDescriptors = new int[newCapacity];
System.arraycopy(updateDescriptors, 0, newDescriptors, 0, oldCapacity);
updateDescriptors = newDescriptors;
}
updateDescriptors[updateCount++] = fd;
// remove from the idle set (if present)
idleSet.remove(channel);
// events are stored as bytes for efficiency reasons
byte b = (byte)mask;
assert (b == mask) && (b != KILLED);
setUpdateEvents(fd, b, false);
}
}
// remove from epoll (if registered)
epollCtl(epfd, EPOLL_CTL_DEL, channel.getFDVal(), 0);
/**
* Add a file descriptor
*/
void add(int fd) {
// force the initial update events to 0 as it may be KILLED by a
// previous registration.
synchronized (updateLock) {
assert !registered.get(fd);
setUpdateEvents(fd, (byte)0, true);
}
}
/**
* Remove a file descriptor
*/
void remove(int fd) {
synchronized (updateLock) {
// kill pending and future update for this file descriptor
setUpdateEvents(fd, KILLED, false);
// remove from epoll
if (registered.get(fd)) {
epollCtl(epfd, EPOLL_CTL_DEL, fd, 0);
registered.clear(fd);
}
}
}
@ -239,36 +268,38 @@ class EPollArrayWrapper {
/**
* Update the pending registrations.
*/
void updateRegistrations() {
synchronized (updateList) {
Updator u = null;
while ((u = updateList.poll()) != null) {
SelChImpl ch = u.channel;
if (!ch.isOpen())
continue;
private void updateRegistrations() {
synchronized (updateLock) {
int j = 0;
while (j < updateCount) {
int fd = updateDescriptors[j];
short events = getUpdateEvents(fd);
boolean isRegistered = registered.get(fd);
int opcode = 0;
// if the events are 0 then file descriptor is put into "idle
// set" to prevent it being polled
if (u.events == 0) {
boolean added = idleSet.add(u.channel);
// if added to idle set then remove from epoll if registered
if (added && (u.opcode == EPOLL_CTL_MOD))
epollCtl(epfd, EPOLL_CTL_DEL, ch.getFDVal(), 0);
} else {
// events are specified. If file descriptor was in idle set
// it must be re-registered (by converting opcode to ADD)
boolean idle = false;
if (!idleSet.isEmpty())
idle = idleSet.remove(u.channel);
int opcode = (idle) ? EPOLL_CTL_ADD : u.opcode;
epollCtl(epfd, opcode, ch.getFDVal(), u.events);
if (events != KILLED) {
if (isRegistered) {
opcode = (events != 0) ? EPOLL_CTL_MOD : EPOLL_CTL_DEL;
} else {
opcode = (events != 0) ? EPOLL_CTL_ADD : 0;
}
if (opcode != 0) {
epollCtl(epfd, opcode, fd, events);
if (opcode == EPOLL_CTL_ADD) {
registered.set(fd);
} else if (opcode == EPOLL_CTL_DEL) {
registered.clear(fd);
}
}
}
j++;
}
updateCount = 0;
}
}
// interrupt support
boolean interrupted = false;
private boolean interrupted = false;
public void interrupt() {
interrupt(outgoingInterruptFD);

@ -53,26 +53,24 @@ class EPollSelectorImpl
private volatile boolean closed = false;
// Lock for interrupt triggering and clearing
private Object interruptLock = new Object();
private final Object interruptLock = new Object();
private boolean interruptTriggered = false;
/**
* Package private constructor called by factory method in
* the abstract superclass Selector.
*/
EPollSelectorImpl(SelectorProvider sp) {
EPollSelectorImpl(SelectorProvider sp) throws IOException {
super(sp);
long pipeFds = IOUtil.makePipe(false);
fd0 = (int) (pipeFds >>> 32);
fd1 = (int) pipeFds;
pollWrapper = new EPollArrayWrapper();
pollWrapper.initInterrupt(fd0, fd1);
fdToKey = new HashMap<Integer,SelectionKeyImpl>();
fdToKey = new HashMap<>();
}
protected int doSelect(long timeout)
throws IOException
{
protected int doSelect(long timeout) throws IOException {
if (closed)
throw new ClosedSelectorException();
processDeregisterQueue();
@ -161,8 +159,9 @@ class EPollSelectorImpl
if (closed)
throw new ClosedSelectorException();
SelChImpl ch = ski.channel;
fdToKey.put(Integer.valueOf(ch.getFDVal()), ski);
pollWrapper.add(ch);
int fd = Integer.valueOf(ch.getFDVal());
fdToKey.put(fd, ski);
pollWrapper.add(fd);
keys.add(ski);
}
@ -171,7 +170,7 @@ class EPollSelectorImpl
SelChImpl ch = ski.channel;
int fd = ch.getFDVal();
fdToKey.remove(Integer.valueOf(fd));
pollWrapper.release(ch);
pollWrapper.remove(fd);
ski.setIndex(-1);
keys.remove(ski);
selectedKeys.remove(ski);
@ -181,10 +180,11 @@ class EPollSelectorImpl
((SelChImpl)selch).kill();
}
public void putEventOps(SelectionKeyImpl sk, int ops) {
public void putEventOps(SelectionKeyImpl ski, int ops) {
if (closed)
throw new ClosedSelectorException();
pollWrapper.setInterest(sk.channel, ops);
SelChImpl ch = ski.channel;
pollWrapper.setInterest(ch.getFDVal(), ops);
}
public Selector wakeup() {
@ -200,5 +200,4 @@ class EPollSelectorImpl
static {
Util.load();
}
}

@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
JNIEXPORT void JNICALL
Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo
(JNIEnv *env, jobject obj) {
@ -39,13 +40,23 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo
char pwd_buf[1024];
struct passwd pwd;
jsize numSuppGroups = getgroups(0, NULL);
gid_t *groups = (gid_t *)calloc(numSuppGroups, sizeof(gid_t));
jfieldID fid;
jstring jstr;
jlongArray jgroups;
jlong *jgroupsAsArray;
jclass cls = (*env)->GetObjectClass(env, obj);
gid_t *groups;
jclass cls;
groups = (gid_t *)calloc(numSuppGroups, sizeof(gid_t));
if (groups == NULL) {
jclass cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError");
if(cls != 0)
(*env)->ThrowNew(env, cls, NULL);
return;
}
cls = (*env)->GetObjectClass(env, obj);
memset(pwd_buf, 0, sizeof(pwd_buf));
if (getpwuid_r(getuid(), &pwd, pwd_buf, sizeof(pwd_buf)) != NULL &&

@ -44,9 +44,6 @@ Java_com_sun_security_auth_module_UnixSystem_getUnixInfo
char pwd_buf[1024];
struct passwd *pwd;
struct passwd resbuf;
jsize numSuppGroups = getgroups(0, NULL);
gid_t *groups = (gid_t *)calloc(numSuppGroups, sizeof(gid_t));
jfieldID userNameID;
jfieldID userID;
jfieldID groupID;
@ -55,7 +52,20 @@ Java_com_sun_security_auth_module_UnixSystem_getUnixInfo
jstring jstr;
jlongArray jgroups;
jlong *jgroupsAsArray;
jclass cls = (*env)->GetObjectClass(env, obj);
jsize numSuppGroups;
gid_t *groups;
jclass cls;
numSuppGroups = getgroups(0, NULL);
groups = (gid_t *)calloc(numSuppGroups, sizeof(gid_t));
if (groups == NULL) {
jclass cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError");
if(cls != 0)
(*env)->ThrowNew(env, cls, NULL);
return;
}
cls = (*env)->GetObjectClass(env, obj);
memset(pwd_buf, 0, sizeof(pwd_buf));

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2013, 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,4 +23,24 @@
* questions.
*/
// Currently, there are no unix specific functions defined.
#ifndef JDK_UTIL_MD_H
#define JDK_UTIL_MD_H
// checking for nanness
#ifdef __solaris__
#include <ieeefp.h>
#define ISNANF(f) isnanf(f)
#define ISNAND(d) isnand(d)
#elif defined(MACOSX)
#include <math.h>
#define ISNANF(f) isnan(f)
#define ISNAND(d) isnan(d)
#elif defined(__linux__) || defined(_ALLBSD_SOURCE)
#include <math.h>
#define ISNANF(f) isnanf(f)
#define ISNAND(d) isnan(d)
#else
#error "missing platform-specific definition here"
#endif
#endif /* JDK_UTIL_MD_H */

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2013, 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,6 +25,7 @@
#include "jni.h"
#include "jni_util.h"
#include "dlfcn.h"
jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
return NULL;
@ -33,3 +34,22 @@ jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) {
return NULL;
}
void* getProcessHandle() {
static void *procHandle = NULL;
if (procHandle != NULL) {
return procHandle;
}
procHandle = (void*)dlopen(NULL, RTLD_LAZY);
return procHandle;
}
void buildJniFunctionName(const char *sym, const char *cname,
char *jniEntryName) {
strcpy(jniEntryName, sym);
if (cname != NULL) {
strcat(jniEntryName, "_");
strcat(jniEntryName, cname);
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, 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,8 @@
* questions.
*/
#include "jni.h"
#include "jni_util.h"
#include "jvm.h"
#include "io_util_md.h"
#include "java_io_FileDescriptor.h"
@ -51,8 +50,8 @@ Java_java_io_FileDescriptor_initIDs(JNIEnv *env, jclass fdClass) {
JNIEXPORT void JNICALL
Java_java_io_FileDescriptor_sync(JNIEnv *env, jobject this) {
int fd = (*env)->GetIntField(env, this, IO_fd_fdID);
if (JVM_Sync(fd) == -1) {
FD fd = THIS_FD(this);
if (IO_Sync(fd) == -1) {
JNU_ThrowByName(env, "java/io/SyncFailedException", "sync failed");
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -77,7 +77,7 @@ Java_java_io_UnixFileSystem_canonicalize0(JNIEnv *env, jobject this,
WITH_PLATFORM_STRING(env, pathname, path) {
char canonicalPath[JVM_MAXPATHLEN];
if (canonicalize(JVM_NativePath((char *)path),
if (canonicalize((char *)path,
canonicalPath, JVM_MAXPATHLEN) < 0) {
JNU_ThrowIOExceptionWithLastError(env, "Bad pathname");
} else {
@ -241,19 +241,18 @@ Java_java_io_UnixFileSystem_createFileExclusively(JNIEnv *env, jclass cls,
jboolean rv = JNI_FALSE;
WITH_PLATFORM_STRING(env, pathname, path) {
int fd;
if (!strcmp (path, "/")) {
fd = JVM_EEXIST; /* The root directory always exists */
} else {
fd = JVM_Open(path, JVM_O_RDWR | JVM_O_CREAT | JVM_O_EXCL, 0666);
}
if (fd < 0) {
if (fd != JVM_EEXIST) {
JNU_ThrowIOExceptionWithLastError(env, path);
FD fd;
/* The root directory always exists */
if (strcmp (path, "/")) {
fd = handleOpen(path, O_RDWR | O_CREAT | O_EXCL, 0666);
if (fd < 0) {
if (errno != EEXIST)
JNU_ThrowIOExceptionWithLastError(env, path);
} else {
if (close(fd) == -1)
JNU_ThrowIOExceptionWithLastError(env, path);
rv = JNI_TRUE;
}
} else {
JVM_Close(fd);
rv = JNI_TRUE;
}
} END_PLATFORM_STRING(env, path);
return rv;

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