Merge
diff --git a/.hgtags b/.hgtags
index 607d2df..ef6e16f 100644
--- a/.hgtags
+++ b/.hgtags
@@ -204,3 +204,6 @@
dfb40f066c6ce129822f0f5dc2ac89173808781a jdk8-b80
c0f8022eba536dcdc8aae659005b33f3982b9368 jdk8-b81
624bcb4800065c6656171948e31ebb2925f25c7a jdk8-b82
+ac519af51769e92c51b597a730974e8607357709 jdk8-b83
+7b4721e4edb4e1c65e9c839a70d7cc67f81c7632 jdk8-b84
+296676d534c52888c36e305a2bf7f345c4ca70f8 jdk8-b85
diff --git a/make/com/sun/Makefile b/make/com/sun/Makefile
index 8b9d9db..052cd54 100644
--- a/make/com/sun/Makefile
+++ b/make/com/sun/Makefile
@@ -45,7 +45,7 @@
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
diff --git a/make/com/sun/org/apache/xml/Makefile b/make/com/sun/org/apache/xml/Makefile
index f00135d..b3568e4 100644
--- a/make/com/sun/org/apache/xml/Makefile
+++ b/make/com/sun/org/apache/xml/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2003, 2011, 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
@@ -34,6 +34,8 @@
JAVAC_WARNINGS_FATAL = true
include $(BUILDDIR)/common/Defs.gmk
+JAVAC_LINT_OPTIONS += -Xlint:-overrides
+
#
# Files to compile
#
diff --git a/make/com/sun/servicetag/Makefile b/make/com/sun/servicetag/Makefile
deleted file mode 100644
index a31b9ae..0000000
--- a/make/com/sun/servicetag/Makefile
+++ /dev/null
@@ -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
diff --git a/make/common/Release.gmk b/make/common/Release.gmk
index 5371d04..2cdfc0e 100644
--- a/make/common/Release.gmk
+++ b/make/common/Release.gmk
@@ -59,8 +59,7 @@
# 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
diff --git a/make/java/java/FILES_java.gmk b/make/java/java/FILES_java.gmk
index 189b9fc..47184e3 100644
--- a/make/java/java/FILES_java.gmk
+++ b/make/java/java/FILES_java.gmk
@@ -209,6 +209,7 @@
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 @@
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 \
@@ -314,6 +316,8 @@
java/util/concurrent/BrokenBarrierException.java \
java/util/concurrent/Callable.java \
java/util/concurrent/CancellationException.java \
+ java/util/concurrent/CompletableFuture.java \
+ java/util/concurrent/CompletionException.java \
java/util/concurrent/CompletionService.java \
java/util/concurrent/ConcurrentHashMap.java \
java/util/concurrent/ConcurrentLinkedDeque.java \
diff --git a/make/java/java/mapfile-vers b/make/java/java/mapfile-vers
index 81e678d..60f0f86 100644
--- a/make/java/java/mapfile-vers
+++ b/make/java/java/mapfile-vers
@@ -133,6 +133,7 @@
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;
diff --git a/make/java/nio/Makefile b/make/java/nio/Makefile
index 9eebd5c..c20bec9 100644
--- a/make/java/nio/Makefile
+++ b/make/java/nio/Makefile
@@ -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 @@
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)
diff --git a/make/javax/others/Makefile b/make/javax/others/Makefile
index b122c20..7ee1151 100644
--- a/make/javax/others/Makefile
+++ b/make/javax/others/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1998, 2011, 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
@@ -33,6 +33,8 @@
include $(BUILDDIR)/common/Defs.gmk
+JAVAC_LINT_OPTIONS += -Xlint:-deprecation
+
#
# Files to compile
#
diff --git a/make/sun/xawt/FILES_c_unix.gmk b/make/sun/xawt/FILES_c_unix.gmk
index 0ce8bdd..74ea1cd 100644
--- a/make/sun/xawt/FILES_c_unix.gmk
+++ b/make/sun/xawt/FILES_c_unix.gmk
@@ -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 @@
debug_trace.c \
debug_util.c \
awt_Plugin.c \
+ gnome_interface.c \
gtk2_interface.c \
swing_GTKEngine.c \
swing_GTKStyle.c \
diff --git a/makefiles/CompileDemos.gmk b/makefiles/CompileDemos.gmk
index f3100b1..f61d940 100644
--- a/makefiles/CompileDemos.gmk
+++ b/makefiles/CompileDemos.gmk
@@ -136,8 +136,7 @@
$$(wildcard $$(addprefix $(JDK_TOPDIR)/src/$6share/demo/$2/$1/,$7)))
ifneq ($7,)
$(JDK_OUTPUTDIR)/demo/$2/$1/% : $(JDK_TOPDIR)/src/$6share/demo/$2/$1/%
- $(MKDIR) -p $$(@D)
- $(CP) $$< $$@
+ $$(call install-file)
$(CHMOD) -f ug+w $$@
BUILD_DEMOS += $$($1_COPY_TARGETS)
@@ -190,8 +189,7 @@
$(JDK_OUTPUTDIR)/demo/nbproject/%,\
$(call CacheFind,$(JDK_TOPDIR)/src/closed/share/demo/nbproject))
$(JDK_OUTPUTDIR)/demo/nbproject/% : $(JDK_TOPDIR)/src/closed/share/demo/nbproject/%
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) -f ug+w $@
endif
@@ -268,8 +266,7 @@
ZIP:=$(JDK_OUTPUTDIR)/demo/jvmti/$1/src.zip))
$(JDK_OUTPUTDIR)/demo/jvmti/$1/README.txt : $(JDK_TOPDIR)/src/share/demo/jvmti/$1/README.txt
- $(MKDIR) -p $$(@D)
- $(CP) $$< $$@
+ $$(call install-file)
$(CHMOD) -f ug+w $$@
ifneq (,$$(wildcard $(JDK_TOPDIR)/src/share/demo/jvmti/$1/*.java))
@@ -325,23 +322,22 @@
JPDA_FILES:=$(subst $(JDK_TOPDIR)/src/share/classes/,,$(JPDA_SOURCES))
$(JDK_OUTPUTDIR)/demo/jpda/src.zip : $(JPDA_SOURCES)
- $(MKDIR) -p $(@D)
- (cd $(JDK_TOPDIR)/src/share/classes && $(ZIP) -qru $@ com -i "com/sun/tools/example/*")
+ $(MKDIR) -p $(@D)
+ (cd $(JDK_TOPDIR)/src/share/classes && $(ZIP) -qru $@ com -i "com/sun/tools/example/*")
$(JDK_OUTPUTDIR)/demo/jpda/examples.jar : $(JPDA_SOURCES)
- $(MKDIR) -p $(@D)
- $(RM) $(@D)/_the.sources
- $(call ListPathsSafely,JPDA_FILES,\n, >> $(@D)/_the.sources)
- $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \
- -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $(JDK_TOPDIR)/make/tools/manifest.mf > $(@D)/_the.manifest
- $(ECHO) "Main-Class: " >> $(@D)/_the.manifest
- (cd $(JDK_TOPDIR)/src/share/classes && $(JAR) cfm $@ $(@D)/_the.manifest @$(@D)/_the.sources)
- (cd $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example && $(JAR) uf $@ README)
+ $(MKDIR) -p $(@D)
+ $(RM) $(@D)/_the.sources
+ $(call ListPathsSafely,JPDA_FILES,\n, >> $(@D)/_the.sources)
+ $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \
+ -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $(JDK_TOPDIR)/make/tools/manifest.mf > $(@D)/_the.manifest
+ $(ECHO) "Main-Class: " >> $(@D)/_the.manifest
+ (cd $(JDK_TOPDIR)/src/share/classes && $(JAR) cfm $@ $(@D)/_the.manifest @$(@D)/_the.sources)
+ (cd $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example && $(JAR) uf $@ README)
$(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README : $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example/README
- $(MKDIR) -p $(@D)
- $(CP) $< $@
- $(CHMOD) -f ug+w $@
+ $(call install-file)
+ $(CHMOD) -f ug+w $@
BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jpda/src.zip $(JDK_OUTPUTDIR)/demo/jpda/examples.jar \
$(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README
@@ -349,14 +345,12 @@
##################################################################################################
$(JDK_OUTPUTDIR)/demo/management/index.html : $(JDK_TOPDIR)/src/share/demo/management/index.html
- $(MKDIR) -p $(@D)
- $(CP) $< $@
- $(CHMOD) -f ug+w $@
+ $(call install-file)
+ $(CHMOD) -f ug+w $@
$(JDK_OUTPUTDIR)/demo/jvmti/index.html : $(JDK_TOPDIR)/src/share/demo/jvmti/index.html
- $(MKDIR) -p $(@D)
- $(CP) $< $@
- $(CHMOD) -f ug+w $@
+ $(call install-file)
+ $(CHMOD) -f ug+w $@
BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/management/index.html \
$(JDK_OUTPUTDIR)/demo/jvmti/index.html
@@ -369,15 +363,13 @@
$(call CacheFind,$(JDK_TOPDIR)/src/share/demo/nbproject))
$(JDK_OUTPUTDIR)/demo/nbproject/% : $(JDK_TOPDIR)/src/share/demo/nbproject/%
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) -f ug+w $@
##################################################################################################
$(JDK_OUTPUTDIR)/demo/README: $(JDK_TOPDIR)/src/share/demo/README
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/README
@@ -386,14 +378,12 @@
ifeq ($(OPENJDK_TARGET_OS), solaris)
$(JDK_OUTPUTDIR)/democlasses/jni/Poller/% : $(JDK_TOPDIR)/src/solaris/demo/jni/Poller/%
- $(MKDIR) -p $(@D)
- $(CP) $< $@
- $(CHMOD) -f ug+w $@
+ $(call install-file)
+ $(CHMOD) -f ug+w $@
$(JDK_OUTPUTDIR)/demo/jni/Poller/README.txt : $(JDK_TOPDIR)/src/solaris/demo/jni/Poller/README.txt
- $(MKDIR) -p $(@D)
- $(CP) $< $@
- $(CHMOD) -f ug+w $@
+ $(call install-file)
+ $(CHMOD) -f ug+w $@
$(JDK_OUTPUTDIR)/demo/jni/Poller/Poller.jar : \
$(JDK_OUTPUTDIR)/democlasses/jni/Poller/README.txt $(JDK_OUTPUTDIR)/democlasses/jni/Poller/Poller.c
@@ -433,8 +423,7 @@
$(JDK_OUTPUTDIR)/demo/jni/Poller/lib/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX) : \
$(JDK_OUTPUTDIR)/demoobjs/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX)
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jni/Poller/lib/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX)
@@ -456,8 +445,8 @@
$(JDK_OUTPUTDIR)/demo/db/README-JDK-DEMOS.html: \
$(JDK_TOPDIR)/src/closed/share/db/README-JDK-DEMOS.html \
| $(JDK_OUTPUTDIR)/demo/_the.db.unzipped
- $(MKDIR) -p $(@D)
- $(CP) '$<' '$@'
+ $(call install-file)
+
BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/_the.db.unzipped $(JDK_OUTPUTDIR)/demo/db/README-JDK-DEMOS.html
endif
diff --git a/makefiles/CompileJavaClasses.gmk b/makefiles/CompileJavaClasses.gmk
index 584458c..24ce0d9 100644
--- a/makefiles/CompileJavaClasses.gmk
+++ b/makefiles/CompileJavaClasses.gmk
@@ -281,8 +281,7 @@
# These resources violates the convention of having code and resources together under
# $(JDK_TOPDIR)/src/.../classes directories
$(JDK_OUTPUTDIR)/classes/javax/swing/beaninfo/images/%.gif: $(JDK_TOPDIR)/make/tools/swing-beans/beaninfo/images/%.gif
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
# The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying
# JDK_FILTER at the make command line, only a subset of the JDK java files will
diff --git a/makefiles/CompileLaunchers.gmk b/makefiles/CompileLaunchers.gmk
index 501c986..7ecad95 100644
--- a/makefiles/CompileLaunchers.gmk
+++ b/makefiles/CompileLaunchers.gmk
@@ -489,8 +489,7 @@
# -link -incremental:no
# like all other launchers.
$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/unpack200$(EXE_SUFFIX): $(BUILD_UNPACKEXE)
- $(MKDIR) -p $(@D)
- $(CP) '$<' '$@'
+ $(call install-file)
BUILD_LAUNCHERS += $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/unpack200$(EXE_SUFFIX)
@@ -588,8 +587,7 @@
$(call SET_SHARED_LIBRARY_MAPFILE,$(JDK_TOPDIR)/makefiles/java/main/java/mapfile-$(OPENJDK_TARGET_CPU))))
else
$(JAVA_RMI_CGI): $(JDK_TOPDIR)/src/solaris/bin/java-rmi.cgi.sh
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) a+x $@
endif
diff --git a/makefiles/CompileNativeLibraries.gmk b/makefiles/CompileNativeLibraries.gmk
index 4c5d8da..0158000 100644
--- a/makefiles/CompileNativeLibraries.gmk
+++ b/makefiles/CompileNativeLibraries.gmk
@@ -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
@@ -109,7 +109,7 @@
BUILD_LIBFDLIBM := $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX)
$(BUILD_LIBFDLIBM) : $(BUILD_LIBFDLIBM_MAC)
- $(CP) -a $< $@
+ $(call install-file)
endif
BUILD_LIBRARIES += $(BUILD_LIBFDLIBM)
@@ -843,6 +843,7 @@
debug_trace.c \
debug_util.c \
awt_Plugin.c \
+ gnome_interface.c \
gtk2_interface.c \
swing_GTKEngine.c \
swing_GTKStyle.c \
@@ -1837,16 +1838,14 @@
$(JDK_OUTPUTDIR)/lib/net.properties: $(JDK_TOPDIR)/src/share/lib/net.properties
$(ECHO) $(LOG_INFO) Copying $(@F)
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(JDK_OUTPUTDIR)/lib/net.properties
ifeq ($(OPENJDK_TARGET_OS), solaris)
$(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template : $(JDK_TOPDIR)/src/${OPENJDK_TARGET_OS_API_DIR}/lib/sdp/sdp.conf.template
$(ECHO) $(LOG_INFO) Copying $(@F)
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template
endif
@@ -1959,8 +1958,6 @@
-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:=,\
@@ -2169,7 +2166,7 @@
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static))
$(JDK_OUTPUTDIR)/objs/libjli_static.a : $(BUILD_LIBJLI_STATIC)
- $(CP) -a $< $@
+ $(call install-file)
BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/libjli_static.a
endif
@@ -2387,18 +2384,23 @@
ifndef BUILD_HEADLESS_ONLY
LIBSPLASHSCREEN_DIRS:=\
- $(JDK_TOPDIR)/src/share/native/sun/awt/giflib \
$(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg \
$(JDK_TOPDIR)/src/share/native/sun/awt/libpng \
$(JDK_TOPDIR)/src/share/native/sun/awt/splashscreen
+ifeq ($(USE_EXTERNAL_LIBGIF),true)
+ GIFLIB_LDFLAGS := -lgif
+else
+ LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/share/native/sun/awt/giflib
+ GIFLIB_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/awt/giflib
+endif
+
ifneq ($(OPENJDK_TARGET_OS), macosx)
LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt/splashscreen
else
LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/awt/splashscreen
endif
-
LIBSPLASHSCREEN_CFLAGS:=-DSPLASHSCREEN -DPNG_NO_MMX_CODE \
$(foreach dir,$(LIBSPLASHSCREEN_DIRS),-I$(dir))
@@ -2450,11 +2452,11 @@
EXCLUDE_FILES:=imageioJPEG.c jpegdecoder.c pngtest.c,\
LANG:=C,\
OPTIMIZATION:=LOW, \
- CFLAGS:=$(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB),\
+ CFLAGS:=$(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB) $(GIFLIB_CFLAGS),\
MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libsplashscreen/mapfile-vers, \
LDFLAGS:=$(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN),\
- LDFLAGS_SUFFIX:=$(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ),\
+ LDFLAGS_SUFFIX:=$(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ) $(GIFLIB_LDFLAGS),\
LDFLAGS_SUFFIX_solaris:=-lc,\
VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
RC_FLAGS:=$(RC_FLAGS)\
diff --git a/makefiles/CopyFiles.gmk b/makefiles/CopyFiles.gmk
index 9c4dc0d..6b15e67 100644
--- a/makefiles/CopyFiles.gmk
+++ b/makefiles/CopyFiles.gmk
@@ -46,14 +46,10 @@
$(OPENJDK_TARGET_OS_INCLUDE)/jawt_md.h
$(INCLUDEDIR)/%.h: $(JDK_TOPDIR)/src/share/javavm/export/%.h
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(OPENJDK_TARGET_OS_INCLUDE)/%.h: $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export/%.h
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES = $(H_TARGET_FILES)
@@ -81,17 +77,6 @@
##########################################################################################
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
@@ -99,22 +84,16 @@
MGMT_TARGET_FILES = $(subst $(MGMT_LIB_SRC),$(MGMT_LIBDIR),$(MGMT_SRC_FILES))
$(MGMT_LIBDIR)/management.properties: $(MGMT_LIB_SRC)/management.properties
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) 644 $@
# this file has different permissions...don't know why...
$(MGMT_LIBDIR)/jmxremote.access: $(MGMT_LIB_SRC)/jmxremote.access
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) 644 $@
$(MGMT_LIBDIR)/%: $(MGMT_LIB_SRC)/%
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) 444 $@
COPY_FILES += $(MGMT_TARGET_FILES)
@@ -124,9 +103,7 @@
LOGGING_LIB_SRC = $(JDK_TOPDIR)/src/share/lib
$(LIBDIR)/logging.properties: $(LOGGING_LIB_SRC)/logging.properties
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(LIBDIR)/logging.properties
@@ -139,9 +116,7 @@
PSFONTPROPFILE_TARGET_FILES = $(subst $(PSFONTPROPFILE_SRC_DIR),$(LIBDIR),$(PSFONTPROPFILE_SRCS))
$(LIBDIR)/%: $(PSFONTPROPFILE_SRC_DIR)/%
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(PSFONTPROPFILE_TARGET_FILES)
@@ -156,9 +131,7 @@
endif
$(LIBDIR)/flavormap.properties: $(OPENJDK_TARGET_OS_LIB_SRC)/flavormap.properties
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(LIBDIR)/flavormap.properties
@@ -166,9 +139,7 @@
CURSORS_OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib/images/cursors
$(CURSORS_DEST_DIR)/cursors.properties: $(CURSORS_OPENJDK_TARGET_OS_LIB_SRC)/cursors.properties
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(CURSORS_DEST_DIR)/cursors.properties
@@ -181,9 +152,7 @@
CURSORS_TARGET_FILES = $(subst $(CURSORS_LIB_SRC),$(CURSORS_DEST_DIR),$(CURSORS_SRC_FILES))
$(CURSORS_DEST_DIR)/%: $(CURSORS_LIB_SRC)/%
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(CURSORS_TARGET_FILES)
@@ -192,9 +161,7 @@
CONTENT_TYPES_SRC=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib
$(LIBDIR)/content-types.properties: $(CONTENT_TYPES_SRC)/content-types.properties
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(LIBDIR)/content-types.properties
@@ -203,9 +170,7 @@
CALENDARS_SRC := $(JDK_TOPDIR)/src/share/lib
$(LIBDIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(LIBDIR)/calendars.properties
@@ -216,9 +181,7 @@
TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib
$(LIBDIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(LIBDIR)/tzmappings
@@ -238,9 +201,7 @@
ICCPROFILE_TARGET_FILES:=$(subst $(ICCPROFILE_SRC_DIR),$(ICCPROFILE_DEST_DIR),$(ICCPROFILE_SRCS))
$(ICCPROFILE_DEST_DIR)%.pf: $(ICCPROFILE_SRC_DIR)%.pf
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) 444 $@
COPY_FILES += $(ICCPROFILE_TARGET_FILES)
@@ -290,9 +251,7 @@
MSVCR_TARGET := $(JDK_OUTPUTDIR)/bin/$(notdir $(MSVCR_DLL))
# Chmod to avoid permission issues if bundles are unpacked on unix platforms.
$(MSVCR_TARGET): $(MSVCR_DLL)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) a+rx $@
COPY_FILES += $(MSVCR_TARGET)
@@ -303,9 +262,7 @@
HPROF_SRC=$(JDK_TOPDIR)/src/share/demo/jvmti/hprof/jvm.hprof.txt
$(LIBDIR)/jvm.hprof.txt : $(HPROF_SRC)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(LIBDIR)/jvm.hprof.txt
@@ -362,17 +319,13 @@
else
# Use the default jvm.cfg for this 32 bit setup.
$(JVMCFG): $(JVMCFG_SRC)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
endif
endif
else
# Use the default jvm.cfg for this 64 bit setup.
$(JVMCFG): $(JVMCFG_SRC)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
endif
COPY_FILES += $(JVMCFG)
@@ -383,9 +336,7 @@
PROPS_DST := $(JDK_OUTPUTDIR)/lib/security/java.security
$(PROPS_DST): $(PROPS_SRC)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(PROPS_DST)
@@ -395,9 +346,7 @@
POLICY_DST := $(JDK_OUTPUTDIR)/lib/security/java.policy
$(POLICY_DST): $(POLICY_SRC)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(POLICY_DST)
@@ -407,9 +356,7 @@
CACERTS_DST := $(JDK_OUTPUTDIR)/lib/security/cacerts
$(CACERTS_DST): $(CACERTS_SRC)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(CACERTS_DST)
@@ -424,16 +371,12 @@
TRUSTEDLIBS_DST := $(JDK_OUTPUTDIR)/lib/security/trusted.libraries
$(BLACKLIST_DST): $(BLACKLIST_SRC)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(BLACKLIST_DST)
$(TRUSTEDLIBS_DST): $(TRUSTEDLIBS_SRC)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(TRUSTEDLIBS_DST)
@@ -459,14 +402,10 @@
SHARED_FONTS_DST := $(foreach F,$(SHARED_FONTS_FILES),$(SHARED_FONTS_DST_DIR)/$(F))
$(SHARED_FONTS_DST_DIR)/%.ttf : $(SHARED_FONTS_SRC_DIR)/%.ttf
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(SHARED_FONTS_DST_DIR)/fonts.dir : $(JDK_TOPDIR)/src/solaris/classes/sun/awt/motif/java.fonts.dir
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(SHARED_FONTS_DST)
@@ -487,14 +426,10 @@
OBL_FONTS_DST := $(foreach F,$(OBL_FONTS_FILES),$(OBL_FONTS_DST_DIR)/$(F))
$(OBL_FONTS_DST_DIR)/%.ttf : $(OBL_FONTS_SRC_DIR)/%.ttf
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(OBL_FONTS_DST_DIR)/fonts.dir : $(JDK_TOPDIR)/src/solaris/classes/sun/awt/motif/java.oblique-fonts.dir
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(OBL_FONTS_DST) $(OBL_FONTS_DST_DIR)/fonts.dir
@@ -513,9 +448,7 @@
JS_RESOURCES_DST := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_DST_DIR)/$(F))
$(JS_RESOURCES_DST_DIR)/% : $(JS_RESOURCES_SRC_DIR)/%
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(JS_RESOURCES_DST)
@@ -550,15 +483,11 @@
DGALIBS = $(_DGALIBS_$(OPENJDK_TARGET_CPU_LEGACY):%=$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/%)
$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libxinerama.so: $(JDK_TOPDIR)/src/closed/solaris/lib/$(OPENJDK_TARGET_CPU_LEGACY)/libxinerama.so
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) 755 $@
$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNW%.so: $(JDK_TOPDIR)/src/closed/solaris/lib/$(OPENJDK_TARGET_CPU_LEGACY)/libjdgaSUNW%.so
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) 755 $@
$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNWafb.so: $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNWffb.so
@@ -578,9 +507,7 @@
SUNPKCS11_CFG_DST := $(JDK_OUTPUTDIR)/lib/security/sunpkcs11-solaris.cfg
$(SUNPKCS11_CFG_DST) : $(SUNPKCS11_CFG_SRC)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(SUNPKCS11_CFG_DST)
@@ -595,9 +522,7 @@
UCRYPTO_CFG_DST := $(JDK_OUTPUTDIR)/lib/security/ucrypto-solaris.cfg
$(UCRYPTO_CFG_DST) : $(UCRYPTO_CFG_SRC)
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(UCRYPTO_CFG_DST)
@@ -607,9 +532,7 @@
##########################################################################################
$(JDK_OUTPUTDIR)/lib/sound.properties : $(JDK_TOPDIR)/src/share/lib/sound.properties
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $(@)
+ $(call install-file)
COPY_FILES += $(JDK_OUTPUTDIR)/lib/sound.properties
diff --git a/makefiles/CopyIntoClasses.gmk b/makefiles/CopyIntoClasses.gmk
index d5ec857..d4df342 100644
--- a/makefiles/CopyIntoClasses.gmk
+++ b/makefiles/CopyIntoClasses.gmk
@@ -59,15 +59,6 @@
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 += \
@@ -232,9 +223,7 @@
###
$(JDK_OUTPUTDIR)/classes/sun/nio/cs/ext/sjis0213.dat : $(JDK_OUTPUTDIR)/gensrc/sun/nio/cs/ext/sjis0213.dat
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $(@)
+ $(call install-file)
COPY_EXTRA += $(JDK_OUTPUTDIR)/classes/sun/nio/cs/ext/sjis0213.dat
diff --git a/makefiles/CopySamples.gmk b/makefiles/CopySamples.gmk
index 7f432f8..1f6b3bf 100644
--- a/makefiles/CopySamples.gmk
+++ b/makefiles/CopySamples.gmk
@@ -53,19 +53,13 @@
endif
$(SAMPLE_TARGET_DIR)/dtrace/%: $(SAMPLE_SOLARIS_SOURCE_DIR)/dtrace/%
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(SAMPLE_TARGET_DIR)/webservices/%: $(SAMPLE_CLOSED_SOURCE_DIR)/webservices/%
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
$(SAMPLE_TARGET_DIR)/%: $(SAMPLE_SOURCE_DIR)/%
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
COPY_FILES += $(SAMPLE_TARGET)
diff --git a/makefiles/CreateJars.gmk b/makefiles/CreateJars.gmk
index 82b85dc..523af3d 100644
--- a/makefiles/CreateJars.gmk
+++ b/makefiles/CreateJars.gmk
@@ -76,8 +76,6 @@
$(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 @@
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 @@
# 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 @@
$(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 @@
# 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 @@
$(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
diff --git a/makefiles/GendataFontConfig.gmk b/makefiles/GendataFontConfig.gmk
index 7f53908..189a732 100644
--- a/makefiles/GendataFontConfig.gmk
+++ b/makefiles/GendataFontConfig.gmk
@@ -72,9 +72,7 @@
$(GENDATA_FONT_CONFIG_DST)/%.src : \
$(GENDATA_FONT_CONFIG_SRC_DIR)/$(GENDATA_FONT_CONFIG_SRC_PREFIX)%
- $(RM) $@
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
$(GENDATA_FONT_CONFIG_DST)/%.bfc : \
$(GENDATA_FONT_CONFIG_SRC_DIR)/$(GENDATA_FONT_CONFIG_SRC_PREFIX)%.properties
diff --git a/makefiles/GensrcCharacterData.gmk b/makefiles/GensrcCharacterData.gmk
index e720ab8..f64edba 100644
--- a/makefiles/GensrcCharacterData.gmk
+++ b/makefiles/GensrcCharacterData.gmk
@@ -55,9 +55,8 @@
# Copy two Java files that need no preprocessing.
$(JDK_OUTPUTDIR)/gensrc/java/lang/%.java : $(CHARACTERDATA)/%.java.template
- $(MKDIR) -p $(@D)
$(ECHO) $(LOG_INFO) Generating $(@F)
- $(CP) -f $< $@
+ $(call install-file)
GENSRC_CHARACTERDATA += $(JDK_OUTPUTDIR)/gensrc/java/lang/CharacterDataUndefined.java \
$(JDK_OUTPUTDIR)/gensrc/java/lang/CharacterDataPrivateUse.java
diff --git a/makefiles/GensrcMisc.gmk b/makefiles/GensrcMisc.gmk
index 72a789b..812b2ce 100644
--- a/makefiles/GensrcMisc.gmk
+++ b/makefiles/GensrcMisc.gmk
@@ -72,9 +72,8 @@
$(JDK_OUTPUTDIR)/gensrc/java/lang/UNIXProcess.java : \
$(JDK_TOPDIR)/src/solaris/classes/java/lang/UNIXProcess.java.$(UPSUFFIX)
- $(MKDIR) -p $(@D)
$(ECHO) $(LOG_INFO) Copying UNIXProcess.java.$(OPENJDK_TARGET_OS) to java/lang/UNIXProcess.java
- $(CP) $< $@
+ $(call install-file)
$(CHMOD) u+rw $@
GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/java/lang/UNIXProcess.java
@@ -114,9 +113,7 @@
$(MV) $@.tmp $@
else
$(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java : $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
endif
##########################################################################################
@@ -156,9 +153,7 @@
$(MV) $@.tmp $@
else
$(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java : $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
+ $(call install-file)
endif
endif
diff --git a/makefiles/GensrcProperties.gmk b/makefiles/GensrcProperties.gmk
index 00598f4..3ef3a53 100644
--- a/makefiles/GensrcProperties.gmk
+++ b/makefiles/GensrcProperties.gmk
@@ -194,7 +194,6 @@
$(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,\
diff --git a/makefiles/GensrcSwing.gmk b/makefiles/GensrcSwing.gmk
index 9f3bff1..f5741ae 100644
--- a/makefiles/GensrcSwing.gmk
+++ b/makefiles/GensrcSwing.gmk
@@ -85,14 +85,12 @@
# For some reason it is under $(JDK_TOPDIR)/make/tools/swing-beans/javax/swing
# Should it be moved under $(JDK_TOPDIR)/src/share/classes/javax/swing instead?
$(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing/SwingBeanInfoBase.java: $(DOCLETSRC_DIR)/javax/swing/SwingBeanInfoBase.java
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
# This file is the part of dt.jar
# For some reason it is under $(JDK_TOPDIR)/make/tools/swing-beans/sun/swing
# Should it be moved under $(JDK_TOPDIR)/src/share/classes/sun/swing instead?
$(JDK_OUTPUTDIR)/gensrc/sun/swing/BeanInfoUtils.java: $(DOCLETSRC_DIR)/sun/swing/BeanInfoUtils.java
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
GENSRC_SWING_BEANINFO = $(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo
diff --git a/makefiles/Images.gmk b/makefiles/Images.gmk
index 4a3a235..70a8161 100644
--- a/makefiles/Images.gmk
+++ b/makefiles/Images.gmk
@@ -649,7 +649,7 @@
EXEC_LIST_BIN:=$(filter-out %$(notdir $(MSVCR_DLL)),$(filter %.exe %.dll,$(ALL_BIN_LIST)))
else
# Find all executables in JDK_OUTPUTDIR since they exist when this makefile is parsed
- EXEC_LIST_BIN:=$(shell $(FILE) `$(FIND) $(JDK_OUTPUTDIR)/bin -type f -name \*$(EXE_SUFFIX)` \
+ EXEC_LIST_BIN:=$(shell $(FILE) `$(FIND) $(JDK_OUTPUTDIR)/bin -type f -name \*$(EXE_SUFFIX) ! -name \*.debuginfo` \
| $(EGREP) 'ELF' | $(CUT) -d':' -f1)
# On mac, the old build searches for static libraries for stripping instead of shared.
# Not clear if it's intentional.
diff --git a/makefiles/ProfileNames.gmk b/makefiles/ProfileNames.gmk
index 2e8640a..b16e915 100644
--- a/makefiles/ProfileNames.gmk
+++ b/makefiles/ProfileNames.gmk
@@ -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
diff --git a/makefiles/Profiles.gmk b/makefiles/Profiles.gmk
index 864d98b..47fadcc 100644
--- a/makefiles/Profiles.gmk
+++ b/makefiles/Profiles.gmk
@@ -74,28 +74,30 @@
$(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 \
$(IMAGES_OUTPUTDIR)/lib/dt.jar \
$(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
+ $(IMAGES_OUTPUTDIR)/src.zip
+
+ifeq ($(INCLUDE_SA),true)
+ ALL_JARS += $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar
+endif
ifeq ($(OPENJDK_TARGET_OS),solaris)
ifndef OPENJDK
@@ -140,7 +142,7 @@
$(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 +151,18 @@
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 +175,7 @@
$(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 +191,18 @@
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 +281,13 @@
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 +295,11 @@
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 +309,9 @@
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)) \
diff --git a/makefiles/SignJars.gmk b/makefiles/SignJars.gmk
index 99caa99..6e84d14 100644
--- a/makefiles/SignJars.gmk
+++ b/makefiles/SignJars.gmk
@@ -79,8 +79,7 @@
fi
$(JCE_OUTPUTDIR)/%: $(IMAGES_OUTPUTDIR)/unsigned/%
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(call install-file)
$(JARSIGNER) -keystore $(SIGNING_KEYSTORE) \
$@ $(SIGNING_ALIAS) < $(SIGNING_PASSPHRASE)
@$(PRINTF) "\nJar codesigning finished.\n"
diff --git a/makefiles/Tools.gmk b/makefiles/Tools.gmk
index 360cbe4..66d08b4 100644
--- a/makefiles/Tools.gmk
+++ b/makefiles/Tools.gmk
@@ -47,17 +47,15 @@
endif
$(JDK_OUTPUTDIR)/btclasses/build/tools/generatenimbus/resources/%.template : \
- $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/nimbus/%.template
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/nimbus/%.template
+ $(call install-file)
BUILD_TOOLS += $(foreach i,$(wildcard $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/nimbus/*.template),$(JDK_OUTPUTDIR)/btclasses/build/tools/generatenimbus/resources/$(notdir $i))
# Resources used by CheckDeps tool
$(JDK_OUTPUTDIR)/btclasses/build/tools/deps/% : \
- $(JDK_TOPDIR)/make/tools/src/build/tools/deps/%
- $(MKDIR) -p $(@D)
- $(CP) $< $@
+ $(JDK_TOPDIR)/make/tools/src/build/tools/deps/%
+ $(call install-file)
BUILD_TOOLS += $(JDK_OUTPUTDIR)/btclasses/build/tools/deps/refs.allowed
diff --git a/makefiles/mapfiles/libjava/mapfile-vers b/makefiles/mapfiles/libjava/mapfile-vers
index 81e678d..60f0f86 100644
--- a/makefiles/mapfiles/libjava/mapfile-vers
+++ b/makefiles/mapfiles/libjava/mapfile-vers
@@ -133,6 +133,7 @@
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;
diff --git a/makefiles/profile-includes.txt b/makefiles/profile-includes.txt
index 2472bae..17e554f 100644
--- a/makefiles/profile-includes.txt
+++ b/makefiles/profile-includes.txt
@@ -27,6 +27,7 @@
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 @@
$(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 @@
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_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 @@
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 @@
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 @@
$(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 @@
$(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 @@
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 @@
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 @@
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
diff --git a/makefiles/profile-rtjar-includes.txt b/makefiles/profile-rtjar-includes.txt
index 4cc528e..a90af14 100644
--- a/makefiles/profile-rtjar-includes.txt
+++ b/makefiles/profile-rtjar-includes.txt
@@ -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_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_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 @@
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 @@
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 \
diff --git a/src/macosx/classes/apple/laf/JRSUIConstants.java b/src/macosx/classes/apple/laf/JRSUIConstants.java
index 8e71a50..40b2fc2 100644
--- a/src/macosx/classes/apple/laf/JRSUIConstants.java
+++ b/src/macosx/classes/apple/laf/JRSUIConstants.java
@@ -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
@@ -28,27 +28,25 @@
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
public final class JRSUIConstants {
private static native long getPtrForConstant(final int constant);
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
static class Key {
- protected static final int _value = 20;
+ @Native protected static final int _value = 20;
public static final Key VALUE = new Key(_value);
- protected static final int _thumbProportion = 24;
+ @Native protected static final int _thumbProportion = 24;
public static final Key THUMB_PROPORTION = new Key(_thumbProportion);
- protected static final int _thumbStart = 25;
+ @Native protected static final int _thumbStart = 25;
public static final Key THUMB_START = new Key(_thumbStart);
- protected static final int _windowTitleBarHeight = 28;
+ @Native protected static final int _windowTitleBarHeight = 28;
public static final Key WINDOW_TITLE_BAR_HEIGHT = new Key(_windowTitleBarHeight);
- protected static final int _animationFrame = 23;
+ @Native protected static final int _animationFrame = 23;
public static final Key ANIMATION_FRAME = new Key(_animationFrame);
final int constant;
@@ -70,10 +68,8 @@
}
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
static class DoubleValue {
- protected static final byte TYPE_CODE = 1;
+ @Native protected static final byte TYPE_CODE = 1;
final double doubleValue;
@@ -139,684 +135,634 @@
}
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class Size extends Property {
- private static final byte SHIFT = 0;
- private static final byte SIZE = 3;
- private static final long MASK = (long)0x7 << SHIFT;
+ @Native private static final byte SHIFT = 0;
+ @Native private static final byte SIZE = 3;
+ @Native private static final long MASK = (long)0x7 << SHIFT;
private static final PropertyEncoding size = new PropertyEncoding(MASK, SHIFT);
Size(final byte value) {
super(size, value);
}
- private static final byte _mini = 1;
+ @Native private static final byte _mini = 1;
public static final Size MINI = new Size(_mini);
- private static final byte _small = 2;
+ @Native private static final byte _small = 2;
public static final Size SMALL = new Size(_small);
- private static final byte _regular = 3;
+ @Native private static final byte _regular = 3;
public static final Size REGULAR = new Size(_regular);
- private static final byte _large = 4;
+ @Native private static final byte _large = 4;
public static final Size LARGE = new Size(_large);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class State extends Property {
- private static final byte SHIFT = Size.SHIFT + Size.SIZE;
- private static final byte SIZE = 4;
- private static final long MASK = (long)0xF << SHIFT;
+ @Native private static final byte SHIFT = Size.SHIFT + Size.SIZE;
+ @Native private static final byte SIZE = 4;
+ @Native private static final long MASK = (long)0xF << SHIFT;
private static final PropertyEncoding state = new PropertyEncoding(MASK, SHIFT);
State(final byte value) {
super(state, value);
}
- private static final byte _active = 1;
+ @Native private static final byte _active = 1;
public static final State ACTIVE = new State(_active);
- private static final byte _inactive = 2;
+ @Native private static final byte _inactive = 2;
public static final State INACTIVE = new State(_inactive);
- private static final byte _disabled = 3;
+ @Native private static final byte _disabled = 3;
public static final State DISABLED = new State(_disabled);
- private static final byte _pressed = 4;
+ @Native private static final byte _pressed = 4;
public static final State PRESSED = new State(_pressed);
- private static final byte _pulsed = 5;
+ @Native private static final byte _pulsed = 5;
public static final State PULSED = new State(_pulsed);
- private static final byte _rollover = 6;
+ @Native private static final byte _rollover = 6;
public static final State ROLLOVER = new State(_rollover);
- private static final byte _drag = 7;
+ @Native private static final byte _drag = 7;
public static final State DRAG = new State(_drag);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class Direction extends Property {
- private static final byte SHIFT = State.SHIFT + State.SIZE;
- private static final byte SIZE = 4;
- private static final long MASK = (long)0xF << SHIFT;
+ @Native private static final byte SHIFT = State.SHIFT + State.SIZE;
+ @Native private static final byte SIZE = 4;
+ @Native private static final long MASK = (long)0xF << SHIFT;
private static final PropertyEncoding direction = new PropertyEncoding(MASK, SHIFT);
Direction(final byte value) {
super(direction, value);
}
- private static final byte _none = 1;
+ @Native private static final byte _none = 1;
public static final Direction NONE = new Direction(_none);
- private static final byte _up = 2;
+ @Native private static final byte _up = 2;
public static final Direction UP = new Direction(_up);
- private static final byte _down = 3;
+ @Native private static final byte _down = 3;
public static final Direction DOWN = new Direction(_down);
- private static final byte _left = 4;
+ @Native private static final byte _left = 4;
public static final Direction LEFT = new Direction(_left);
- private static final byte _right = 5;
+ @Native private static final byte _right = 5;
public static final Direction RIGHT = new Direction(_right);
- private static final byte _north = 6;
+ @Native private static final byte _north = 6;
public static final Direction NORTH = new Direction(_north);
- private static final byte _south = 7;
+ @Native private static final byte _south = 7;
public static final Direction SOUTH = new Direction(_south);
- private static final byte _east = 8;
+ @Native private static final byte _east = 8;
public static final Direction EAST = new Direction(_east);
- private static final byte _west = 9;
+ @Native private static final byte _west = 9;
public static final Direction WEST = new Direction(_west);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class Orientation extends Property {
- private static final byte SHIFT = Direction.SHIFT + Direction.SIZE;
- private static final byte SIZE = 2;
- private static final long MASK = (long)0x3 << SHIFT;
+ @Native private static final byte SHIFT = Direction.SHIFT + Direction.SIZE;
+ @Native private static final byte SIZE = 2;
+ @Native private static final long MASK = (long)0x3 << SHIFT;
private static final PropertyEncoding orientation = new PropertyEncoding(MASK, SHIFT);
Orientation(final byte value) {
super(orientation, value);
}
- private static final byte _horizontal = 1;
+ @Native private static final byte _horizontal = 1;
public static final Orientation HORIZONTAL = new Orientation(_horizontal);
- private static final byte _vertical = 2;
+ @Native private static final byte _vertical = 2;
public static final Orientation VERTICAL = new Orientation(_vertical);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class AlignmentVertical extends Property {
- private static final byte SHIFT = Orientation.SHIFT + Orientation.SIZE;
- private static final byte SIZE = 2;
- private static final long MASK = (long)0x3 << SHIFT;
+ @Native private static final byte SHIFT = Orientation.SHIFT + Orientation.SIZE;
+ @Native private static final byte SIZE = 2;
+ @Native private static final long MASK = (long)0x3 << SHIFT;
private static final PropertyEncoding alignmentVertical = new PropertyEncoding(MASK, SHIFT);
AlignmentVertical(final byte value){
super(alignmentVertical, value);
}
- private static final byte _top = 1;
+ @Native private static final byte _top = 1;
public static final AlignmentVertical TOP = new AlignmentVertical(_top);
- private static final byte _center = 2;
+ @Native private static final byte _center = 2;
public static final AlignmentVertical CENTER = new AlignmentVertical(_center);
- private static final byte _bottom = 3;
+ @Native private static final byte _bottom = 3;
public static final AlignmentVertical BOTTOM = new AlignmentVertical(_bottom);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class AlignmentHorizontal extends Property {
- private static final byte SHIFT = AlignmentVertical.SHIFT + AlignmentVertical.SIZE;
- private static final byte SIZE = 2;
- private static final long MASK = (long)0x3 << SHIFT;
+ @Native private static final byte SHIFT = AlignmentVertical.SHIFT + AlignmentVertical.SIZE;
+ @Native private static final byte SIZE = 2;
+ @Native private static final long MASK = (long)0x3 << SHIFT;
private static final PropertyEncoding alignmentHorizontal = new PropertyEncoding(MASK, SHIFT);
AlignmentHorizontal(final byte value){
super(alignmentHorizontal, value);
}
- private static final byte _left = 1;
+ @Native private static final byte _left = 1;
public static final AlignmentHorizontal LEFT = new AlignmentHorizontal(_left);
- private static final byte _center = 2;
+ @Native private static final byte _center = 2;
public static final AlignmentHorizontal CENTER = new AlignmentHorizontal(_center);
- private static final byte _right = 3;
+ @Native private static final byte _right = 3;
public static final AlignmentHorizontal RIGHT = new AlignmentHorizontal(_right);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class SegmentPosition extends Property {
- private static final byte SHIFT = AlignmentHorizontal.SHIFT + AlignmentHorizontal.SIZE;
- private static final byte SIZE = 3;
- private static final long MASK = (long)0x7 << SHIFT;
+ @Native private static final byte SHIFT = AlignmentHorizontal.SHIFT + AlignmentHorizontal.SIZE;
+ @Native private static final byte SIZE = 3;
+ @Native private static final long MASK = (long)0x7 << SHIFT;
private static final PropertyEncoding segmentPosition = new PropertyEncoding(MASK, SHIFT);
SegmentPosition(final byte value) {
super(segmentPosition, value);
}
- private static final byte _first = 1;
+ @Native private static final byte _first = 1;
public static final SegmentPosition FIRST = new SegmentPosition(_first);
- private static final byte _middle = 2;
+ @Native private static final byte _middle = 2;
public static final SegmentPosition MIDDLE = new SegmentPosition(_middle);
- private static final byte _last = 3;
+ @Native private static final byte _last = 3;
public static final SegmentPosition LAST = new SegmentPosition(_last);
- private static final byte _only = 4;
+ @Native private static final byte _only = 4;
public static final SegmentPosition ONLY = new SegmentPosition(_only);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class ScrollBarPart extends Property {
- private static final byte SHIFT = SegmentPosition.SHIFT + SegmentPosition.SIZE;
- private static final byte SIZE = 4;
- private static final long MASK = (long)0xF << SHIFT;
+ @Native private static final byte SHIFT = SegmentPosition.SHIFT + SegmentPosition.SIZE;
+ @Native private static final byte SIZE = 4;
+ @Native private static final long MASK = (long)0xF << SHIFT;
private static final PropertyEncoding scrollBarPart = new PropertyEncoding(MASK, SHIFT);
ScrollBarPart(final byte value) {
super(scrollBarPart, value);
}
- private static final byte _none = 1;
+ @Native private static final byte _none = 1;
public static final ScrollBarPart NONE = new ScrollBarPart(_none);
- private static final byte _thumb = 2;
+ @Native private static final byte _thumb = 2;
public static final ScrollBarPart THUMB = new ScrollBarPart(_thumb);
- private static final byte _arrowMin = 3;
+ @Native private static final byte _arrowMin = 3;
public static final ScrollBarPart ARROW_MIN = new ScrollBarPart(_arrowMin);
- private static final byte _arrowMax = 4;
+ @Native private static final byte _arrowMax = 4;
public static final ScrollBarPart ARROW_MAX = new ScrollBarPart(_arrowMax);
- private static final byte _arrowMaxInside = 5;
+ @Native private static final byte _arrowMaxInside = 5;
public static final ScrollBarPart ARROW_MAX_INSIDE = new ScrollBarPart(_arrowMaxInside);
- private static final byte _arrowMinInside = 6;
+ @Native private static final byte _arrowMinInside = 6;
public static final ScrollBarPart ARROW_MIN_INSIDE = new ScrollBarPart(_arrowMinInside);
- private static final byte _trackMin = 7;
+ @Native private static final byte _trackMin = 7;
public static final ScrollBarPart TRACK_MIN = new ScrollBarPart(_trackMin);
- private static final byte _trackMax = 8;
+ @Native private static final byte _trackMax = 8;
public static final ScrollBarPart TRACK_MAX = new ScrollBarPart(_trackMax);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class Variant extends Property {
- private static final byte SHIFT = ScrollBarPart.SHIFT + ScrollBarPart.SIZE;
- private static final byte SIZE = 4;
- private static final long MASK = (long)0xF << SHIFT;
+ @Native private static final byte SHIFT = ScrollBarPart.SHIFT + ScrollBarPart.SIZE;
+ @Native private static final byte SIZE = 4;
+ @Native private static final long MASK = (long)0xF << SHIFT;
private static final PropertyEncoding variant = new PropertyEncoding(MASK, SHIFT);
Variant(final byte value) {
super(variant, value);
}
- private static final byte _menuGlyph = 1;
+ @Native private static final byte _menuGlyph = 1;
public static final Variant MENU_GLYPH = new Variant(_menuGlyph);
- private static final byte _menuPopup = Variant._menuGlyph + 1;
+ @Native private static final byte _menuPopup = Variant._menuGlyph + 1;
public static final Variant MENU_POPUP = new Variant(_menuPopup);
- private static final byte _menuPulldown = Variant._menuPopup + 1;
+ @Native private static final byte _menuPulldown = Variant._menuPopup + 1;
public static final Variant MENU_PULLDOWN = new Variant(_menuPulldown);
- private static final byte _menuHierarchical = Variant._menuPulldown + 1;
+ @Native private static final byte _menuHierarchical = Variant._menuPulldown + 1;
public static final Variant MENU_HIERARCHICAL = new Variant(_menuHierarchical);
- private static final byte _gradientListBackgroundEven = Variant._menuHierarchical + 1;
+ @Native private static final byte _gradientListBackgroundEven = Variant._menuHierarchical + 1;
public static final Variant GRADIENT_LIST_BACKGROUND_EVEN = new Variant(_gradientListBackgroundEven);
- private static final byte _gradientListBackgroundOdd = Variant._gradientListBackgroundEven + 1;
+ @Native private static final byte _gradientListBackgroundOdd = Variant._gradientListBackgroundEven + 1;
public static final Variant GRADIENT_LIST_BACKGROUND_ODD = new Variant(_gradientListBackgroundOdd);
- private static final byte _gradientSideBar = Variant._gradientListBackgroundOdd + 1;
+ @Native private static final byte _gradientSideBar = Variant._gradientListBackgroundOdd + 1;
public static final Variant GRADIENT_SIDE_BAR = new Variant(_gradientSideBar);
- private static final byte _gradientSideBarSelection = Variant._gradientSideBar + 1;
+ @Native private static final byte _gradientSideBarSelection = Variant._gradientSideBar + 1;
public static final Variant GRADIENT_SIDE_BAR_SELECTION = new Variant(_gradientSideBarSelection);
- private static final byte _gradientSideBarFocusedSelection = Variant._gradientSideBarSelection + 1;
+ @Native private static final byte _gradientSideBarFocusedSelection = Variant._gradientSideBarSelection + 1;
public static final Variant GRADIENT_SIDE_BAR_FOCUSED_SELECTION = new Variant(_gradientSideBarFocusedSelection);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class WindowType extends Property {
- private static final byte SHIFT = Variant.SHIFT + Variant.SIZE;
- private static final byte SIZE = 2;
- private static final long MASK = (long)0x3 << SHIFT;
+ @Native private static final byte SHIFT = Variant.SHIFT + Variant.SIZE;
+ @Native private static final byte SIZE = 2;
+ @Native private static final long MASK = (long)0x3 << SHIFT;
private static final PropertyEncoding windowType = new PropertyEncoding(MASK, SHIFT);
WindowType(final byte value){
super(windowType, value);
}
- private static final byte _document = 1;
+ @Native private static final byte _document = 1;
public static final WindowType DOCUMENT = new WindowType(_document);
- private static final byte _utility = 2;
+ @Native private static final byte _utility = 2;
public static final WindowType UTILITY = new WindowType(_utility);
- private static final byte _titlelessUtility = 3;
+ @Native private static final byte _titlelessUtility = 3;
public static final WindowType TITLELESS_UTILITY = new WindowType(_titlelessUtility);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class Focused extends Property {
- private static final byte SHIFT = WindowType.SHIFT + WindowType.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = WindowType.SHIFT + WindowType.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
Focused(final byte value) {
super(focused, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final Focused NO = new Focused(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final Focused YES = new Focused(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class IndicatorOnly extends Property {
- private static final byte SHIFT = Focused.SHIFT + Focused.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = Focused.SHIFT + Focused.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding indicatorOnly = new PropertyEncoding(MASK, SHIFT);
IndicatorOnly(final byte value) {
super(indicatorOnly, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final IndicatorOnly NO = new IndicatorOnly(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final IndicatorOnly YES = new IndicatorOnly(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class NoIndicator extends Property {
- private static final byte SHIFT = IndicatorOnly.SHIFT + IndicatorOnly.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = IndicatorOnly.SHIFT + IndicatorOnly.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding noIndicator = new PropertyEncoding(MASK, SHIFT);
NoIndicator(final byte value) {
super(noIndicator, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final NoIndicator NO = new NoIndicator(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final NoIndicator YES = new NoIndicator(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class ArrowsOnly extends Property {
- private static final byte SHIFT = NoIndicator.SHIFT + NoIndicator.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = NoIndicator.SHIFT + NoIndicator.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
ArrowsOnly(final byte value) {
super(focused, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final ArrowsOnly NO = new ArrowsOnly(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final ArrowsOnly YES = new ArrowsOnly(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class FrameOnly extends Property {
- private static final byte SHIFT = ArrowsOnly.SHIFT + ArrowsOnly.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = ArrowsOnly.SHIFT + ArrowsOnly.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
FrameOnly(final byte value) {
super(focused, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final FrameOnly NO = new FrameOnly(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final FrameOnly YES = new FrameOnly(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class SegmentTrailingSeparator extends Property {
- private static final byte SHIFT = FrameOnly.SHIFT + FrameOnly.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = FrameOnly.SHIFT + FrameOnly.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
SegmentTrailingSeparator(final byte value) {
super(focused, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final SegmentTrailingSeparator NO = new SegmentTrailingSeparator(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final SegmentTrailingSeparator YES = new SegmentTrailingSeparator(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class SegmentLeadingSeparator extends Property {
- private static final byte SHIFT = SegmentTrailingSeparator.SHIFT + SegmentTrailingSeparator.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = SegmentTrailingSeparator.SHIFT + SegmentTrailingSeparator.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding leadingSeparator = new PropertyEncoding(MASK, SHIFT);
SegmentLeadingSeparator(final byte value) {
super(leadingSeparator, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final SegmentLeadingSeparator NO = new SegmentLeadingSeparator(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final SegmentLeadingSeparator YES = new SegmentLeadingSeparator(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class NothingToScroll extends Property {
- private static final byte SHIFT = SegmentLeadingSeparator.SHIFT + SegmentLeadingSeparator.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = SegmentLeadingSeparator.SHIFT + SegmentLeadingSeparator.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
NothingToScroll(final byte value) {
super(focused, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final NothingToScroll NO = new NothingToScroll(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final NothingToScroll YES = new NothingToScroll(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class WindowTitleBarSeparator extends Property {
- private static final byte SHIFT = NothingToScroll.SHIFT + NothingToScroll.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = NothingToScroll.SHIFT + NothingToScroll.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
WindowTitleBarSeparator(final byte value) {
super(focused, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final WindowTitleBarSeparator NO = new WindowTitleBarSeparator(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final WindowTitleBarSeparator YES = new WindowTitleBarSeparator(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class WindowClipCorners extends Property {
- private static final byte SHIFT = WindowTitleBarSeparator.SHIFT + WindowTitleBarSeparator.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = WindowTitleBarSeparator.SHIFT + WindowTitleBarSeparator.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT);
WindowClipCorners(final byte value) {
super(focused, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final WindowClipCorners NO = new WindowClipCorners(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final WindowClipCorners YES = new WindowClipCorners(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class ShowArrows extends Property {
- private static final byte SHIFT = WindowClipCorners.SHIFT + WindowClipCorners.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = WindowClipCorners.SHIFT + WindowClipCorners.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding showArrows = new PropertyEncoding(MASK, SHIFT);
ShowArrows(final byte value) {
super(showArrows, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final ShowArrows NO = new ShowArrows(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final ShowArrows YES = new ShowArrows(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class BooleanValue extends Property {
- private static final byte SHIFT = ShowArrows.SHIFT + ShowArrows.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = ShowArrows.SHIFT + ShowArrows.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding booleanValue = new PropertyEncoding(MASK, SHIFT);
BooleanValue(final byte value) {
super(booleanValue, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final BooleanValue NO = new BooleanValue(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final BooleanValue YES = new BooleanValue(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class Animating extends Property {
- private static final byte SHIFT = BooleanValue.SHIFT + BooleanValue.SIZE;
- private static final byte SIZE = 1;
- private static final long MASK = (long)0x1 << SHIFT;
+ @Native private static final byte SHIFT = BooleanValue.SHIFT + BooleanValue.SIZE;
+ @Native private static final byte SIZE = 1;
+ @Native private static final long MASK = (long)0x1 << SHIFT;
private static final PropertyEncoding animating = new PropertyEncoding(MASK, SHIFT);
Animating(final byte value) {
super(animating, value);
}
- private static final byte _no = 0;
+ @Native private static final byte _no = 0;
public static final Animating NO = new Animating(_no);
- private static final byte _yes = 1;
+ @Native private static final byte _yes = 1;
public static final Animating YES = new Animating(_yes);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class Widget extends Property {
- private static final byte SHIFT = Animating.SHIFT + Animating.SIZE;
- private static final byte SIZE = 7;
- private static final long MASK = (long)0x7F << SHIFT;
+ @Native private static final byte SHIFT = Animating.SHIFT + Animating.SIZE;
+ @Native private static final byte SIZE = 7;
+ @Native private static final long MASK = (long)0x7F << SHIFT;
private static final PropertyEncoding widget = new PropertyEncoding(MASK, SHIFT);
Widget(final byte constant) {
super(widget, constant);
}
- private static final byte _background = 1;
+ @Native private static final byte _background = 1;
public static final Widget BACKGROUND = new Widget(_background);
- private static final byte _buttonBevel = _background + 1;
+ @Native private static final byte _buttonBevel = _background + 1;
public static final Widget BUTTON_BEVEL = new Widget(_buttonBevel);
- private static final byte _buttonBevelInset = _buttonBevel + 1;
+ @Native private static final byte _buttonBevelInset = _buttonBevel + 1;
public static final Widget BUTTON_BEVEL_INSET = new Widget(_buttonBevelInset);
- private static final byte _buttonBevelRound = _buttonBevelInset + 1;
+ @Native private static final byte _buttonBevelRound = _buttonBevelInset + 1;
public static final Widget BUTTON_BEVEL_ROUND = new Widget(_buttonBevelRound);
- private static final byte _buttonCheckBox = _buttonBevelRound + 1;
+ @Native private static final byte _buttonCheckBox = _buttonBevelRound + 1;
public static final Widget BUTTON_CHECK_BOX = new Widget(_buttonCheckBox);
- private static final byte _buttonComboBox = _buttonCheckBox + 1;
+ @Native private static final byte _buttonComboBox = _buttonCheckBox + 1;
public static final Widget BUTTON_COMBO_BOX = new Widget(_buttonComboBox);
- private static final byte _buttonComboBoxInset = _buttonComboBox + 1;
+ @Native private static final byte _buttonComboBoxInset = _buttonComboBox + 1;
public static final Widget BUTTON_COMBO_BOX_INSET = new Widget(_buttonComboBoxInset); // not hooked up in JRSUIConstants.m
- private static final byte _buttonDisclosure = _buttonComboBoxInset + 1;
+ @Native private static final byte _buttonDisclosure = _buttonComboBoxInset + 1;
public static final Widget BUTTON_DISCLOSURE = new Widget(_buttonDisclosure);
- private static final byte _buttonListHeader = _buttonDisclosure + 1;
+ @Native private static final byte _buttonListHeader = _buttonDisclosure + 1;
public static final Widget BUTTON_LIST_HEADER = new Widget(_buttonListHeader);
- private static final byte _buttonLittleArrows = _buttonListHeader + 1;
+ @Native private static final byte _buttonLittleArrows = _buttonListHeader + 1;
public static final Widget BUTTON_LITTLE_ARROWS = new Widget(_buttonLittleArrows);
- private static final byte _buttonPopDown = _buttonLittleArrows + 1;
+ @Native private static final byte _buttonPopDown = _buttonLittleArrows + 1;
public static final Widget BUTTON_POP_DOWN = new Widget(_buttonPopDown);
- private static final byte _buttonPopDownInset = _buttonPopDown + 1;
+ @Native private static final byte _buttonPopDownInset = _buttonPopDown + 1;
public static final Widget BUTTON_POP_DOWN_INSET = new Widget(_buttonPopDownInset);
- private static final byte _buttonPopDownSquare = _buttonPopDownInset + 1;
+ @Native private static final byte _buttonPopDownSquare = _buttonPopDownInset + 1;
public static final Widget BUTTON_POP_DOWN_SQUARE = new Widget(_buttonPopDownSquare);
- private static final byte _buttonPopUp = _buttonPopDownSquare + 1;
+ @Native private static final byte _buttonPopUp = _buttonPopDownSquare + 1;
public static final Widget BUTTON_POP_UP = new Widget(_buttonPopUp);
- private static final byte _buttonPopUpInset = _buttonPopUp + 1;
+ @Native private static final byte _buttonPopUpInset = _buttonPopUp + 1;
public static final Widget BUTTON_POP_UP_INSET = new Widget(_buttonPopUpInset);
- private static final byte _buttonPopUpSquare = _buttonPopUpInset + 1;
+ @Native private static final byte _buttonPopUpSquare = _buttonPopUpInset + 1;
public static final Widget BUTTON_POP_UP_SQUARE = new Widget(_buttonPopUpSquare);
- private static final byte _buttonPush = _buttonPopUpSquare + 1;
+ @Native private static final byte _buttonPush = _buttonPopUpSquare + 1;
public static final Widget BUTTON_PUSH = new Widget(_buttonPush);
- private static final byte _buttonPushScope = _buttonPush + 1;
+ @Native private static final byte _buttonPushScope = _buttonPush + 1;
public static final Widget BUTTON_PUSH_SCOPE = new Widget(_buttonPushScope);
- private static final byte _buttonPushScope2 = _buttonPushScope + 1;
+ @Native private static final byte _buttonPushScope2 = _buttonPushScope + 1;
public static final Widget BUTTON_PUSH_SCOPE2 = new Widget(_buttonPushScope2);
- private static final byte _buttonPushTextured = _buttonPushScope2 + 1;
+ @Native private static final byte _buttonPushTextured = _buttonPushScope2 + 1;
public static final Widget BUTTON_PUSH_TEXTURED = new Widget(_buttonPushTextured);
- private static final byte _buttonPushInset = _buttonPushTextured + 1;
+ @Native private static final byte _buttonPushInset = _buttonPushTextured + 1;
public static final Widget BUTTON_PUSH_INSET = new Widget(_buttonPushInset);
- private static final byte _buttonPushInset2 = _buttonPushInset + 1;
+ @Native private static final byte _buttonPushInset2 = _buttonPushInset + 1;
public static final Widget BUTTON_PUSH_INSET2 = new Widget(_buttonPushInset2);
- private static final byte _buttonRadio = _buttonPushInset2 + 1;
+ @Native private static final byte _buttonRadio = _buttonPushInset2 + 1;
public static final Widget BUTTON_RADIO = new Widget(_buttonRadio);
- private static final byte _buttonRound = _buttonRadio + 1;
+ @Native private static final byte _buttonRound = _buttonRadio + 1;
public static final Widget BUTTON_ROUND = new Widget(_buttonRound);
- private static final byte _buttonRoundHelp = _buttonRound + 1;
+ @Native private static final byte _buttonRoundHelp = _buttonRound + 1;
public static final Widget BUTTON_ROUND_HELP = new Widget(_buttonRoundHelp);
- private static final byte _buttonRoundInset = _buttonRoundHelp + 1;
+ @Native private static final byte _buttonRoundInset = _buttonRoundHelp + 1;
public static final Widget BUTTON_ROUND_INSET = new Widget(_buttonRoundInset);
- private static final byte _buttonRoundInset2 =_buttonRoundInset + 1;
+ @Native private static final byte _buttonRoundInset2 =_buttonRoundInset + 1;
public static final Widget BUTTON_ROUND_INSET2 = new Widget(_buttonRoundInset2);
- private static final byte _buttonSearchFieldCancel = _buttonRoundInset2 + 1;
+ @Native private static final byte _buttonSearchFieldCancel = _buttonRoundInset2 + 1;
public static final Widget BUTTON_SEARCH_FIELD_CANCEL = new Widget(_buttonSearchFieldCancel);
- private static final byte _buttonSearchFieldFind = _buttonSearchFieldCancel + 1;
+ @Native private static final byte _buttonSearchFieldFind = _buttonSearchFieldCancel + 1;
public static final Widget BUTTON_SEARCH_FIELD_FIND = new Widget(_buttonSearchFieldFind);
- private static final byte _buttonSegmented = _buttonSearchFieldFind + 1;
+ @Native private static final byte _buttonSegmented = _buttonSearchFieldFind + 1;
public static final Widget BUTTON_SEGMENTED = new Widget(_buttonSegmented);
- private static final byte _buttonSegmentedInset = _buttonSegmented + 1;
+ @Native private static final byte _buttonSegmentedInset = _buttonSegmented + 1;
public static final Widget BUTTON_SEGMENTED_INSET = new Widget(_buttonSegmentedInset);
- private static final byte _buttonSegmentedInset2 = _buttonSegmentedInset + 1;
+ @Native private static final byte _buttonSegmentedInset2 = _buttonSegmentedInset + 1;
public static final Widget BUTTON_SEGMENTED_INSET2 = new Widget(_buttonSegmentedInset2);
- private static final byte _buttonSegmentedSCurve = _buttonSegmentedInset2 + 1;
+ @Native private static final byte _buttonSegmentedSCurve = _buttonSegmentedInset2 + 1;
public static final Widget BUTTON_SEGMENTED_SCURVE = new Widget(_buttonSegmentedSCurve);
- private static final byte _buttonSegmentedTextured = _buttonSegmentedSCurve + 1;
+ @Native private static final byte _buttonSegmentedTextured = _buttonSegmentedSCurve + 1;
public static final Widget BUTTON_SEGMENTED_TEXTURED = new Widget(_buttonSegmentedTextured);
- private static final byte _buttonSegmentedToolbar = _buttonSegmentedTextured + 1;
+ @Native private static final byte _buttonSegmentedToolbar = _buttonSegmentedTextured + 1;
public static final Widget BUTTON_SEGMENTED_TOOLBAR = new Widget(_buttonSegmentedToolbar);
- private static final byte _dial = _buttonSegmentedToolbar + 1;
+ @Native private static final byte _dial = _buttonSegmentedToolbar + 1;
public static final Widget DIAL = new Widget(_dial);
- private static final byte _disclosureTriangle = _dial + 1;
+ @Native private static final byte _disclosureTriangle = _dial + 1;
public static final Widget DISCLOSURE_TRIANGLE = new Widget(_disclosureTriangle);
- private static final byte _dividerGrabber = _disclosureTriangle + 1;
+ @Native private static final byte _dividerGrabber = _disclosureTriangle + 1;
public static final Widget DIVIDER_GRABBER = new Widget(_dividerGrabber);
- private static final byte _dividerSeparatorBar = _dividerGrabber + 1;
+ @Native private static final byte _dividerSeparatorBar = _dividerGrabber + 1;
public static final Widget DIVIDER_SEPARATOR_BAR = new Widget(_dividerSeparatorBar);
- private static final byte _dividerSplitter = _dividerSeparatorBar + 1;
+ @Native private static final byte _dividerSplitter = _dividerSeparatorBar + 1;
public static final Widget DIVIDER_SPLITTER = new Widget(_dividerSplitter);
- private static final byte _focus = _dividerSplitter + 1;
+ @Native private static final byte _focus = _dividerSplitter + 1;
public static final Widget FOCUS = new Widget(_focus);
- private static final byte _frameGroupBox = _focus + 1;
+ @Native private static final byte _frameGroupBox = _focus + 1;
public static final Widget FRAME_GROUP_BOX = new Widget(_frameGroupBox);
- private static final byte _frameGroupBoxSecondary = _frameGroupBox + 1;
+ @Native private static final byte _frameGroupBoxSecondary = _frameGroupBox + 1;
public static final Widget FRAME_GROUP_BOX_SECONDARY = new Widget(_frameGroupBoxSecondary);
- private static final byte _frameListBox = _frameGroupBoxSecondary + 1;
+ @Native private static final byte _frameListBox = _frameGroupBoxSecondary + 1;
public static final Widget FRAME_LIST_BOX = new Widget(_frameListBox);
- private static final byte _framePlacard = _frameListBox + 1;
+ @Native private static final byte _framePlacard = _frameListBox + 1;
public static final Widget FRAME_PLACARD = new Widget(_framePlacard);
- private static final byte _frameTextField = _framePlacard + 1;
+ @Native private static final byte _frameTextField = _framePlacard + 1;
public static final Widget FRAME_TEXT_FIELD = new Widget(_frameTextField);
- private static final byte _frameTextFieldRound = _frameTextField + 1;
+ @Native private static final byte _frameTextFieldRound = _frameTextField + 1;
public static final Widget FRAME_TEXT_FIELD_ROUND = new Widget(_frameTextFieldRound);
- private static final byte _frameWell = _frameTextFieldRound + 1;
+ @Native private static final byte _frameWell = _frameTextFieldRound + 1;
public static final Widget FRAME_WELL = new Widget(_frameWell);
- private static final byte _growBox = _frameWell + 1;
+ @Native private static final byte _growBox = _frameWell + 1;
public static final Widget GROW_BOX = new Widget(_growBox);
- private static final byte _growBoxTextured = _growBox + 1;
+ @Native private static final byte _growBoxTextured = _growBox + 1;
public static final Widget GROW_BOX_TEXTURED = new Widget(_growBoxTextured);
- private static final byte _gradient = _growBoxTextured + 1;
+ @Native private static final byte _gradient = _growBoxTextured + 1;
public static final Widget GRADIENT = new Widget(_gradient);
- private static final byte _menu = _gradient + 1;
+ @Native private static final byte _menu = _gradient + 1;
public static final Widget MENU = new Widget(_menu);
- private static final byte _menuItem = _menu + 1;
+ @Native private static final byte _menuItem = _menu + 1;
public static final Widget MENU_ITEM = new Widget(_menuItem);
- private static final byte _menuBar = _menuItem + 1;
+ @Native private static final byte _menuBar = _menuItem + 1;
public static final Widget MENU_BAR = new Widget(_menuBar);
- private static final byte _menuTitle = _menuBar + 1;
+ @Native private static final byte _menuTitle = _menuBar + 1;
public static final Widget MENU_TITLE = new Widget(_menuTitle);
- private static final byte _progressBar = _menuTitle + 1;
+ @Native private static final byte _progressBar = _menuTitle + 1;
public static final Widget PROGRESS_BAR = new Widget(_progressBar);
- private static final byte _progressIndeterminateBar = _progressBar + 1;
+ @Native private static final byte _progressIndeterminateBar = _progressBar + 1;
public static final Widget PROGRESS_INDETERMINATE_BAR = new Widget(_progressIndeterminateBar);
- private static final byte _progressRelevance = _progressIndeterminateBar + 1;
+ @Native private static final byte _progressRelevance = _progressIndeterminateBar + 1;
public static final Widget PROGRESS_RELEVANCE = new Widget(_progressRelevance);
- private static final byte _progressSpinner = _progressRelevance + 1;
+ @Native private static final byte _progressSpinner = _progressRelevance + 1;
public static final Widget PROGRESS_SPINNER = new Widget(_progressSpinner);
- private static final byte _scrollBar = _progressSpinner + 1;
+ @Native private static final byte _scrollBar = _progressSpinner + 1;
public static final Widget SCROLL_BAR = new Widget(_scrollBar);
- private static final byte _scrollColumnSizer = _scrollBar + 1;
+ @Native private static final byte _scrollColumnSizer = _scrollBar + 1;
public static final Widget SCROLL_COLUMN_SIZER = new Widget(_scrollColumnSizer);
- private static final byte _slider = _scrollColumnSizer + 1;
+ @Native private static final byte _slider = _scrollColumnSizer + 1;
public static final Widget SLIDER = new Widget(_slider);
- private static final byte _sliderThumb = _slider + 1;
+ @Native private static final byte _sliderThumb = _slider + 1;
public static final Widget SLIDER_THUMB = new Widget(_sliderThumb);
- private static final byte _synchronization = _sliderThumb + 1;
+ @Native private static final byte _synchronization = _sliderThumb + 1;
public static final Widget SYNCHRONIZATION = new Widget(_synchronization);
- private static final byte _tab = _synchronization + 1;
+ @Native private static final byte _tab = _synchronization + 1;
public static final Widget TAB = new Widget(_tab);
- private static final byte _titleBarCloseBox = _tab + 1;
+ @Native private static final byte _titleBarCloseBox = _tab + 1;
public static final Widget TITLE_BAR_CLOSE_BOX = new Widget(_titleBarCloseBox);
- private static final byte _titleBarCollapseBox = _titleBarCloseBox + 1;
+ @Native private static final byte _titleBarCollapseBox = _titleBarCloseBox + 1;
public static final Widget TITLE_BAR_COLLAPSE_BOX = new Widget(_titleBarCollapseBox);
- private static final byte _titleBarZoomBox = _titleBarCollapseBox + 1;
+ @Native private static final byte _titleBarZoomBox = _titleBarCollapseBox + 1;
public static final Widget TITLE_BAR_ZOOM_BOX = new Widget(_titleBarZoomBox);
- private static final byte _titleBarToolbarButton = _titleBarZoomBox + 1;
+ @Native private static final byte _titleBarToolbarButton = _titleBarZoomBox + 1;
public static final Widget TITLE_BAR_TOOLBAR_BUTTON = new Widget(_titleBarToolbarButton);
- private static final byte _toolbarItemWell = _titleBarToolbarButton + 1;
+ @Native private static final byte _toolbarItemWell = _titleBarToolbarButton + 1;
public static final Widget TOOLBAR_ITEM_WELL = new Widget(_toolbarItemWell);
- private static final byte _windowFrame = _toolbarItemWell + 1;
+ @Native private static final byte _windowFrame = _toolbarItemWell + 1;
public static final Widget WINDOW_FRAME = new Widget(_windowFrame);
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class Hit {
- private static final int _unknown = -1;
+ @Native private static final int _unknown = -1;
public static final Hit UNKNOWN = new Hit(_unknown);
- private static final int _none = 0;
+ @Native private static final int _none = 0;
public static final Hit NONE = new Hit(_none);
- private static final int _hit = 1;
+ @Native private static final int _hit = 1;
public static final Hit HIT = new Hit(_hit);
final int hit;
@@ -831,24 +777,22 @@
}
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class ScrollBarHit extends Hit {
- private static final int _thumb = 2;
+ @Native private static final int _thumb = 2;
public static final ScrollBarHit THUMB = new ScrollBarHit(_thumb);
- private static final int _trackMin = 3;
+ @Native private static final int _trackMin = 3;
public static final ScrollBarHit TRACK_MIN = new ScrollBarHit(_trackMin);
- private static final int _trackMax = 4;
+ @Native private static final int _trackMax = 4;
public static final ScrollBarHit TRACK_MAX = new ScrollBarHit(_trackMax);
- private static final int _arrowMin = 5;
+ @Native private static final int _arrowMin = 5;
public static final ScrollBarHit ARROW_MIN = new ScrollBarHit(_arrowMin);
- private static final int _arrowMax = 6;
+ @Native private static final int _arrowMax = 6;
public static final ScrollBarHit ARROW_MAX = new ScrollBarHit(_arrowMax);
- private static final int _arrowMaxInside = 7;
+ @Native private static final int _arrowMaxInside = 7;
public static final ScrollBarHit ARROW_MAX_INSIDE = new ScrollBarHit(_arrowMaxInside);
- private static final int _arrowMinInside = 8;
+ @Native private static final int _arrowMinInside = 8;
public static final ScrollBarHit ARROW_MIN_INSIDE = new ScrollBarHit(_arrowMinInside);
ScrollBarHit(final int hit) { super(hit); }
diff --git a/src/macosx/classes/com/apple/eawt/FullScreenHandler.java b/src/macosx/classes/com/apple/eawt/FullScreenHandler.java
index 7ad9364..f5a843b 100644
--- a/src/macosx/classes/com/apple/eawt/FullScreenHandler.java
+++ b/src/macosx/classes/com/apple/eawt/FullScreenHandler.java
@@ -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
@@ -33,17 +33,15 @@
import com.apple.eawt.AppEvent.FullScreenEvent;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
final class FullScreenHandler {
private static final String CLIENT_PROPERTY = "com.apple.eawt.event.internalFullScreenHandler";
- static final int FULLSCREEN_WILL_ENTER = 1;
- static final int FULLSCREEN_DID_ENTER = 2;
- static final int FULLSCREEN_WILL_EXIT = 3;
- static final int FULLSCREEN_DID_EXIT = 4;
+ @Native static final int FULLSCREEN_WILL_ENTER = 1;
+ @Native static final int FULLSCREEN_DID_ENTER = 2;
+ @Native static final int FULLSCREEN_WILL_EXIT = 3;
+ @Native static final int FULLSCREEN_DID_EXIT = 4;
// installs a private instance of the handler, if necessary
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
diff --git a/src/macosx/classes/com/apple/eawt/event/GestureHandler.java b/src/macosx/classes/com/apple/eawt/event/GestureHandler.java
index 3b4d54f..1378a2c 100644
--- a/src/macosx/classes/com/apple/eawt/event/GestureHandler.java
+++ b/src/macosx/classes/com/apple/eawt/event/GestureHandler.java
@@ -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
@@ -31,18 +31,16 @@
import javax.swing.*;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
final class GestureHandler {
private static final String CLIENT_PROPERTY = "com.apple.eawt.event.internalGestureHandler";
// native constants for the supported types of high-level gestures
- static final int PHASE = 1;
- static final int ROTATE = 2;
- static final int MAGNIFY = 3;
- static final int SWIPE = 4;
+ @Native static final int PHASE = 1;
+ @Native static final int ROTATE = 2;
+ @Native static final int MAGNIFY = 3;
+ @Native static final int SWIPE = 4;
// installs a private instance of GestureHandler, if necessary
static void addGestureListenerTo(final JComponent component, final GestureListener listener) {
diff --git a/src/macosx/classes/com/apple/laf/AquaButtonBorder.java b/src/macosx/classes/com/apple/laf/AquaButtonBorder.java
index b45b0ce..80ccd72 100644
--- a/src/macosx/classes/com/apple/laf/AquaButtonBorder.java
+++ b/src/macosx/classes/com/apple/laf/AquaButtonBorder.java
@@ -83,14 +83,19 @@
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);
}
diff --git a/src/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java b/src/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java
index 14350ad..a370dc5 100644
--- a/src/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java
+++ b/src/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java
@@ -184,30 +184,30 @@
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))),
diff --git a/src/macosx/classes/sun/java2d/OSXSurfaceData.java b/src/macosx/classes/sun/java2d/OSXSurfaceData.java
index 8844d5a..2592b65 100644
--- a/src/macosx/classes/sun/java2d/OSXSurfaceData.java
+++ b/src/macosx/classes/sun/java2d/OSXSurfaceData.java
@@ -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
@@ -37,13 +37,11 @@
import sun.java2d.pipe.*;
import sun.lwawt.macosx.*;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/*
* This is the SurfaceData for a CGContextRef.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class OSXSurfaceData extends BufImgSurfaceData {
final static float UPPER_BND = Float.MAX_VALUE / 2.0f;
final static float LOWER_BND = -UPPER_BND;
@@ -198,147 +196,147 @@
// graphics primitives drawing implementation:
// certain primitives don't care about all the states (ex. drawing an image needs not involve setting current paint)
- static final int kPrimitive = 0;
- static final int kImage = 1;
- static final int kText = 2;
- static final int kCopyArea = 3;
- static final int kExternal = 4;
+ @Native static final int kPrimitive = 0;
+ @Native static final int kImage = 1;
+ @Native static final int kText = 2;
+ @Native static final int kCopyArea = 3;
+ @Native static final int kExternal = 4;
- static final int kLine = 5; // belongs to kPrimitive
- static final int kRect = 6; // belongs to kPrimitive
- static final int kRoundRect = 7; // belongs to kPrimitive
- static final int kOval = 8; // belongs to kPrimitive
- static final int kArc = 9; // belongs to kPrimitive
- static final int kPolygon = 10; // belongs to kPrimitive
- static final int kShape = 11; // belongs to kPrimitive
+ @Native static final int kLine = 5; // belongs to kPrimitive
+ @Native static final int kRect = 6; // belongs to kPrimitive
+ @Native static final int kRoundRect = 7; // belongs to kPrimitive
+ @Native static final int kOval = 8; // belongs to kPrimitive
+ @Native static final int kArc = 9; // belongs to kPrimitive
+ @Native static final int kPolygon = 10; // belongs to kPrimitive
+ @Native static final int kShape = 11; // belongs to kPrimitive
// static final int kImage = 12; // belongs to kImage
- static final int kString = 13; // belongs to kText
- static final int kGlyphs = 14; // belongs to kText
- static final int kUnicodes = 15; // belongs to kText
+ @Native static final int kString = 13; // belongs to kText
+ @Native static final int kGlyphs = 14; // belongs to kText
+ @Native static final int kUnicodes = 15; // belongs to kText
// static final int kCopyArea = 16; // belongs to kCopyArea
// static final int kExternal = 17; // belongs to kExternal
- static final int kCommonParameterCount = 1 + 1 + 4 + 4; // type + change flags + color info (type(1) align(1) and
+ @Native static final int kCommonParameterCount = 1 + 1 + 4 + 4; // type + change flags + color info (type(1) align(1) and
// value(2)) + parameters ((x1, y1, x2, y2) OR (x, y, w, h))
- static final int kLineParametersCount = kCommonParameterCount; // kCommonParameterCount
- static final int kRectParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill
- static final int kRoundRectParametersCount = kCommonParameterCount + 2 + 1; // kCommonParameterCount + arcW + arcH +
+ @Native static final int kLineParametersCount = kCommonParameterCount; // kCommonParameterCount
+ @Native static final int kRectParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill
+ @Native static final int kRoundRectParametersCount = kCommonParameterCount + 2 + 1; // kCommonParameterCount + arcW + arcH +
// isfill
- static final int kOvalParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill
- static final int kArcParametersCount = kCommonParameterCount + 2 + 1 + 1;// kCommonParameterCount + startAngle +
+ @Native static final int kOvalParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill
+ @Native static final int kArcParametersCount = kCommonParameterCount + 2 + 1 + 1;// kCommonParameterCount + startAngle +
// arcAngle + isfill + type
- static final int kPolygonParametersCount = 0; // not supported
- static final int kShapeParametersCount = 0; // not supported
- static final int kImageParametersCount = kCommonParameterCount + 2 + 2 + 4 + 4; // flip horz vert + w&h + src + dst
- static final int kStringParametersCount = 0; // not supported
- static final int kGlyphsParametersCount = 0; // not supported
- static final int kUnicodesParametersCount = 0; // not supported
- static final int kPixelParametersCount = 0; // not supported
- static final int kExternalParametersCount = 0; // not supported
+ @Native static final int kPolygonParametersCount = 0; // not supported
+ @Native static final int kShapeParametersCount = 0; // not supported
+ @Native static final int kImageParametersCount = kCommonParameterCount + 2 + 2 + 4 + 4; // flip horz vert + w&h + src + dst
+ @Native static final int kStringParametersCount = 0; // not supported
+ @Native static final int kGlyphsParametersCount = 0; // not supported
+ @Native static final int kUnicodesParametersCount = 0; // not supported
+ @Native static final int kPixelParametersCount = 0; // not supported
+ @Native static final int kExternalParametersCount = 0; // not supported
// for intParameters
// states info
- static final int kChangeFlagIndex = 0; // kBoundsChangedBit | .. | kFontChangedBit
+ @Native static final int kChangeFlagIndex = 0; // kBoundsChangedBit | .. | kFontChangedBit
// bounds info
- static final int kBoundsXIndex = 1;
- static final int kBoundsYIndex = 2;
- static final int kBoundsWidthIndex = 3;
- static final int kBoundsHeightIndex = 4;
+ @Native static final int kBoundsXIndex = 1;
+ @Native static final int kBoundsYIndex = 2;
+ @Native static final int kBoundsWidthIndex = 3;
+ @Native static final int kBoundsHeightIndex = 4;
// clip info
- static final int kClipStateIndex = 5;
- static final int kClipNumTypesIndex = 6;
- static final int kClipNumCoordsIndex = 7;
- static final int kClipWindingRuleIndex = 8;
- static final int kClipXIndex = 9;
- static final int kClipYIndex = 10;
- static final int kClipWidthIndex = 11;
- static final int kClipHeightIndex = 12;
+ @Native static final int kClipStateIndex = 5;
+ @Native static final int kClipNumTypesIndex = 6;
+ @Native static final int kClipNumCoordsIndex = 7;
+ @Native static final int kClipWindingRuleIndex = 8;
+ @Native static final int kClipXIndex = 9;
+ @Native static final int kClipYIndex = 10;
+ @Native static final int kClipWidthIndex = 11;
+ @Native static final int kClipHeightIndex = 12;
// ctm info
- static final int kCTMaIndex = 13;
- static final int kCTMbIndex = 14;
- static final int kCTMcIndex = 15;
- static final int kCTMdIndex = 16;
- static final int kCTMtxIndex = 17;
- static final int kCTMtyIndex = 18;
+ @Native static final int kCTMaIndex = 13;
+ @Native static final int kCTMbIndex = 14;
+ @Native static final int kCTMcIndex = 15;
+ @Native static final int kCTMdIndex = 16;
+ @Native static final int kCTMtxIndex = 17;
+ @Native static final int kCTMtyIndex = 18;
// color info
- static final int kColorStateIndex = 19; // kColorSimple or kColorGradient or kColorTexture
- static final int kColorRGBValueIndex = 20; // if kColorSimple
- static final int kColorIndexValueIndex = 21; // if kColorSystem
- static final int kColorPointerIndex = 22; //
- static final int kColorPointerIndex2 = 23; //
- static final int kColorRGBValue1Index = 24; // if kColorGradient
- static final int kColorWidthIndex = 25; // if kColorTexture
- static final int kColorRGBValue2Index = 26; // if kColorGradient
- static final int kColorHeightIndex = 27; // if kColorTexture
- static final int kColorIsCyclicIndex = 28; // if kColorGradient (kColorNonCyclic or kColorCyclic)
- static final int kColorx1Index = 29;
- static final int kColortxIndex = 30;
- static final int kColory1Index = 31;
- static final int kColortyIndex = 32;
- static final int kColorx2Index = 33;
- static final int kColorsxIndex = 34;
- static final int kColory2Index = 35;
- static final int kColorsyIndex = 36;
+ @Native static final int kColorStateIndex = 19; // kColorSimple or kColorGradient or kColorTexture
+ @Native static final int kColorRGBValueIndex = 20; // if kColorSimple
+ @Native static final int kColorIndexValueIndex = 21; // if kColorSystem
+ @Native static final int kColorPointerIndex = 22; //
+ @Native static final int kColorPointerIndex2 = 23; //
+ @Native static final int kColorRGBValue1Index = 24; // if kColorGradient
+ @Native static final int kColorWidthIndex = 25; // if kColorTexture
+ @Native static final int kColorRGBValue2Index = 26; // if kColorGradient
+ @Native static final int kColorHeightIndex = 27; // if kColorTexture
+ @Native static final int kColorIsCyclicIndex = 28; // if kColorGradient (kColorNonCyclic or kColorCyclic)
+ @Native static final int kColorx1Index = 29;
+ @Native static final int kColortxIndex = 30;
+ @Native static final int kColory1Index = 31;
+ @Native static final int kColortyIndex = 32;
+ @Native static final int kColorx2Index = 33;
+ @Native static final int kColorsxIndex = 34;
+ @Native static final int kColory2Index = 35;
+ @Native static final int kColorsyIndex = 36;
// composite info
- static final int kCompositeRuleIndex = 37; // kCGCompositeClear or ... or kCGCompositeXor
- static final int kCompositeValueIndex = 38;
+ @Native static final int kCompositeRuleIndex = 37; // kCGCompositeClear or ... or kCGCompositeXor
+ @Native static final int kCompositeValueIndex = 38;
// stroke info
- static final int kStrokeJoinIndex = 39; // see BasicStroke.java
- static final int kStrokeCapIndex = 40; // see BasicStroke.java
- static final int kStrokeWidthIndex = 41;
- static final int kStrokeDashPhaseIndex = 42;
- static final int kStrokeLimitIndex = 43;
+ @Native static final int kStrokeJoinIndex = 39; // see BasicStroke.java
+ @Native static final int kStrokeCapIndex = 40; // see BasicStroke.java
+ @Native static final int kStrokeWidthIndex = 41;
+ @Native static final int kStrokeDashPhaseIndex = 42;
+ @Native static final int kStrokeLimitIndex = 43;
// hints info
- static final int kHintsAntialiasIndex = 44;
- static final int kHintsTextAntialiasIndex = 45;
- static final int kHintsFractionalMetricsIndex = 46;
- static final int kHintsRenderingIndex = 47;
- static final int kHintsInterpolationIndex = 48;
+ @Native static final int kHintsAntialiasIndex = 44;
+ @Native static final int kHintsTextAntialiasIndex = 45;
+ @Native static final int kHintsFractionalMetricsIndex = 46;
+ @Native static final int kHintsRenderingIndex = 47;
+ @Native static final int kHintsInterpolationIndex = 48;
// live resizing info
- static final int kCanDrawDuringLiveResizeIndex = 49;
+ @Native static final int kCanDrawDuringLiveResizeIndex = 49;
- static final int kSizeOfParameters = kCanDrawDuringLiveResizeIndex + 1;
+ @Native static final int kSizeOfParameters = kCanDrawDuringLiveResizeIndex + 1;
// for objectParameters
- static final int kClipCoordinatesIndex = 0;
- static final int kClipTypesIndex = 1;
- static final int kTextureImageIndex = 2;
- static final int kStrokeDashArrayIndex = 3;
- static final int kFontIndex = 4;
- static final int kFontPaintIndex = 5;
+ @Native static final int kClipCoordinatesIndex = 0;
+ @Native static final int kClipTypesIndex = 1;
+ @Native static final int kTextureImageIndex = 2;
+ @Native static final int kStrokeDashArrayIndex = 3;
+ @Native static final int kFontIndex = 4;
+ @Native static final int kFontPaintIndex = 5;
// possible state changes
- static final int kBoundsChangedBit = 1 << 0;
- static final int kBoundsNotChangedBit = ~kBoundsChangedBit;
- static final int kClipChangedBit = 1 << 1;
- static final int kClipNotChangedBit = ~kClipChangedBit;
- static final int kCTMChangedBit = 1 << 2;
- static final int kCTMNotChangedBit = ~kCTMChangedBit;
- static final int kColorChangedBit = 1 << 3;
- static final int kColorNotChangedBit = ~kColorChangedBit;
- static final int kCompositeChangedBit = 1 << 4;
- static final int kCompositeNotChangedBit = ~kCompositeChangedBit;
- static final int kStrokeChangedBit = 1 << 5;
- static final int kStrokeNotChangedBit = ~kStrokeChangedBit;
- static final int kHintsChangedBit = 1 << 6;
- static final int kHintsNotChangedBit = ~kHintsChangedBit;
- static final int kFontChangedBit = 1 << 7;
- static final int kFontNotChangedBit = ~kFontChangedBit;
- static final int kEverythingChangedFlag = 0xffffffff;
+ @Native static final int kBoundsChangedBit = 1 << 0;
+ @Native static final int kBoundsNotChangedBit = ~kBoundsChangedBit;
+ @Native static final int kClipChangedBit = 1 << 1;
+ @Native static final int kClipNotChangedBit = ~kClipChangedBit;
+ @Native static final int kCTMChangedBit = 1 << 2;
+ @Native static final int kCTMNotChangedBit = ~kCTMChangedBit;
+ @Native static final int kColorChangedBit = 1 << 3;
+ @Native static final int kColorNotChangedBit = ~kColorChangedBit;
+ @Native static final int kCompositeChangedBit = 1 << 4;
+ @Native static final int kCompositeNotChangedBit = ~kCompositeChangedBit;
+ @Native static final int kStrokeChangedBit = 1 << 5;
+ @Native static final int kStrokeNotChangedBit = ~kStrokeChangedBit;
+ @Native static final int kHintsChangedBit = 1 << 6;
+ @Native static final int kHintsNotChangedBit = ~kHintsChangedBit;
+ @Native static final int kFontChangedBit = 1 << 7;
+ @Native static final int kFontNotChangedBit = ~kFontChangedBit;
+ @Native static final int kEverythingChangedFlag = 0xffffffff;
// possible color states
- static final int kColorSimple = 0;
- static final int kColorSystem = 1;
- static final int kColorGradient = 2;
- static final int kColorTexture = 3;
+ @Native static final int kColorSimple = 0;
+ @Native static final int kColorSystem = 1;
+ @Native static final int kColorGradient = 2;
+ @Native static final int kColorTexture = 3;
// possible gradient color states
- static final int kColorNonCyclic = 0;
- static final int kColorCyclic = 1;
+ @Native static final int kColorNonCyclic = 0;
+ @Native static final int kColorCyclic = 1;
// possible clip states
- static final int kClipRect = 0;
- static final int kClipShape = 1;
+ @Native static final int kClipRect = 0;
+ @Native static final int kClipShape = 1;
static int getRendererTypeForPrimitive(int primitiveType) {
switch (primitiveType) {
diff --git a/src/macosx/classes/sun/lwawt/macosx/CocoaConstants.java b/src/macosx/classes/sun/lwawt/macosx/CocoaConstants.java
index a3c4851..e94f512 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CocoaConstants.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CocoaConstants.java
@@ -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
@@ -25,10 +25,7 @@
package sun.lwawt.macosx;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public final class CocoaConstants {
private CocoaConstants(){}
diff --git a/src/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java b/src/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
index f571512..dfd5d4e 100644
--- a/src/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
+++ b/src/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
@@ -32,11 +32,13 @@
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.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 @@
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 @@
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 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 @@
}
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 @@
}
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;
}
}
diff --git a/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs b/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs
index 2759733..b9b0070 100644
--- a/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs
+++ b/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs
@@ -2,7 +2,7 @@
{-
/*
- * 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
@@ -34,7 +34,7 @@
import Data.List
import Data.Maybe
-import Char
+import Data.Char
data Width = W32 | W64
deriving (Show, Eq, Bounded, Enum)
@@ -196,8 +196,6 @@
c2java ntype =
unlines [
"// native " ++ ntypeS ++ " -> java " ++ jprimS,
- "/* No native methods here, but the constants are needed in the supporting JNI code */",
- "@GenerateNativeHeader",
"public static final class " ++ className ++ " extends PrimitiveCoder<" ++ jclassS ++ ">{",
"\tpublic static final " ++ className ++ " INST = new " ++ className ++ "();",
"\tpublic " ++ className ++ "(){ super("++ffitypeVal ntype++", \"" ++ [encoding ntype] ++ "\", "++jclassS++".class, "++jprimS++".class); }",
@@ -248,13 +246,10 @@
putStrLn "package com.apple.jobjc;"
putStrLn "import com.apple.jobjc.JObjCRuntime.Width;"
- putStrLn "import javax.tools.annotation.GenerateNativeHeader;"
putStrLn "// Auto generated by PrimitiveCoder.hs"
putStrLn "// Do not edit by hand."
- putStrLn "/* No native methods here, but the constants are needed in the supporting JNI code */"
- putStrLn "@GenerateNativeHeader"
putStrLn "public abstract class PrimitiveCoder<T> extends Coder<T>{"
putStrLn "\tpublic PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){"
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java
index 9f05ed7..5207cf8 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java
@@ -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
@@ -24,10 +24,7 @@
*/
package com.apple.jobjc;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class CFType extends Pointer<Void> {
protected CFType(long ptr) { super(ptr); }
protected CFType(Pointer<?> ptr) { super(ptr.ptr); }
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java
index eb8387a..9efc76e 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java
@@ -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
@@ -35,7 +35,6 @@
import com.apple.jobjc.PrimitiveCoder.SIntCoder;
import com.apple.jobjc.PrimitiveCoder.SLongLongCoder;
import com.apple.jobjc.PrimitiveCoder.SShortCoder;
-import javax.tools.annotation.GenerateNativeHeader;
public abstract class Coder<T> {
private static native long getNativeFFITypePtrForCode(final int code);
@@ -143,8 +142,6 @@
//
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static final class VoidCoder extends Coder<Object>{
public static final VoidCoder INST = new VoidCoder();
public VoidCoder(){ super(FFI_VOID, "v", Void.class, void.class); }
@@ -153,8 +150,6 @@
@Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Trying to push a Void."); }
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static final class UnknownCoder extends Coder<Object> {
public static final UnknownCoder INST = new UnknownCoder();
public UnknownCoder(){ super(-1, "?", null, null); }
@@ -163,8 +158,6 @@
@Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Coder not implemented"); }
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static final class PrimitivePointerCoder extends Coder<Long> {
public static final PrimitivePointerCoder INST = new PrimitivePointerCoder();
public PrimitivePointerCoder(){ super(Coder.FFI_PTR, "^?", Long.class, long.class); }
@@ -194,8 +187,6 @@
@Override public void push(JObjCRuntime runtime, long addr, Long x) { push(runtime, addr, (long) x); }
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static final class PointerCoder extends Coder<Pointer> {
public static final PointerCoder INST = new PointerCoder();
public PointerCoder(){ super(FFI_PTR, "^?", Pointer.class); }
@@ -209,8 +200,6 @@
}
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static final class SELCoder extends Coder<SEL> {
public static final SELCoder INST = new SELCoder();
public SELCoder(){ super(FFI_PTR, ":", SEL.class); }
@@ -224,8 +213,6 @@
}
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static abstract class StructCoder extends Coder<Struct> {
private final FFIType ffiType;
final int sizeof;
@@ -267,8 +254,6 @@
}
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static final class IDCoder extends Coder<ID>{
public static final IDCoder INST = new IDCoder();
public IDCoder(){ super(FFI_PTR, "@", ID.class); }
@@ -287,8 +272,6 @@
}
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static final class NSClassCoder extends Coder<NSClass>{
public static final NSClassCoder INST = new NSClassCoder();
public NSClassCoder(){ super(FFI_PTR, "#", NSClass.class); }
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java
index 9927edf..dcff003 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java
@@ -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
@@ -26,10 +26,7 @@
import com.apple.jobjc.Coder.PrimitivePointerCoder;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
class FFIType{
private static native void makeFFIType(long ffi_type_buf, long elements_buf);
private static native int getFFITypeSizeof();
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java
index cbbc359..413d8fa 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java
@@ -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
@@ -24,10 +24,7 @@
*/
package com.apple.jobjc;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class Function {
private static native long getFxnPtrForFunctionName(final String functionName);
private static native long getFxnPtrForFunctionNameAndLib(final long libPtr, final String functionName);
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java
index 084a55f..aa202cf 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java
@@ -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
@@ -29,10 +29,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class ID extends Pointer<Void>{
static native String getNativeDescription(final long objPtr);
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java
index 5851843..48ffc98 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java
@@ -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
@@ -30,18 +30,13 @@
import com.apple.jobjc.Coder.SELCoder;
import com.apple.jobjc.Coder.StructCoder;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class Invoke {
public abstract void invoke(NativeArgumentBuffer argBuf);
public abstract void invoke(NativeArgumentBuffer buffer, Struct retvalStruct);
//
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static final class FunCall extends Invoke{
static native void invoke(long cifPtr, long fxnPtr, long retValPtr, long argsPtr);
@@ -78,8 +73,6 @@
}
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static final class MsgSend extends Invoke{
static{ System.load("/usr/lib/libobjc.dylib"); }
@@ -165,8 +158,6 @@
}
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static final class MsgSendSuper extends Invoke{
static{ System.load("/usr/lib/libobjc.dylib"); }
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java
index e6757ce..5bc01bc 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java
@@ -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
@@ -31,16 +31,11 @@
import sun.misc.Unsafe;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public final class JObjCRuntime {
static { System.loadLibrary("JObjC"); }
- @GenerateNativeHeader
public static enum Arch{ ppc, i386, x86_64 };
- @GenerateNativeHeader
public static enum Width{ W32, W64 };
public static final Arch ARCH = getArch();
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java
index bb70553..bd77668 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java
@@ -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
@@ -25,10 +25,7 @@
package com.apple.jobjc;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class MacOSXFramework {
private static native long retainFramework(final String frameworkName);
private static native void releaseFramework(final long frameworkPtr);
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java
index c116bc6..dfda99a 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java
@@ -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
@@ -27,13 +27,8 @@
import java.lang.ref.WeakReference;
import java.lang.reflect.Constructor;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class NSClass<T extends ID> extends ID {
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class NSClassNotFoundException extends RuntimeException{
public NSClassNotFoundException(String m){ super(m); }
public NSClassNotFoundException(String m, Throwable cause){ super(m, cause); }
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java
index be6a009..7f8949a 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java
@@ -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
@@ -28,10 +28,7 @@
import com.apple.jobjc.Coder.PrimitivePointerCoder;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public final class NativeArgumentBuffer{
private static final ThreadLocal<NativeArgumentBuffer> threadLocal = new ThreadLocal<NativeArgumentBuffer>();
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java
index 229a245..8630971 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java
@@ -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
@@ -27,13 +27,10 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* A wrapper around a direct ByteBuffer and its native pointer. For documentation, @see java.nio.ByteBuffer
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class NativeBuffer {
static native long getPtrOfBuffer(final ByteBuffer byteBuffer);
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java
index 78f4ca5..993be33 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java
@@ -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
@@ -24,10 +24,7 @@
*/
package com.apple.jobjc;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class NativeObjectLifecycleManager {
private static native void retainNativeObject(final long ptr);
private static native void releaseNativeObject(final long ptr);
@@ -37,8 +34,6 @@
abstract void end(final long ptr);
boolean shouldPreRetain() { return false; }
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class CFRetainRelease extends NativeObjectLifecycleManager {
public static final NativeObjectLifecycleManager INST = new CFRetainRelease();
@Override void begin(final long ptr) { retainNativeObject(ptr); }
@@ -46,16 +41,12 @@
@Override boolean shouldPreRetain() { return true; }
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class Free extends NativeObjectLifecycleManager {
public static final NativeObjectLifecycleManager INST = new Free();
@Override void begin(final long ptr) { }
@Override void end(final long ptr) { freeNativeObject(ptr); }
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
public static class Nothing extends NativeObjectLifecycleManager {
public static final NativeObjectLifecycleManager INST = new Nothing();
@Override void begin(final long ptr) { }
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java
index 1a362d6..fe66848 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java
@@ -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
@@ -24,10 +24,7 @@
*/
package com.apple.jobjc;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class Opaque extends Pointer<Void> {
protected Opaque(long ptr) { super(ptr); }
protected Opaque(Pointer<?> ptr) { super(ptr.ptr); }
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java
index 1cd728c..d5b83b9 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java
@@ -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
@@ -24,10 +24,7 @@
*/
package com.apple.jobjc;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class Pointer <T> implements Comparable<Pointer<T>>{
long ptr;
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java
index 975b888..eab34a7 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java
@@ -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
@@ -24,11 +24,8 @@
*/
package com.apple.jobjc;
import com.apple.jobjc.JObjCRuntime.Width;
-import javax.tools.annotation.GenerateNativeHeader;
// Auto generated by PrimitiveCoder.hs
// Do not edit by hand.
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class PrimitiveCoder<T> extends Coder<T>{
public PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){
super(ffiTypeCode, objCEncoding, jclass, jprim);
@@ -130,8 +127,6 @@
// native BOOL -> java boolean
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class BoolCoder extends PrimitiveCoder<Boolean>{
public static final BoolCoder INST = new BoolCoder();
public BoolCoder(){ super(FFI_SINT8, "B", Boolean.class, boolean.class); }
@@ -175,8 +170,6 @@
}
// native schar -> java byte
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class SCharCoder extends PrimitiveCoder<Byte>{
public static final SCharCoder INST = new SCharCoder();
public SCharCoder(){ super(FFI_SINT8, "c", Byte.class, byte.class); }
@@ -220,8 +213,6 @@
}
// native uchar -> java byte
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class UCharCoder extends PrimitiveCoder<Byte>{
public static final UCharCoder INST = new UCharCoder();
public UCharCoder(){ super(FFI_UINT8, "C", Byte.class, byte.class); }
@@ -265,8 +256,6 @@
}
// native sshort -> java short
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class SShortCoder extends PrimitiveCoder<Short>{
public static final SShortCoder INST = new SShortCoder();
public SShortCoder(){ super(FFI_SINT16, "s", Short.class, short.class); }
@@ -310,8 +299,6 @@
}
// native ushort -> java short
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class UShortCoder extends PrimitiveCoder<Short>{
public static final UShortCoder INST = new UShortCoder();
public UShortCoder(){ super(FFI_UINT16, "S", Short.class, short.class); }
@@ -355,8 +342,6 @@
}
// native sint -> java int
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class SIntCoder extends PrimitiveCoder<Integer>{
public static final SIntCoder INST = new SIntCoder();
public SIntCoder(){ super(FFI_SINT32, "i", Integer.class, int.class); }
@@ -400,8 +385,6 @@
}
// native uint -> java int
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class UIntCoder extends PrimitiveCoder<Integer>{
public static final UIntCoder INST = new UIntCoder();
public UIntCoder(){ super(FFI_UINT32, "I", Integer.class, int.class); }
@@ -445,8 +428,6 @@
}
// native slong -> java long
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class SLongCoder extends PrimitiveCoder<Long>{
public static final SLongCoder INST = new SLongCoder();
public SLongCoder(){ super((JObjCRuntime.IS64 ? (FFI_SINT64) : (FFI_SINT32)), "l", Long.class, long.class); }
@@ -496,8 +477,6 @@
}
// native ulong -> java long
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class ULongCoder extends PrimitiveCoder<Long>{
public static final ULongCoder INST = new ULongCoder();
public ULongCoder(){ super((JObjCRuntime.IS64 ? (FFI_UINT64) : (FFI_UINT32)), "L", Long.class, long.class); }
@@ -547,8 +526,6 @@
}
// native slonglong -> java long
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class SLongLongCoder extends PrimitiveCoder<Long>{
public static final SLongLongCoder INST = new SLongLongCoder();
public SLongLongCoder(){ super(FFI_SINT64, "q", Long.class, long.class); }
@@ -592,8 +569,6 @@
}
// native ulonglong -> java long
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class ULongLongCoder extends PrimitiveCoder<Long>{
public static final ULongLongCoder INST = new ULongLongCoder();
public ULongLongCoder(){ super(FFI_UINT64, "Q", Long.class, long.class); }
@@ -637,8 +612,6 @@
}
// native float -> java float
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class FloatCoder extends PrimitiveCoder<Float>{
public static final FloatCoder INST = new FloatCoder();
public FloatCoder(){ super(FFI_FLOAT, "f", Float.class, float.class); }
@@ -682,8 +655,6 @@
}
// native double -> java double
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public static final class DoubleCoder extends PrimitiveCoder<Double>{
public static final DoubleCoder INST = new DoubleCoder();
public DoubleCoder(){ super(FFI_DOUBLE, "d", Double.class, double.class); }
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java
index 0dfcf3f..7e085f8 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java
@@ -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
@@ -24,10 +24,7 @@
*/
package com.apple.jobjc;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class SEL {
static native long getSelectorPtr(String selectorName);
static native String getSelectorName(long ptr);
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java
index 1d1ddff..b14e84d 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java
@@ -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
@@ -24,13 +24,10 @@
*/
package com.apple.jobjc;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* A struct is malloced on the C heap and accessed in Java through a ByteBuffer.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class Struct{
protected final NativeBuffer raw;
private final JObjCRuntime runtime;
diff --git a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java
index 04961a3..c0e72b1 100644
--- a/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java
+++ b/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java
@@ -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
@@ -33,10 +33,7 @@
import com.apple.jobjc.Coder.VoidCoder;
import com.apple.jobjc.Invoke.MsgSend;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
final class Subclassing {
static native long allocateClassPair(long superClass, String name);
static native boolean addIVarForJObj(long clazz);
diff --git a/src/macosx/native/jobjc/src/core/native/Invoke.m b/src/macosx/native/jobjc/src/core/native/Invoke.m
index f756034..28a11d9 100644
--- a/src/macosx/native/jobjc/src/core/native/Invoke.m
+++ b/src/macosx/native/jobjc/src/core/native/Invoke.m
@@ -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
@@ -24,8 +24,6 @@
*/
#include "com_apple_jobjc_Invoke_FunCall.h"
-#include "com_apple_jobjc_Invoke_MsgSend.h"
-#include "com_apple_jobjc_Invoke_MsgSendSuper.h"
#include <ffi/ffi.h>
#include <objc/message.h>
#include <JavaNativeFoundation/JavaNativeFoundation.h>
diff --git a/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m b/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m
index cd4cddd..dfb5b48 100644
--- a/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m
+++ b/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m
@@ -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
@@ -23,6 +23,5 @@
* questions.
*/
-#include "com_apple_jobjc_JObjCRuntime.h"
#include "Cocoa/Cocoa.h"
diff --git a/src/macosx/native/sun/awt/CGraphicsDevice.m b/src/macosx/native/sun/awt/CGraphicsDevice.m
index 1e2df28..230569d 100644
--- a/src/macosx/native/sun/awt/CGraphicsDevice.m
+++ b/src/macosx/native/sun/awt/CGraphicsDevice.m
@@ -49,6 +49,42 @@
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 @@
(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 @@
{
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");
diff --git a/src/macosx/native/sun/awt/PrinterView.m b/src/macosx/native/sun/awt/PrinterView.m
index b713409..0400f5e 100644
--- a/src/macosx/native/sun/awt/PrinterView.m
+++ b/src/macosx/native/sun/awt/PrinterView.m
@@ -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
@@ -26,7 +26,6 @@
#import "PrinterView.h"
#import "java_awt_print_Pageable.h"
-#import "java_awt_print_Printable.h"
#import "java_awt_print_PageFormat.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
diff --git a/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c b/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
index 3e1fda3..5cac939 100644
--- a/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
+++ b/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
@@ -32,8 +32,8 @@
static CFDateFormatterStyle convertDateFormatterStyle(jint javaStyle);
static CFNumberFormatterStyle convertNumberFormatterStyle(jint javaStyle);
static void copyArrayElements(JNIEnv *env, CFArrayRef cfarray, jobjectArray jarray, CFIndex sindex, int dindex, int count);
-static jstring getNumberSymbolString(JNIEnv *env, jstring jdefault, CFStringRef type);
-static jchar getNumberSymbolChar(jchar jdefault, CFStringRef type);
+static jstring getNumberSymbolString(JNIEnv *env, jstring jlangtag, jstring jdefault, CFStringRef type);
+static jchar getNumberSymbolChar(JNIEnv *env, jstring jlangtag, jchar jdefault, CFStringRef type);
// from java_props_macosx.c
extern char * getMacOSXLocale(int cat);
@@ -322,7 +322,7 @@
*/
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCurrencySymbol
(JNIEnv *env, jclass cls, jstring jlangtag, jstring currencySymbol) {
- return getNumberSymbolString(env, currencySymbol, kCFNumberFormatterCurrencySymbol);
+ return getNumberSymbolString(env, jlangtag, currencySymbol, kCFNumberFormatterCurrencySymbol);
}
/*
@@ -332,7 +332,7 @@
*/
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDecimalSeparator
(JNIEnv *env, jclass cls, jstring jlangtag, jchar decimalSeparator) {
- return getNumberSymbolChar(decimalSeparator, kCFNumberFormatterDecimalSeparator);
+ return getNumberSymbolChar(env, jlangtag, decimalSeparator, kCFNumberFormatterDecimalSeparator);
}
/*
@@ -342,7 +342,7 @@
*/
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getGroupingSeparator
(JNIEnv *env, jclass cls, jstring jlangtag, jchar groupingSeparator) {
- return getNumberSymbolChar(groupingSeparator, kCFNumberFormatterGroupingSeparator);
+ return getNumberSymbolChar(env, jlangtag, groupingSeparator, kCFNumberFormatterGroupingSeparator);
}
/*
@@ -352,7 +352,7 @@
*/
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInfinity
(JNIEnv *env, jclass cls, jstring jlangtag, jstring infinity) {
- return getNumberSymbolString(env, infinity, kCFNumberFormatterInfinitySymbol);
+ return getNumberSymbolString(env, jlangtag, infinity, kCFNumberFormatterInfinitySymbol);
}
/*
@@ -362,7 +362,7 @@
*/
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInternationalCurrencySymbol
(JNIEnv *env, jclass cls, jstring jlangtag, jstring internationalCurrencySymbol) {
- return getNumberSymbolString(env, internationalCurrencySymbol, kCFNumberFormatterInternationalCurrencySymbol);
+ return getNumberSymbolString(env, jlangtag, internationalCurrencySymbol, kCFNumberFormatterInternationalCurrencySymbol);
}
/*
@@ -372,7 +372,7 @@
*/
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMinusSign
(JNIEnv *env, jclass cls, jstring jlangtag, jchar minusSign) {
- return getNumberSymbolChar(minusSign, kCFNumberFormatterMinusSign);
+ return getNumberSymbolChar(env, jlangtag, minusSign, kCFNumberFormatterMinusSign);
}
/*
@@ -382,7 +382,7 @@
*/
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMonetaryDecimalSeparator
(JNIEnv *env, jclass cls, jstring jlangtag, jchar monetaryDecimalSeparator) {
- return getNumberSymbolChar(monetaryDecimalSeparator, kCFNumberFormatterCurrencyDecimalSeparator);
+ return getNumberSymbolChar(env, jlangtag, monetaryDecimalSeparator, kCFNumberFormatterCurrencyDecimalSeparator);
}
/*
@@ -392,7 +392,7 @@
*/
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNaN
(JNIEnv *env, jclass cls, jstring jlangtag, jstring nan) {
- return getNumberSymbolString(env, nan, kCFNumberFormatterNaNSymbol);
+ return getNumberSymbolString(env, jlangtag, nan, kCFNumberFormatterNaNSymbol);
}
/*
@@ -402,7 +402,7 @@
*/
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPercent
(JNIEnv *env, jclass cls, jstring jlangtag, jchar percent) {
- return getNumberSymbolChar(percent, kCFNumberFormatterPercentSymbol);
+ return getNumberSymbolChar(env, jlangtag, percent, kCFNumberFormatterPercentSymbol);
}
/*
@@ -412,7 +412,7 @@
*/
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPerMill
(JNIEnv *env, jclass cls, jstring jlangtag, jchar perMill) {
- return getNumberSymbolChar(perMill, kCFNumberFormatterPerMillSymbol);
+ return getNumberSymbolChar(env, jlangtag, perMill, kCFNumberFormatterPerMillSymbol);
}
/*
@@ -422,7 +422,36 @@
*/
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getZeroDigit
(JNIEnv *env, jclass cls, jstring jlangtag, jchar zeroDigit) {
- return getNumberSymbolChar(zeroDigit, kCFNumberFormatterZeroSymbol);
+ // The following code *should* work, but not for some reason :o
+ //
+ //return getNumberSymbolChar(env, jlangtag, zeroDigit, kCFNumberFormatterZeroSymbol);
+ //
+ // so here is a workaround.
+ jchar ret = zeroDigit;
+ CFLocaleRef cflocale = CFLocaleCopyCurrent();
+
+ if (cflocale != NULL) {
+ CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorDefault,
+ cflocale,
+ kCFNumberFormatterNoStyle);
+ if (nf != NULL) {
+ int zero = 0;
+ CFStringRef str = CFNumberFormatterCreateStringWithValue(kCFAllocatorDefault,
+ nf, kCFNumberIntType, &zero);
+ if (str != NULL) {
+ if (CFStringGetLength(str) > 0) {
+ ret = CFStringGetCharacterAtIndex(str, 0);
+ }
+ CFRelease(str);
+ }
+
+ CFRelease(nf);
+ }
+
+ CFRelease(cflocale);
+ }
+
+ return ret;
}
/*
@@ -432,7 +461,7 @@
*/
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getExponentSeparator
(JNIEnv *env, jclass cls, jstring jlangtag, jstring exponent) {
- return getNumberSymbolString(env, exponent, kCFNumberFormatterExponentSymbol);
+ return getNumberSymbolString(env, jlangtag, exponent, kCFNumberFormatterExponentSymbol);
}
/*
@@ -625,7 +654,7 @@
}
}
-static jstring getNumberSymbolString(JNIEnv *env, jstring jdefault, CFStringRef type) {
+static jstring getNumberSymbolString(JNIEnv *env, jstring jlangtag, jstring jdefault, CFStringRef type) {
char buf[BUFLEN];
jstring ret = jdefault;
CFLocaleRef cflocale = CFLocaleCopyCurrent();
@@ -633,7 +662,7 @@
if (cflocale != NULL) {
CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorDefault,
cflocale,
- kCFNumberFormatterDecimalStyle);
+ kCFNumberFormatterNoStyle);
if (nf != NULL) {
CFStringRef str = CFNumberFormatterCopyProperty(nf, type);
if (str != NULL) {
@@ -651,21 +680,21 @@
return ret;
}
-static jchar getNumberSymbolChar(jchar jdefault, CFStringRef type) {
- char buf[BUFLEN];
+static jchar getNumberSymbolChar(JNIEnv *env, jstring jlangtag, jchar jdefault, CFStringRef type) {
jchar ret = jdefault;
CFLocaleRef cflocale = CFLocaleCopyCurrent();
if (cflocale != NULL) {
CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorDefault,
cflocale,
- kCFNumberFormatterDecimalStyle);
+ kCFNumberFormatterNoStyle);
if (nf != NULL) {
CFStringRef str = CFNumberFormatterCopyProperty(nf, type);
if (str != NULL) {
- CFStringGetCString(str, buf, BUFLEN, kCFStringEncodingUTF8);
+ if (CFStringGetLength(str) > 0) {
+ ret = CFStringGetCharacterAtIndex(str, 0);
+ }
CFRelease(str);
- ret = buf[0];
}
CFRelease(nf);
diff --git a/src/share/back/export/sys.h b/src/share/back/export/sys.h
index 4c42ec2..bd4bb9d 100644
--- a/src/share/back/export/sys.h
+++ b/src/share/back/export/sys.h
@@ -37,7 +37,7 @@
/* Implemented in linker_md.c */
-void dbgsysBuildLibName(char *, int, char *, char *);
+void dbgsysBuildLibName(char *, int, const char *, const char *);
void * dbgsysLoadLibrary(const char *, char *err_buf, int err_buflen);
void dbgsysUnloadLibrary(void *);
void * dbgsysFindLibraryEntry(void *, const char *);
diff --git a/src/share/back/transport.c b/src/share/back/transport.c
index 1d7335d..20892e3 100644
--- a/src/share/back/transport.c
+++ b/src/share/back/transport.c
@@ -97,12 +97,12 @@
/* Load transport library (directory=="" means do system search) */
static void *
-loadTransportLibrary(char *libdir, char *name)
+loadTransportLibrary(const char *libdir, const char *name)
{
void *handle;
char libname[MAXPATHLEN+2];
char buf[MAXPATHLEN*2+100];
- char *plibdir;
+ const char *plibdir;
/* Convert libdir from UTF-8 to platform encoding */
plibdir = NULL;
@@ -131,12 +131,12 @@
* JDK 1.2 javai.c v1.61
*/
static jdwpError
-loadTransport(char *name, jdwpTransportEnv **transportPtr)
+loadTransport(const char *name, jdwpTransportEnv **transportPtr)
{
JNIEnv *env;
jdwpTransport_OnLoad_t onLoad;
void *handle;
- char *libdir;
+ const char *libdir;
/* Make sure library name is not empty */
if (name == NULL) {
diff --git a/src/share/classes/com/sun/security/auth/module/JndiLoginModule.java b/src/share/classes/com/sun/security/auth/module/JndiLoginModule.java
index cb68cfc..b6b8660 100644
--- a/src/share/classes/com/sun/security/auth/module/JndiLoginModule.java
+++ b/src/share/classes/com/sun/security/auth/module/JndiLoginModule.java
@@ -32,8 +32,11 @@
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 @@
*/
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";
diff --git a/src/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java b/src/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java
index e5d88cf..70f74d6 100644
--- a/src/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java
+++ b/src/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java
@@ -30,22 +30,11 @@
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 @@
*/
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 -- */
diff --git a/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java b/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
index 719aeee..cd60c6a 100644
--- a/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
+++ b/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
@@ -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 @@
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>.
diff --git a/src/share/classes/com/sun/servicetag/BrowserSupport.java b/src/share/classes/com/sun/servicetag/BrowserSupport.java
deleted file mode 100644
index cfbc832..0000000
--- a/src/share/classes/com/sun/servicetag/BrowserSupport.java
+++ /dev/null
@@ -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
- }
- }
- }
- }
-}
diff --git a/src/share/classes/com/sun/servicetag/Installer.java b/src/share/classes/com/sun/servicetag/Installer.java
deleted file mode 100644
index 35395ab..0000000
--- a/src/share/classes/com/sun/servicetag/Installer.java
+++ /dev/null
@@ -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>
- * <JAVA_HOME>/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");
- }
-}
diff --git a/src/share/classes/com/sun/servicetag/LinuxSystemEnvironment.java b/src/share/classes/com/sun/servicetag/LinuxSystemEnvironment.java
deleted file mode 100644
index 0d5a707..0000000
--- a/src/share/classes/com/sun/servicetag/LinuxSystemEnvironment.java
+++ /dev/null
@@ -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 "";
- }
-
-}
diff --git a/src/share/classes/com/sun/servicetag/RegistrationData.java b/src/share/classes/com/sun/servicetag/RegistrationData.java
deleted file mode 100644
index 1c203f4..0000000
--- a/src/share/classes/com/sun/servicetag/RegistrationData.java
+++ /dev/null
@@ -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(""<JAVA_HOME>/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<ServiceTag> 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:<32-char {@link java.util.UUID uuid}></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.";
- }
- }
-}
diff --git a/src/share/classes/com/sun/servicetag/RegistrationDocument.java b/src/share/classes/com/sun/servicetag/RegistrationDocument.java
deleted file mode 100644
index d6d5520..0000000
--- a/src/share/classes/com/sun/servicetag/RegistrationDocument.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/src/share/classes/com/sun/servicetag/Registry.java b/src/share/classes/com/sun/servicetag/Registry.java
deleted file mode 100644
index a9f3c8d..0000000
--- a/src/share/classes/com/sun/servicetag/Registry.java
+++ /dev/null
@@ -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();
- }
- }
- }
-}
diff --git a/src/share/classes/com/sun/servicetag/ServiceTag.java b/src/share/classes/com/sun/servicetag/ServiceTag.java
deleted file mode 100644
index 4794f8d..0000000
--- a/src/share/classes/com/sun/servicetag/ServiceTag.java
+++ /dev/null
@@ -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);
- }
-
-}
diff --git a/src/share/classes/com/sun/servicetag/SolarisServiceTag.java b/src/share/classes/com/sun/servicetag/SolarisServiceTag.java
deleted file mode 100644
index 6b4ae39..0000000
--- a/src/share/classes/com/sun/servicetag/SolarisServiceTag.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java b/src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java
deleted file mode 100644
index 19cbae0..0000000
--- a/src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java
+++ /dev/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 "";
- }
- }
-
-}
diff --git a/src/share/classes/com/sun/servicetag/SunConnection.java b/src/share/classes/com/sun/servicetag/SunConnection.java
deleted file mode 100644
index f5a13b6..0000000
--- a/src/share/classes/com/sun/servicetag/SunConnection.java
+++ /dev/null
@@ -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();
- }
- }
- }
-}
diff --git a/src/share/classes/com/sun/servicetag/SystemEnvironment.java b/src/share/classes/com/sun/servicetag/SystemEnvironment.java
deleted file mode 100644
index d1ec3fe..0000000
--- a/src/share/classes/com/sun/servicetag/SystemEnvironment.java
+++ /dev/null
@@ -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
- }
- }
- }
- }
-}
diff --git a/src/share/classes/com/sun/servicetag/Util.java b/src/share/classes/com/sun/servicetag/Util.java
deleted file mode 100644
index 055edfa..0000000
--- a/src/share/classes/com/sun/servicetag/Util.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/src/share/classes/com/sun/servicetag/WindowsSystemEnvironment.java b/src/share/classes/com/sun/servicetag/WindowsSystemEnvironment.java
deleted file mode 100644
index 3203926..0000000
--- a/src/share/classes/com/sun/servicetag/WindowsSystemEnvironment.java
+++ /dev/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();
- }
-}
diff --git a/src/share/classes/com/sun/servicetag/package.html b/src/share/classes/com/sun/servicetag/package.html
deleted file mode 100644
index 8c7c90a..0000000
--- a/src/share/classes/com/sun/servicetag/package.html
+++ /dev/null
@@ -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>
-
-
diff --git a/src/share/classes/com/sun/servicetag/resources/Putback-Notes.txt b/src/share/classes/com/sun/servicetag/resources/Putback-Notes.txt
deleted file mode 100644
index 70e8cff..0000000
--- a/src/share/classes/com/sun/servicetag/resources/Putback-Notes.txt
+++ /dev/null
@@ -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.
diff --git a/src/share/classes/com/sun/servicetag/resources/javase_5_swordfish.properties b/src/share/classes/com/sun/servicetag/resources/javase_5_swordfish.properties
deleted file mode 100644
index 2d7ee83..0000000
--- a/src/share/classes/com/sun/servicetag/resources/javase_5_swordfish.properties
+++ /dev/null
@@ -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
diff --git a/src/share/classes/com/sun/servicetag/resources/javase_6_swordfish.properties b/src/share/classes/com/sun/servicetag/resources/javase_6_swordfish.properties
deleted file mode 100644
index 1365715..0000000
--- a/src/share/classes/com/sun/servicetag/resources/javase_6_swordfish.properties
+++ /dev/null
@@ -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)
diff --git a/src/share/classes/com/sun/servicetag/resources/javase_7_swordfish.properties b/src/share/classes/com/sun/servicetag/resources/javase_7_swordfish.properties
deleted file mode 100644
index 97c5ef8..0000000
--- a/src/share/classes/com/sun/servicetag/resources/javase_7_swordfish.properties
+++ /dev/null
@@ -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)
diff --git a/src/share/classes/com/sun/servicetag/resources/javase_servicetag.properties b/src/share/classes/com/sun/servicetag/resources/javase_servicetag.properties
deleted file mode 100644
index 7ff81b2..0000000
--- a/src/share/classes/com/sun/servicetag/resources/javase_servicetag.properties
+++ /dev/null
@@ -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
diff --git a/src/share/classes/com/sun/servicetag/resources/jdk_header.png b/src/share/classes/com/sun/servicetag/resources/jdk_header.png
deleted file mode 100644
index ccfe6da..0000000
--- a/src/share/classes/com/sun/servicetag/resources/jdk_header.png
+++ /dev/null
Binary files differ
diff --git a/src/share/classes/com/sun/servicetag/resources/product_registration.xsd b/src/share/classes/com/sun/servicetag/resources/product_registration.xsd
deleted file mode 100644
index 43d2745..0000000
--- a/src/share/classes/com/sun/servicetag/resources/product_registration.xsd
+++ /dev/null
@@ -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>
diff --git a/src/share/classes/com/sun/servicetag/resources/register.html b/src/share/classes/com/sun/servicetag/resources/register.html
deleted file mode 100644
index d1bf235..0000000
--- a/src/share/classes/com/sun/servicetag/resources/register.html
+++ /dev/null
@@ -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"> </td>
- <td width="794" align="left" valign="top">
- <img src="@@JDK_HEADER_PNG@@" width="783" height="63"></td>
- </tr>
- <tr>
- <td> </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> </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> </td>
- <td> </td>
- </tr>
- <tr>
- <td> </td>
- <td> </td>
- </tr>
-</table>
-</body>
-</html>
diff --git a/src/share/classes/com/sun/servicetag/resources/register_ja.html b/src/share/classes/com/sun/servicetag/resources/register_ja.html
deleted file mode 100644
index c49c313..0000000
--- a/src/share/classes/com/sun/servicetag/resources/register_ja.html
+++ /dev/null
@@ -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"> </td>
- <td align="left" valign="top" width="794"><img src="@@JDK_HEADER_PNG@@" height="63" width="783"></td>
- </tr>
- <tr>
- <td> </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> </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> </td>
- <td> </td>
- </tr>
- <tr>
- <td> </td>
- <td> </td>
- </tr>
-</table>
-</body>
-</html>
diff --git a/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html b/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html
deleted file mode 100644
index bff0f69..0000000
--- a/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html
+++ /dev/null
@@ -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"> </td>
- <td align="left" valign="top" width="794"><img src="@@JDK_HEADER_PNG@@" height="63" width="783"></td>
- </tr>
-
- <tr>
- <td> </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> </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> </td>
- <td> </td>
- </tr>
- <tr>
- <td> </td>
- <td> </td>
- </tr>
-</table>
-</body>
-</html>
diff --git a/src/share/classes/com/sun/tools/script/shell/init.js b/src/share/classes/com/sun/tools/script/shell/init.js
index 35256fa..5f294b4 100644
--- a/src/share/classes/com/sun/tools/script/shell/init.js
+++ b/src/share/classes/com/sun/tools/script/shell/init.js
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, 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
@@ -28,7 +28,7 @@
*/
/**
- * Creates an object that delegates all method calls on
+ * Creates an object that delegates all method calls on
* it to the 'invoke' method on the given delegate object.<br>
*
* Example:
@@ -43,13 +43,13 @@
* @constructor
*/
function JSInvoker(obj) {
- return new JSAdapter({
- __get__ : function(name) {
- return function() {
- return obj.invoke(name, arguments);
- }
- }
- });
+ return new JSAdapter({
+ __get__ : function(name) {
+ return function() {
+ return obj.invoke(name, arguments);
+ }
+ }
+ });
}
/**
@@ -58,24 +58,24 @@
* example, env.PATH will return PATH value configured.
*/
var env = new JSAdapter({
- __get__ : function (name) {
- return java.lang.System.getenv(name);
- },
- __has__ : function (name) {
- return java.lang.System.getenv().containsKey(name);
- },
- __getIds__ : function() {
- return java.lang.System.getenv().keySet().toArray();
- },
- __delete__ : function(name) {
- println("can't delete env item");
- },
- __put__ : function (name, value) {
- println("can't change env item");
- },
- toString: function() {
- return java.lang.System.getenv().toString();
- }
+ __get__ : function (name) {
+ return java.lang.System.getenv(name);
+ },
+ __has__ : function (name) {
+ return java.lang.System.getenv().containsKey(name);
+ },
+ __getIds__ : function() {
+ return java.lang.System.getenv().keySet().toArray();
+ },
+ __delete__ : function(name) {
+ println("can't delete env item");
+ },
+ __put__ : function (name, value) {
+ println("can't change env item");
+ },
+ toString: function() {
+ return java.lang.System.getenv().toString();
+ }
});
/**
@@ -91,36 +91,36 @@
* delete y['java.class.path']; // remove java.class.path System property
* </code>
* </pre>
- *
+ *
* @param map java.util.Map instance that will be wrapped
* @constructor
*/
-function jmap(map) {
- return new JSAdapter({
- __get__ : function(name) {
- if (map.containsKey(name)) {
- return map.get(name);
- } else {
- return undefined;
- }
- },
- __has__ : function(name) {
- return map.containsKey(name);
- },
+function jmap(map) {
+ return new JSAdapter({
+ __get__ : function(name) {
+ if (map.containsKey(name)) {
+ return map.get(name);
+ } else {
+ return undefined;
+ }
+ },
+ __has__ : function(name) {
+ return map.containsKey(name);
+ },
- __delete__ : function (name) {
- return map.remove(name);
- },
- __put__ : function(name, value) {
- map.put(name, value);
- },
- __getIds__ : function() {
- return map.keySet().toArray();
- },
- toString: function() {
- return map.toString();
- }
- });
+ __delete__ : function (name) {
+ return map.remove(name);
+ },
+ __put__ : function(name, value) {
+ map.put(name, value);
+ },
+ __getIds__ : function() {
+ return map.keySet().toArray();
+ },
+ toString: function() {
+ return map.toString();
+ }
+ });
}
/**
@@ -146,52 +146,72 @@
* @constructor
*/
function jlist(list) {
- function isValid(index) {
- return typeof(index) == 'number' &&
- index > -1 && index < list.size();
- }
- return new JSAdapter({
- __get__ : function(name) {
- if (isValid(name)) {
- return list.get(name);
- } else if (name == 'length') {
- return list.size();
- } else {
- return undefined;
- }
- },
- __has__ : function (name) {
- return isValid(name) || name == 'length';
- },
- __delete__ : function(name) {
- if (isValid(name)) {
- list.remove(name);
- }
- },
- __put__ : function(name, value) {
- if (isValid(name)) {
- list.set(name, value);
- }
- },
- __getIds__: function() {
- var res = new Array(list.size());
- for (var i = 0; i < res.length; i++) {
- res[i] = i;
- }
- return res;
- },
- toString: function() {
- return list.toString();
- }
- });
+ function isValid(index) {
+ return typeof(index) == 'number' &&
+ index > -1 && index < list.size();
+ }
+ return new JSAdapter({
+ __get__ : function(name) {
+ if (isValid(name)) {
+ return list.get(name);
+ } else if (name == 'length') {
+ return list.size();
+ } else {
+ return undefined;
+ }
+ },
+ __has__ : function (name) {
+ return isValid(name) || name == 'length';
+ },
+ __delete__ : function(name) {
+ if (isValid(name)) {
+ list.remove(name);
+ }
+ },
+ __put__ : function(name, value) {
+ if (isValid(name)) {
+ list.set(name, value);
+ }
+ },
+ __getIds__: function() {
+ var res = new Array(list.size());
+ for (var i = 0; i < res.length; i++) {
+ res[i] = i;
+ }
+ return res;
+ },
+ toString: function() {
+ return list.toString();
+ }
+ });
}
/**
- * This is java.lang.System properties wrapped by jmap.
+ * This is java.lang.System properties wrapped by JSAdapter.
* For eg. to access java.class.path property, you can use
* the syntax sysProps["java.class.path"]
*/
-var sysProps = jmap(java.lang.System.getProperties());
+var sysProps = new JSAdapter({
+ __get__ : function (name) {
+ return java.lang.System.getProperty(name);
+ },
+ __has__ : function (name) {
+ return java.lang.System.getProperty(name) != null;
+ },
+ __getIds__ : function() {
+ return java.lang.System.getProperties().keySet().toArray();
+ },
+ __delete__ : function(name) {
+ java.lang.System.clearProperty(name);
+ return true;
+ },
+ __put__ : function (name, value) {
+ java.lang.System.setProperty(name, value);
+ },
+ toString: function() {
+ return "<system properties>";
+ }
+});
// stdout, stderr & stdin
var out = java.lang.System.out;
@@ -199,76 +219,85 @@
// can't use 'in' because it is a JavaScript keyword :-(
var inp = java.lang.System["in"];
-// useful imports for often used io, net classes
-importPackage(java.io);
-importPackage(java.net);
+var BufferedInputStream = java.io.BufferedInputStream;
+var BufferedOutputStream = java.io.BufferedOutputStream;
+var BufferedReader = java.io.BufferedReader;
+var DataInputStream = java.io.DataInputStream;
+var File = java.io.File;
+var FileInputStream = java.io.FileInputStream;
+var FileOutputStream = java.io.FileOutputStream;
+var InputStream = java.io.InputStream;
+var InputStreamReader = java.io.InputStreamReader;
+var OutputStream = java.io.OutputStream;
+var Reader = java.io.Reader;
+var URL = java.net.URL;
/**
* Generic any object to input stream mapper
- * @param str input file name, URL or InputStream
+ * @param str input file name, URL or InputStream
* @return InputStream object
* @private
*/
function inStream(str) {
- if (typeof(str) == "string") {
- // '-' means standard input
- if (str == '-') {
- return java.lang.System["in"];
- }
- // try file first
- var file = null;
- try {
- file = pathToFile(str);
- } catch (e) {
- }
- if (file && file.exists()) {
- return new FileInputStream(file);
- } else {
- try {
- // treat the string as URL
- return new URL(str).openStream();
- } catch (e) {
- throw 'file or URL ' + str + ' not found';
- }
- }
- } else {
- if (str instanceof InputStream) {
- return str;
- } else if (str instanceof URL) {
- return str.openStream();
- } else if (str instanceof File) {
- return new FileInputStream(str);
- }
- }
- // everything failed, just give input stream
- return java.lang.System["in"];
+ if (typeof(str) == "string") {
+ // '-' means standard input
+ if (str == '-') {
+ return java.lang.System["in"];
+ }
+ // try file first
+ var file = null;
+ try {
+ file = pathToFile(str);
+ } catch (e) {
+ }
+ if (file && file.exists()) {
+ return new FileInputStream(file);
+ } else {
+ try {
+ // treat the string as URL
+ return new URL(str).openStream();
+ } catch (e) {
+ throw 'file or URL ' + str + ' not found';
+ }
+ }
+ } else {
+ if (str instanceof InputStream) {
+ return str;
+ } else if (str instanceof URL) {
+ return str.openStream();
+ } else if (str instanceof File) {
+ return new FileInputStream(str);
+ }
+ }
+ // everything failed, just give input stream
+ return java.lang.System["in"];
}
/**
* Generic any object to output stream mapper
- *
+ *
* @param out output file name or stream
* @return OutputStream object
* @private
*/
function outStream(out) {
- if (typeof(out) == "string") {
- if (out == '>') {
- return java.lang.System.out;
- } else {
- // treat it as file
- return new FileOutputStream(pathToFile(out));
- }
- } else {
- if (out instanceof OutputStream) {
- return out;
- } else if (out instanceof File) {
- return new FileOutputStream(out);
- }
- }
+ if (typeof(out) == "string") {
+ if (out == '>') {
+ return java.lang.System.out;
+ } else {
+ // treat it as file
+ return new FileOutputStream(pathToFile(out));
+ }
+ } else {
+ if (out instanceof OutputStream) {
+ return out;
+ } else if (out instanceof File) {
+ return new FileOutputStream(out);
+ }
+ }
- // everything failed, just return System.out
- return java.lang.System.out;
+ // everything failed, just return System.out
+ return java.lang.System.out;
}
/**
@@ -276,17 +305,17 @@
* @private
*/
function streamClose(stream) {
- if (stream) {
- if (stream != java.lang.System["in"] &&
- stream != java.lang.System.out &&
- stream != java.lang.System.err) {
- try {
- stream.close();
- } catch (e) {
- println(e);
- }
- }
- }
+ if (stream) {
+ if (stream != java.lang.System["in"] &&
+ stream != java.lang.System.out &&
+ stream != java.lang.System.err) {
+ try {
+ stream.close();
+ } catch (e) {
+ println(e);
+ }
+ }
+ }
}
/**
@@ -302,18 +331,20 @@
*
* @param str input from which script is loaded and evaluated
*/
-function load(str) {
- var stream = inStream(str);
- var bstream = new BufferedInputStream(stream);
- var reader = new BufferedReader(new InputStreamReader(bstream));
- var oldFilename = engine.get(engine.FILENAME);
- engine.put(engine.FILENAME, str);
- try {
- engine.eval(reader);
- } finally {
- engine.put(engine.FILENAME, oldFilename);
- streamClose(stream);
- }
+if (typeof(load) == 'undefined') {
+ var load = function(str) {
+ var stream = inStream(str);
+ var bstream = new BufferedInputStream(stream);
+ var reader = new BufferedReader(new InputStreamReader(bstream));
+ var oldFilename = engine.get(engine.FILENAME);
+ engine.put(engine.FILENAME, str);
+ try {
+ engine.eval(reader);
+ } finally {
+ engine.put(engine.FILENAME, oldFilename);
+ streamClose(stream);
+ }
+ }
}
// file system utilities
@@ -324,7 +355,7 @@
* @private
*/
function javaByteArray(len) {
- return java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, len);
+ return java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, len);
}
var curDir = new File('.');
@@ -333,7 +364,7 @@
* Print present working directory
*/
function pwd() {
- println(curDir.getAbsolutePath());
+ println(curDir.getAbsolutePath());
}
/**
@@ -341,17 +372,17 @@
* @param target directory to change to. optional, defaults to user's HOME
*/
function cd(target) {
- if (target == undefined) {
- target = sysProps["user.home"];
- }
- if (!(target instanceof File)) {
- target = pathToFile(target);
- }
- if (target.exists() && target.isDirectory()) {
- curDir = target;
- } else {
- println(target + " is not a directory");
- }
+ if (target == undefined) {
+ target = sysProps["user.home"];
+ }
+ if (!(target instanceof File)) {
+ target = pathToFile(target);
+ }
+ if (target.exists() && target.isDirectory()) {
+ curDir = target;
+ } else {
+ println(target + " is not a directory");
+ }
}
/**
@@ -361,15 +392,15 @@
* @private
*/
function pathToFile(pathname) {
- var tmp = pathname;
- if (!(tmp instanceof File)) {
- tmp = new File(tmp);
- }
- if (!tmp.isAbsolute()) {
- return new File(curDir, pathname);
- } else {
- return tmp;
- }
+ var tmp = pathname;
+ if (!(tmp instanceof File)) {
+ tmp = new File(tmp);
+ }
+ if (!tmp.isAbsolute()) {
+ return new File(curDir, pathname);
+ } else {
+ return tmp;
+ }
}
/**
@@ -379,22 +410,22 @@
* @param to output stream or file
*/
function cp(from, to) {
- if (from == to) {
- println("file " + from + " cannot be copied onto itself!");
- return;
- }
- var inp = inStream(from);
- var out = outStream(to);
- var binp = new BufferedInputStream(inp);
- var bout = new BufferedOutputStream(out);
- var buff = javaByteArray(1024);
- var len;
- while ((len = binp.read(buff)) > 0 )
- bout.write(buff, 0, len);
+ if (from == to) {
+ println("file " + from + " cannot be copied onto itself!");
+ return;
+ }
+ var inp = inStream(from);
+ var out = outStream(to);
+ var binp = new BufferedInputStream(inp);
+ var bout = new BufferedOutputStream(out);
+ var buff = javaByteArray(1024);
+ var len;
+ while ((len = binp.read(buff)) > 0 )
+ bout.write(buff, 0, len);
- bout.flush();
- streamClose(inp);
- streamClose(out);
+ bout.flush();
+ streamClose(inp);
+ streamClose(out);
}
/**
@@ -403,37 +434,37 @@
* <pre>
* <code>
* cat('test.txt'); // show test.txt file contents
- * cat('http://java.net'); // show the contents from the URL http://java.net
+ * cat('http://java.net'); // show the contents from the URL http://java.net
* </code>
* </pre>
* @param obj input to show
* @param pattern optional. show only the lines matching the pattern
*/
function cat(obj, pattern) {
- if (obj instanceof File && obj.isDirectory()) {
- ls(obj);
- return;
- }
-
- var inp = null;
- if (!(obj instanceof Reader)) {
- inp = inStream(obj);
- obj = new BufferedReader(new InputStreamReader(inp));
- }
- var line;
- if (pattern) {
- var count = 1;
- while ((line=obj.readLine()) != null) {
- if (line.match(pattern)) {
- println(count + "\t: " + line);
- }
- count++;
- }
- } else {
- while ((line=obj.readLine()) != null) {
- println(line);
- }
- }
+ if (obj instanceof File && obj.isDirectory()) {
+ ls(obj);
+ return;
+ }
+
+ var inp = null;
+ if (!(obj instanceof Reader)) {
+ inp = inStream(obj);
+ obj = new BufferedReader(new InputStreamReader(inp));
+ }
+ var line;
+ if (pattern) {
+ var count = 1;
+ while ((line=obj.readLine()) != null) {
+ if (line.match(pattern)) {
+ println(count + "\t: " + line);
+ }
+ count++;
+ }
+ } else {
+ while ((line=obj.readLine()) != null) {
+ println(line);
+ }
+ }
}
/**
@@ -443,13 +474,13 @@
* @return directory part of the given file name
*/
function dirname(pathname) {
- var dirName = ".";
- // Normalize '/' to local file separator before work.
- var i = pathname.replace('/', File.separatorChar ).lastIndexOf(
- File.separator );
- if ( i != -1 )
- dirName = pathname.substring(0, i);
- return dirName;
+ var dirName = ".";
+ // Normalize '/' to local file separator before work.
+ var i = pathname.replace('/', File.separatorChar ).lastIndexOf(
+ File.separator );
+ if ( i != -1 )
+ dirName = pathname.substring(0, i);
+ return dirName;
}
/**
@@ -458,34 +489,34 @@
* @param dir name of the new directory
*/
function mkdir(dir) {
- var dir = pathToFile(dir);
- println(dir.mkdir()? "created" : "can not create dir");
+ dir = pathToFile(dir);
+ println(dir.mkdir()? "created" : "can not create dir");
}
/**
- * Creates the directory named by given pathname, including
+ * Creates the directory named by given pathname, including
* any necessary but nonexistent parent directories.
*
* @param dir input path name
*/
function mkdirs(dir) {
- var dir = pathToFile(dir);
- println(dir.mkdirs()? "created" : "can not create dirs");
+ dir = pathToFile(dir);
+ println(dir.mkdirs()? "created" : "can not create dirs");
}
-
+
/**
- * Removes a given file
+ * Removes a given file
*
- * @param pathname name of the file
+ * @param pathname name of the file
*/
function rm(pathname) {
- file = pathToFile(pathname);
- if (!file.exists()) {
- println("file not found: " + pathname);
- return false;
- }
- // note that delete is a keyword in JavaScript!
- println(file["delete"]()? "deleted" : "can not delete");
+ var file = pathToFile(pathname);
+ if (!file.exists()) {
+ println("file not found: " + pathname);
+ return false;
+ }
+ // note that delete is a keyword in JavaScript!
+ println(file["delete"]()? "deleted" : "can not delete");
}
/**
@@ -494,14 +525,14 @@
* @param pathname name of the directory
*/
function rmdir(pathname) {
- rm(pathname);
+ rm(pathname);
}
/**
* Synonym for 'rm'
*/
function del(pathname) {
- rm(pathname);
+ rm(pathname);
}
/**
@@ -511,62 +542,62 @@
* @param to new name for the file
*/
function mv(from, to) {
- println(pathToFile(from).renameTo(pathToFile(to))?
- "moved" : "can not move");
+ println(pathToFile(from).renameTo(pathToFile(to))?
+ "moved" : "can not move");
}
/**
* Synonym for 'mv'.
*/
function ren(from, to) {
- mv(from, to);
+ mv(from, to);
}
-var months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
+var months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
/**
* Helper function called by ls
* @private
- */
+ */
function printFile(f) {
- var sb = new java.lang.StringBuffer();
- sb.append(f.isDirectory()? "d" : "-");
- sb.append(f.canRead() ? "r": "-" );
- sb.append(f.canWrite() ? "w": "-" );
- sb.append(" ");
+ var sb = new java.lang.StringBuffer();
+ sb.append(f.isDirectory()? "d" : "-");
+ sb.append(f.canRead() ? "r": "-" );
+ sb.append(f.canWrite() ? "w": "-" );
+ sb.append(" ");
- var d = new java.util.Date(f.lastModified());
- var c = new java.util.GregorianCalendar();
- c.setTime(d);
- var day = c.get(java.util.Calendar.DAY_OF_MONTH);
- sb.append(months[c.get(java.util.Calendar.MONTH)]
- + " " + day );
- if (day < 10) {
- sb.append(" ");
- }
+ var d = new java.util.Date(f.lastModified());
+ var c = new java.util.GregorianCalendar();
+ c.setTime(d);
+ var day = c.get(java.util.Calendar.DAY_OF_MONTH);
+ sb.append(months[c.get(java.util.Calendar.MONTH)]
+ + " " + day );
+ if (day < 10) {
+ sb.append(" ");
+ }
- // to get fixed length 'length' field
- var fieldlen = 8;
- var len = new java.lang.StringBuffer();
- for(var j=0; j<fieldlen; j++)
- len.append(" ");
- len.insert(0, java.lang.Long.toString(f.length()));
- len.setLength(fieldlen);
- // move the spaces to the front
- var si = len.toString().indexOf(" ");
- if ( si != -1 ) {
- var pad = len.toString().substring(si);
- len.setLength(si);
- len.insert(0, pad);
- }
- sb.append(len.toString());
- sb.append(" ");
- sb.append(f.getName());
- if (f.isDirectory()) {
- sb.append('/');
- }
- println(sb.toString());
+ // to get fixed length 'length' field
+ var fieldlen = 8;
+ var len = new java.lang.StringBuffer();
+ for(var j=0; j<fieldlen; j++)
+ len.append(" ");
+ len.insert(0, java.lang.Long.toString(f.length()));
+ len.setLength(fieldlen);
+ // move the spaces to the front
+ var si = len.toString().indexOf(" ");
+ if ( si != -1 ) {
+ var pad = len.toString().substring(si);
+ len.setLength(si);
+ len.insert(0, pad);
+ }
+ sb.append(len.toString());
+ sb.append(" ");
+ sb.append(f.getName());
+ if (f.isDirectory()) {
+ sb.append('/');
+ }
+ println(sb.toString());
}
/**
@@ -576,32 +607,32 @@
* @param filter pattern to filter the files listed. optional, default is '.'.
*/
function ls(dir, filter) {
- if (dir) {
- dir = pathToFile(dir);
- } else {
- dir = curDir;
- }
- if (dir.isDirectory()) {
- var files = dir.listFiles();
- for (var i in files) {
- var f = files[i];
- if (filter) {
- if(!f.getName().match(filter)) {
- continue;
- }
- }
- printFile(f);
- }
- } else {
- printFile(dir);
- }
+ if (dir) {
+ dir = pathToFile(dir);
+ } else {
+ dir = curDir;
+ }
+ if (dir.isDirectory()) {
+ var files = dir.listFiles();
+ for (var i in files) {
+ var f = files[i];
+ if (filter) {
+ if(!f.getName().match(filter)) {
+ continue;
+ }
+ }
+ printFile(f);
+ }
+ } else {
+ printFile(dir);
+ }
}
/**
* Synonym for 'ls'.
*/
function dir(d, filter) {
- ls(d, filter);
+ ls(d, filter);
}
/**
@@ -611,24 +642,24 @@
* @param files one or more files
*/
function grep(pattern, files /*, one or more files */) {
- if (arguments.length < 2) return;
- for (var i = 1; i < arguments.length; i++) {
- println(arguments[i] + ":");
- cat(arguments[i], pattern);
- }
+ if (arguments.length < 2) return;
+ for (var i = 1; i < arguments.length; i++) {
+ println(arguments[i] + ":");
+ cat(arguments[i], pattern);
+ }
}
/**
* Find in files. Calls arbitrary callback function
* for each matching file.<br>
*
- * Examples:
+ * Examples:
* <pre>
* <code>
- * find('.')
- * find('.', '.*\.class', rm); // remove all .class files
- * find('.', '.*\.java'); // print fullpath of each .java file
- * find('.', '.*\.java', cat); // print all .java files
+ * find('.')
+ * find('.', '.*\.class', rm); // remove all .class files
+ * find('.', '.*\.java'); // print fullpath of each .java file
+ * find('.', '.*\.java', cat); // print all .java files
* </code>
* </pre>
*
@@ -637,23 +668,23 @@
* @param callback function to call for matching files
*/
function find(dir, pattern, callback) {
- dir = pathToFile(dir);
- if (!callback) callback = print;
- var files = dir.listFiles();
- for (var f in files) {
- var file = files[f];
- if (file.isDirectory()) {
- find(file, pattern, callback);
- } else {
- if (pattern) {
- if (file.getName().match(pattern)) {
- callback(file);
- }
- } else {
- callback(file);
- }
- }
- }
+ dir = pathToFile(dir);
+ if (!callback) callback = print;
+ var files = dir.listFiles();
+ for (var f in files) {
+ var file = files[f];
+ if (file.isDirectory()) {
+ find(file, pattern, callback);
+ } else {
+ if (pattern) {
+ if (file.getName().match(pattern)) {
+ callback(file);
+ }
+ } else {
+ callback(file);
+ }
+ }
+ }
}
// process utilities
@@ -664,40 +695,44 @@
* @param cmd command to execute in child process
*/
function exec(cmd) {
- var process = java.lang.Runtime.getRuntime().exec(cmd);
- var inp = new DataInputStream(process.getInputStream());
- var line = null;
- while ((line = inp.readLine()) != null) {
- println(line);
- }
- process.waitFor();
- $exit = process.exitValue();
+ var process = java.lang.Runtime.getRuntime().exec(cmd);
+ var inp = new DataInputStream(process.getInputStream());
+ var line = null;
+ while ((line = inp.readLine()) != null) {
+ println(line);
+ }
+ process.waitFor();
+ $exit = process.exitValue();
}
-/**
- * Exit the shell program.
- *
- * @param exitCode integer code returned to OS shell.
- * optional, defaults to 0
- */
-function exit(code) {
- if (code) {
- java.lang.System.exit(code + 0);
- } else {
- java.lang.System.exit(0);
- }
+if (typeof(exit) == 'undefined') {
+ /**
+ * Exit the shell program.
+ *
+ * @param exitCode integer code returned to OS shell.
+ * optional, defaults to 0
+ */
+ var exit = function (code) {
+ if (code) {
+ java.lang.System.exit(code + 0);
+ } else {
+ java.lang.System.exit(0);
+ }
+ }
}
-/**
- * synonym for exit
- */
-function quit(code) {
- exit(code);
+if (typeof(quit) == 'undefined') {
+ /**
+ * synonym for exit
+ */
+ var quit = function (code) {
+ exit(code);
+ }
}
// XML utilities
-/**
+/**
* Converts input to DOM Document object
*
* @param inp file or reader. optional, without this param,
@@ -705,17 +740,17 @@
* @return returns a DOM Document object
*/
function XMLDocument(inp) {
- var factory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
- var builder = factory.newDocumentBuilder();
- if (inp) {
- if (typeof(inp) == "string") {
- return builder.parse(pathToFile(inp));
- } else {
- return builder.parse(inp);
- }
- } else {
- return builder.newDocument();
- }
+ var factory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
+ var builder = factory.newDocumentBuilder();
+ if (inp) {
+ if (typeof(inp) == "string") {
+ return builder.parse(pathToFile(inp));
+ } else {
+ return builder.parse(inp);
+ }
+ } else {
+ return builder.newDocument();
+ }
}
/**
@@ -725,14 +760,14 @@
* @return XMLSource object
*/
function XMLSource(inp) {
- if (inp instanceof javax.xml.transform.Source) {
- return inp;
- } else if (inp instanceof Packages.org.w3c.dom.Document) {
- return new javax.xml.transform.dom.DOMSource(inp);
- } else {
- inp = new BufferedInputStream(inStream(inp));
- return new javax.xml.transform.stream.StreamSource(inp);
- }
+ if (inp instanceof javax.xml.transform.Source) {
+ return inp;
+ } else if (inp instanceof Packages.org.w3c.dom.Document) {
+ return new javax.xml.transform.dom.DOMSource(inp);
+ } else {
+ inp = new BufferedInputStream(inStream(inp));
+ return new javax.xml.transform.stream.StreamSource(inp);
+ }
}
/**
@@ -742,73 +777,73 @@
* @return XMLResult object
*/
function XMLResult(out) {
- if (out instanceof javax.xml.transform.Result) {
- return out;
- } else if (out instanceof Packages.org.w3c.dom.Document) {
- return new javax.xml.transform.dom.DOMResult(out);
- } else {
- out = new BufferedOutputStream(outStream(out));
- return new javax.xml.transform.stream.StreamResult(out);
- }
+ if (out instanceof javax.xml.transform.Result) {
+ return out;
+ } else if (out instanceof Packages.org.w3c.dom.Document) {
+ return new javax.xml.transform.dom.DOMResult(out);
+ } else {
+ out = new BufferedOutputStream(outStream(out));
+ return new javax.xml.transform.stream.StreamResult(out);
+ }
}
/**
- * Perform XSLT transform
+ * Perform XSLT transform
*
* @param inp Input XML to transform (URL, File or InputStream)
* @param style XSL Stylesheet to be used (URL, File or InputStream). optional.
* @param out Output XML (File or OutputStream
*/
function XSLTransform(inp, style, out) {
- switch (arguments.length) {
- case 2:
- inp = arguments[0];
- out = arguments[1];
- break;
- case 3:
- inp = arguments[0];
- style = arguments[1];
- out = arguments[2];
- break;
- default:
- println("XSL tranform requires 2 or 3 arguments");
- return;
- }
+ switch (arguments.length) {
+ case 2:
+ inp = arguments[0];
+ out = arguments[1];
+ break;
+ case 3:
+ inp = arguments[0];
+ style = arguments[1];
+ out = arguments[2];
+ break;
+ default:
+ println("XSL tranform requires 2 or 3 arguments");
+ return;
+ }
- var factory = javax.xml.transform.TransformerFactory.newInstance();
- var tranformer;
- if (style) {
- transformer = factory.newTransformer(XMLSource(style));
- } else {
- transformer = factory.newTransformer();
- }
- var source = XMLSource(inp);
- var result = XMLResult(out);
- transformer.transform(source, result);
- if (source.getInputStream) {
- streamClose(source.getInputStream());
- }
- if (result.getOutputStream) {
- streamClose(result.getOutputStream());
- }
+ var factory = javax.xml.transform.TransformerFactory.newInstance();
+ var transformer;
+ if (style) {
+ transformer = factory.newTransformer(XMLSource(style));
+ } else {
+ transformer = factory.newTransformer();
+ }
+ var source = XMLSource(inp);
+ var result = XMLResult(out);
+ transformer.transform(source, result);
+ if (source.getInputStream) {
+ streamClose(source.getInputStream());
+ }
+ if (result.getOutputStream) {
+ streamClose(result.getOutputStream());
+ }
}
// miscellaneous utilities
/**
- * Prints which command is selected from PATH
+ * Prints which command is selected from PATH
*
* @param cmd name of the command searched from PATH
*/
function which(cmd) {
- var st = new java.util.StringTokenizer(env.PATH, File.pathSeparator);
- while (st.hasMoreTokens()) {
- var file = new File(st.nextToken(), cmd);
- if (file.exists()) {
- println(file.getAbsolutePath());
- return;
- }
- }
+ var st = new java.util.StringTokenizer(env.PATH, File.pathSeparator);
+ while (st.hasMoreTokens()) {
+ var file = new File(st.nextToken(), cmd);
+ if (file.exists()) {
+ println(file.getAbsolutePath());
+ return;
+ }
+ }
}
/**
@@ -817,41 +852,43 @@
* @param name domain name
*/
function ip(name) {
- var addrs = InetAddress.getAllByName(name);
- for (var i in addrs) {
- println(addrs[i]);
- }
+ var addrs = InetAddress.getAllByName(name);
+ for (var i in addrs) {
+ println(addrs[i]);
+ }
}
/**
* Prints current date in current locale
*/
function date() {
- println(new Date().toLocaleString());
+ println(new Date().toLocaleString());
}
/**
* Echoes the given string arguments
*/
function echo(x) {
- for (var i = 0; i < arguments.length; i++) {
- println(arguments[i]);
- }
+ for (var i = 0; i < arguments.length; i++) {
+ println(arguments[i]);
+ }
}
-/**
- * This is C-like printf
- *
- * @param format string to format the rest of the print items
- * @param args variadic argument list
- */
-function printf(format, args/*, more args*/) {
- var array = java.lang.reflect.Array.newInstance(java.lang.Object,
- arguments.length - 1);
- for (var i = 0; i < array.length; i++) {
- array[i] = arguments[i+1];
- }
- return java.lang.System.out.printf(format, array);
+if (typeof(printf) == 'undefined') {
+ /**
+ * This is C-like printf
+ *
+ * @param format string to format the rest of the print items
+ * @param args variadic argument list
+ */
+ var printf = function (format, args/*, more args*/) {
+ var array = java.lang.reflect.Array.newInstance(java.lang.Object,
+ arguments.length - 1);
+ for (var i = 0; i < array.length; i++) {
+ array[i] = arguments[i+1];
+ }
+ java.lang.System.out.printf(format, array);
+ }
}
/**
@@ -861,24 +898,48 @@
* @param multiline to tell whether to read single line or multiple lines
*/
function read(prompt, multiline) {
- if (!prompt) {
- prompt = '>';
- }
- var inp = java.lang.System["in"];
- var reader = new BufferedReader(new InputStreamReader(inp));
- if (multiline) {
- var line = '';
- while (true) {
- java.lang.System.err.print(prompt);
- java.lang.System.err.flush();
- var tmp = reader.readLine();
- if (tmp == '' || tmp == null) break;
- line += tmp + '\n';
- }
- return line;
- } else {
- java.lang.System.err.print(prompt);
- java.lang.System.err.flush();
- return reader.readLine();
- }
+ if (!prompt) {
+ prompt = '>';
+ }
+ var inp = java.lang.System["in"];
+ var reader = new BufferedReader(new InputStreamReader(inp));
+ if (multiline) {
+ var line = '';
+ while (true) {
+ java.lang.System.err.print(prompt);
+ java.lang.System.err.flush();
+ var tmp = reader.readLine();
+ if (tmp == '' || tmp == null) break;
+ line += tmp + '\n';
+ }
+ return line;
+ } else {
+ java.lang.System.err.print(prompt);
+ java.lang.System.err.flush();
+ return reader.readLine();
+ }
+}
+
+if (typeof(println) == 'undefined') {
+ var print = function(str, newline) {
+ if (typeof(str) == 'undefined') {
+ str = 'undefined';
+ } else if (str == null) {
+ str = 'null';
+ }
+
+ if (!(out instanceof java.io.PrintWriter)) {
+ out = new java.io.PrintWriter(out);
+ }
+
+ out.print(String(str));
+ if (newline) {
+ out.print('\n');
+ }
+ out.flush();
+ }
+
+ var println = function(str) {
+ print(str, true);
+ };
}
diff --git a/src/share/classes/java/awt/Adjustable.java b/src/share/classes/java/awt/Adjustable.java
index 53d5152..6193a07 100644
--- a/src/share/classes/java/awt/Adjustable.java
+++ b/src/share/classes/java/awt/Adjustable.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2003, 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
@@ -27,7 +27,7 @@
import java.awt.event.*;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* The interface for objects which have an adjustable numeric value
@@ -36,24 +36,22 @@
* @author Amy Fowler
* @author Tim Prinzing
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public interface Adjustable {
/**
* Indicates that the <code>Adjustable</code> has horizontal orientation.
*/
- public static final int HORIZONTAL = 0;
+ @Native public static final int HORIZONTAL = 0;
/**
* Indicates that the <code>Adjustable</code> has vertical orientation.
*/
- public static final int VERTICAL = 1;
+ @Native public static final int VERTICAL = 1;
/**
* Indicates that the <code>Adjustable</code> has no orientation.
*/
- public static final int NO_ORIENTATION = 2;
+ @Native public static final int NO_ORIENTATION = 2;
/**
* Gets the orientation of the adjustable object.
diff --git a/src/share/classes/java/awt/AlphaComposite.java b/src/share/classes/java/awt/AlphaComposite.java
index 0889642..6903e7e 100644
--- a/src/share/classes/java/awt/AlphaComposite.java
+++ b/src/share/classes/java/awt/AlphaComposite.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, 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
@@ -26,7 +26,7 @@
package java.awt;
import java.awt.image.ColorModel;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
import sun.java2d.SunCompositeContext;
/**
@@ -350,8 +350,6 @@
* @see CompositeContext
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public final class AlphaComposite implements Composite {
/**
* Both the color and the alpha of the destination are cleared
@@ -364,7 +362,7 @@
* <em>C<sub>r</sub></em> = 0
*</pre>
*/
- public static final int CLEAR = 1;
+ @Native public static final int CLEAR = 1;
/**
* The source is copied to the destination
@@ -377,7 +375,7 @@
* <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em>
*</pre>
*/
- public static final int SRC = 2;
+ @Native public static final int SRC = 2;
/**
* The destination is left untouched
@@ -390,7 +388,7 @@
*</pre>
* @since 1.4
*/
- public static final int DST = 9;
+ @Native public static final int DST = 9;
// Note that DST was added in 1.4 so it is numbered out of order...
/**
@@ -403,7 +401,7 @@
* <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em> + <em>C<sub>d</sub></em>*(1-<em>A<sub>s</sub></em>)
*</pre>
*/
- public static final int SRC_OVER = 3;
+ @Native public static final int SRC_OVER = 3;
/**
* The destination is composited over the source and
@@ -416,7 +414,7 @@
* <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em>*(1-<em>A<sub>d</sub></em>) + <em>C<sub>d</sub></em>
*</pre>
*/
- public static final int DST_OVER = 4;
+ @Native public static final int DST_OVER = 4;
/**
* The part of the source lying inside of the destination replaces
@@ -429,7 +427,7 @@
* <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em>*<em>A<sub>d</sub></em>
*</pre>
*/
- public static final int SRC_IN = 5;
+ @Native public static final int SRC_IN = 5;
/**
* The part of the destination lying inside of the source
@@ -442,7 +440,7 @@
* <em>C<sub>r</sub></em> = <em>C<sub>d</sub></em>*<em>A<sub>s</sub></em>
*</pre>
*/
- public static final int DST_IN = 6;
+ @Native public static final int DST_IN = 6;
/**
* The part of the source lying outside of the destination
@@ -455,7 +453,7 @@
* <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em>*(1-<em>A<sub>d</sub></em>)
*</pre>
*/
- public static final int SRC_OUT = 7;
+ @Native public static final int SRC_OUT = 7;
/**
* The part of the destination lying outside of the source
@@ -468,7 +466,7 @@
* <em>C<sub>r</sub></em> = <em>C<sub>d</sub></em>*(1-<em>A<sub>s</sub></em>)
*</pre>
*/
- public static final int DST_OUT = 8;
+ @Native public static final int DST_OUT = 8;
// Rule 9 is DST which is defined above where it fits into the
// list logically, rather than numerically
@@ -487,7 +485,7 @@
*</pre>
* @since 1.4
*/
- public static final int SRC_ATOP = 10;
+ @Native public static final int SRC_ATOP = 10;
/**
* The part of the destination lying inside of the source
@@ -501,7 +499,7 @@
*</pre>
* @since 1.4
*/
- public static final int DST_ATOP = 11;
+ @Native public static final int DST_ATOP = 11;
/**
* The part of the source that lies outside of the destination
@@ -516,7 +514,7 @@
*</pre>
* @since 1.4
*/
- public static final int XOR = 12;
+ @Native public static final int XOR = 12;
/**
* <code>AlphaComposite</code> object that implements the opaque CLEAR rule
@@ -606,8 +604,8 @@
*/
public static final AlphaComposite Xor = new AlphaComposite(XOR);
- private static final int MIN_RULE = CLEAR;
- private static final int MAX_RULE = XOR;
+ @Native private static final int MIN_RULE = CLEAR;
+ @Native private static final int MAX_RULE = XOR;
float extraAlpha;
int rule;
diff --git a/src/share/classes/java/awt/BasicStroke.java b/src/share/classes/java/awt/BasicStroke.java
index 2e5c8de..55d59d4 100644
--- a/src/share/classes/java/awt/BasicStroke.java
+++ b/src/share/classes/java/awt/BasicStroke.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, 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
@@ -27,7 +27,7 @@
import java.beans.ConstructorProperties;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* The <code>BasicStroke</code> class defines a basic set of rendering
@@ -111,47 +111,45 @@
* @see Graphics2D
* @author Jim Graham
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class BasicStroke implements Stroke {
/**
* Joins path segments by extending their outside edges until
* they meet.
*/
- public final static int JOIN_MITER = 0;
+ @Native public final static int JOIN_MITER = 0;
/**
* Joins path segments by rounding off the corner at a radius
* of half the line width.
*/
- public final static int JOIN_ROUND = 1;
+ @Native public final static int JOIN_ROUND = 1;
/**
* Joins path segments by connecting the outer corners of their
* wide outlines with a straight segment.
*/
- public final static int JOIN_BEVEL = 2;
+ @Native public final static int JOIN_BEVEL = 2;
/**
* Ends unclosed subpaths and dash segments with no added
* decoration.
*/
- public final static int CAP_BUTT = 0;
+ @Native public final static int CAP_BUTT = 0;
/**
* Ends unclosed subpaths and dash segments with a round
* decoration that has a radius equal to half of the width
* of the pen.
*/
- public final static int CAP_ROUND = 1;
+ @Native public final static int CAP_ROUND = 1;
/**
* Ends unclosed subpaths and dash segments with a square
* projection that extends beyond the end of the segment
* to a distance equal to half of the line width.
*/
- public final static int CAP_SQUARE = 2;
+ @Native public final static int CAP_SQUARE = 2;
float width;
diff --git a/src/share/classes/java/awt/Choice.java b/src/share/classes/java/awt/Choice.java
index 9ef7658..e026953 100644
--- a/src/share/classes/java/awt/Choice.java
+++ b/src/share/classes/java/awt/Choice.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2008, 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
@@ -34,7 +34,6 @@
import javax.accessibility.*;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* The <code>Choice</code> class presents a pop-up menu of choices.
@@ -71,8 +70,6 @@
* @author Arthur van Hoff
* @since JDK1.0
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class Choice extends Component implements ItemSelectable, Accessible {
/**
* The items for the <code>Choice</code>.
diff --git a/src/share/classes/java/awt/DisplayMode.java b/src/share/classes/java/awt/DisplayMode.java
index a4ca0f1..c4bd095 100644
--- a/src/share/classes/java/awt/DisplayMode.java
+++ b/src/share/classes/java/awt/DisplayMode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2006, 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
@@ -25,7 +25,7 @@
package java.awt;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* The <code>DisplayMode</code> class encapsulates the bit depth, height,
@@ -46,8 +46,6 @@
* @since 1.4
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public final class DisplayMode {
private Dimension size;
@@ -94,7 +92,7 @@
* display mode.
* @see #getBitDepth
*/
- public final static int BIT_DEPTH_MULTI = -1;
+ @Native public final static int BIT_DEPTH_MULTI = -1;
/**
* Returns the bit depth of the display, in bits per pixel. This may be
@@ -112,7 +110,7 @@
* Value of the refresh rate if not known.
* @see #getRefreshRate
*/
- public final static int REFRESH_RATE_UNKNOWN = 0;
+ @Native public final static int REFRESH_RATE_UNKNOWN = 0;
/**
* Returns the refresh rate of the display, in hertz. This may be
diff --git a/src/share/classes/java/awt/Image.java b/src/share/classes/java/awt/Image.java
index 521509d..ce23169 100644
--- a/src/share/classes/java/awt/Image.java
+++ b/src/share/classes/java/awt/Image.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2007, 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
@@ -33,7 +33,6 @@
import sun.awt.image.SurfaceManager;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* The abstract class <code>Image</code> is the superclass of all
@@ -44,8 +43,6 @@
* @author Arthur van Hoff
* @since JDK1.0
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class Image {
/**
diff --git a/src/share/classes/java/awt/List.java b/src/share/classes/java/awt/List.java
index 562f400..92a1867 100644
--- a/src/share/classes/java/awt/List.java
+++ b/src/share/classes/java/awt/List.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2007, 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
@@ -33,7 +33,6 @@
import java.io.ObjectInputStream;
import java.io.IOException;
import javax.accessibility.*;
-import javax.tools.annotation.GenerateNativeHeader;
/**
@@ -107,8 +106,6 @@
* @see java.awt.event.ActionListener
* @since JDK1.0
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class List extends Component implements ItemSelectable, Accessible {
/**
* A vector created to contain items which will become
diff --git a/src/share/classes/java/awt/PopupMenu.java b/src/share/classes/java/awt/PopupMenu.java
index 1c700a1..0e70063 100644
--- a/src/share/classes/java/awt/PopupMenu.java
+++ b/src/share/classes/java/awt/PopupMenu.java
@@ -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
@@ -28,7 +28,6 @@
import java.awt.peer.PopupMenuPeer;
import javax.accessibility.*;
-import javax.tools.annotation.GenerateNativeHeader;
import sun.awt.AWTAccessor;
@@ -44,8 +43,6 @@
*
* @author Amy Fowler
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class PopupMenu extends Menu {
private static final String base = "popup";
diff --git a/src/share/classes/java/awt/SystemColor.java b/src/share/classes/java/awt/SystemColor.java
index a5e2456..931cf32 100644
--- a/src/share/classes/java/awt/SystemColor.java
+++ b/src/share/classes/java/awt/SystemColor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2007, 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
@@ -26,7 +26,7 @@
import java.io.ObjectStreamException;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* A class to encapsulate symbolic colors representing the color of
@@ -49,8 +49,6 @@
* @author Carl Quinn
* @author Amy Fowler
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public final class SystemColor extends Color implements java.io.Serializable {
/**
@@ -58,187 +56,187 @@
* {@link #desktop} system color.
* @see SystemColor#desktop
*/
- public final static int DESKTOP = 0;
+ @Native public final static int DESKTOP = 0;
/**
* The array index for the
* {@link #activeCaption} system color.
* @see SystemColor#activeCaption
*/
- public final static int ACTIVE_CAPTION = 1;
+ @Native public final static int ACTIVE_CAPTION = 1;
/**
* The array index for the
* {@link #activeCaptionText} system color.
* @see SystemColor#activeCaptionText
*/
- public final static int ACTIVE_CAPTION_TEXT = 2;
+ @Native public final static int ACTIVE_CAPTION_TEXT = 2;
/**
* The array index for the
* {@link #activeCaptionBorder} system color.
* @see SystemColor#activeCaptionBorder
*/
- public final static int ACTIVE_CAPTION_BORDER = 3;
+ @Native public final static int ACTIVE_CAPTION_BORDER = 3;
/**
* The array index for the
* {@link #inactiveCaption} system color.
* @see SystemColor#inactiveCaption
*/
- public final static int INACTIVE_CAPTION = 4;
+ @Native public final static int INACTIVE_CAPTION = 4;
/**
* The array index for the
* {@link #inactiveCaptionText} system color.
* @see SystemColor#inactiveCaptionText
*/
- public final static int INACTIVE_CAPTION_TEXT = 5;
+ @Native public final static int INACTIVE_CAPTION_TEXT = 5;
/**
* The array index for the
* {@link #inactiveCaptionBorder} system color.
* @see SystemColor#inactiveCaptionBorder
*/
- public final static int INACTIVE_CAPTION_BORDER = 6;
+ @Native public final static int INACTIVE_CAPTION_BORDER = 6;
/**
* The array index for the
* {@link #window} system color.
* @see SystemColor#window
*/
- public final static int WINDOW = 7;
+ @Native public final static int WINDOW = 7;
/**
* The array index for the
* {@link #windowBorder} system color.
* @see SystemColor#windowBorder
*/
- public final static int WINDOW_BORDER = 8;
+ @Native public final static int WINDOW_BORDER = 8;
/**
* The array index for the
* {@link #windowText} system color.
* @see SystemColor#windowText
*/
- public final static int WINDOW_TEXT = 9;
+ @Native public final static int WINDOW_TEXT = 9;
/**
* The array index for the
* {@link #menu} system color.
* @see SystemColor#menu
*/
- public final static int MENU = 10;
+ @Native public final static int MENU = 10;
/**
* The array index for the
* {@link #menuText} system color.
* @see SystemColor#menuText
*/
- public final static int MENU_TEXT = 11;
+ @Native public final static int MENU_TEXT = 11;
/**
* The array index for the
* {@link #text} system color.
* @see SystemColor#text
*/
- public final static int TEXT = 12;
+ @Native public final static int TEXT = 12;
/**
* The array index for the
* {@link #textText} system color.
* @see SystemColor#textText
*/
- public final static int TEXT_TEXT = 13;
+ @Native public final static int TEXT_TEXT = 13;
/**
* The array index for the
* {@link #textHighlight} system color.
* @see SystemColor#textHighlight
*/
- public final static int TEXT_HIGHLIGHT = 14;
+ @Native public final static int TEXT_HIGHLIGHT = 14;
/**
* The array index for the
* {@link #textHighlightText} system color.
* @see SystemColor#textHighlightText
*/
- public final static int TEXT_HIGHLIGHT_TEXT = 15;
+ @Native public final static int TEXT_HIGHLIGHT_TEXT = 15;
/**
* The array index for the
* {@link #textInactiveText} system color.
* @see SystemColor#textInactiveText
*/
- public final static int TEXT_INACTIVE_TEXT = 16;
+ @Native public final static int TEXT_INACTIVE_TEXT = 16;
/**
* The array index for the
* {@link #control} system color.
* @see SystemColor#control
*/
- public final static int CONTROL = 17;
+ @Native public final static int CONTROL = 17;
/**
* The array index for the
* {@link #controlText} system color.
* @see SystemColor#controlText
*/
- public final static int CONTROL_TEXT = 18;
+ @Native public final static int CONTROL_TEXT = 18;
/**
* The array index for the
* {@link #controlHighlight} system color.
* @see SystemColor#controlHighlight
*/
- public final static int CONTROL_HIGHLIGHT = 19;
+ @Native public final static int CONTROL_HIGHLIGHT = 19;
/**
* The array index for the
* {@link #controlLtHighlight} system color.
* @see SystemColor#controlLtHighlight
*/
- public final static int CONTROL_LT_HIGHLIGHT = 20;
+ @Native public final static int CONTROL_LT_HIGHLIGHT = 20;
/**
* The array index for the
* {@link #controlShadow} system color.
* @see SystemColor#controlShadow
*/
- public final static int CONTROL_SHADOW = 21;
+ @Native public final static int CONTROL_SHADOW = 21;
/**
* The array index for the
* {@link #controlDkShadow} system color.
* @see SystemColor#controlDkShadow
*/
- public final static int CONTROL_DK_SHADOW = 22;
+ @Native public final static int CONTROL_DK_SHADOW = 22;
/**
* The array index for the
* {@link #scrollbar} system color.
* @see SystemColor#scrollbar
*/
- public final static int SCROLLBAR = 23;
+ @Native public final static int SCROLLBAR = 23;
/**
* The array index for the
* {@link #info} system color.
* @see SystemColor#info
*/
- public final static int INFO = 24;
+ @Native public final static int INFO = 24;
/**
* The array index for the
* {@link #infoText} system color.
* @see SystemColor#infoText
*/
- public final static int INFO_TEXT = 25;
+ @Native public final static int INFO_TEXT = 25;
/**
* The number of system colors in the array.
*/
- public final static int NUM_COLORS = 26;
+ @Native public final static int NUM_COLORS = 26;
/******************************************************************************************/
diff --git a/src/share/classes/java/awt/TextComponent.java b/src/share/classes/java/awt/TextComponent.java
index 0a2fe25..7a6cd26 100644
--- a/src/share/classes/java/awt/TextComponent.java
+++ b/src/share/classes/java/awt/TextComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2006, 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
@@ -35,7 +35,6 @@
import javax.swing.text.AttributeSet;
import javax.accessibility.*;
import java.awt.im.InputMethodRequests;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* The <code>TextComponent</code> class is the superclass of
@@ -57,8 +56,6 @@
* @author Arthur van Hoff
* @since JDK1.0
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class TextComponent extends Component implements Accessible {
/**
diff --git a/src/share/classes/java/awt/Transparency.java b/src/share/classes/java/awt/Transparency.java
index e968ebb..2c8f845 100644
--- a/src/share/classes/java/awt/Transparency.java
+++ b/src/share/classes/java/awt/Transparency.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999, 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
@@ -25,34 +25,32 @@
package java.awt;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* The <code>Transparency</code> interface defines the common transparency
* modes for implementing classes.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public interface Transparency {
/**
* Represents image data that is guaranteed to be completely opaque,
* meaning that all pixels have an alpha value of 1.0.
*/
- public final static int OPAQUE = 1;
+ @Native public final static int OPAQUE = 1;
/**
* Represents image data that is guaranteed to be either completely
* opaque, with an alpha value of 1.0, or completely transparent,
* with an alpha value of 0.0.
*/
- public final static int BITMASK = 2;
+ @Native public final static int BITMASK = 2;
/**
* Represents image data that contains or might contain arbitrary
* alpha values between and including 0.0 and 1.0.
*/
- public final static int TRANSLUCENT = 3;
+ @Native public final static int TRANSLUCENT = 3;
/**
* Returns the type of this <code>Transparency</code>.
diff --git a/src/share/classes/java/awt/color/ColorSpace.java b/src/share/classes/java/awt/color/ColorSpace.java
index f4ca58b..c0bcb49 100644
--- a/src/share/classes/java/awt/color/ColorSpace.java
+++ b/src/share/classes/java/awt/color/ColorSpace.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2008, 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
@@ -35,7 +35,7 @@
package java.awt.color;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
import sun.java2d.cmm.PCMM;
import sun.java2d.cmm.CMSManager;
@@ -95,8 +95,6 @@
* @see ICC_ColorSpace
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class ColorSpace implements java.io.Serializable {
static final long serialVersionUID = -409452704308689724L;
@@ -115,127 +113,127 @@
/**
* Any of the family of XYZ color spaces.
*/
- public static final int TYPE_XYZ = 0;
+ @Native public static final int TYPE_XYZ = 0;
/**
* Any of the family of Lab color spaces.
*/
- public static final int TYPE_Lab = 1;
+ @Native public static final int TYPE_Lab = 1;
/**
* Any of the family of Luv color spaces.
*/
- public static final int TYPE_Luv = 2;
+ @Native public static final int TYPE_Luv = 2;
/**
* Any of the family of YCbCr color spaces.
*/
- public static final int TYPE_YCbCr = 3;
+ @Native public static final int TYPE_YCbCr = 3;
/**
* Any of the family of Yxy color spaces.
*/
- public static final int TYPE_Yxy = 4;
+ @Native public static final int TYPE_Yxy = 4;
/**
* Any of the family of RGB color spaces.
*/
- public static final int TYPE_RGB = 5;
+ @Native public static final int TYPE_RGB = 5;
/**
* Any of the family of GRAY color spaces.
*/
- public static final int TYPE_GRAY = 6;
+ @Native public static final int TYPE_GRAY = 6;
/**
* Any of the family of HSV color spaces.
*/
- public static final int TYPE_HSV = 7;
+ @Native public static final int TYPE_HSV = 7;
/**
* Any of the family of HLS color spaces.
*/
- public static final int TYPE_HLS = 8;
+ @Native public static final int TYPE_HLS = 8;
/**
* Any of the family of CMYK color spaces.
*/
- public static final int TYPE_CMYK = 9;
+ @Native public static final int TYPE_CMYK = 9;
/**
* Any of the family of CMY color spaces.
*/
- public static final int TYPE_CMY = 11;
+ @Native public static final int TYPE_CMY = 11;
/**
* Generic 2 component color spaces.
*/
- public static final int TYPE_2CLR = 12;
+ @Native public static final int TYPE_2CLR = 12;
/**
* Generic 3 component color spaces.
*/
- public static final int TYPE_3CLR = 13;
+ @Native public static final int TYPE_3CLR = 13;
/**
* Generic 4 component color spaces.
*/
- public static final int TYPE_4CLR = 14;
+ @Native public static final int TYPE_4CLR = 14;
/**
* Generic 5 component color spaces.
*/
- public static final int TYPE_5CLR = 15;
+ @Native public static final int TYPE_5CLR = 15;
/**
* Generic 6 component color spaces.
*/
- public static final int TYPE_6CLR = 16;
+ @Native public static final int TYPE_6CLR = 16;
/**
* Generic 7 component color spaces.
*/
- public static final int TYPE_7CLR = 17;
+ @Native public static final int TYPE_7CLR = 17;
/**
* Generic 8 component color spaces.
*/
- public static final int TYPE_8CLR = 18;
+ @Native public static final int TYPE_8CLR = 18;
/**
* Generic 9 component color spaces.
*/
- public static final int TYPE_9CLR = 19;
+ @Native public static final int TYPE_9CLR = 19;
/**
* Generic 10 component color spaces.
*/
- public static final int TYPE_ACLR = 20;
+ @Native public static final int TYPE_ACLR = 20;
/**
* Generic 11 component color spaces.
*/
- public static final int TYPE_BCLR = 21;
+ @Native public static final int TYPE_BCLR = 21;
/**
* Generic 12 component color spaces.
*/
- public static final int TYPE_CCLR = 22;
+ @Native public static final int TYPE_CCLR = 22;
/**
* Generic 13 component color spaces.
*/
- public static final int TYPE_DCLR = 23;
+ @Native public static final int TYPE_DCLR = 23;
/**
* Generic 14 component color spaces.
*/
- public static final int TYPE_ECLR = 24;
+ @Native public static final int TYPE_ECLR = 24;
/**
* Generic 15 component color spaces.
*/
- public static final int TYPE_FCLR = 25;
+ @Native public static final int TYPE_FCLR = 25;
/**
* The sRGB color space defined at
@@ -243,28 +241,28 @@
* http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html
* </A>.
*/
- public static final int CS_sRGB = 1000;
+ @Native public static final int CS_sRGB = 1000;
/**
* A built-in linear RGB color space. This space is based on the
* same RGB primaries as CS_sRGB, but has a linear tone reproduction curve.
*/
- public static final int CS_LINEAR_RGB = 1004;
+ @Native public static final int CS_LINEAR_RGB = 1004;
/**
* The CIEXYZ conversion color space defined above.
*/
- public static final int CS_CIEXYZ = 1001;
+ @Native public static final int CS_CIEXYZ = 1001;
/**
* The Photo YCC conversion color space.
*/
- public static final int CS_PYCC = 1002;
+ @Native public static final int CS_PYCC = 1002;
/**
* The built-in linear gray scale color space.
*/
- public static final int CS_GRAY = 1003;
+ @Native public static final int CS_GRAY = 1003;
/**
diff --git a/src/share/classes/java/awt/color/ICC_Profile.java b/src/share/classes/java/awt/color/ICC_Profile.java
index 321db6c..b459f63 100644
--- a/src/share/classes/java/awt/color/ICC_Profile.java
+++ b/src/share/classes/java/awt/color/ICC_Profile.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, 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
@@ -58,7 +58,6 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* A representation of color profile data for device independent and
@@ -90,8 +89,6 @@
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class ICC_Profile implements Serializable {
private static final long serialVersionUID = -3938515861990936766L;
diff --git a/src/share/classes/java/awt/datatransfer/StringSelection.java b/src/share/classes/java/awt/datatransfer/StringSelection.java
index c646015..6036bd8 100644
--- a/src/share/classes/java/awt/datatransfer/StringSelection.java
+++ b/src/share/classes/java/awt/datatransfer/StringSelection.java
@@ -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
@@ -27,7 +27,6 @@
import java.io.*;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* A <code>Transferable</code> which implements the capability required
@@ -43,8 +42,6 @@
* @see java.awt.datatransfer.DataFlavor#stringFlavor
* @see java.awt.datatransfer.DataFlavor#plainTextFlavor
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class StringSelection implements Transferable, ClipboardOwner {
private static final int STRING = 0;
diff --git a/src/share/classes/java/awt/dnd/DnDConstants.java b/src/share/classes/java/awt/dnd/DnDConstants.java
index f497332..e4c5fb4 100644
--- a/src/share/classes/java/awt/dnd/DnDConstants.java
+++ b/src/share/classes/java/awt/dnd/DnDConstants.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999, 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
@@ -25,15 +25,13 @@
package java.awt.dnd;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* This class contains constant values representing
* the type of action(s) to be performed by a Drag and Drop operation.
* @since 1.2
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public final class DnDConstants {
private DnDConstants() {} // define null private constructor.
@@ -41,23 +39,23 @@
/**
* An <code>int</code> representing no action.
*/
- public static final int ACTION_NONE = 0x0;
+ @Native public static final int ACTION_NONE = 0x0;
/**
* An <code>int</code> representing a "copy" action.
*/
- public static final int ACTION_COPY = 0x1;
+ @Native public static final int ACTION_COPY = 0x1;
/**
* An <code>int</code> representing a "move" action.
*/
- public static final int ACTION_MOVE = 0x2;
+ @Native public static final int ACTION_MOVE = 0x2;
/**
* An <code>int</code> representing a "copy" or
* "move" action.
*/
- public static final int ACTION_COPY_OR_MOVE = ACTION_COPY | ACTION_MOVE;
+ @Native public static final int ACTION_COPY_OR_MOVE = ACTION_COPY | ACTION_MOVE;
/**
* An <code>int</code> representing a "link" action.
@@ -75,12 +73,12 @@
* results for the user.
*/
- public static final int ACTION_LINK = 0x40000000;
+ @Native public static final int ACTION_LINK = 0x40000000;
/**
* An <code>int</code> representing a "reference"
* action (synonym for ACTION_LINK).
*/
- public static final int ACTION_REFERENCE = ACTION_LINK;
+ @Native public static final int ACTION_REFERENCE = ACTION_LINK;
}
diff --git a/src/share/classes/java/awt/event/ActionEvent.java b/src/share/classes/java/awt/event/ActionEvent.java
index 755de2b..08bd8db 100644
--- a/src/share/classes/java/awt/event/ActionEvent.java
+++ b/src/share/classes/java/awt/event/ActionEvent.java
@@ -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
@@ -27,7 +27,7 @@
import java.awt.AWTEvent;
import java.awt.Event;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* A semantic event which indicates that a component-defined action occurred.
@@ -57,8 +57,6 @@
* @author Carl Quinn
* @since 1.1
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class ActionEvent extends AWTEvent {
/**
@@ -99,7 +97,7 @@
/**
* This event id indicates that a meaningful action occured.
*/
- public static final int ACTION_PERFORMED = ACTION_FIRST; //Event.ACTION_EVENT
+ @Native public static final int ACTION_PERFORMED = ACTION_FIRST; //Event.ACTION_EVENT
/**
* The nonlocalized string that gives more details
diff --git a/src/share/classes/java/awt/event/AdjustmentEvent.java b/src/share/classes/java/awt/event/AdjustmentEvent.java
index 669d292..66d54c3 100644
--- a/src/share/classes/java/awt/event/AdjustmentEvent.java
+++ b/src/share/classes/java/awt/event/AdjustmentEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2008, 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
@@ -27,9 +27,8 @@
import java.awt.Adjustable;
import java.awt.AWTEvent;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* The adjustment event emitted by Adjustable objects like
@@ -57,8 +56,6 @@
* @author Amy Fowler
* @since 1.1
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class AdjustmentEvent extends AWTEvent {
/**
@@ -79,27 +76,27 @@
/**
* The unit increment adjustment type.
*/
- public static final int UNIT_INCREMENT = 1;
+ @Native public static final int UNIT_INCREMENT = 1;
/**
* The unit decrement adjustment type.
*/
- public static final int UNIT_DECREMENT = 2;
+ @Native public static final int UNIT_DECREMENT = 2;
/**
* The block decrement adjustment type.
*/
- public static final int BLOCK_DECREMENT = 3;
+ @Native public static final int BLOCK_DECREMENT = 3;
/**
* The block increment adjustment type.
*/
- public static final int BLOCK_INCREMENT = 4;
+ @Native public static final int BLOCK_INCREMENT = 4;
/**
* The absolute tracking adjustment type.
*/
- public static final int TRACK = 5;
+ @Native public static final int TRACK = 5;
/**
* The adjustable object that fired the event.
diff --git a/src/share/classes/java/awt/event/ComponentEvent.java b/src/share/classes/java/awt/event/ComponentEvent.java
index 51c2b68..67149a7 100644
--- a/src/share/classes/java/awt/event/ComponentEvent.java
+++ b/src/share/classes/java/awt/event/ComponentEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2008, 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
@@ -28,7 +28,7 @@
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Rectangle;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* A low-level event which indicates that a component moved, changed
@@ -65,8 +65,6 @@
* @author Carl Quinn
* @since 1.1
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class ComponentEvent extends AWTEvent {
/**
@@ -82,22 +80,22 @@
/**
* This event indicates that the component's position changed.
*/
- public static final int COMPONENT_MOVED = COMPONENT_FIRST;
+ @Native public static final int COMPONENT_MOVED = COMPONENT_FIRST;
/**
* This event indicates that the component's size changed.
*/
- public static final int COMPONENT_RESIZED = 1 + COMPONENT_FIRST;
+ @Native public static final int COMPONENT_RESIZED = 1 + COMPONENT_FIRST;
/**
* This event indicates that the component was made visible.
*/
- public static final int COMPONENT_SHOWN = 2 + COMPONENT_FIRST;
+ @Native public static final int COMPONENT_SHOWN = 2 + COMPONENT_FIRST;
/**
* This event indicates that the component was rendered invisible.
*/
- public static final int COMPONENT_HIDDEN = 3 + COMPONENT_FIRST;
+ @Native public static final int COMPONENT_HIDDEN = 3 + COMPONENT_FIRST;
/*
* JDK 1.1 serialVersionUID
diff --git a/src/share/classes/java/awt/event/FocusEvent.java b/src/share/classes/java/awt/event/FocusEvent.java
index f9b1c8d..e70b968 100644
--- a/src/share/classes/java/awt/event/FocusEvent.java
+++ b/src/share/classes/java/awt/event/FocusEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2008, 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
@@ -26,7 +26,6 @@
package java.awt.event;
import java.awt.Component;
-import javax.tools.annotation.GenerateNativeHeader;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
@@ -64,8 +63,6 @@
* @author Amy Fowler
* @since 1.1
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class FocusEvent extends ComponentEvent {
/**
diff --git a/src/share/classes/java/awt/event/InputMethodEvent.java b/src/share/classes/java/awt/event/InputMethodEvent.java
index 339078c..ec5548a 100644
--- a/src/share/classes/java/awt/event/InputMethodEvent.java
+++ b/src/share/classes/java/awt/event/InputMethodEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2007, 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
@@ -33,7 +33,7 @@
import java.io.ObjectInputStream;
import java.text.AttributedCharacterIterator;
import java.text.CharacterIterator;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* Input method events contain information about text that is being
@@ -56,8 +56,6 @@
* @author JavaSoft Asia/Pacific
* @since 1.2
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class InputMethodEvent extends AWTEvent {
/**
@@ -68,25 +66,25 @@
/**
* Marks the first integer id for the range of input method event ids.
*/
- public static final int INPUT_METHOD_FIRST = 1100;
+ @Native public static final int INPUT_METHOD_FIRST = 1100;
/**
* The event type indicating changed input method text. This event is
* generated by input methods while processing input.
*/
- public static final int INPUT_METHOD_TEXT_CHANGED = INPUT_METHOD_FIRST;
+ @Native public static final int INPUT_METHOD_TEXT_CHANGED = INPUT_METHOD_FIRST;
/**
* The event type indicating a changed insertion point in input method text.
* This event is
* generated by input methods while processing input if only the caret changed.
*/
- public static final int CARET_POSITION_CHANGED = INPUT_METHOD_FIRST + 1;
+ @Native public static final int CARET_POSITION_CHANGED = INPUT_METHOD_FIRST + 1;
/**
* Marks the last integer id for the range of input method event ids.
*/
- public static final int INPUT_METHOD_LAST = INPUT_METHOD_FIRST + 1;
+ @Native public static final int INPUT_METHOD_LAST = INPUT_METHOD_FIRST + 1;
/**
* The time stamp that indicates when the event was created.
diff --git a/src/share/classes/java/awt/event/MouseWheelEvent.java b/src/share/classes/java/awt/event/MouseWheelEvent.java
index 2d0228a..b33c723 100644
--- a/src/share/classes/java/awt/event/MouseWheelEvent.java
+++ b/src/share/classes/java/awt/event/MouseWheelEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2008, 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
@@ -27,7 +27,7 @@
import java.awt.Component;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* An event which indicates that the mouse wheel was rotated in a component.
@@ -99,8 +99,6 @@
* @since 1.4
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class MouseWheelEvent extends MouseEvent {
/**
@@ -109,7 +107,7 @@
*
* @see #getScrollType
*/
- public static final int WHEEL_UNIT_SCROLL = 0;
+ @Native public static final int WHEEL_UNIT_SCROLL = 0;
/**
* Constant representing scrolling by a "block" (like scrolling
@@ -117,7 +115,7 @@
*
* @see #getScrollType
*/
- public static final int WHEEL_BLOCK_SCROLL = 1;
+ @Native public static final int WHEEL_BLOCK_SCROLL = 1;
/**
* Indicates what sort of scrolling should take place in response to this
diff --git a/src/share/classes/java/awt/event/WindowEvent.java b/src/share/classes/java/awt/event/WindowEvent.java
index 1fee154..49e45f3 100644
--- a/src/share/classes/java/awt/event/WindowEvent.java
+++ b/src/share/classes/java/awt/event/WindowEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2008, 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
@@ -26,7 +26,7 @@
package java.awt.event;
import java.awt.Window;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
@@ -56,8 +56,6 @@
*
* @since JDK1.1
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class WindowEvent extends ComponentEvent {
/**
@@ -69,7 +67,7 @@
* The window opened event. This event is delivered only
* the first time a window is made visible.
*/
- public static final int WINDOW_OPENED = WINDOW_FIRST; // 200
+ @Native public static final int WINDOW_OPENED = WINDOW_FIRST; // 200
/**
* The "window is closing" event. This event is delivered when
@@ -78,13 +76,13 @@
* while processing this event, the window close operation will be
* cancelled.
*/
- public static final int WINDOW_CLOSING = 1 + WINDOW_FIRST; //Event.WINDOW_DESTROY
+ @Native public static final int WINDOW_CLOSING = 1 + WINDOW_FIRST; //Event.WINDOW_DESTROY
/**
* The window closed event. This event is delivered after
* the window has been closed as the result of a call to dispose.
*/
- public static final int WINDOW_CLOSED = 2 + WINDOW_FIRST;
+ @Native public static final int WINDOW_CLOSED = 2 + WINDOW_FIRST;
/**
* The window iconified event. This event is delivered when
@@ -93,13 +91,13 @@
* the icon specified in the window's iconImage property.
* @see java.awt.Frame#setIconImage
*/
- public static final int WINDOW_ICONIFIED = 3 + WINDOW_FIRST; //Event.WINDOW_ICONIFY
+ @Native public static final int WINDOW_ICONIFIED = 3 + WINDOW_FIRST; //Event.WINDOW_ICONIFY
/**
* The window deiconified event type. This event is delivered when
* the window has been changed from a minimized to a normal state.
*/
- public static final int WINDOW_DEICONIFIED = 4 + WINDOW_FIRST; //Event.WINDOW_DEICONIFY
+ @Native public static final int WINDOW_DEICONIFIED = 4 + WINDOW_FIRST; //Event.WINDOW_DEICONIFY
/**
* The window-activated event type. This event is delivered when the Window
@@ -109,7 +107,7 @@
* active Window is always either the focused Window, or the first Frame or
* Dialog that is an owner of the focused Window.
*/
- public static final int WINDOW_ACTIVATED = 5 + WINDOW_FIRST;
+ @Native public static final int WINDOW_ACTIVATED = 5 + WINDOW_FIRST;
/**
* The window-deactivated event type. This event is delivered when the
@@ -119,21 +117,21 @@
* title bar. The active Window is always either the focused Window, or the
* first Frame or Dialog that is an owner of the focused Window.
*/
- public static final int WINDOW_DEACTIVATED = 6 + WINDOW_FIRST;
+ @Native public static final int WINDOW_DEACTIVATED = 6 + WINDOW_FIRST;
/**
* The window-gained-focus event type. This event is delivered when the
* Window becomes the focused Window, which means that the Window, or one
* of its subcomponents, will receive keyboard events.
*/
- public static final int WINDOW_GAINED_FOCUS = 7 + WINDOW_FIRST;
+ @Native public static final int WINDOW_GAINED_FOCUS = 7 + WINDOW_FIRST;
/**
* The window-lost-focus event type. This event is delivered when a Window
* is no longer the focused Window, which means keyboard events will no
* longer be delivered to the Window or any of its subcomponents.
*/
- public static final int WINDOW_LOST_FOCUS = 8 + WINDOW_FIRST;
+ @Native public static final int WINDOW_LOST_FOCUS = 8 + WINDOW_FIRST;
/**
* The window-state-changed event type. This event is delivered
@@ -141,7 +139,7 @@
* iconified, maximized etc.
* @since 1.4
*/
- public static final int WINDOW_STATE_CHANGED = 9 + WINDOW_FIRST;
+ @Native public static final int WINDOW_STATE_CHANGED = 9 + WINDOW_FIRST;
/**
* The last number in the range of ids used for window events.
diff --git a/src/share/classes/java/awt/geom/PathIterator.java b/src/share/classes/java/awt/geom/PathIterator.java
index 84eb219..75cb228 100644
--- a/src/share/classes/java/awt/geom/PathIterator.java
+++ b/src/share/classes/java/awt/geom/PathIterator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000, 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
@@ -25,7 +25,7 @@
package java.awt.geom;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* The <code>PathIterator</code> interface provides the mechanism
@@ -59,8 +59,6 @@
*
* @author Jim Graham
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public interface PathIterator {
/**
* The winding rule constant for specifying an even-odd rule
@@ -69,7 +67,7 @@
* path if a ray drawn in any direction from that point to
* infinity is crossed by path segments an odd number of times.
*/
- public static final int WIND_EVEN_ODD = 0;
+ @Native public static final int WIND_EVEN_ODD = 0;
/**
* The winding rule constant for specifying a non-zero rule
@@ -80,20 +78,20 @@
* of times in the counter-clockwise direction than the
* clockwise direction.
*/
- public static final int WIND_NON_ZERO = 1;
+ @Native public static final int WIND_NON_ZERO = 1;
/**
* The segment type constant for a point that specifies the
* starting location for a new subpath.
*/
- public static final int SEG_MOVETO = 0;
+ @Native public static final int SEG_MOVETO = 0;
/**
* The segment type constant for a point that specifies the
* end point of a line to be drawn from the most recently
* specified point.
*/
- public static final int SEG_LINETO = 1;
+ @Native public static final int SEG_LINETO = 1;
/**
* The segment type constant for the pair of points that specify
@@ -115,7 +113,7 @@
* = n! / (m! * (n-m)!)
* </pre>
*/
- public static final int SEG_QUADTO = 2;
+ @Native public static final int SEG_QUADTO = 2;
/**
* The segment type constant for the set of 3 points that specify
@@ -139,14 +137,14 @@
* </pre>
* This form of curve is commonly known as a Bézier curve.
*/
- public static final int SEG_CUBICTO = 3;
+ @Native public static final int SEG_CUBICTO = 3;
/**
* The segment type constant that specifies that
* the preceding subpath should be closed by appending a line segment
* back to the point corresponding to the most recent SEG_MOVETO.
*/
- public static final int SEG_CLOSE = 4;
+ @Native public static final int SEG_CLOSE = 4;
/**
* Returns the winding rule for determining the interior of the
diff --git a/src/share/classes/java/awt/image/AffineTransformOp.java b/src/share/classes/java/awt/image/AffineTransformOp.java
index b3f090a..30819ba 100644
--- a/src/share/classes/java/awt/image/AffineTransformOp.java
+++ b/src/share/classes/java/awt/image/AffineTransformOp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2005, 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
@@ -34,7 +34,7 @@
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Transparency;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
import sun.awt.image.ImagingLib;
/**
@@ -63,8 +63,6 @@
* @see java.awt.RenderingHints#KEY_COLOR_RENDERING
* @see java.awt.RenderingHints#KEY_DITHERING
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class AffineTransformOp implements BufferedImageOp, RasterOp {
private AffineTransform xform;
RenderingHints hints;
@@ -72,17 +70,17 @@
/**
* Nearest-neighbor interpolation type.
*/
- public static final int TYPE_NEAREST_NEIGHBOR = 1;
+ @Native public static final int TYPE_NEAREST_NEIGHBOR = 1;
/**
* Bilinear interpolation type.
*/
- public static final int TYPE_BILINEAR = 2;
+ @Native public static final int TYPE_BILINEAR = 2;
/**
* Bicubic interpolation type.
*/
- public static final int TYPE_BICUBIC = 3;
+ @Native public static final int TYPE_BICUBIC = 3;
int interpolationType = TYPE_NEAREST_NEIGHBOR;
diff --git a/src/share/classes/java/awt/image/ConvolveOp.java b/src/share/classes/java/awt/image/ConvolveOp.java
index 20f1c31..1c5e20e 100644
--- a/src/share/classes/java/awt/image/ConvolveOp.java
+++ b/src/share/classes/java/awt/image/ConvolveOp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000, 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
@@ -30,7 +30,7 @@
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.Point2D;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
import sun.awt.image.ImagingLib;
/**
@@ -66,8 +66,6 @@
* @see java.awt.RenderingHints#KEY_COLOR_RENDERING
* @see java.awt.RenderingHints#KEY_DITHERING
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class ConvolveOp implements BufferedImageOp, RasterOp {
Kernel kernel;
int edgeHint;
@@ -81,13 +79,13 @@
* is the default.
*/
- public static final int EDGE_ZERO_FILL = 0;
+ @Native public static final int EDGE_ZERO_FILL = 0;
/**
* Pixels at the edge of the source image are copied to
* the corresponding pixels in the destination without modification.
*/
- public static final int EDGE_NO_OP = 1;
+ @Native public static final int EDGE_NO_OP = 1;
/**
* Constructs a ConvolveOp given a Kernel, an edge condition, and a
diff --git a/src/share/classes/java/awt/image/DataBuffer.java b/src/share/classes/java/awt/image/DataBuffer.java
index b0e70f2..5bf9652 100644
--- a/src/share/classes/java/awt/image/DataBuffer.java
+++ b/src/share/classes/java/awt/image/DataBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2008, 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
@@ -41,7 +41,7 @@
import sun.awt.image.SunWritableRaster;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* This class exists to wrap one or more data arrays. Each data array in
@@ -67,30 +67,28 @@
* @see java.awt.image.Raster
* @see java.awt.image.SampleModel
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class DataBuffer {
/** Tag for unsigned byte data. */
- public static final int TYPE_BYTE = 0;
+ @Native public static final int TYPE_BYTE = 0;
/** Tag for unsigned short data. */
- public static final int TYPE_USHORT = 1;
+ @Native public static final int TYPE_USHORT = 1;
/** Tag for signed short data. Placeholder for future use. */
- public static final int TYPE_SHORT = 2;
+ @Native public static final int TYPE_SHORT = 2;
/** Tag for int data. */
- public static final int TYPE_INT = 3;
+ @Native public static final int TYPE_INT = 3;
/** Tag for float data. Placeholder for future use. */
- public static final int TYPE_FLOAT = 4;
+ @Native public static final int TYPE_FLOAT = 4;
/** Tag for double data. Placeholder for future use. */
- public static final int TYPE_DOUBLE = 5;
+ @Native public static final int TYPE_DOUBLE = 5;
/** Tag for undefined data. */
- public static final int TYPE_UNDEFINED = 32;
+ @Native public static final int TYPE_UNDEFINED = 32;
/** The data type of this DataBuffer. */
protected int dataType;
diff --git a/src/share/classes/java/awt/image/ImageConsumer.java b/src/share/classes/java/awt/image/ImageConsumer.java
index c14d50a..da22310 100644
--- a/src/share/classes/java/awt/image/ImageConsumer.java
+++ b/src/share/classes/java/awt/image/ImageConsumer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2006, 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
@@ -27,7 +27,6 @@
import java.util.Hashtable;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* The interface for objects expressing interest in image data through
@@ -39,8 +38,6 @@
*
* @author Jim Graham
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public interface ImageConsumer {
/**
* The dimensions of the source image are reported using the
diff --git a/src/share/classes/java/awt/image/ImageObserver.java b/src/share/classes/java/awt/image/ImageObserver.java
index 60db15b..1790309 100644
--- a/src/share/classes/java/awt/image/ImageObserver.java
+++ b/src/share/classes/java/awt/image/ImageObserver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 1999, 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
@@ -27,7 +27,6 @@
import java.awt.Image;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* An asynchronous update interface for receiving notifications about
@@ -35,8 +34,6 @@
*
* @author Jim Graham
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public interface ImageObserver {
/**
* This method is called when information about an image which was
diff --git a/src/share/classes/java/awt/peer/ComponentPeer.java b/src/share/classes/java/awt/peer/ComponentPeer.java
index 43ef8e5..40f310d 100644
--- a/src/share/classes/java/awt/peer/ComponentPeer.java
+++ b/src/share/classes/java/awt/peer/ComponentPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2008, 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
@@ -32,7 +32,6 @@
import java.awt.image.ColorModel;
import java.awt.image.VolatileImage;
import java.awt.GraphicsConfiguration;
-import javax.tools.annotation.GenerateNativeHeader;
import sun.awt.CausedFocusEvent;
import sun.java2d.pipe.Region;
@@ -50,8 +49,6 @@
* nor invoke any of the peer methods directly on the peer
* instances.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public interface ComponentPeer {
/**
diff --git a/src/share/classes/java/awt/print/PageFormat.java b/src/share/classes/java/awt/print/PageFormat.java
index 8a19b66..0b25201 100644
--- a/src/share/classes/java/awt/print/PageFormat.java
+++ b/src/share/classes/java/awt/print/PageFormat.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000, 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
@@ -29,14 +29,12 @@
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* The <code>PageFormat</code> class describes the size and
* orientation of a page to be printed.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class PageFormat implements Cloneable
{
@@ -48,21 +46,21 @@
* Note that this is not the Macintosh landscape but
* is the Window's and PostScript landscape.
*/
- public static final int LANDSCAPE = 0;
+ @Native public static final int LANDSCAPE = 0;
/**
* The origin is at the top left of the paper with
* x running to the right and y running down the
* paper.
*/
- public static final int PORTRAIT = 1;
+ @Native public static final int PORTRAIT = 1;
/**
* The origin is at the top right of the paper with x
* running top to bottom and y running right to left.
* Note that this is the Macintosh landscape.
*/
- public static final int REVERSE_LANDSCAPE = 2;
+ @Native public static final int REVERSE_LANDSCAPE = 2;
/* Instance Variables */
diff --git a/src/share/classes/java/awt/print/Pageable.java b/src/share/classes/java/awt/print/Pageable.java
index e98f6f4..b87cc7b 100644
--- a/src/share/classes/java/awt/print/Pageable.java
+++ b/src/share/classes/java/awt/print/Pageable.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2000, 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
@@ -25,7 +25,7 @@
package java.awt.print;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* The <code>Pageable</code> implementation represents a set of
@@ -35,8 +35,6 @@
* @see java.awt.print.PageFormat
* @see java.awt.print.Printable
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public interface Pageable {
/**
@@ -45,7 +43,7 @@
* method if a <code>Pageable</code> implementation does not know
* the number of pages in its set.
*/
- int UNKNOWN_NUMBER_OF_PAGES = -1;
+ @Native int UNKNOWN_NUMBER_OF_PAGES = -1;
/**
* Returns the number of pages in the set.
diff --git a/src/share/classes/java/awt/print/Printable.java b/src/share/classes/java/awt/print/Printable.java
index dacf917..6737aec 100644
--- a/src/share/classes/java/awt/print/Printable.java
+++ b/src/share/classes/java/awt/print/Printable.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2005, 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
@@ -27,7 +27,6 @@
import java.awt.Graphics;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* The <code>Printable</code> interface is implemented
@@ -100,8 +99,6 @@
* @see java.awt.print.PageFormat
* @see java.awt.print.PrinterJob
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public interface Printable {
/**
diff --git a/src/share/classes/java/lang/AbstractStringBuilder.java b/src/share/classes/java/lang/AbstractStringBuilder.java
index 6e4881c..c319fa4 100644
--- a/src/share/classes/java/lang/AbstractStringBuilder.java
+++ b/src/share/classes/java/lang/AbstractStringBuilder.java
@@ -236,7 +236,7 @@
if ((index < 0) || (index >= count)) {
throw new StringIndexOutOfBoundsException(index);
}
- return Character.codePointAt(value, index);
+ return Character.codePointAtImpl(value, index, count);
}
/**
@@ -265,7 +265,7 @@
if ((i < 0) || (i >= count)) {
throw new StringIndexOutOfBoundsException(index);
}
- return Character.codePointBefore(value, index);
+ return Character.codePointBeforeImpl(value, index, 0);
}
/**
@@ -415,7 +415,8 @@
* @return a reference to this object.
*/
public AbstractStringBuilder append(String str) {
- if (str == null) str = "null";
+ if (str == null)
+ return appendNull();
int len = str.length();
ensureCapacityInternal(count + len);
str.getChars(0, len, value, count);
@@ -426,7 +427,7 @@
// Documentation in subclasses because of synchro difference
public AbstractStringBuilder append(StringBuffer sb) {
if (sb == null)
- return append("null");
+ return appendNull();
int len = sb.length();
ensureCapacityInternal(count + len);
sb.getChars(0, len, value, count);
@@ -439,7 +440,7 @@
*/
AbstractStringBuilder append(AbstractStringBuilder asb) {
if (asb == null)
- return append("null");
+ return appendNull();
int len = asb.length();
ensureCapacityInternal(count + len);
asb.getChars(0, len, value, count);
@@ -451,7 +452,7 @@
@Override
public AbstractStringBuilder append(CharSequence s) {
if (s == null)
- s = "null";
+ return appendNull();
if (s instanceof String)
return this.append((String)s);
if (s instanceof AbstractStringBuilder)
@@ -460,6 +461,18 @@
return this.append(s, 0, s.length());
}
+ private AbstractStringBuilder appendNull() {
+ int c = count;
+ ensureCapacityInternal(c + 4);
+ final char[] value = this.value;
+ value[c++] = 'n';
+ value[c++] = 'u';
+ value[c++] = 'l';
+ value[c++] = 'l';
+ count = c;
+ return this;
+ }
+
/**
* Appends a subsequence of the specified {@code CharSequence} to this
* sequence.
@@ -1370,32 +1383,37 @@
* @return a reference to this object.
*/
public AbstractStringBuilder reverse() {
- boolean hasSurrogate = false;
+ boolean hasSurrogates = false;
int n = count - 1;
- for (int j = (n-1) >> 1; j >= 0; --j) {
- char temp = value[j];
- char temp2 = value[n - j];
- if (!hasSurrogate) {
- hasSurrogate = (temp >= Character.MIN_SURROGATE && temp <= Character.MAX_SURROGATE)
- || (temp2 >= Character.MIN_SURROGATE && temp2 <= Character.MAX_SURROGATE);
+ for (int j = (n-1) >> 1; j >= 0; j--) {
+ int k = n - j;
+ char cj = value[j];
+ char ck = value[k];
+ value[j] = ck;
+ value[k] = cj;
+ if (Character.isSurrogate(cj) ||
+ Character.isSurrogate(ck)) {
+ hasSurrogates = true;
}
- value[j] = temp2;
- value[n - j] = temp;
}
- if (hasSurrogate) {
- // Reverse back all valid surrogate pairs
- for (int i = 0; i < count - 1; i++) {
- char c2 = value[i];
- if (Character.isLowSurrogate(c2)) {
- char c1 = value[i + 1];
- if (Character.isHighSurrogate(c1)) {
- value[i++] = c1;
- value[i] = c2;
- }
+ if (hasSurrogates) {
+ reverseAllValidSurrogatePairs();
+ }
+ return this;
+ }
+
+ /** Outlined helper method for reverse() */
+ private void reverseAllValidSurrogatePairs() {
+ for (int i = 0; i < count - 1; i++) {
+ char c2 = value[i];
+ if (Character.isLowSurrogate(c2)) {
+ char c1 = value[i + 1];
+ if (Character.isHighSurrogate(c1)) {
+ value[i++] = c1;
+ value[i] = c2;
}
}
}
- return this;
}
/**
diff --git a/src/share/classes/java/lang/Character.java b/src/share/classes/java/lang/Character.java
index 0f44006..531263d 100644
--- a/src/share/classes/java/lang/Character.java
+++ b/src/share/classes/java/lang/Character.java
@@ -4862,13 +4862,11 @@
* @since 1.5
*/
public static int codePointAt(CharSequence seq, int index) {
- char c1 = seq.charAt(index++);
- if (isHighSurrogate(c1)) {
- if (index < seq.length()) {
- char c2 = seq.charAt(index);
- if (isLowSurrogate(c2)) {
- return toCodePoint(c1, c2);
- }
+ char c1 = seq.charAt(index);
+ if (isHighSurrogate(c1) && ++index < seq.length()) {
+ char c2 = seq.charAt(index);
+ if (isLowSurrogate(c2)) {
+ return toCodePoint(c1, c2);
}
}
return c1;
@@ -4931,15 +4929,13 @@
return codePointAtImpl(a, index, limit);
}
- // throws ArrayIndexOutofBoundsException if index out of bounds
+ // throws ArrayIndexOutOfBoundsException if index out of bounds
static int codePointAtImpl(char[] a, int index, int limit) {
- char c1 = a[index++];
- if (isHighSurrogate(c1)) {
- if (index < limit) {
- char c2 = a[index];
- if (isLowSurrogate(c2)) {
- return toCodePoint(c1, c2);
- }
+ char c1 = a[index];
+ if (isHighSurrogate(c1) && ++index < limit) {
+ char c2 = a[index];
+ if (isLowSurrogate(c2)) {
+ return toCodePoint(c1, c2);
}
}
return c1;
@@ -4968,12 +4964,10 @@
*/
public static int codePointBefore(CharSequence seq, int index) {
char c2 = seq.charAt(--index);
- if (isLowSurrogate(c2)) {
- if (index > 0) {
- char c1 = seq.charAt(--index);
- if (isHighSurrogate(c1)) {
- return toCodePoint(c1, c2);
- }
+ if (isLowSurrogate(c2) && index > 0) {
+ char c1 = seq.charAt(--index);
+ if (isHighSurrogate(c1)) {
+ return toCodePoint(c1, c2);
}
}
return c2;
@@ -5038,15 +5032,13 @@
return codePointBeforeImpl(a, index, start);
}
- // throws ArrayIndexOutofBoundsException if index-1 out of bounds
+ // throws ArrayIndexOutOfBoundsException if index-1 out of bounds
static int codePointBeforeImpl(char[] a, int index, int start) {
char c2 = a[--index];
- if (isLowSurrogate(c2)) {
- if (index > start) {
- char c1 = a[--index];
- if (isHighSurrogate(c1)) {
- return toCodePoint(c1, c2);
- }
+ if (isLowSurrogate(c2) && index > start) {
+ char c1 = a[--index];
+ if (isHighSurrogate(c1)) {
+ return toCodePoint(c1, c2);
}
}
return c2;
diff --git a/src/share/classes/java/lang/Class.java b/src/share/classes/java/lang/Class.java
index f0ab8b2..5fd388d 100644
--- a/src/share/classes/java/lang/Class.java
+++ b/src/share/classes/java/lang/Class.java
@@ -113,8 +113,7 @@
* @see java.lang.ClassLoader#defineClass(byte[], int, int)
* @since JDK1.0
*/
-public final
- class Class<T> implements java.io.Serializable,
+public final class Class<T> implements java.io.Serializable,
java.lang.reflect.GenericDeclaration,
java.lang.reflect.Type,
java.lang.reflect.AnnotatedElement {
@@ -150,6 +149,75 @@
+ getName();
}
+ /**
+ * Returns a string describing this {@code Class}, including
+ * information about modifiers and type parameters.
+ *
+ * The string is formatted as a list of type modifiers, if any,
+ * followed by the kind of type (empty string for primitive types
+ * and {@code class}, {@code enum}, {@code interface}, or {@code
+ * @interface}, as appropriate), followed by the type's name,
+ * followed by an angle-bracketed comma-separated list of the
+ * type's type parameters, if any.
+ *
+ * A space is used to separate modifiers from one another and to
+ * separate any modifiers from the kind of type. The modifiers
+ * occur in canonical order. If there are no type parameters, the
+ * type parameter list is elided.
+ *
+ * <p>Note that since information about the runtime representation
+ * of a type is being generated, modifiers not present on the
+ * originating source code or illegal on the originating source
+ * code may be present.
+ *
+ * @return a string describing this {@code Class}, including
+ * information about modifiers and type parameters
+ *
+ * @since 1.8
+ */
+ public String toGenericString() {
+ if (isPrimitive()) {
+ return toString();
+ } else {
+ StringBuilder sb = new StringBuilder();
+
+ // Class modifiers are a superset of interface modifiers
+ int modifiers = getModifiers() & Modifier.classModifiers();
+ if (modifiers != 0) {
+ sb.append(Modifier.toString(modifiers));
+ sb.append(' ');
+ }
+
+ if (isAnnotation()) {
+ sb.append('@');
+ }
+ if (isInterface()) { // Note: all annotation types are interfaces
+ sb.append("interface");
+ } else {
+ if (isEnum())
+ sb.append("enum");
+ else
+ sb.append("class");
+ }
+ sb.append(' ');
+ sb.append(getName());
+
+ TypeVariable<?>[] typeparms = getTypeParameters();
+ if (typeparms.length > 0) {
+ boolean first = true;
+ sb.append('<');
+ for(TypeVariable<?> typeparm: typeparms) {
+ if (!first)
+ sb.append(',');
+ sb.append(typeparm.getTypeName());
+ first = false;
+ }
+ sb.append('>');
+ }
+
+ return sb.toString();
+ }
+ }
/**
* Returns the {@code Class} object associated with the class or
@@ -1164,6 +1232,32 @@
}
/**
+ * Return an informative string for the name of this type.
+ *
+ * @return an informative string for the name of this type
+ * @since 1.8
+ */
+ public String getTypeName() {
+ if (isArray()) {
+ try {
+ Class<?> cl = this;
+ int dimensions = 0;
+ while (cl.isArray()) {
+ dimensions++;
+ cl = cl.getComponentType();
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append(cl.getName());
+ for (int i = 0; i < dimensions; i++) {
+ sb.append("[]");
+ }
+ return sb.toString();
+ } catch (Throwable e) { /*FALLTHRU*/ }
+ }
+ return getName();
+ }
+
+ /**
* Character.isDigit answers {@code true} to some non-ascii
* digits. This one does not.
*/
diff --git a/src/share/classes/java/lang/ClassLoader.java b/src/share/classes/java/lang/ClassLoader.java
index a1e18ff..c41280d 100644
--- a/src/share/classes/java/lang/ClassLoader.java
+++ b/src/share/classes/java/lang/ClassLoader.java
@@ -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 @@
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 @@
/* unload the library. */
ClassLoader.nativeLibraryContext.push(this);
try {
- unload();
+ unload(name, isBuiltin);
} finally {
ClassLoader.nativeLibraryContext.pop();
}
@@ -1830,20 +1837,24 @@
}
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 @@
}
}
}
- 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;
diff --git a/src/share/classes/java/lang/Long.java b/src/share/classes/java/lang/Long.java
index b67c852..76dbfc3 100644
--- a/src/share/classes/java/lang/Long.java
+++ b/src/share/classes/java/lang/Long.java
@@ -479,7 +479,7 @@
* of the string as a type indicator, as would be permitted in
* Java programming language source code - except that either
* {@code L} or {@code l} may appear as a digit for a
- * radix greater than 22.
+ * radix greater than or equal to 22.
*
* <p>An exception of type {@code NumberFormatException} is
* thrown if any of the following situations occurs:
diff --git a/src/share/classes/java/lang/Runtime.java b/src/share/classes/java/lang/Runtime.java
index 5454707..ada915d 100644
--- a/src/share/classes/java/lang/Runtime.java
+++ b/src/share/classes/java/lang/Runtime.java
@@ -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 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 @@
* @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 @@
}
/**
- * 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 @@
* @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
diff --git a/src/share/classes/java/lang/System.java b/src/share/classes/java/lang/System.java
index 45ea719..9d1663a 100644
--- a/src/share/classes/java/lang/System.java
+++ b/src/share/classes/java/lang/System.java
@@ -1037,9 +1037,21 @@
}
/**
- * 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 @@
* @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 @@
}
/**
- * 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 @@
* @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)
diff --git a/src/share/classes/java/lang/invoke/DirectMethodHandle.java b/src/share/classes/java/lang/invoke/DirectMethodHandle.java
index 7793bc2..b9c10d8 100644
--- a/src/share/classes/java/lang/invoke/DirectMethodHandle.java
+++ b/src/share/classes/java/lang/invoke/DirectMethodHandle.java
@@ -52,7 +52,8 @@
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);
diff --git a/src/share/classes/java/lang/reflect/Constructor.java b/src/share/classes/java/lang/reflect/Constructor.java
index bdbd7c3..14a515f 100644
--- a/src/share/classes/java/lang/reflect/Constructor.java
+++ b/src/share/classes/java/lang/reflect/Constructor.java
@@ -284,16 +284,20 @@
* modifiers {@code public}, {@code protected} or
* {@code private}. Only one of these may appear, or none if the
* constructor has default (package) access.
+ *
+ * @return a string describing this {@code Constructor}
+ * @jls 8.8.3. Constructor Modifiers
*/
public String toString() {
return sharedToString(Modifier.constructorModifiers(),
+ false,
parameterTypes,
exceptionTypes);
}
@Override
void specificToStringHeader(StringBuilder sb) {
- sb.append(Field.getTypeName(getDeclaringClass()));
+ sb.append(getDeclaringClass().getTypeName());
}
/**
@@ -328,10 +332,11 @@
* include type parameters
*
* @since 1.5
+ * @jls 8.8.3. Constructor Modifiers
*/
@Override
public String toGenericString() {
- return sharedToGenericString(Modifier.constructorModifiers());
+ return sharedToGenericString(Modifier.constructorModifiers(), false);
}
@Override
diff --git a/src/share/classes/java/lang/reflect/Executable.java b/src/share/classes/java/lang/reflect/Executable.java
index 1a89968..bd8bac3 100644
--- a/src/share/classes/java/lang/reflect/Executable.java
+++ b/src/share/classes/java/lang/reflect/Executable.java
@@ -82,27 +82,38 @@
void separateWithCommas(Class<?>[] types, StringBuilder sb) {
for (int j = 0; j < types.length; j++) {
- sb.append(Field.getTypeName(types[j]));
+ sb.append(types[j].getTypeName());
if (j < (types.length - 1))
sb.append(",");
}
}
- void printModifiersIfNonzero(StringBuilder sb, int mask) {
+ void printModifiersIfNonzero(StringBuilder sb, int mask, boolean isDefault) {
int mod = getModifiers() & mask;
- if (mod != 0) {
+
+ if (mod != 0 && !isDefault) {
sb.append(Modifier.toString(mod)).append(' ');
+ } else {
+ int access_mod = mod & Modifier.ACCESS_MODIFIERS;
+ if (access_mod != 0)
+ sb.append(Modifier.toString(access_mod)).append(' ');
+ if (isDefault)
+ sb.append("default ");
+ mod = (mod & ~Modifier.ACCESS_MODIFIERS);
+ if (mod != 0)
+ sb.append(Modifier.toString(mod)).append(' ');
}
}
String sharedToString(int modifierMask,
+ boolean isDefault,
Class<?>[] parameterTypes,
Class<?>[] exceptionTypes) {
try {
StringBuilder sb = new StringBuilder();
- printModifiersIfNonzero(sb, modifierMask);
+ printModifiersIfNonzero(sb, modifierMask, isDefault);
specificToStringHeader(sb);
sb.append('(');
@@ -124,11 +135,11 @@
*/
abstract void specificToStringHeader(StringBuilder sb);
- String sharedToGenericString(int modifierMask) {
+ String sharedToGenericString(int modifierMask, boolean isDefault) {
try {
StringBuilder sb = new StringBuilder();
- printModifiersIfNonzero(sb, modifierMask);
+ printModifiersIfNonzero(sb, modifierMask, isDefault);
TypeVariable<?>[] typeparms = getTypeParameters();
if (typeparms.length > 0) {
@@ -150,9 +161,7 @@
sb.append('(');
Type[] params = getGenericParameterTypes();
for (int j = 0; j < params.length; j++) {
- String param = (params[j] instanceof Class)?
- Field.getTypeName((Class)params[j]):
- (params[j].toString());
+ String param = params[j].getTypeName();
if (isVarArgs() && (j == params.length - 1)) // replace T[] with T...
param = param.replaceFirst("\\[\\]$", "...");
sb.append(param);
diff --git a/src/share/classes/java/lang/reflect/Field.java b/src/share/classes/java/lang/reflect/Field.java
index be13b07..bd2b9ef 100644
--- a/src/share/classes/java/lang/reflect/Field.java
+++ b/src/share/classes/java/lang/reflect/Field.java
@@ -288,12 +288,15 @@
* {@code protected} or {@code private} first, and then other
* modifiers in the following order: {@code static}, {@code final},
* {@code transient}, {@code volatile}.
+ *
+ * @return a string describing this {@code Field}
+ * @jls 8.3.1 Field Modifiers
*/
public String toString() {
int mod = getModifiers();
return (((mod == 0) ? "" : (Modifier.toString(mod) + " "))
- + getTypeName(getType()) + " "
- + getTypeName(getDeclaringClass()) + "."
+ + getType().getTypeName() + " "
+ + getDeclaringClass().getTypeName() + "."
+ getName());
}
@@ -315,14 +318,14 @@
* its generic type
*
* @since 1.5
+ * @jls 8.3.1 Field Modifiers
*/
public String toGenericString() {
int mod = getModifiers();
Type fieldType = getGenericType();
return (((mod == 0) ? "" : (Modifier.toString(mod) + " "))
- + ((fieldType instanceof Class) ?
- getTypeName((Class)fieldType): fieldType.toString())+ " "
- + getTypeName(getDeclaringClass()) + "."
+ + fieldType.getTypeName() + " "
+ + getDeclaringClass().getTypeName() + "."
+ getName());
}
@@ -992,29 +995,6 @@
}
}
- /*
- * Utility routine to paper over array type names
- */
- static String getTypeName(Class<?> type) {
- if (type.isArray()) {
- try {
- Class<?> cl = type;
- int dimensions = 0;
- while (cl.isArray()) {
- dimensions++;
- cl = cl.getComponentType();
- }
- StringBuffer sb = new StringBuffer();
- sb.append(cl.getName());
- for (int i = 0; i < dimensions; i++) {
- sb.append("[]");
- }
- return sb.toString();
- } catch (Throwable e) { /*FALLTHRU*/ }
- }
- return type.getName();
- }
-
/**
* @throws NullPointerException {@inheritDoc}
* @since 1.5
diff --git a/src/share/classes/java/lang/reflect/Method.java b/src/share/classes/java/lang/reflect/Method.java
index 30e7646..1caddd6 100644
--- a/src/share/classes/java/lang/reflect/Method.java
+++ b/src/share/classes/java/lang/reflect/Method.java
@@ -342,19 +342,24 @@
* specified by "The Java Language Specification". This is
* {@code public}, {@code protected} or {@code private} first,
* and then other modifiers in the following order:
- * {@code abstract}, {@code static}, {@code final},
+ * {@code abstract}, {@code default}, {@code static}, {@code final},
* {@code synchronized}, {@code native}, {@code strictfp}.
+ *
+ * @return a string describing this {@code Method}
+ *
+ * @jls 8.4.3 Method Modifiers
*/
public String toString() {
return sharedToString(Modifier.methodModifiers(),
+ isDefault(),
parameterTypes,
exceptionTypes);
}
@Override
void specificToStringHeader(StringBuilder sb) {
- sb.append(Field.getTypeName(getReturnType())).append(' ');
- sb.append(Field.getTypeName(getDeclaringClass())).append('.');
+ sb.append(getReturnType().getTypeName()).append(' ');
+ sb.append(getDeclaringClass().getTypeName()).append('.');
sb.append(getName());
}
@@ -381,34 +386,32 @@
* class name. If the method is declared to throw exceptions, the
* parameter list is followed by a space, followed by the word
* throws followed by a comma-separated list of the generic thrown
- * exception types. If there are no type parameters, the type
- * parameter list is elided.
+ * exception types.
*
* <p>The access modifiers are placed in canonical order as
* specified by "The Java Language Specification". This is
* {@code public}, {@code protected} or {@code private} first,
* and then other modifiers in the following order:
- * {@code abstract}, {@code static}, {@code final},
+ * {@code abstract}, {@code default}, {@code static}, {@code final},
* {@code synchronized}, {@code native}, {@code strictfp}.
*
* @return a string describing this {@code Method},
* include type parameters
*
* @since 1.5
+ *
+ * @jls 8.4.3 Method Modifiers
*/
@Override
public String toGenericString() {
- return sharedToGenericString(Modifier.methodModifiers());
+ return sharedToGenericString(Modifier.methodModifiers(), isDefault());
}
@Override
void specificToGenericStringHeader(StringBuilder sb) {
Type genRetType = getGenericReturnType();
- sb.append( ((genRetType instanceof Class<?>)?
- Field.getTypeName((Class<?>)genRetType):genRetType.toString()))
- .append(' ');
-
- sb.append(Field.getTypeName(getDeclaringClass())).append('.');
+ sb.append(genRetType.getTypeName()).append(' ');
+ sb.append(getDeclaringClass().getTypeName()).append('.');
sb.append(getName());
}
@@ -522,16 +525,19 @@
* 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
diff --git a/src/share/classes/java/lang/reflect/Modifier.java b/src/share/classes/java/lang/reflect/Modifier.java
index 8c2b2cc..227beee 100644
--- a/src/share/classes/java/lang/reflect/Modifier.java
+++ b/src/share/classes/java/lang/reflect/Modifier.java
@@ -43,8 +43,7 @@
* @author Nakul Saraiya
* @author Kenneth Russell
*/
-public
-class Modifier {
+public class Modifier {
/*
* Bootstrapping protocol between java.lang and java.lang.reflect
@@ -233,7 +232,7 @@
* represented by {@code mod}
*/
public static String toString(int mod) {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
int len;
if ((mod & PUBLIC) != 0) sb.append("public ");
@@ -390,6 +389,12 @@
Modifier.VOLATILE;
/**
+ *
+ */
+ static final int ACCESS_MODIFIERS =
+ Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
+
+ /**
* Return an {@code int} value OR-ing together the source language
* modifiers that can be applied to a class.
* @return an {@code int} value OR-ing together the source language
diff --git a/src/share/classes/java/lang/reflect/Parameter.java b/src/share/classes/java/lang/reflect/Parameter.java
index e479bfd..af10431 100644
--- a/src/share/classes/java/lang/reflect/Parameter.java
+++ b/src/share/classes/java/lang/reflect/Parameter.java
@@ -110,21 +110,19 @@
public String toString() {
final StringBuilder sb = new StringBuilder();
final Type type = getParameterizedType();
- final String typename = (type instanceof Class)?
- Field.getTypeName((Class)type):
- (type.toString());
+ final String typename = type.getTypeName();
sb.append(Modifier.toString(getModifiers()));
if(0 != modifiers)
- sb.append(" ");
+ sb.append(' ');
if(isVarArgs())
sb.append(typename.replaceFirst("\\[\\]$", "..."));
else
sb.append(typename);
- sb.append(" ");
+ sb.append(' ');
sb.append(getName());
return sb.toString();
diff --git a/src/share/classes/java/lang/reflect/Type.java b/src/share/classes/java/lang/reflect/Type.java
index 76b40d6..ecd3527 100644
--- a/src/share/classes/java/lang/reflect/Type.java
+++ b/src/share/classes/java/lang/reflect/Type.java
@@ -32,6 +32,17 @@
*
* @since 1.5
*/
-
public interface Type {
+ /**
+ * Returns a string describing this type, including information
+ * about any type parameters.
+ *
+ * @implSpec The default implementation calls {@code toString}.
+ *
+ * @return a string describing this type
+ * @since 1.8
+ */
+ default String getTypeName() {
+ return toString();
+ }
}
diff --git a/src/share/classes/java/util/Base64.java b/src/share/classes/java/util/Base64.java
index 88b1740..92b9cb0 100644
--- a/src/share/classes/java/util/Base64.java
+++ b/src/share/classes/java/util/Base64.java
@@ -620,7 +620,10 @@
* required. So if the final unit of the encoded byte data only has
* two or three Base64 characters (without the corresponding padding
* character(s) padded), they are decoded as if followed by padding
- * character(s).
+ * character(s). If there is padding character present in the
+ * final unit, the correct number of padding character(s) must be
+ * present, otherwise {@code IllegalArgumentException} is thrown
+ * during decoding.
*
* <p> Instances of {@link Decoder} class are safe for use by
* multiple concurrent threads.
@@ -1034,23 +1037,26 @@
throw new IllegalArgumentException(
"Input byte[] should at least have 2 bytes for base64 bytes");
}
- if (src[sl - 1] == '=') {
- paddings++;
- if (src[sl - 2] == '=')
- paddings++;
- }
if (isMIME) {
// scan all bytes to fill out all non-alphabet. a performance
// trade-off of pre-scan or Arrays.copyOf
int n = 0;
while (sp < sl) {
int b = src[sp++] & 0xff;
- if (b == '=')
+ if (b == '=') {
+ len -= (sl - sp + 1);
break;
+ }
if ((b = base64[b]) == -1)
n++;
}
len -= n;
+ } else {
+ if (src[sl - 1] == '=') {
+ paddings++;
+ if (src[sl - 2] == '=')
+ paddings++;
+ }
}
if (paddings == 0 && (len & 0x3) != 0)
paddings = 4 - (len & 0x3);
diff --git a/src/share/classes/java/util/Calendar.java b/src/share/classes/java/util/Calendar.java
index c57f50c..19c3c85 100644
--- a/src/share/classes/java/util/Calendar.java
+++ b/src/share/classes/java/util/Calendar.java
@@ -57,6 +57,8 @@
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 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 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 @@
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()) {
diff --git a/src/share/classes/java/util/LocaleISOData.java b/src/share/classes/java/util/LocaleISOData.java
index 170fef6..9470c65 100644
--- a/src/share/classes/java/util/LocaleISOData.java
+++ b/src/share/classes/java/util/LocaleISOData.java
@@ -404,7 +404,7 @@
+ "PG" + "PNG" // Papua New Guinea
+ "PH" + "PHL" // Philippines, Republic of the
+ "PK" + "PAK" // Pakistan, Islamic Republic of
- + "PL" + "POL" // Poland, Polish People's Republic
+ + "PL" + "POL" // Poland, Republic of Poland
+ "PM" + "SPM" // St. Pierre and Miquelon
+ "PN" + "PCN" // Pitcairn Island
+ "PR" + "PRI" // Puerto Rico
diff --git a/src/share/classes/java/util/Optional.java b/src/share/classes/java/util/Optional.java
new file mode 100644
index 0000000..b51a4d2
--- /dev/null
+++ b/src/share/classes/java/util/Optional.java
@@ -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";
+ }
+}
diff --git a/src/share/classes/java/util/OptionalDouble.java b/src/share/classes/java/util/OptionalDouble.java
new file mode 100644
index 0000000..118a4b8
--- /dev/null
+++ b/src/share/classes/java/util/OptionalDouble.java
@@ -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";
+ }
+}
diff --git a/src/share/classes/java/util/OptionalInt.java b/src/share/classes/java/util/OptionalInt.java
new file mode 100644
index 0000000..755c287
--- /dev/null
+++ b/src/share/classes/java/util/OptionalInt.java
@@ -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";
+ }
+}
diff --git a/src/share/classes/java/util/OptionalLong.java b/src/share/classes/java/util/OptionalLong.java
new file mode 100644
index 0000000..fbb1661
--- /dev/null
+++ b/src/share/classes/java/util/OptionalLong.java
@@ -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";
+ }
+}
diff --git a/src/share/classes/java/util/concurrent/CompletableFuture.java b/src/share/classes/java/util/concurrent/CompletableFuture.java
new file mode 100644
index 0000000..dfcba20
--- /dev/null
+++ b/src/share/classes/java/util/concurrent/CompletableFuture.java
@@ -0,0 +1,3305 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+package java.util.concurrent;
+import java.util.function.Supplier;
+import java.util.function.Consumer;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.function.BiFunction;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ForkJoinTask;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.LockSupport;
+
+/**
+ * A {@link Future} that may be explicitly completed (setting its
+ * value and status), and may include dependent functions and actions
+ * that trigger upon its completion.
+ *
+ * <p>When two or more threads attempt to
+ * {@link #complete complete},
+ * {@link #completeExceptionally completeExceptionally}, or
+ * {@link #cancel cancel}
+ * a CompletableFuture, only one of them succeeds.
+ *
+ * <p>Methods are available for adding dependents based on
+ * user-provided Functions, Consumers, or Runnables. The appropriate
+ * form to use depends on whether actions require arguments and/or
+ * produce results. Completion of a dependent action will trigger the
+ * completion of another CompletableFuture. Actions may also be
+ * triggered after either or both the current and another
+ * CompletableFuture complete. Multiple CompletableFutures may also
+ * be grouped as one using {@link #anyOf(CompletableFuture...)} and
+ * {@link #allOf(CompletableFuture...)}.
+ *
+ * <p>CompletableFutures themselves do not execute asynchronously.
+ * However, actions supplied for dependent completions of another
+ * CompletableFuture may do so, depending on whether they are provided
+ * via one of the <em>async</em> methods (that is, methods with names
+ * of the form <tt><var>xxx</var>Async</tt>). The <em>async</em>
+ * methods provide a way to commence asynchronous processing of an
+ * action using either a given {@link Executor} or by default the
+ * {@link ForkJoinPool#commonPool()}. To simplify monitoring,
+ * debugging, and tracking, all generated asynchronous tasks are
+ * instances of the marker interface {@link AsynchronousCompletionTask}.
+ *
+ * <p>Actions supplied for dependent completions of <em>non-async</em>
+ * methods may be performed by the thread that completes the current
+ * CompletableFuture, or by any other caller of these methods. There
+ * are no guarantees about the order of processing completions unless
+ * constrained by these methods.
+ *
+ * <p>Since (unlike {@link FutureTask}) this class has no direct
+ * control over the computation that causes it to be completed,
+ * cancellation is treated as just another form of exceptional completion.
+ * Method {@link #cancel cancel} has the same effect as
+ * {@code completeExceptionally(new CancellationException())}.
+ *
+ * <p>Upon exceptional completion (including cancellation), or when a
+ * completion entails an additional computation which terminates
+ * abruptly with an (unchecked) exception or error, then all of their
+ * dependent completions (and their dependents in turn) generally act
+ * as {@code completeExceptionally} with a {@link CompletionException}
+ * holding that exception as its cause. However, the {@link
+ * #exceptionally exceptionally} and {@link #handle handle}
+ * completions <em>are</em> able to handle exceptional completions of
+ * the CompletableFutures they depend on.
+ *
+ * <p>In case of exceptional completion with a CompletionException,
+ * methods {@link #get()} and {@link #get(long, TimeUnit)} throw an
+ * {@link ExecutionException} with the same cause as held in the
+ * corresponding CompletionException. However, in these cases,
+ * methods {@link #join()} and {@link #getNow} throw the
+ * CompletionException, which simplifies usage.
+ *
+ * <p>Arguments used to pass a completion result (that is, for parameters
+ * of type {@code T}) may be null, but passing a null value for any other
+ * parameter will result in a {@link NullPointerException} being thrown.
+ *
+ * @author Doug Lea
+ * @since 1.8
+ */
+public class CompletableFuture<T> implements Future<T> {
+
+ /*
+ * Overview:
+ *
+ * 1. Non-nullness of field result (set via CAS) indicates done.
+ * An AltResult is used to box null as a result, as well as to
+ * hold exceptions. Using a single field makes completion fast
+ * and simple to detect and trigger, at the expense of a lot of
+ * encoding and decoding that infiltrates many methods. One minor
+ * simplification relies on the (static) NIL (to box null results)
+ * being the only AltResult with a null exception field, so we
+ * don't usually need explicit comparisons with NIL. The CF
+ * exception propagation mechanics surrounding decoding rely on
+ * unchecked casts of decoded results really being unchecked,
+ * where user type errors are caught at point of use, as is
+ * currently the case in Java. These are highlighted by using
+ * SuppressWarnings-annotated temporaries.
+ *
+ * 2. Waiters are held in a Treiber stack similar to the one used
+ * in FutureTask, Phaser, and SynchronousQueue. See their
+ * internal documentation for algorithmic details.
+ *
+ * 3. Completions are also kept in a list/stack, and pulled off
+ * and run when completion is triggered. (We could even use the
+ * same stack as for waiters, but would give up the potential
+ * parallelism obtained because woken waiters help release/run
+ * others -- see method postComplete). Because post-processing
+ * may race with direct calls, class Completion opportunistically
+ * extends AtomicInteger so callers can claim the action via
+ * compareAndSet(0, 1). The Completion.run methods are all
+ * written a boringly similar uniform way (that sometimes includes
+ * unnecessary-looking checks, kept to maintain uniformity).
+ * There are enough dimensions upon which they differ that
+ * attempts to factor commonalities while maintaining efficiency
+ * require more lines of code than they would save.
+ *
+ * 4. The exported then/and/or methods do support a bit of
+ * factoring (see doThenApply etc). They must cope with the
+ * intrinsic races surrounding addition of a dependent action
+ * versus performing the action directly because the task is
+ * already complete. For example, a CF may not be complete upon
+ * entry, so a dependent completion is added, but by the time it
+ * is added, the target CF is complete, so must be directly
+ * executed. This is all done while avoiding unnecessary object
+ * construction in safe-bypass cases.
+ */
+
+ // preliminaries
+
+ static final class AltResult {
+ final Throwable ex; // null only for NIL
+ AltResult(Throwable ex) { this.ex = ex; }
+ }
+
+ static final AltResult NIL = new AltResult(null);
+
+ // Fields
+
+ volatile Object result; // Either the result or boxed AltResult
+ volatile WaitNode waiters; // Treiber stack of threads blocked on get()
+ volatile CompletionNode completions; // list (Treiber stack) of completions
+
+ // Basic utilities for triggering and processing completions
+
+ /**
+ * Removes and signals all waiting threads and runs all completions.
+ */
+ final void postComplete() {
+ WaitNode q; Thread t;
+ while ((q = waiters) != null) {
+ if (UNSAFE.compareAndSwapObject(this, WAITERS, q, q.next) &&
+ (t = q.thread) != null) {
+ q.thread = null;
+ LockSupport.unpark(t);
+ }
+ }
+
+ CompletionNode h; Completion c;
+ while ((h = completions) != null) {
+ if (UNSAFE.compareAndSwapObject(this, COMPLETIONS, h, h.next) &&
+ (c = h.completion) != null)
+ c.run();
+ }
+ }
+
+ /**
+ * Triggers completion with the encoding of the given arguments:
+ * if the exception is non-null, encodes it as a wrapped
+ * CompletionException unless it is one already. Otherwise uses
+ * the given result, boxed as NIL if null.
+ */
+ final void internalComplete(T v, Throwable ex) {
+ if (result == null)
+ UNSAFE.compareAndSwapObject
+ (this, RESULT, null,
+ (ex == null) ? (v == null) ? NIL : v :
+ new AltResult((ex instanceof CompletionException) ? ex :
+ new CompletionException(ex)));
+ postComplete(); // help out even if not triggered
+ }
+
+ /**
+ * If triggered, helps release and/or process completions.
+ */
+ final void helpPostComplete() {
+ if (result != null)
+ postComplete();
+ }
+
+ /* ------------- waiting for completions -------------- */
+
+ /** Number of processors, for spin control */
+ static final int NCPU = Runtime.getRuntime().availableProcessors();
+
+ /**
+ * Heuristic spin value for waitingGet() before blocking on
+ * multiprocessors
+ */
+ static final int SPINS = (NCPU > 1) ? 1 << 8 : 0;
+
+ /**
+ * Linked nodes to record waiting threads in a Treiber stack. See
+ * other classes such as Phaser and SynchronousQueue for more
+ * detailed explanation. This class implements ManagedBlocker to
+ * avoid starvation when blocking actions pile up in
+ * ForkJoinPools.
+ */
+ static final class WaitNode implements ForkJoinPool.ManagedBlocker {
+ long nanos; // wait time if timed
+ final long deadline; // non-zero if timed
+ volatile int interruptControl; // > 0: interruptible, < 0: interrupted
+ volatile Thread thread;
+ volatile WaitNode next;
+ WaitNode(boolean interruptible, long nanos, long deadline) {
+ this.thread = Thread.currentThread();
+ this.interruptControl = interruptible ? 1 : 0;
+ this.nanos = nanos;
+ this.deadline = deadline;
+ }
+ public boolean isReleasable() {
+ if (thread == null)
+ return true;
+ if (Thread.interrupted()) {
+ int i = interruptControl;
+ interruptControl = -1;
+ if (i > 0)
+ return true;
+ }
+ if (deadline != 0L &&
+ (nanos <= 0L || (nanos = deadline - System.nanoTime()) <= 0L)) {
+ thread = null;
+ return true;
+ }
+ return false;
+ }
+ public boolean block() {
+ if (isReleasable())
+ return true;
+ else if (deadline == 0L)
+ LockSupport.park(this);
+ else if (nanos > 0L)
+ LockSupport.parkNanos(this, nanos);
+ return isReleasable();
+ }
+ }
+
+ /**
+ * Returns raw result after waiting, or null if interruptible and
+ * interrupted.
+ */
+ private Object waitingGet(boolean interruptible) {
+ WaitNode q = null;
+ boolean queued = false;
+ int spins = SPINS;
+ for (Object r;;) {
+ if ((r = result) != null) {
+ if (q != null) { // suppress unpark
+ q.thread = null;
+ if (q.interruptControl < 0) {
+ if (interruptible) {
+ removeWaiter(q);
+ return null;
+ }
+ Thread.currentThread().interrupt();
+ }
+ }
+ postComplete(); // help release others
+ return r;
+ }
+ else if (spins > 0) {
+ int rnd = ThreadLocalRandom.nextSecondarySeed();
+ if (rnd == 0)
+ rnd = ThreadLocalRandom.current().nextInt();
+ if (rnd >= 0)
+ --spins;
+ }
+ else if (q == null)
+ q = new WaitNode(interruptible, 0L, 0L);
+ else if (!queued)
+ queued = UNSAFE.compareAndSwapObject(this, WAITERS,
+ q.next = waiters, q);
+ else if (interruptible && q.interruptControl < 0) {
+ removeWaiter(q);
+ return null;
+ }
+ else if (q.thread != null && result == null) {
+ try {
+ ForkJoinPool.managedBlock(q);
+ } catch (InterruptedException ex) {
+ q.interruptControl = -1;
+ }
+ }
+ }
+ }
+
+ /**
+ * Awaits completion or aborts on interrupt or timeout.
+ *
+ * @param nanos time to wait
+ * @return raw result
+ */
+ private Object timedAwaitDone(long nanos)
+ throws InterruptedException, TimeoutException {
+ WaitNode q = null;
+ boolean queued = false;
+ for (Object r;;) {
+ if ((r = result) != null) {
+ if (q != null) {
+ q.thread = null;
+ if (q.interruptControl < 0) {
+ removeWaiter(q);
+ throw new InterruptedException();
+ }
+ }
+ postComplete();
+ return r;
+ }
+ else if (q == null) {
+ if (nanos <= 0L)
+ throw new TimeoutException();
+ long d = System.nanoTime() + nanos;
+ q = new WaitNode(true, nanos, d == 0L ? 1L : d); // avoid 0
+ }
+ else if (!queued)
+ queued = UNSAFE.compareAndSwapObject(this, WAITERS,
+ q.next = waiters, q);
+ else if (q.interruptControl < 0) {
+ removeWaiter(q);
+ throw new InterruptedException();
+ }
+ else if (q.nanos <= 0L) {
+ if (result == null) {
+ removeWaiter(q);
+ throw new TimeoutException();
+ }
+ }
+ else if (q.thread != null && result == null) {
+ try {
+ ForkJoinPool.managedBlock(q);
+ } catch (InterruptedException ex) {
+ q.interruptControl = -1;
+ }
+ }
+ }
+ }
+
+ /**
+ * Tries to unlink a timed-out or interrupted wait node to avoid
+ * accumulating garbage. Internal nodes are simply unspliced
+ * without CAS since it is harmless if they are traversed anyway
+ * by releasers. To avoid effects of unsplicing from already
+ * removed nodes, the list is retraversed in case of an apparent
+ * race. This is slow when there are a lot of nodes, but we don't
+ * expect lists to be long enough to outweigh higher-overhead
+ * schemes.
+ */
+ private void removeWaiter(WaitNode node) {
+ if (node != null) {
+ node.thread = null;
+ retry:
+ for (;;) { // restart on removeWaiter race
+ for (WaitNode pred = null, q = waiters, s; q != null; q = s) {
+ s = q.next;
+ if (q.thread != null)
+ pred = q;
+ else if (pred != null) {
+ pred.next = s;
+ if (pred.thread == null) // check for race
+ continue retry;
+ }
+ else if (!UNSAFE.compareAndSwapObject(this, WAITERS, q, s))
+ continue retry;
+ }
+ break;
+ }
+ }
+ }
+
+ /* ------------- Async tasks -------------- */
+
+ /**
+ * A marker interface identifying asynchronous tasks produced by
+ * {@code async} methods. This may be useful for monitoring,
+ * debugging, and tracking asynchronous activities.
+ *
+ * @since 1.8
+ */
+ public static interface AsynchronousCompletionTask {
+ }
+
+ /** Base class can act as either FJ or plain Runnable */
+ abstract static class Async extends ForkJoinTask<Void>
+ implements Runnable, AsynchronousCompletionTask {
+ public final Void getRawResult() { return null; }
+ public final void setRawResult(Void v) { }
+ public final void run() { exec(); }
+ }
+
+ static final class AsyncRun extends Async {
+ final Runnable fn;
+ final CompletableFuture<Void> dst;
+ AsyncRun(Runnable fn, CompletableFuture<Void> dst) {
+ this.fn = fn; this.dst = dst;
+ }
+ public final boolean exec() {
+ CompletableFuture<Void> d; Throwable ex;
+ if ((d = this.dst) != null && d.result == null) {
+ try {
+ fn.run();
+ ex = null;
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ d.internalComplete(null, ex);
+ }
+ return true;
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class AsyncSupply<U> extends Async {
+ final Supplier<U> fn;
+ final CompletableFuture<U> dst;
+ AsyncSupply(Supplier<U> fn, CompletableFuture<U> dst) {
+ this.fn = fn; this.dst = dst;
+ }
+ public final boolean exec() {
+ CompletableFuture<U> d; U u; Throwable ex;
+ if ((d = this.dst) != null && d.result == null) {
+ try {
+ u = fn.get();
+ ex = null;
+ } catch (Throwable rex) {
+ ex = rex;
+ u = null;
+ }
+ d.internalComplete(u, ex);
+ }
+ return true;
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class AsyncApply<T,U> extends Async {
+ final T arg;
+ final Function<? super T,? extends U> fn;
+ final CompletableFuture<U> dst;
+ AsyncApply(T arg, Function<? super T,? extends U> fn,
+ CompletableFuture<U> dst) {
+ this.arg = arg; this.fn = fn; this.dst = dst;
+ }
+ public final boolean exec() {
+ CompletableFuture<U> d; U u; Throwable ex;
+ if ((d = this.dst) != null && d.result == null) {
+ try {
+ u = fn.apply(arg);
+ ex = null;
+ } catch (Throwable rex) {
+ ex = rex;
+ u = null;
+ }
+ d.internalComplete(u, ex);
+ }
+ return true;
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class AsyncCombine<T,U,V> extends Async {
+ final T arg1;
+ final U arg2;
+ final BiFunction<? super T,? super U,? extends V> fn;
+ final CompletableFuture<V> dst;
+ AsyncCombine(T arg1, U arg2,
+ BiFunction<? super T,? super U,? extends V> fn,
+ CompletableFuture<V> dst) {
+ this.arg1 = arg1; this.arg2 = arg2; this.fn = fn; this.dst = dst;
+ }
+ public final boolean exec() {
+ CompletableFuture<V> d; V v; Throwable ex;
+ if ((d = this.dst) != null && d.result == null) {
+ try {
+ v = fn.apply(arg1, arg2);
+ ex = null;
+ } catch (Throwable rex) {
+ ex = rex;
+ v = null;
+ }
+ d.internalComplete(v, ex);
+ }
+ return true;
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class AsyncAccept<T> extends Async {
+ final T arg;
+ final Consumer<? super T> fn;
+ final CompletableFuture<Void> dst;
+ AsyncAccept(T arg, Consumer<? super T> fn,
+ CompletableFuture<Void> dst) {
+ this.arg = arg; this.fn = fn; this.dst = dst;
+ }
+ public final boolean exec() {
+ CompletableFuture<Void> d; Throwable ex;
+ if ((d = this.dst) != null && d.result == null) {
+ try {
+ fn.accept(arg);
+ ex = null;
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ d.internalComplete(null, ex);
+ }
+ return true;
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class AsyncAcceptBoth<T,U> extends Async {
+ final T arg1;
+ final U arg2;
+ final BiConsumer<? super T,? super U> fn;
+ final CompletableFuture<Void> dst;
+ AsyncAcceptBoth(T arg1, U arg2,
+ BiConsumer<? super T,? super U> fn,
+ CompletableFuture<Void> dst) {
+ this.arg1 = arg1; this.arg2 = arg2; this.fn = fn; this.dst = dst;
+ }
+ public final boolean exec() {
+ CompletableFuture<Void> d; Throwable ex;
+ if ((d = this.dst) != null && d.result == null) {
+ try {
+ fn.accept(arg1, arg2);
+ ex = null;
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ d.internalComplete(null, ex);
+ }
+ return true;
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class AsyncCompose<T,U> extends Async {
+ final T arg;
+ final Function<? super T, CompletableFuture<U>> fn;
+ final CompletableFuture<U> dst;
+ AsyncCompose(T arg,
+ Function<? super T, CompletableFuture<U>> fn,
+ CompletableFuture<U> dst) {
+ this.arg = arg; this.fn = fn; this.dst = dst;
+ }
+ public final boolean exec() {
+ CompletableFuture<U> d, fr; U u; Throwable ex;
+ if ((d = this.dst) != null && d.result == null) {
+ try {
+ fr = fn.apply(arg);
+ ex = (fr == null) ? new NullPointerException() : null;
+ } catch (Throwable rex) {
+ ex = rex;
+ fr = null;
+ }
+ if (ex != null)
+ u = null;
+ else {
+ Object r = fr.result;
+ if (r == null)
+ r = fr.waitingGet(false);
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ u = null;
+ }
+ else {
+ @SuppressWarnings("unchecked") U ur = (U) r;
+ u = ur;
+ }
+ }
+ d.internalComplete(u, ex);
+ }
+ return true;
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ /* ------------- Completions -------------- */
+
+ /**
+ * Simple linked list nodes to record completions, used in
+ * basically the same way as WaitNodes. (We separate nodes from
+ * the Completions themselves mainly because for the And and Or
+ * methods, the same Completion object resides in two lists.)
+ */
+ static final class CompletionNode {
+ final Completion completion;
+ volatile CompletionNode next;
+ CompletionNode(Completion completion) { this.completion = completion; }
+ }
+
+ // Opportunistically subclass AtomicInteger to use compareAndSet to claim.
+ abstract static class Completion extends AtomicInteger implements Runnable {
+ }
+
+ static final class ThenApply<T,U> extends Completion {
+ final CompletableFuture<? extends T> src;
+ final Function<? super T,? extends U> fn;
+ final CompletableFuture<U> dst;
+ final Executor executor;
+ ThenApply(CompletableFuture<? extends T> src,
+ Function<? super T,? extends U> fn,
+ CompletableFuture<U> dst,
+ Executor executor) {
+ this.src = src; this.fn = fn; this.dst = dst;
+ this.executor = executor;
+ }
+ public final void run() {
+ final CompletableFuture<? extends T> a;
+ final Function<? super T,? extends U> fn;
+ final CompletableFuture<U> dst;
+ Object r; T t; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ Executor e = executor;
+ U u = null;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncApply<T,U>(t, fn, dst));
+ else
+ u = fn.apply(t);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(u, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class ThenAccept<T> extends Completion {
+ final CompletableFuture<? extends T> src;
+ final Consumer<? super T> fn;
+ final CompletableFuture<Void> dst;
+ final Executor executor;
+ ThenAccept(CompletableFuture<? extends T> src,
+ Consumer<? super T> fn,
+ CompletableFuture<Void> dst,
+ Executor executor) {
+ this.src = src; this.fn = fn; this.dst = dst;
+ this.executor = executor;
+ }
+ public final void run() {
+ final CompletableFuture<? extends T> a;
+ final Consumer<? super T> fn;
+ final CompletableFuture<Void> dst;
+ Object r; T t; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ Executor e = executor;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncAccept<T>(t, fn, dst));
+ else
+ fn.accept(t);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class ThenRun extends Completion {
+ final CompletableFuture<?> src;
+ final Runnable fn;
+ final CompletableFuture<Void> dst;
+ final Executor executor;
+ ThenRun(CompletableFuture<?> src,
+ Runnable fn,
+ CompletableFuture<Void> dst,
+ Executor executor) {
+ this.src = src; this.fn = fn; this.dst = dst;
+ this.executor = executor;
+ }
+ public final void run() {
+ final CompletableFuture<?> a;
+ final Runnable fn;
+ final CompletableFuture<Void> dst;
+ Object r; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult)
+ ex = ((AltResult)r).ex;
+ else
+ ex = null;
+ Executor e = executor;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncRun(fn, dst));
+ else
+ fn.run();
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class ThenCombine<T,U,V> extends Completion {
+ final CompletableFuture<? extends T> src;
+ final CompletableFuture<? extends U> snd;
+ final BiFunction<? super T,? super U,? extends V> fn;
+ final CompletableFuture<V> dst;
+ final Executor executor;
+ ThenCombine(CompletableFuture<? extends T> src,
+ CompletableFuture<? extends U> snd,
+ BiFunction<? super T,? super U,? extends V> fn,
+ CompletableFuture<V> dst,
+ Executor executor) {
+ this.src = src; this.snd = snd;
+ this.fn = fn; this.dst = dst;
+ this.executor = executor;
+ }
+ public final void run() {
+ final CompletableFuture<? extends T> a;
+ final CompletableFuture<? extends U> b;
+ final BiFunction<? super T,? super U,? extends V> fn;
+ final CompletableFuture<V> dst;
+ Object r, s; T t; U u; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ (b = this.snd) != null &&
+ (s = b.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ if (ex != null)
+ u = null;
+ else if (s instanceof AltResult) {
+ ex = ((AltResult)s).ex;
+ u = null;
+ }
+ else {
+ @SuppressWarnings("unchecked") U us = (U) s;
+ u = us;
+ }
+ Executor e = executor;
+ V v = null;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncCombine<T,U,V>(t, u, fn, dst));
+ else
+ v = fn.apply(t, u);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(v, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class ThenAcceptBoth<T,U> extends Completion {
+ final CompletableFuture<? extends T> src;
+ final CompletableFuture<? extends U> snd;
+ final BiConsumer<? super T,? super U> fn;
+ final CompletableFuture<Void> dst;
+ final Executor executor;
+ ThenAcceptBoth(CompletableFuture<? extends T> src,
+ CompletableFuture<? extends U> snd,
+ BiConsumer<? super T,? super U> fn,
+ CompletableFuture<Void> dst,
+ Executor executor) {
+ this.src = src; this.snd = snd;
+ this.fn = fn; this.dst = dst;
+ this.executor = executor;
+ }
+ public final void run() {
+ final CompletableFuture<? extends T> a;
+ final CompletableFuture<? extends U> b;
+ final BiConsumer<? super T,? super U> fn;
+ final CompletableFuture<Void> dst;
+ Object r, s; T t; U u; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ (b = this.snd) != null &&
+ (s = b.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ if (ex != null)
+ u = null;
+ else if (s instanceof AltResult) {
+ ex = ((AltResult)s).ex;
+ u = null;
+ }
+ else {
+ @SuppressWarnings("unchecked") U us = (U) s;
+ u = us;
+ }
+ Executor e = executor;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncAcceptBoth<T,U>(t, u, fn, dst));
+ else
+ fn.accept(t, u);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class RunAfterBoth extends Completion {
+ final CompletableFuture<?> src;
+ final CompletableFuture<?> snd;
+ final Runnable fn;
+ final CompletableFuture<Void> dst;
+ final Executor executor;
+ RunAfterBoth(CompletableFuture<?> src,
+ CompletableFuture<?> snd,
+ Runnable fn,
+ CompletableFuture<Void> dst,
+ Executor executor) {
+ this.src = src; this.snd = snd;
+ this.fn = fn; this.dst = dst;
+ this.executor = executor;
+ }
+ public final void run() {
+ final CompletableFuture<?> a;
+ final CompletableFuture<?> b;
+ final Runnable fn;
+ final CompletableFuture<Void> dst;
+ Object r, s; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ (b = this.snd) != null &&
+ (s = b.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult)
+ ex = ((AltResult)r).ex;
+ else
+ ex = null;
+ if (ex == null && (s instanceof AltResult))
+ ex = ((AltResult)s).ex;
+ Executor e = executor;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncRun(fn, dst));
+ else
+ fn.run();
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class AndCompletion extends Completion {
+ final CompletableFuture<?> src;
+ final CompletableFuture<?> snd;
+ final CompletableFuture<Void> dst;
+ AndCompletion(CompletableFuture<?> src,
+ CompletableFuture<?> snd,
+ CompletableFuture<Void> dst) {
+ this.src = src; this.snd = snd; this.dst = dst;
+ }
+ public final void run() {
+ final CompletableFuture<?> a;
+ final CompletableFuture<?> b;
+ final CompletableFuture<Void> dst;
+ Object r, s; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ (b = this.snd) != null &&
+ (s = b.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult)
+ ex = ((AltResult)r).ex;
+ else
+ ex = null;
+ if (ex == null && (s instanceof AltResult))
+ ex = ((AltResult)s).ex;
+ dst.internalComplete(null, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class ApplyToEither<T,U> extends Completion {
+ final CompletableFuture<? extends T> src;
+ final CompletableFuture<? extends T> snd;
+ final Function<? super T,? extends U> fn;
+ final CompletableFuture<U> dst;
+ final Executor executor;
+ ApplyToEither(CompletableFuture<? extends T> src,
+ CompletableFuture<? extends T> snd,
+ Function<? super T,? extends U> fn,
+ CompletableFuture<U> dst,
+ Executor executor) {
+ this.src = src; this.snd = snd;
+ this.fn = fn; this.dst = dst;
+ this.executor = executor;
+ }
+ public final void run() {
+ final CompletableFuture<? extends T> a;
+ final CompletableFuture<? extends T> b;
+ final Function<? super T,? extends U> fn;
+ final CompletableFuture<U> dst;
+ Object r; T t; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (((a = this.src) != null && (r = a.result) != null) ||
+ ((b = this.snd) != null && (r = b.result) != null)) &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ Executor e = executor;
+ U u = null;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncApply<T,U>(t, fn, dst));
+ else
+ u = fn.apply(t);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(u, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class AcceptEither<T> extends Completion {
+ final CompletableFuture<? extends T> src;
+ final CompletableFuture<? extends T> snd;
+ final Consumer<? super T> fn;
+ final CompletableFuture<Void> dst;
+ final Executor executor;
+ AcceptEither(CompletableFuture<? extends T> src,
+ CompletableFuture<? extends T> snd,
+ Consumer<? super T> fn,
+ CompletableFuture<Void> dst,
+ Executor executor) {
+ this.src = src; this.snd = snd;
+ this.fn = fn; this.dst = dst;
+ this.executor = executor;
+ }
+ public final void run() {
+ final CompletableFuture<? extends T> a;
+ final CompletableFuture<? extends T> b;
+ final Consumer<? super T> fn;
+ final CompletableFuture<Void> dst;
+ Object r; T t; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (((a = this.src) != null && (r = a.result) != null) ||
+ ((b = this.snd) != null && (r = b.result) != null)) &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ Executor e = executor;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncAccept<T>(t, fn, dst));
+ else
+ fn.accept(t);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class RunAfterEither extends Completion {
+ final CompletableFuture<?> src;
+ final CompletableFuture<?> snd;
+ final Runnable fn;
+ final CompletableFuture<Void> dst;
+ final Executor executor;
+ RunAfterEither(CompletableFuture<?> src,
+ CompletableFuture<?> snd,
+ Runnable fn,
+ CompletableFuture<Void> dst,
+ Executor executor) {
+ this.src = src; this.snd = snd;
+ this.fn = fn; this.dst = dst;
+ this.executor = executor;
+ }
+ public final void run() {
+ final CompletableFuture<?> a;
+ final CompletableFuture<?> b;
+ final Runnable fn;
+ final CompletableFuture<Void> dst;
+ Object r; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (((a = this.src) != null && (r = a.result) != null) ||
+ ((b = this.snd) != null && (r = b.result) != null)) &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult)
+ ex = ((AltResult)r).ex;
+ else
+ ex = null;
+ Executor e = executor;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncRun(fn, dst));
+ else
+ fn.run();
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class OrCompletion extends Completion {
+ final CompletableFuture<?> src;
+ final CompletableFuture<?> snd;
+ final CompletableFuture<Object> dst;
+ OrCompletion(CompletableFuture<?> src,
+ CompletableFuture<?> snd,
+ CompletableFuture<Object> dst) {
+ this.src = src; this.snd = snd; this.dst = dst;
+ }
+ public final void run() {
+ final CompletableFuture<?> a;
+ final CompletableFuture<?> b;
+ final CompletableFuture<Object> dst;
+ Object r, t; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (((a = this.src) != null && (r = a.result) != null) ||
+ ((b = this.snd) != null && (r = b.result) != null)) &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ t = r;
+ }
+ dst.internalComplete(t, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class ExceptionCompletion<T> extends Completion {
+ final CompletableFuture<? extends T> src;
+ final Function<? super Throwable, ? extends T> fn;
+ final CompletableFuture<T> dst;
+ ExceptionCompletion(CompletableFuture<? extends T> src,
+ Function<? super Throwable, ? extends T> fn,
+ CompletableFuture<T> dst) {
+ this.src = src; this.fn = fn; this.dst = dst;
+ }
+ public final void run() {
+ final CompletableFuture<? extends T> a;
+ final Function<? super Throwable, ? extends T> fn;
+ final CompletableFuture<T> dst;
+ Object r; T t = null; Throwable ex, dx = null;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ compareAndSet(0, 1)) {
+ if ((r instanceof AltResult) &&
+ (ex = ((AltResult)r).ex) != null) {
+ try {
+ t = fn.apply(ex);
+ } catch (Throwable rex) {
+ dx = rex;
+ }
+ }
+ else {
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ dst.internalComplete(t, dx);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class ThenCopy<T> extends Completion {
+ final CompletableFuture<?> src;
+ final CompletableFuture<T> dst;
+ ThenCopy(CompletableFuture<?> src,
+ CompletableFuture<T> dst) {
+ this.src = src; this.dst = dst;
+ }
+ public final void run() {
+ final CompletableFuture<?> a;
+ final CompletableFuture<T> dst;
+ Object r; T t; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ dst.internalComplete(t, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ // version of ThenCopy for CompletableFuture<Void> dst
+ static final class ThenPropagate extends Completion {
+ final CompletableFuture<?> src;
+ final CompletableFuture<Void> dst;
+ ThenPropagate(CompletableFuture<?> src,
+ CompletableFuture<Void> dst) {
+ this.src = src; this.dst = dst;
+ }
+ public final void run() {
+ final CompletableFuture<?> a;
+ final CompletableFuture<Void> dst;
+ Object r; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult)
+ ex = ((AltResult)r).ex;
+ else
+ ex = null;
+ dst.internalComplete(null, ex);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class HandleCompletion<T,U> extends Completion {
+ final CompletableFuture<? extends T> src;
+ final BiFunction<? super T, Throwable, ? extends U> fn;
+ final CompletableFuture<U> dst;
+ HandleCompletion(CompletableFuture<? extends T> src,
+ BiFunction<? super T, Throwable, ? extends U> fn,
+ CompletableFuture<U> dst) {
+ this.src = src; this.fn = fn; this.dst = dst;
+ }
+ public final void run() {
+ final CompletableFuture<? extends T> a;
+ final BiFunction<? super T, Throwable, ? extends U> fn;
+ final CompletableFuture<U> dst;
+ Object r; T t; Throwable ex;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ U u = null; Throwable dx = null;
+ try {
+ u = fn.apply(t, ex);
+ } catch (Throwable rex) {
+ dx = rex;
+ }
+ dst.internalComplete(u, dx);
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ static final class ThenCompose<T,U> extends Completion {
+ final CompletableFuture<? extends T> src;
+ final Function<? super T, CompletableFuture<U>> fn;
+ final CompletableFuture<U> dst;
+ final Executor executor;
+ ThenCompose(CompletableFuture<? extends T> src,
+ Function<? super T, CompletableFuture<U>> fn,
+ CompletableFuture<U> dst,
+ Executor executor) {
+ this.src = src; this.fn = fn; this.dst = dst;
+ this.executor = executor;
+ }
+ public final void run() {
+ final CompletableFuture<? extends T> a;
+ final Function<? super T, CompletableFuture<U>> fn;
+ final CompletableFuture<U> dst;
+ Object r; T t; Throwable ex; Executor e;
+ if ((dst = this.dst) != null &&
+ (fn = this.fn) != null &&
+ (a = this.src) != null &&
+ (r = a.result) != null &&
+ compareAndSet(0, 1)) {
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ CompletableFuture<U> c = null;
+ U u = null;
+ boolean complete = false;
+ if (ex == null) {
+ if ((e = executor) != null)
+ e.execute(new AsyncCompose<T,U>(t, fn, dst));
+ else {
+ try {
+ if ((c = fn.apply(t)) == null)
+ ex = new NullPointerException();
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ }
+ if (c != null) {
+ ThenCopy<U> d = null;
+ Object s;
+ if ((s = c.result) == null) {
+ CompletionNode p = new CompletionNode
+ (d = new ThenCopy<U>(c, dst));
+ while ((s = c.result) == null) {
+ if (UNSAFE.compareAndSwapObject
+ (c, COMPLETIONS, p.next = c.completions, p))
+ break;
+ }
+ }
+ if (s != null && (d == null || d.compareAndSet(0, 1))) {
+ complete = true;
+ if (s instanceof AltResult) {
+ ex = ((AltResult)s).ex; // no rewrap
+ u = null;
+ }
+ else {
+ @SuppressWarnings("unchecked") U us = (U) s;
+ u = us;
+ }
+ }
+ }
+ if (complete || ex != null)
+ dst.internalComplete(u, ex);
+ if (c != null)
+ c.helpPostComplete();
+ }
+ }
+ private static final long serialVersionUID = 5232453952276885070L;
+ }
+
+ // public methods
+
+ /**
+ * Creates a new incomplete CompletableFuture.
+ */
+ public CompletableFuture() {
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * by a task running in the {@link ForkJoinPool#commonPool()} with
+ * the value obtained by calling the given Supplier.
+ *
+ * @param supplier a function returning the value to be used
+ * to complete the returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier) {
+ if (supplier == null) throw new NullPointerException();
+ CompletableFuture<U> f = new CompletableFuture<U>();
+ ForkJoinPool.commonPool().
+ execute((ForkJoinTask<?>)new AsyncSupply<U>(supplier, f));
+ return f;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * by a task running in the given executor with the value obtained
+ * by calling the given Supplier.
+ *
+ * @param supplier a function returning the value to be used
+ * to complete the returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier,
+ Executor executor) {
+ if (executor == null || supplier == null)
+ throw new NullPointerException();
+ CompletableFuture<U> f = new CompletableFuture<U>();
+ executor.execute(new AsyncSupply<U>(supplier, f));
+ return f;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * by a task running in the {@link ForkJoinPool#commonPool()} after
+ * it runs the given action.
+ *
+ * @param runnable the action to run before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public static CompletableFuture<Void> runAsync(Runnable runnable) {
+ if (runnable == null) throw new NullPointerException();
+ CompletableFuture<Void> f = new CompletableFuture<Void>();
+ ForkJoinPool.commonPool().
+ execute((ForkJoinTask<?>)new AsyncRun(runnable, f));
+ return f;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * by a task running in the given executor after it runs the given
+ * action.
+ *
+ * @param runnable the action to run before completing the
+ * returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public static CompletableFuture<Void> runAsync(Runnable runnable,
+ Executor executor) {
+ if (executor == null || runnable == null)
+ throw new NullPointerException();
+ CompletableFuture<Void> f = new CompletableFuture<Void>();
+ executor.execute(new AsyncRun(runnable, f));
+ return f;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is already completed with
+ * the given value.
+ *
+ * @param value the value
+ * @return the completed CompletableFuture
+ */
+ public static <U> CompletableFuture<U> completedFuture(U value) {
+ CompletableFuture<U> f = new CompletableFuture<U>();
+ f.result = (value == null) ? NIL : value;
+ return f;
+ }
+
+ /**
+ * Returns {@code true} if completed in any fashion: normally,
+ * exceptionally, or via cancellation.
+ *
+ * @return {@code true} if completed
+ */
+ public boolean isDone() {
+ return result != null;
+ }
+
+ /**
+ * Waits if necessary for this future to complete, and then
+ * returns its result.
+ *
+ * @return the result value
+ * @throws CancellationException if this future was cancelled
+ * @throws ExecutionException if this future completed exceptionally
+ * @throws InterruptedException if the current thread was interrupted
+ * while waiting
+ */
+ public T get() throws InterruptedException, ExecutionException {
+ Object r; Throwable ex, cause;
+ if ((r = result) == null && (r = waitingGet(true)) == null)
+ throw new InterruptedException();
+ if (!(r instanceof AltResult)) {
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ return tr;
+ }
+ if ((ex = ((AltResult)r).ex) == null)
+ return null;
+ if (ex instanceof CancellationException)
+ throw (CancellationException)ex;
+ if ((ex instanceof CompletionException) &&
+ (cause = ex.getCause()) != null)
+ ex = cause;
+ throw new ExecutionException(ex);
+ }
+
+ /**
+ * Waits if necessary for at most the given time for this future
+ * to complete, and then returns its result, if available.
+ *
+ * @param timeout the maximum time to wait
+ * @param unit the time unit of the timeout argument
+ * @return the result value
+ * @throws CancellationException if this future was cancelled
+ * @throws ExecutionException if this future completed exceptionally
+ * @throws InterruptedException if the current thread was interrupted
+ * while waiting
+ * @throws TimeoutException if the wait timed out
+ */
+ public T get(long timeout, TimeUnit unit)
+ throws InterruptedException, ExecutionException, TimeoutException {
+ Object r; Throwable ex, cause;
+ long nanos = unit.toNanos(timeout);
+ if (Thread.interrupted())
+ throw new InterruptedException();
+ if ((r = result) == null)
+ r = timedAwaitDone(nanos);
+ if (!(r instanceof AltResult)) {
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ return tr;
+ }
+ if ((ex = ((AltResult)r).ex) == null)
+ return null;
+ if (ex instanceof CancellationException)
+ throw (CancellationException)ex;
+ if ((ex instanceof CompletionException) &&
+ (cause = ex.getCause()) != null)
+ ex = cause;
+ throw new ExecutionException(ex);
+ }
+
+ /**
+ * Returns the result value when complete, or throws an
+ * (unchecked) exception if completed exceptionally. To better
+ * conform with the use of common functional forms, if a
+ * computation involved in the completion of this
+ * CompletableFuture threw an exception, this method throws an
+ * (unchecked) {@link CompletionException} with the underlying
+ * exception as its cause.
+ *
+ * @return the result value
+ * @throws CancellationException if the computation was cancelled
+ * @throws CompletionException if this future completed
+ * exceptionally or a completion computation threw an exception
+ */
+ public T join() {
+ Object r; Throwable ex;
+ if ((r = result) == null)
+ r = waitingGet(false);
+ if (!(r instanceof AltResult)) {
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ return tr;
+ }
+ if ((ex = ((AltResult)r).ex) == null)
+ return null;
+ if (ex instanceof CancellationException)
+ throw (CancellationException)ex;
+ if (ex instanceof CompletionException)
+ throw (CompletionException)ex;
+ throw new CompletionException(ex);
+ }
+
+ /**
+ * Returns the result value (or throws any encountered exception)
+ * if completed, else returns the given valueIfAbsent.
+ *
+ * @param valueIfAbsent the value to return if not completed
+ * @return the result value, if completed, else the given valueIfAbsent
+ * @throws CancellationException if the computation was cancelled
+ * @throws CompletionException if this future completed
+ * exceptionally or a completion computation threw an exception
+ */
+ public T getNow(T valueIfAbsent) {
+ Object r; Throwable ex;
+ if ((r = result) == null)
+ return valueIfAbsent;
+ if (!(r instanceof AltResult)) {
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ return tr;
+ }
+ if ((ex = ((AltResult)r).ex) == null)
+ return null;
+ if (ex instanceof CancellationException)
+ throw (CancellationException)ex;
+ if (ex instanceof CompletionException)
+ throw (CompletionException)ex;
+ throw new CompletionException(ex);
+ }
+
+ /**
+ * If not already completed, sets the value returned by {@link
+ * #get()} and related methods to the given value.
+ *
+ * @param value the result value
+ * @return {@code true} if this invocation caused this CompletableFuture
+ * to transition to a completed state, else {@code false}
+ */
+ public boolean complete(T value) {
+ boolean triggered = result == null &&
+ UNSAFE.compareAndSwapObject(this, RESULT, null,
+ value == null ? NIL : value);
+ postComplete();
+ return triggered;
+ }
+
+ /**
+ * If not already completed, causes invocations of {@link #get()}
+ * and related methods to throw the given exception.
+ *
+ * @param ex the exception
+ * @return {@code true} if this invocation caused this CompletableFuture
+ * to transition to a completed state, else {@code false}
+ */
+ public boolean completeExceptionally(Throwable ex) {
+ if (ex == null) throw new NullPointerException();
+ boolean triggered = result == null &&
+ UNSAFE.compareAndSwapObject(this, RESULT, null, new AltResult(ex));
+ postComplete();
+ return triggered;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed
+ * when this CompletableFuture completes, with the result of the
+ * given function of this CompletableFuture's result.
+ *
+ * <p>If this CompletableFuture completes exceptionally, or the
+ * supplied function throws an exception, then the returned
+ * CompletableFuture completes exceptionally with a
+ * CompletionException holding the exception as its cause.
+ *
+ * @param fn the function to use to compute the value of
+ * the returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public <U> CompletableFuture<U> thenApply(Function<? super T,? extends U> fn) {
+ return doThenApply(fn, null);
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when this CompletableFuture completes, with the result of the
+ * given function of this CompletableFuture's result from a
+ * task running in the {@link ForkJoinPool#commonPool()}.
+ *
+ * <p>If this CompletableFuture completes exceptionally, or the
+ * supplied function throws an exception, then the returned
+ * CompletableFuture completes exceptionally with a
+ * CompletionException holding the exception as its cause.
+ *
+ * @param fn the function to use to compute the value of
+ * the returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public <U> CompletableFuture<U> thenApplyAsync
+ (Function<? super T,? extends U> fn) {
+ return doThenApply(fn, ForkJoinPool.commonPool());
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when this CompletableFuture completes, with the result of the
+ * given function of this CompletableFuture's result from a
+ * task running in the given executor.
+ *
+ * <p>If this CompletableFuture completes exceptionally, or the
+ * supplied function throws an exception, then the returned
+ * CompletableFuture completes exceptionally with a
+ * CompletionException holding the exception as its cause.
+ *
+ * @param fn the function to use to compute the value of
+ * the returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public <U> CompletableFuture<U> thenApplyAsync
+ (Function<? super T,? extends U> fn,
+ Executor executor) {
+ if (executor == null) throw new NullPointerException();
+ return doThenApply(fn, executor);
+ }
+
+ private <U> CompletableFuture<U> doThenApply
+ (Function<? super T,? extends U> fn,
+ Executor e) {
+ if (fn == null) throw new NullPointerException();
+ CompletableFuture<U> dst = new CompletableFuture<U>();
+ ThenApply<T,U> d = null;
+ Object r;
+ if ((r = result) == null) {
+ CompletionNode p = new CompletionNode
+ (d = new ThenApply<T,U>(this, fn, dst, e));
+ while ((r = result) == null) {
+ if (UNSAFE.compareAndSwapObject
+ (this, COMPLETIONS, p.next = completions, p))
+ break;
+ }
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1))) {
+ T t; Throwable ex;
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ U u = null;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncApply<T,U>(t, fn, dst));
+ else
+ u = fn.apply(t);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(u, ex);
+ }
+ helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed
+ * when this CompletableFuture completes, after performing the given
+ * action with this CompletableFuture's result.
+ *
+ * <p>If this CompletableFuture completes exceptionally, or the
+ * supplied action throws an exception, then the returned
+ * CompletableFuture completes exceptionally with a
+ * CompletionException holding the exception as its cause.
+ *
+ * @param block the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> thenAccept(Consumer<? super T> block) {
+ return doThenAccept(block, null);
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when this CompletableFuture completes, after performing the given
+ * action with this CompletableFuture's result from a task running
+ * in the {@link ForkJoinPool#commonPool()}.
+ *
+ * <p>If this CompletableFuture completes exceptionally, or the
+ * supplied action throws an exception, then the returned
+ * CompletableFuture completes exceptionally with a
+ * CompletionException holding the exception as its cause.
+ *
+ * @param block the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> block) {
+ return doThenAccept(block, ForkJoinPool.commonPool());
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when this CompletableFuture completes, after performing the given
+ * action with this CompletableFuture's result from a task running
+ * in the given executor.
+ *
+ * <p>If this CompletableFuture completes exceptionally, or the
+ * supplied action throws an exception, then the returned
+ * CompletableFuture completes exceptionally with a
+ * CompletionException holding the exception as its cause.
+ *
+ * @param block the action to perform before completing the
+ * returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> block,
+ Executor executor) {
+ if (executor == null) throw new NullPointerException();
+ return doThenAccept(block, executor);
+ }
+
+ private CompletableFuture<Void> doThenAccept(Consumer<? super T> fn,
+ Executor e) {
+ if (fn == null) throw new NullPointerException();
+ CompletableFuture<Void> dst = new CompletableFuture<Void>();
+ ThenAccept<T> d = null;
+ Object r;
+ if ((r = result) == null) {
+ CompletionNode p = new CompletionNode
+ (d = new ThenAccept<T>(this, fn, dst, e));
+ while ((r = result) == null) {
+ if (UNSAFE.compareAndSwapObject
+ (this, COMPLETIONS, p.next = completions, p))
+ break;
+ }
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1))) {
+ T t; Throwable ex;
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncAccept<T>(t, fn, dst));
+ else
+ fn.accept(t);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed
+ * when this CompletableFuture completes, after performing the given
+ * action.
+ *
+ * <p>If this CompletableFuture completes exceptionally, or the
+ * supplied action throws an exception, then the returned
+ * CompletableFuture completes exceptionally with a
+ * CompletionException holding the exception as its cause.
+ *
+ * @param action the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> thenRun(Runnable action) {
+ return doThenRun(action, null);
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when this CompletableFuture completes, after performing the given
+ * action from a task running in the {@link ForkJoinPool#commonPool()}.
+ *
+ * <p>If this CompletableFuture completes exceptionally, or the
+ * supplied action throws an exception, then the returned
+ * CompletableFuture completes exceptionally with a
+ * CompletionException holding the exception as its cause.
+ *
+ * @param action the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> thenRunAsync(Runnable action) {
+ return doThenRun(action, ForkJoinPool.commonPool());
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when this CompletableFuture completes, after performing the given
+ * action from a task running in the given executor.
+ *
+ * <p>If this CompletableFuture completes exceptionally, or the
+ * supplied action throws an exception, then the returned
+ * CompletableFuture completes exceptionally with a
+ * CompletionException holding the exception as its cause.
+ *
+ * @param action the action to perform before completing the
+ * returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> thenRunAsync(Runnable action,
+ Executor executor) {
+ if (executor == null) throw new NullPointerException();
+ return doThenRun(action, executor);
+ }
+
+ private CompletableFuture<Void> doThenRun(Runnable action,
+ Executor e) {
+ if (action == null) throw new NullPointerException();
+ CompletableFuture<Void> dst = new CompletableFuture<Void>();
+ ThenRun d = null;
+ Object r;
+ if ((r = result) == null) {
+ CompletionNode p = new CompletionNode
+ (d = new ThenRun(this, action, dst, e));
+ while ((r = result) == null) {
+ if (UNSAFE.compareAndSwapObject
+ (this, COMPLETIONS, p.next = completions, p))
+ break;
+ }
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1))) {
+ Throwable ex;
+ if (r instanceof AltResult)
+ ex = ((AltResult)r).ex;
+ else
+ ex = null;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncRun(action, dst));
+ else
+ action.run();
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed
+ * when both this and the other given CompletableFuture complete,
+ * with the result of the given function of the results of the two
+ * CompletableFutures.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, or the supplied function throws an exception,
+ * then the returned CompletableFuture completes exceptionally
+ * with a CompletionException holding the exception as its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param fn the function to use to compute the value of
+ * the returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public <U,V> CompletableFuture<V> thenCombine
+ (CompletableFuture<? extends U> other,
+ BiFunction<? super T,? super U,? extends V> fn) {
+ return doThenCombine(other, fn, null);
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when both this and the other given CompletableFuture complete,
+ * with the result of the given function of the results of the two
+ * CompletableFutures from a task running in the
+ * {@link ForkJoinPool#commonPool()}.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, or the supplied function throws an exception,
+ * then the returned CompletableFuture completes exceptionally
+ * with a CompletionException holding the exception as its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param fn the function to use to compute the value of
+ * the returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public <U,V> CompletableFuture<V> thenCombineAsync
+ (CompletableFuture<? extends U> other,
+ BiFunction<? super T,? super U,? extends V> fn) {
+ return doThenCombine(other, fn, ForkJoinPool.commonPool());
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when both this and the other given CompletableFuture complete,
+ * with the result of the given function of the results of the two
+ * CompletableFutures from a task running in the given executor.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, or the supplied function throws an exception,
+ * then the returned CompletableFuture completes exceptionally
+ * with a CompletionException holding the exception as its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param fn the function to use to compute the value of
+ * the returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public <U,V> CompletableFuture<V> thenCombineAsync
+ (CompletableFuture<? extends U> other,
+ BiFunction<? super T,? super U,? extends V> fn,
+ Executor executor) {
+ if (executor == null) throw new NullPointerException();
+ return doThenCombine(other, fn, executor);
+ }
+
+ private <U,V> CompletableFuture<V> doThenCombine
+ (CompletableFuture<? extends U> other,
+ BiFunction<? super T,? super U,? extends V> fn,
+ Executor e) {
+ if (other == null || fn == null) throw new NullPointerException();
+ CompletableFuture<V> dst = new CompletableFuture<V>();
+ ThenCombine<T,U,V> d = null;
+ Object r, s = null;
+ if ((r = result) == null || (s = other.result) == null) {
+ d = new ThenCombine<T,U,V>(this, other, fn, dst, e);
+ CompletionNode q = null, p = new CompletionNode(d);
+ while ((r == null && (r = result) == null) ||
+ (s == null && (s = other.result) == null)) {
+ if (q != null) {
+ if (s != null ||
+ UNSAFE.compareAndSwapObject
+ (other, COMPLETIONS, q.next = other.completions, q))
+ break;
+ }
+ else if (r != null ||
+ UNSAFE.compareAndSwapObject
+ (this, COMPLETIONS, p.next = completions, p)) {
+ if (s != null)
+ break;
+ q = new CompletionNode(d);
+ }
+ }
+ }
+ if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) {
+ T t; U u; Throwable ex;
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ if (ex != null)
+ u = null;
+ else if (s instanceof AltResult) {
+ ex = ((AltResult)s).ex;
+ u = null;
+ }
+ else {
+ @SuppressWarnings("unchecked") U us = (U) s;
+ u = us;
+ }
+ V v = null;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncCombine<T,U,V>(t, u, fn, dst));
+ else
+ v = fn.apply(t, u);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(v, ex);
+ }
+ helpPostComplete();
+ other.helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed
+ * when both this and the other given CompletableFuture complete,
+ * after performing the given action with the results of the two
+ * CompletableFutures.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, or the supplied action throws an exception,
+ * then the returned CompletableFuture completes exceptionally
+ * with a CompletionException holding the exception as its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param block the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public <U> CompletableFuture<Void> thenAcceptBoth
+ (CompletableFuture<? extends U> other,
+ BiConsumer<? super T, ? super U> block) {
+ return doThenAcceptBoth(other, block, null);
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when both this and the other given CompletableFuture complete,
+ * after performing the given action with the results of the two
+ * CompletableFutures from a task running in the {@link
+ * ForkJoinPool#commonPool()}.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, or the supplied action throws an exception,
+ * then the returned CompletableFuture completes exceptionally
+ * with a CompletionException holding the exception as its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param block the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public <U> CompletableFuture<Void> thenAcceptBothAsync
+ (CompletableFuture<? extends U> other,
+ BiConsumer<? super T, ? super U> block) {
+ return doThenAcceptBoth(other, block, ForkJoinPool.commonPool());
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when both this and the other given CompletableFuture complete,
+ * after performing the given action with the results of the two
+ * CompletableFutures from a task running in the given executor.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, or the supplied action throws an exception,
+ * then the returned CompletableFuture completes exceptionally
+ * with a CompletionException holding the exception as its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param block the action to perform before completing the
+ * returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public <U> CompletableFuture<Void> thenAcceptBothAsync
+ (CompletableFuture<? extends U> other,
+ BiConsumer<? super T, ? super U> block,
+ Executor executor) {
+ if (executor == null) throw new NullPointerException();
+ return doThenAcceptBoth(other, block, executor);
+ }
+
+ private <U> CompletableFuture<Void> doThenAcceptBoth
+ (CompletableFuture<? extends U> other,
+ BiConsumer<? super T,? super U> fn,
+ Executor e) {
+ if (other == null || fn == null) throw new NullPointerException();
+ CompletableFuture<Void> dst = new CompletableFuture<Void>();
+ ThenAcceptBoth<T,U> d = null;
+ Object r, s = null;
+ if ((r = result) == null || (s = other.result) == null) {
+ d = new ThenAcceptBoth<T,U>(this, other, fn, dst, e);
+ CompletionNode q = null, p = new CompletionNode(d);
+ while ((r == null && (r = result) == null) ||
+ (s == null && (s = other.result) == null)) {
+ if (q != null) {
+ if (s != null ||
+ UNSAFE.compareAndSwapObject
+ (other, COMPLETIONS, q.next = other.completions, q))
+ break;
+ }
+ else if (r != null ||
+ UNSAFE.compareAndSwapObject
+ (this, COMPLETIONS, p.next = completions, p)) {
+ if (s != null)
+ break;
+ q = new CompletionNode(d);
+ }
+ }
+ }
+ if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) {
+ T t; U u; Throwable ex;
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ if (ex != null)
+ u = null;
+ else if (s instanceof AltResult) {
+ ex = ((AltResult)s).ex;
+ u = null;
+ }
+ else {
+ @SuppressWarnings("unchecked") U us = (U) s;
+ u = us;
+ }
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncAcceptBoth<T,U>(t, u, fn, dst));
+ else
+ fn.accept(t, u);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ helpPostComplete();
+ other.helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed
+ * when both this and the other given CompletableFuture complete,
+ * after performing the given action.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, or the supplied action throws an exception,
+ * then the returned CompletableFuture completes exceptionally
+ * with a CompletionException holding the exception as its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param action the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> runAfterBoth(CompletableFuture<?> other,
+ Runnable action) {
+ return doRunAfterBoth(other, action, null);
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when both this and the other given CompletableFuture complete,
+ * after performing the given action from a task running in the
+ * {@link ForkJoinPool#commonPool()}.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, or the supplied action throws an exception,
+ * then the returned CompletableFuture completes exceptionally
+ * with a CompletionException holding the exception as its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param action the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> runAfterBothAsync(CompletableFuture<?> other,
+ Runnable action) {
+ return doRunAfterBoth(other, action, ForkJoinPool.commonPool());
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when both this and the other given CompletableFuture complete,
+ * after performing the given action from a task running in the
+ * given executor.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, or the supplied action throws an exception,
+ * then the returned CompletableFuture completes exceptionally
+ * with a CompletionException holding the exception as its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param action the action to perform before completing the
+ * returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> runAfterBothAsync(CompletableFuture<?> other,
+ Runnable action,
+ Executor executor) {
+ if (executor == null) throw new NullPointerException();
+ return doRunAfterBoth(other, action, executor);
+ }
+
+ private CompletableFuture<Void> doRunAfterBoth(CompletableFuture<?> other,
+ Runnable action,
+ Executor e) {
+ if (other == null || action == null) throw new NullPointerException();
+ CompletableFuture<Void> dst = new CompletableFuture<Void>();
+ RunAfterBoth d = null;
+ Object r, s = null;
+ if ((r = result) == null || (s = other.result) == null) {
+ d = new RunAfterBoth(this, other, action, dst, e);
+ CompletionNode q = null, p = new CompletionNode(d);
+ while ((r == null && (r = result) == null) ||
+ (s == null && (s = other.result) == null)) {
+ if (q != null) {
+ if (s != null ||
+ UNSAFE.compareAndSwapObject
+ (other, COMPLETIONS, q.next = other.completions, q))
+ break;
+ }
+ else if (r != null ||
+ UNSAFE.compareAndSwapObject
+ (this, COMPLETIONS, p.next = completions, p)) {
+ if (s != null)
+ break;
+ q = new CompletionNode(d);
+ }
+ }
+ }
+ if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) {
+ Throwable ex;
+ if (r instanceof AltResult)
+ ex = ((AltResult)r).ex;
+ else
+ ex = null;
+ if (ex == null && (s instanceof AltResult))
+ ex = ((AltResult)s).ex;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncRun(action, dst));
+ else
+ action.run();
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ helpPostComplete();
+ other.helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed
+ * when either this or the other given CompletableFuture completes,
+ * with the result of the given function of either this or the other
+ * CompletableFuture's result.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, then the returned CompletableFuture may also do so,
+ * with a CompletionException holding one of these exceptions as its
+ * cause. No guarantees are made about which result or exception is
+ * used in the returned CompletableFuture. If the supplied function
+ * throws an exception, then the returned CompletableFuture completes
+ * exceptionally with a CompletionException holding the exception as
+ * its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param fn the function to use to compute the value of
+ * the returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public <U> CompletableFuture<U> applyToEither
+ (CompletableFuture<? extends T> other,
+ Function<? super T, U> fn) {
+ return doApplyToEither(other, fn, null);
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when either this or the other given CompletableFuture completes,
+ * with the result of the given function of either this or the other
+ * CompletableFuture's result from a task running in the
+ * {@link ForkJoinPool#commonPool()}.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, then the returned CompletableFuture may also do so,
+ * with a CompletionException holding one of these exceptions as its
+ * cause. No guarantees are made about which result or exception is
+ * used in the returned CompletableFuture. If the supplied function
+ * throws an exception, then the returned CompletableFuture completes
+ * exceptionally with a CompletionException holding the exception as
+ * its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param fn the function to use to compute the value of
+ * the returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public <U> CompletableFuture<U> applyToEitherAsync
+ (CompletableFuture<? extends T> other,
+ Function<? super T, U> fn) {
+ return doApplyToEither(other, fn, ForkJoinPool.commonPool());
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when either this or the other given CompletableFuture completes,
+ * with the result of the given function of either this or the other
+ * CompletableFuture's result from a task running in the
+ * given executor.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, then the returned CompletableFuture may also do so,
+ * with a CompletionException holding one of these exceptions as its
+ * cause. No guarantees are made about which result or exception is
+ * used in the returned CompletableFuture. If the supplied function
+ * throws an exception, then the returned CompletableFuture completes
+ * exceptionally with a CompletionException holding the exception as
+ * its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param fn the function to use to compute the value of
+ * the returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public <U> CompletableFuture<U> applyToEitherAsync
+ (CompletableFuture<? extends T> other,
+ Function<? super T, U> fn,
+ Executor executor) {
+ if (executor == null) throw new NullPointerException();
+ return doApplyToEither(other, fn, executor);
+ }
+
+ private <U> CompletableFuture<U> doApplyToEither
+ (CompletableFuture<? extends T> other,
+ Function<? super T, U> fn,
+ Executor e) {
+ if (other == null || fn == null) throw new NullPointerException();
+ CompletableFuture<U> dst = new CompletableFuture<U>();
+ ApplyToEither<T,U> d = null;
+ Object r;
+ if ((r = result) == null && (r = other.result) == null) {
+ d = new ApplyToEither<T,U>(this, other, fn, dst, e);
+ CompletionNode q = null, p = new CompletionNode(d);
+ while ((r = result) == null && (r = other.result) == null) {
+ if (q != null) {
+ if (UNSAFE.compareAndSwapObject
+ (other, COMPLETIONS, q.next = other.completions, q))
+ break;
+ }
+ else if (UNSAFE.compareAndSwapObject
+ (this, COMPLETIONS, p.next = completions, p))
+ q = new CompletionNode(d);
+ }
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1))) {
+ T t; Throwable ex;
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ U u = null;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncApply<T,U>(t, fn, dst));
+ else
+ u = fn.apply(t);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(u, ex);
+ }
+ helpPostComplete();
+ other.helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed
+ * when either this or the other given CompletableFuture completes,
+ * after performing the given action with the result of either this
+ * or the other CompletableFuture's result.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, then the returned CompletableFuture may also do so,
+ * with a CompletionException holding one of these exceptions as its
+ * cause. No guarantees are made about which result or exception is
+ * used in the returned CompletableFuture. If the supplied action
+ * throws an exception, then the returned CompletableFuture completes
+ * exceptionally with a CompletionException holding the exception as
+ * its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param block the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> acceptEither
+ (CompletableFuture<? extends T> other,
+ Consumer<? super T> block) {
+ return doAcceptEither(other, block, null);
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when either this or the other given CompletableFuture completes,
+ * after performing the given action with the result of either this
+ * or the other CompletableFuture's result from a task running in
+ * the {@link ForkJoinPool#commonPool()}.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, then the returned CompletableFuture may also do so,
+ * with a CompletionException holding one of these exceptions as its
+ * cause. No guarantees are made about which result or exception is
+ * used in the returned CompletableFuture. If the supplied action
+ * throws an exception, then the returned CompletableFuture completes
+ * exceptionally with a CompletionException holding the exception as
+ * its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param block the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> acceptEitherAsync
+ (CompletableFuture<? extends T> other,
+ Consumer<? super T> block) {
+ return doAcceptEither(other, block, ForkJoinPool.commonPool());
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when either this or the other given CompletableFuture completes,
+ * after performing the given action with the result of either this
+ * or the other CompletableFuture's result from a task running in
+ * the given executor.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, then the returned CompletableFuture may also do so,
+ * with a CompletionException holding one of these exceptions as its
+ * cause. No guarantees are made about which result or exception is
+ * used in the returned CompletableFuture. If the supplied action
+ * throws an exception, then the returned CompletableFuture completes
+ * exceptionally with a CompletionException holding the exception as
+ * its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param block the action to perform before completing the
+ * returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> acceptEitherAsync
+ (CompletableFuture<? extends T> other,
+ Consumer<? super T> block,
+ Executor executor) {
+ if (executor == null) throw new NullPointerException();
+ return doAcceptEither(other, block, executor);
+ }
+
+ private CompletableFuture<Void> doAcceptEither
+ (CompletableFuture<? extends T> other,
+ Consumer<? super T> fn,
+ Executor e) {
+ if (other == null || fn == null) throw new NullPointerException();
+ CompletableFuture<Void> dst = new CompletableFuture<Void>();
+ AcceptEither<T> d = null;
+ Object r;
+ if ((r = result) == null && (r = other.result) == null) {
+ d = new AcceptEither<T>(this, other, fn, dst, e);
+ CompletionNode q = null, p = new CompletionNode(d);
+ while ((r = result) == null && (r = other.result) == null) {
+ if (q != null) {
+ if (UNSAFE.compareAndSwapObject
+ (other, COMPLETIONS, q.next = other.completions, q))
+ break;
+ }
+ else if (UNSAFE.compareAndSwapObject
+ (this, COMPLETIONS, p.next = completions, p))
+ q = new CompletionNode(d);
+ }
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1))) {
+ T t; Throwable ex;
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncAccept<T>(t, fn, dst));
+ else
+ fn.accept(t);
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ helpPostComplete();
+ other.helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed
+ * when either this or the other given CompletableFuture completes,
+ * after performing the given action.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, then the returned CompletableFuture may also do so,
+ * with a CompletionException holding one of these exceptions as its
+ * cause. No guarantees are made about which result or exception is
+ * used in the returned CompletableFuture. If the supplied action
+ * throws an exception, then the returned CompletableFuture completes
+ * exceptionally with a CompletionException holding the exception as
+ * its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param action the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> runAfterEither(CompletableFuture<?> other,
+ Runnable action) {
+ return doRunAfterEither(other, action, null);
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when either this or the other given CompletableFuture completes,
+ * after performing the given action from a task running in the
+ * {@link ForkJoinPool#commonPool()}.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, then the returned CompletableFuture may also do so,
+ * with a CompletionException holding one of these exceptions as its
+ * cause. No guarantees are made about which result or exception is
+ * used in the returned CompletableFuture. If the supplied action
+ * throws an exception, then the returned CompletableFuture completes
+ * exceptionally with a CompletionException holding the exception as
+ * its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param action the action to perform before completing the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> runAfterEitherAsync
+ (CompletableFuture<?> other,
+ Runnable action) {
+ return doRunAfterEither(other, action, ForkJoinPool.commonPool());
+ }
+
+ /**
+ * Returns a new CompletableFuture that is asynchronously completed
+ * when either this or the other given CompletableFuture completes,
+ * after performing the given action from a task running in the
+ * given executor.
+ *
+ * <p>If this and/or the other CompletableFuture complete
+ * exceptionally, then the returned CompletableFuture may also do so,
+ * with a CompletionException holding one of these exceptions as its
+ * cause. No guarantees are made about which result or exception is
+ * used in the returned CompletableFuture. If the supplied action
+ * throws an exception, then the returned CompletableFuture completes
+ * exceptionally with a CompletionException holding the exception as
+ * its cause.
+ *
+ * @param other the other CompletableFuture
+ * @param action the action to perform before completing the
+ * returned CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<Void> runAfterEitherAsync
+ (CompletableFuture<?> other,
+ Runnable action,
+ Executor executor) {
+ if (executor == null) throw new NullPointerException();
+ return doRunAfterEither(other, action, executor);
+ }
+
+ private CompletableFuture<Void> doRunAfterEither
+ (CompletableFuture<?> other,
+ Runnable action,
+ Executor e) {
+ if (other == null || action == null) throw new NullPointerException();
+ CompletableFuture<Void> dst = new CompletableFuture<Void>();
+ RunAfterEither d = null;
+ Object r;
+ if ((r = result) == null && (r = other.result) == null) {
+ d = new RunAfterEither(this, other, action, dst, e);
+ CompletionNode q = null, p = new CompletionNode(d);
+ while ((r = result) == null && (r = other.result) == null) {
+ if (q != null) {
+ if (UNSAFE.compareAndSwapObject
+ (other, COMPLETIONS, q.next = other.completions, q))
+ break;
+ }
+ else if (UNSAFE.compareAndSwapObject
+ (this, COMPLETIONS, p.next = completions, p))
+ q = new CompletionNode(d);
+ }
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1))) {
+ Throwable ex;
+ if (r instanceof AltResult)
+ ex = ((AltResult)r).ex;
+ else
+ ex = null;
+ if (ex == null) {
+ try {
+ if (e != null)
+ e.execute(new AsyncRun(action, dst));
+ else
+ action.run();
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ helpPostComplete();
+ other.helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a CompletableFuture that upon completion, has the same
+ * value as produced by the given function of the result of this
+ * CompletableFuture.
+ *
+ * <p>If this CompletableFuture completes exceptionally, then the
+ * returned CompletableFuture also does so, with a
+ * CompletionException holding this exception as its cause.
+ * Similarly, if the computed CompletableFuture completes
+ * exceptionally, then so does the returned CompletableFuture.
+ *
+ * @param fn the function returning a new CompletableFuture
+ * @return the CompletableFuture
+ */
+ public <U> CompletableFuture<U> thenCompose
+ (Function<? super T, CompletableFuture<U>> fn) {
+ return doThenCompose(fn, null);
+ }
+
+ /**
+ * Returns a CompletableFuture that upon completion, has the same
+ * value as that produced asynchronously using the {@link
+ * ForkJoinPool#commonPool()} by the given function of the result
+ * of this CompletableFuture.
+ *
+ * <p>If this CompletableFuture completes exceptionally, then the
+ * returned CompletableFuture also does so, with a
+ * CompletionException holding this exception as its cause.
+ * Similarly, if the computed CompletableFuture completes
+ * exceptionally, then so does the returned CompletableFuture.
+ *
+ * @param fn the function returning a new CompletableFuture
+ * @return the CompletableFuture
+ */
+ public <U> CompletableFuture<U> thenComposeAsync
+ (Function<? super T, CompletableFuture<U>> fn) {
+ return doThenCompose(fn, ForkJoinPool.commonPool());
+ }
+
+ /**
+ * Returns a CompletableFuture that upon completion, has the same
+ * value as that produced asynchronously using the given executor
+ * by the given function of this CompletableFuture.
+ *
+ * <p>If this CompletableFuture completes exceptionally, then the
+ * returned CompletableFuture also does so, with a
+ * CompletionException holding this exception as its cause.
+ * Similarly, if the computed CompletableFuture completes
+ * exceptionally, then so does the returned CompletableFuture.
+ *
+ * @param fn the function returning a new CompletableFuture
+ * @param executor the executor to use for asynchronous execution
+ * @return the CompletableFuture
+ */
+ public <U> CompletableFuture<U> thenComposeAsync
+ (Function<? super T, CompletableFuture<U>> fn,
+ Executor executor) {
+ if (executor == null) throw new NullPointerException();
+ return doThenCompose(fn, executor);
+ }
+
+ private <U> CompletableFuture<U> doThenCompose
+ (Function<? super T, CompletableFuture<U>> fn,
+ Executor e) {
+ if (fn == null) throw new NullPointerException();
+ CompletableFuture<U> dst = null;
+ ThenCompose<T,U> d = null;
+ Object r;
+ if ((r = result) == null) {
+ dst = new CompletableFuture<U>();
+ CompletionNode p = new CompletionNode
+ (d = new ThenCompose<T,U>(this, fn, dst, e));
+ while ((r = result) == null) {
+ if (UNSAFE.compareAndSwapObject
+ (this, COMPLETIONS, p.next = completions, p))
+ break;
+ }
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1))) {
+ T t; Throwable ex;
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ if (ex == null) {
+ if (e != null) {
+ if (dst == null)
+ dst = new CompletableFuture<U>();
+ e.execute(new AsyncCompose<T,U>(t, fn, dst));
+ }
+ else {
+ try {
+ if ((dst = fn.apply(t)) == null)
+ ex = new NullPointerException();
+ } catch (Throwable rex) {
+ ex = rex;
+ }
+ }
+ }
+ if (dst == null)
+ dst = new CompletableFuture<U>();
+ if (e == null || ex != null)
+ dst.internalComplete(null, ex);
+ }
+ helpPostComplete();
+ dst.helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed when this
+ * CompletableFuture completes, with the result of the given
+ * function of the exception triggering this CompletableFuture's
+ * completion when it completes exceptionally; otherwise, if this
+ * CompletableFuture completes normally, then the returned
+ * CompletableFuture also completes normally with the same value.
+ *
+ * @param fn the function to use to compute the value of the
+ * returned CompletableFuture if this CompletableFuture completed
+ * exceptionally
+ * @return the new CompletableFuture
+ */
+ public CompletableFuture<T> exceptionally
+ (Function<Throwable, ? extends T> fn) {
+ if (fn == null) throw new NullPointerException();
+ CompletableFuture<T> dst = new CompletableFuture<T>();
+ ExceptionCompletion<T> d = null;
+ Object r;
+ if ((r = result) == null) {
+ CompletionNode p =
+ new CompletionNode(d = new ExceptionCompletion<T>(this, fn, dst));
+ while ((r = result) == null) {
+ if (UNSAFE.compareAndSwapObject(this, COMPLETIONS,
+ p.next = completions, p))
+ break;
+ }
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1))) {
+ T t = null; Throwable ex, dx = null;
+ if (r instanceof AltResult) {
+ if ((ex = ((AltResult)r).ex) != null) {
+ try {
+ t = fn.apply(ex);
+ } catch (Throwable rex) {
+ dx = rex;
+ }
+ }
+ }
+ else {
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ dst.internalComplete(t, dx);
+ }
+ helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed when this
+ * CompletableFuture completes, with the result of the given
+ * function of the result and exception of this CompletableFuture's
+ * completion. The given function is invoked with the result (or
+ * {@code null} if none) and the exception (or {@code null} if none)
+ * of this CompletableFuture when complete.
+ *
+ * @param fn the function to use to compute the value of the
+ * returned CompletableFuture
+ * @return the new CompletableFuture
+ */
+ public <U> CompletableFuture<U> handle
+ (BiFunction<? super T, Throwable, ? extends U> fn) {
+ if (fn == null) throw new NullPointerException();
+ CompletableFuture<U> dst = new CompletableFuture<U>();
+ HandleCompletion<T,U> d = null;
+ Object r;
+ if ((r = result) == null) {
+ CompletionNode p =
+ new CompletionNode(d = new HandleCompletion<T,U>(this, fn, dst));
+ while ((r = result) == null) {
+ if (UNSAFE.compareAndSwapObject(this, COMPLETIONS,
+ p.next = completions, p))
+ break;
+ }
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1))) {
+ T t; Throwable ex;
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ U u; Throwable dx;
+ try {
+ u = fn.apply(t, ex);
+ dx = null;
+ } catch (Throwable rex) {
+ dx = rex;
+ u = null;
+ }
+ dst.internalComplete(u, dx);
+ }
+ helpPostComplete();
+ return dst;
+ }
+
+
+ /* ------------- Arbitrary-arity constructions -------------- */
+
+ /*
+ * The basic plan of attack is to recursively form binary
+ * completion trees of elements. This can be overkill for small
+ * sets, but scales nicely. The And/All vs Or/Any forms use the
+ * same idea, but details differ.
+ */
+
+ /**
+ * Returns a new CompletableFuture that is completed when all of
+ * the given CompletableFutures complete. If any of the given
+ * CompletableFutures complete exceptionally, then the returned
+ * CompletableFuture also does so, with a CompletionException
+ * holding this exception as its cause. Otherwise, the results,
+ * if any, of the given CompletableFutures are not reflected in
+ * the returned CompletableFuture, but may be obtained by
+ * inspecting them individually. If no CompletableFutures are
+ * provided, returns a CompletableFuture completed with the value
+ * {@code null}.
+ *
+ * <p>Among the applications of this method is to await completion
+ * of a set of independent CompletableFutures before continuing a
+ * program, as in: {@code CompletableFuture.allOf(c1, c2,
+ * c3).join();}.
+ *
+ * @param cfs the CompletableFutures
+ * @return a new CompletableFuture that is completed when all of the
+ * given CompletableFutures complete
+ * @throws NullPointerException if the array or any of its elements are
+ * {@code null}
+ */
+ public static CompletableFuture<Void> allOf(CompletableFuture<?>... cfs) {
+ int len = cfs.length; // Directly handle empty and singleton cases
+ if (len > 1)
+ return allTree(cfs, 0, len - 1);
+ else {
+ CompletableFuture<Void> dst = new CompletableFuture<Void>();
+ CompletableFuture<?> f;
+ if (len == 0)
+ dst.result = NIL;
+ else if ((f = cfs[0]) == null)
+ throw new NullPointerException();
+ else {
+ ThenPropagate d = null;
+ CompletionNode p = null;
+ Object r;
+ while ((r = f.result) == null) {
+ if (d == null)
+ d = new ThenPropagate(f, dst);
+ else if (p == null)
+ p = new CompletionNode(d);
+ else if (UNSAFE.compareAndSwapObject
+ (f, COMPLETIONS, p.next = f.completions, p))
+ break;
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1)))
+ dst.internalComplete(null, (r instanceof AltResult) ?
+ ((AltResult)r).ex : null);
+ f.helpPostComplete();
+ }
+ return dst;
+ }
+ }
+
+ /**
+ * Recursively constructs an And'ed tree of CompletableFutures.
+ * Called only when array known to have at least two elements.
+ */
+ private static CompletableFuture<Void> allTree(CompletableFuture<?>[] cfs,
+ int lo, int hi) {
+ CompletableFuture<?> fst, snd;
+ int mid = (lo + hi) >>> 1;
+ if ((fst = (lo == mid ? cfs[lo] : allTree(cfs, lo, mid))) == null ||
+ (snd = (hi == mid+1 ? cfs[hi] : allTree(cfs, mid+1, hi))) == null)
+ throw new NullPointerException();
+ CompletableFuture<Void> dst = new CompletableFuture<Void>();
+ AndCompletion d = null;
+ CompletionNode p = null, q = null;
+ Object r = null, s = null;
+ while ((r = fst.result) == null || (s = snd.result) == null) {
+ if (d == null)
+ d = new AndCompletion(fst, snd, dst);
+ else if (p == null)
+ p = new CompletionNode(d);
+ else if (q == null) {
+ if (UNSAFE.compareAndSwapObject
+ (fst, COMPLETIONS, p.next = fst.completions, p))
+ q = new CompletionNode(d);
+ }
+ else if (UNSAFE.compareAndSwapObject
+ (snd, COMPLETIONS, q.next = snd.completions, q))
+ break;
+ }
+ if ((r != null || (r = fst.result) != null) &&
+ (s != null || (s = snd.result) != null) &&
+ (d == null || d.compareAndSet(0, 1))) {
+ Throwable ex;
+ if (r instanceof AltResult)
+ ex = ((AltResult)r).ex;
+ else
+ ex = null;
+ if (ex == null && (s instanceof AltResult))
+ ex = ((AltResult)s).ex;
+ dst.internalComplete(null, ex);
+ }
+ fst.helpPostComplete();
+ snd.helpPostComplete();
+ return dst;
+ }
+
+ /**
+ * Returns a new CompletableFuture that is completed when any of
+ * the given CompletableFutures complete, with the same result.
+ * Otherwise, if it completed exceptionally, the returned
+ * CompletableFuture also does so, with a CompletionException
+ * holding this exception as its cause. If no CompletableFutures
+ * are provided, returns an incomplete CompletableFuture.
+ *
+ * @param cfs the CompletableFutures
+ * @return a new CompletableFuture that is completed with the
+ * result or exception of any of the given CompletableFutures when
+ * one completes
+ * @throws NullPointerException if the array or any of its elements are
+ * {@code null}
+ */
+ public static CompletableFuture<Object> anyOf(CompletableFuture<?>... cfs) {
+ int len = cfs.length; // Same idea as allOf
+ if (len > 1)
+ return anyTree(cfs, 0, len - 1);
+ else {
+ CompletableFuture<Object> dst = new CompletableFuture<Object>();
+ CompletableFuture<?> f;
+ if (len == 0)
+ ; // skip
+ else if ((f = cfs[0]) == null)
+ throw new NullPointerException();
+ else {
+ ThenCopy<Object> d = null;
+ CompletionNode p = null;
+ Object r;
+ while ((r = f.result) == null) {
+ if (d == null)
+ d = new ThenCopy<Object>(f, dst);
+ else if (p == null)
+ p = new CompletionNode(d);
+ else if (UNSAFE.compareAndSwapObject
+ (f, COMPLETIONS, p.next = f.completions, p))
+ break;
+ }
+ if (r != null && (d == null || d.compareAndSet(0, 1))) {
+ Throwable ex; Object t;
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ t = r;
+ }
+ dst.internalComplete(t, ex);
+ }
+ f.helpPostComplete();
+ }
+ return dst;
+ }
+ }
+
+ /**
+ * Recursively constructs an Or'ed tree of CompletableFutures.
+ */
+ private static CompletableFuture<Object> anyTree(CompletableFuture<?>[] cfs,
+ int lo, int hi) {
+ CompletableFuture<?> fst, snd;
+ int mid = (lo + hi) >>> 1;
+ if ((fst = (lo == mid ? cfs[lo] : anyTree(cfs, lo, mid))) == null ||
+ (snd = (hi == mid+1 ? cfs[hi] : anyTree(cfs, mid+1, hi))) == null)
+ throw new NullPointerException();
+ CompletableFuture<Object> dst = new CompletableFuture<Object>();
+ OrCompletion d = null;
+ CompletionNode p = null, q = null;
+ Object r;
+ while ((r = fst.result) == null && (r = snd.result) == null) {
+ if (d == null)
+ d = new OrCompletion(fst, snd, dst);
+ else if (p == null)
+ p = new CompletionNode(d);
+ else if (q == null) {
+ if (UNSAFE.compareAndSwapObject
+ (fst, COMPLETIONS, p.next = fst.completions, p))
+ q = new CompletionNode(d);
+ }
+ else if (UNSAFE.compareAndSwapObject
+ (snd, COMPLETIONS, q.next = snd.completions, q))
+ break;
+ }
+ if ((r != null || (r = fst.result) != null ||
+ (r = snd.result) != null) &&
+ (d == null || d.compareAndSet(0, 1))) {
+ Throwable ex; Object t;
+ if (r instanceof AltResult) {
+ ex = ((AltResult)r).ex;
+ t = null;
+ }
+ else {
+ ex = null;
+ t = r;
+ }
+ dst.internalComplete(t, ex);
+ }
+ fst.helpPostComplete();
+ snd.helpPostComplete();
+ return dst;
+ }
+
+ /* ------------- Control and status methods -------------- */
+
+ /**
+ * If not already completed, completes this CompletableFuture with
+ * a {@link CancellationException}. Dependent CompletableFutures
+ * that have not already completed will also complete
+ * exceptionally, with a {@link CompletionException} caused by
+ * this {@code CancellationException}.
+ *
+ * @param mayInterruptIfRunning this value has no effect in this
+ * implementation because interrupts are not used to control
+ * processing.
+ *
+ * @return {@code true} if this task is now cancelled
+ */
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ boolean cancelled = (result == null) &&
+ UNSAFE.compareAndSwapObject
+ (this, RESULT, null, new AltResult(new CancellationException()));
+ postComplete();
+ return cancelled || isCancelled();
+ }
+
+ /**
+ * Returns {@code true} if this CompletableFuture was cancelled
+ * before it completed normally.
+ *
+ * @return {@code true} if this CompletableFuture was cancelled
+ * before it completed normally
+ */
+ public boolean isCancelled() {
+ Object r;
+ return ((r = result) instanceof AltResult) &&
+ (((AltResult)r).ex instanceof CancellationException);
+ }
+
+ /**
+ * Forcibly sets or resets the value subsequently returned by
+ * method {@link #get()} and related methods, whether or not
+ * already completed. This method is designed for use only in
+ * error recovery actions, and even in such situations may result
+ * in ongoing dependent completions using established versus
+ * overwritten outcomes.
+ *
+ * @param value the completion value
+ */
+ public void obtrudeValue(T value) {
+ result = (value == null) ? NIL : value;
+ postComplete();
+ }
+
+ /**
+ * Forcibly causes subsequent invocations of method {@link #get()}
+ * and related methods to throw the given exception, whether or
+ * not already completed. This method is designed for use only in
+ * recovery actions, and even in such situations may result in
+ * ongoing dependent completions using established versus
+ * overwritten outcomes.
+ *
+ * @param ex the exception
+ */
+ public void obtrudeException(Throwable ex) {
+ if (ex == null) throw new NullPointerException();
+ result = new AltResult(ex);
+ postComplete();
+ }
+
+ /**
+ * Returns the estimated number of CompletableFutures whose
+ * completions are awaiting completion of this CompletableFuture.
+ * This method is designed for use in monitoring system state, not
+ * for synchronization control.
+ *
+ * @return the number of dependent CompletableFutures
+ */
+ public int getNumberOfDependents() {
+ int count = 0;
+ for (CompletionNode p = completions; p != null; p = p.next)
+ ++count;
+ return count;
+ }
+
+ /**
+ * Returns a string identifying this CompletableFuture, as well as
+ * its completion state. The state, in brackets, contains the
+ * String {@code "Completed Normally"} or the String {@code
+ * "Completed Exceptionally"}, or the String {@code "Not
+ * completed"} followed by the number of CompletableFutures
+ * dependent upon its completion, if any.
+ *
+ * @return a string identifying this CompletableFuture, as well as its state
+ */
+ public String toString() {
+ Object r = result;
+ int count;
+ return super.toString() +
+ ((r == null) ?
+ (((count = getNumberOfDependents()) == 0) ?
+ "[Not completed]" :
+ "[Not completed, " + count + " dependents]") :
+ (((r instanceof AltResult) && ((AltResult)r).ex != null) ?
+ "[Completed exceptionally]" :
+ "[Completed normally]"));
+ }
+
+ // Unsafe mechanics
+ private static final sun.misc.Unsafe UNSAFE;
+ private static final long RESULT;
+ private static final long WAITERS;
+ private static final long COMPLETIONS;
+ static {
+ try {
+ UNSAFE = sun.misc.Unsafe.getUnsafe();
+ Class<?> k = CompletableFuture.class;
+ RESULT = UNSAFE.objectFieldOffset
+ (k.getDeclaredField("result"));
+ WAITERS = UNSAFE.objectFieldOffset
+ (k.getDeclaredField("waiters"));
+ COMPLETIONS = UNSAFE.objectFieldOffset
+ (k.getDeclaredField("completions"));
+ } catch (Exception e) {
+ throw new Error(e);
+ }
+ }
+}
diff --git a/src/share/classes/java/util/concurrent/CompletionException.java b/src/share/classes/java/util/concurrent/CompletionException.java
new file mode 100644
index 0000000..2a3cfc5
--- /dev/null
+++ b/src/share/classes/java/util/concurrent/CompletionException.java
@@ -0,0 +1,90 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+package java.util.concurrent;
+
+/**
+ * Exception thrown when an error or other exception is encountered
+ * in the course of completing a result or task.
+ *
+ * @since 1.8
+ * @author Doug Lea
+ */
+public class CompletionException extends RuntimeException {
+ private static final long serialVersionUID = 7830266012832686185L;
+
+ /**
+ * Constructs a {@code CompletionException} with no detail message.
+ * The cause is not initialized, and may subsequently be
+ * initialized by a call to {@link #initCause(Throwable) initCause}.
+ */
+ protected CompletionException() { }
+
+ /**
+ * Constructs a {@code CompletionException} with the specified detail
+ * message. The cause is not initialized, and may subsequently be
+ * initialized by a call to {@link #initCause(Throwable) initCause}.
+ *
+ * @param message the detail message
+ */
+ protected CompletionException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a {@code CompletionException} with the specified detail
+ * message and cause.
+ *
+ * @param message the detail message
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method)
+ */
+ public CompletionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs a {@code CompletionException} with the specified cause.
+ * The detail message is set to {@code (cause == null ? null :
+ * cause.toString())} (which typically contains the class and
+ * detail message of {@code cause}).
+ *
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method)
+ */
+ public CompletionException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java b/src/share/classes/java/util/function/DoubleToIntFunction.java
similarity index 60%
copy from src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
copy to src/share/classes/java/util/function/DoubleToIntFunction.java
index 6d85ca3..8eaf0b8 100644
--- a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
+++ b/src/share/classes/java/util/function/DoubleToIntFunction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 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
@@ -22,32 +22,25 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-package com.sun.servicetag;
+package java.util.function;
/**
- * Thrown if the user is not authorized to
- * {@link Registry#updateServiceTag update} or
- * {@link Registry#removeServiceTag remove}
- * a service tag from a {@link Registry}.
+ * Apply a function to the input argument, yielding an appropriate result.
+ * This is the {@code double}-to-{@code int} specialization for {@link Function}.
+ *
+ * @see Function
+ * @see IntToDoubleFunction
+ * @see LongToIntFunction
+ * @since 1.8
*/
-public class UnauthorizedAccessException extends RuntimeException {
+@FunctionalInterface
+public interface DoubleToIntFunction {
/**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * without detail message.
- */
- public UnauthorizedAccessException() {
- }
-
-
- /**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * with the specified detail message.
+ * Compute the result of applying the function to the input arguments.
*
- * @param msg the detail message.
+ * @param value the input value
+ * @return the function result value
*/
- public UnauthorizedAccessException(String msg) {
- super(msg);
- }
+ int applyAsInt(double value);
}
diff --git a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java b/src/share/classes/java/util/function/DoubleToLongFunction.java
similarity index 60%
copy from src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
copy to src/share/classes/java/util/function/DoubleToLongFunction.java
index 6d85ca3..7568157 100644
--- a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
+++ b/src/share/classes/java/util/function/DoubleToLongFunction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 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
@@ -22,32 +22,25 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-package com.sun.servicetag;
+package java.util.function;
/**
- * Thrown if the user is not authorized to
- * {@link Registry#updateServiceTag update} or
- * {@link Registry#removeServiceTag remove}
- * a service tag from a {@link Registry}.
+ * Apply a function to the input argument, yielding an appropriate result.
+ * This is the {@code double}-to-{@code long} specialization for {@link Function}.
+ *
+ * @see Function
+ * @see LongToDoubleFunction
+ * @see IntToLongFunction
+ * @since 1.8
*/
-public class UnauthorizedAccessException extends RuntimeException {
+@FunctionalInterface
+public interface DoubleToLongFunction {
/**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * without detail message.
- */
- public UnauthorizedAccessException() {
- }
-
-
- /**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * with the specified detail message.
+ * Compute the result of applying the function to the input arguments.
*
- * @param msg the detail message.
+ * @param value the input value
+ * @return the function result value
*/
- public UnauthorizedAccessException(String msg) {
- super(msg);
- }
+ long applyAsLong(double value);
}
diff --git a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java b/src/share/classes/java/util/function/IntToDoubleFunction.java
similarity index 60%
copy from src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
copy to src/share/classes/java/util/function/IntToDoubleFunction.java
index 6d85ca3..773164d 100644
--- a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
+++ b/src/share/classes/java/util/function/IntToDoubleFunction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 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
@@ -22,32 +22,25 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-package com.sun.servicetag;
+package java.util.function;
/**
- * Thrown if the user is not authorized to
- * {@link Registry#updateServiceTag update} or
- * {@link Registry#removeServiceTag remove}
- * a service tag from a {@link Registry}.
+ * Apply a function to the input argument, yielding an appropriate result.
+ * This is the {@code int}-to-{@code double} specialization for {@link Function}.
+ *
+ * @see Function
+ * @see DoubleToIntFunction
+ * @see LongToDoubleFunction
+ * @since 1.8
*/
-public class UnauthorizedAccessException extends RuntimeException {
+@FunctionalInterface
+public interface IntToDoubleFunction {
/**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * without detail message.
- */
- public UnauthorizedAccessException() {
- }
-
-
- /**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * with the specified detail message.
+ * Compute the result of applying the function to the input arguments.
*
- * @param msg the detail message.
+ * @param value the input value
+ * @return the function result value
*/
- public UnauthorizedAccessException(String msg) {
- super(msg);
- }
+ double applyAsDouble(int value);
}
diff --git a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java b/src/share/classes/java/util/function/IntToLongFunction.java
similarity index 60%
copy from src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
copy to src/share/classes/java/util/function/IntToLongFunction.java
index 6d85ca3..c50b20f 100644
--- a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
+++ b/src/share/classes/java/util/function/IntToLongFunction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 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
@@ -22,32 +22,25 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-package com.sun.servicetag;
+package java.util.function;
/**
- * Thrown if the user is not authorized to
- * {@link Registry#updateServiceTag update} or
- * {@link Registry#removeServiceTag remove}
- * a service tag from a {@link Registry}.
+ * Apply a function to the input argument, yielding an appropriate result.
+ * This is the {@code int}-to-{@code long} specialization for {@link Function}.
+ *
+ * @see Function
+ * @see LongToIntFunction
+ * @see DoubleToLongFunction
+ * @since 1.8
*/
-public class UnauthorizedAccessException extends RuntimeException {
+@FunctionalInterface
+public interface IntToLongFunction {
/**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * without detail message.
- */
- public UnauthorizedAccessException() {
- }
-
-
- /**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * with the specified detail message.
+ * Compute the result of applying the function to the input arguments.
*
- * @param msg the detail message.
+ * @param value the input value
+ * @return the function result value
*/
- public UnauthorizedAccessException(String msg) {
- super(msg);
- }
+ long applyAsLong(int value);
}
diff --git a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java b/src/share/classes/java/util/function/LongToDoubleFunction.java
similarity index 60%
rename from src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
rename to src/share/classes/java/util/function/LongToDoubleFunction.java
index 6d85ca3..718021c 100644
--- a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
+++ b/src/share/classes/java/util/function/LongToDoubleFunction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 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
@@ -22,32 +22,25 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-package com.sun.servicetag;
+package java.util.function;
/**
- * Thrown if the user is not authorized to
- * {@link Registry#updateServiceTag update} or
- * {@link Registry#removeServiceTag remove}
- * a service tag from a {@link Registry}.
+ * Apply a function to the input argument, yielding an appropriate result.
+ * This is the {@code long}-to-{@code double} specialization for {@link Function}.
+ *
+ * @see Function
+ * @see DoubleToLongFunction
+ * @see IntToDoubleFunction
+ * @since 1.8
*/
-public class UnauthorizedAccessException extends RuntimeException {
+@FunctionalInterface
+public interface LongToDoubleFunction {
/**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * without detail message.
- */
- public UnauthorizedAccessException() {
- }
-
-
- /**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * with the specified detail message.
+ * Compute the result of applying the function to the input arguments.
*
- * @param msg the detail message.
+ * @param value the input value
+ * @return the function result value
*/
- public UnauthorizedAccessException(String msg) {
- super(msg);
- }
+ double applyAsDouble(long value);
}
diff --git a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java b/src/share/classes/java/util/function/LongToIntFunction.java
similarity index 60%
copy from src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
copy to src/share/classes/java/util/function/LongToIntFunction.java
index 6d85ca3..e5dc6ba 100644
--- a/src/share/classes/com/sun/servicetag/UnauthorizedAccessException.java
+++ b/src/share/classes/java/util/function/LongToIntFunction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 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
@@ -22,32 +22,25 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-package com.sun.servicetag;
+package java.util.function;
/**
- * Thrown if the user is not authorized to
- * {@link Registry#updateServiceTag update} or
- * {@link Registry#removeServiceTag remove}
- * a service tag from a {@link Registry}.
+ * Apply a function to the input argument, yielding an appropriate result.
+ * This is the {@code long}-to-{@code int} specialization for {@link Function}.
+ *
+ * @see Function
+ * @see IntToLongFunction
+ * @see DoubleToIntFunction
+ * @since 1.8
*/
-public class UnauthorizedAccessException extends RuntimeException {
+@FunctionalInterface
+public interface LongToIntFunction {
/**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * without detail message.
- */
- public UnauthorizedAccessException() {
- }
-
-
- /**
- * Constructs an <code>UnauthorizedAccessException</code> object
- * with the specified detail message.
+ * Compute the result of applying the function to the input arguments.
*
- * @param msg the detail message.
+ * @param value the input value
+ * @return the function result value
*/
- public UnauthorizedAccessException(String msg) {
- super(msg);
- }
+ int applyAsInt(long value);
}
diff --git a/src/share/classes/java/util/logging/Logger.java b/src/share/classes/java/util/logging/Logger.java
index 5d06005..c8f8fae 100644
--- a/src/share/classes/java/util/logging/Logger.java
+++ b/src/share/classes/java/util/logging/Logger.java
@@ -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 @@
* 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 @@
}
...
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 @@
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 @@
});
}
+ /**
+ * 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 @@
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 @@
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 @@
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 @@
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, "");
}
diff --git a/src/share/classes/java/util/logging/LoggingProxyImpl.java b/src/share/classes/java/util/logging/LoggingProxyImpl.java
index a207d1f..736e0c3 100644
--- a/src/share/classes/java/util/logging/LoggingProxyImpl.java
+++ b/src/share/classes/java/util/logging/LoggingProxyImpl.java
@@ -106,6 +106,11 @@
}
@Override
+ public int getLevelValue(Object level) {
+ return ((Level) level).intValue();
+ }
+
+ @Override
public String getProperty(String key) {
return LogManager.getLogManager().getProperty(key);
}
diff --git a/src/share/classes/java/util/zip/ZipOutputStream.java b/src/share/classes/java/util/zip/ZipOutputStream.java
index 91b28a6..0c98082 100644
--- a/src/share/classes/java/util/zip/ZipOutputStream.java
+++ b/src/share/classes/java/util/zip/ZipOutputStream.java
@@ -43,6 +43,20 @@
public
class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
+ /**
+ * Whether to use ZIP64 for zip files with more than 64k entries.
+ * Until ZIP64 support in zip implementations is ubiquitous, this
+ * system property allows the creation of zip files which can be
+ * read by legacy zip implementations which tolerate "incorrect"
+ * total entry count fields, such as the ones in jdk6, and even
+ * some in jdk7.
+ */
+ private static final boolean inhibitZip64 =
+ Boolean.parseBoolean(
+ java.security.AccessController.doPrivileged(
+ new sun.security.action.GetPropertyAction(
+ "jdk.util.zip.inhibitZip64", "false")));
+
private static class XEntry {
public final ZipEntry entry;
public final long offset;
@@ -534,8 +548,10 @@
}
int count = xentries.size();
if (count >= ZIP64_MAGICCOUNT) {
- count = ZIP64_MAGICCOUNT;
- hasZip64 = true;
+ hasZip64 |= !inhibitZip64;
+ if (hasZip64) {
+ count = ZIP64_MAGICCOUNT;
+ }
}
if (hasZip64) {
long off64 = written;
diff --git a/src/share/classes/javax/sql/rowset/serial/SerialClob.java b/src/share/classes/javax/sql/rowset/serial/SerialClob.java
index 6020e34..5ea5fee 100644
--- a/src/share/classes/javax/sql/rowset/serial/SerialClob.java
+++ b/src/share/classes/javax/sql/rowset/serial/SerialClob.java
@@ -508,7 +508,7 @@
*
* @param length the length, in bytes, to which the <code>CLOB</code>
* value should be truncated
- * @throws SerialLException if there is an error accessing the
+ * @throws SerialException if there is an error accessing the
* <code>CLOB</code> value;
* if the {@code free} method had been previously called on this object
*/
diff --git a/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java b/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
index 093aeae..fa631ed 100644
--- a/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
+++ b/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
@@ -57,6 +57,7 @@
*/
@Override
protected void installDefaults() {
+ super.installDefaults();
trackHighlight = NO_HIGHLIGHT;
if (scrollbar.getLayout() == null ||
(scrollbar.getLayout() instanceof UIResource)) {
diff --git a/src/share/classes/sun/awt/EmbeddedFrame.java b/src/share/classes/sun/awt/EmbeddedFrame.java
index fe8ad9a..5ad4293 100644
--- a/src/share/classes/sun/awt/EmbeddedFrame.java
+++ b/src/share/classes/sun/awt/EmbeddedFrame.java
@@ -34,7 +34,6 @@
import java.util.Set;
import java.awt.AWTKeyStroke;
import java.applet.Applet;
-import javax.tools.annotation.GenerateNativeHeader;
import sun.applet.AppletPanel;
/**
@@ -54,8 +53,6 @@
*
* @author Thomas Ball
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class EmbeddedFrame extends Frame
implements KeyEventDispatcher, PropertyChangeListener {
diff --git a/src/share/classes/sun/awt/SunHints.java b/src/share/classes/sun/awt/SunHints.java
index 1d8cb54..3e0dff5 100644
--- a/src/share/classes/sun/awt/SunHints.java
+++ b/src/share/classes/sun/awt/SunHints.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2005, 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
@@ -26,7 +26,7 @@
package sun.awt;
import java.awt.RenderingHints;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* This class contains rendering hints that can be used by the
@@ -34,8 +34,6 @@
* {@link java.awt.image.BufferedImageOp} and
* {@link java.awt.image.Raster}.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class SunHints {
/**
* Defines the type of all keys used to control various
@@ -180,86 +178,86 @@
/**
* Rendering hint key and values
*/
- public static final int INTKEY_RENDERING = 0;
- public static final int INTVAL_RENDER_DEFAULT = 0;
- public static final int INTVAL_RENDER_SPEED = 1;
- public static final int INTVAL_RENDER_QUALITY = 2;
+ @Native public static final int INTKEY_RENDERING = 0;
+ @Native public static final int INTVAL_RENDER_DEFAULT = 0;
+ @Native public static final int INTVAL_RENDER_SPEED = 1;
+ @Native public static final int INTVAL_RENDER_QUALITY = 2;
/**
* Antialiasing hint key and values
*/
- public static final int INTKEY_ANTIALIASING = 1;
- public static final int INTVAL_ANTIALIAS_DEFAULT = 0;
- public static final int INTVAL_ANTIALIAS_OFF = 1;
- public static final int INTVAL_ANTIALIAS_ON = 2;
+ @Native public static final int INTKEY_ANTIALIASING = 1;
+ @Native public static final int INTVAL_ANTIALIAS_DEFAULT = 0;
+ @Native public static final int INTVAL_ANTIALIAS_OFF = 1;
+ @Native public static final int INTVAL_ANTIALIAS_ON = 2;
/**
* Text antialiasing hint key and values
*/
- public static final int INTKEY_TEXT_ANTIALIASING = 2;
- public static final int INTVAL_TEXT_ANTIALIAS_DEFAULT = 0;
- public static final int INTVAL_TEXT_ANTIALIAS_OFF = 1;
- public static final int INTVAL_TEXT_ANTIALIAS_ON = 2;
- public static final int INTVAL_TEXT_ANTIALIAS_GASP = 3;
- public static final int INTVAL_TEXT_ANTIALIAS_LCD_HRGB = 4;
- public static final int INTVAL_TEXT_ANTIALIAS_LCD_HBGR = 5;
- public static final int INTVAL_TEXT_ANTIALIAS_LCD_VRGB = 6;
- public static final int INTVAL_TEXT_ANTIALIAS_LCD_VBGR = 7;
+ @Native public static final int INTKEY_TEXT_ANTIALIASING = 2;
+ @Native public static final int INTVAL_TEXT_ANTIALIAS_DEFAULT = 0;
+ @Native public static final int INTVAL_TEXT_ANTIALIAS_OFF = 1;
+ @Native public static final int INTVAL_TEXT_ANTIALIAS_ON = 2;
+ @Native public static final int INTVAL_TEXT_ANTIALIAS_GASP = 3;
+ @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_HRGB = 4;
+ @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_HBGR = 5;
+ @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_VRGB = 6;
+ @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_VBGR = 7;
/**
* Font fractional metrics hint key and values
*/
- public static final int INTKEY_FRACTIONALMETRICS = 3;
- public static final int INTVAL_FRACTIONALMETRICS_DEFAULT = 0;
- public static final int INTVAL_FRACTIONALMETRICS_OFF = 1;
- public static final int INTVAL_FRACTIONALMETRICS_ON = 2;
+ @Native public static final int INTKEY_FRACTIONALMETRICS = 3;
+ @Native public static final int INTVAL_FRACTIONALMETRICS_DEFAULT = 0;
+ @Native public static final int INTVAL_FRACTIONALMETRICS_OFF = 1;
+ @Native public static final int INTVAL_FRACTIONALMETRICS_ON = 2;
/**
* Dithering hint key and values
*/
- public static final int INTKEY_DITHERING = 4;
- public static final int INTVAL_DITHER_DEFAULT = 0;
- public static final int INTVAL_DITHER_DISABLE = 1;
- public static final int INTVAL_DITHER_ENABLE = 2;
+ @Native public static final int INTKEY_DITHERING = 4;
+ @Native public static final int INTVAL_DITHER_DEFAULT = 0;
+ @Native public static final int INTVAL_DITHER_DISABLE = 1;
+ @Native public static final int INTVAL_DITHER_ENABLE = 2;
/**
* Interpolation hint key and values
*/
- public static final int INTKEY_INTERPOLATION = 5;
- public static final int INTVAL_INTERPOLATION_NEAREST_NEIGHBOR = 0;
- public static final int INTVAL_INTERPOLATION_BILINEAR = 1;
- public static final int INTVAL_INTERPOLATION_BICUBIC = 2;
+ @Native public static final int INTKEY_INTERPOLATION = 5;
+ @Native public static final int INTVAL_INTERPOLATION_NEAREST_NEIGHBOR = 0;
+ @Native public static final int INTVAL_INTERPOLATION_BILINEAR = 1;
+ @Native public static final int INTVAL_INTERPOLATION_BICUBIC = 2;
/**
* Alpha interpolation hint key and values
*/
- public static final int INTKEY_ALPHA_INTERPOLATION = 6;
- public static final int INTVAL_ALPHA_INTERPOLATION_DEFAULT = 0;
- public static final int INTVAL_ALPHA_INTERPOLATION_SPEED = 1;
- public static final int INTVAL_ALPHA_INTERPOLATION_QUALITY = 2;
+ @Native public static final int INTKEY_ALPHA_INTERPOLATION = 6;
+ @Native public static final int INTVAL_ALPHA_INTERPOLATION_DEFAULT = 0;
+ @Native public static final int INTVAL_ALPHA_INTERPOLATION_SPEED = 1;
+ @Native public static final int INTVAL_ALPHA_INTERPOLATION_QUALITY = 2;
/**
* Color rendering hint key and values
*/
- public static final int INTKEY_COLOR_RENDERING = 7;
- public static final int INTVAL_COLOR_RENDER_DEFAULT = 0;
- public static final int INTVAL_COLOR_RENDER_SPEED = 1;
- public static final int INTVAL_COLOR_RENDER_QUALITY = 2;
+ @Native public static final int INTKEY_COLOR_RENDERING = 7;
+ @Native public static final int INTVAL_COLOR_RENDER_DEFAULT = 0;
+ @Native public static final int INTVAL_COLOR_RENDER_SPEED = 1;
+ @Native public static final int INTVAL_COLOR_RENDER_QUALITY = 2;
/**
* Stroke normalization control hint key and values
*/
- public static final int INTKEY_STROKE_CONTROL = 8;
- public static final int INTVAL_STROKE_DEFAULT = 0;
- public static final int INTVAL_STROKE_NORMALIZE = 1;
- public static final int INTVAL_STROKE_PURE = 2;
+ @Native public static final int INTKEY_STROKE_CONTROL = 8;
+ @Native public static final int INTVAL_STROKE_DEFAULT = 0;
+ @Native public static final int INTVAL_STROKE_NORMALIZE = 1;
+ @Native public static final int INTVAL_STROKE_PURE = 2;
/**
* LCD text contrast control hint key.
* Value is "100" to make discontiguous with the others which
* are all enumerative and are of a different class.
*/
- public static final int INTKEY_AATEXT_LCD_CONTRAST = 100;
+ @Native public static final int INTKEY_AATEXT_LCD_CONTRAST = 100;
/**
* Rendering hint key and value objects
diff --git a/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java b/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java
index c5e80b2..a893c9d 100644
--- a/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java
+++ b/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2009, 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
@@ -54,7 +54,6 @@
import sun.awt.datatransfer.DataTransferer;
import java.awt.datatransfer.DataFlavor;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* <p>
@@ -64,8 +63,6 @@
* @since JDK1.3.1
*
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class SunDragSourceContextPeer implements DragSourceContextPeer {
private DragGestureEvent trigger;
diff --git a/src/share/classes/sun/awt/image/BufImgSurfaceData.java b/src/share/classes/sun/awt/image/BufImgSurfaceData.java
index 2f8732e..efc4bc9 100644
--- a/src/share/classes/sun/awt/image/BufImgSurfaceData.java
+++ b/src/share/classes/sun/awt/image/BufImgSurfaceData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2010, 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
@@ -45,10 +45,7 @@
import sun.java2d.loops.CompositeType;
import sun.java2d.loops.RenderLoops;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class BufImgSurfaceData extends SurfaceData {
BufferedImage bufImg;
private BufferedImageGraphicsConfig graphicsConfig;
diff --git a/src/share/classes/sun/font/FontManager.java b/src/share/classes/sun/font/FontManager.java
index 4238cfa..cace22e 100644
--- a/src/share/classes/sun/font/FontManager.java
+++ b/src/share/classes/sun/font/FontManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2008, 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
@@ -32,14 +32,11 @@
import javax.swing.plaf.FontUIResource;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* Interface between Java Fonts (java.awt.Font) and the underlying
* font files/native font resources and the Java and native font scalers.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public interface FontManager {
// These constants are used in findFont().
diff --git a/src/share/classes/sun/java2d/SunGraphics2D.java b/src/share/classes/sun/java2d/SunGraphics2D.java
index 1b2d3d6..ba24604 100644
--- a/src/share/classes/sun/java2d/SunGraphics2D.java
+++ b/src/share/classes/sun/java2d/SunGraphics2D.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2008, 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
@@ -92,7 +92,7 @@
import sun.java2d.DestSurfaceProvider;
import sun.misc.PerformanceLogger;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* This is a the master Graphics2D superclass for all of the Sun
@@ -103,8 +103,6 @@
*
* @author Jim Graham
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public final class SunGraphics2D
extends Graphics2D
implements ConstrainableGraphics, Cloneable, DestSurfaceProvider
@@ -113,18 +111,29 @@
* Attribute States
*/
/* Paint */
+ @Native
public static final int PAINT_CUSTOM = 6; /* Any other Paint object */
+ @Native
public static final int PAINT_TEXTURE = 5; /* Tiled Image */
+ @Native
public static final int PAINT_RAD_GRADIENT = 4; /* Color RadialGradient */
+ @Native
public static final int PAINT_LIN_GRADIENT = 3; /* Color LinearGradient */
+ @Native
public static final int PAINT_GRADIENT = 2; /* Color Gradient */
+ @Native
public static final int PAINT_ALPHACOLOR = 1; /* Non-opaque Color */
+ @Native
public static final int PAINT_OPAQUECOLOR = 0; /* Opaque Color */
/* Composite*/
+ @Native
public static final int COMP_CUSTOM = 3;/* Custom Composite */
+ @Native
public static final int COMP_XOR = 2;/* XOR Mode Composite */
+ @Native
public static final int COMP_ALPHA = 1;/* AlphaComposite */
+ @Native
public static final int COMP_ISCOPY = 0;/* simple stores into destination,
* i.e. Src, SrcOverNoEa, and other
* alpha modes which replace
@@ -132,21 +141,33 @@
*/
/* Stroke */
+ @Native
public static final int STROKE_CUSTOM = 3; /* custom Stroke */
+ @Native
public static final int STROKE_WIDE = 2; /* BasicStroke */
+ @Native
public static final int STROKE_THINDASHED = 1; /* BasicStroke */
+ @Native
public static final int STROKE_THIN = 0; /* BasicStroke */
/* Transform */
+ @Native
public static final int TRANSFORM_GENERIC = 4; /* any 3x2 */
+ @Native
public static final int TRANSFORM_TRANSLATESCALE = 3; /* scale XY */
+ @Native
public static final int TRANSFORM_ANY_TRANSLATE = 2; /* non-int translate */
+ @Native
public static final int TRANSFORM_INT_TRANSLATE = 1; /* int translate */
+ @Native
public static final int TRANSFORM_ISIDENT = 0; /* Identity */
/* Clipping */
+ @Native
public static final int CLIP_SHAPE = 2; /* arbitrary clip */
+ @Native
public static final int CLIP_RECTANGULAR = 1; /* rectangular clip */
+ @Native
public static final int CLIP_DEVICE = 0; /* no clipping set */
/* The following fields are used when the current Paint is a Color. */
diff --git a/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java b/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java
index 684f6fc..ef78a81 100644
--- a/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java
+++ b/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2007, 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
@@ -45,10 +45,8 @@
import sun.java2d.pipe.RenderBuffer;
import sun.java2d.pipe.RenderQueue;
import static sun.java2d.pipe.BufferedOpCodes.*;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
class OGLBlitLoops {
static void register() {
@@ -190,12 +188,12 @@
* createPackedParams(). (They are also used at the native level when
* unpacking the params.)
*/
- private static final int OFFSET_SRCTYPE = 16;
- private static final int OFFSET_HINT = 8;
- private static final int OFFSET_TEXTURE = 3;
- private static final int OFFSET_RTT = 2;
- private static final int OFFSET_XFORM = 1;
- private static final int OFFSET_ISOBLIT = 0;
+ @Native private static final int OFFSET_SRCTYPE = 16;
+ @Native private static final int OFFSET_HINT = 8;
+ @Native private static final int OFFSET_TEXTURE = 3;
+ @Native private static final int OFFSET_RTT = 2;
+ @Native private static final int OFFSET_XFORM = 1;
+ @Native private static final int OFFSET_ISOBLIT = 0;
/**
* Packs the given parameters into a single int value in order to save
diff --git a/src/share/classes/sun/java2d/opengl/OGLContext.java b/src/share/classes/sun/java2d/opengl/OGLContext.java
index 17c4f8a..e3ac65f 100644
--- a/src/share/classes/sun/java2d/opengl/OGLContext.java
+++ b/src/share/classes/sun/java2d/opengl/OGLContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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,7 +32,7 @@
import static sun.java2d.pipe.BufferedOpCodes.*;
import static sun.java2d.pipe.hw.ContextCapabilities.*;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* Note that the RenderQueue lock must be acquired before calling any of
@@ -155,39 +155,44 @@
rq.flushNow();
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
static class OGLContextCaps extends ContextCapabilities {
/**
* Indicates the presence of the GL_EXT_framebuffer_object extension.
* This cap will only be set if the fbobject system property has been
* enabled and we are able to create an FBO with depth buffer.
*/
+ @Native
static final int CAPS_EXT_FBOBJECT =
(CAPS_RT_TEXTURE_ALPHA | CAPS_RT_TEXTURE_OPAQUE);
/** Indicates that the context supports a stored alpha channel. */
+ @Native
static final int CAPS_STORED_ALPHA = CAPS_RT_PLAIN_ALPHA;
/** Indicates that the context is doublebuffered. */
+ @Native
static final int CAPS_DOUBLEBUFFERED = (FIRST_PRIVATE_CAP << 0);
/**
* Indicates the presence of the GL_ARB_fragment_shader extension.
* This cap will only be set if the lcdshader system property has been
* enabled and the hardware supports the minimum number of texture units
*/
+ @Native
static final int CAPS_EXT_LCD_SHADER = (FIRST_PRIVATE_CAP << 1);
/**
* Indicates the presence of the GL_ARB_fragment_shader extension.
* This cap will only be set if the biopshader system property has been
* enabled and the hardware meets our minimum requirements.
*/
+ @Native
static final int CAPS_EXT_BIOP_SHADER = (FIRST_PRIVATE_CAP << 2);
/**
* Indicates the presence of the GL_ARB_fragment_shader extension.
* This cap will only be set if the gradshader system property has been
* enabled and the hardware meets our minimum requirements.
*/
+ @Native
static final int CAPS_EXT_GRAD_SHADER = (FIRST_PRIVATE_CAP << 3);
/** Indicates the presence of the GL_ARB_texture_rectangle extension. */
+ @Native
static final int CAPS_EXT_TEXRECT = (FIRST_PRIVATE_CAP << 4);
OGLContextCaps(int caps, String adapterId) {
diff --git a/src/share/classes/sun/java2d/pipe/BufferedContext.java b/src/share/classes/sun/java2d/pipe/BufferedContext.java
index 6bc3039..75b18be 100644
--- a/src/share/classes/sun/java2d/pipe/BufferedContext.java
+++ b/src/share/classes/sun/java2d/pipe/BufferedContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, 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
@@ -37,7 +37,7 @@
import static sun.java2d.pipe.BufferedOpCodes.*;
import static sun.java2d.pipe.BufferedRenderPipe.BYTES_PER_SPAN;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* Base context class for managing state in a single-threaded rendering
@@ -49,8 +49,6 @@
*
* @see RenderQueue
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class BufferedContext {
/*
@@ -63,19 +61,19 @@
/**
* Indicates that no flags are needed; take all default code paths.
*/
- public static final int NO_CONTEXT_FLAGS = (0 << 0);
+ @Native public static final int NO_CONTEXT_FLAGS = (0 << 0);
/**
* Indicates that the source surface (or color value, if it is a simple
* rendering operation) is opaque (has an alpha value of 1.0). If this
* flag is present, it allows us to disable blending in certain
* situations in order to improve performance.
*/
- public static final int SRC_IS_OPAQUE = (1 << 0);
+ @Native public static final int SRC_IS_OPAQUE = (1 << 0);
/**
* Indicates that the operation uses an alpha mask, which may determine
* the code path that is used when setting up the current paint state.
*/
- public static final int USE_MASK = (1 << 1);
+ @Native public static final int USE_MASK = (1 << 1);
protected RenderQueue rq;
protected RenderBuffer buf;
diff --git a/src/share/classes/sun/java2d/pipe/BufferedOpCodes.java b/src/share/classes/sun/java2d/pipe/BufferedOpCodes.java
index 78ee323..89acfdf 100644
--- a/src/share/classes/sun/java2d/pipe/BufferedOpCodes.java
+++ b/src/share/classes/sun/java2d/pipe/BufferedOpCodes.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, 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
@@ -25,79 +25,77 @@
package sun.java2d.pipe;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class BufferedOpCodes {
// draw ops
- public static final int DRAW_LINE = 10;
- public static final int DRAW_RECT = 11;
- public static final int DRAW_POLY = 12;
- public static final int DRAW_PIXEL = 13;
- public static final int DRAW_SCANLINES = 14;
- public static final int DRAW_PARALLELOGRAM = 15;
- public static final int DRAW_AAPARALLELOGRAM = 16;
+ @Native public static final int DRAW_LINE = 10;
+ @Native public static final int DRAW_RECT = 11;
+ @Native public static final int DRAW_POLY = 12;
+ @Native public static final int DRAW_PIXEL = 13;
+ @Native public static final int DRAW_SCANLINES = 14;
+ @Native public static final int DRAW_PARALLELOGRAM = 15;
+ @Native public static final int DRAW_AAPARALLELOGRAM = 16;
// fill ops
- public static final int FILL_RECT = 20;
- public static final int FILL_SPANS = 21;
- public static final int FILL_PARALLELOGRAM = 22;
- public static final int FILL_AAPARALLELOGRAM = 23;
+ @Native public static final int FILL_RECT = 20;
+ @Native public static final int FILL_SPANS = 21;
+ @Native public static final int FILL_PARALLELOGRAM = 22;
+ @Native public static final int FILL_AAPARALLELOGRAM = 23;
// copy-related ops
- public static final int COPY_AREA = 30;
- public static final int BLIT = 31;
- public static final int MASK_FILL = 32;
- public static final int MASK_BLIT = 33;
- public static final int SURFACE_TO_SW_BLIT = 34;
+ @Native public static final int COPY_AREA = 30;
+ @Native public static final int BLIT = 31;
+ @Native public static final int MASK_FILL = 32;
+ @Native public static final int MASK_BLIT = 33;
+ @Native public static final int SURFACE_TO_SW_BLIT = 34;
// text-related ops
- public static final int DRAW_GLYPH_LIST = 40;
+ @Native public static final int DRAW_GLYPH_LIST = 40;
// state-related ops
- public static final int SET_RECT_CLIP = 51;
- public static final int BEGIN_SHAPE_CLIP = 52;
- public static final int SET_SHAPE_CLIP_SPANS = 53;
- public static final int END_SHAPE_CLIP = 54;
- public static final int RESET_CLIP = 55;
- public static final int SET_ALPHA_COMPOSITE = 56;
- public static final int SET_XOR_COMPOSITE = 57;
- public static final int RESET_COMPOSITE = 58;
- public static final int SET_TRANSFORM = 59;
- public static final int RESET_TRANSFORM = 60;
+ @Native public static final int SET_RECT_CLIP = 51;
+ @Native public static final int BEGIN_SHAPE_CLIP = 52;
+ @Native public static final int SET_SHAPE_CLIP_SPANS = 53;
+ @Native public static final int END_SHAPE_CLIP = 54;
+ @Native public static final int RESET_CLIP = 55;
+ @Native public static final int SET_ALPHA_COMPOSITE = 56;
+ @Native public static final int SET_XOR_COMPOSITE = 57;
+ @Native public static final int RESET_COMPOSITE = 58;
+ @Native public static final int SET_TRANSFORM = 59;
+ @Native public static final int RESET_TRANSFORM = 60;
// context-related ops
- public static final int SET_SURFACES = 70;
- public static final int SET_SCRATCH_SURFACE = 71;
- public static final int FLUSH_SURFACE = 72;
- public static final int DISPOSE_SURFACE = 73;
- public static final int DISPOSE_CONFIG = 74;
- public static final int INVALIDATE_CONTEXT = 75;
- public static final int SYNC = 76;
- public static final int RESTORE_DEVICES = 77;
- public static final int SAVE_STATE = 78;
- public static final int RESTORE_STATE = 79;
+ @Native public static final int SET_SURFACES = 70;
+ @Native public static final int SET_SCRATCH_SURFACE = 71;
+ @Native public static final int FLUSH_SURFACE = 72;
+ @Native public static final int DISPOSE_SURFACE = 73;
+ @Native public static final int DISPOSE_CONFIG = 74;
+ @Native public static final int INVALIDATE_CONTEXT = 75;
+ @Native public static final int SYNC = 76;
+ @Native public static final int RESTORE_DEVICES = 77;
+ @Native public static final int SAVE_STATE = 78;
+ @Native public static final int RESTORE_STATE = 79;
// multibuffering ops
- public static final int SWAP_BUFFERS = 80;
+ @Native public static final int SWAP_BUFFERS = 80;
// special no-op op code (mainly used for achieving 8-byte alignment)
- public static final int NOOP = 90;
+ @Native public static final int NOOP = 90;
// paint-related ops
- public static final int RESET_PAINT = 100;
- public static final int SET_COLOR = 101;
- public static final int SET_GRADIENT_PAINT = 102;
- public static final int SET_LINEAR_GRADIENT_PAINT = 103;
- public static final int SET_RADIAL_GRADIENT_PAINT = 104;
- public static final int SET_TEXTURE_PAINT = 105;
+ @Native public static final int RESET_PAINT = 100;
+ @Native public static final int SET_COLOR = 101;
+ @Native public static final int SET_GRADIENT_PAINT = 102;
+ @Native public static final int SET_LINEAR_GRADIENT_PAINT = 103;
+ @Native public static final int SET_RADIAL_GRADIENT_PAINT = 104;
+ @Native public static final int SET_TEXTURE_PAINT = 105;
// BufferedImageOp-related ops
- public static final int ENABLE_CONVOLVE_OP = 120;
- public static final int DISABLE_CONVOLVE_OP = 121;
- public static final int ENABLE_RESCALE_OP = 122;
- public static final int DISABLE_RESCALE_OP = 123;
- public static final int ENABLE_LOOKUP_OP = 124;
- public static final int DISABLE_LOOKUP_OP = 125;
+ @Native public static final int ENABLE_CONVOLVE_OP = 120;
+ @Native public static final int DISABLE_CONVOLVE_OP = 121;
+ @Native public static final int ENABLE_RESCALE_OP = 122;
+ @Native public static final int DISABLE_RESCALE_OP = 123;
+ @Native public static final int ENABLE_LOOKUP_OP = 124;
+ @Native public static final int DISABLE_LOOKUP_OP = 125;
}
diff --git a/src/share/classes/sun/java2d/pipe/BufferedPaints.java b/src/share/classes/sun/java2d/pipe/BufferedPaints.java
index 5737e40..84394e2 100644
--- a/src/share/classes/sun/java2d/pipe/BufferedPaints.java
+++ b/src/share/classes/sun/java2d/pipe/BufferedPaints.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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,10 +46,8 @@
import sun.java2d.loops.SurfaceType;
import static sun.java2d.pipe.BufferedOpCodes.*;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class BufferedPaints {
static void setPaint(RenderQueue rq, SunGraphics2D sg2d,
@@ -304,7 +302,7 @@
* shaders. So for now we will cap this value at 12, but we can
* re-evaluate this in the future as hardware becomes more capable.
*/
- public static final int MULTI_MAX_FRACTIONS = 12;
+ @Native public static final int MULTI_MAX_FRACTIONS = 12;
/**
* Helper function to convert a color component in sRGB space to
diff --git a/src/share/classes/sun/java2d/pipe/BufferedTextPipe.java b/src/share/classes/sun/java2d/pipe/BufferedTextPipe.java
index 8f4a2bf..ce38825 100644
--- a/src/share/classes/sun/java2d/pipe/BufferedTextPipe.java
+++ b/src/share/classes/sun/java2d/pipe/BufferedTextPipe.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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,24 +32,22 @@
import sun.java2d.SurfaceData;
import static sun.java2d.pipe.BufferedOpCodes.*;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public abstract class BufferedTextPipe extends GlyphListPipe {
- private static final int BYTES_PER_GLYPH_IMAGE = 8;
- private static final int BYTES_PER_GLYPH_POSITION = 8;
+ @Native private static final int BYTES_PER_GLYPH_IMAGE = 8;
+ @Native private static final int BYTES_PER_GLYPH_POSITION = 8;
/**
* The following offsets are used to pack the parameters in
* createPackedParams(). (They are also used at the native level when
* unpacking the params.)
*/
- private static final int OFFSET_CONTRAST = 8;
- private static final int OFFSET_RGBORDER = 2;
- private static final int OFFSET_SUBPIXPOS = 1;
- private static final int OFFSET_POSITIONS = 0;
+ @Native private static final int OFFSET_CONTRAST = 8;
+ @Native private static final int OFFSET_RGBORDER = 2;
+ @Native private static final int OFFSET_SUBPIXPOS = 1;
+ @Native private static final int OFFSET_POSITIONS = 0;
/**
* Packs the given parameters into a single int value in order to save
diff --git a/src/share/classes/sun/java2d/pipe/RenderBuffer.java b/src/share/classes/sun/java2d/pipe/RenderBuffer.java
index 353c8d1..5f5118a 100644
--- a/src/share/classes/sun/java2d/pipe/RenderBuffer.java
+++ b/src/share/classes/sun/java2d/pipe/RenderBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, 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
@@ -27,7 +27,6 @@
import sun.misc.Unsafe;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* The RenderBuffer class is a simplified, high-performance, Unsafe wrapper
@@ -44,8 +43,6 @@
* single-threaded rendering. For example, there is no put(double[]) method
* because we currently have no need for such a method in the STR classes.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class RenderBuffer {
/**
diff --git a/src/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java b/src/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java
index 1a3b791..44d4115 100644
--- a/src/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java
+++ b/src/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -30,16 +30,13 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* This class is used to notify listeners about accelerated device's
* events such as device reset or dispose that are about to occur.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class AccelDeviceEventNotifier {
private static AccelDeviceEventNotifier theInstance;
@@ -49,13 +46,13 @@
* resources associated with the device which are required for the device
* to be reset.
*/
- public static final int DEVICE_RESET = 0;
+ @Native public static final int DEVICE_RESET = 0;
/**
* A device is about to be disposed. The listeners have to release all
* resources associated with the device.
*/
- public static final int DEVICE_DISPOSED = 1;
+ @Native public static final int DEVICE_DISPOSED = 1;
private final Map<AccelDeviceEventListener, Integer> listeners;
diff --git a/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java b/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java
index 6dd5137..8f4e5a3 100644
--- a/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java
+++ b/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -28,41 +28,39 @@
import java.awt.Rectangle;
import sun.java2d.Surface;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* Abstraction for a hardware accelerated surface.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public interface AccelSurface extends BufferedContextProvider, Surface {
/**
* Undefined
*/
- public static final int UNDEFINED = 0;
+ @Native public static final int UNDEFINED = 0;
/**
* Window (or window substitute) surface
*/
- public static final int WINDOW = 1;
+ @Native public static final int WINDOW = 1;
/**
* Render-To Plain surface (pbuffer for OpenGL, Render Target surface
* for Direct3D)
*/
- public static final int RT_PLAIN = 2;
+ @Native public static final int RT_PLAIN = 2;
/**
* Texture surface
*/
- public static final int TEXTURE = 3;
+ @Native public static final int TEXTURE = 3;
/**
* A back-buffer surface (SwapChain surface for Direct3D, backbuffer for
* OpenGL)
*/
- public static final int FLIP_BACKBUFFER = 4;
+ @Native public static final int FLIP_BACKBUFFER = 4;
/**
* Render-To Texture surface (fbobject for OpenGL, texture with render-to
* attribute for Direct3D)
*/
- public static final int RT_TEXTURE = 5;
+ @Native public static final int RT_TEXTURE = 5;
/**
* Returns {@code int} representing surface's type as defined by constants
diff --git a/src/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java b/src/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java
index 0a6ab79..86a9a25 100644
--- a/src/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java
+++ b/src/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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,7 +25,6 @@
package sun.java2d.pipe.hw;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* Represents a set of capabilities of a BufferedContext and associated
@@ -33,8 +32,6 @@
*
* @see AccelGraphicsConfig
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class ContextCapabilities {
/** Indicates that the context has no capabilities. */
public static final int CAPS_EMPTY = (0 << 0);
diff --git a/src/share/classes/sun/misc/Version.java.template b/src/share/classes/sun/misc/Version.java.template
index 710bf71..6897e0a 100644
--- a/src/share/classes/sun/misc/Version.java.template
+++ b/src/share/classes/sun/misc/Version.java.template
@@ -52,8 +52,6 @@
System.setProperty("java.version", java_version);
System.setProperty("java.runtime.version", java_runtime_version);
System.setProperty("java.runtime.name", java_runtime_name);
- if (java_profile_name.length() > 0)
- System.setProperty("java.runtime.profile", java_profile_name);
}
private static boolean versionsInitialized = false;
diff --git a/src/share/classes/sun/net/ftp/impl/FtpClient.java b/src/share/classes/sun/net/ftp/impl/FtpClient.java
index 1d1b26d..babb9f5 100644
--- a/src/share/classes/sun/net/ftp/impl/FtpClient.java
+++ b/src/share/classes/sun/net/ftp/impl/FtpClient.java
@@ -1299,16 +1299,16 @@
* <code>null</code> if the command was unsuccessful.
* @throws IOException if an error occured during the transmission.
*/
- public OutputStream putFileStream(String name, boolean unique) throws sun.net.ftp.FtpProtocolException, IOException {
+ public OutputStream putFileStream(String name, boolean unique)
+ throws sun.net.ftp.FtpProtocolException, IOException
+ {
String cmd = unique ? "STOU " : "STOR ";
Socket s = openDataConnection(cmd + name);
if (s == null) {
return null;
}
- if (type == TransferType.BINARY) {
- return s.getOutputStream();
- }
- return new sun.net.TelnetOutputStream(s.getOutputStream(), false);
+ boolean bm = (type == TransferType.BINARY);
+ return new sun.net.TelnetOutputStream(s.getOutputStream(), bm);
}
/**
diff --git a/src/share/classes/sun/net/spi/DefaultProxySelector.java b/src/share/classes/sun/net/spi/DefaultProxySelector.java
index 37fb6c7..0e786fe 100644
--- a/src/share/classes/sun/net/spi/DefaultProxySelector.java
+++ b/src/share/classes/sun/net/spi/DefaultProxySelector.java
@@ -124,6 +124,7 @@
final String defaultVal;
static NonProxyInfo ftpNonProxyInfo = new NonProxyInfo("ftp.nonProxyHosts", null, null, defStringVal);
static NonProxyInfo httpNonProxyInfo = new NonProxyInfo("http.nonProxyHosts", null, null, defStringVal);
+ static NonProxyInfo socksNonProxyInfo = new NonProxyInfo("socksNonProxyHosts", null, null, defStringVal);
NonProxyInfo(String p, String s, RegexpPool pool, String d) {
property = p;
@@ -186,6 +187,8 @@
pinfo = NonProxyInfo.httpNonProxyInfo;
} else if ("ftp".equalsIgnoreCase(protocol)) {
pinfo = NonProxyInfo.ftpNonProxyInfo;
+ } else if ("socket".equalsIgnoreCase(protocol)) {
+ pinfo = NonProxyInfo.socksNonProxyInfo;
}
/**
diff --git a/src/share/classes/sun/net/www/http/HttpClient.java b/src/share/classes/sun/net/www/http/HttpClient.java
index cfbc932..9f6b80a 100644
--- a/src/share/classes/sun/net/www/http/HttpClient.java
+++ b/src/share/classes/sun/net/www/http/HttpClient.java
@@ -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 @@
// 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 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 @@
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 @@
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 @@
}
}
- 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 @@
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;
}
diff --git a/src/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java b/src/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java
index 88c6259..ada2ee9 100644
--- a/src/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java
+++ b/src/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java
@@ -96,7 +96,7 @@
http = HttpsClient.New (getSSLSocketFactory(),
url,
getHostnameVerifier(),
- useCache);
+ useCache, this);
((HttpsClient)http).afterConnect();
}
@@ -149,7 +149,7 @@
http = HttpsClient.New (getSSLSocketFactory(),
url,
getHostnameVerifier(),
- proxyHost, proxyPort, useCache);
+ proxyHost, proxyPort, useCache, this);
connected = true;
}
@@ -189,7 +189,8 @@
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 @@
throws IOException {
return HttpsClient.New(getSSLSocketFactory(), url,
getHostnameVerifier(), p,
- useCache, connectTimeout);
+ useCache, connectTimeout, this);
}
/**
diff --git a/src/share/classes/sun/net/www/protocol/https/HttpsClient.java b/src/share/classes/sun/net/www/protocol/https/HttpsClient.java
index 4ead34d..bf4c2b4 100644
--- a/src/share/classes/sun/net/www/protocol/https/HttpsClient.java
+++ b/src/share/classes/sun/net/www/protocol/https/HttpsClient.java
@@ -30,6 +30,7 @@
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.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 @@
// 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 @@
* 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 @@
} 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 @@
@Override
protected void putInKeepAliveCache() {
+ if (inCache) {
+ assert false : "Duplicate put to keep alive cache";
+ return;
+ }
+ inCache = true;
kac.put(url, sslSocketFactory, this);
}
diff --git a/src/share/classes/sun/net/www/protocol/jar/JarURLConnection.java b/src/share/classes/sun/net/www/protocol/jar/JarURLConnection.java
index 7ea6427..4c5dc87 100644
--- a/src/share/classes/sun/net/www/protocol/jar/JarURLConnection.java
+++ b/src/share/classes/sun/net/www/protocol/jar/JarURLConnection.java
@@ -51,7 +51,7 @@
/* 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;
diff --git a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
index ff2ee58..cdd5b3c 100644
--- a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+++ b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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,15 +32,12 @@
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
-import javax.tools.annotation.GenerateNativeHeader;
import sun.net.ResourceManager;
/**
* An implementation of DatagramChannels.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
class DatagramChannelImpl
extends DatagramChannel
implements SelChImpl
diff --git a/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java b/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java
index a7779b0..8bcc1c4 100644
--- a/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java
+++ b/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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,21 +25,19 @@
package sun.nio.ch.sctp;
import com.sun.nio.sctp.SctpSocketOption;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class SctpStdSocketOption<T>
implements SctpSocketOption<T>
{
/* for native mapping of int options */
- public static final int SCTP_DISABLE_FRAGMENTS = 1;
- public static final int SCTP_EXPLICIT_COMPLETE = 2;
- public static final int SCTP_FRAGMENT_INTERLEAVE = 3;
- public static final int SCTP_NODELAY = 4;
- public static final int SO_SNDBUF = 5;
- public static final int SO_RCVBUF = 6;
- public static final int SO_LINGER = 7;
+ @Native public static final int SCTP_DISABLE_FRAGMENTS = 1;
+ @Native public static final int SCTP_EXPLICIT_COMPLETE = 2;
+ @Native public static final int SCTP_FRAGMENT_INTERLEAVE = 3;
+ @Native public static final int SCTP_NODELAY = 4;
+ @Native public static final int SO_SNDBUF = 5;
+ @Native public static final int SO_RCVBUF = 6;
+ @Native public static final int SO_LINGER = 7;
private final String name;
private final Class<T> type;
diff --git a/src/share/classes/sun/reflect/annotation/AnnotationType.java b/src/share/classes/sun/reflect/annotation/AnnotationType.java
index 530834c..cfc1444 100644
--- a/src/share/classes/sun/reflect/annotation/AnnotationType.java
+++ b/src/share/classes/sun/reflect/annotation/AnnotationType.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2006, 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
@@ -45,19 +45,18 @@
* types. This matches the return value that must be used for a
* dynamic proxy, allowing for a simple isInstance test.
*/
- private final Map<String, Class<?>> memberTypes = new HashMap<String,Class<?>>();
+ private final Map<String, Class<?>> memberTypes;
/**
* Member name -> default value mapping.
*/
- private final Map<String, Object> memberDefaults =
- new HashMap<String, Object>();
+ private final Map<String, Object> memberDefaults;
/**
* Member name -> Method object mapping. This (and its assoicated
* accessor) are used only to generate AnnotationTypeMismatchExceptions.
*/
- private final Map<String, Method> members = new HashMap<String, Method>();
+ private final Map<String, Method> members;
/**
* The retention policy for this annotation type.
@@ -105,6 +104,9 @@
}
});
+ memberTypes = new HashMap<String,Class<?>>(methods.length+1, 1.0f);
+ memberDefaults = new HashMap<String, Object>(0);
+ members = new HashMap<String, Method>(methods.length+1, 1.0f);
for (Method method : methods) {
if (method.getParameterTypes().length != 0)
@@ -117,8 +119,6 @@
Object defaultValue = method.getDefaultValue();
if (defaultValue != null)
memberDefaults.put(name, defaultValue);
-
- members.put(name, method);
}
sun.misc.SharedSecrets.getJavaLangAccess().
diff --git a/src/share/classes/sun/security/krb5/KdcComm.java b/src/share/classes/sun/security/krb5/KdcComm.java
index 6a40bac..80c0af4 100644
--- a/src/share/classes/sun/security/krb5/KdcComm.java
+++ b/src/share/classes/sun/security/krb5/KdcComm.java
@@ -138,7 +138,7 @@
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 @@
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 @@
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();
}
diff --git a/src/share/classes/sun/security/krb5/PrincipalName.java b/src/share/classes/sun/security/krb5/PrincipalName.java
index f4cbecd..fc3b71f 100644
--- a/src/share/classes/sun/security/krb5/PrincipalName.java
+++ b/src/share/classes/sun/security/krb5/PrincipalName.java
@@ -499,7 +499,7 @@
}
public String[] getNameStrings() {
- return nameStrings;
+ return nameStrings.clone();
}
public byte[][] toByteArray() {
diff --git a/src/share/classes/sun/security/krb5/internal/Krb5.java b/src/share/classes/sun/security/krb5/internal/Krb5.java
index 1d3bb64..1861c39 100644
--- a/src/share/classes/sun/security/krb5/internal/Krb5.java
+++ b/src/share/classes/sun/security/krb5/internal/Krb5.java
@@ -130,6 +130,8 @@
// 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
diff --git a/src/share/classes/sun/security/pkcs/PKCS7.java b/src/share/classes/sun/security/pkcs/PKCS7.java
index fa67e29..8c3c947 100644
--- a/src/share/classes/sun/security/pkcs/PKCS7.java
+++ b/src/share/classes/sun/security/pkcs/PKCS7.java
@@ -161,7 +161,8 @@
} catch (IOException ioe1) {
ParsingException pe = new ParsingException(
ioe1.getMessage());
- pe.initCause(ioe1);
+ pe.initCause(ioe);
+ pe.addSuppressed(ioe1);
throw pe;
}
}
@@ -310,19 +311,26 @@
len = certVals.length;
certificates = new X509Certificate[len];
+ int count = 0;
for (int i = 0; i < len; i++) {
ByteArrayInputStream bais = null;
try {
- if (certfac == null)
- certificates[i] = new X509CertImpl(certVals[i]);
- else {
- byte[] encoded = certVals[i].toByteArray();
- bais = new ByteArrayInputStream(encoded);
- certificates[i] =
- (X509Certificate)certfac.generateCertificate(bais);
- bais.close();
- bais = null;
+ byte tag = certVals[i].getTag();
+ // We only parse the normal certificate. Other types of
+ // CertificateChoices ignored.
+ if (tag == DerValue.tag_Sequence) {
+ if (certfac == null) {
+ certificates[count] = new X509CertImpl(certVals[i]);
+ } else {
+ byte[] encoded = certVals[i].toByteArray();
+ bais = new ByteArrayInputStream(encoded);
+ certificates[count] =
+ (X509Certificate)certfac.generateCertificate(bais);
+ bais.close();
+ bais = null;
+ }
+ count++;
}
} catch (CertificateException ce) {
ParsingException pe = new ParsingException(ce.getMessage());
@@ -337,6 +345,9 @@
bais.close();
}
}
+ if (count != len) {
+ certificates = Arrays.copyOf(certificates, count);
+ }
}
// check if crls (implicit tag) are provided (crls are OPTIONAL)
diff --git a/src/share/classes/sun/security/pkcs/PKCS9Attribute.java b/src/share/classes/sun/security/pkcs/PKCS9Attribute.java
index 64ead04..0a9e3a5 100644
--- a/src/share/classes/sun/security/pkcs/PKCS9Attribute.java
+++ b/src/share/classes/sun/security/pkcs/PKCS9Attribute.java
@@ -42,12 +42,14 @@
/**
* Class supporting any PKCS9 attributes.
- * Supports DER decoding and access to attribute values, but not
- * DER encoding or setting of values.
+ * Supports DER decoding/encoding and access to attribute values.
*
* <a name="classTable"><h3>Type/Class Table</h3></a>
* The following table shows the correspondence between
* PKCS9 attribute types and value component classes.
+ * For types not listed here, its name is the OID
+ * in string form, its value is a (single-valued)
+ * byte array that is the SET's encoding.
*
* <P>
* <TABLE BORDER CELLPADDING=8 ALIGN=CENTER>
@@ -185,6 +187,8 @@
*/
static final ObjectIdentifier[] PKCS9_OIDS = new ObjectIdentifier[18];
+ private final static Class<?> BYTE_ARRAY_CLASS;
+
static { // static initializer for PKCS9_OIDS
for (int i = 1; i < PKCS9_OIDS.length - 2; i++) {
PKCS9_OIDS[i] =
@@ -196,6 +200,12 @@
ObjectIdentifier.newInternal(new int[]{1,2,840,113549,1,9,16,2,12});
PKCS9_OIDS[PKCS9_OIDS.length - 1] =
ObjectIdentifier.newInternal(new int[]{1,2,840,113549,1,9,16,2,14});
+
+ try {
+ BYTE_ARRAY_CLASS = Class.forName("[B");
+ } catch (ClassNotFoundException e) {
+ throw new ExceptionInInitializerError(e.toString());
+ }
}
// first element [0] not used
@@ -331,7 +341,7 @@
VALUE_CLASSES[2] = str; // UnstructuredName
VALUE_CLASSES[3] = // ContentType
Class.forName("sun.security.util.ObjectIdentifier");
- VALUE_CLASSES[4] = Class.forName("[B"); // MessageDigest (byte[])
+ VALUE_CLASSES[4] = BYTE_ARRAY_CLASS; // MessageDigest (byte[])
VALUE_CLASSES[5] = Class.forName("java.util.Date"); // SigningTime
VALUE_CLASSES[6] = // Countersignature
Class.forName("[Lsun.security.pkcs.SignerInfo;");
@@ -347,7 +357,7 @@
Class.forName("sun.security.x509.CertificateExtensions");
VALUE_CLASSES[15] = null; // not supported yet
VALUE_CLASSES[16] = null; // not supported yet
- VALUE_CLASSES[17] = Class.forName("[B"); // SignatureTimestampToken
+ VALUE_CLASSES[17] = BYTE_ARRAY_CLASS; // SignatureTimestampToken
} catch (ClassNotFoundException e) {
throw new ExceptionInInitializerError(e.toString());
}
@@ -379,13 +389,20 @@
};
/**
- * The OID of this attribute is <code>PKCS9_OIDS[index]</code>.
+ * The OID of this attribute.
+ */
+ private ObjectIdentifier oid;
+
+ /**
+ * The index of the OID of this attribute in <code>PKCS9_OIDS</code>,
+ * or -1 if it's unknown.
*/
private int index;
/**
* Value set of this attribute. Its class is given by
- * <code>VALUE_CLASSES[index]</code>.
+ * <code>VALUE_CLASSES[index]</code>. The SET itself
+ * as byte[] if unknown.
*/
private Object value;
@@ -400,6 +417,8 @@
* <a href=#classTable>table</a> gives the class that <code>value</code>
* must have for a given attribute.
*
+ * @exception IllegalArgumentException
+ * if the <code>value</code> has the wrong type.
*/
public PKCS9Attribute(ObjectIdentifier oid, Object value)
throws IllegalArgumentException {
@@ -419,7 +438,7 @@
* attributes are accepted; in particular, case does not matter.
*
* @exception IllegalArgumentException
- * if the <code>name</code> is not recognized of the
+ * if the <code>name</code> is not recognized or the
* <code>value</code> has the wrong type.
*/
public PKCS9Attribute(String name, Object value)
@@ -437,21 +456,17 @@
private void init(ObjectIdentifier oid, Object value)
throws IllegalArgumentException {
+ this.oid = oid;
index = indexOf(oid, PKCS9_OIDS, 1);
-
- if (index == -1)
- throw new IllegalArgumentException(
- "Unsupported OID " + oid +
- " constructing PKCS9Attribute.");
-
- if (!VALUE_CLASSES[index].isInstance(value))
+ Class<?> clazz = index == -1 ? BYTE_ARRAY_CLASS: VALUE_CLASSES[index];
+ if (!clazz.isInstance(value)) {
throw new IllegalArgumentException(
"Wrong value class " +
" for attribute " + oid +
" constructing PKCS9Attribute; was " +
value.getClass().toString() + ", should be " +
- VALUE_CLASSES[index].toString());
-
+ clazz.toString());
+ }
this.value = value;
}
@@ -475,16 +490,19 @@
throw new IOException("PKCS9Attribute doesn't have two components");
// get the oid
- ObjectIdentifier oid = val[0].getOID();
+ oid = val[0].getOID();
+ byte[] content = val[1].toByteArray();
+ DerValue[] elems = new DerInputStream(content).getSet(1);
+
index = indexOf(oid, PKCS9_OIDS, 1);
if (index == -1) {
if (debug != null) {
- debug.println("ignoring unsupported signer attribute: " + oid);
+ debug.println("Unsupported signer attribute: " + oid);
}
- throw new ParsingException("Unsupported PKCS9 attribute: " + oid);
+ value = content;
+ return;
}
- DerValue[] elems = new DerInputStream(val[1].toByteArray()).getSet(1);
// check single valued have only one value
if (SINGLE_VALUED[index] && elems.length > 1)
throwSingleValuedException();
@@ -584,8 +602,11 @@
*/
public void derEncode(OutputStream out) throws IOException {
DerOutputStream temp = new DerOutputStream();
- temp.putOID(getOID());
+ temp.putOID(oid);
switch (index) {
+ case -1: // Unknown
+ temp.write((byte[])value);
+ break;
case 1: // email address
case 2: // unstructured name
{ // open scope
@@ -704,6 +725,14 @@
}
/**
+ * Returns if the attribute is known. Unknown attributes can be created
+ * from DER encoding with unknown OIDs.
+ */
+ public boolean isKnown() {
+ return index != -1;
+ }
+
+ /**
* Get the value of this attribute. If the attribute is
* single-valued, return just the one value. If the attribute is
* multi-valued, return an array containing all the values.
@@ -721,21 +750,23 @@
* Show whether this attribute is single-valued.
*/
public boolean isSingleValued() {
- return SINGLE_VALUED[index];
+ return index == -1 || SINGLE_VALUED[index];
}
/**
* Return the OID of this attribute.
*/
public ObjectIdentifier getOID() {
- return PKCS9_OIDS[index];
+ return oid;
}
/**
* Return the name of this attribute.
*/
public String getName() {
- return OID_NAME_TABLE.get(PKCS9_OIDS[index]);
+ return index == -1 ?
+ oid.toString() :
+ OID_NAME_TABLE.get(PKCS9_OIDS[index]);
}
/**
@@ -762,10 +793,14 @@
buf.append("[");
- buf.append(OID_NAME_TABLE.get(PKCS9_OIDS[index]));
+ if (index == -1) {
+ buf.append(oid.toString());
+ } else {
+ buf.append(OID_NAME_TABLE.get(PKCS9_OIDS[index]));
+ }
buf.append(": ");
- if (SINGLE_VALUED[index]) {
+ if (index == -1 || SINGLE_VALUED[index]) {
if (value instanceof byte[]) { // special case for octet string
HexDumpEncoder hexDump = new HexDumpEncoder();
buf.append(hexDump.encodeBuffer((byte[]) value));
@@ -809,20 +844,21 @@
*/
private void throwSingleValuedException() throws IOException {
throw new IOException("Single-value attribute " +
- getOID() + " (" + getName() + ")" +
+ oid + " (" + getName() + ")" +
" has multiple values.");
}
/**
* Throw an exception when the tag on a value encoding is
- * wrong for the attribute whose value it is.
+ * wrong for the attribute whose value it is. This method
+ * will only be called for known tags.
*/
private void throwTagException(Byte tag)
throws IOException {
Byte[] expectedTags = PKCS9_VALUE_TAGS[index];
StringBuffer msg = new StringBuffer(100);
msg.append("Value of attribute ");
- msg.append(getOID().toString());
+ msg.append(oid.toString());
msg.append(" (");
msg.append(getName());
msg.append(") has wrong tag: ");
diff --git a/src/share/classes/sun/security/pkcs11/Secmod.java b/src/share/classes/sun/security/pkcs11/Secmod.java
index de4d12e..07651fe 100644
--- a/src/share/classes/sun/security/pkcs11/Secmod.java
+++ b/src/share/classes/sun/security/pkcs11/Secmod.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, 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
@@ -35,7 +35,6 @@
import sun.security.pkcs11.wrapper.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* The Secmod class defines the interface to the native NSS
@@ -57,8 +56,6 @@
* @since 1.6
* @author Andreas Sterbenz
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public final class Secmod {
private final static boolean DEBUG = false;
diff --git a/src/share/classes/sun/security/pkcs11/wrapper/PKCS11.java b/src/share/classes/sun/security/pkcs11/wrapper/PKCS11.java
index 0284244..0ada894 100644
--- a/src/share/classes/sun/security/pkcs11/wrapper/PKCS11.java
+++ b/src/share/classes/sun/security/pkcs11/wrapper/PKCS11.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@@ -55,7 +55,6 @@
import java.security.PrivilegedAction;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
-import javax.tools.annotation.GenerateNativeHeader;
/**
* This is the default implementation of the PKCS11 interface. IT connects to
@@ -68,8 +67,6 @@
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
* @invariants (pkcs11ModulePath_ <> null)
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class PKCS11 {
/**
diff --git a/src/share/classes/sun/security/provider/certpath/CertId.java b/src/share/classes/sun/security/provider/certpath/CertId.java
index 731111e..ff7be69 100644
--- a/src/share/classes/sun/security/provider/certpath/CertId.java
+++ b/src/share/classes/sun/security/provider/certpath/CertId.java
@@ -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.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 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 @@
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 @@
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 " +
diff --git a/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java b/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java
index 136aacd..ab78452 100644
--- a/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java
+++ b/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java
@@ -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 @@
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 @@
// 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)) {
diff --git a/src/share/classes/sun/security/provider/certpath/RevocationChecker.java b/src/share/classes/sun/security/provider/certpath/RevocationChecker.java
index b65b6df..98d8a9d 100644
--- a/src/share/classes/sun/security/provider/certpath/RevocationChecker.java
+++ b/src/share/classes/sun/security/provider/certpath/RevocationChecker.java
@@ -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 @@
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);
diff --git a/src/share/classes/sun/security/tools/keytool/Main.java b/src/share/classes/sun/security/tools/keytool/Main.java
index a33e00a..c8e96eb 100644
--- a/src/share/classes/sun/security/tools/keytool/Main.java
+++ b/src/share/classes/sun/security/tools/keytool/Main.java
@@ -1832,9 +1832,9 @@
if (alias != null) {
doImportKeyStoreSingle(loadSourceKeyStore(), alias);
} else {
- if (dest != null || srckeyPass != null || destKeyPass != null) {
+ if (dest != null || srckeyPass != null) {
throw new Exception(rb.getString(
- "if.alias.not.specified.destalias.srckeypass.and.destkeypass.must.not.be.specified"));
+ "if.alias.not.specified.destalias.and.srckeypass.must.not.be.specified"));
}
doImportKeyStoreAll(loadSourceKeyStore());
}
@@ -1888,14 +1888,25 @@
// using destkeypass. If destkeypass is not provided, the destination
// entry will be protected with the source entry password."
// so always try to protect with destKeyPass.
+ char[] newPass = null;
if (destKeyPass != null) {
+ newPass = destKeyPass;
pp = new PasswordProtection(destKeyPass);
} else if (objs.snd != null) {
+ newPass = objs.snd;
pp = new PasswordProtection(objs.snd);
}
try {
keyStore.setEntry(newAlias, entry, pp);
+ // Place the check so that only successful imports are blocked.
+ // For example, we don't block a failed SecretEntry import.
+ if (P12KEYSTORE.equalsIgnoreCase(storetype)) {
+ if (newPass != null && !Arrays.equals(newPass, storePass)) {
+ throw new Exception(rb.getString(
+ "The.destination.pkcs12.keystore.has.different.storepass.and.keypass.Please.retry.with.destkeypass.specified."));
+ }
+ }
return 1;
} catch (KeyStoreException kse) {
Object[] source2 = {alias, kse.toString()};
diff --git a/src/share/classes/sun/security/tools/keytool/Resources.java b/src/share/classes/sun/security/tools/keytool/Resources.java
index 262fe20..393aa3b 100644
--- a/src/share/classes/sun/security/tools/keytool/Resources.java
+++ b/src/share/classes/sun/security/tools/keytool/Resources.java
@@ -242,8 +242,10 @@
{"Certification.request.stored.in.file.filename.",
"Certification request stored in file <{0}>"},
{"Submit.this.to.your.CA", "Submit this to your CA"},
- {"if.alias.not.specified.destalias.srckeypass.and.destkeypass.must.not.be.specified",
- "if alias not specified, destalias, srckeypass, and destkeypass must not be specified"},
+ {"if.alias.not.specified.destalias.and.srckeypass.must.not.be.specified",
+ "if alias not specified, destalias and srckeypass must not be specified"},
+ {"The.destination.pkcs12.keystore.has.different.storepass.and.keypass.Please.retry.with.destkeypass.specified.",
+ "The destination pkcs12 keystore has different storepass and keypass. Please retry with -destkeypass specified."},
{"Certificate.stored.in.file.filename.",
"Certificate stored in file <{0}>"},
{"Certificate.reply.was.installed.in.keystore",
diff --git a/src/share/classes/sun/security/x509/X509CertImpl.java b/src/share/classes/sun/security/x509/X509CertImpl.java
index 1593e5e..bd59b62 100644
--- a/src/share/classes/sun/security/x509/X509CertImpl.java
+++ b/src/share/classes/sun/security/x509/X509CertImpl.java
@@ -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 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
diff --git a/src/share/classes/sun/tools/jmap/JMap.java b/src/share/classes/sun/tools/jmap/JMap.java
index 5350c31..8c127ac 100644
--- a/src/share/classes/sun/tools/jmap/JMap.java
+++ b/src/share/classes/sun/tools/jmap/JMap.java
@@ -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 @@
// 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 @@
// 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 @@
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:");
diff --git a/src/share/classes/sun/tools/jstat/resources/jstat_options b/src/share/classes/sun/tools/jstat/resources/jstat_options
index 14a2d05..bead542 100644
--- a/src/share/classes/sun/tools/jstat/resources/jstat_options
+++ b/src/share/classes/sun/tools/jstat/resources/jstat_options
@@ -192,16 +192,16 @@
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 @@
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 @@
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 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 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 @@
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
diff --git a/src/share/classes/sun/util/locale/LanguageTag.java b/src/share/classes/sun/util/locale/LanguageTag.java
index fc7b07b..0de8710 100644
--- a/src/share/classes/sun/util/locale/LanguageTag.java
+++ b/src/share/classes/sun/util/locale/LanguageTag.java
@@ -134,7 +134,7 @@
}
/*
- * BNF in RFC5464
+ * BNF in RFC5646
*
* Language-Tag = langtag ; normal language tags
* / privateuse ; private use tag
diff --git a/src/share/classes/sun/util/locale/provider/AuxLocaleProviderAdapter.java b/src/share/classes/sun/util/locale/provider/AuxLocaleProviderAdapter.java
index 78edef1..6389bcc 100644
--- a/src/share/classes/sun/util/locale/provider/AuxLocaleProviderAdapter.java
+++ b/src/share/classes/sun/util/locale/provider/AuxLocaleProviderAdapter.java
@@ -43,6 +43,7 @@
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 @@
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;
diff --git a/src/share/classes/sun/util/locale/provider/CalendarProviderImpl.java b/src/share/classes/sun/util/locale/provider/CalendarProviderImpl.java
new file mode 100644
index 0000000..05e99a2
--- /dev/null
+++ b/src/share/classes/sun/util/locale/provider/CalendarProviderImpl.java
@@ -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;
+ }
+}
diff --git a/src/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java b/src/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java
index cd33bc2..beabfd1 100644
--- a/src/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java
+++ b/src/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java
@@ -34,10 +34,12 @@
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.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 @@
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 @@
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 @@
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);
diff --git a/src/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java b/src/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java
index d7e3240..fa5eac1 100644
--- a/src/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java
+++ b/src/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java
@@ -47,6 +47,7 @@
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 @@
}
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 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();
diff --git a/src/share/classes/sun/util/logging/LoggingProxy.java b/src/share/classes/sun/util/logging/LoggingProxy.java
index 5d8e999..41fb7c8 100644
--- a/src/share/classes/sun/util/logging/LoggingProxy.java
+++ b/src/share/classes/sun/util/logging/LoggingProxy.java
@@ -61,6 +61,8 @@
public String getLevelName(Object level);
+ public int getLevelValue(Object level);
+
// return the logging property
public String getProperty(String key);
}
diff --git a/src/share/classes/sun/util/logging/LoggingSupport.java b/src/share/classes/sun/util/logging/LoggingSupport.java
index 27f0109..eed1c8f 100644
--- a/src/share/classes/sun/util/logging/LoggingSupport.java
+++ b/src/share/classes/sun/util/logging/LoggingSupport.java
@@ -140,6 +140,11 @@
return proxy.getLevelName(level);
}
+ public static int getLevelValue(Object level) {
+ ensureAvailable();
+ return proxy.getLevelValue(level);
+ }
+
private static final String DEFAULT_FORMAT =
"%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%6$s%n";
diff --git a/src/share/classes/sun/util/logging/PlatformLogger.java b/src/share/classes/sun/util/logging/PlatformLogger.java
index 000a160..9a1b893 100644
--- a/src/share/classes/sun/util/logging/PlatformLogger.java
+++ b/src/share/classes/sun/util/logging/PlatformLogger.java
@@ -27,14 +27,12 @@
package sun.util.logging;
import java.lang.ref.WeakReference;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.text.MessageFormat;
+import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -87,7 +85,13 @@
* @since 1.7
*/
public class PlatformLogger {
- // Same values as java.util.logging.Level for easy mapping
+ /*
+ * These constants should be shortcuts to Level enum constants that
+ * the clients of sun.util.logging.PlatformLogger require no source
+ * modification and avoid the conversion from int to Level enum.
+ *
+ * This can be done when JavaFX is converted to use the new PlatformLogger.Level API.
+ */
public static final int OFF = Integer.MAX_VALUE;
public static final int SEVERE = 1000;
public static final int WARNING = 900;
@@ -98,7 +102,63 @@
public static final int FINEST = 300;
public static final int ALL = Integer.MIN_VALUE;
- private static final int defaultLevel = INFO;
+ /**
+ * PlatformLogger logging levels.
+ */
+ public static enum Level {
+ // The name and value must match that of {@code java.util.logging.Level}s.
+ // Declare in ascending order of the given value for binary search.
+ ALL,
+ FINEST,
+ FINER,
+ FINE,
+ CONFIG,
+ INFO,
+ WARNING,
+ SEVERE,
+ OFF;
+
+ /**
+ * Associated java.util.logging.Level lazily initialized in
+ * JavaLoggerProxy's static initializer only once
+ * when java.util.logging is available and enabled.
+ * Only accessed by JavaLoggerProxy.
+ */
+ /* java.util.logging.Level */ Object javaLevel;
+
+ // ascending order for binary search matching the list of enum constants
+ private static final int[] levelValues = new int[] {
+ PlatformLogger.ALL, PlatformLogger.FINEST, PlatformLogger.FINER,
+ PlatformLogger.FINE, PlatformLogger.CONFIG, PlatformLogger.INFO,
+ PlatformLogger.WARNING, PlatformLogger.SEVERE, PlatformLogger.OFF
+ };
+
+ public int intValue() {
+ return levelValues[this.ordinal()];
+ }
+
+ static Level valueOf(int level) {
+ switch (level) {
+ // ordering per the highest occurences in the jdk source
+ // finest, fine, finer, info first
+ case PlatformLogger.FINEST : return Level.FINEST;
+ case PlatformLogger.FINE : return Level.FINE;
+ case PlatformLogger.FINER : return Level.FINER;
+ case PlatformLogger.INFO : return Level.INFO;
+ case PlatformLogger.WARNING : return Level.WARNING;
+ case PlatformLogger.CONFIG : return Level.CONFIG;
+ case PlatformLogger.SEVERE : return Level.SEVERE;
+ case PlatformLogger.OFF : return Level.OFF;
+ case PlatformLogger.ALL : return Level.ALL;
+ }
+ // return the nearest Level value >= the given level,
+ // for level > SEVERE, return SEVERE and exclude OFF
+ int i = Arrays.binarySearch(levelValues, 0, levelValues.length-2, level);
+ return values()[i >= 0 ? i : (-i-1)];
+ }
+ }
+
+ private static final Level DEFAULT_LEVEL = Level.INFO;
private static boolean loggingEnabled;
static {
loggingEnabled = AccessController.doPrivileged(
@@ -109,6 +169,20 @@
return (cname != null || fname != null);
}
});
+
+ // force loading of all JavaLoggerProxy (sub)classes to make JIT de-optimizations
+ // less probable. Don't initialize JavaLoggerProxy class since
+ // java.util.logging may not be enabled.
+ try {
+ Class.forName("sun.util.logging.PlatformLogger$DefaultLoggerProxy",
+ false,
+ PlatformLogger.class.getClassLoader());
+ Class.forName("sun.util.logging.PlatformLogger$JavaLoggerProxy",
+ false, // do not invoke class initializer
+ PlatformLogger.class.getClassLoader());
+ } catch (ClassNotFoundException ex) {
+ throw new InternalError(ex);
+ }
}
// Table of known loggers. Maps names to PlatformLoggers.
@@ -143,27 +217,32 @@
WeakReference<PlatformLogger> ref = entry.getValue();
PlatformLogger plog = ref.get();
if (plog != null) {
- plog.newJavaLogger();
+ plog.redirectToJavaLoggerProxy();
}
}
}
/**
- * Creates a new JavaLogger that the platform logger uses
+ * Creates a new JavaLoggerProxy and redirects the platform logger to it
*/
- private void newJavaLogger() {
- logger = new JavaLogger(logger.name, logger.effectiveLevel);
+ private void redirectToJavaLoggerProxy() {
+ DefaultLoggerProxy lp = DefaultLoggerProxy.class.cast(this.loggerProxy);
+ JavaLoggerProxy jlp = new JavaLoggerProxy(lp.name, lp.level);
+ // the order of assignments is important
+ this.javaLoggerProxy = jlp; // isLoggable checks javaLoggerProxy if set
+ this.loggerProxy = jlp;
}
- // logger may be replaced with a JavaLogger object
- // when the logging facility is enabled
- private volatile LoggerProxy logger;
-
+ // DefaultLoggerProxy may be replaced with a JavaLoggerProxy object
+ // when the java.util.logging facility is enabled
+ private volatile LoggerProxy loggerProxy;
+ // javaLoggerProxy is only set when the java.util.logging facility is enabled
+ private volatile JavaLoggerProxy javaLoggerProxy;
private PlatformLogger(String name) {
if (loggingEnabled) {
- this.logger = new JavaLogger(name);
+ this.loggerProxy = this.javaLoggerProxy = new JavaLoggerProxy(name);
} else {
- this.logger = new LoggerProxy(name);
+ this.loggerProxy = new DefaultLoggerProxy(name);
}
}
@@ -172,204 +251,278 @@
* (i.e. its level is OFF).
*/
public boolean isEnabled() {
- return logger.isEnabled();
+ return loggerProxy.isEnabled();
}
/**
* Gets the name for this platform logger.
*/
public String getName() {
- return logger.name;
+ return loggerProxy.name;
+ }
+
+ /**
+ * Returns true if a message of the given level would actually
+ * be logged by this logger.
+ *
+ * @deprecated Use isLoggable(Level) instead.
+ */
+ @Deprecated
+ public boolean isLoggable(int levelValue) {
+ return isLoggable(Level.valueOf(levelValue));
+ }
+
+ /**
+ * Gets the current log level. Returns 0 if the current effective level is
+ * not set (equivalent to Logger.getLevel() returns null).
+ *
+ * @deprecated Use level() instead
+ */
+ @Deprecated
+ public int getLevel() {
+ Level level = loggerProxy.getLevel();
+ return level != null ? level.intValue() : 0;
+ }
+
+ /**
+ * Sets the log level.
+ *
+ * @deprecated Use setLevel(Level) instead
+ */
+ @Deprecated
+ public void setLevel(int newLevel) {
+ loggerProxy.setLevel(newLevel == 0 ? null : Level.valueOf(newLevel));
}
/**
* Returns true if a message of the given level would actually
* be logged by this logger.
*/
- public boolean isLoggable(int level) {
- return logger.isLoggable(level);
+ public boolean isLoggable(Level level) {
+ if (level == null) {
+ throw new NullPointerException();
+ }
+ // performance-sensitive method: use two monomorphic call-sites
+ JavaLoggerProxy jlp = javaLoggerProxy;
+ return jlp != null ? jlp.isLoggable(level) : loggerProxy.isLoggable(level);
}
/**
- * Gets the current log level. Returns 0 if the current effective level
- * is not set (equivalent to Logger.getLevel() returns null).
+ * Get the log level that has been specified for this PlatformLogger.
+ * The result may be null, which means that this logger's
+ * effective level will be inherited from its parent.
+ *
+ * @return this PlatformLogger's level
*/
- public int getLevel() {
- return logger.getLevel();
+ public Level level() {
+ return loggerProxy.getLevel();
}
/**
- * Sets the log level.
+ * Set the log level specifying which message levels will be
+ * logged by this logger. Message levels lower than this
+ * value will be discarded. The level value {@link #OFF}
+ * can be used to turn off logging.
+ * <p>
+ * If the new level is null, it means that this node should
+ * inherit its level from its nearest ancestor with a specific
+ * (non-null) level value.
+ *
+ * @param newLevel the new value for the log level (may be null)
*/
- public void setLevel(int newLevel) {
- logger.setLevel(newLevel);
+ public void setLevel(Level newLevel) {
+ loggerProxy.setLevel(newLevel);
}
/**
* Logs a SEVERE message.
*/
public void severe(String msg) {
- logger.doLog(SEVERE, msg);
+ loggerProxy.doLog(Level.SEVERE, msg);
}
public void severe(String msg, Throwable t) {
- logger.doLog(SEVERE, msg, t);
+ loggerProxy.doLog(Level.SEVERE, msg, t);
}
public void severe(String msg, Object... params) {
- logger.doLog(SEVERE, msg, params);
+ loggerProxy.doLog(Level.SEVERE, msg, params);
}
/**
* Logs a WARNING message.
*/
public void warning(String msg) {
- logger.doLog(WARNING, msg);
+ loggerProxy.doLog(Level.WARNING, msg);
}
public void warning(String msg, Throwable t) {
- logger.doLog(WARNING, msg, t);
+ loggerProxy.doLog(Level.WARNING, msg, t);
}
public void warning(String msg, Object... params) {
- logger.doLog(WARNING, msg, params);
+ loggerProxy.doLog(Level.WARNING, msg, params);
}
/**
* Logs an INFO message.
*/
public void info(String msg) {
- logger.doLog(INFO, msg);
+ loggerProxy.doLog(Level.INFO, msg);
}
public void info(String msg, Throwable t) {
- logger.doLog(INFO, msg, t);
+ loggerProxy.doLog(Level.INFO, msg, t);
}
public void info(String msg, Object... params) {
- logger.doLog(INFO, msg, params);
+ loggerProxy.doLog(Level.INFO, msg, params);
}
/**
* Logs a CONFIG message.
*/
public void config(String msg) {
- logger.doLog(CONFIG, msg);
+ loggerProxy.doLog(Level.CONFIG, msg);
}
public void config(String msg, Throwable t) {
- logger.doLog(CONFIG, msg, t);
+ loggerProxy.doLog(Level.CONFIG, msg, t);
}
public void config(String msg, Object... params) {
- logger.doLog(CONFIG, msg, params);
+ loggerProxy.doLog(Level.CONFIG, msg, params);
}
/**
* Logs a FINE message.
*/
public void fine(String msg) {
- logger.doLog(FINE, msg);
+ loggerProxy.doLog(Level.FINE, msg);
}
public void fine(String msg, Throwable t) {
- logger.doLog(FINE, msg, t);
+ loggerProxy.doLog(Level.FINE, msg, t);
}
public void fine(String msg, Object... params) {
- logger.doLog(FINE, msg, params);
+ loggerProxy.doLog(Level.FINE, msg, params);
}
/**
* Logs a FINER message.
*/
public void finer(String msg) {
- logger.doLog(FINER, msg);
+ loggerProxy.doLog(Level.FINER, msg);
}
public void finer(String msg, Throwable t) {
- logger.doLog(FINER, msg, t);
+ loggerProxy.doLog(Level.FINER, msg, t);
}
public void finer(String msg, Object... params) {
- logger.doLog(FINER, msg, params);
+ loggerProxy.doLog(Level.FINER, msg, params);
}
/**
* Logs a FINEST message.
*/
public void finest(String msg) {
- logger.doLog(FINEST, msg);
+ loggerProxy.doLog(Level.FINEST, msg);
}
public void finest(String msg, Throwable t) {
- logger.doLog(FINEST, msg, t);
+ loggerProxy.doLog(Level.FINEST, msg, t);
}
public void finest(String msg, Object... params) {
- logger.doLog(FINEST, msg, params);
+ loggerProxy.doLog(Level.FINEST, msg, params);
}
/**
- * Default platform logging support - output messages to
- * System.err - equivalent to ConsoleHandler with SimpleFormatter.
+ * Abstract base class for logging support, defining the API and common field.
*/
- static class LoggerProxy {
- private static final PrintStream defaultStream = System.err;
-
+ private static abstract class LoggerProxy {
final String name;
- volatile int levelValue;
- volatile int effectiveLevel = 0; // current effective level value
- LoggerProxy(String name) {
- this(name, defaultLevel);
+ protected LoggerProxy(String name) {
+ this.name = name;
}
- LoggerProxy(String name, int level) {
- this.name = name;
- this.levelValue = level == 0 ? defaultLevel : level;
+ abstract boolean isEnabled();
+
+ abstract Level getLevel();
+ abstract void setLevel(Level newLevel);
+
+ abstract void doLog(Level level, String msg);
+ abstract void doLog(Level level, String msg, Throwable thrown);
+ abstract void doLog(Level level, String msg, Object... params);
+
+ abstract boolean isLoggable(Level level);
+ }
+
+
+ private static final class DefaultLoggerProxy extends LoggerProxy {
+ /**
+ * Default platform logging support - output messages to System.err -
+ * equivalent to ConsoleHandler with SimpleFormatter.
+ */
+ private static PrintStream outputStream() {
+ return System.err;
+ }
+
+ volatile Level effectiveLevel; // effective level (never null)
+ volatile Level level; // current level set for this node (may be null)
+
+ DefaultLoggerProxy(String name) {
+ super(name);
+ this.effectiveLevel = deriveEffectiveLevel(null);
+ this.level = null;
}
boolean isEnabled() {
- return levelValue != OFF;
+ return effectiveLevel != Level.OFF;
}
- int getLevel() {
- return effectiveLevel;
+ Level getLevel() {
+ return level;
}
- void setLevel(int newLevel) {
- levelValue = newLevel;
- effectiveLevel = newLevel;
- }
-
- void doLog(int level, String msg) {
- if (level < levelValue || levelValue == OFF) {
- return;
+ void setLevel(Level newLevel) {
+ Level oldLevel = level;
+ if (oldLevel != newLevel) {
+ level = newLevel;
+ effectiveLevel = deriveEffectiveLevel(newLevel);
}
- defaultStream.print(format(level, msg, null));
}
- void doLog(int level, String msg, Throwable thrown) {
- if (level < levelValue || levelValue == OFF) {
- return;
+ void doLog(Level level, String msg) {
+ if (isLoggable(level)) {
+ outputStream().print(format(level, msg, null));
}
- defaultStream.print(format(level, msg, thrown));
}
- void doLog(int level, String msg, Object... params) {
- if (level < levelValue || levelValue == OFF) {
- return;
+ void doLog(Level level, String msg, Throwable thrown) {
+ if (isLoggable(level)) {
+ outputStream().print(format(level, msg, thrown));
}
- String newMsg = formatMessage(msg, params);
- defaultStream.print(format(level, newMsg, null));
}
- public boolean isLoggable(int level) {
- if (level < levelValue || levelValue == OFF) {
- return false;
+ void doLog(Level level, String msg, Object... params) {
+ if (isLoggable(level)) {
+ String newMsg = formatMessage(msg, params);
+ outputStream().print(format(level, newMsg, null));
}
- return true;
+ }
+
+ boolean isLoggable(Level level) {
+ Level effectiveLevel = this.effectiveLevel;
+ return level.intValue() >= effectiveLevel.intValue() && effectiveLevel != Level.OFF;
+ }
+
+ // derive effective level (could do inheritance search like j.u.l.Logger)
+ private Level deriveEffectiveLevel(Level level) {
+ return level == null ? DEFAULT_LEVEL : level;
}
// Copied from java.util.logging.Formatter.formatMessage
@@ -401,7 +554,7 @@
// minimize memory allocation
private Date date = new Date();
- private synchronized String format(int level, String msg, Throwable thrown) {
+ private synchronized String format(Level level, String msg, Throwable thrown) {
date.setTime(System.currentTimeMillis());
String throwable = "";
if (thrown != null) {
@@ -417,7 +570,7 @@
date,
getCallerInfo(),
name,
- PlatformLogger.getLevelName(level),
+ level.name(),
msg,
throwable);
}
@@ -464,58 +617,41 @@
}
/**
- * JavaLogger forwards all the calls to its corresponding
+ * JavaLoggerProxy forwards all the calls to its corresponding
* java.util.logging.Logger object.
*/
- static class JavaLogger extends LoggerProxy {
- private static final Map<Integer, Object> levelObjects =
- new HashMap<>();
-
+ private static final class JavaLoggerProxy extends LoggerProxy {
+ // initialize javaLevel fields for mapping from Level enum -> j.u.l.Level object
static {
- if (LoggingSupport.isAvailable()) {
- // initialize the map to Level objects
- getLevelObjects();
+ for (Level level : Level.values()) {
+ level.javaLevel = LoggingSupport.parseLevel(level.name());
}
}
- private static void getLevelObjects() {
- // get all java.util.logging.Level objects
- int[] levelArray = new int[] {OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL};
- for (int l : levelArray) {
- Object level = LoggingSupport.parseLevel(getLevelName(l));
- levelObjects.put(l, level);
- }
+ private final /* java.util.logging.Logger */ Object javaLogger;
+
+ JavaLoggerProxy(String name) {
+ this(name, null);
}
- private final Object javaLogger;
- JavaLogger(String name) {
- this(name, 0);
- }
-
- JavaLogger(String name, int level) {
- super(name, level);
+ JavaLoggerProxy(String name, Level level) {
+ super(name);
this.javaLogger = LoggingSupport.getLogger(name);
- if (level != 0) {
+ if (level != null) {
// level has been updated and so set the Logger's level
- LoggingSupport.setLevel(javaLogger, levelObjects.get(level));
+ LoggingSupport.setLevel(javaLogger, level.javaLevel);
}
}
- /**
- * Let Logger.log() do the filtering since if the level of a
- * platform logger is altered directly from
- * java.util.logging.Logger.setLevel(), the levelValue will
- * not be updated.
- */
- void doLog(int level, String msg) {
- LoggingSupport.log(javaLogger, levelObjects.get(level), msg);
+ void doLog(Level level, String msg) {
+ LoggingSupport.log(javaLogger, level.javaLevel, msg);
}
- void doLog(int level, String msg, Throwable t) {
- LoggingSupport.log(javaLogger, levelObjects.get(level), msg, t);
+ void doLog(Level level, String msg, Throwable t) {
+ LoggingSupport.log(javaLogger, level.javaLevel, msg, t);
}
- void doLog(int level, String msg, Object... params) {
+ void doLog(Level level, String msg, Object... params) {
if (!isLoggable(level)) {
return;
}
@@ -526,49 +662,35 @@
for (int i = 0; i < len; i++) {
sparams [i] = String.valueOf(params[i]);
}
- LoggingSupport.log(javaLogger, levelObjects.get(level), msg, sparams);
+ LoggingSupport.log(javaLogger, level.javaLevel, msg, sparams);
}
boolean isEnabled() {
- Object level = LoggingSupport.getLevel(javaLogger);
- return level == null || level.equals(levelObjects.get(OFF)) == false;
+ return LoggingSupport.isLoggable(javaLogger, Level.OFF.javaLevel);
}
- int getLevel() {
- Object level = LoggingSupport.getLevel(javaLogger);
- if (level != null) {
- for (Map.Entry<Integer, Object> l : levelObjects.entrySet()) {
- if (level == l.getValue()) {
- return l.getKey();
- }
- }
+ /**
+ * Returns the PlatformLogger.Level mapped from j.u.l.Level
+ * set in the logger. If the j.u.l.Logger is set to a custom Level,
+ * this method will return the nearest Level.
+ */
+ Level getLevel() {
+ Object javaLevel = LoggingSupport.getLevel(javaLogger);
+ if (javaLevel == null) return null;
+
+ try {
+ return Level.valueOf(LoggingSupport.getLevelName(javaLevel));
+ } catch (IllegalArgumentException e) {
+ return Level.valueOf(LoggingSupport.getLevelValue(javaLevel));
}
- return 0;
}
- void setLevel(int newLevel) {
- levelValue = newLevel;
- LoggingSupport.setLevel(javaLogger, levelObjects.get(newLevel));
+ void setLevel(Level level) {
+ LoggingSupport.setLevel(javaLogger, level == null ? null : level.javaLevel);
}
- public boolean isLoggable(int level) {
- return LoggingSupport.isLoggable(javaLogger, levelObjects.get(level));
+ boolean isLoggable(Level level) {
+ return LoggingSupport.isLoggable(javaLogger, level.javaLevel);
}
}
-
- private static String getLevelName(int level) {
- switch (level) {
- case OFF : return "OFF";
- case SEVERE : return "SEVERE";
- case WARNING : return "WARNING";
- case INFO : return "INFO";
- case CONFIG : return "CONFIG";
- case FINE : return "FINE";
- case FINER : return "FINER";
- case FINEST : return "FINEST";
- case ALL : return "ALL";
- default : return "UNKNOWN";
- }
- }
-
}
diff --git a/src/share/classes/sun/util/spi/CalendarProvider.java b/src/share/classes/sun/util/spi/CalendarProvider.java
new file mode 100644
index 0000000..7114aad
--- /dev/null
+++ b/src/share/classes/sun/util/spi/CalendarProvider.java
@@ -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);
+}
diff --git a/src/share/demo/jvmti/hprof/hprof_md.h b/src/share/demo/jvmti/hprof/hprof_md.h
index b3e66fe..b65cba0 100644
--- a/src/share/demo/jvmti/hprof/hprof_md.h
+++ b/src/share/demo/jvmti/hprof/hprof_md.h
@@ -69,7 +69,7 @@
unsigned md_ntohs(unsigned short s);
unsigned md_ntohl(unsigned l);
-void md_build_library_name(char *holder, int holderlen, char *pname, char *fname);
+void md_build_library_name(char *holder, int holderlen, const char *pname, const char *fname);
void * md_load_library(const char *name, char *err_buf, int err_buflen);
void md_unload_library(void *handle);
void * md_find_library_entry(void *handle, const char *name);
diff --git a/src/share/javavm/export/jni.h b/src/share/javavm/export/jni.h
index dc2c8f6..2e83cb7 100644
--- a/src/share/javavm/export/jni.h
+++ b/src/share/javavm/export/jni.h
@@ -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 @@
#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" */
diff --git a/src/share/lib/security/java.security-linux b/src/share/lib/security/java.security-linux
index 8797a68..f03617a 100644
--- a/src/share/lib/security/java.security-linux
+++ b/src/share/lib/security/java.security-linux
@@ -169,7 +169,12 @@
com.sun.org.apache.xml.internal.serializer.utils.,\
com.sun.org.apache.xml.internal.utils.,\
com.sun.org.glassfish.,\
- jdk.internal.
+ com.oracle.xmlns.internal.,\
+ com.oracle.webservices.internal.,\
+ jdk.internal.,\
+ jdk.nashorn.internal.,\
+ jdk.nashorn.tools.
+
#
# List of comma-separated packages that start with or equal this string
@@ -205,7 +210,12 @@
com.sun.org.apache.xml.internal.serializer.utils.,\
com.sun.org.apache.xml.internal.utils.,\
com.sun.org.glassfish.,\
- jdk.internal.
+ com.oracle.xmlns.internal.,\
+ com.oracle.webservices.internal.,\
+ jdk.internal.,\
+ jdk.nashorn.internal.,\
+ jdk.nashorn.tools.
+
#
# Determines whether this properties file can be appended to
diff --git a/src/share/lib/security/java.security-macosx b/src/share/lib/security/java.security-macosx
index 3ed6a4f..feaa712 100644
--- a/src/share/lib/security/java.security-macosx
+++ b/src/share/lib/security/java.security-macosx
@@ -170,7 +170,11 @@
com.sun.org.apache.xml.internal.serializer.utils.,\
com.sun.org.apache.xml.internal.utils.,\
com.sun.org.glassfish.,\
- jdk.internal.,\
+ com.oracle.xmlns.internal.,\
+ com.oracle.webservices.internal.,\
+ jdk.internal.,\
+ jdk.nashorn.internal.,\
+ jdk.nashorn.tools.,\
apple.
#
@@ -207,7 +211,11 @@
com.sun.org.apache.xml.internal.serializer.utils.,\
com.sun.org.apache.xml.internal.utils.,\
com.sun.org.glassfish.,\
- jdk.internal.,\
+ com.oracle.xmlns.internal.,\
+ com.oracle.webservices.internal.,\
+ jdk.internal.,\
+ jdk.nashorn.internal.,\
+ jdk.nashorn.tools.,\
apple.
#
diff --git a/src/share/lib/security/java.security-solaris b/src/share/lib/security/java.security-solaris
index a88da32..697ab0c 100644
--- a/src/share/lib/security/java.security-solaris
+++ b/src/share/lib/security/java.security-solaris
@@ -171,7 +171,11 @@
com.sun.org.apache.xml.internal.serializer.utils.,\
com.sun.org.apache.xml.internal.utils.,\
com.sun.org.glassfish.,\
- jdk.internal.
+ com.oracle.xmlns.internal.,\
+ com.oracle.webservices.internal.,\
+ jdk.internal.,\
+ jdk.nashorn.internal.,\
+ jdk.nashorn.tools.
#
# List of comma-separated packages that start with or equal this string
@@ -207,7 +211,11 @@
com.sun.org.apache.xml.internal.serializer.utils.,\
com.sun.org.apache.xml.internal.utils.,\
com.sun.org.glassfish.,\
- jdk.internal.
+ com.oracle.xmlns.internal.,\
+ com.oracle.webservices.internal.,\
+ jdk.internal.,\
+ jdk.nashorn.internal.,\
+ jdk.nashorn.tools.
#
# Determines whether this properties file can be appended to
diff --git a/src/share/lib/security/java.security-windows b/src/share/lib/security/java.security-windows
index 3949ef2..0a16ecb 100644
--- a/src/share/lib/security/java.security-windows
+++ b/src/share/lib/security/java.security-windows
@@ -170,7 +170,11 @@
com.sun.org.apache.xml.internal.serializer.utils.,\
com.sun.org.apache.xml.internal.utils.,\
com.sun.org.glassfish.,\
+ com.oracle.xmlns.internal.,\
+ com.oracle.webservices.internal.,\
jdk.internal.,\
+ jdk.nashorn.internal.,\
+ jdk.nashorn.tools.,\
com.sun.java.accessibility.
#
@@ -207,7 +211,11 @@
com.sun.org.apache.xml.internal.serializer.utils.,\
com.sun.org.apache.xml.internal.utils.,\
com.sun.org.glassfish.,\
+ com.oracle.xmlns.internal.,\
+ com.oracle.webservices.internal.,\
jdk.internal.,\
+ jdk.nashorn.internal.,\
+ jdk.nashorn.tools.,\
com.sun.java.accessibility.
#
diff --git a/src/share/native/common/jni_util.h b/src/share/native/common/jni_util.h
index 55dd0fa..65cabb7 100644
--- a/src/share/native/common/jni_util.h
+++ b/src/share/native/common/jni_util.h
@@ -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 @@
void initializeEncoding();
+void* getProcessHandle();
+
+void buildJniFunctionName(const char *sym, const char *cname,
+ char *jniEntryName);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/src/share/native/java/io/ObjectOutputStream.c b/src/share/native/java/io/ObjectOutputStream.c
index 2bbb222..5db2c62 100644
--- a/src/share/native/java/io/ObjectOutputStream.c
+++ b/src/share/native/java/io/ObjectOutputStream.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 @@
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 @@
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 {
diff --git a/src/share/native/java/io/io_util.c b/src/share/native/java/io/io_util.c
index 8777ff0..9a9ca7d 100644
--- a/src/share/native/java/io/io_util.c
+++ b/src/share/native/java/io/io_util.c
@@ -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 @@
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 @@
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 @@
} 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 @@
} 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 @@
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);
}
diff --git a/src/share/native/java/io/io_util.h b/src/share/native/java/io/io_util.h
index d1804e1..6f058cc 100644
--- a/src/share/native/java/io/io_util.h
+++ b/src/share/native/java/io/io_util.h
@@ -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 @@
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:
diff --git a/src/share/native/java/lang/ClassLoader.c b/src/share/native/java/lang/ClassLoader.c
index 8965d0a..776b2dd 100644
--- a/src/share/native/java/lang/ClassLoader.c
+++ b/src/share/native/java/lang/ClassLoader.c
@@ -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 @@
static jfieldID handleID;
static jfieldID jniVersionID;
+static jfieldID loadedID;
+static void *procHandle;
static jboolean initIDs(JNIEnv *env)
{
@@ -300,6 +303,10 @@
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;
}
@@ -308,13 +315,59 @@
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 @@
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 @@
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 @@
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 @@
/*
* 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 @@
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;
+}
diff --git a/src/share/native/sun/awt/splashscreen/splashscreen_gif.c b/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
index 3c2d0fa..1fc081e 100644
--- a/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
+++ b/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
@@ -26,7 +26,7 @@
#include "splashscreen_impl.h"
#include "splashscreen_gfx.h"
-#include "../giflib/gif_lib.h"
+#include <gif_lib.h>
#define GIF_TRANSPARENT 0x01
#define GIF_USER_INPUT 0x02
diff --git a/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c b/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c
index 33cd364..541a1d3 100644
--- a/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c
+++ b/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c
@@ -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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
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);
diff --git a/src/share/native/sun/security/jgss/wrapper/NativeUtil.c b/src/share/native/sun/security/jgss/wrapper/NativeUtil.c
index 7c15ed6..e5edfbc 100644
--- a/src/share/native/sun/security/jgss/wrapper/NativeUtil.c
+++ b/src/share/native/sun/security/jgss/wrapper/NativeUtil.c
@@ -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 @@
(*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);
diff --git a/src/solaris/back/linker_md.c b/src/solaris/back/linker_md.c
index dbcfc04..07be055 100644
--- a/src/solaris/back/linker_md.c
+++ b/src/solaris/back/linker_md.c
@@ -55,34 +55,27 @@
#endif
static void dll_build_name(char* buffer, size_t buflen,
- const char* pname, const char* fname) {
- // Based on os_solaris.cpp
+ const char* paths, const char* fname) {
+ char *path, *paths_copy, *next_token;
- char *path_sep = PATH_SEPARATOR;
- char *pathname = (char *)pname;
- *buffer = '\0';
- while (strlen(pathname) > 0) {
- char *p = strchr(pathname, *path_sep);
- if (p == NULL) {
- p = pathname + strlen(pathname);
- }
- /* check for NULL path */
- if (p == pathname) {
- continue;
- }
- (void)snprintf(buffer, buflen, "%.*s/lib%s." LIB_SUFFIX, (int)(p - pathname),
- pathname, fname);
+ paths_copy = strdup(paths);
+ if (paths_copy == NULL) {
+ return;
+ }
+ next_token = NULL;
+ path = strtok_r(paths_copy, PATH_SEPARATOR, &next_token);
+
+ while (path != NULL) {
+ snprintf(buffer, buflen, "%s/lib%s." LIB_SUFFIX, path, fname);
if (access(buffer, F_OK) == 0) {
break;
}
- if (*p == '\0') {
- pathname = p;
- } else {
- pathname = p + 1;
- }
*buffer = '\0';
+ path = strtok_r(NULL, PATH_SEPARATOR, &next_token);
}
+
+ free(paths_copy);
}
/*
@@ -103,7 +96,7 @@
* appropriate pre and extensions to a filename and the path
*/
void
-dbgsysBuildLibName(char *holder, int holderlen, char *pname, char *fname)
+dbgsysBuildLibName(char *holder, int holderlen, const char *pname, const char *fname)
{
const int pnamelen = pname ? strlen(pname) : 0;
diff --git a/src/solaris/classes/sun/awt/X11/XComponentPeer.java b/src/solaris/classes/sun/awt/X11/XComponentPeer.java
index 906e9a8..b5c2086 100644
--- a/src/solaris/classes/sun/awt/X11/XComponentPeer.java
+++ b/src/solaris/classes/sun/awt/X11/XComponentPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, 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
@@ -70,10 +70,7 @@
import sun.java2d.BackBufferCapsProvider;
import sun.java2d.pipe.Region;
-import javax.tools.annotation.GenerateNativeHeader;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class XComponentPeer extends XWindow implements ComponentPeer, DropTargetPeer,
BackBufferCapsProvider
{
diff --git a/src/solaris/classes/sun/net/www/protocol/jar/JarFileFactory.java b/src/solaris/classes/sun/net/www/protocol/jar/JarFileFactory.java
index 2a001a7..ae86964 100644
--- a/src/solaris/classes/sun/net/www/protocol/jar/JarFileFactory.java
+++ b/src/solaris/classes/sun/net/www/protocol/jar/JarFileFactory.java
@@ -43,13 +43,24 @@
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 @@
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 @@
* 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 */
diff --git a/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java b/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java
index dc08340..3b59a06 100644
--- a/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java
+++ b/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java
@@ -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 @@
* 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 @@
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 @@
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 @@
}
/**
- * 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;
}
-
- // update existing registration
- updateList.add(new Updator(channel, EPOLL_CTL_MOD, mask));
+ } else {
+ Integer key = Integer.valueOf(fd);
+ if ((eventsHigh.get(key) != KILLED) || force) {
+ eventsHigh.put(key, Byte.valueOf(events));
+ }
}
}
/**
- * 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 @@
/**
* 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);
diff --git a/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java b/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java
index 5fa2b32..c8bdab4 100644
--- a/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java
+++ b/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java
@@ -53,26 +53,24 @@
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 @@
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 @@
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 @@
((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 @@
static {
Util.load();
}
-
}
diff --git a/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java b/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java
index 2399a38..79a0805 100644
--- a/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java
+++ b/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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,22 +26,20 @@
import com.sun.nio.sctp.Association;
import com.sun.nio.sctp.AssociationChangeNotification;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* An implementation of AssociationChangeNotification
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class AssociationChange extends AssociationChangeNotification
implements SctpNotification
{
/* static final ints so that they can be referenced from native */
- private final static int SCTP_COMM_UP = 1;
- private final static int SCTP_COMM_LOST = 2;
- private final static int SCTP_RESTART = 3;
- private final static int SCTP_SHUTDOWN = 4;
- private final static int SCTP_CANT_START = 5;
+ @Native private final static int SCTP_COMM_UP = 1;
+ @Native private final static int SCTP_COMM_LOST = 2;
+ @Native private final static int SCTP_RESTART = 3;
+ @Native private final static int SCTP_SHUTDOWN = 4;
+ @Native private final static int SCTP_CANT_START = 5;
private Association association;
diff --git a/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java b/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java
index 2dac583..55ee10f 100644
--- a/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java
+++ b/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -27,23 +27,21 @@
import java.net.SocketAddress;
import com.sun.nio.sctp.Association;
import com.sun.nio.sctp.PeerAddressChangeNotification;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* An implementation of PeerAddressChangeNotification
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class PeerAddrChange extends PeerAddressChangeNotification
implements SctpNotification
{
/* static final ints so that they can be referenced from native */
- private final static int SCTP_ADDR_AVAILABLE = 1;
- private final static int SCTP_ADDR_UNREACHABLE = 2;
- private final static int SCTP_ADDR_REMOVED = 3;
- private final static int SCTP_ADDR_ADDED = 4;
- private final static int SCTP_ADDR_MADE_PRIM = 5;
- private final static int SCTP_ADDR_CONFIRMED =6;
+ @Native private final static int SCTP_ADDR_AVAILABLE = 1;
+ @Native private final static int SCTP_ADDR_UNREACHABLE = 2;
+ @Native private final static int SCTP_ADDR_REMOVED = 3;
+ @Native private final static int SCTP_ADDR_ADDED = 4;
+ @Native private final static int SCTP_ADDR_MADE_PRIM = 5;
+ @Native private final static int SCTP_ADDR_CONFIRMED =6;
private Association association;
diff --git a/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java b/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java
index dee2f98..229899f 100644
--- a/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java
+++ b/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,22 +24,20 @@
*/
package sun.nio.ch.sctp;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
/**
* Wraps the actual message or notification so that it can be
* set and returned from the native receive implementation.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
public class ResultContainer {
/* static final ints so that they can be referenced from native */
- static final int NOTHING = 0;
- static final int MESSAGE = 1;
- static final int SEND_FAILED = 2;
- static final int ASSOCIATION_CHANGED = 3;
- static final int PEER_ADDRESS_CHANGED = 4;
- static final int SHUTDOWN = 5;
+ @Native static final int NOTHING = 0;
+ @Native static final int MESSAGE = 1;
+ @Native static final int SEND_FAILED = 2;
+ @Native static final int ASSOCIATION_CHANGED = 3;
+ @Native static final int PEER_ADDRESS_CHANGED = 4;
+ @Native static final int SHUTDOWN = 5;
private Object value;
private int type;
diff --git a/src/solaris/demo/jvmti/hprof/hprof_md.c b/src/solaris/demo/jvmti/hprof/hprof_md.c
index 2046363..9cfcc59 100644
--- a/src/solaris/demo/jvmti/hprof/hprof_md.c
+++ b/src/solaris/demo/jvmti/hprof/hprof_md.c
@@ -381,38 +381,32 @@
}
static void dll_build_name(char* buffer, size_t buflen,
- const char* pname, const char* fname) {
- // Loosely based on os_solaris.cpp
+ const char* paths, const char* fname) {
+ char *path, *paths_copy, *next_token;
- char *pathname = (char *)pname;
- *buffer = '\0';
- while (strlen(pathname) > 0) {
- char *p = strchr(pathname, ':');
- if (p == NULL) {
- p = pathname + strlen(pathname);
- }
- /* check for NULL path */
- if (p == pathname) {
- continue;
- }
- (void)snprintf(buffer, buflen, "%.*s/lib%s" JNI_LIB_SUFFIX,
- (int)(p - pathname), pathname, fname);
+ paths_copy = strdup(paths);
+ if (paths_copy == NULL) {
+ return;
+ }
- if (access(buffer, F_OK) == 0) {
- break;
- }
- if (*p == '\0') {
- pathname = p;
- } else {
- pathname = p + 1;
- }
- *buffer = '\0';
- }
+ next_token = NULL;
+ path = strtok_r(paths_copy, ":", &next_token);
+
+ while (path != NULL) {
+ snprintf(buffer, buflen, "%s/lib%s" JNI_LIB_SUFFIX, path, fname);
+ if (access(buffer, F_OK) == 0) {
+ break;
+ }
+ *buffer = '\0';
+ path = strtok_r(NULL, ":", &next_token);
+ }
+
+ free(paths_copy);
}
/* Create the actual fill filename for a dynamic library. */
void
-md_build_library_name(char *holder, int holderlen, char *pname, char *fname)
+md_build_library_name(char *holder, int holderlen, const char *pname, const char *fname)
{
int pnamelen;
diff --git a/src/solaris/native/com/sun/security/auth/module/Solaris.c b/src/solaris/native/com/sun/security/auth/module/Solaris.c
index 169d76b..3e31e7f 100644
--- a/src/solaris/native/com/sun/security/auth/module/Solaris.c
+++ b/src/solaris/native/com/sun/security/auth/module/Solaris.c
@@ -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 @@
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 &&
diff --git a/src/solaris/native/com/sun/security/auth/module/Unix.c b/src/solaris/native/com/sun/security/auth/module/Unix.c
index 6af63a2..620e19b 100644
--- a/src/solaris/native/com/sun/security/auth/module/Unix.c
+++ b/src/solaris/native/com/sun/security/auth/module/Unix.c
@@ -44,9 +44,6 @@
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 @@
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));
diff --git a/src/solaris/native/common/jdk_util_md.h b/src/solaris/native/common/jdk_util_md.h
index b2472b3..d9fd2a2 100644
--- a/src/solaris/native/common/jdk_util_md.h
+++ b/src/solaris/native/common/jdk_util_md.h
@@ -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 */
diff --git a/src/solaris/native/common/jni_util_md.c b/src/solaris/native/common/jni_util_md.c
index dc9fb99..e9e0f4e 100644
--- a/src/solaris/native/common/jni_util_md.c
+++ b/src/solaris/native/common/jni_util_md.c
@@ -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 @@
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);
+ }
+}
+
diff --git a/src/solaris/native/java/io/FileDescriptor_md.c b/src/solaris/native/java/io/FileDescriptor_md.c
index c279ca9..7147a14 100644
--- a/src/solaris/native/java/io/FileDescriptor_md.c
+++ b/src/solaris/native/java/io/FileDescriptor_md.c
@@ -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 @@
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");
}
}
diff --git a/src/solaris/native/java/io/UnixFileSystem_md.c b/src/solaris/native/java/io/UnixFileSystem_md.c
index 954e212..5f95cd9 100644
--- a/src/solaris/native/java/io/UnixFileSystem_md.c
+++ b/src/solaris/native/java/io/UnixFileSystem_md.c
@@ -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 @@
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 @@
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;
diff --git a/src/solaris/native/java/io/io_util_md.c b/src/solaris/native/java/io/io_util_md.c
index 61ceda9..e74bc12 100644
--- a/src/solaris/native/java/io/io_util_md.c
+++ b/src/solaris/native/java/io/io_util_md.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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,6 +29,15 @@
#include "io_util.h"
#include "io_util_md.h"
#include <string.h>
+#include <unistd.h>
+
+#ifdef __solaris__
+#include <sys/filio.h>
+#endif
+
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#include <sys/ioctl.h>
+#endif
#ifdef MACOSX
@@ -62,6 +71,28 @@
}
#endif
+FD
+handleOpen(const char *path, int oflag, int mode) {
+ FD fd;
+ RESTARTABLE(open64(path, oflag, mode), fd);
+ if (fd != -1) {
+ struct stat64 buf64;
+ int result;
+ RESTARTABLE(fstat64(fd, &buf64), result);
+ if (result != -1) {
+ if (S_ISDIR(buf64.st_mode)) {
+ close(fd);
+ errno = EISDIR;
+ fd = -1;
+ }
+ } else {
+ close(fd);
+ fd = -1;
+ }
+ }
+ return fd;
+}
+
void
fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags)
{
@@ -74,8 +105,8 @@
while ((p > ps) && (*p == '/'))
*p-- = '\0';
#endif
- fd = JVM_Open(ps, flags, 0666);
- if (fd >= 0) {
+ fd = handleOpen(ps, flags, 0666);
+ if (fd != -1) {
SET_FD(this, fd, fid);
} else {
throwFileNotFoundException(env, path);
@@ -83,7 +114,6 @@
} END_PLATFORM_STRING(env, ps);
}
-
void
fileClose(JNIEnv *env, jobject this, jfieldID fid)
{
@@ -114,7 +144,85 @@
dup2(devnull, fd);
close(devnull);
}
- } else if (JVM_Close(fd) == -1) {
+ } else if (close(fd) == -1) {
JNU_ThrowIOExceptionWithLastError(env, "close failed");
}
}
+
+ssize_t
+handleRead(FD fd, void *buf, jint len)
+{
+ ssize_t result;
+ RESTARTABLE(read(fd, buf, len), result);
+ return result;
+}
+
+ssize_t
+handleWrite(FD fd, const void *buf, jint len)
+{
+ ssize_t result;
+ RESTARTABLE(write(fd, buf, len), result);
+ return result;
+}
+
+jint
+handleAvailable(FD fd, jlong *pbytes)
+{
+ int mode;
+ struct stat64 buf64;
+ jlong size = -1, current = -1;
+
+ int result;
+ RESTARTABLE(fstat64(fd, &buf64), result);
+ if (result != -1) {
+ mode = buf64.st_mode;
+ if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) {
+ int n;
+ int result;
+ RESTARTABLE(ioctl(fd, FIONREAD, &n), result);
+ if (result >= 0) {
+ *pbytes = n;
+ return 1;
+ }
+ } else if (S_ISREG(mode)) {
+ size = buf64.st_size;
+ }
+ }
+
+ if ((current = lseek64(fd, 0, SEEK_CUR)) == -1) {
+ return 0;
+ }
+
+ if (size < current) {
+ if ((size = lseek64(fd, 0, SEEK_END)) == -1)
+ return 0;
+ else if (lseek64(fd, current, SEEK_SET) == -1)
+ return 0;
+ }
+
+ *pbytes = size - current;
+ return 1;
+}
+
+jint
+handleSetLength(FD fd, jlong length)
+{
+ int result;
+ RESTARTABLE(ftruncate64(fd, length), result);
+ return result;
+}
+
+size_t
+getLastErrorString(char *buf, size_t len)
+{
+ if (errno == 0 || len < 1) return 0;
+
+ const char *err = strerror(errno);
+ size_t n = strlen(err);
+ if (n >= len)
+ n = len - 1;
+
+ strncpy(buf, err, n);
+ buf[n] = '\0';
+ return n;
+}
diff --git a/src/solaris/native/java/io/io_util_md.h b/src/solaris/native/java/io/io_util_md.h
index fe1b7e1..b7b2573 100644
--- a/src/solaris/native/java/io/io_util_md.h
+++ b/src/solaris/native/java/io/io_util_md.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, 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
@@ -23,7 +23,6 @@
* questions.
*/
-#include "jni.h"
#include "jni_util.h"
/*
@@ -32,6 +31,18 @@
#define FD jint
/*
+ * Prototypes for functions in io_util_md.c called from io_util.c,
+ * FileDescriptor.c, FileInputStream.c, FileOutputStream.c,
+ * UnixFileSystem_md.c
+ */
+ssize_t handleWrite(FD fd, const void *buf, jint len);
+ssize_t handleRead(FD fd, void *buf, jint len);
+jint handleAvailable(FD fd, jlong *pbytes);
+jint handleSetLength(FD fd, jlong length);
+
+FD handleOpen(const char *path, int oflag, int mode);
+
+/*
* Macros to set/get fd from the java.io.FileDescriptor. These
* macros rely on having an appropriately defined 'this' object
* within the scope in which they're used.
@@ -53,15 +64,25 @@
#define THIS_FD(obj) (*env)->GetIntField(env, obj, IO_fd_fdID)
/*
- * Route the routines through VM
+ * Route the routines
*/
-#define IO_Append JVM_Write
-#define IO_Write JVM_Write
-#define IO_Sync JVM_Sync
-#define IO_Read JVM_Read
-#define IO_Lseek JVM_Lseek
-#define IO_Available JVM_Available
-#define IO_SetLength JVM_SetLength
+#define IO_Sync fsync
+#define IO_Read handleRead
+#define IO_Write handleWrite
+#define IO_Append handleWrite
+#define IO_Available handleAvailable
+#define IO_SetLength handleSetLength
+
+#ifdef _ALLBSD_SOURCE
+#define open64 open
+#define fstat64 fstat
+#define stat64 stat
+#define lseek64 lseek
+#define ftruncate64 ftruncate
+#define IO_Lseek lseek
+#else
+#define IO_Lseek lseek64
+#endif
/*
* On Solaris, the handle field is unused
@@ -69,6 +90,15 @@
#define SET_HANDLE(fd) return (jlong)-1
/*
+ * Retry the operation if it is interrupted
+ */
+#define RESTARTABLE(_cmd, _result) do { \
+ do { \
+ _result = _cmd; \
+ } while((_result == -1) && (errno == EINTR)); \
+} while(0)
+
+/*
* IO helper function(s)
*/
void fileClose(JNIEnv *env, jobject this, jfieldID fid);
diff --git a/src/solaris/native/sun/awt/awt_InputMethod.c b/src/solaris/native/sun/awt/awt_InputMethod.c
index 80da504..5a95455 100644
--- a/src/solaris/native/sun/awt/awt_InputMethod.c
+++ b/src/solaris/native/sun/awt/awt_InputMethod.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, 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
@@ -36,7 +36,6 @@
#include "awt_p.h"
#include <sun_awt_X11InputMethod.h>
-#include <sun_awt_X11_XComponentPeer.h>
#include <sun_awt_X11_XInputMethod.h>
#define THROW_OUT_OF_MEMORY_ERROR() \
diff --git a/src/solaris/native/sun/awt/fontpath.c b/src/solaris/native/sun/awt/fontpath.c
index 412c631..24146b9 100644
--- a/src/solaris/native/sun/awt/fontpath.c
+++ b/src/solaris/native/sun/awt/fontpath.c
@@ -41,7 +41,6 @@
#include <jni.h>
#include <jni_util.h>
#include <jvm_md.h>
-#include <sun_font_FontManager.h>
#ifndef HEADLESS
#include <X11/Xlib.h>
#include <awt.h>
diff --git a/src/solaris/native/sun/awt/gtk2_interface.c b/src/solaris/native/sun/awt/gtk2_interface.c
index cb93366..daca810 100644
--- a/src/solaris/native/sun/awt/gtk2_interface.c
+++ b/src/solaris/native/sun/awt/gtk2_interface.c
@@ -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
@@ -438,6 +438,39 @@
}
/**
+ * Functions for awt_Desktop.c
+ */
+gboolean gtk2_show_uri_load() {
+ gboolean success = FALSE;
+ dlerror();
+ const char *gtk_version = fp_gtk_check_version(2, 14, 0);
+ if (gtk_version != NULL) {
+ // The gtk_show_uri is available from GTK+ 2.14
+#ifdef INTERNAL_BUILD
+ fprintf (stderr, "The version of GTK is %s. "
+ "The gtk_show_uri function is supported "
+ "since GTK+ 2.14.\n", gtk_version);
+#endif /* INTERNAL_BUILD */
+ } else {
+ // Loading symbols only if the GTK version is 2.14 and higher
+ fp_gtk_show_uri = dl_symbol("gtk_show_uri");
+ const char *dlsym_error = dlerror();
+ if (dlsym_error) {
+#ifdef INTERNAL_BUILD
+ fprintf (stderr, "Cannot load symbol: %s \n", dlsym_error);
+#endif /* INTERNAL_BUILD */
+ } else if (fp_gtk_show_uri == NULL) {
+#ifdef INTERNAL_BUILD
+ fprintf(stderr, "dlsym(gtk_show_uri) returned NULL\n");
+#endif /* INTERNAL_BUILD */
+ } else {
+ success = TRUE;
+ }
+ }
+ return success;
+}
+
+/**
* Functions for sun_awt_X11_GtkFileDialogPeer.c
*/
void gtk2_file_chooser_load()
diff --git a/src/solaris/native/sun/awt/gtk2_interface.h b/src/solaris/native/sun/awt/gtk2_interface.h
index 1b46920..22ba24a 100644
--- a/src/solaris/native/sun/awt/gtk2_interface.h
+++ b/src/solaris/native/sun/awt/gtk2_interface.h
@@ -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
@@ -42,6 +42,7 @@
#define GTK_STOCK_CANCEL "gtk-cancel"
#define GTK_STOCK_SAVE "gtk-save"
#define GTK_STOCK_OPEN "gtk-open"
+#define GDK_CURRENT_TIME 0L
typedef enum _WidgetType
{
@@ -280,6 +281,7 @@
typedef void GdkColormap;
typedef void GdkDrawable;
typedef void GdkGC;
+typedef void GdkScreen;
typedef void GdkPixbuf;
typedef void GdkPixmap;
typedef void GdkWindow;
@@ -664,6 +666,15 @@
gboolean gtk2_load();
/*
+ * Loads fp_gtk_show_uri function pointer. This initialization is
+ * separated because the function is required only
+ * for java.awt.Desktop API. The function relies on initialization in
+ * gtk2_load, so it must be invoked only after a successful gtk2_load
+ * invocation
+ */
+gboolean gtk2_show_uri_load();
+
+/*
* Unload the gtk2 library. If the library is already unloaded this method has
* no effect and returns success.
* Returns FALSE on failure and TRUE on success.
@@ -795,4 +806,7 @@
void (*fp_gdk_threads_enter)(void);
void (*fp_gdk_threads_leave)(void);
+gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
+ guint32 timestamp, GError **error);
+
#endif /* !_GTK2_INTERFACE_H */
diff --git a/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c b/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c
index 12a4f24..3d805c5 100644
--- a/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c
+++ b/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@@ -104,6 +104,10 @@
if (hModule == NULL) {
systemErrorMessage = dlerror();
exceptionMessage = (char *) malloc(sizeof(char) * (strlen(systemErrorMessage) + strlen(libraryNameStr) + 1));
+ if (exceptionMessage == NULL) {
+ throwOutOfMemoryError(env, 0);
+ return;
+ }
strcpy(exceptionMessage, systemErrorMessage);
strcat(exceptionMessage, libraryNameStr);
throwIOException(env, exceptionMessage);
@@ -134,6 +138,11 @@
* Get function pointers to all PKCS #11 functions
*/
moduleData = (ModuleData *) malloc(sizeof(ModuleData));
+ if (moduleData == NULL) {
+ dlclose(hModule);
+ throwOutOfMemoryError(env, 0);
+ return;
+ }
moduleData->hModule = hModule;
moduleData->applicationMutexHandler = NULL;
rv = (C_GetFunctionList)(&(moduleData->ckFunctionListPtr));
diff --git a/src/solaris/native/sun/security/smartcardio/pcsc_md.c b/src/solaris/native/sun/security/smartcardio/pcsc_md.c
index 589f3e3..6f1021c 100644
--- a/src/solaris/native/sun/security/smartcardio/pcsc_md.c
+++ b/src/solaris/native/sun/security/smartcardio/pcsc_md.c
@@ -32,8 +32,6 @@
#include <winscard.h>
-#include <jni_util.h>
-
#include "sun_security_smartcardio_PlatformPCSC.h"
#include "pcsc_md.h"
@@ -77,7 +75,6 @@
throwByName(env, "java/io/IOException", msg);
}
-
void *findFunction(JNIEnv *env, void *hModule, char *functionName) {
void *fAddress = dlsym(hModule, functionName);
if (fAddress == NULL) {
diff --git a/src/solaris/native/sun/xawt/awt_Desktop.c b/src/solaris/native/sun/xawt/awt_Desktop.c
index b8b250b..317af3d 100644
--- a/src/solaris/native/sun/xawt/awt_Desktop.c
+++ b/src/solaris/native/sun/xawt/awt_Desktop.c
@@ -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
@@ -23,71 +23,11 @@
* questions.
*/
-#include <jni.h>
-#include <jvm_md.h>
-#include <dlfcn.h>
+#include "gtk2_interface.h"
+#include "gnome_interface.h"
-typedef int gboolean;
-
-typedef gboolean (GNOME_URL_SHOW_TYPE)(const char *, void **);
-typedef gboolean (GNOME_VFS_INIT_TYPE)(void);
-
-GNOME_URL_SHOW_TYPE *gnome_url_show;
-GNOME_VFS_INIT_TYPE *gnome_vfs_init;
-
-int init(){
- void *vfs_handle;
- void *gnome_handle;
- const char *errmsg;
-
- vfs_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnomevfs-2", "0"), RTLD_LAZY);
- if (vfs_handle == NULL) {
- vfs_handle = dlopen(JNI_LIB_NAME("gnomevfs-2"), RTLD_LAZY);
- if (vfs_handle == NULL) {
-#ifdef INTERNAL_BUILD
- fprintf(stderr, "can not load libgnomevfs-2.so\n");
-#endif
- return 0;
- }
- }
- dlerror(); /* Clear errors */
- gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
- if (gnome_vfs_init == NULL){
-#ifdef INTERNAL_BUILD
- fprintf(stderr, "dlsym( gnome_vfs_init) returned NULL\n");
-#endif
- return 0;
- }
- if ((errmsg = dlerror()) != NULL) {
-#ifdef INTERNAL_BUILD
- fprintf(stderr, "can not find symbol gnome_vfs_init %s \n", errmsg);
-#endif
- return 0;
- }
- // call gonme_vfs_init()
- (*gnome_vfs_init)();
-
- gnome_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnome-2", "0"), RTLD_LAZY);
- if (gnome_handle == NULL) {
- gnome_handle = dlopen(JNI_LIB_NAME("gnome-2"), RTLD_LAZY);
- if (gnome_handle == NULL) {
-#ifdef INTERNAL_BUILD
- fprintf(stderr, "can not load libgnome-2.so\n");
-#endif
- return 0;
- }
- }
- dlerror(); /* Clear errors */
- gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
- if ((errmsg = dlerror()) != NULL) {
-#ifdef INTERNAL_BUILD
- fprintf(stderr, "can not find symble gnome_url_show\n");
-#endif
- return 0;
- }
-
- return 1;
-}
+static gboolean gtk_has_been_loaded = FALSE;
+static gboolean gnome_has_been_loaded = FALSE;
/*
* Class: sun_awt_X11_XDesktopPeer
@@ -97,8 +37,20 @@
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_init
(JNIEnv *env, jclass cls)
{
- int init_ok = init();
- return init_ok ? JNI_TRUE : JNI_FALSE;
+
+ if (gtk_has_been_loaded || gnome_has_been_loaded) {
+ return JNI_TRUE;
+ }
+
+ if (gtk2_load() && gtk2_show_uri_load()) {
+ gtk_has_been_loaded = TRUE;
+ return JNI_TRUE;
+ } else if (gnome_load()) {
+ gnome_has_been_loaded = TRUE;
+ return JNI_TRUE;
+ }
+
+ return JNI_FALSE;
}
/*
@@ -109,16 +61,19 @@
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show
(JNIEnv *env, jobject obj, jbyteArray url_j)
{
- gboolean success;
- const char* url_c;
-
- if (gnome_url_show == NULL) {
- return JNI_FALSE;
- }
+ gboolean success = FALSE;
+ const gchar* url_c;
url_c = (char*)(*env)->GetByteArrayElements(env, url_j, NULL);
- // call gnome_url_show(const char* , GError**)
- success = (*gnome_url_show)(url_c, NULL);
+
+ if (gtk_has_been_loaded) {
+ fp_gdk_threads_enter();
+ success = fp_gtk_show_uri(NULL, url_c, GDK_CURRENT_TIME, NULL);
+ fp_gdk_threads_leave();
+ } else if (gnome_has_been_loaded) {
+ success = (*gnome_url_show)(url_c, NULL);
+ }
+
(*env)->ReleaseByteArrayElements(env, url_j, (signed char*)url_c, 0);
return success ? JNI_TRUE : JNI_FALSE;
diff --git a/src/solaris/native/sun/xawt/gnome_interface.c b/src/solaris/native/sun/xawt/gnome_interface.c
new file mode 100644
index 0000000..90d56de
--- /dev/null
+++ b/src/solaris/native/sun/xawt/gnome_interface.c
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+#include "gnome_interface.h"
+
+GNOME_URL_SHOW_TYPE *gnome_url_show = NULL;
+
+gboolean gnome_load() {
+ void *vfs_handle;
+ void *gnome_handle;
+ const char *errmsg;
+ GNOME_VFS_INIT_TYPE *gnome_vfs_init;
+
+ // trying to open the gnomevfs. VERSIONED_JNI_LIB_NAME
+ // macros formats the library name in a system specific manner
+ // see jdk/src/solaris/javavm/export/jvm_md.h for more details
+ vfs_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnomevfs-2", "0"), RTLD_LAZY);
+ if (vfs_handle == NULL) {
+ // if we cannot load the library using a version assumed by JNI
+ // we are trying to load the library without a version suffix
+ vfs_handle = dlopen(JNI_LIB_NAME("gnomevfs-2"), RTLD_LAZY);
+ if (vfs_handle == NULL) {
+ #ifdef INTERNAL_BUILD
+ fprintf(stderr, "can not load libgnomevfs-2.so\n");
+ #endif
+ return FALSE;
+ }
+ }
+ dlerror(); /* Clear errors */
+ gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
+ if (gnome_vfs_init == NULL){
+ #ifdef INTERNAL_BUILD
+ fprintf(stderr, "dlsym( gnome_vfs_init) returned NULL\n");
+ #endif
+ return FALSE;
+ }
+ if ((errmsg = dlerror()) != NULL) {
+ #ifdef INTERNAL_BUILD
+ fprintf(stderr, "can not find symbol gnome_vfs_init %s \n", errmsg);
+ #endif
+ return FALSE;
+ }
+ // call gonme_vfs_init()
+ (*gnome_vfs_init)();
+
+ gnome_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnome-2", "0"), RTLD_LAZY);
+ if (gnome_handle == NULL) {
+ gnome_handle = dlopen(JNI_LIB_NAME("gnome-2"), RTLD_LAZY);
+ if (gnome_handle == NULL) {
+ #ifdef INTERNAL_BUILD
+ fprintf(stderr, "can not load libgnome-2.so\n");
+ #endif
+ return FALSE;
+ }
+ }
+ dlerror(); /* Clear errors */
+ gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
+ if ((errmsg = dlerror()) != NULL) {
+ #ifdef INTERNAL_BUILD
+ fprintf(stderr, "can not find symble gnome_url_show\n");
+ #endif
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/src/solaris/native/sun/xawt/gnome_interface.h b/src/solaris/native/sun/xawt/gnome_interface.h
new file mode 100644
index 0000000..2ca4447
--- /dev/null
+++ b/src/solaris/native/sun/xawt/gnome_interface.h
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+#ifndef _GNOME_INTERFACE_H
+#define _GNOME_INTERFACE_H
+#include "gtk2_interface.h"
+#include <dlfcn.h>
+#include <jvm_md.h>
+#include <jni.h>
+
+typedef gboolean (GNOME_URL_SHOW_TYPE)(const char *, void **);
+typedef gboolean (GNOME_VFS_INIT_TYPE)(void);
+
+extern GNOME_URL_SHOW_TYPE *gnome_url_show;
+gboolean gnome_load();
+
+#endif /* !_GNOME_INTERFACE_H */
diff --git a/src/windows/back/linker_md.c b/src/windows/back/linker_md.c
index ad48d3d..52bf494 100644
--- a/src/windows/back/linker_md.c
+++ b/src/windows/back/linker_md.c
@@ -39,38 +39,27 @@
#include "path_md.h"
static void dll_build_name(char* buffer, size_t buflen,
- const char* pname, const char* fname) {
- // Based on os_windows.cpp
+ const char* paths, const char* fname) {
+ char *path, *paths_copy, *next_token;
- char *path_sep = PATH_SEPARATOR;
- char *pathname = (char *)pname;
- *buffer = '\0';
- while (strlen(pathname) > 0) {
- char *p = strchr(pathname, *path_sep);
- if (p == NULL) {
- p = pathname + strlen(pathname);
- }
- /* check for NULL path */
- if (p == pathname) {
- continue;
- }
- if (*(p-1) == ':' || *(p-1) == '\\') {
- (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname),
- pathname, fname);
- } else {
- (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname),
- pathname, fname);
- }
+ paths_copy = strdup(paths);
+ if (paths_copy == NULL) {
+ return;
+ }
+
+ next_token = NULL;
+ path = strtok_s(paths_copy, PATH_SEPARATOR, &next_token);
+
+ while (path != NULL) {
+ _snprintf(buffer, buflen, "%s\\%s.dll", path, fname);
if (_access(buffer, 0) == 0) {
break;
}
- if (*p == '\0') {
- pathname = p;
- } else {
- pathname = p + 1;
- }
*buffer = '\0';
+ path = strtok_s(NULL, PATH_SEPARATOR, &next_token);
}
+
+ free(paths_copy);
}
/*
@@ -113,7 +102,7 @@
* Build a machine dependent library name out of a path and file name.
*/
void
-dbgsysBuildLibName(char *holder, int holderlen, char *pname, char *fname)
+dbgsysBuildLibName(char *holder, int holderlen, const char *pname, const char *fname)
{
const int pnamelen = pname ? (int)strlen(pname) : 0;
diff --git a/src/windows/classes/java/lang/ProcessImpl.java b/src/windows/classes/java/lang/ProcessImpl.java
index 5f772ae..90878af 100644
--- a/src/windows/classes/java/lang/ProcessImpl.java
+++ b/src/windows/classes/java/lang/ProcessImpl.java
@@ -333,7 +333,7 @@
return stderr_stream;
}
- public void finalize() {
+ protected void finalize() {
closeHandle(handle);
}
diff --git a/src/windows/classes/sun/awt/windows/WDesktopPeer.java b/src/windows/classes/sun/awt/windows/WDesktopPeer.java
index a7ddc14..8661f61 100644
--- a/src/windows/classes/sun/awt/windows/WDesktopPeer.java
+++ b/src/windows/classes/sun/awt/windows/WDesktopPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -51,15 +51,15 @@
}
public void open(File file) throws IOException {
- this.ShellExecute(file.toURI(), ACTION_OPEN_VERB);
+ this.ShellExecute(file, ACTION_OPEN_VERB);
}
public void edit(File file) throws IOException {
- this.ShellExecute(file.toURI(), ACTION_EDIT_VERB);
+ this.ShellExecute(file, ACTION_EDIT_VERB);
}
public void print(File file) throws IOException {
- this.ShellExecute(file.toURI(), ACTION_PRINT_VERB);
+ this.ShellExecute(file, ACTION_PRINT_VERB);
}
public void mail(URI uri) throws IOException {
@@ -70,6 +70,13 @@
this.ShellExecute(uri, ACTION_OPEN_VERB);
}
+ private void ShellExecute(File file, String verb) throws IOException {
+ String errMsg = ShellExecute(file.getAbsolutePath(), verb);
+ if (errMsg != null) {
+ throw new IOException("Failed to " + verb + " " + file + ". Error message: " + errMsg);
+ }
+ }
+
private void ShellExecute(URI uri, String verb) throws IOException {
String errmsg = ShellExecute(uri.toString(), verb);
@@ -79,6 +86,6 @@
}
}
- private static native String ShellExecute(String uri, String verb);
+ private static native String ShellExecute(String fileOrUri, String verb);
}
diff --git a/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java b/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java
index 636dd79..9d05ddb 100644
--- a/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java
+++ b/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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,7 +32,7 @@
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.lang.ref.WeakReference;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
import sun.java2d.ScreenUpdateManager;
import sun.java2d.SurfaceData;
import sun.java2d.loops.Blit;
@@ -48,8 +48,6 @@
import static sun.java2d.pipe.BufferedOpCodes.*;
import sun.java2d.windows.GDIWindowSurfaceData;
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
class D3DBlitLoops {
static void register() {
@@ -179,12 +177,12 @@
* createPackedParams(). (They are also used at the native level when
* unpacking the params.)
*/
- private static final int OFFSET_SRCTYPE = 16;
- private static final int OFFSET_HINT = 8;
- private static final int OFFSET_TEXTURE = 3;
- private static final int OFFSET_RTT = 2;
- private static final int OFFSET_XFORM = 1;
- private static final int OFFSET_ISOBLIT = 0;
+ @Native private static final int OFFSET_SRCTYPE = 16;
+ @Native private static final int OFFSET_HINT = 8;
+ @Native private static final int OFFSET_TEXTURE = 3;
+ @Native private static final int OFFSET_RTT = 2;
+ @Native private static final int OFFSET_XFORM = 1;
+ @Native private static final int OFFSET_ISOBLIT = 0;
/**
* Packs the given parameters into a single int value in order to save
diff --git a/src/windows/classes/sun/java2d/d3d/D3DContext.java b/src/windows/classes/sun/java2d/d3d/D3DContext.java
index 9eb26b8..4de986c 100644
--- a/src/windows/classes/sun/java2d/d3d/D3DContext.java
+++ b/src/windows/classes/sun/java2d/d3d/D3DContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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,7 +25,7 @@
package sun.java2d.d3d;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
import sun.java2d.pipe.BufferedContext;
import sun.java2d.pipe.RenderBuffer;
import sun.java2d.pipe.RenderQueue;
@@ -38,8 +38,6 @@
* Note that the RenderQueue lock must be acquired before calling any of
* the methods in this class.
*/
-/* No native methods here, but the constants are needed in the supporting JNI code */
-@GenerateNativeHeader
class D3DContext extends BufferedContext {
private final D3DGraphicsDevice device;
@@ -143,31 +141,29 @@
return device;
}
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
static class D3DContextCaps extends ContextCapabilities {
/**
* Indicates the presence of pixel shaders (v2.0 or greater).
* This cap will only be set if the hardware supports the minimum number
* of texture units.
*/
- static final int CAPS_LCD_SHADER = (FIRST_PRIVATE_CAP << 0);
+ @Native static final int CAPS_LCD_SHADER = (FIRST_PRIVATE_CAP << 0);
/**
* Indicates the presence of pixel shaders (v2.0 or greater).
* This cap will only be set if the hardware meets our
* minimum requirements.
*/
- static final int CAPS_BIOP_SHADER = (FIRST_PRIVATE_CAP << 1);
+ @Native static final int CAPS_BIOP_SHADER = (FIRST_PRIVATE_CAP << 1);
/**
* Indicates that the device was successfully initialized and can
* be safely used.
*/
- static final int CAPS_DEVICE_OK = (FIRST_PRIVATE_CAP << 2);
+ @Native static final int CAPS_DEVICE_OK = (FIRST_PRIVATE_CAP << 2);
/**
* Indicates that the device has all of the necessary capabilities
* to support the Antialiasing Pixel Shader program.
*/
- static final int CAPS_AA_SHADER = (FIRST_PRIVATE_CAP << 3);
+ @Native static final int CAPS_AA_SHADER = (FIRST_PRIVATE_CAP << 3);
D3DContextCaps(int caps, String adapterId) {
super(caps, adapterId);
diff --git a/src/windows/classes/sun/java2d/d3d/D3DPaints.java b/src/windows/classes/sun/java2d/d3d/D3DPaints.java
index a5661bd..53e5976 100644
--- a/src/windows/classes/sun/java2d/d3d/D3DPaints.java
+++ b/src/windows/classes/sun/java2d/d3d/D3DPaints.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -33,7 +33,7 @@
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
-import javax.tools.annotation.GenerateNativeHeader;
+import java.lang.annotation.Native;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import sun.java2d.loops.CompositeType;
@@ -158,8 +158,6 @@
/****************** Shared MultipleGradientPaint support ********************/
- /* No native methods here, but the constants are needed in the supporting JNI code */
- @GenerateNativeHeader
private static abstract class MultiGradient extends D3DPaints {
/**
@@ -170,7 +168,7 @@
* all versions of the shader can be compiled for PS 2.0 hardware,
* we need to cap this maximum value at 8.
*/
- public static final int MULTI_MAX_FRACTIONS_D3D = 8;
+ @Native public static final int MULTI_MAX_FRACTIONS_D3D = 8;
protected MultiGradient() {}
diff --git a/src/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java b/src/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java
index 80bd9d1..3bc98eb 100644
--- a/src/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java
+++ b/src/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java
@@ -43,13 +43,24 @@
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();
@@ -72,16 +83,16 @@
}
}
- 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);
@@ -109,13 +120,15 @@
* 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 */
diff --git a/src/windows/classes/sun/nio/fs/WindowsConstants.java b/src/windows/classes/sun/nio/fs/WindowsConstants.java
index 83becb4..eefd501 100644
--- a/src/windows/classes/sun/nio/fs/WindowsConstants.java
+++ b/src/windows/classes/sun/nio/fs/WindowsConstants.java
@@ -181,6 +181,11 @@
public static final int FILE_READ_ATTRIBUTES = 0x0080;
public static final int FILE_WRITE_ATTRIBUTES = 0x0100;
+ public static final int FILE_GENERIC_READ = 0x00120089;
+ public static final int FILE_GENERIC_WRITE = 0x00120116;
+ public static final int FILE_GENERIC_EXECUTE = 0x001200a0;
+ public static final int FILE_ALL_ACCESS = 0x001f01ff;
+
// operating system security
public static final int TOKEN_DUPLICATE = 0x0002;
public static final int TOKEN_IMPERSONATE = 0x0004;
diff --git a/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java b/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java
index 70a3730..31b7c0f 100644
--- a/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java
+++ b/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java
@@ -38,6 +38,7 @@
import sun.security.util.SecurityConstants;
import static sun.nio.fs.WindowsNativeDispatcher.*;
+import static sun.nio.fs.WindowsSecurity.*;
import static sun.nio.fs.WindowsConstants.*;
public class WindowsFileSystemProvider
@@ -289,67 +290,29 @@
}
/**
- * Returns buffer with SID_AND_ATTRIBUTES structure representing the user
- * associated with the current thread access token.
- * FIXME - this should be cached.
+ * Checks the file security against desired access.
*/
- private static NativeBuffer getUserInfo(WindowsPath file) throws IOException {
- try {
- long hToken = WindowsSecurity.processTokenWithQueryAccess;
- int size = GetTokenInformation(hToken, TokenUser, 0L, 0);
- assert size > 0;
-
- NativeBuffer buffer = NativeBuffers.getNativeBuffer(size);
- try {
- int newsize = GetTokenInformation(hToken, TokenUser,
- buffer.address(), size);
- if (newsize != size)
- throw new AssertionError();
- return buffer;
- } catch (WindowsException x) {
- buffer.release();
- throw x;
- }
- } catch (WindowsException x) {
- throw new IOException(x.getMessage());
- }
- }
-
- /**
- * Reads the file ACL and return the effective access as ACCESS_MASK
- */
- private static int getEffectiveAccess(WindowsPath file) throws IOException {
- // read security descriptor continaing ACL (symlinks are followed)
+ private static boolean hasDesiredAccess(WindowsPath file, int rights) throws IOException {
+ // read security descriptor containing ACL (symlinks are followed)
+ boolean hasRights = false;
String target = WindowsLinkSupport.getFinalPath(file, true);
NativeBuffer aclBuffer = WindowsAclFileAttributeView
- .getFileSecurity(target, DACL_SECURITY_INFORMATION);
-
- // retrieves DACL from security descriptor
- long pAcl = GetSecurityDescriptorDacl(aclBuffer.address());
-
- // Use GetEffectiveRightsFromAcl to get effective access to file
+ .getFileSecurity(target,
+ DACL_SECURITY_INFORMATION
+ | OWNER_SECURITY_INFORMATION
+ | GROUP_SECURITY_INFORMATION);
try {
- NativeBuffer userBuffer = getUserInfo(file);
- try {
- try {
- // SID_AND_ATTRIBUTES->pSid
- long pSid = unsafe.getAddress(userBuffer.address());
- long pTrustee = BuildTrusteeWithSid(pSid);
- try {
- return GetEffectiveRightsFromAcl(pAcl, pTrustee);
- } finally {
- LocalFree(pTrustee);
- }
- } catch (WindowsException x) {
- throw new IOException("Unable to get effective rights from ACL: " +
- x.getMessage());
- }
- } finally {
- userBuffer.release();
- }
+ hasRights = checkAccessMask(aclBuffer.address(), rights,
+ FILE_GENERIC_READ,
+ FILE_GENERIC_WRITE,
+ FILE_GENERIC_EXECUTE,
+ FILE_ALL_ACCESS);
+ } catch (WindowsException exc) {
+ exc.rethrowAsIOException(file);
} finally {
aclBuffer.release();
}
+ return hasRights;
}
/**
@@ -416,10 +379,10 @@
mask |= FILE_EXECUTE;
}
- if ((getEffectiveAccess(file) & mask) == 0)
+ if (!hasDesiredAccess(file, mask))
throw new AccessDeniedException(
file.getPathForExceptionMessage(), null,
- "Effective permissions does not allow requested access");
+ "Permissions does not allow requested access");
// for write access we neeed to check if the DOS readonly attribute
// and if the volume is read-only
@@ -438,7 +401,6 @@
throw new AccessDeniedException(
file.getPathForExceptionMessage(), null, "Read-only file system");
}
- return;
}
}
diff --git a/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java b/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java
index 3d9f497..b0af243 100644
--- a/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java
+++ b/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java
@@ -844,6 +844,23 @@
static native void AdjustTokenPrivileges(long token, long luid, int attributes)
throws WindowsException;
+
+ /**
+ * AccessCheck(
+ * PSECURITY_DESCRIPTOR pSecurityDescriptor,
+ * HANDLE ClientToken,
+ * DWORD DesiredAccess,
+ * PGENERIC_MAPPING GenericMapping,
+ * PPRIVILEGE_SET PrivilegeSet,
+ * LPDWORD PrivilegeSetLength,
+ * LPDWORD GrantedAccess,
+ * LPBOOL AccessStatus
+ * )
+ */
+ static native boolean AccessCheck(long token, long securityInfo, int accessMask,
+ int genericRead, int genericWrite, int genericExecute, int genericAll)
+ throws WindowsException;
+
/**
*/
static long LookupPrivilegeValue(String name) throws WindowsException {
@@ -858,28 +875,6 @@
throws WindowsException;
/**
- * BuildTrusteeWithSid(
- * PTRUSTEE pTrustee,
- * PSID pSid
- * )
- *
- * @return pTrustee
- */
- static native long BuildTrusteeWithSid(long pSid);
-
- /**
- * GetEffectiveRightsFromAcl(
- * PACL pacl,
- * PTRUSTEE pTrustee,
- * PACCESS_MASK pAccessRights
- * )
- *
- * @return AccessRights
- */
- static native int GetEffectiveRightsFromAcl(long pAcl, long pTrustee)
- throws WindowsException;
-
- /**
* CreateSymbolicLink(
* LPCWSTR lpSymlinkFileName,
* LPCWSTR lpTargetFileName,
diff --git a/src/windows/classes/sun/nio/fs/WindowsSecurity.java b/src/windows/classes/sun/nio/fs/WindowsSecurity.java
index 06351db..ef9982e 100644
--- a/src/windows/classes/sun/nio/fs/WindowsSecurity.java
+++ b/src/windows/classes/sun/nio/fs/WindowsSecurity.java
@@ -105,19 +105,46 @@
return new Privilege() {
@Override
public void drop() {
- try {
- if (stopImpersontating) {
- SetThreadToken(0L, 0L);
- } else {
- if (needToRevert) {
+ if (token != 0L) {
+ try {
+ if (stopImpersontating)
+ SetThreadToken(0L, 0L);
+ else if (needToRevert)
AdjustTokenPrivileges(token, pLuid, 0);
- }
+ } catch (WindowsException x) {
+ // should not happen
+ throw new AssertionError(x);
+ } finally {
+ CloseHandle(token);
}
- } catch (WindowsException x) {
- // should not happen
- throw new AssertionError(x);
}
}
};
}
+
+ /**
+ * Check the access right against the securityInfo in the current thread.
+ */
+ static boolean checkAccessMask(long securityInfo, int accessMask,
+ int genericRead, int genericWrite, int genericExecute, int genericAll)
+ throws WindowsException
+ {
+ int privilegies = TOKEN_QUERY;
+ long hToken = OpenThreadToken(GetCurrentThread(), privilegies, false);
+ if (hToken == 0L && processTokenWithDuplicateAccess != 0L)
+ hToken = DuplicateTokenEx(processTokenWithDuplicateAccess,
+ privilegies);
+
+ boolean hasRight = false;
+ if (hToken != 0L) {
+ try {
+ hasRight = AccessCheck(hToken, securityInfo, accessMask,
+ genericRead, genericWrite, genericExecute, genericAll);
+ } finally {
+ CloseHandle(hToken);
+ }
+ }
+ return hasRight;
+ }
+
}
diff --git a/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java b/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
index a5666f6..fddffb9 100644
--- a/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
+++ b/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
@@ -35,17 +35,20 @@
import java.text.spi.DateFormatSymbolsProvider;
import java.text.spi.DecimalFormatSymbolsProvider;
import java.text.spi.NumberFormatProvider;
+import java.util.Calendar;
import java.util.Collections;
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;
import java.util.spi.CalendarDataProvider;
import java.util.spi.CalendarNameProvider;
+import sun.util.spi.CalendarProvider;
/**
* LocaleProviderdapter implementation for the Windows locale data.
@@ -98,9 +101,9 @@
if (initialize()) {
// 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 = Locale.forLanguageTag(getDefaultLocale(CAT_FORMAT).replace('_', '-'));
tmpSet.addAll(Control.getNoFallbackControl(Control.FORMAT_DEFAULT).getCandidateLocales("", l));
- l = Locale.forLanguageTag(getDefaultLocale(CAT_DISPLAY).replaceAll("_","-"));
+ l = Locale.forLanguageTag(getDefaultLocale(CAT_DISPLAY).replace('_', '-'));
tmpSet.addAll(Control.getNoFallbackControl(Control.FORMAT_DEFAULT).getCandidateLocales("", l));
}
supportedLocaleSet = Collections.unmodifiableSet(tmpSet);
@@ -173,24 +176,12 @@
@Override
public Locale[] getAvailableLocales() {
- if (isSupportedLocale(Locale.getDefault(Locale.Category.FORMAT))) {
- return supportedLocale;
- }
-
- return new Locale[0];
+ return getSupportedCalendarLocales();
}
@Override
public boolean isSupportedLocale(Locale locale) {
- // Only supports the locale with Gregorian calendar
- if (supportedLocale.length != 0) {
- int calid = getCalendarID(locale.toLanguageTag());
- if (calid > 0 && calid < calIDToLDML.length) {
- return calIDToLDML[calid].startsWith("gregory");
- }
- }
-
- return false;
+ return isSupportedCalendarLocale(locale);
}
@Override
@@ -312,9 +303,7 @@
dfs.setNaN(getNaN(langTag, dfs.getNaN()));
dfs.setPercent(getPercent(langTag, dfs.getPercent()));
dfs.setPerMill(getPerMill(langTag, dfs.getPerMill()));
- if (isNativeDigit(langTag)) {
- dfs.setZeroDigit(getZeroDigit(langTag, dfs.getZeroDigit()));
- }
+ dfs.setZeroDigit(getZeroDigit(langTag, dfs.getZeroDigit()));
ref = new SoftReference<>(dfs);
decimalFormatSymbolsCache.put(locale, ref);
}
@@ -380,6 +369,29 @@
};
}
+ 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(getCalendarLocale(locale))
+ .setTimeZone(zone)
+ .setInstant(System.currentTimeMillis())
+ .build();
+ }
+ };
+ }
+
private static String convertDateTimePattern(String winPattern) {
String ret = winPattern.replaceAll("dddd", "EEEE");
ret = ret.replaceAll("ddd", "EEE");
@@ -401,24 +413,25 @@
}
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;
+ int calid = getCalendarID(locale.toLanguageTag());
+ if (calid <= 0 || calid >= calIDToLDML.length) {
+ return false;
}
- return caltype.equals(
- calIDToLDML[getCalendarID(locale.toLanguageTag())]
- .replaceFirst("_.*", ""));
+ String requestedCalType = locale.getUnicodeLocaleType("ca");
+ String nativeCalType = calIDToLDML[calid]
+ .replaceFirst("_.*", ""); // remove locale part.
+
+ if (requestedCalType == null) {
+ return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
+ } else {
+ return requestedCalType.equals(nativeCalType);
+ }
}
private static Locale[] getSupportedNativeDigitLocales() {
diff --git a/src/windows/demo/jvmti/hprof/hprof_md.c b/src/windows/demo/jvmti/hprof/hprof_md.c
index 4bd4a40..90e15ed 100644
--- a/src/windows/demo/jvmti/hprof/hprof_md.c
+++ b/src/windows/demo/jvmti/hprof/hprof_md.c
@@ -368,42 +368,32 @@
}
static void dll_build_name(char* buffer, size_t buflen,
- const char* pname, const char* fname) {
- // Loosley based on os_windows.cpp
+ const char* paths, const char* fname) {
+ char *path, *paths_copy, *next_token;
- char *pathname = (char *)pname;
- *buffer = '\0';
- while (strlen(pathname) > 0) {
- char *p = strchr(pathname, ';');
- if (p == NULL) {
- p = pathname + strlen(pathname);
- }
- /* check for NULL path */
- if (p == pathname) {
- continue;
- }
- if (*(p-1) == ':' || *(p-1) == '\\') {
- (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname),
- pathname, fname);
- } else {
- (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname),
- pathname, fname);
- }
+ paths_copy = strdup(paths);
+ if (paths_copy == NULL) {
+ return;
+ }
+
+ next_token = NULL;
+ path = strtok_s(paths_copy, ";", &next_token);
+
+ while (path != NULL) {
+ _snprintf(buffer, buflen, "%s\\%s.dll", path, fname);
if (_access(buffer, 0) == 0) {
break;
}
- if (*p == '\0') {
- pathname = p;
- } else {
- pathname = p + 1;
- }
*buffer = '\0';
+ path = strtok_s(NULL, ";", &next_token);
}
+
+ free(paths_copy);
}
/* Build a machine dependent library name out of a path and file name. */
void
-md_build_library_name(char *holder, int holderlen, char *pname, char *fname)
+md_build_library_name(char *holder, int holderlen, const char *pname, const char *fname)
{
int pnamelen;
diff --git a/src/windows/native/common/jdk_util_md.h b/src/windows/native/common/jdk_util_md.h
index 67c45a2..7611c55 100644
--- a/src/windows/native/common/jdk_util_md.h
+++ b/src/windows/native/common/jdk_util_md.h
@@ -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
@@ -28,6 +28,11 @@
#define JDK_UTIL_MD_H
#include "jni.h"
+#include <float.h>
+
+// checking for nanness
+#define ISNANF(f) _isnan(f)
+#define ISNAND(d) _isnan(d)
#ifdef __cplusplus
extern "C" {
diff --git a/src/windows/native/common/jni_util_md.c b/src/windows/native/common/jni_util_md.c
index 5b90a59..cdaaa2b 100644
--- a/src/windows/native/common/jni_util_md.c
+++ b/src/windows/native/common/jni_util_md.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -137,3 +137,35 @@
else
return NULL;
}
+
+void* getProcessHandle() {
+ return (void*)GetModuleHandle(NULL);
+}
+
+/*
+ * Windows symbols can be simple like JNI_OnLoad or __stdcall format
+ * like _JNI_OnLoad@8. We need to handle both.
+ */
+void buildJniFunctionName(const char *sym, const char *cname,
+ char *jniEntryName) {
+ if (cname != NULL) {
+ char *p = strrchr(sym, '@');
+ if (p != NULL && p != sym) {
+ // sym == _JNI_OnLoad@8
+ strncpy(jniEntryName, sym, (p - sym));
+ jniEntryName[(p-sym)] = '\0';
+ // jniEntryName == _JNI_OnLoad
+ strcat(jniEntryName, "_");
+ strcat(jniEntryName, cname);
+ strcat(jniEntryName, p);
+ //jniEntryName == _JNI_OnLoad_cname@8
+ } else {
+ strcpy(jniEntryName, sym);
+ strcat(jniEntryName, "_");
+ strcat(jniEntryName, cname);
+ }
+ } else {
+ strcpy(jniEntryName, sym);
+ }
+ return;
+}
diff --git a/src/windows/native/java/io/io_util_md.c b/src/windows/native/java/io/io_util_md.c
index 2f0e74f..3e9aef3 100644
--- a/src/windows/native/java/io/io_util_md.c
+++ b/src/windows/native/java/io/io_util_md.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -208,7 +208,7 @@
return pathbuf;
}
-jlong
+FD
winFileHandleOpen(JNIEnv *env, jstring path, int flags)
{
const DWORD access =
@@ -264,7 +264,7 @@
void
fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags)
{
- jlong h = winFileHandleOpen(env, path, flags);
+ FD h = winFileHandleOpen(env, path, flags);
if (h >= 0) {
SET_FD(this, h, fid);
}
@@ -274,12 +274,12 @@
old C style int fd as is used in HPI layer */
static int
-handleNonSeekAvailable(jlong, long *);
+handleNonSeekAvailable(FD, long *);
static int
-handleStdinAvailable(jlong, long *);
+handleStdinAvailable(FD, long *);
int
-handleAvailable(jlong fd, jlong *pbytes) {
+handleAvailable(FD fd, jlong *pbytes) {
HANDLE h = (HANDLE)fd;
DWORD type = 0;
@@ -317,7 +317,7 @@
}
static int
-handleNonSeekAvailable(jlong fd, long *pbytes) {
+handleNonSeekAvailable(FD fd, long *pbytes) {
/* This is used for available on non-seekable devices
* (like both named and anonymous pipes, such as pipes
* connected to an exec'd process).
@@ -346,7 +346,7 @@
}
static int
-handleStdinAvailable(jlong fd, long *pbytes) {
+handleStdinAvailable(FD fd, long *pbytes) {
HANDLE han;
DWORD numEventsRead = 0; /* Number of events read from buffer */
DWORD numEvents = 0; /* Number of events in buffer */
@@ -412,8 +412,8 @@
* denied".
*/
-JNIEXPORT int
-handleSync(jlong fd) {
+int
+handleSync(FD fd) {
/*
* From the documentation:
*
@@ -443,7 +443,7 @@
int
-handleSetLength(jlong fd, jlong length) {
+handleSetLength(FD fd, jlong length) {
HANDLE h = (HANDLE)fd;
long high = (long)(length >> 32);
DWORD ret;
@@ -459,7 +459,7 @@
JNIEXPORT
jint
-handleRead(jlong fd, void *buf, jint len)
+handleRead(FD fd, void *buf, jint len)
{
DWORD read = 0;
BOOL result = 0;
@@ -482,7 +482,7 @@
return (jint)read;
}
-static jint writeInternal(jlong fd, const void *buf, jint len, jboolean append)
+static jint writeInternal(FD fd, const void *buf, jint len, jboolean append)
{
BOOL result = 0;
DWORD written = 0;
@@ -510,13 +510,11 @@
return (jint)written;
}
-JNIEXPORT
-jint handleWrite(jlong fd, const void *buf, jint len) {
+jint handleWrite(FD fd, const void *buf, jint len) {
return writeInternal(fd, buf, len, JNI_FALSE);
}
-JNIEXPORT
-jint handleAppend(jlong fd, const void *buf, jint len) {
+jint handleAppend(FD fd, const void *buf, jint len) {
return writeInternal(fd, buf, len, JNI_TRUE);
}
@@ -545,7 +543,7 @@
}
jlong
-handleLseek(jlong fd, jlong offset, jint whence)
+handleLseek(FD fd, jlong offset, jint whence)
{
LARGE_INTEGER pos, distance;
DWORD lowPos = 0;
@@ -569,3 +567,44 @@
}
return long_to_jlong(pos.QuadPart);
}
+
+size_t
+getLastErrorString(char *buf, size_t len)
+{
+ DWORD errval;
+ if (len > 0) {
+ if ((errval = GetLastError()) != 0) {
+ // DOS error
+ size_t n = (size_t)FormatMessage(
+ FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ errval,
+ 0,
+ buf,
+ (DWORD)len,
+ NULL);
+ if (n > 3) {
+ // Drop final '.', CR, LF
+ if (buf[n - 1] == '\n') n--;
+ if (buf[n - 1] == '\r') n--;
+ if (buf[n - 1] == '.') n--;
+ buf[n] = '\0';
+ }
+ return n;
+ }
+
+ if (errno != 0) {
+ // C runtime error that has no corresponding DOS error code
+ const char *err = strerror(errno);
+ size_t n = strlen(err);
+ if (n >= len)
+ n = len - 1;
+
+ strncpy(buf, err, n);
+ buf[n] = '\0';
+ return n;
+ }
+ }
+
+ return 0;
+}
diff --git a/src/windows/native/java/io/io_util_md.h b/src/windows/native/java/io/io_util_md.h
index 34036d4..cf92507 100644
--- a/src/windows/native/java/io/io_util_md.h
+++ b/src/windows/native/java/io/io_util_md.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, 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
@@ -27,7 +27,12 @@
#include "jni_util.h"
/*
- * Prototypes for functions in io_util_md.c called from io_util,
+ * Macros to use the right data type for file descriptors
+ */
+#define FD jlong
+
+/*
+ * Prototypes for functions in io_util_md.c called from io_util.c,
* FileDescriptor.c, FileInputStream.c, FileOutputStream.c
*/
WCHAR* pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE);
@@ -35,26 +40,20 @@
WCHAR* getPrefixed(const WCHAR* path, int pathlen);
WCHAR* currentDir(int di);
int currentDirLength(const WCHAR* path, int pathlen);
-void fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags);
-int handleAvailable(jlong fd, jlong *pbytes);
-JNIEXPORT int handleSync(jlong fd);
-int handleSetLength(jlong fd, jlong length);
-JNIEXPORT jint handleRead(jlong fd, void *buf, jint len);
-JNIEXPORT jint handleWrite(jlong fd, const void *buf, jint len);
-JNIEXPORT jint handleAppend(jlong fd, const void *buf, jint len);
+int handleAvailable(FD fd, jlong *pbytes);
+int handleSync(FD fd);
+int handleSetLength(FD fd, jlong length);
+JNIEXPORT jint handleRead(FD fd, void *buf, jint len);
+jint handleWrite(FD fd, const void *buf, jint len);
+jint handleAppend(FD fd, const void *buf, jint len);
jint handleClose(JNIEnv *env, jobject this, jfieldID fid);
-jlong handleLseek(jlong fd, jlong offset, jint whence);
+jlong handleLseek(FD fd, jlong offset, jint whence);
/*
* Returns an opaque handle to file named by "path". If an error occurs,
* returns -1 and an exception is pending.
*/
-jlong winFileHandleOpen(JNIEnv *env, jstring path, int flags);
-
-/*
- * Macros to use the right data type for file descriptors
- */
-#define FD jlong
+FD winFileHandleOpen(JNIEnv *env, jstring path, int flags);
/*
* Macros to set/get fd from the java.io.FileDescriptor.
diff --git a/src/windows/native/sun/java2d/d3d/D3DContext.h b/src/windows/native/sun/java2d/d3d/D3DContext.h
index 8075c41..48defe1 100644
--- a/src/windows/native/sun/java2d/d3d/D3DContext.h
+++ b/src/windows/native/sun/java2d/d3d/D3DContext.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -28,7 +28,6 @@
#include "java_awt_Transparency.h"
#include "sun_java2d_pipe_BufferedContext.h"
-#include "sun_java2d_d3d_D3DContext.h"
#include "sun_java2d_d3d_D3DContext_D3DContextCaps.h"
#include "sun_java2d_d3d_D3DSurfaceData.h"
#include "sun_java2d_pipe_hw_AccelDeviceEventNotifier.h"
diff --git a/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c b/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c
index 5faf34d..9672b85 100644
--- a/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c
+++ b/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c
@@ -1021,6 +1021,33 @@
throwWindowsException(env, GetLastError());
}
+JNIEXPORT jboolean JNICALL
+Java_sun_nio_fs_WindowsNativeDispatcher_AccessCheck(JNIEnv* env,
+ jclass this, jlong token, jlong securityInfo, jint accessMask,
+ jint genericRead, jint genericWrite, jint genericExecute, jint genericAll)
+{
+ HANDLE hImpersonatedToken = (HANDLE)jlong_to_ptr(token);
+ PSECURITY_DESCRIPTOR security = (PSECURITY_DESCRIPTOR)jlong_to_ptr(securityInfo);
+ DWORD checkAccessRights = (DWORD)accessMask;
+ GENERIC_MAPPING mapping = {
+ genericRead,
+ genericWrite,
+ genericExecute,
+ genericAll};
+ PRIVILEGE_SET privileges = {0};
+ DWORD privilegesLength = sizeof(privileges);
+ DWORD grantedAccess = 0;
+ BOOL result = FALSE;
+
+ /* checkAccessRights is in-out parameter */
+ MapGenericMask(&checkAccessRights, &mapping);
+ if (AccessCheck(security, hImpersonatedToken, checkAccessRights,
+ &mapping, &privileges, &privilegesLength, &grantedAccess, &result) == 0)
+ throwWindowsException(env, GetLastError());
+
+ return (result == FALSE) ? JNI_FALSE : JNI_TRUE;
+}
+
JNIEXPORT jlong JNICALL
Java_sun_nio_fs_WindowsNativeDispatcher_LookupPrivilegeValue0(JNIEnv* env,
jclass this, jlong name)
@@ -1037,35 +1064,6 @@
return ptr_to_jlong(pLuid);
}
-JNIEXPORT jlong JNICALL
-Java_sun_nio_fs_WindowsNativeDispatcher_BuildTrusteeWithSid(JNIEnv* env,
- jclass this, jlong sid)
-{
- PSID pSid = (HANDLE)jlong_to_ptr(sid);
- PTRUSTEE_W pTrustee = LocalAlloc(0, sizeof(TRUSTEE_W));
-
- if (pTrustee == NULL) {
- JNU_ThrowInternalError(env, "Unable to allocate TRUSTEE_W structure");
- } else {
- BuildTrusteeWithSidW(pTrustee, pSid);
- }
- return ptr_to_jlong(pTrustee);
-}
-
-JNIEXPORT jint JNICALL
-Java_sun_nio_fs_WindowsNativeDispatcher_GetEffectiveRightsFromAcl(JNIEnv* env,
- jclass this, jlong acl, jlong trustee)
-{
- ACCESS_MASK access;
- PACL pAcl = (PACL)jlong_to_ptr(acl);
- PTRUSTEE pTrustee = (PTRUSTEE)jlong_to_ptr(trustee);
-
- if (GetEffectiveRightsFromAcl(pAcl, pTrustee, &access) != ERROR_SUCCESS) {
- throwWindowsException(env, GetLastError());
- }
- return (jint)access;
-}
-
JNIEXPORT void JNICALL
Java_sun_nio_fs_WindowsNativeDispatcher_CreateSymbolicLink0(JNIEnv* env,
jclass this, jlong linkAddress, jlong targetAddress, jint flags)
diff --git a/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c b/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
index e507a6f..037ea5e 100644
--- a/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
+++ b/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
@@ -611,7 +611,12 @@
int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen) {
if (pGetLocaleInfoEx) {
- return pGetLocaleInfoEx((LPWSTR)langtag, type, data, buflen);
+ if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
+ // defaults to "en"
+ return pGetLocaleInfoEx(L"en", type, data, buflen);
+ } else {
+ return pGetLocaleInfoEx((LPWSTR)langtag, type, data, buflen);
+ }
} else {
// If we ever wanted to support WinXP, we will need extra module from
// MS...
@@ -622,7 +627,12 @@
int getCalendarInfoWrapper(const jchar *langtag, CALID id, LPCWSTR reserved, CALTYPE type, LPWSTR data, int buflen, LPDWORD val) {
if (pGetCalendarInfoEx) {
- return pGetCalendarInfoEx((LPWSTR)langtag, id, reserved, type, data, buflen, val);
+ if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
+ // defaults to "en"
+ return pGetCalendarInfoEx(L"en", id, reserved, type, data, buflen, val);
+ } else {
+ return pGetCalendarInfoEx((LPWSTR)langtag, id, reserved, type, data, buflen, val);
+ }
} else {
// If we ever wanted to support WinXP, we will need extra module from
// MS...
diff --git a/src/windows/native/sun/windows/awt_Component.h b/src/windows/native/sun/windows/awt_Component.h
index 8ce8fa3..815843f 100644
--- a/src/windows/native/sun/windows/awt_Component.h
+++ b/src/windows/native/sun/windows/awt_Component.h
@@ -37,7 +37,6 @@
#include "java_awt_Component.h"
#include "sun_awt_windows_WComponentPeer.h"
#include "java_awt_event_KeyEvent.h"
-#include "java_awt_event_FocusEvent.h"
#include "java_awt_event_MouseEvent.h"
#include "java_awt_event_WindowEvent.h"
#include "java_awt_Dimension.h"
diff --git a/src/windows/native/sun/windows/awt_Desktop.cpp b/src/windows/native/sun/windows/awt_Desktop.cpp
index 5db6c4b..623718e 100644
--- a/src/windows/native/sun/windows/awt_Desktop.cpp
+++ b/src/windows/native/sun/windows/awt_Desktop.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, 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
@@ -38,17 +38,17 @@
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_ShellExecute
- (JNIEnv *env, jclass cls, jstring uri_j, jstring verb_j)
+ (JNIEnv *env, jclass cls, jstring fileOrUri_j, jstring verb_j)
{
- LPCWSTR uri_c = JNU_GetStringPlatformChars(env, uri_j, JNI_FALSE);
+ LPCWSTR fileOrUri_c = JNU_GetStringPlatformChars(env, fileOrUri_j, JNI_FALSE);
LPCWSTR verb_c = JNU_GetStringPlatformChars(env, verb_j, JNI_FALSE);
// 6457572: ShellExecute possibly changes FPU control word - saving it here
unsigned oldcontrol87 = _control87(0, 0);
- HINSTANCE retval = ::ShellExecute(NULL, verb_c, uri_c, NULL, NULL, SW_SHOWNORMAL);
+ HINSTANCE retval = ::ShellExecute(NULL, verb_c, fileOrUri_c, NULL, NULL, SW_SHOWNORMAL);
_control87(oldcontrol87, 0xffffffff);
- JNU_ReleaseStringPlatformChars(env, uri_j, uri_c);
+ JNU_ReleaseStringPlatformChars(env, fileOrUri_j, fileOrUri_c);
JNU_ReleaseStringPlatformChars(env, verb_j, verb_c);
if ((int)retval <= 32) {
diff --git a/src/windows/native/sun/windows/awt_DnDDS.cpp b/src/windows/native/sun/windows/awt_DnDDS.cpp
index 2d585e0..21c3b17 100644
--- a/src/windows/native/sun/windows/awt_DnDDS.cpp
+++ b/src/windows/native/sun/windows/awt_DnDDS.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, 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
@@ -52,7 +52,6 @@
#include "java_awt_event_InputEvent.h"
#include "java_awt_dnd_DnDConstants.h"
-#include "sun_awt_dnd_SunDragSourceContextPeer.h"
#include "sun_awt_windows_WDragSourceContextPeer.h"
#include "awt_ole.h"
diff --git a/src/windows/native/sun/windows/awt_Frame.cpp b/src/windows/native/sun/windows/awt_Frame.cpp
index 41c5624..5d344e7 100644
--- a/src/windows/native/sun/windows/awt_Frame.cpp
+++ b/src/windows/native/sun/windows/awt_Frame.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2011, 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
@@ -34,7 +34,6 @@
#include <windowsx.h>
#include <java_lang_Integer.h>
-#include <sun_awt_EmbeddedFrame.h>
#include <sun_awt_windows_WEmbeddedFrame.h>
#include <sun_awt_windows_WEmbeddedFramePeer.h>
diff --git a/src/windows/native/sun/windows/awt_List.h b/src/windows/native/sun/windows/awt_List.h
index 3751b02..585eed9 100644
--- a/src/windows/native/sun/windows/awt_List.h
+++ b/src/windows/native/sun/windows/awt_List.h
@@ -28,7 +28,6 @@
#include "awt_Component.h"
-#include "java_awt_List.h"
#include "sun_awt_windows_WListPeer.h"
diff --git a/src/windows/native/sun/windows/awt_PopupMenu.cpp b/src/windows/native/sun/windows/awt_PopupMenu.cpp
index dee95e2..05fc30d 100644
--- a/src/windows/native/sun/windows/awt_PopupMenu.cpp
+++ b/src/windows/native/sun/windows/awt_PopupMenu.cpp
@@ -28,7 +28,6 @@
#include "awt_Event.h"
#include "awt_Window.h"
-#include <java_awt_PopupMenu.h>
#include <sun_awt_windows_WPopupMenuPeer.h>
#include <java_awt_Event.h>
diff --git a/src/windows/native/sun/windows/awt_PopupMenu.h b/src/windows/native/sun/windows/awt_PopupMenu.h
index ab82768..112645e 100644
--- a/src/windows/native/sun/windows/awt_PopupMenu.h
+++ b/src/windows/native/sun/windows/awt_PopupMenu.h
@@ -30,7 +30,6 @@
#include <java_awt_MenuItem.h>
#include <sun_awt_windows_WMenuItemPeer.h>
-#include <java_awt_PopupMenu.h>
#include <sun_awt_windows_WPopupMenuPeer.h>
diff --git a/src/windows/native/sun/windows/awt_TextComponent.h b/src/windows/native/sun/windows/awt_TextComponent.h
index cc0fc97..e293e09 100644
--- a/src/windows/native/sun/windows/awt_TextComponent.h
+++ b/src/windows/native/sun/windows/awt_TextComponent.h
@@ -28,7 +28,6 @@
#include "awt_Component.h"
-#include "java_awt_TextComponent.h"
#include "sun_awt_windows_WTextComponentPeer.h"
#include <ole2.h>
diff --git a/src/windows/native/sun/windows/awt_Toolkit.cpp b/src/windows/native/sun/windows/awt_Toolkit.cpp
index e8b2d51..8a3ed22 100644
--- a/src/windows/native/sun/windows/awt_Toolkit.cpp
+++ b/src/windows/native/sun/windows/awt_Toolkit.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2011, 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
@@ -62,7 +62,6 @@
#include <java_awt_Toolkit.h>
#include <java_awt_event_InputMethodEvent.h>
-#include <java_awt_peer_ComponentPeer.h>
extern void initScreens(JNIEnv *env);
extern "C" void awt_dnd_initialize();
diff --git a/test/Makefile b/test/Makefile
index c09368d..bd3a8d3 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1995, 2012, 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
@@ -336,7 +336,7 @@
@$(ECHO) "Testing completed successfully"
# Prep for output
-prep: clean
+prep:
@$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR)
@$(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`
@@ -519,7 +519,6 @@
jdk/asm \
com/sun/org/apache/xerces \
com/sun/corba \
- com/sun/servicetag \
com/sun/tracing \
sun/usagetracker)
$(call RunAgentvmBatch)
@@ -706,200 +705,6 @@
################################################################
-# packtest
-
-# Expect JPRT to set JPRT_PACKTEST_HOME.
-PACKTEST_HOME = /net/jprt-web.sfbay.sun.com/jprt/allproducts/packtest
-ifdef JPRT_PACKTEST_HOME
- PACKTEST_HOME = $(JPRT_PACKTEST_HOME)
-endif
-
-packtest: prep $(PACKTEST_HOME)/ptest $(PRODUCT_HOME)
- ( $(CD) $(PACKTEST_HOME) && \
- $(PACKTEST_HOME)/ptest \
- -t "$(PRODUCT_HOME)" \
- $(PACKTEST_STRESS_OPTION) \
- $(EXTRA_PACKTEST_OPTIONS) \
- -W $(ABS_TEST_OUTPUT_DIR) \
- $(JAVA_ARGS:%=-J %) \
- $(JAVA_VM_ARGS:%=-J %) \
- ) ; $(BUNDLE_UP_AND_EXIT)
-
-packtest_stress: PACKTEST_STRESS_OPTION=-s
-packtest_stress: packtest
-
-PHONY_LIST += packtest packtest_stress
-
-################################################################
-
-# perftest to collect statistics
-
-# Expect JPRT to set JPRT_PACKTEST_HOME.
-PERFTEST_HOME = $(TEST_ROOT)/perf
-ifdef JPRT_PERFTEST_HOME
- PERFTEST_HOME = $(JPRT_PERFTEST_HOME)
-endif
-
-perftest: ( $(PERFTEST_HOME)/perftest \
- -t $(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \
- -w $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)") \
- -h $(PERFTEST_HOME) \
- ) ; $(BUNDLE_UP_AND_EXIT)
-
-
-PHONY_LIST += perftest
-
-################################################################
-
-# vmsqe tests
-
-# Expect JPRT to set JPRT_VMSQE_HOME.
-VMSQE_HOME = $(SLASH_JAVA)/sqe/comp/vm/testbase/sqe/vm/current/build/latest/vm
-ifdef JPRT_VMSQE_HOME
- VMSQE_HOME = $(JPRT_VMSQE_HOME)
-endif
-
-# Expect JPRT to set JPRT_RUNVMSQE_HOME.
-RUNVMSQE_HOME = /net/jprt-web.sfbay.sun.com/jprt/allproducts/runvmsqe
-ifdef JPRT_RUNVMSQE_HOME
- RUNVMSQE_HOME = $(JPRT_RUNVMSQE_HOME)
-endif
-
-# Expect JPRT to set JPRT_TONGA3_HOME.
-TONGA3_HOME = $(SLASH_JAVA)/sqe/tools/gtee/harness/tonga
-ifdef JPRT_TONGA3_HOME
- TONGA3_HOME = $(JPRT_TONGA3_HOME)
-endif
-
-RUNVMSQE_BIN = $(RUNVMSQE_HOME)/bin/runvmsqe
-
-vmsqe_tests: prep $(VMSQE_HOME)/vm $(TONGA3_HOME) $(RUNVMSQE_BIN) $(PRODUCT_HOME)
- $(RM) -r $(ABS_TEST_OUTPUT_DIR)/vmsqe
- ( $(CD) $(ABS_TEST_OUTPUT_DIR) && \
- $(RUNVMSQE_BIN) \
- -jdk "$(PRODUCT_HOME)" \
- -o "$(ABS_TEST_OUTPUT_DIR)/vmsqe" \
- -testbase "$(VMSQE_HOME)/vm" \
- -tonga "$(TONGA3_HOME)" \
- -tongajdk "$(ALT_BOOTDIR)" \
- $(JAVA_ARGS) \
- $(JAVA_VM_ARGS) \
- $(RUNVMSQE_TEST_OPTION) \
- $(EXTRA_RUNVMSQE_OPTIONS) \
- ) ; $(BUNDLE_UP_AND_EXIT)
-
-vmsqe_jdwp: RUNVMSQE_TEST_OPTION=-jdwp
-vmsqe_jdwp: vmsqe_tests
-
-vmsqe_jdi: RUNVMSQE_TEST_OPTION=-jdi
-vmsqe_jdi: vmsqe_tests
-
-vmsqe_jdb: RUNVMSQE_TEST_OPTION=-jdb
-vmsqe_jdb: vmsqe_tests
-
-vmsqe_quick-jdi: RUNVMSQE_TEST_OPTION=-quick-jdi
-vmsqe_quick-jdi: vmsqe_tests
-
-vmsqe_sajdi: RUNVMSQE_TEST_OPTION=-sajdi
-vmsqe_sajdi: vmsqe_tests
-
-vmsqe_jvmti: RUNVMSQE_TEST_OPTION=-jvmti
-vmsqe_jvmti: vmsqe_tests
-
-vmsqe_hprof: RUNVMSQE_TEST_OPTION=-hprof
-vmsqe_hprof: vmsqe_tests
-
-vmsqe_monitoring: RUNVMSQE_TEST_OPTION=-monitoring
-vmsqe_monitoring: vmsqe_tests
-
-PHONY_LIST += vmsqe_jdwp vmsqe_jdi vmsqe_jdb vmsqe_quick-jdi vmsqe_sajdi \
- vmsqe_jvmti vmsqe_hprof vmsqe_monitoring vmsqe_tests
-
-################################################################
-
-# jck tests
-
-# Default is to use jck 7 from /java/re
-JCK7_DEFAULT_HOME = $(SLASH_JAVA)/re/jck/7/promoted/latest/binaries
-
-# Expect JPRT to set JPRT_JCK7COMPILER_HOME.
-JCK7COMPILER_HOME = $(JCK7_DEFAULT_HOME)/JCK-compiler-7
-ifdef JPRT_JCK7COMPILER_HOME
- JCK7COMPILER_HOME = $(JPRT_JCK7COMPILER_HOME)/JCK-compiler-7
-endif
-
-# Expect JPRT to set JPRT_JCK7RUNTIME_HOME.
-JCK7RUNTIME_HOME = $(JCK7_DEFAULT_HOME)/JCK-runtime-7
-ifdef JPRT_JCK7RUNTIME_HOME
- JCK7RUNTIME_HOME = $(JPRT_JCK7RUNTIME_HOME)/JCK-runtime-7
-endif
-
-# Expect JPRT to set JPRT_JCK7DEVTOOLS_HOME.
-JCK7DEVTOOLS_HOME = $(JCK7_DEFAULT_HOME)/JCK-devtools-7
-ifdef JPRT_JCK7DEVTOOLS_HOME
- JCK7DEVTOOLS_HOME = $(JPRT_JCK7DEVTOOLS_HOME)/JCK-devtools-7
-endif
-
-# The jtjck.jar utility to use to run the tests
-JTJCK_JAR = $(JCK_HOME)/lib/jtjck.jar
-JTJCK_JAVA_ARGS = -XX:MaxPermSize=256m -Xmx512m
-JTJCK_OPTIONS = -headless -v
-
-# Default tests to run
-ifndef JCK_COMPILER_TESTS
- JCK_COMPILER_TESTS =
-endif
-ifndef JCK_RUNTIME_TESTS
- JCK_RUNTIME_TESTS =
-endif
-ifndef JCK_DEVTOOLS_TESTS
- JCK_DEVTOOLS_TESTS =
-endif
-
-# Generic rule used to run jck tests
-_generic_jck_tests: prep $(PRODUCT_HOME) $(EXCLUDELIST)
- @$(EXPAND) $(EXCLUDELIST) \
- | $(CUT) -d' ' -f1 \
- | $(SED) -e 's@^@Excluding: @'
- ( $(CD) $(ABS_TEST_OUTPUT_DIR) && \
- $(PRODUCT_HOME)/bin/java $(JTJCK_JAVA_ARGS) \
- -jar "$(JTJCK_JAR)" \
- $(JTJCK_OPTIONS) \
- -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport \
- -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork \
- -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \
- $(TESTDIRS) \
- ) ; $(BUNDLE_UP_AND_EXIT)
-
-# JCK7 compiler tests
-jck7compiler:
- $(MAKE) UNIQUE_DIR=$@ \
- JCK_HOME=$(JCK7COMPILER_HOME) \
- TESTDIRS="$(JCK_COMPILER_TESTS)" \
- _generic_jck_tests
-
-# JCK7 runtime tests
-jck7runtime:
- $(MAKE) UNIQUE_DIR=$@ \
- JCK_HOME=$(JCK7RUNTIME_HOME) \
- TESTDIRS="$(JCK_RUNTIME_TESTS)" \
- _generic_jck_tests
-
-# JCK7 devtools tests
-jck7devtools:
- $(MAKE) UNIQUE_DIR=$@ \
- JCK_HOME=$(JCK7DEVTOOLS_HOME) \
- TESTDIRS="$(JCK_DEVTOOLS_TESTS)" \
- _generic_jck_tests
-
-# Run all 3 sets of JCK7 tests
-jck_all: jck7runtime jck7devtools jck7compiler
-
-PHONY_LIST += jck_all _generic_jck_tests \
- jck7compiler jck7runtime jck7devtools
-
-################################################################
-
# Phony targets (e.g. these are not filenames)
.PHONY: all clean prep $(PHONY_LIST)
diff --git a/test/ProblemList.txt b/test/ProblemList.txt
index 842ffbe..d139754 100644
--- a/test/ProblemList.txt
+++ b/test/ProblemList.txt
@@ -137,6 +137,9 @@
# 8008200
java/lang/Class/asSubclass/BasicUnit.java generic-all
+# 8009552
+vm/verifier/TestStaticIF.java generic-all
+
############################################################################
# jdk_management
@@ -285,6 +288,12 @@
# 8000439: NPG: REGRESSION : sun/security/krb5/auto/MaxRetries.java fails with timeout
sun/security/krb5/auto/MaxRetries.java solaris-sparcv9
+# 8006690: sun/security/krb5/auto/BadKdc1.java fails intermittently
+sun/security/krb5/auto/BadKdc1.java solaris-sparcv9
+sun/security/krb5/auto/BadKdc2.java solaris-sparcv9
+sun/security/krb5/auto/BadKdc3.java solaris-sparcv9
+sun/security/krb5/auto/BadKdc4.java solaris-sparcv9
+
# 7194428
sun/security/mscapi/ShortRSAKey1024.sh windows-all
@@ -330,23 +339,6 @@
# 8007410
tools/launcher/FXLauncherTest.java linux-all
-# 8004172
-sun/tools/jstat/jstatGcCapacityOutput1.sh generic-all
-sun/tools/jstat/jstatGcCauseOutput1.sh generic-all
-sun/tools/jstat/jstatGcOldOutput1.sh generic-all
-sun/tools/jstat/jstatGcOutput1.sh generic-all
-sun/tools/jstat/jstatGcPermCapacityOutput1.sh generic-all
-sun/tools/jstat/jstatLineCounts1.sh generic-all
-sun/tools/jstat/jstatLineCounts2.sh generic-all
-sun/tools/jstat/jstatLineCounts3.sh generic-all
-sun/tools/jstat/jstatLineCounts4.sh generic-all
-sun/tools/jstat/jstatOptions1.sh generic-all
-sun/tools/jstat/jstatTimeStamp1.sh generic-all
-sun/tools/jstatd/jstatdExternalRegistry.sh generic-all
-sun/tools/jstatd/jstatdDefaults.sh generic-all
-sun/tools/jstatd/jstatdPort.sh generic-all
-sun/tools/jstatd/jstatdServerName.sh generic-all
-
############################################################################
# jdk_jdi
diff --git a/test/com/sun/jdi/NativeInstanceFilter.java b/test/com/sun/jdi/NativeInstanceFilter.java
index eaa501a..7902971 100644
--- a/test/com/sun/jdi/NativeInstanceFilter.java
+++ b/test/com/sun/jdi/NativeInstanceFilter.java
@@ -57,6 +57,7 @@
static EventRequestManager requestManager = null;
static MethodExitRequest request = null;
+ static ThreadReference mainThread = null;
private void listen() {
TargetAdapter adapter = new TargetAdapter() {
@@ -77,6 +78,7 @@
requestManager.deleteEventRequest(request);
request = requestManager.createMethodExitRequest();
request.addInstanceFilter(instance);
+ request.addThreadFilter(mainThread);
request.enable();
} else if (instance != null && name.equals("intern")) {
// If not for the filter, this will be called twice
@@ -101,10 +103,12 @@
// VM has started, but hasn't started running the test program yet.
requestManager = vm().eventRequestManager();
- ReferenceType referenceType =
- resumeToPrepareOf("NativeInstanceFilterTarg").referenceType();
+ ClassPrepareEvent e = resumeToPrepareOf("NativeInstanceFilterTarg");
+ ReferenceType referenceType = e.referenceType();
+ mainThread = e.thread();
request = requestManager.createMethodExitRequest();
+ request.addThreadFilter(mainThread);
request.enable();
listen();
diff --git a/test/com/sun/servicetag/DeleteServiceTag.java b/test/com/sun/servicetag/DeleteServiceTag.java
deleted file mode 100644
index 5fcaa78..0000000
--- a/test/com/sun/servicetag/DeleteServiceTag.java
+++ /dev/null
@@ -1,129 +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.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for deleting a service tag in a product registration
- * @author Mandy Chung
- *
- * @run build DeleteServiceTag Util
- * @run main DeleteServiceTag
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class DeleteServiceTag {
- private static RegistrationData registration;
- private static File regFile;
- private static Map<String, ServiceTag> stMap =
- new LinkedHashMap<String, ServiceTag>();
- private static String[] files = new String[] {
- "servicetag1.properties",
- "servicetag2.properties",
- "servicetag3.properties"
- };
-
- public static void main(String[] argv) throws Exception {
- String registrationDir = System.getProperty("test.classes");
- String servicetagDir = System.getProperty("test.src");
-
- File original = new File(servicetagDir, "registration.xml");
- regFile = new File(registrationDir, "registration.xml");
- copyRegistrationXML(original, regFile);
-
- // loads all the service tags
- for (String f : files) {
- File stfile = new File(servicetagDir, f);
- ServiceTag svcTag = Util.newServiceTag(stfile);
- stMap.put(svcTag.getInstanceURN(), svcTag);
- }
-
- // load the registration data with all service tags
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(regFile));
- registration = RegistrationData.loadFromXML(in);
-
- if (stMap.size() != files.length) {
- throw new RuntimeException("Invalid service tag count= " +
- stMap.size() + " expected=" + files.length);
- }
- // check the service tags
- Util.checkRegistrationData(regFile.getCanonicalPath(), stMap);
-
- // delete a service tag
- deleteServiceTag(servicetagDir, files[0]);
-
- System.out.println("Test passed: service tags deleted.");
- }
-
- private static void copyRegistrationXML(File from, File to) throws IOException {
-
- to.delete();
- BufferedReader reader = new BufferedReader(new FileReader(from));
- PrintWriter writer = new PrintWriter(to);
- try {
- String line = null;
- while ((line = reader.readLine()) != null) {
- writer.println(line);
- }
- writer.flush();
- } finally {
- writer.close();
- }
- }
-
- private static void deleteServiceTag(String parent, String filename) throws Exception {
- File f = new File(parent, filename);
- ServiceTag svcTag = Util.newServiceTag(f);
-
- ServiceTag st = registration.removeServiceTag(svcTag.getInstanceURN());
- if (st == null) {
- throw new RuntimeException("RegistrationData.remove method" +
- " returns null");
- }
- if (!Util.matches(st, svcTag)) {
- throw new RuntimeException("ServiceTag added in the registration " +
- " doesn't match.");
- }
- // check the service tags before storing the updated data
- Util.checkRegistrationData(regFile.getCanonicalPath(), stMap);
-
- ServiceTag st1 = registration.getServiceTag(svcTag.getInstanceURN());
- if (st1 != null) {
- throw new RuntimeException("RegistrationData.get method returns " +
- "non-null.");
- }
- // Now remove the service tag from the map and store to the XML file
- stMap.remove(svcTag.getInstanceURN());
- BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(regFile));
- try {
- registration.storeToXML(out);
- } finally {
- out.close();
- }
- }
-}
diff --git a/test/com/sun/servicetag/DuplicateNotFound.java b/test/com/sun/servicetag/DuplicateNotFound.java
deleted file mode 100644
index fa1d11b..0000000
--- a/test/com/sun/servicetag/DuplicateNotFound.java
+++ /dev/null
@@ -1,97 +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.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for RegistrationData.removeServiceTag and
- * updateServiceTag.
- * @author Mandy Chung
- *
- * @run build DuplicateNotFound Util
- * @run main DuplicateNotFound
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class DuplicateNotFound {
- private static String servicetagDir = System.getProperty("test.src");
- private static String[] files = new String[] {
- "servicetag1.properties",
- "servicetag2.properties",
- "servicetag3.properties"
- };
-
- private static RegistrationData registration = new RegistrationData();
-
- public static void main(String[] argv) throws Exception {
- ServiceTag svcTag;
- registration.addServiceTag(loadServiceTag(files[0]));
- registration.addServiceTag(loadServiceTag(files[1]));
- testDuplicate(files[0]);
- testDuplicate(files[1]);
- testNotFound(files[2]);
- }
-
- private static void testDuplicate(String filename) throws Exception {
- boolean dup = false;
- try {
- registration.addServiceTag(loadServiceTag(filename));
- } catch (IllegalArgumentException e) {
- dup = true;
- }
- if (!dup) {
- throw new RuntimeException(filename +
- " added successfully but expected to be a duplicated.");
- }
- }
- private static void testNotFound(String filename) throws Exception {
- ServiceTag st = loadServiceTag(filename);
- ServiceTag svctag = registration.getServiceTag(st.getInstanceURN());
- if (svctag != null) {
- throw new RuntimeException(st.getInstanceURN() +
- " exists but expected not found");
- }
-
- svctag = registration.removeServiceTag(st.getInstanceURN());
- if (svctag != null) {
- throw new RuntimeException(st.getInstanceURN() +
- " exists but expected not found");
- }
-
- svctag = registration.updateServiceTag(st.getInstanceURN(), "testing");
- if (svctag != null) {
- throw new RuntimeException(st.getInstanceURN() +
- " updated successfully but expected not found.");
- }
- }
-
- private static ServiceTag loadServiceTag(String filename) throws Exception {
- File f = new File(servicetagDir, filename);
- return Util.newServiceTag(f);
- }
-}
diff --git a/test/com/sun/servicetag/FindServiceTags.java b/test/com/sun/servicetag/FindServiceTags.java
deleted file mode 100644
index 349cc76..0000000
--- a/test/com/sun/servicetag/FindServiceTags.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for Registry.findServiceTags()
- * @author Mandy Chung
- *
- * @run build FindServiceTags SvcTagClient Util
- * @run main FindServiceTags
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-// This test creates a few service tags in the Registry.
-// Check if the findServiceTags method returns the expected ones.
-public class FindServiceTags {
- private static String registryDir = System.getProperty("test.classes");
- private static String servicetagDir = System.getProperty("test.src");
- private static String[] files = new String[] {
- "servicetag1.properties",
- "servicetag2.properties",
- "servicetag3.properties",
- "servicetag4.properties",
- "servicetag5.properties"
- };
-
- private static Registry registry;
- private static Set<ServiceTag> set = new HashSet<ServiceTag>();
- private static Set<String> productUrns = new HashSet<String>();
- private static int expectedUrnCount = 3;
-
- public static void main(String[] argv) throws Exception {
- try {
- registry = Util.getSvcTagClientRegistry();
- runTest();
- } finally {
- // restore empty registry file
- Util.emptyRegistryFile();
- }
- System.out.println("Test passed.");
- }
-
- public static void runTest() throws Exception {
- for (String filename : files) {
- File f = new File(servicetagDir, filename);
- ServiceTag svcTag = Util.newServiceTag(f);
- ServiceTag st = registry.addServiceTag(svcTag);
-
- set.add(st);
- productUrns.add(st.getProductURN());
- }
- if (productUrns.size() != expectedUrnCount) {
- throw new RuntimeException("Unexpected number of product URNs = " +
- productUrns.size() + " expected " + expectedUrnCount);
- }
- if (set.size() != files.length) {
- throw new RuntimeException("Unexpected number of service tags = " +
- set.size() + " expected " + files.length);
- }
- String purn = null;
- for (String urn : productUrns) {
- if (purn == null) {
- // save the first product_urn for later use
- purn = urn;
- }
- findServiceTags(urn);
- }
-
- // remove all service tags of purn
- Set<ServiceTag> tags = registry.findServiceTags(purn);
- for (ServiceTag st : tags) {
- System.out.println("Removing service tag " + st.getInstanceURN());
- registry.removeServiceTag(st.getInstanceURN());
- }
- tags = registry.findServiceTags(purn);
- if (tags.size() != 0) {
- throw new RuntimeException("Unexpected service tag count = " +
- tags.size());
- }
-
- }
-
- private static void findServiceTags(String productUrn) throws Exception {
- Set<ServiceTag> found = registry.findServiceTags(productUrn);
- Set<ServiceTag> matched = new HashSet<ServiceTag>();
- System.out.println("Finding service tags of product_urn=" +
- productUrn);
- for (ServiceTag st : set) {
- if (st.getProductURN().equals(productUrn)) {
- System.out.println(st.getInstanceURN());
- matched.add(st);
- }
- }
- if (found.size() != matched.size()) {
- throw new RuntimeException("Unmatched service tag count = " +
- found.size() + " expected " + matched.size());
- }
-
- for (ServiceTag st0 : found) {
- ServiceTag st = null;
- for (ServiceTag st1 : matched) {
- if (Util.matches(st0, st1)) {
- st = st1;
- break;
- }
- }
- if (st == null) {
- System.out.println("product_urn=" + st0.getProductURN());
- System.out.println("instance_urn=" + st0.getInstanceURN() );
- throw new RuntimeException(st0.getInstanceURN() +
- " not expected in the returned list");
- }
- }
- }
-}
diff --git a/test/com/sun/servicetag/InstanceUrnCheck.java b/test/com/sun/servicetag/InstanceUrnCheck.java
deleted file mode 100644
index b01d46b..0000000
--- a/test/com/sun/servicetag/InstanceUrnCheck.java
+++ /dev/null
@@ -1,76 +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.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for checking instance_urn
- * @author Mandy Chung
- *
- * @run build InstanceUrnCheck Util
- * @run main InstanceUrnCheck
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class InstanceUrnCheck {
- private static String servicetagDir = System.getProperty("test.src");
- private static String[] files = new String[] {
- "servicetag1.properties",
- "servicetag2.properties",
- "servicetag3.properties"
- };
- private static RegistrationData registration = new RegistrationData();
-
- public static void main(String[] argv) throws Exception {
- for (String f : files) {
- addServiceTag(f);
- }
- }
-
- private static void addServiceTag(String filename) throws Exception {
- File f = new File(servicetagDir, filename);
- ServiceTag svcTag = Util.newServiceTag(f, true /* no instance_urn */);
- ServiceTag st = registration.addServiceTag(svcTag);
- if (!Util.matchesNoInstanceUrn(svcTag, st)) {
- throw new RuntimeException("ServiceTag " +
- " doesn't match.");
- }
- System.out.println("New service tag instance_urn=" + st.getInstanceURN());
- if (!st.getInstanceURN().startsWith("urn:st:")) {
- throw new RuntimeException("Invalid generated instance_urn " +
- st.getInstanceURN());
- }
- if (st.getInstallerUID() != -1) {
- throw new RuntimeException("Invalid installer_uid " +
- st.getInstallerUID());
- }
- if (st.getTimestamp() == null) {
- throw new RuntimeException("null timestamp ");
- }
- }
-}
diff --git a/test/com/sun/servicetag/InvalidRegistrationData.java b/test/com/sun/servicetag/InvalidRegistrationData.java
deleted file mode 100644
index 31b5bbf..0000000
--- a/test/com/sun/servicetag/InvalidRegistrationData.java
+++ /dev/null
@@ -1,65 +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.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for invalid product registry
- * @author Mandy Chung
- *
- * @run build InvalidRegistrationData
- * @run main InvalidRegistrationData
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class InvalidRegistrationData {
- public static void main(String[] argv) throws Exception {
- String servicetagDir = System.getProperty("test.src");
-
- checkRegistrationData(servicetagDir, "missing-environ-field.xml");
- checkRegistrationData(servicetagDir, "newer-registry-version.xml");
- }
-
- private static void checkRegistrationData(String parent, String filename)
- throws Exception {
- boolean thrown = false;
- File f = new File(parent, filename);
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
- try {
- RegistrationData regData = RegistrationData.loadFromXML(in);
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage() + " thrown expected");
- thrown = true;
- }
-
- if (!thrown) {
- throw new RuntimeException("ERROR: No IllegalArgumentException thrown");
- }
- }
-
-}
diff --git a/test/com/sun/servicetag/InvalidServiceTag.java b/test/com/sun/servicetag/InvalidServiceTag.java
deleted file mode 100644
index 0b90fc2..0000000
--- a/test/com/sun/servicetag/InvalidServiceTag.java
+++ /dev/null
@@ -1,96 +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.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for ServiceTag.newServiceTag() to test invalid fields.
- * @author Mandy Chung
- *
- * @run build InvalidServiceTag
- * @run main InvalidServiceTag
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class InvalidServiceTag {
- private final static int MAX_CONTAINER_LEN = 64 - 1;
- public static void main(String[] argv) throws Exception {
- // all fields valid
- ServiceTag st1 = ServiceTag.newInstance("product name",
- "product version",
- "product urn",
- "product parent",
- "product parent urn",
- "product defined instance ID",
- "product vendor",
- "platform arch",
- "container",
- "source");
- // empty optional field
- ServiceTag st2 = ServiceTag.newInstance("product name",
- "product version",
- "product urn",
- "product parent",
- "",
- "",
- "product vendor",
- "platform arch",
- "container",
- "source");
- // Invalid - empty required field
- setInvalidContainer("");
- // Invalid - required field exceeds max length.
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i <= MAX_CONTAINER_LEN; i++) {
- sb.append('x');
- }
- setInvalidContainer(sb.toString());
- System.out.println("Test passed.");
- }
- private static void setInvalidContainer(String container) {
- boolean exceptionThrown = false;
- try {
- ServiceTag st2 = ServiceTag.newInstance("product name",
- "product version",
- "product urn",
- "product parent",
- "product parent urn",
- "product defined instance ID",
- "product vendor",
- "platform arch",
- container,
- "source");
- } catch (IllegalArgumentException iae) {
- iae.printStackTrace();
- exceptionThrown = true;
- }
- if (!exceptionThrown) {
- throw new RuntimeException("IllegalArgumentException not thrown");
- }
- }
-}
diff --git a/test/com/sun/servicetag/JavaServiceTagTest.java b/test/com/sun/servicetag/JavaServiceTagTest.java
deleted file mode 100644
index a411fa9..0000000
--- a/test/com/sun/servicetag/JavaServiceTagTest.java
+++ /dev/null
@@ -1,191 +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.
- */
-
-/*
- * @test
- * @bug 6622366 7078024
- * @summary Basic Test for ServiceTag.getJavaServiceTag()
- * Disable creating the service tag in the system registry.
- * Verify the existence of registration.xml file and the
- * content of the service tag.
- * @author Mandy Chung
- *
- * @run build JavaServiceTagTest
- * @run main JavaServiceTagTest
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class JavaServiceTagTest {
- public static void main(String[] argv) throws Exception {
- String registrationDir = System.getProperty("test.classes");
-
- // disable calling to stclient
- System.setProperty("servicetag.sthelper.supported", "false");
-
- if (Registry.isSupported()) {
- throw new RuntimeException("Registry.isSupported() should " +
- "return false");
- }
- // For debugging
- // System.setProperty("servicetag.verbose", "");
-
- // cleanup the registration.xml and servicetag file in the test directory
- System.setProperty("servicetag.dir.path", registrationDir);
- File regFile = new File(registrationDir, "registration.xml");
- regFile.delete();
- File svcTagFile = new File(registrationDir, "servicetag");
- svcTagFile.delete();
-
- ServiceTag svctag = ServiceTag.getJavaServiceTag("JavaServiceTagTest");
- checkServiceTag(svctag);
-
- if (svcTagFile.exists()) {
- throw new RuntimeException(svcTagFile + " should not exist.");
- }
-
- // registration.xml should be created
- if (!regFile.exists()) {
- throw new RuntimeException(regFile + " not created.");
- }
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(regFile));
- RegistrationData registration = RegistrationData.loadFromXML(in);
- Set<ServiceTag> c = registration.getServiceTags();
- if (c.size() != 1) {
- throw new RuntimeException(regFile + " has " + c.size() +
- " service tags. Expected 1.");
- }
- ServiceTag st = registration.getServiceTag(svctag.getInstanceURN());
- if (!Util.matches(st, svctag)) {
- throw new RuntimeException("ServiceTag " +
- " doesn't match.");
- }
- }
-
- /**
- * Tests if the running platform is a JDK.
- */
- static boolean isJDK() {
- // Determine the JRE path by checking the existence of
- // <HOME>/jre/lib and <HOME>/lib.
- String javaHome = System.getProperty("java.home");
- String 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.endsWith(File.separator + "jre");
- }
-
- private static void checkServiceTag(ServiceTag st) throws IOException {
- Properties props = loadServiceTagProps();
- // jdk 8 and later, JDK and JRE have the same product URN.
- String jdkUrn = props.getProperty("servicetag.jdk.urn");
- String jreUrn = props.getProperty("servicetag.jre.urn");
- boolean isJdk = isJDK();
-
- if (isJdk) {
- if (!st.getProductURN().equals(jdkUrn) ||
- !st.getProductName().equals(
- props.getProperty("servicetag.jdk.name"))) {
- throw new RuntimeException("Product URN and name don't match.");
- }
- } else {
- if (!st.getProductURN().equals(jreUrn) ||
- !st.getProductName().equals(
- props.getProperty("servicetag.jre.name"))) {
- throw new RuntimeException("Product URN and name don't match.");
- }
- }
- if (!st.getProductVersion().
- equals(System.getProperty("java.version"))) {
- throw new RuntimeException("Unexpected product_version: " +
- st.getProductVersion());
- }
- if (!st.getProductParent().
- equals(props.getProperty("servicetag.parent.name"))) {
- throw new RuntimeException("Unexpected product_parent: " +
- st.getProductParent());
- }
- if (!st.getProductParentURN().
- equals(props.getProperty("servicetag.parent.urn"))) {
- throw new RuntimeException("Unexpected product_parent_urn: " +
- st.getProductParentURN());
- }
- if (!st.getPlatformArch().
- equals(System.getProperty("os.arch"))) {
- throw new RuntimeException("Unexpected platform_arch: " +
- st.getPlatformArch());
- }
- String vendor = System.getProperty("java.vendor");
- if (!st.getProductVendor().
- equals(vendor)) {
- throw new RuntimeException("Unexpected product_vendor: " +
- st.getProductVendor());
- }
- if (!st.getSource().
- equals("JavaServiceTagTest")) {
- throw new RuntimeException("Unexpected source: " +
- st.getSource());
- }
- String[] ss = st.getProductDefinedInstanceID().split(",");
- boolean id = false;
- boolean dir = false;
- for (String s : ss) {
- String[] values = s.split("=");
- if (values[0].equals("id")) {
- id = true;
- String[] sss = values[1].split(" ");
- if (!sss[0].equals(System.getProperty("java.runtime.version"))) {
- throw new RuntimeException("Unexpected version in id: " +
- sss[0]);
- }
- if (sss.length < 2) {
- throw new RuntimeException("Unexpected id=" + values[1]);
- }
- } else if (values[0].equals("dir")) {
- dir = true;
- }
- }
- if (!id || !dir) {
- throw new RuntimeException("Unexpected product_defined_instance_id: " +
- st.getProductDefinedInstanceID());
- }
- }
-
- private static Properties loadServiceTagProps()
- throws IOException {
- String filename = "/com/sun/servicetag/resources/javase_servicetag.properties";
- try (InputStream in = Installer.class.getClass().getResourceAsStream(filename)) {
- Properties props = new Properties();
- props.load(in);
- return props;
- }
- }
-}
diff --git a/test/com/sun/servicetag/JavaServiceTagTest1.java b/test/com/sun/servicetag/JavaServiceTagTest1.java
deleted file mode 100644
index d220bf0..0000000
--- a/test/com/sun/servicetag/JavaServiceTagTest1.java
+++ /dev/null
@@ -1,265 +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.
- */
-
-/*
- * @test
- * @bug 6622366 7078024
- * @summary Basic Test for ServiceTag.getJavaServiceTag(String)
- * to verify that the registration.xml and servicetag files
- * are both created correctly.
- * @author Mandy Chung
- *
- * @run build JavaServiceTagTest1 SvcTagClient Util
- * @run main JavaServiceTagTest1
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class JavaServiceTagTest1 {
- private static String registrationDir = System.getProperty("test.classes");
- private static String servicetagDir = System.getProperty("test.src");
- private static File regFile;
- private static File svcTagFile;
- private static Registry registry;
- public static void main(String[] argv) throws Exception {
- try {
- registry = Util.getSvcTagClientRegistry();
- runTest();
- } finally {
- // restore empty registry file
- Util.emptyRegistryFile();
- }
- }
-
- private static void runTest() throws Exception {
- // cleanup the registration.xml and servicetag file in the test directory
- System.setProperty("servicetag.dir.path", registrationDir);
- regFile = new File(registrationDir, "registration.xml");
- regFile.delete();
-
- svcTagFile = new File(registrationDir, "servicetag");
- svcTagFile.delete();
-
- // verify that only one service tag is created
- ServiceTag st1 = testJavaServiceTag("Test1");
-
- // getJavaServiceTag method should create a new service tag
- // and delete the old one
- ServiceTag st2 = testJavaServiceTag("Test2");
- if (registry.getServiceTag(st1.getInstanceURN()) != null) {
- throw new RuntimeException("instance_urn: " + st1.getInstanceURN() +
- " exists but expected to be removed");
- }
-
- // expected to have different instance_urn
- if (st1.getInstanceURN().equals(st2.getInstanceURN())) {
- throw new RuntimeException("instance_urn: " + st1.getInstanceURN() +
- " == " + st2.getInstanceURN());
- }
-
- // Delete the service tag from the Registry and the servicetag file
- if (registry.removeServiceTag(st2.getInstanceURN()) == null) {
- throw new RuntimeException("Failed to remove " +
- st1.getInstanceURN() + " from the registry");
- }
- svcTagFile.delete();
-
- // call the getJavaServiceTag(String) method again
- // should create the servicetag file.
- ServiceTag st3 = testJavaServiceTag("Test2");
- if (!Util.matches(st2, st3)) {
- System.out.println(st2);
- System.out.println(st3);
- throw new RuntimeException("Test Failed: Expected to be the same");
- }
-
- }
-
- private static ServiceTag testJavaServiceTag(String source) throws Exception {
- ServiceTag svctag = ServiceTag.getJavaServiceTag(source);
- checkServiceTag(svctag, source);
-
- // verify if registration.xml is created
- if (!regFile.exists()) {
- throw new RuntimeException(regFile + " not created.");
- }
-
- // verify the registration.xml content is the expected service tag
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(regFile));
- RegistrationData registration = RegistrationData.loadFromXML(in);
- Set<ServiceTag> c = registration.getServiceTags();
- if (c.size() != 1) {
- throw new RuntimeException(regFile + " has " + c.size() +
- " service tags. Expected 1.");
- }
- ServiceTag st = registration.getServiceTag(svctag.getInstanceURN());
- if (!Util.matches(st, svctag)) {
- throw new RuntimeException("RegistrationData ServiceTag " +
- " doesn't match.");
- }
-
- // verify the service tag added in the registry
- st = registry.getServiceTag(svctag.getInstanceURN());
- if (!Util.matches(st, svctag)) {
- throw new RuntimeException("Registry ServiceTag " +
- " doesn't match.");
- }
-
- // verify if servicetag file is created
- if (!svcTagFile.exists()) {
- throw new RuntimeException(svcTagFile + " not created.");
- }
-
- // verify that the servicetag file only contains one instance_urn
- BufferedReader reader = new BufferedReader(new FileReader(svcTagFile));
- int count = 0;
- try {
- String line;
- while ((line = reader.readLine()) != null) {
- if (line.equals(svctag.getInstanceURN())) {
- count++;
- } else {
- throw new RuntimeException("servicetag contains " +
- " unexpected instance_urn " + line);
- }
- }
- } finally {
- reader.close();
- }
- if (count != 1) {
- throw new RuntimeException("servicetag contains unexpected " +
- "number of instance_urn = " + count);
- }
- return svctag;
- }
-
- /**
- * Tests if the running platform is a JDK.
- */
- static boolean isJDK() {
- // Determine the JRE path by checking the existence of
- // <HOME>/jre/lib and <HOME>/lib.
- String javaHome = System.getProperty("java.home");
- String 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.endsWith(File.separator + "jre");
- }
-
- private static void checkServiceTag(ServiceTag st, String source)
- throws IOException {
- Properties props = loadServiceTagProps();
- // jdk 8 and later, JDK and JRE have the same product URN.
- String jdkUrn = props.getProperty("servicetag.jdk.urn");
- String jreUrn = props.getProperty("servicetag.jre.urn");
- boolean isJdk = isJDK();
-
- if (isJdk) {
- if (!st.getProductURN().equals(jdkUrn) ||
- !st.getProductName().equals(
- props.getProperty("servicetag.jdk.name"))) {
- throw new RuntimeException("Product URN and name don't match.");
- }
- } else {
- if (!st.getProductURN().equals(jreUrn) ||
- !st.getProductName().equals(
- props.getProperty("servicetag.jre.name"))) {
- throw new RuntimeException("Product URN and name don't match.");
- }
- }
-
- if (!st.getProductVersion().
- equals(System.getProperty("java.version"))) {
- throw new RuntimeException("Unexpected product_version: " +
- st.getProductVersion());
- }
- if (!st.getProductParent().
- equals(props.getProperty("servicetag.parent.name"))) {
- throw new RuntimeException("Unexpected product_parent: " +
- st.getProductParent());
- }
- if (!st.getProductParentURN().
- equals(props.getProperty("servicetag.parent.urn"))) {
- throw new RuntimeException("Unexpected product_parent_urn: " +
- st.getProductParentURN());
- }
- if (!st.getPlatformArch().
- equals(System.getProperty("os.arch"))) {
- throw new RuntimeException("Unexpected platform_arch: " +
- st.getPlatformArch());
- }
-
- String vendor = System.getProperty("java.vendor");
- if (!st.getProductVendor().
- equals(vendor)) {
- throw new RuntimeException("Unexpected product_vendor: " +
- st.getProductVendor());
- }
- if (!st.getSource().
- equals(source)) {
- throw new RuntimeException("Unexpected source: " +
- st.getSource() + " expected: " + source);
- }
- String[] ss = st.getProductDefinedInstanceID().split(",");
- boolean id = false;
- boolean dir = false;
- for (String s : ss) {
- String[] values = s.split("=");
- if (values[0].equals("id")) {
- id = true;
- String[] sss = values[1].split(" ");
- if (!sss[0].equals(System.getProperty("java.runtime.version"))) {
- throw new RuntimeException("Unexpected version in id: " +
- sss[0]);
- }
- if (sss.length < 2) {
- throw new RuntimeException("Unexpected id=" + values[1]);
- }
- } else if (values[0].equals("dir")) {
- dir = true;
- }
- }
- if (!id || !dir) {
- throw new RuntimeException("Unexpected product_defined_instance_id: " +
- st.getProductDefinedInstanceID());
- }
- }
-
- private static Properties loadServiceTagProps()
- throws IOException {
- String filename = "/com/sun/servicetag/resources/javase_servicetag.properties";
- try (InputStream in = Installer.class.getClass().getResourceAsStream(filename)) {
- Properties props = new Properties();
- props.load(in);
- return props;
- }
- }
-}
diff --git a/test/com/sun/servicetag/NewRegistrationData.java b/test/com/sun/servicetag/NewRegistrationData.java
deleted file mode 100644
index d2b6c8b..0000000
--- a/test/com/sun/servicetag/NewRegistrationData.java
+++ /dev/null
@@ -1,105 +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.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for Registration Data
- * @author Mandy Chung
- *
- * @run build NewRegistrationData Util
- * @run main NewRegistrationData
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class NewRegistrationData {
- private static RegistrationData regData;
- private static Map<String, ServiceTag> stMap = new LinkedHashMap<String, ServiceTag>();
- private static String[] files = new String[] {
- "servicetag1.properties",
- "servicetag2.properties",
- "servicetag3.properties"
- };
-
- public static void main(String[] argv) throws Exception {
- String regDataDir = System.getProperty("test.classes");
- String servicetagDir = System.getProperty("test.src");
-
- File reg = new File(regDataDir, "registration.xml");
- // Make sure a brand new file is created
- reg.delete();
-
- regData = new RegistrationData();
- if (regData.getRegistrationURN().isEmpty()) {
- throw new RuntimeException("Empty registration urn");
- }
-
- int count = 0;
- for (String f : files) {
- addServiceTag(servicetagDir, f, ++count);
- }
-
- // check if the registration data contains all service tags
- Set<ServiceTag> c = regData.getServiceTags();
- for (ServiceTag st : c) {
- if (!Util.matches(st, regData.getServiceTag(st.getInstanceURN()))) {
- throw new RuntimeException("ServiceTag added in the regData " +
- " doesn't match.");
- }
- }
-
- // store the service tag to a file
- BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(reg));
- try {
- regData.storeToXML(out);
- } finally {
- out.close();
- }
-
- Util.checkRegistrationData(reg.getCanonicalPath(), stMap);
- System.out.println("Test passed: " + count + " service tags added");
- }
-
- private static void addServiceTag(String parent, String filename, int count) throws Exception {
- File f = new File(parent, filename);
- ServiceTag svcTag = Util.newServiceTag(f);
- regData.addServiceTag(svcTag);
- stMap.put(svcTag.getInstanceURN(), svcTag);
-
- Set<ServiceTag> c = regData.getServiceTags();
- if (c.size() != count) {
- throw new RuntimeException("Invalid service tag count= " +
- c.size() + " expected=" + count);
- }
- ServiceTag st = regData.getServiceTag(svcTag.getInstanceURN());
- if (!Util.matches(st, svcTag)) {
- throw new RuntimeException("ServiceTag added in the regData " +
- " doesn't match.");
- }
- }
-}
diff --git a/test/com/sun/servicetag/SvcTagClient.java b/test/com/sun/servicetag/SvcTagClient.java
deleted file mode 100644
index d888a44..0000000
--- a/test/com/sun/servicetag/SvcTagClient.java
+++ /dev/null
@@ -1,200 +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.
- */
-
-/*
- * @bug 6622366
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-/**
- * A utility class simulating stclient for testing purpose.
- */
-public class SvcTagClient {
- private static File xmlFile;
- private static RegistrationData registration;
- private static String instanceURN;
- private static String productName;
- private static String productVersion;
- private static String productURN;
- private static String productParent;
- private static String productParentURN = ""; // optional
- private static String productDefinedInstanceID = ""; //optional
- private static String productVendor;
- private static String platformArch;
- private static String container;
- private static String source;
-
- // stclient exit value
- private static final int ST_ERR_REC_NOT_FOUND = 225;
-
- public static void main(String[] args) throws Exception {
- String path = System.getProperty("stclient.registry.path");
- if (path == null) {
- System.err.println("stclient registry path missing");
- System.exit(-1);
- }
- xmlFile = new File(path);
- if (xmlFile.exists()) {
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(xmlFile));
- registration = RegistrationData.loadFromXML(in);
- } else {
- registration = new RegistrationData();
- }
- boolean add = false;
- boolean delete = false;
- boolean update = false;
- boolean get = false;
- boolean find = false;
-
- int count = 0;
- while (count < args.length) {
- String arg = args[count];
- if (!arg.startsWith("-")) {
- System.err.println("Invalid option:" + arg);
- System.exit(-1);
- }
- if (arg.equals("-a")) {
- add = true;
- } else if (arg.equals("-d")) {
- delete = true;
- } else if (arg.equals("-u")) {
- update = true;
- } else if (arg.equals("-g")) {
- get = true;
- } else if (arg.equals("-f")) {
- find = true;
- productURN = "";
- } else if (arg.equals("-t")) {
- productURN = args[++count];
- } else if (arg.equals("-i")) {
- instanceURN = args[++count];
- } else if (arg.equals("-p")) {
- productName = args[++count];
- } else if (arg.equals("-e")) {
- productVersion = args[++count];
- } else if (arg.equals("-t")) {
- productURN = args[++count];
- } else if (arg.equals("-F")) {
- productParentURN = args[++count];
- } else if (arg.equals("-P")) {
- productParent = args[++count];
- } else if (arg.equals("-I")) {
- productDefinedInstanceID = args[++count];
- } else if (arg.equals("-m")) {
- productVendor = args[++count];
- } else if (arg.equals("-A")) {
- platformArch = args[++count];
- } else if (arg.equals("-z")) {
- container = args[++count];
- } else if (arg.equals("-S")) {
- source = args[++count];
- } else {
- System.err.println("Invalid option:" + arg);
- System.exit(-1);
- }
- count++;
- }
-
- if (add) {
- addServiceTag();
- } else if (delete) {
- deleteServiceTag();
- } else if (update) {
- updateServiceTag();
- } else if (get) {
- getServiceTag();
- } else if (find) {
- findServiceTags();
- } else {
- System.err.println("Error");
- System.exit(-1);
- }
- updateXmlFile();
- }
- private static String OUTPUT = "Product instance URN=";
-
- private static void addServiceTag() {
- if (instanceURN == null) {
- instanceURN = ServiceTag.generateInstanceURN();
- }
- ServiceTag st = ServiceTag.newInstance(instanceURN,
- productName,
- productVersion,
- productURN,
- productParent,
- productParentURN,
- productDefinedInstanceID,
- productVendor,
- platformArch,
- container,
- source);
- registration.addServiceTag(st);
- System.out.println(OUTPUT + st.getInstanceURN());
- }
-
- private static void deleteServiceTag() {
- registration.removeServiceTag(instanceURN);
- System.out.println("instance_urn=" + instanceURN + " deleted");
- }
-
- private static void updateServiceTag() {
- registration.updateServiceTag(instanceURN, productDefinedInstanceID);
- System.out.println("instance_urn=" + instanceURN + " updated");
- }
-
- private static void getServiceTag() {
- ServiceTag st = registration.getServiceTag(instanceURN);
- if (st == null) {
- System.err.println("instance_urn=" + instanceURN + " not found");
- System.exit(ST_ERR_REC_NOT_FOUND);
- } else {
- System.out.println(st);
- }
- }
-
- private static void findServiceTags() {
- Set<ServiceTag> set = registration.getServiceTags();
- for (ServiceTag st : set) {
- if (st.getProductURN().equals(productURN)) {
- System.out.println(st.getInstanceURN());
- }
- }
- if (set.size() == 0) {
- System.out.println("No records found");
- System.exit(ST_ERR_REC_NOT_FOUND);
- }
- }
- private static void updateXmlFile() throws IOException {
- BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(xmlFile));
- try {
- registration.storeToXML(out);
- } finally {
- out.close();
- }
- }
-}
diff --git a/test/com/sun/servicetag/SystemRegistryTest.java b/test/com/sun/servicetag/SystemRegistryTest.java
deleted file mode 100644
index 4ec459c..0000000
--- a/test/com/sun/servicetag/SystemRegistryTest.java
+++ /dev/null
@@ -1,139 +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.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for registry class
- * by replacing stclient with SvcTagClient utility
- * @author Mandy Chung
- *
- * @run build SvcTagClient SystemRegistryTest Util
- * @run main SystemRegistryTest
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class SystemRegistryTest {
- private static String registryDir = System.getProperty("test.classes");
- private static String servicetagDir = System.getProperty("test.src");
- private static List<ServiceTag> list = new ArrayList<ServiceTag>();
- private static String[] files = new String[] {
- "servicetag1.properties",
- "servicetag2.properties",
- "servicetag3.properties"
- };
-
- private static Registry registry;
- public static void main(String[] argv) throws Exception {
- try {
- registry = Util.getSvcTagClientRegistry();
- runTest();
- } finally {
- // restore empty registry file
- Util.emptyRegistryFile();
- }
- }
-
- private static void runTest() throws Exception {
- for (String filename : files) {
- File f = new File(servicetagDir, filename);
- ServiceTag svcTag = Util.newServiceTag(f);
- ServiceTag st = registry.addServiceTag(svcTag);
- list.add(st);
- System.out.println(st);
- }
-
- testDuplicate(list.get(0));
- testNotFound();
-
- // remove a service tag
- String urn = list.get(0).getInstanceURN();
- ServiceTag svcTag = registry.removeServiceTag(urn);
- if (!Util.matches(svcTag, list.get(0))) {
- throw new RuntimeException(urn +
- " deleted but does not match.");
- }
-
- // get a service tag
- svcTag = list.get(1);
- urn = svcTag.getInstanceURN();
- ServiceTag st = registry.getServiceTag(urn);
- if (!Util.matches(svcTag, st)) {
- throw new RuntimeException(urn +
- " returned from getServiceTag but does not match.");
- }
- // update the service tag
- registry.updateServiceTag(urn, "My new defined ID");
- st = registry.getServiceTag(urn);
- if (Util.matches(svcTag, st)) {
- throw new RuntimeException(urn +
- " updated but expected to be different.");
- }
-
- if (!st.getProductDefinedInstanceID().equals("My new defined ID")) {
- throw new RuntimeException("Invalid product_defined_instance_id " +
- st.getProductDefinedInstanceID());
- }
- if (st.getInstallerUID() != -1) {
- throw new RuntimeException("Invalid installer_uid " +
- st.getInstallerUID());
- }
- if (st.getTimestamp().equals(svcTag.getTimestamp())) {
- throw new RuntimeException("Timestamp " +
- st.getTimestamp() + " == " + svcTag.getTimestamp());
- }
-
- }
- private static void testDuplicate(ServiceTag st) throws IOException {
- boolean dup = false;
- try {
- registry.addServiceTag(st);
- } catch (IllegalArgumentException e) {
- dup = true;
- }
- if (!dup) {
- throw new RuntimeException(st.getInstanceURN() +
- " added successfully but expected to be a duplicated.");
- }
- }
-
- private static void testNotFound() throws Exception {
- String instanceURN = "urn:st:721cf98a-f4d7-6231-bb1d-f2f5aa903ef7";
- ServiceTag svctag = registry.removeServiceTag(instanceURN);
- if (svctag != null) {
- throw new RuntimeException(instanceURN +
- " exists but expected not found");
- }
-
- svctag = registry.updateServiceTag(instanceURN, "testing");
- if (svctag != null) {
- throw new RuntimeException(instanceURN +
- " exists but expected not found");
- }
- }
-}
diff --git a/test/com/sun/servicetag/TestLoadFromXML.java b/test/com/sun/servicetag/TestLoadFromXML.java
deleted file mode 100644
index a41d016..0000000
--- a/test/com/sun/servicetag/TestLoadFromXML.java
+++ /dev/null
@@ -1,69 +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.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for RegistrationData.loadFromXML
- * @author Mandy Chung
- *
- * @run build TestLoadFromXML
- * @run main TestLoadFromXML
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class TestLoadFromXML {
- public static void main(String[] argv) throws Exception {
- String registrationDir = System.getProperty("test.classes");
- String servicetagDir = System.getProperty("test.src");
-
- File inFile = new File(servicetagDir, "registration.xml");
- File outFile = new File(registrationDir, "out.xml");
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(inFile));
- RegistrationData regData = RegistrationData.loadFromXML(in);
- boolean closed = false;
- try {
- in.read();
- } catch (IOException e) {
- // expect the InputStream is closed
- closed = true;
- System.out.println("*** Expected IOException ***");
- e.printStackTrace();
- }
- if (!closed) {
- throw new RuntimeException("InputStream not closed after " +
- "RegistrationData.loadFromXML() call");
- }
-
- BufferedOutputStream out =
- new BufferedOutputStream(new FileOutputStream(outFile));
- regData.storeToXML(out);
- // should be able to write to the OutputStream
- out.write(0);
- }
-}
diff --git a/test/com/sun/servicetag/UpdateServiceTagTest.java b/test/com/sun/servicetag/UpdateServiceTagTest.java
deleted file mode 100644
index b564ea3..0000000
--- a/test/com/sun/servicetag/UpdateServiceTagTest.java
+++ /dev/null
@@ -1,109 +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.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for RegistrationData.updateServiceTag
- * @author Mandy Chung
- *
- * @run build UpdateServiceTagTest Util
- * @run main UpdateServiceTagTest
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class UpdateServiceTagTest {
- private static String servicetagDir = System.getProperty("test.src");
- private static String[] files = new String[] {
- "servicetag1.properties",
- "servicetag2.properties",
- "servicetag3.properties"
- };
- private static RegistrationData registration = new RegistrationData();
- private static Set<ServiceTag> set = new HashSet<ServiceTag>();
-
- public static void main(String[] argv) throws Exception {
- for (String f : files) {
- ServiceTag st = addServiceTag(f);
- set.add(st);
- }
- Thread.sleep(1000);
- for (ServiceTag st : set) {
- updateServiceTag(st);
- }
- }
-
- private static ServiceTag addServiceTag(String filename) throws Exception {
- File f = new File(servicetagDir, filename);
- ServiceTag svcTag = Util.newServiceTag(f, true /* no instance_urn */);
- ServiceTag st = registration.addServiceTag(svcTag);
- if (!Util.matchesNoInstanceUrn(svcTag, st)) {
- throw new RuntimeException("ServiceTag " +
- " doesn't match.");
- }
- String urn = st.getInstanceURN();
- if (!urn.startsWith("urn:st:")) {
- throw new RuntimeException("Invalid generated instance_urn " +
- urn);
- }
- if (st.getInstallerUID() != -1) {
- throw new RuntimeException("Invalid installer_uid " +
- st.getInstallerUID());
- }
- if (st.getTimestamp() == null) {
- throw new RuntimeException("null timestamp ");
- }
- return st;
- }
-
- private static String newID = "New product defined instance ID";
- private static void updateServiceTag(ServiceTag svcTag) throws Exception {
- // update the service tag
- String urn = svcTag.getInstanceURN();
- registration.updateServiceTag(urn, newID);
-
- // get the updated service tag
- ServiceTag st = registration.getServiceTag(urn);
- if (Util.matches(svcTag, st)) {
- throw new RuntimeException("ServiceTag " +
- " should not match.");
- }
- if (!st.getProductDefinedInstanceID().equals(newID)) {
- throw new RuntimeException("Invalid product_defined_instance_id " +
- st.getProductDefinedInstanceID());
- }
- if (st.getInstallerUID() != -1) {
- throw new RuntimeException("Invalid installer_uid " +
- st.getInstallerUID());
- }
- if (st.getTimestamp().equals(svcTag.getTimestamp())) {
- throw new RuntimeException("Timestamp " +
- st.getTimestamp() + " == " + svcTag.getTimestamp());
- }
- }
-}
diff --git a/test/com/sun/servicetag/Util.java b/test/com/sun/servicetag/Util.java
deleted file mode 100644
index d0d3301..0000000
--- a/test/com/sun/servicetag/Util.java
+++ /dev/null
@@ -1,265 +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.
- */
-
-/*
- * @bug 6622366
- * @summary Utility class used by other jtreg tests
- */
-
-import com.sun.servicetag.RegistrationData;
-import com.sun.servicetag.ServiceTag;
-import com.sun.servicetag.Registry;
-
-import java.util.Set;
-import java.util.Date;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TimeZone;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.io.*;
-
-public class Util {
- public static ServiceTag newServiceTag(File f)
- throws FileNotFoundException, IOException, NumberFormatException {
- return newServiceTag(f, false /* with instance_urn */);
- }
-
- public static ServiceTag newServiceTag(File f, boolean noInstanceURN)
- throws FileNotFoundException, IOException, NumberFormatException {
- Properties props = new Properties();
- FileReader reader = new FileReader(f);
- try {
- props.load(reader);
- } finally {
- reader.close();
- }
- if (noInstanceURN) {
- return ServiceTag.newInstance(
- props.getProperty("product_name"),
- props.getProperty("product_version"),
- props.getProperty("product_urn"),
- props.getProperty("product_parent"),
- props.getProperty("product_parent_urn"),
- props.getProperty("product_defined_inst_id"),
- props.getProperty("product_vendor"),
- props.getProperty("platform_arch"),
- props.getProperty("container"),
- props.getProperty("source"));
- } else {
- return ServiceTag.newInstance(
- props.getProperty("instance_urn"),
- props.getProperty("product_name"),
- props.getProperty("product_version"),
- props.getProperty("product_urn"),
- props.getProperty("product_parent"),
- props.getProperty("product_parent_urn"),
- props.getProperty("product_defined_inst_id"),
- props.getProperty("product_vendor"),
- props.getProperty("platform_arch"),
- props.getProperty("container"),
- props.getProperty("source"));
- }
- }
-
- public static boolean matches(ServiceTag st1, ServiceTag st2) {
- if (!st1.getInstanceURN().equals(st2.getInstanceURN())) {
- System.out.println("instance_urn: " + st1.getInstanceURN() +
- " != " + st2.getInstanceURN());
- return false;
- }
- return matchesNoInstanceUrn(st1, st2);
- }
-
- public static boolean matchesNoInstanceUrn(ServiceTag st1, ServiceTag st2) {
- if (!st1.getProductName().equals(st2.getProductName())) {
- System.out.println("product_name: " + st1.getProductName() +
- " != " + st2.getProductName());
- return false;
- }
-
- if (!st1.getProductVersion().equals(st2.getProductVersion())) {
- System.out.println("product_version: " + st1.getProductVersion() +
- " != " + st2.getProductVersion());
- return false;
- }
- if (!st1.getProductURN().equals(st2.getProductURN())) {
- System.out.println("product_urn: " + st1.getProductURN() +
- " != " + st2.getProductURN());
- return false;
- }
- if (!st1.getProductParentURN().equals(st2.getProductParentURN())) {
- System.out.println("product_parent_urn: " + st1.getProductParentURN() +
- " != " + st2.getProductParentURN());
- return false;
- }
- if (!st1.getProductParent().equals(st2.getProductParent())) {
- System.out.println("product_parent: " + st1.getProductParent() +
- " != " + st2.getProductParent());
- return false;
- }
- if (!st1.getProductDefinedInstanceID().equals(st2.getProductDefinedInstanceID())) {
- System.out.println("product_defined_inst_id: " +
- st1.getProductDefinedInstanceID() +
- " != " + st2.getProductDefinedInstanceID());
- return false;
- }
- if (!st1.getProductVendor().equals(st2.getProductVendor())) {
- System.out.println("product_vendor: " + st1.getProductVendor() +
- " != " + st2.getProductVendor());
- return false;
- }
- if (!st1.getPlatformArch().equals(st2.getPlatformArch())) {
- System.out.println("platform_arch: " + st1.getPlatformArch() +
- " != " + st2.getPlatformArch());
- return false;
- }
- if (!st1.getContainer().equals(st2.getContainer())) {
- System.out.println("container: " + st1.getContainer() +
- " != " + st2.getContainer());
- return false;
- }
- if (!st1.getSource().equals(st2.getSource())) {
- System.out.println("source: " + st1.getSource() +
- " != " + st2.getSource());
- return false;
- }
- return true;
- }
-
- public static void checkRegistrationData(String regFile,
- Map<String, ServiceTag> stMap)
- throws IOException {
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(regFile));
- RegistrationData registration = RegistrationData.loadFromXML(in);
- Set<ServiceTag> svcTags = registration.getServiceTags();
- if (svcTags.size() != stMap.size()) {
- throw new RuntimeException("Invalid service tag count= " +
- svcTags.size() + " expected=" + stMap.size());
- }
- for (ServiceTag st : svcTags) {
- ServiceTag st1 = stMap.get(st.getInstanceURN());
- if (!matches(st, st1)) {
- System.err.println(st);
- System.err.println(st1);
- throw new RuntimeException("ServiceTag in the registry " +
- "does not match the one in the map");
- }
- }
- }
-
-
- /**
- * 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) {
- 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();
- }
- }
-
- /**
- * Returns the command simulating stclient behavior.
- */
- static String getSvcClientCommand(String stclientRegistry) {
- String regDir = System.getProperty("test.classes");
-
- StringBuilder sb = new StringBuilder();
- // wrap each argument to the command with double quotes
- sb.append("\"");
- sb.append(System.getProperty("java.home"));
- sb.append(File.separator).append("bin");
- sb.append(File.separator).append("java");
- sb.append("\"");
- sb.append(" -cp ");
- sb.append("\"").append(regDir).append("\"");
- sb.append(" \"-Dstclient.registry.path=");
- sb.append(stclientRegistry).append("\"");
- sb.append(" SvcTagClient");
- return sb.toString();
- }
-
- private static Registry registry = null;
- private static File registryFile = null;
- /**
- * Returns the Registry processed by SvcTagClient that simulates
- * stclient.
- */
- static synchronized Registry getSvcTagClientRegistry() throws IOException {
- String regDir = System.getProperty("test.classes");
- File f = new File(regDir, "registry.xml");
- if (registry != null) {
- if (!f.equals(registryFile) && f.length() != 0) {
- throw new AssertionError("Has to be empty registry.xml to run in samevm");
- }
- return registry;
- }
-
- // System.setProperty("servicetag.verbose", "true");
- // enable the helper class
- System.setProperty("servicetag.sthelper.supported", "true");
- registryFile = f;
-
- String stclientCmd = Util.getSvcClientCommand(registryFile.getCanonicalPath());
- System.out.println("stclient cmd: " + stclientCmd);
- System.setProperty("servicetag.stclient.cmd", stclientCmd);
-
- // get the Registry object after the system properties are set
- registry = Registry.getSystemRegistry();
- return registry;
- }
-
- static void emptyRegistryFile() throws IOException {
- if (registryFile.exists()) {
- BufferedOutputStream out = new BufferedOutputStream(
- new FileOutputStream(registryFile));
- try {
- RegistrationData data = new RegistrationData();
- data.storeToXML(out);
- } finally {
- out.close();
- }
- }
- }
-}
diff --git a/test/com/sun/servicetag/ValidRegistrationData.java b/test/com/sun/servicetag/ValidRegistrationData.java
deleted file mode 100644
index affcb8c..0000000
--- a/test/com/sun/servicetag/ValidRegistrationData.java
+++ /dev/null
@@ -1,112 +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.
- */
-
-/*
- * @test
- * @bug 6622366
- * @summary Basic Test for reading a valid registration
- * @author Mandy Chung
- *
- * @run build ValidRegistrationData
- * @run main ValidRegistrationData
- */
-
-import com.sun.servicetag.*;
-import java.io.*;
-import java.util.*;
-
-public class ValidRegistrationData {
- private static String registrationDir = System.getProperty("test.classes");
- private static String servicetagDir = System.getProperty("test.src");
- private static RegistrationData registration;
- private static Map<String, ServiceTag> stMap =
- new LinkedHashMap<String, ServiceTag>();
- private static String[] files = new String[] {
- "servicetag1.properties",
- "servicetag2.properties",
- "servicetag3.properties"
- };
- private static String URN = "urn:st:9543ffaa-a4f1-4f77-b2d1-f561922d4e4a";
-
- public static void main(String[] argv) throws Exception {
- File f = new File(servicetagDir, "registration.xml");
-
- // load the registration data with all service tags
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
- registration = RegistrationData.loadFromXML(in);
- if (!registration.getRegistrationURN().equals(URN)){
- throw new RuntimeException("Invalid URN=" +
- registration.getRegistrationURN());
- }
- Map<String,String> environMap = registration.getEnvironmentMap();
- checkEnvironmentMap(environMap);
-
- // set environment
- setInvalidEnvironment("hostname", "");
- setInvalidEnvironment("osName", "");
- setInvalidEnvironment("invalid", "");
- }
-
- private static void checkEnvironmentMap(Map<String,String> envMap)
- throws Exception {
- Properties props = new Properties();
- File f = new File(servicetagDir, "environ.properties");
- FileReader reader = new FileReader(f);
- try {
- props.load(reader);
- } finally {
- reader.close();
- }
- for (Map.Entry<String,String> entry : envMap.entrySet()) {
- String name = entry.getKey();
- String value = entry.getValue();
- String expected = props.getProperty(name);
- if (expected == null || !value.equals(expected)) {
- throw new RuntimeException("Invalid environment " +
- name + "=" + value);
- }
- props.remove(name);
- }
- if (!props.isEmpty()) {
- System.out.println("Environment missing: ");
- for (String s : props.stringPropertyNames()) {
- System.out.println(" " + s + "=" + props.getProperty(s));
- }
- throw new RuntimeException("Invalid environment read");
- }
- }
- private static void setInvalidEnvironment(String name, String value) {
- boolean invalid = false;
- try {
- registration.setEnvironment(name, value);
- } catch (IllegalArgumentException e) {
- invalid = true;
- }
- if (!invalid) {
- throw new RuntimeException(name + "=" + value +
- " set but expected to fail.");
- }
- }
-}
diff --git a/test/com/sun/servicetag/environ.properties b/test/com/sun/servicetag/environ.properties
deleted file mode 100644
index 22163e5..0000000
--- a/test/com/sun/servicetag/environ.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-hostname=ko
-hostId=83abc1ab
-osName=SunOS
-osVersion=5.10
-osArchitecture=sparc
-systemModel=Sun-Fire-V440
-systemManufacturer=Oracle Corporation
-cpuManufacturer=Oracle Corporation
-serialNumber=BEL078932
diff --git a/test/com/sun/servicetag/missing-environ-field.xml b/test/com/sun/servicetag/missing-environ-field.xml
deleted file mode 100644
index 775bbaa..0000000
--- a/test/com/sun/servicetag/missing-environ-field.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<registration_data version="1.0">
-<environment>
-<hostname>ko</hostname>
-<hostId/>
-<osName>SunOS</osName>
-<osVersion>5.10</osVersion>
-<osArchitecture>sparc</osArchitecture>
-<systemModel/>
-<systemManufacturer/>
-<cpuManufacturer/>
-</environment>
-<registry urn="urn:st:9b2c801f-89d5-431e-a930-1335a9049124" version="1.0">
-<service_tag>
-<instance_urn>urn:st:9efff93a-767c-4714-fcfa-c48988293110</instance_urn>
-<product_name>Java SE 6 Runtime Environment</product_name>
-<product_version>1.6.0-internal</product_version>
-<product_urn>urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc</product_urn>
-<product_parent_urn>urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3</product_parent_urn>
-<product_parent>Java Platform Standard Edition 6 (Java SE 6)</product_parent>
-<product_defined_inst_id>id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc</product_defined_inst_id>
-<product_vendor>Oracle Corporation</product_vendor>
-<platform_arch>sparc</platform_arch>
-<timestamp>2007-11-12 06:15:11 GMT</timestamp>
-<container>global</container>
-<source>servicetag1.properties</source>
-<installer_uid>121937</installer_uid>
-</service_tag>
-<service_tag>
-<instance_urn>urn:st:0e9712bf-4832-e315-8e40-c4b17ffac9a9</instance_urn>
-<product_name>Java SE 6 Development Kit</product_name>
-<product_version>1.6.0</product_version>
-<product_urn>urn:uuid:b58ef9a8-5ae8-11db-a023-080020a9ed93</product_urn>
-<product_parent_urn>urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3</product_parent_urn>
-<product_parent>Java Platform Standard Edition 6 (Java SE 6)</product_parent>
-<product_defined_inst_id>id=1.6.0_05-b01 sparc,dir=/myjdk/solaris-i586</product_defined_inst_id>
-<product_vendor>Oracle Corporation</product_vendor>
-<platform_arch>i386</platform_arch>
-<timestamp>2007-11-12 06:15:11 GMT</timestamp>
-<container>global</container>
-<source>servicetag2.properties</source>
-<installer_uid>121937</installer_uid>
-</service_tag>
-</registry>
-</registration_data>
diff --git a/test/com/sun/servicetag/newer-registry-version.xml b/test/com/sun/servicetag/newer-registry-version.xml
deleted file mode 100644
index fe9fdf3..0000000
--- a/test/com/sun/servicetag/newer-registry-version.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<registration_data version="1.0">
-<environment>
-<hostname>ko</hostname>
-<hostId/>
-<osName>SunOS</osName>
-<osVersion>5.10</osVersion>
-<osArchitecture>sparc</osArchitecture>
-<systemModel/>
-<systemManufacturer/>
-<cpuManufacturer/>
-<serialNumber/>
-</environment>
-<registry urn="urn:st:9543ffaa-a4f1-4f77-b2d1-f561922d4e4a" version="100.0">
-<service_tag>
-<instance_urn>urn:st:9efff93a-767c-4714-fcfa-c48988293110</instance_urn>
-<product_name>Java SE 6 Runtime Environment</product_name>
-<product_version>1.6.0-internal</product_version>
-<product_urn>urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc</product_urn>
-<product_parent_urn>urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3</product_parent_urn>
-<product_parent>Java Platform Standard Edition 6 (Java SE 6)</product_parent>
-<product_defined_inst_id>id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc</product_defined_inst_id>
-<product_vendor>Oracle Corporation</product_vendor>
-<platform_arch>sparc</platform_arch>
-<timestamp>2007-11-13 00:49:01 GMT</timestamp>
-<container>global</container>
-<source>servicetag1.properties</source>
-<installer_uid>121937</installer_uid>
-<NEW-FIELD/>
-</service_tag>
-</registry>
-</registration_data>
diff --git a/test/com/sun/servicetag/registration.xml b/test/com/sun/servicetag/registration.xml
deleted file mode 100644
index 287590a..0000000
--- a/test/com/sun/servicetag/registration.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<registration_data version="1.0">
-<environment>
-<hostname>ko</hostname>
-<hostId>83abc1ab</hostId>
-<osName>SunOS</osName>
-<osVersion>5.10</osVersion>
-<osArchitecture>sparc</osArchitecture>
-<systemModel>Sun-Fire-V440</systemModel>
-<systemManufacturer>Oracle Corporation</systemManufacturer>
-<cpuManufacturer>Oracle Corporation</cpuManufacturer>
-<serialNumber>BEL078932</serialNumber>
-</environment>
-<registry urn="urn:st:9543ffaa-a4f1-4f77-b2d1-f561922d4e4a" version="1.0">
-<service_tag>
-<instance_urn>urn:st:9efff93a-767c-4714-fcfa-c48988293110</instance_urn>
-<product_name>Java SE 6 Runtime Environment</product_name>
-<product_version>1.6.0-internal</product_version>
-<product_urn>urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc</product_urn>
-<product_parent_urn>urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3</product_parent_urn>
-<product_parent>Java Platform Standard Edition 6 (Java SE 6)</product_parent>
-<product_defined_inst_id>id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc</product_defined_inst_id>
-<product_vendor>Oracle Corporation</product_vendor>
-<platform_arch>sparc</platform_arch>
-<timestamp>2007-11-13 00:49:01 GMT</timestamp>
-<container>global</container>
-<source>servicetag1.properties</source>
-<installer_uid>121937</installer_uid>
-</service_tag>
-<service_tag>
-<instance_urn>urn:st:0e9712bf-4832-e315-8e40-c4b17ffac9a9</instance_urn>
-<product_name>Java SE 6 Development Kit</product_name>
-<product_version>1.6.0</product_version>
-<product_urn>urn:uuid:b58ef9a8-5ae8-11db-a023-080020a9ed93</product_urn>
-<product_parent_urn>urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3</product_parent_urn>
-<product_parent>Java Platform Standard Edition 6 (Java SE 6)</product_parent>
-<product_defined_inst_id>id=1.6.0_05-b01 i386,dir=/myjdk/solaris-i586</product_defined_inst_id>
-<product_vendor>Oracle Corporation</product_vendor>
-<platform_arch>i386</platform_arch>
-<timestamp>2007-11-13 00:49:01 GMT</timestamp>
-<container>global</container>
-<source>servicetag2.properties</source>
-<installer_uid>121937</installer_uid>
-</service_tag>
-<service_tag>
-<instance_urn>urn:st:8a6ff75e-21a4-c8d7-bbda-de2c971bd67d</instance_urn>
-<product_name>Solaris 10 Operating System</product_name>
-<product_version>10</product_version>
-<product_urn>urn:uuid:5005588c-36f3-11d6-9cec-fc96f718e113</product_urn>
-<product_parent_urn>urn:uuid:596ffcfa-63d5-11d7-9886-ac816a682f92</product_parent_urn>
-<product_parent>Solaris Operating System</product_parent>
-<product_defined_inst_id/>
-<product_vendor>Oracle Corporation</product_vendor>
-<platform_arch>sparc</platform_arch>
-<timestamp>2007-11-13 00:49:01 GMT</timestamp>
-<container>global</container>
-<source>servicetag3.properties</source>
-<installer_uid>212883</installer_uid>
-</service_tag>
-</registry>
-</registration_data>
diff --git a/test/com/sun/servicetag/servicetag1.properties b/test/com/sun/servicetag/servicetag1.properties
deleted file mode 100644
index c37bc36..0000000
--- a/test/com/sun/servicetag/servicetag1.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-instance_urn=urn:st:9efff93a-767c-4714-fcfa-c48988293110
-product_name=Java SE 6 Runtime Environment
-product_version=1.6.0-internal
-product_urn=urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc
-product_parent_urn=urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
-product_parent=Java Platform Standard Edition 6 (Java SE 6)
-product_defined_inst_id=id=1.6.0-internal-b00 sparc,dir=/myjdk/solaris-sparc
-product_vendor=Oracle Corporation
-platform_arch=sparc
-timestamp=2007-11-12 05:19:40 GMT
-container=global
-source=servicetag1.properties
-installer_uid=121937
diff --git a/test/com/sun/servicetag/servicetag2.properties b/test/com/sun/servicetag/servicetag2.properties
deleted file mode 100644
index 54867f7..0000000
--- a/test/com/sun/servicetag/servicetag2.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-instance_urn=urn:st:0e9712bf-4832-e315-8e40-c4b17ffac9a9
-product_name=Java SE 6 Development Kit
-product_version=1.6.0
-product_urn=urn:uuid:b58ef9a8-5ae8-11db-a023-080020a9ed93
-product_parent_urn=urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
-product_parent=Java Platform Standard Edition 6 (Java SE 6)
-product_defined_inst_id=id=1.6.0_05-b01 i386,dir=/myjdk/solaris-i586
-product_vendor=Oracle Corporation
-platform_arch=i386
-timestamp=2007-11-12 06:12:21 GMT
-container=global
-source=servicetag2.properties
-installer_uid=121937
diff --git a/test/com/sun/servicetag/servicetag3.properties b/test/com/sun/servicetag/servicetag3.properties
deleted file mode 100644
index 5bd4e47..0000000
--- a/test/com/sun/servicetag/servicetag3.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-instance_urn=urn:st:8a6ff75e-21a4-c8d7-bbda-de2c971bd67d
-product_name=Solaris 10 Operating System
-product_version=10
-product_urn=urn:uuid:5005588c-36f3-11d6-9cec-fc96f718e113
-product_parent_urn=urn:uuid:596ffcfa-63d5-11d7-9886-ac816a682f92
-product_parent=Solaris Operating System
-product_defined_inst_id=
-product_vendor=Oracle Corporation
-platform_arch=sparc
-timestamp=2007-06-20 22:07:11 GMT
-container=global
-source=servicetag3.properties
-installer_uid=212883
diff --git a/test/com/sun/servicetag/servicetag4.properties b/test/com/sun/servicetag/servicetag4.properties
deleted file mode 100644
index 0289204..0000000
--- a/test/com/sun/servicetag/servicetag4.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-instance_urn=urn:st:b8171b45-a087-47b3-92c8-f2d9fb34e8c2
-product_name=Java SE 6 Runtime Environment
-product_version=1.6.0_05
-product_urn=urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc
-product_parent_urn=urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
-product_parent=Java Platform Standard Edition 6 (Java SE 6)
-product_defined_inst_id=id=1.6.0_05-b01 amd64,dir=/myjdk/linux-amd64
-product_vendor=Oracle Corporation
-platform_arch=x64
-timestamp=2007-12-12 05:19:40 GMT
-container=global
-source=servicetag4.properties
-installer_uid=121937
diff --git a/test/com/sun/servicetag/servicetag5.properties b/test/com/sun/servicetag/servicetag5.properties
deleted file mode 100644
index f7e53bf..0000000
--- a/test/com/sun/servicetag/servicetag5.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-instance_urn=urn:st:1d4269a1-71e3-4e44-bc8f-3793da7928ed
-product_name=Java SE 6 Runtime Environment
-product_version=1.6.0_06
-product_urn=urn:uuid:92d1de8c-1e59-42c6-a280-1c379526bcbc
-product_parent_urn=urn:uuid:fdc90b21-018d-4cab-b866-612c7c119ed3
-product_parent=Java Platform Standard Edition 6 (Java SE 6)
-product_defined_inst_id=id=1.6.0_06-b06 i386,dir=/w/mchung/bundles/jdk1.6.0_05/jre
-product_vendor=Oracle Corporation
-platform_arch=x86
-timestamp=2007-11-29 17:59:42 GMT
-container=global
-source=servicetag5.properties
-installer_uid=-1
diff --git a/test/java/awt/Desktop/OpenByUNCPathNameTest/OpenByUNCPathNameTest.java b/test/java/awt/Desktop/OpenByUNCPathNameTest/OpenByUNCPathNameTest.java
new file mode 100644
index 0000000..052f36f
--- /dev/null
+++ b/test/java/awt/Desktop/OpenByUNCPathNameTest/OpenByUNCPathNameTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ @bug 6550588
+ @summary java.awt.Desktop cannot open file with Windows UNC filename
+ @author Anton Litvinov
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+
+public class OpenByUNCPathNameTest {
+ private static boolean validatePlatform() {
+ String osName = System.getProperty("os.name");
+ if (osName == null) {
+ throw new RuntimeException("Name of the current OS could not be retrieved.");
+ }
+ return osName.startsWith("Windows");
+ }
+
+ private static void openFile() throws IOException {
+ if (!Desktop.isDesktopSupported()) {
+ System.out.println("java.awt.Desktop is not supported on this platform.");
+ } else {
+ Desktop desktop = Desktop.getDesktop();
+ File file = File.createTempFile("Read Me File", ".txt");
+ try {
+ // Test opening of the file with Windows local file path.
+ desktop.open(file);
+ Robot robot = null;
+ try {
+ Thread.sleep(5000);
+ robot = new Robot();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ pressAltF4Keys(robot);
+
+ // Test opening of the file with Windows UNC pathname.
+ String uncFilePath = "\\\\127.0.0.1\\" + file.getAbsolutePath().replace(':', '$');
+ File uncFile = new File(uncFilePath);
+ if (!uncFile.exists()) {
+ throw new RuntimeException(String.format(
+ "File with UNC pathname '%s' does not exist.", uncFilePath));
+ }
+ desktop.open(uncFile);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ pressAltF4Keys(robot);
+ } finally {
+ file.delete();
+ }
+ }
+ }
+
+ private static void pressAltF4Keys(Robot robot) {
+ if (robot != null) {
+ robot.keyPress(KeyEvent.VK_ALT);
+ robot.keyPress(KeyEvent.VK_F4);
+ robot.delay(50);
+ robot.keyRelease(KeyEvent.VK_F4);
+ robot.keyRelease(KeyEvent.VK_ALT);
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ if (!validatePlatform()) {
+ System.out.println("This test is only for MS Windows OS.");
+ } else {
+ openFile();
+ }
+ }
+}
diff --git a/test/java/awt/GraphicsDevice/CheckDisplayModes.java b/test/java/awt/GraphicsDevice/CheckDisplayModes.java
new file mode 100644
index 0000000..bc8d8a5
--- /dev/null
+++ b/test/java/awt/GraphicsDevice/CheckDisplayModes.java
@@ -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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8007146
+ * @summary [macosx] Setting a display mode crashes JDK under VNC
+ * @author Alexander Scherbatiy
+ * @run main CheckDisplayModes
+ */
+import java.awt.DisplayMode;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+
+public class CheckDisplayModes {
+
+ public static void main(String[] args) {
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsDevice graphicDevice = ge.getDefaultScreenDevice();
+ DisplayMode defaultDisplayMode = graphicDevice.getDisplayMode();
+ checkDisplayMode(defaultDisplayMode);
+ graphicDevice.setDisplayMode(defaultDisplayMode);
+
+ DisplayMode[] displayModes = graphicDevice.getDisplayModes();
+ boolean isDefaultDisplayModeIncluded = false;
+ for (DisplayMode displayMode : displayModes) {
+ checkDisplayMode(displayMode);
+ graphicDevice.setDisplayMode(displayMode);
+ if (defaultDisplayMode.equals(displayMode)) {
+ isDefaultDisplayModeIncluded = true;
+ }
+ }
+
+ if (!isDefaultDisplayModeIncluded) {
+ throw new RuntimeException("Default display mode is not included");
+ }
+ }
+
+ static void checkDisplayMode(DisplayMode displayMode) {
+ if (displayMode == null || displayMode.getWidth() <= 1 || displayMode.getHeight() <= 1) {
+ throw new RuntimeException("invalid display mode");
+ }
+ }
+}
diff --git a/test/java/beans/Introspector/TestTypeResolver.java b/test/java/beans/Introspector/TestTypeResolver.java
index e691519..1b4535f 100644
--- a/test/java/beans/Introspector/TestTypeResolver.java
+++ b/test/java/beans/Introspector/TestTypeResolver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -30,6 +30,7 @@
import com.sun.beans.TypeResolver;
import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Field;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Method;
@@ -199,6 +200,19 @@
public Annotation[] getDeclaredAnnotations() {
return null; // not used
}
+
+ public AnnotatedType[] getAnnotatedBounds() {
+ return null; // not used
+ }
+
+ public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
+ return null; // not used
+ }
+
+ public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
+ return null; // not used
+ }
+
}
private static class ClassTypeVariable extends TypeVariableImpl<Class<?>> {
diff --git a/test/java/io/FileInputStream/NegativeAvailable.java b/test/java/io/FileInputStream/NegativeAvailable.java
new file mode 100644
index 0000000..a4dedbc
--- /dev/null
+++ b/test/java/io/FileInputStream/NegativeAvailable.java
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8010837
+ * @summary Test if available returns correct value when skipping beyond
+ * the end of a file.
+ * @author Dan Xu
+ */
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class NegativeAvailable {
+
+ public static void main(String[] args) throws IOException {
+ final int SIZE = 10;
+ final int SKIP = 5;
+
+ // Create a temporary file with size of 10 bytes.
+ Path tmp = Files.createTempFile(null, null);
+ try (BufferedWriter writer =
+ Files.newBufferedWriter(tmp, Charset.defaultCharset())) {
+ for (int i = 0; i < SIZE; i++) {
+ writer.write('1');
+ }
+ }
+
+ File tempFile = tmp.toFile();
+ try (FileInputStream fis = new FileInputStream(tempFile)) {
+ if (tempFile.length() != SIZE) {
+ throw new RuntimeException("unexpected file size = "
+ + tempFile.length());
+ }
+ long space = skipBytes(fis, SKIP, SIZE);
+ space = skipBytes(fis, SKIP, space);
+ space = skipBytes(fis, SKIP, space);
+ space = skipBytes(fis, SKIP, space);
+ }
+ Files.deleteIfExists(tmp);
+ }
+
+ /**
+ * Skip toSkip number of bytes and return the remaining bytes of the file.
+ */
+ private static long skipBytes(FileInputStream fis, int toSkip, long space)
+ throws IOException {
+ long skip = fis.skip(toSkip);
+ if (skip != toSkip) {
+ throw new RuntimeException("skip() returns " + skip
+ + " but expected " + toSkip);
+ }
+ long remaining = space - toSkip;
+ int avail = fis.available();
+ if (avail != remaining) {
+ throw new RuntimeException("available() returns " + avail
+ + " but expected " + remaining);
+ }
+
+ System.out.println("Skipped " + skip + " bytes "
+ + " available() returns " + avail);
+ return remaining;
+ }
+}
diff --git a/test/java/lang/Class/GenericStringTest.java b/test/java/lang/Class/GenericStringTest.java
new file mode 100644
index 0000000..cdd8c1a
--- /dev/null
+++ b/test/java/lang/Class/GenericStringTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6298888 6992705
+ * @summary Check Class.toGenericString()
+ * @author Joseph D. Darcy
+ */
+
+import java.lang.reflect.*;
+import java.lang.annotation.*;
+import java.util.*;
+
+@ExpectedGenericString("public class GenericStringTest")
+public class GenericStringTest {
+ public static void main(String... args){
+ int failures = 0;
+
+ failures += checkToGenericString(int.class, "int");
+
+ Class<?>[] types = {
+ GenericStringTest.class,
+ AnInterface.class,
+ LocalMap.class,
+ AnEnum.class,
+ AnotherEnum.class,
+ };
+
+ for(Class<?> clazz : types) {
+ failures += checkToGenericString(clazz, clazz.getAnnotation(ExpectedGenericString.class).value());
+ }
+
+ if (failures > 0) {
+ throw new RuntimeException();
+ }
+ }
+
+ private static int checkToGenericString(Class<?> clazz, String expected) {
+ String genericString = clazz.toGenericString();
+ if (!genericString.equals(expected)) {
+ System.err.printf("Unexpected Class.toGenericString output; expected '%s', got '%s'.%n",
+ expected,
+ genericString);
+ return 1;
+ } else
+ return 0;
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface ExpectedGenericString {
+ String value();
+}
+
+@ExpectedGenericString("abstract interface AnInterface")
+strictfp interface AnInterface {}
+
+@ExpectedGenericString("abstract interface LocalMap<K,V>")
+interface LocalMap<K,V> {}
+
+@ExpectedGenericString("final enum AnEnum")
+enum AnEnum {
+ FOO;
+}
+
+@ExpectedGenericString("enum AnotherEnum")
+enum AnotherEnum {
+ BAR{};
+}
diff --git a/test/java/lang/Runtime/exec/WinCommand.java b/test/java/lang/Runtime/exec/WinCommand.java
index a812bff..6d34a1e 100644
--- a/test/java/lang/Runtime/exec/WinCommand.java
+++ b/test/java/lang/Runtime/exec/WinCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -135,19 +135,24 @@
// Win9x systems don't have a cmd.exe
if (new File(systemDirW, "cmd.exe").exists()) {
- out.println("Running cmd.exe tests...");
- writeFile("cdcmd.cmd", "@echo off\r\nCD\r\n");
- writeFile("cdbat.bat", "@echo off\r\nCD\r\n");
- checkCD("cmd",
- "cmd.exe",
- systemDirW + "\\cmd.exe",
- // Only the ".exe" extension can be omitted
- systemDirW + "\\cmd",
- systemDirM + "/cmd.exe",
- systemDirM + "/cmd",
- "/" + systemDirM + "/cmd",
- "cdcmd.cmd", "./cdcmd.cmd", ".\\cdcmd.cmd",
- "cdbat.bat", "./cdbat.bat", ".\\cdbat.bat");
+ try {
+ out.println("Running cmd.exe tests...");
+ writeFile("cdcmd.cmd", "@echo off\r\nCD\r\n");
+ writeFile("cdbat.bat", "@echo off\r\nCD\r\n");
+ checkCD("cmd",
+ "cmd.exe",
+ systemDirW + "\\cmd.exe",
+ // Only the ".exe" extension can be omitted
+ systemDirW + "\\cmd",
+ systemDirM + "/cmd.exe",
+ systemDirM + "/cmd",
+ "/" + systemDirM + "/cmd",
+ "cdcmd.cmd", "./cdcmd.cmd", ".\\cdcmd.cmd",
+ "cdbat.bat", "./cdbat.bat", ".\\cdbat.bat");
+ } finally {
+ new File("cdcmd.cmd").delete();
+ new File("cdbat.bat").delete();
+ }
}
// 16-bit apps like command.com must have a console;
diff --git a/test/java/lang/StringBuilder/Supplementary.java b/test/java/lang/StringBuilder/Supplementary.java
index 30ff5e9..f5af9a0 100644
--- a/test/java/lang/StringBuilder/Supplementary.java
+++ b/test/java/lang/StringBuilder/Supplementary.java
@@ -37,6 +37,7 @@
test4(); // Test for appendCodePoint(int codePoint)
test5(); // Test for codePointCount(int beginIndex, int endIndex)
test6(); // Test for offsetByCodePoints(int index, int offset)
+ testDontReadOutOfBoundsTrailingSurrogate();
}
/* Text strings which are used as input data.
@@ -305,6 +306,19 @@
}
}
+ static void testDontReadOutOfBoundsTrailingSurrogate() {
+ StringBuilder sb = new StringBuilder();
+ int suppl = Character.MIN_SUPPLEMENTARY_CODE_POINT;
+ sb.appendCodePoint(suppl);
+ check(sb.codePointAt(0) != (int) suppl,
+ "codePointAt(0)", sb.codePointAt(0), suppl);
+ check(sb.length() != 2, "sb.length()");
+ sb.setLength(1);
+ check(sb.length() != 1, "sb.length()");
+ check(sb.codePointAt(0) != Character.highSurrogate(suppl),
+ "codePointAt(0)",
+ sb.codePointAt(0), Character.highSurrogate(suppl));
+ }
static final boolean At = true, Before = false;
diff --git a/test/java/lang/invoke/8009222/Test8009222.java b/test/java/lang/invoke/8009222/Test8009222.java
new file mode 100644
index 0000000..212e09a
--- /dev/null
+++ b/test/java/lang/invoke/8009222/Test8009222.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8009222
+ * @summary java.lang.IllegalArgumentException: not invocable, no method type
+ * when attempting to get getter method handle for a static field
+ *
+ * @run main/othervm Test8009222
+ */
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+
+interface Intf {
+ static int i = 0;
+}
+
+public class Test8009222 {
+ public static void main(String[] args) throws Exception {
+ MethodHandles.lookup()
+ .findStaticGetter(Intf.class, "i", int.class)
+ .getClass(); // null check
+
+ System.out.println("TEST PASSED");
+ }
+}
diff --git a/test/java/lang/reflect/Method/DefaultMethodModeling.java b/test/java/lang/reflect/Method/DefaultMethodModeling.java
new file mode 100644
index 0000000..f05dd02
--- /dev/null
+++ b/test/java/lang/reflect/Method/DefaultMethodModeling.java
@@ -0,0 +1,224 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8011590
+ * @summary Check modeling of default methods
+ * @author Joseph D. Darcy
+ */
+
+import java.util.Objects;
+import java.lang.reflect.*;
+import java.lang.annotation.*;
+
+import static java.lang.reflect.Modifier.*;
+
+public class DefaultMethodModeling {
+ public static void main(String... args) {
+ int failures = 0;
+
+ Class<?>[] classes = {SuperC.class, SuperCchild.class,
+ SuperI.class, SuperIchild.class,
+ SuperIwithDefault.class, SuperIwithDefaultChild.class,
+ Base.class, Combo1.class, Combo2.class,
+ SonSuperIwithDefault.class, DaughterSuperIwithDefault.class, GrandchildSuperIwithDefault.class, D.class,
+ B.class, C.class
+ };
+
+ for(Class<?> clazz : classes) {
+ System.err.println(clazz.toString());
+ for(Method m : clazz.getMethods()) {
+ if (m.getDeclaringClass() != java.lang.Object.class)
+ failures += testMethod(m);
+ }
+ }
+
+ if (failures > 0)
+ throw new RuntimeException();
+ }
+
+ private static int testMethod(Method m) {
+ ExpectedModel em = Objects.requireNonNull(m.getAnnotation(ExpectedModel.class));
+ boolean failed = false;
+
+ if (m.getModifiers() != em.modifiers()) {
+ failed = true;
+ System.err.printf("Unexpected modifiers %d; expected %d%n", m.getModifiers(), em.modifiers());
+ }
+
+ if (m.isDefault() != em.isDefault()) {
+ failed = true;
+ System.err.printf("Unexpected isDefualt %b; expected b%n", m.isDefault(), em.isDefault());
+ }
+
+ if (!m.getDeclaringClass().equals(em.declaringClass())) {
+ failed = true;
+ System.err.printf("Unexpected isDefualt %s; expected %s%n",
+ m.getDeclaringClass().toString(), em.declaringClass().toString());
+ }
+
+ return (!failed) ? 0 :1;
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface ExpectedModel {
+ boolean isDefault() default false;
+ int modifiers() default PUBLIC;
+ Class<?> declaringClass();
+}
+
+abstract class SuperC {
+ @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperC.class)
+ public abstract void foo();
+
+ @ExpectedModel(declaringClass=SuperC.class)
+ public void bar() {
+ ;
+ }
+}
+
+class SuperCchild extends SuperC {
+ @ExpectedModel(declaringClass=SuperCchild.class)
+ @Override
+ public void foo() {;}
+}
+
+// -=-=-=-
+
+interface SuperI {
+ @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperI.class)
+ void foo();
+
+ @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperI.class)
+ void bar();
+}
+
+class SuperIchild implements SuperI {
+ @ExpectedModel(declaringClass=SuperIchild.class)
+ public void foo() {;}
+
+ @ExpectedModel(declaringClass=SuperIchild.class)
+ public void bar() {;}
+}
+
+// -=-=-=-
+
+interface SuperIwithDefault {
+ @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperIwithDefault.class)
+ void foo();
+
+ @ExpectedModel(isDefault=true, declaringClass=SuperIwithDefault.class)
+ default void bar() {
+ ;
+ }
+}
+
+class SuperIwithDefaultChild implements SuperIwithDefault {
+ @ExpectedModel(declaringClass=SuperIwithDefaultChild.class)
+ @Override
+ public void foo() {;}
+}
+
+// -=-=-=-
+
+abstract class Base {
+ @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=Base.class)
+ abstract public void baz();
+
+ @ExpectedModel(declaringClass=Base.class)
+ public void quux() {;}
+}
+
+abstract class Combo1 extends Base implements SuperI {
+ @ExpectedModel(declaringClass=Combo1.class)
+ public void wombat() {}
+}
+
+abstract class Combo2 extends Base implements SuperIwithDefault {
+ @ExpectedModel(declaringClass=Combo2.class)
+ public void wombat() {}
+}
+
+// -=-=-=-
+
+interface SonSuperIwithDefault extends SuperIwithDefault {
+ @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SonSuperIwithDefault.class)
+ void baz();
+
+ @ExpectedModel(isDefault=true, declaringClass=SonSuperIwithDefault.class)
+ default void bazD() {;}
+}
+
+interface DaughterSuperIwithDefault extends SuperIwithDefault {
+ @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=DaughterSuperIwithDefault.class)
+ void quux();
+
+ @ExpectedModel(isDefault=true, declaringClass=DaughterSuperIwithDefault.class)
+ default void quuxD() {;}
+}
+
+interface GrandchildSuperIwithDefault extends SonSuperIwithDefault, DaughterSuperIwithDefault {
+ @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=GrandchildSuperIwithDefault.class)
+ void wombat();
+
+ @ExpectedModel(isDefault=true, declaringClass=GrandchildSuperIwithDefault.class)
+ default void wombatD() {;}
+
+}
+
+class D implements GrandchildSuperIwithDefault {
+ @ExpectedModel(declaringClass=D.class)
+ public void wombat(){}
+
+ @ExpectedModel(declaringClass=D.class)
+ public void baz(){}
+
+ @ExpectedModel(declaringClass=D.class)
+ public void foo(){}
+
+ @ExpectedModel(declaringClass=D.class)
+ public void quux(){}
+}
+
+// -=-=-=-
+
+// What does re-abstraction look like?
+
+class A implements SuperIwithDefault {
+ @ExpectedModel(declaringClass=A.class)
+ @Override
+ public void foo(){;}
+}
+
+abstract class B extends A {
+ @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=B.class)
+ @Override
+ public abstract void bar();
+}
+
+class C extends B implements SuperIwithDefault {
+ @ExpectedModel(declaringClass=C.class)
+ public void bar(){}
+}
diff --git a/test/java/lang/reflect/Method/GenericStringTest.java b/test/java/lang/reflect/Method/GenericStringTest.java
index 14c3c62..9e50dca 100644
--- a/test/java/lang/reflect/Method/GenericStringTest.java
+++ b/test/java/lang/reflect/Method/GenericStringTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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,7 +23,7 @@
/*
* @test
- * @bug 5033583 6316717 6470106
+ * @bug 5033583 6316717 6470106 8004979
* @summary Check toGenericString() and toString() methods
* @author Joseph D. Darcy
*/
@@ -39,6 +39,7 @@
classList.add(TestClass1.class);
classList.add(TestClass2.class);
classList.add(Roebling.class);
+ classList.add(TestInterface1.class);
for(Class<?> clazz: classList)
@@ -129,6 +130,27 @@
void varArg(Object ... arg) {}
}
+interface TestInterface1 {
+ @ExpectedGenericString(
+ "public default void TestInterface1.foo()")
+ @ExpectedString(
+ "public default void TestInterface1.foo()")
+ public default void foo(){;}
+
+ @ExpectedString(
+ "public default java.lang.Object TestInterface1.bar()")
+ @ExpectedGenericString(
+ "public default <A> A TestInterface1.bar()")
+ default <A> A bar(){return null;}
+
+ @ExpectedString(
+ "public default strictfp double TestInterface1.quux()")
+ @ExpectedGenericString(
+ "public default strictfp double TestInterface1.quux()")
+ strictfp default double quux(){return 1.0;}
+
+}
+
@Retention(RetentionPolicy.RUNTIME)
@interface ExpectedGenericString {
String value();
diff --git a/test/java/net/Socks/SocksProxyVersion.java b/test/java/net/Socks/SocksProxyVersion.java
index fe4f1c6..bc46c42 100644
--- a/test/java/net/Socks/SocksProxyVersion.java
+++ b/test/java/net/Socks/SocksProxyVersion.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6964547
+ * @bug 6964547 5001942
* @run main/othervm SocksProxyVersion
* @summary test socksProxyVersion system property
*/
@@ -34,6 +34,7 @@
import java.net.SocketException;
import java.io.DataInputStream;
import java.io.IOException;
+import java.net.InetAddress;
public class SocksProxyVersion implements Runnable {
final ServerSocket ss;
@@ -56,13 +57,19 @@
Thread serverThread = new Thread(this);
serverThread.start();
- System.setProperty("socksProxyHost", "localhost");
+ /*
+ * Retreving the IP Address of the machine
+ * since "localhost" is bypassed as a non-proxy host
+ */
+ String addr = InetAddress.getLocalHost().getHostAddress();
+
+ System.setProperty("socksProxyHost", addr);
System.setProperty("socksProxyPort", Integer.toString(port));
// SOCKS V4
System.setProperty("socksProxyVersion", Integer.toString(4));
try (Socket s = new Socket()) {
- s.connect(new InetSocketAddress("localhost", port));
+ s.connect(new InetSocketAddress(addr, port));
} catch (SocketException e) {
// java.net.SocketException: Malformed reply from SOCKS server
// This exception is OK, since the "server" does not implement
@@ -72,7 +79,7 @@
// SOCKS V5
System.setProperty("socksProxyVersion", Integer.toString(5));
try (Socket s = new Socket()) {
- s.connect(new InetSocketAddress("localhost", port));
+ s.connect(new InetSocketAddress(addr, port));
} catch (SocketException e) { /* OK */ }
serverThread.join();
diff --git a/test/java/nio/channels/DatagramChannel/Connect.java b/test/java/nio/channels/DatagramChannel/Connect.java
index 5fac928..558f032 100644
--- a/test/java/nio/channels/DatagramChannel/Connect.java
+++ b/test/java/nio/channels/DatagramChannel/Connect.java
@@ -22,6 +22,7 @@
*/
/* @test
+ * @bug 4313882 7183800
* @summary Test DatagramChannel's send and receive methods
* @author Mike McCloskey
*/
@@ -88,6 +89,9 @@
bb.put("hello".getBytes());
bb.flip();
InetAddress address = InetAddress.getLocalHost();
+ if (address.isLoopbackAddress()) {
+ address = InetAddress.getLoopbackAddress();
+ }
InetSocketAddress isa = new InetSocketAddress(address, port);
dc.connect(isa);
dc.write(bb);
diff --git a/test/java/nio/channels/DatagramChannel/ConnectedSend.java b/test/java/nio/channels/DatagramChannel/ConnectedSend.java
index 9ac48ed..1f56e51 100644
--- a/test/java/nio/channels/DatagramChannel/ConnectedSend.java
+++ b/test/java/nio/channels/DatagramChannel/ConnectedSend.java
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 4849277
+ * @bug 4849277 7183800
* @summary Test DatagramChannel send while connected
* @author Mike McCloskey
*/
@@ -46,14 +46,18 @@
DatagramChannel sndChannel = DatagramChannel.open();
sndChannel.socket().bind(null);
+ InetAddress address = InetAddress.getLocalHost();
+ if (address.isLoopbackAddress()) {
+ address = InetAddress.getLoopbackAddress();
+ }
InetSocketAddress sender = new InetSocketAddress(
- InetAddress.getLocalHost(),
+ address,
sndChannel.socket().getLocalPort());
DatagramChannel rcvChannel = DatagramChannel.open();
rcvChannel.socket().bind(null);
InetSocketAddress receiver = new InetSocketAddress(
- InetAddress.getLocalHost(),
+ address,
rcvChannel.socket().getLocalPort());
rcvChannel.connect(sender);
@@ -80,14 +84,18 @@
private static void test2() throws Exception {
DatagramChannel sndChannel = DatagramChannel.open();
sndChannel.socket().bind(null);
+ InetAddress address = InetAddress.getLocalHost();
+ if (address.isLoopbackAddress()) {
+ address = InetAddress.getLoopbackAddress();
+ }
InetSocketAddress sender = new InetSocketAddress(
- InetAddress.getLocalHost(),
+ address,
sndChannel.socket().getLocalPort());
DatagramChannel rcvChannel = DatagramChannel.open();
rcvChannel.socket().bind(null);
InetSocketAddress receiver = new InetSocketAddress(
- InetAddress.getLocalHost(),
+ address,
rcvChannel.socket().getLocalPort());
rcvChannel.connect(sender);
diff --git a/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java b/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java
index 834a963..d8c88ff 100644
--- a/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java
+++ b/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java
@@ -133,8 +133,11 @@
dc.close();
dc = DatagramChannel.open();
-
- InetSocketAddress isa = new InetSocketAddress(InetAddress.getLocalHost(), port);
+ InetAddress address = InetAddress.getLocalHost();
+ if (address.isLoopbackAddress()) {
+ address = InetAddress.getLoopbackAddress();
+ }
+ InetSocketAddress isa = new InetSocketAddress(address, port);
dc.connect(isa);
return dc;
diff --git a/test/java/util/Base64/TestBase64.java b/test/java/util/Base64/TestBase64.java
index e0af4de..94413a2 100644
--- a/test/java/util/Base64/TestBase64.java
+++ b/test/java/util/Base64/TestBase64.java
@@ -22,7 +22,7 @@
*/
/**
- * @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530
+ * @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530 8007379 8008925
* @summary tests java.util.Base64
*/
@@ -107,6 +107,9 @@
checkIAE(new Runnable() { public void run() {
Base64.getDecoder().decode(ByteBuffer.wrap(decoded), ByteBuffer.allocateDirect(1024)); }});
+ // illegal ending unit
+ checkIAE(new Runnable() { public void run() { Base64.getMimeDecoder().decode("$=#"); }});
+
// test return value from decode(ByteBuffer, ByteBuffer)
testDecBufRet();
@@ -115,7 +118,6 @@
// test decoding of unpadded data
testDecodeUnpadded();
-
// test mime decoding with ignored character after padding
testDecodeIgnoredAfterPadding();
}
@@ -384,6 +386,10 @@
encoded = Arrays.copyOf(encoded, encoded.length + 1);
encoded[encoded.length - 1] = nonBase64;
checkEqual(decM.decode(encoded), src[i], "Non-base64 char is not ignored");
+ byte[] decoded = new byte[src[i].length];
+ decM.decode(encoded, decoded);
+ checkEqual(decoded, src[i], "Non-base64 char is not ignored");
+
try {
dec.decode(encoded);
throw new RuntimeException("No IAE for non-base64 char");
diff --git a/test/java/util/Optional/Basic.java b/test/java/util/Optional/Basic.java
new file mode 100644
index 0000000..099e045
--- /dev/null
+++ b/test/java/util/Optional/Basic.java
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @summary Basic functional test of Optional
+ * @author Mike Duigou
+ * @run testng Basic
+ */
+
+import java.util.NoSuchElementException;
+import java.util.Optional;
+
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+
+
+public class Basic {
+
+ @Test(groups = "unit")
+ public void testEmpty() {
+ Optional<Boolean> empty = Optional.empty();
+ Optional<String> presentEmptyString = Optional.of("");
+ Optional<Boolean> present = Optional.of(Boolean.TRUE);
+
+ // empty
+ assertTrue(empty.equals(empty));
+ assertTrue(empty.equals(Optional.empty()));
+ assertTrue(!empty.equals(present));
+ assertTrue(0 == empty.hashCode());
+ assertTrue(!empty.toString().isEmpty());
+ assertTrue(!empty.toString().equals(presentEmptyString.toString()));
+ assertTrue(!empty.isPresent());
+ empty.ifPresent(v -> { fail(); });
+ assertSame(null, empty.orElse(null));
+ RuntimeException orElse = new RuntimeException() { };
+ assertSame(Boolean.FALSE, empty.orElse(Boolean.FALSE));
+ assertSame(null, empty.orElseGet(()-> null));
+ assertSame(Boolean.FALSE, empty.orElseGet(()-> Boolean.FALSE));
+ }
+
+ @Test(expectedExceptions=NoSuchElementException.class)
+ public void testEmptyGet() {
+ Optional<Boolean> empty = Optional.empty();
+
+ Boolean got = empty.get();
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void testEmptyOrElseGetNull() {
+ Optional<Boolean> empty = Optional.empty();
+
+ Boolean got = empty.orElseGet(null);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void testEmptyOrElseThrowNull() throws Throwable {
+ Optional<Boolean> empty = Optional.empty();
+
+ Boolean got = empty.orElseThrow(null);
+ }
+
+ @Test(expectedExceptions=ObscureException.class)
+ public void testEmptyOrElseThrow() throws Exception {
+ Optional<Boolean> empty = Optional.empty();
+
+ Boolean got = empty.orElseThrow(ObscureException::new);
+ }
+
+ @Test(groups = "unit")
+ public void testPresent() {
+ Optional<Boolean> empty = Optional.empty();
+ Optional<String> presentEmptyString = Optional.of("");
+ Optional<Boolean> present = Optional.of(Boolean.TRUE);
+
+ // present
+ assertTrue(present.equals(present));
+ assertTrue(present.equals(Optional.of(Boolean.TRUE)));
+ assertTrue(!present.equals(empty));
+ assertTrue(Boolean.TRUE.hashCode() == present.hashCode());
+ assertTrue(!present.toString().isEmpty());
+ assertTrue(!present.toString().equals(presentEmptyString.toString()));
+ assertTrue(-1 != present.toString().indexOf(Boolean.TRUE.toString()));
+ assertSame(Boolean.TRUE, present.get());
+ try {
+ present.ifPresent(v -> { throw new ObscureException(); });
+ fail();
+ } catch(ObscureException expected) {
+
+ }
+ assertSame(Boolean.TRUE, present.orElse(null));
+ assertSame(Boolean.TRUE, present.orElse(Boolean.FALSE));
+ assertSame(Boolean.TRUE, present.orElseGet(null));
+ assertSame(Boolean.TRUE, present.orElseGet(()-> null));
+ assertSame(Boolean.TRUE, present.orElseGet(()-> Boolean.FALSE));
+ assertSame(Boolean.TRUE, present.<RuntimeException>orElseThrow( null));
+ assertSame(Boolean.TRUE, present.<RuntimeException>orElseThrow(ObscureException::new));
+ }
+
+ private static class ObscureException extends RuntimeException {
+
+ }
+}
diff --git a/test/java/util/Optional/BasicDouble.java b/test/java/util/Optional/BasicDouble.java
new file mode 100644
index 0000000..741137c
--- /dev/null
+++ b/test/java/util/Optional/BasicDouble.java
@@ -0,0 +1,115 @@
+/*
+ * 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.0 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2.0 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.0 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @summary Basic functional test of OptionalDouble
+ * @author Mike Duigou
+ * @run testng BasicDouble
+ */
+
+import java.util.NoSuchElementException;
+import java.util.OptionalDouble;
+
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+
+
+public class BasicDouble {
+
+ @Test(groups = "unit")
+ public void testEmpty() {
+ OptionalDouble empty = OptionalDouble.empty();
+ OptionalDouble present = OptionalDouble.of(1.0);
+
+ // empty
+ assertTrue(empty.equals(empty));
+ assertTrue(empty.equals(OptionalDouble.empty()));
+ assertTrue(!empty.equals(present));
+ assertTrue(0 == empty.hashCode());
+ assertTrue(!empty.toString().isEmpty());
+ assertTrue(!empty.isPresent());
+ empty.ifPresent(v -> { fail(); });
+ assertEquals(2.0, empty.orElse(2.0));
+ assertEquals(2.0, empty.orElseGet(()-> 2.0));
+ }
+
+ @Test(expectedExceptions=NoSuchElementException.class)
+ public void testEmptyGet() {
+ OptionalDouble empty = OptionalDouble.empty();
+
+ double got = empty.getAsDouble();
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void testEmptyOrElseGetNull() {
+ OptionalDouble empty = OptionalDouble.empty();
+
+ double got = empty.orElseGet(null);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void testEmptyOrElseThrowNull() throws Throwable {
+ OptionalDouble empty = OptionalDouble.empty();
+
+ double got = empty.orElseThrow(null);
+ }
+
+ @Test(expectedExceptions=ObscureException.class)
+ public void testEmptyOrElseThrow() throws Exception {
+ OptionalDouble empty = OptionalDouble.empty();
+
+ double got = empty.orElseThrow(ObscureException::new);
+ }
+
+ @Test(groups = "unit")
+ public void testPresent() {
+ OptionalDouble empty = OptionalDouble.empty();
+ OptionalDouble present = OptionalDouble.of(1.0);
+
+ // present
+ assertTrue(present.equals(present));
+ assertFalse(present.equals(OptionalDouble.of(0.0)));
+ assertTrue(present.equals(OptionalDouble.of(1.0)));
+ assertTrue(!present.equals(empty));
+ assertTrue(Double.hashCode(1.0) == present.hashCode());
+ assertFalse(present.toString().isEmpty());
+ assertTrue(-1 != present.toString().indexOf(Double.toString(present.getAsDouble()).toString()));
+ assertEquals(1.0, present.getAsDouble());
+ try {
+ present.ifPresent(v -> { throw new ObscureException(); });
+ fail();
+ } catch(ObscureException expected) {
+
+ }
+ assertEquals(1.0, present.orElse(2.0));
+ assertEquals(1.0, present.orElseGet(null));
+ assertEquals(1.0, present.orElseGet(()-> 2.0));
+ assertEquals(1.0, present.orElseGet(()-> 3.0));
+ assertEquals(1.0, present.<RuntimeException>orElseThrow(null));
+ assertEquals(1.0, present.<RuntimeException>orElseThrow(ObscureException::new));
+ }
+
+ private static class ObscureException extends RuntimeException {
+
+ }
+}
diff --git a/test/java/util/Optional/BasicInt.java b/test/java/util/Optional/BasicInt.java
new file mode 100644
index 0000000..fa29f95
--- /dev/null
+++ b/test/java/util/Optional/BasicInt.java
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @summary Basic functional test of OptionalInt
+ * @author Mike Duigou
+ * @run testng BasicInt
+ */
+
+import java.util.NoSuchElementException;
+import java.util.OptionalInt;
+
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+
+
+public class BasicInt {
+
+ @Test(groups = "unit")
+ public void testEmpty() {
+ OptionalInt empty = OptionalInt.empty();
+ OptionalInt present = OptionalInt.of(1);
+
+ // empty
+ assertTrue(empty.equals(empty));
+ assertTrue(empty.equals(OptionalInt.empty()));
+ assertTrue(!empty.equals(present));
+ assertTrue(0 == empty.hashCode());
+ assertTrue(!empty.toString().isEmpty());
+ assertTrue(!empty.isPresent());
+ empty.ifPresent(v -> { fail(); });
+ assertEquals(2, empty.orElse(2));
+ assertEquals(2, empty.orElseGet(()-> 2));
+ }
+
+ @Test(expectedExceptions=NoSuchElementException.class)
+ public void testEmptyGet() {
+ OptionalInt empty = OptionalInt.empty();
+
+ int got = empty.getAsInt();
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void testEmptyOrElseGetNull() {
+ OptionalInt empty = OptionalInt.empty();
+
+ int got = empty.orElseGet(null);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void testEmptyOrElseThrowNull() throws Throwable {
+ OptionalInt empty = OptionalInt.empty();
+
+ int got = empty.orElseThrow(null);
+ }
+
+ @Test(expectedExceptions=ObscureException.class)
+ public void testEmptyOrElseThrow() throws Exception {
+ OptionalInt empty = OptionalInt.empty();
+
+ int got = empty.orElseThrow(ObscureException::new);
+ }
+
+ @Test(groups = "unit")
+ public void testPresent() {
+ OptionalInt empty = OptionalInt.empty();
+ OptionalInt present = OptionalInt.of(1);
+
+ // present
+ assertTrue(present.equals(present));
+ assertFalse(present.equals(OptionalInt.of(0)));
+ assertTrue(present.equals(OptionalInt.of(1)));
+ assertFalse(present.equals(empty));
+ assertTrue(Integer.hashCode(1) == present.hashCode());
+ assertFalse(present.toString().isEmpty());
+ assertTrue(-1 != present.toString().indexOf(Integer.toString(present.getAsInt()).toString()));
+ assertEquals(1, present.getAsInt());
+ try {
+ present.ifPresent(v -> { throw new ObscureException(); });
+ fail();
+ } catch(ObscureException expected) {
+
+ }
+ assertEquals(1, present.orElse(2));
+ assertEquals(1, present.orElseGet(null));
+ assertEquals(1, present.orElseGet(()-> 2));
+ assertEquals(1, present.orElseGet(()-> 3));
+ assertEquals(1, present.<RuntimeException>orElseThrow(null));
+ assertEquals(1, present.<RuntimeException>orElseThrow(ObscureException::new));
+ }
+
+ private static class ObscureException extends RuntimeException {
+
+ }
+}
diff --git a/test/java/util/Optional/BasicLong.java b/test/java/util/Optional/BasicLong.java
new file mode 100644
index 0000000..85bf689
--- /dev/null
+++ b/test/java/util/Optional/BasicLong.java
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @summary Basic functional test of OptionalLong
+ * @author Mike Duigou
+ * @run testng BasicLong
+ */
+
+import java.util.NoSuchElementException;
+import java.util.OptionalLong;
+
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+
+
+public class BasicLong {
+
+ @Test(groups = "unit")
+ public void testEmpty() {
+ OptionalLong empty = OptionalLong.empty();
+ OptionalLong present = OptionalLong.of(1);
+
+ // empty
+ assertTrue(empty.equals(empty));
+ assertTrue(empty.equals(OptionalLong.empty()));
+ assertTrue(!empty.equals(present));
+ assertTrue(0 == empty.hashCode());
+ assertTrue(!empty.toString().isEmpty());
+ assertTrue(!empty.isPresent());
+ empty.ifPresent(v -> { fail(); });
+ assertEquals(2, empty.orElse(2));
+ assertEquals(2, empty.orElseGet(()-> 2));
+ }
+
+ @Test(expectedExceptions=NoSuchElementException.class)
+ public void testEmptyGet() {
+ OptionalLong empty = OptionalLong.empty();
+
+ long got = empty.getAsLong();
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void testEmptyOrElseGetNull() {
+ OptionalLong empty = OptionalLong.empty();
+
+ long got = empty.orElseGet(null);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void testEmptyOrElseThrowNull() throws Throwable {
+ OptionalLong empty = OptionalLong.empty();
+
+ long got = empty.orElseThrow(null);
+ }
+
+ @Test(expectedExceptions=ObscureException.class)
+ public void testEmptyOrElseThrow() throws Exception {
+ OptionalLong empty = OptionalLong.empty();
+
+ long got = empty.orElseThrow(ObscureException::new);
+ }
+
+ @Test(groups = "unit")
+ public void testPresent() {
+ OptionalLong empty = OptionalLong.empty();
+ OptionalLong present = OptionalLong.of(1L);
+
+ // present
+ assertTrue(present.equals(present));
+ assertFalse(present.equals(OptionalLong.of(0L)));
+ assertTrue(present.equals(OptionalLong.of(1L)));
+ assertFalse(present.equals(empty));
+ assertTrue(Long.hashCode(1) == present.hashCode());
+ assertFalse(present.toString().isEmpty());
+ assertTrue(-1 != present.toString().indexOf(Long.toString(present.getAsLong()).toString()));
+ assertEquals(1L, present.getAsLong());
+ try {
+ present.ifPresent(v -> { throw new ObscureException(); });
+ fail();
+ } catch(ObscureException expected) {
+
+ }
+ assertEquals(1, present.orElse(2));
+ assertEquals(1, present.orElseGet(null));
+ assertEquals(1, present.orElseGet(()-> 2));
+ assertEquals(1, present.orElseGet(()-> 3));
+ assertEquals(1, present.<RuntimeException>orElseThrow(null));
+ assertEquals(1, present.<RuntimeException>orElseThrow(ObscureException::new));
+ }
+
+ private static class ObscureException extends RuntimeException {
+
+ }
+}
diff --git a/test/java/util/concurrent/CompletableFuture/Basic.java b/test/java/util/concurrent/CompletableFuture/Basic.java
new file mode 100644
index 0000000..e8ed706
--- /dev/null
+++ b/test/java/util/concurrent/CompletableFuture/Basic.java
@@ -0,0 +1,761 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/*
+ * @test
+ * @bug 8005696
+ * @summary Basic tests for CompletableFuture
+ * @author Chris Hegarty
+ */
+
+import java.lang.reflect.Array;
+import java.util.concurrent.Phaser;
+import static java.util.concurrent.TimeUnit.*;
+import java.util.concurrent.CompletableFuture;
+import static java.util.concurrent.CompletableFuture.*;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import static java.util.concurrent.ForkJoinPool.*;
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+public class Basic {
+
+ static void checkCompletedNormally(CompletableFuture<?> cf, Object value) {
+ checkCompletedNormally(cf, value == null ? null : new Object[] { value });
+ }
+
+ static void checkCompletedNormally(CompletableFuture<?> cf, Object[] values) {
+ try { equalAnyOf(cf.join(), values); } catch (Throwable x) { unexpected(x); }
+ try { equalAnyOf(cf.getNow(null), values); } catch (Throwable x) { unexpected(x); }
+ try { equalAnyOf(cf.get(), values); } catch (Throwable x) { unexpected(x); }
+ try { equalAnyOf(cf.get(0L, SECONDS), values); } catch (Throwable x) { unexpected(x); }
+ check(cf.isDone(), "Expected isDone to be true, got:" + cf);
+ check(!cf.isCancelled(), "Expected isCancelled to be false");
+ check(!cf.cancel(true), "Expected cancel to return false");
+ check(cf.toString().contains("[Completed normally]"));
+ check(cf.complete(null) == false, "Expected complete() to fail");
+ check(cf.completeExceptionally(new Throwable()) == false,
+ "Expected completeExceptionally() to fail");
+ }
+
+ static <T> void checkCompletedExceptionally(CompletableFuture<T> cf)
+ throws Exception
+ {
+ checkCompletedExceptionally(cf, false);
+ }
+
+ @SuppressWarnings("unchecked")
+ static <T> void checkCompletedExceptionally(CompletableFuture<T> cf, boolean cancelled)
+ throws Exception
+ {
+ try { cf.join(); fail("Excepted exception to be thrown"); }
+ catch (CompletionException x) { if (cancelled) fail(); else pass(); }
+ catch (CancellationException x) { if (cancelled) pass(); else fail(); }
+ try { cf.getNow(null); fail("Excepted exception to be thrown"); }
+ catch (CompletionException x) { if (cancelled) fail(); else pass(); }
+ catch (CancellationException x) { if (cancelled) pass(); else fail(); }
+ try { cf.get(); fail("Excepted exception to be thrown");}
+ catch (CancellationException x) { if (cancelled) pass(); else fail(); }
+ catch (ExecutionException x) { if (cancelled) check(x.getCause() instanceof CancellationException); else pass(); }
+ try { cf.get(0L, SECONDS); fail("Excepted exception to be thrown");}
+ catch (CancellationException x) { if (cancelled) pass(); else fail(); }
+ catch (ExecutionException x) { if (cancelled) check(x.getCause() instanceof CancellationException); else pass(); }
+ check(cf.isDone(), "Expected isDone to be true, got:" + cf);
+ check(cf.isCancelled() == cancelled, "Expected isCancelled: " + cancelled + ", got:" + cf.isCancelled());
+ check(cf.cancel(true) == cancelled, "Expected cancel: " + cancelled + ", got:" + cf.cancel(true));
+ check(cf.toString().contains("[Completed exceptionally]")); // ## TODO: 'E'xceptionally
+ check(cf.complete((T)new Object()) == false, "Expected complete() to fail");
+ check(cf.completeExceptionally(new Throwable()) == false,
+ "Expected completeExceptionally() to fail, already completed");
+ }
+
+ private static void realMain(String[] args) throws Throwable {
+ ExecutorService executor = Executors.newFixedThreadPool(2);
+ try {
+ test(executor);
+ } finally {
+ executor.shutdown();
+ executor.awaitTermination(30, SECONDS);
+ }
+ }
+
+ static AtomicInteger atomicInt = new AtomicInteger(0);
+
+ private static void test(ExecutorService executor) throws Throwable {
+
+ Thread.currentThread().setName("mainThread");
+
+ //----------------------------------------------------------------
+ // supplyAsync tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<String> cf = supplyAsync(() -> "a test string");
+ checkCompletedNormally(cf, cf.join());
+ cf = supplyAsync(() -> "a test string", commonPool());
+ checkCompletedNormally(cf, cf.join());
+ cf = supplyAsync(() -> "a test string", executor);
+ checkCompletedNormally(cf, cf.join());
+ cf = supplyAsync(() -> { throw new RuntimeException(); });
+ checkCompletedExceptionally(cf);
+ cf = supplyAsync(() -> { throw new RuntimeException(); }, commonPool());
+ checkCompletedExceptionally(cf);
+ cf = supplyAsync(() -> { throw new RuntimeException(); }, executor);
+ checkCompletedExceptionally(cf);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // runAsync tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Void> cf = runAsync(() -> { });
+ checkCompletedNormally(cf, cf.join());
+ cf = runAsync(() -> { }, commonPool());
+ checkCompletedNormally(cf, cf.join());
+ cf = runAsync(() -> { }, executor);
+ checkCompletedNormally(cf, cf.join());
+ cf = runAsync(() -> { throw new RuntimeException(); });
+ checkCompletedExceptionally(cf);
+ cf = runAsync(() -> { throw new RuntimeException(); }, commonPool());
+ checkCompletedExceptionally(cf);
+ cf = runAsync(() -> { throw new RuntimeException(); }, executor);
+ checkCompletedExceptionally(cf);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // explicit completion
+ //----------------------------------------------------------------
+ try {
+ final Phaser phaser = new Phaser(1);
+ final int phase = phaser.getPhase();
+ CompletableFuture<Integer> cf;
+ cf = supplyAsync(() -> { phaser.awaitAdvance(phase); return 1; });
+ cf.complete(2);
+ phaser.arrive();
+ checkCompletedNormally(cf, 2);
+
+ cf = supplyAsync(() -> { phaser.awaitAdvance(phase+1); return 1; });
+ cf.completeExceptionally(new Throwable());
+ phaser.arrive();
+ checkCompletedExceptionally(cf);
+
+ cf = supplyAsync(() -> { phaser.awaitAdvance(phase+2); return 1; });
+ cf.cancel(true);
+ phaser.arrive();
+ checkCompletedExceptionally(cf, true);
+
+ cf = supplyAsync(() -> { phaser.awaitAdvance(phase+3); return 1; });
+ check(cf.getNow(2) == 2);
+ phaser.arrive();
+ checkCompletedNormally(cf, 1);
+ check(cf.getNow(2) == 1);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // thenApplyXXX tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Integer> cf2;
+ CompletableFuture<String> cf1 = supplyAsync(() -> "a test string");
+ cf2 = cf1.thenApply((x) -> { if (x.equals("a test string")) return 1; else return 0; });
+ checkCompletedNormally(cf1, "a test string");
+ checkCompletedNormally(cf2, 1);
+
+ cf1 = supplyAsync(() -> "a test string");
+ cf2 = cf1.thenApplyAsync((x) -> { if (x.equals("a test string")) return 1; else return 0; });
+ checkCompletedNormally(cf1, "a test string");
+ checkCompletedNormally(cf2, 1);
+
+ cf1 = supplyAsync(() -> "a test string");
+ cf2 = cf1.thenApplyAsync((x) -> { if (x.equals("a test string")) return 1; else return 0; }, executor);
+ checkCompletedNormally(cf1, "a test string");
+ checkCompletedNormally(cf2, 1);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenApply((x) -> { return 0; } );
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenApplyAsync((x) -> { return 0; } );
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenApplyAsync((x) -> { return 0; }, executor);
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // thenAcceptXXX tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Void> cf2;
+ int before = atomicInt.get();
+ CompletableFuture<String> cf1 = supplyAsync(() -> "a test string");
+ cf2 = cf1.thenAccept((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); });
+ checkCompletedNormally(cf1, "a test string");
+ checkCompletedNormally(cf2, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> "a test string");
+ cf2 = cf1.thenAcceptAsync((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); });
+ checkCompletedNormally(cf1, "a test string");
+ checkCompletedNormally(cf2, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> "a test string");
+ cf2 = cf1.thenAcceptAsync((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); }, executor);
+ checkCompletedNormally(cf1, "a test string");
+ checkCompletedNormally(cf2, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenAccept((x) -> { atomicInt.incrementAndGet(); } );
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ check(atomicInt.get() == before);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenAcceptAsync((x) -> { atomicInt.incrementAndGet(); } );
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ check(atomicInt.get() == before);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenAcceptAsync((x) -> { atomicInt.incrementAndGet(); }, executor );
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ check(atomicInt.get() == before);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // thenRunXXX tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Void> cf2;
+ int before = atomicInt.get();
+ CompletableFuture<String> cf1 = supplyAsync(() -> "a test string");
+ cf2 = cf1.thenRun(() -> { atomicInt.incrementAndGet(); });
+ checkCompletedNormally(cf1, "a test string");
+ checkCompletedNormally(cf2, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> "a test string");
+ cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); });
+ checkCompletedNormally(cf1, "a test string");
+ checkCompletedNormally(cf2, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> "a test string");
+ cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); }, executor);
+ checkCompletedNormally(cf1, "a test string");
+ checkCompletedNormally(cf2, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenRun(() -> { atomicInt.incrementAndGet(); });
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ check(atomicInt.get() == before);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); });
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ check(atomicInt.get() == before);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); }, executor);
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ check(atomicInt.get() == before);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // thenCombineXXX tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Integer> cf3;
+ CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+ CompletableFuture<Integer> cf2 = supplyAsync(() -> 1);
+ cf3 = cf1.thenCombine(cf2, (x, y) -> { return x + y; });
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 1);
+ checkCompletedNormally(cf3, 2);
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> 1);
+ cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return x + y; });
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 1);
+ checkCompletedNormally(cf3, 2);
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> 1);
+ cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return x + y; }, executor);
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 1);
+ checkCompletedNormally(cf3, 2);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = supplyAsync(() -> 1);
+ cf3 = cf1.thenCombine(cf2, (x, y) -> { return 0; });
+ checkCompletedExceptionally(cf1);
+ checkCompletedNormally(cf2, 1);
+ checkCompletedExceptionally(cf3);
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return 0; });
+ checkCompletedNormally(cf1, 1);
+ checkCompletedExceptionally(cf2);
+ checkCompletedExceptionally(cf3);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return 0; }, executor);
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ checkCompletedExceptionally(cf3);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // thenAcceptBothXXX tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Void> cf3;
+ int before = atomicInt.get();
+ CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+ CompletableFuture<Integer> cf2 = supplyAsync(() -> 1);
+ cf3 = cf1.thenAcceptBoth(cf2, (x, y) -> { check(x + y == 2); atomicInt.incrementAndGet(); });
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 1);
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> 1);
+ cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { check(x + y == 2); atomicInt.incrementAndGet(); });
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 1);
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> 1);
+ cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { check(x + y == 2); atomicInt.incrementAndGet(); }, executor);
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 1);
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = supplyAsync(() -> 1);
+ cf3 = cf1.thenAcceptBoth(cf2, (x, y) -> { atomicInt.incrementAndGet(); });
+ checkCompletedExceptionally(cf1);
+ checkCompletedNormally(cf2, 1);
+ checkCompletedExceptionally(cf3);
+ check(atomicInt.get() == before);
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { atomicInt.incrementAndGet(); });
+ checkCompletedNormally(cf1, 1);
+ checkCompletedExceptionally(cf2);
+ checkCompletedExceptionally(cf3);
+ check(atomicInt.get() == before);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { atomicInt.incrementAndGet(); }, executor);
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ checkCompletedExceptionally(cf3);
+ check(atomicInt.get() == before);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // runAfterBothXXX tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Void> cf3;
+ int before = atomicInt.get();
+ CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+ CompletableFuture<Integer> cf2 = supplyAsync(() -> 1);
+ cf3 = cf1.runAfterBoth(cf2, () -> { check(cf1.isDone()); check(cf2.isDone()); atomicInt.incrementAndGet(); });
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 1);
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ CompletableFuture<Integer> cfa = supplyAsync(() -> 1);
+ CompletableFuture<Integer> cfb = supplyAsync(() -> 1);
+ cf3 = cfa.runAfterBothAsync(cfb, () -> { check(cfa.isDone()); check(cfb.isDone()); atomicInt.incrementAndGet(); });
+ checkCompletedNormally(cfa, 1);
+ checkCompletedNormally(cfb, 1);
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ CompletableFuture<Integer> cfx = supplyAsync(() -> 1);
+ CompletableFuture<Integer> cfy = supplyAsync(() -> 1);
+ cf3 = cfy.runAfterBothAsync(cfx, () -> { check(cfx.isDone()); check(cfy.isDone()); atomicInt.incrementAndGet(); }, executor);
+ checkCompletedNormally(cfx, 1);
+ checkCompletedNormally(cfy, 1);
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ CompletableFuture<Integer> cf4 = supplyAsync(() -> { throw new RuntimeException(); });
+ CompletableFuture<Integer> cf5 = supplyAsync(() -> 1);
+ cf3 = cf5.runAfterBothAsync(cf4, () -> { atomicInt.incrementAndGet(); }, executor);
+ checkCompletedExceptionally(cf4);
+ checkCompletedNormally(cf5, 1);
+ checkCompletedExceptionally(cf3);
+ check(atomicInt.get() == before);
+
+ before = atomicInt.get();
+ cf4 = supplyAsync(() -> 1);
+ cf5 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf5.runAfterBothAsync(cf4, () -> { atomicInt.incrementAndGet(); });
+ checkCompletedNormally(cf4, 1);
+ checkCompletedExceptionally(cf5);
+ checkCompletedExceptionally(cf3);
+ check(atomicInt.get() == before);
+
+ before = atomicInt.get();
+ cf4 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf5 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf5.runAfterBoth(cf4, () -> { atomicInt.incrementAndGet(); });
+ checkCompletedExceptionally(cf4);
+ checkCompletedExceptionally(cf5);
+ checkCompletedExceptionally(cf3);
+ check(atomicInt.get() == before);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // applyToEitherXXX tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Integer> cf3;
+ CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+ CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
+ cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 1 || x == 2); return x; });
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedNormally(cf3, new Object[] {1, 2});
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> 2);
+ cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); return x; });
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedNormally(cf3, new Object[] {1, 2});
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> 2);
+ cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); return x; }, executor);
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedNormally(cf3, new Object[] {1, 2});
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = supplyAsync(() -> 2);
+ cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 2); return x; });
+ check(cf1.isDone() || cf2.isDone());
+ try { check(cf3.join() == 1); } catch (CompletionException x) { pass(); }
+ check(cf3.isDone());
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1); return x; });
+ check(cf1.isDone() || cf2.isDone());
+ try { check(cf3.join() == 1); } catch (CompletionException x) { pass(); }
+ check(cf3.isDone());
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf1.applyToEitherAsync(cf2, (x) -> { fail(); return x; });
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedExceptionally(cf3);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // acceptEitherXXX tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Void> cf3;
+ int before = atomicInt.get();
+ CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+ CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
+ cf3 = cf1.acceptEither(cf2, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); });
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> 2);
+ cf3 = cf1.acceptEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); });
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> 2);
+ cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); }, executor);
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = supplyAsync(() -> 2);
+ cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 2); }, executor);
+ check(cf1.isDone() || cf2.isDone());
+ try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
+ check(cf3.isDone());
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 1); });
+ check(cf1.isDone() || cf2.isDone());
+ try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
+ check(cf3.isDone());
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf2.acceptEitherAsync(cf1, (x) -> { fail(); });
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedExceptionally(cf3);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // runAfterEitherXXX tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Void> cf3;
+ int before = atomicInt.get();
+ CompletableFuture<Void> cf1 = runAsync(() -> { });
+ CompletableFuture<Void> cf2 = runAsync(() -> { });
+ cf3 = cf1.runAfterEither(cf2, () -> { atomicInt.incrementAndGet(); });
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = runAsync(() -> { });
+ cf2 = runAsync(() -> { });
+ cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = runAsync(() -> { });
+ cf2 = runAsync(() -> { });
+ cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor);
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedNormally(cf3, null);
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = runAsync(() -> { throw new RuntimeException(); });
+ cf2 = runAsync(() -> { });
+ cf3 = cf2.runAfterEither(cf1, () -> { atomicInt.incrementAndGet(); });
+ check(cf1.isDone() || cf2.isDone());
+ try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
+ check(cf3.isDone());
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = runAsync(() -> { });
+ cf2 = runAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
+ check(cf1.isDone() || cf2.isDone());
+ try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
+ check(cf3.isDone());
+ check(atomicInt.get() == (before + 1));
+
+ before = atomicInt.get();
+ cf1 = runAsync(() -> { throw new RuntimeException(); });
+ cf2 = runAsync(() -> { throw new RuntimeException(); });
+ cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor);
+ check(cf1.isDone() || cf2.isDone());
+ checkCompletedExceptionally(cf3);
+ check(atomicInt.get() == before);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // thenComposeXXX tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Integer> cf2;
+ CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+ cf2 = cf1.thenCompose((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); });
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 2);
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = cf1.thenComposeAsync((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); });
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 2);
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = cf1.thenComposeAsync((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); }, executor);
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 2);
+
+ int before = atomicInt.get();
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenCompose((x) -> { atomicInt.incrementAndGet(); return CompletableFuture.completedFuture(2); });
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ check(atomicInt.get() == before);
+
+ cf1 = supplyAsync(() -> { throw new RuntimeException(); });
+ cf2 = cf1.thenComposeAsync((x) -> { atomicInt.incrementAndGet(); return CompletableFuture.completedFuture(2); });
+ checkCompletedExceptionally(cf1);
+ checkCompletedExceptionally(cf2);
+ check(atomicInt.get() == before);
+
+ cf1 = supplyAsync(() -> 1);
+ cf2 = cf1.thenComposeAsync((x) -> { throw new RuntimeException(); }, executor);
+ checkCompletedNormally(cf1, 1);
+ checkCompletedExceptionally(cf2);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // anyOf tests
+ //----------------------------------------------------------------
+ //try {
+ // CompletableFuture<Object> cf3;
+ // for (int k=0; k < 10; k++){
+ // CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+ // CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
+ // cf3 = CompletableFuture.anyOf(cf1, cf2);
+ // check(cf1.isDone() || cf2.isDone());
+ // checkCompletedNormally(cf3, new Object[] {1, 2});
+ // }
+ //} catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // allOf tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<?> cf3;
+ for (int k=0; k < 10; k++){
+ CompletableFuture<Integer>[] cfs = (CompletableFuture<Integer>[])
+ Array.newInstance(CompletableFuture.class, 10);
+ for (int j=0; j < 10; j++) {
+ final int v = j;
+ cfs[j] = supplyAsync(() -> v);
+ }
+ cf3 = CompletableFuture.allOf(cfs);
+ for (int j=0; j < 10; j++)
+ checkCompletedNormally(cfs[j], j);
+ checkCompletedNormally(cf3, null);
+ }
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // exceptionally tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Integer> cf2;
+ CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+ cf2 = cf1.exceptionally((t) -> { fail("function should never be called"); return 2;});
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 1);
+
+ final RuntimeException t = new RuntimeException();
+ cf1 = supplyAsync(() -> { throw t; });
+ cf2 = cf1.exceptionally((x) -> { check(x.getCause() == t); return 2;});
+ checkCompletedExceptionally(cf1);
+ checkCompletedNormally(cf2, 2);
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // handle tests
+ //----------------------------------------------------------------
+ try {
+ CompletableFuture<Integer> cf2;
+ CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
+ cf2 = cf1.handle((x,t) -> x+1);
+ checkCompletedNormally(cf1, 1);
+ checkCompletedNormally(cf2, 2);
+
+ final RuntimeException ex = new RuntimeException();
+ cf1 = supplyAsync(() -> { throw ex; });
+ cf2 = cf1.handle((x,t) -> { check(t.getCause() == ex); return 2;});
+ checkCompletedExceptionally(cf1);
+ checkCompletedNormally(cf2, 2);
+ } catch (Throwable t) { unexpected(t); }
+
+ }
+
+ //--------------------- Infrastructure ---------------------------
+ static volatile int passed = 0, failed = 0;
+ static void pass() {passed++;}
+ static void fail() {failed++; Thread.dumpStack();}
+ static void fail(String msg) {System.out.println(msg); fail();}
+ static void unexpected(Throwable t) {failed++; t.printStackTrace();}
+ static void check(boolean cond) {if (cond) pass(); else fail();}
+ static void check(boolean cond, String msg) {if (cond) pass(); else fail(msg);}
+ static void equal(Object x, Object y) {
+ if (x == null ? y == null : x.equals(y)) pass();
+ else fail(x + " not equal to " + y);}
+ static void equalAnyOf(Object x, Object[] y) {
+ if (x == null && y == null) { pass(); return; }
+ for (Object z : y) { if (x.equals(z)) { pass(); return; } }
+ StringBuilder sb = new StringBuilder();
+ for (Object o : y)
+ sb.append(o).append(" ");
+ fail(x + " not equal to one of [" + sb + "]");}
+ public static void main(String[] args) throws Throwable {
+ try {realMain(args);} catch (Throwable t) {unexpected(t);}
+ System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+ if (failed > 0) throw new AssertionError("Some tests failed");}
+}
diff --git a/test/java/util/logging/CustomLogManager.java b/test/java/util/logging/CustomLogManager.java
index 9542e54..4598449 100644
--- a/test/java/util/logging/CustomLogManager.java
+++ b/test/java/util/logging/CustomLogManager.java
@@ -43,6 +43,20 @@
INSTANCE = this;
}
+ private boolean useParentHandlers(String loggerName) {
+ String s = props.getProperty(loggerName + ".useParentHandlers");
+ if (s == null)
+ return true; // default is true
+
+ s = s.toLowerCase();
+ if (s.equals("true") || s.equals("1")) {
+ return true;
+ } else if (s.equals("false") || s.equals("0")) {
+ return false;
+ }
+ return true;
+ }
+
public synchronized boolean addLogger(Logger logger) {
String name = logger.getName();
if (namedLoggers.containsKey(name)) {
@@ -57,6 +71,9 @@
if (props.get(name + ".handlers") != null && logger.getHandlers().length == 0) {
logger.addHandler(new CustomHandler());
}
+ if (!useParentHandlers(name)) {
+ logger.setUseParentHandlers(false);
+ }
// add parent loggers
int ix = 1;
for (;;) {
@@ -72,7 +89,10 @@
//
// The test doesn't set the parent for simplicity.
if (!namedLoggers.containsKey(pname)) {
- Logger.getLogger(pname);
+ Logger parent = Logger.getLogger(pname);
+ if (!useParentHandlers(pname)) {
+ parent.setUseParentHandlers(false);
+ }
}
}
ix = ix2 + 1;
@@ -110,14 +130,16 @@
props.put("CustomLogManager$CustomHandler.level", "WARNING");
props.put(".handlers", "CustomLogManager$CustomHandler");
props.put("org.foo.bar.level", "SEVERE");
+ props.put("org.foo.bar.useParentHandlers", "true");
props.put("org.foo.handlers", "CustomLogManager$CustomHandler");
+ props.put("org.foo.useParentHandlers", "false");
props.put("org.openjdk.level", "SEVERE");
props.put("org.openjdk.handlers", "CustomLogManager$CustomHandler");
props.put("org.openjdk.core.level", "INFO");
+ props.put("org.openjdk.core.useParentHandlers", "false");
return props;
}
-
public static void checkLogger(String name) {
checkLogger(name, null);
}
@@ -127,10 +149,11 @@
if (logger == null) {
throw new RuntimeException("Logger \"" + name + "\" not exist");
}
- System.out.format("Logger \"%s\" level=%s handlers=%s resourcebundle=%s%n",
+ System.out.format("Logger \"%s\" level=%s handlers=%s resourcebundle=%s useParentHandlers=%s%n",
name, logger.getLevel(),
Arrays.toString(logger.getHandlers()),
- logger.getResourceBundleName());
+ logger.getResourceBundleName(),
+ logger.getUseParentHandlers());
String rb = logger.getResourceBundleName();
if (rb != resourceBundleName && (rb == null || rb.equals(resourceBundleName))) {
throw new RuntimeException("Logger \"" + name +
@@ -150,6 +173,13 @@
throw new RuntimeException("Logger \"" + name + "\" unexpected handler: " +
Arrays.toString(handlers));
}
+
+ String s = INSTANCE.getProperty(name + ".useParentHandlers");
+ boolean uph = (s != null && s.equals("false")) ? false : true;
+ if (logger.getUseParentHandlers() != uph) {
+ throw new RuntimeException("Logger \"" + name + "\" unexpected useParentHandlers: " +
+ logger.getUseParentHandlers());
+ }
checkParents(name);
}
diff --git a/test/java/util/logging/CustomLogManagerTest.java b/test/java/util/logging/CustomLogManagerTest.java
index 2fa89a9..b8f0bfa 100644
--- a/test/java/util/logging/CustomLogManagerTest.java
+++ b/test/java/util/logging/CustomLogManagerTest.java
@@ -29,7 +29,7 @@
/*
* @test
- * @bug 8005615
+ * @bug 8005615 8006104
* @summary Add loggers to custom log manager
*
* @compile -XDignore.symbol.file CustomLogManagerTest.java CustomLogManager.java
diff --git a/test/java/util/logging/LoggerResourceBundleRace.java b/test/java/util/logging/LoggerResourceBundleRace.java
index aabbc14..f9acc87 100644
--- a/test/java/util/logging/LoggerResourceBundleRace.java
+++ b/test/java/util/logging/LoggerResourceBundleRace.java
@@ -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
@@ -23,13 +23,14 @@
/*
* @test
- * @bug 7045594
+ * @bug 7045594 8002070
* @summary ResourceBundle setting race in Logger.getLogger(name, rbName)
* @author Daniel D. Daugherty
* @build RacingThreadsTest LoggerResourceBundleRace
- * @run main LoggerResourceBundleRace
+ * @run main/othervm LoggerResourceBundleRace
+ *
+ * (In samevm mode, the bundle classes don't end up in the classpath.)
*/
-
import java.util.ListResourceBundle;
import java.util.MissingResourceException;
import java.util.concurrent.atomic.AtomicInteger;
diff --git a/test/java/util/zip/EntryCount64k.java b/test/java/util/zip/EntryCount64k.java
new file mode 100644
index 0000000..c815efd
--- /dev/null
+++ b/test/java/util/zip/EntryCount64k.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013 Google Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Test java.util.zip behavior with ~64k entries
+ * @run main/othervm EntryCount64k
+ * @run main/othervm -Djdk.util.zip.inhibitZip64=true EntryCount64k
+ * @run main/othervm -Djdk.util.zip.inhibitZip64=false EntryCount64k
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+
+public class EntryCount64k {
+
+ public static void main(String[] args) throws Exception {
+ for (int i = (1 << 16) - 2; i < (1 << 16) + 2; i++)
+ test(i);
+ }
+
+ static void test(int entryCount) throws Exception {
+ File zipFile = new File("EntryCount64k-tmp.zip");
+ zipFile.delete();
+
+ try (ZipOutputStream zos =
+ new ZipOutputStream(
+ new BufferedOutputStream(
+ new FileOutputStream(zipFile)))) {
+ for (int i = 0; i < entryCount; i++) {
+ ZipEntry e = new ZipEntry(Integer.toString(i));
+ zos.putNextEntry(e);
+ zos.closeEntry();
+ }
+ }
+
+ String p = System.getProperty("jdk.util.zip.inhibitZip64");
+ boolean tooManyEntries = entryCount >= (1 << 16) - 1;
+ boolean shouldUseZip64 = tooManyEntries & !("true".equals(p));
+ boolean usesZip64 = usesZip64(zipFile);
+ String details = String.format
+ ("entryCount=%d shouldUseZip64=%s usesZip64=%s zipSize=%d%n",
+ entryCount, shouldUseZip64, usesZip64, zipFile.length());
+ System.err.println(details);
+ checkCanRead(zipFile, entryCount);
+ if (shouldUseZip64 != usesZip64)
+ throw new Error(details);
+ zipFile.delete();
+ }
+
+ static boolean usesZip64(File zipFile) throws Exception {
+ RandomAccessFile raf = new RandomAccessFile(zipFile, "r");
+ byte[] buf = new byte[4096];
+ raf.seek(raf.length() - buf.length);
+ raf.read(buf);
+ for (int i = 0; i < buf.length - 4; i++) {
+ // Look for ZIP64 End Header Signature
+ // Phil Katz: yes, we will always remember you
+ if (buf[i+0] == 'P' &&
+ buf[i+1] == 'K' &&
+ buf[i+2] == 6 &&
+ buf[i+3] == 6)
+ return true;
+ }
+ return false;
+ }
+
+ static void checkCanRead(File zipFile, int entryCount) throws Exception {
+ // Check ZipInputStream API
+ try (ZipInputStream zis =
+ new ZipInputStream(
+ new BufferedInputStream(
+ new FileInputStream(zipFile)))) {
+ for (int i = 0; i < entryCount; i++) {
+ ZipEntry e = zis.getNextEntry();
+ if (Integer.parseInt(e.getName()) != i)
+ throw new AssertionError();
+ }
+ if (zis.getNextEntry() != null)
+ throw new AssertionError();
+ }
+
+ // Check ZipFile API
+ try (ZipFile zf = new ZipFile(zipFile)) {
+ Enumeration<? extends ZipEntry> en = zf.entries();
+ for (int i = 0; i < entryCount; i++) {
+ ZipEntry e = en.nextElement();
+ if (Integer.parseInt(e.getName()) != i)
+ throw new AssertionError();
+ }
+ if (en.hasMoreElements()
+ || (zf.size() != entryCount)
+ || (zf.getEntry(Integer.toString(entryCount - 1)) == null)
+ || (zf.getEntry(Integer.toString(entryCount)) != null))
+ throw new AssertionError();
+ }
+ }
+}
diff --git a/test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java b/test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java
index 7de3c1a..c392f11 100644
--- a/test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java
+++ b/test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4901808
+ * @bug 4901808 7183800
* @summary Check that RMI connection ids include client host name
* @author Eamonn McManus
* @run clean RMIConnectionIdTest
@@ -60,7 +60,7 @@
}
String clientAddr = rest.substring(0, spaceIndex);
InetAddress clientInetAddr = InetAddress.getByName(clientAddr);
- InetAddress localAddr = InetAddress.getLocalHost();
+ InetAddress localAddr = clientInetAddr.isLoopbackAddress() ? InetAddress.getLoopbackAddress() : InetAddress.getLocalHost();
System.out.println("InetAddresses: local=" + localAddr + "; " +
"connectionId=" + clientInetAddr);
if (!localAddr.equals(clientInetAddr)) {
diff --git a/test/javax/script/GetInterfaceTest.java b/test/javax/script/GetInterfaceTest.java
index dffc74e..654147e 100644
--- a/test/javax/script/GetInterfaceTest.java
+++ b/test/javax/script/GetInterfaceTest.java
@@ -22,7 +22,6 @@
*/
/*
- * @run ignore
* @test
* @bug 6960211
* @summary JavaScript engine allows creation of interface although methods not available.
@@ -49,30 +48,30 @@
}
// now define "run"
- engine.eval("function run() { println('this is run function'); }");
+ engine.eval("function run() { print('this is run function'); }");
runnable = ((Invocable)engine).getInterface(Runnable.class);
// should not return null now!
runnable.run();
// define only one method of "Foo2"
- engine.eval("function bar() { println('bar function'); }");
+ engine.eval("function bar() { print('bar function'); }");
Foo2 foo2 = ((Invocable)engine).getInterface(Foo2.class);
if (foo2 != null) {
throw new RuntimeException("foo2 is not null!");
}
// now define other method of "Foo2"
- engine.eval("function bar2() { println('bar2 function'); }");
+ engine.eval("function bar2() { print('bar2 function'); }");
foo2 = ((Invocable)engine).getInterface(Foo2.class);
foo2.bar();
foo2.bar2();
}
- interface Foo {
+ public interface Foo {
public void bar();
}
- interface Foo2 extends Foo {
+ public interface Foo2 extends Foo {
public void bar2();
}
}
diff --git a/test/javax/swing/JMenu/4515762/bug4515762.java b/test/javax/swing/JMenu/4515762/bug4515762.java
new file mode 100644
index 0000000..cb86ac1
--- /dev/null
+++ b/test/javax/swing/JMenu/4515762/bug4515762.java
@@ -0,0 +1,172 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import sun.awt.SunToolkit;
+
+/**
+ * @test
+ * @bug 4515762
+ * @author Mark Davidson
+ * @summary Tests the ability to support duplicate mnemonics
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main bug4515762
+ */
+public class bug4515762 {
+
+ private static volatile boolean actionExpected = false;
+ private static volatile boolean actionRecieved = false;
+
+ /**
+ * @param str name of Menu
+ */
+ private static JMenuBar createMenuBar() {
+ JMenuBar menubar = new JMenuBar();
+
+ // Duplicate menu item test for 4515762
+ JMenu menu = new JMenu("Duplicate Menu");
+ menu.setMnemonic('D');
+ menu.add(createMenuItem("Sunday", 'S'));
+ menu.add(createMenuItem("Monday", 'M'));
+
+ menu.add(createMenuItem("Tuesday", 'S'));
+ menu.add(createMenuItem("Wednesday", 'S'));
+ menu.add(createMenuItem("Thursday", 'S'));
+ menu.add(createMenuItem("Friday", 'F'));
+ menu.add(createMenuItem("Saturday", 'S'));
+
+ // Control with unique menu
+ JMenu menu2 = new JMenu("Unique Menu");
+ menu2.setMnemonic('U');
+ menu2.add(createMenuItem("Sunday", 'S'));
+ menu2.add(createMenuItem("Monday", 'M'));
+
+ menu2.add(createMenuItem("Tuesday", 'T'));
+ menu2.add(createMenuItem("Wednesday", 'W'));
+ menu2.add(createMenuItem("Thursday", 'U'));
+ menu2.add(createMenuItem("Friday", 'F'));
+ menu2.add(createMenuItem("Saturday", 'A'));
+
+ menubar.add(menu);
+ menubar.add(menu2);
+
+ return menubar;
+ }
+
+ /**
+ * Creates and returns the menu item.
+ */
+ private static JMenuItem createMenuItem(String name, char mnemonic) {
+ JMenuItem menuItem = new JMenuItem(name, mnemonic);
+ menuItem.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent evt) {
+ JMenuItem item = (JMenuItem) evt.getSource();
+ if (actionExpected == false) {
+ throw new RuntimeException("Menu Action: "
+ + item.getText() + " should not be called");
+ } else {
+ actionRecieved = true;
+ }
+ }
+ });
+
+ return menuItem;
+ }
+
+ public static void checkAction() {
+ if (actionRecieved == true) {
+ actionRecieved = false;
+ } else {
+ throw new RuntimeException("Action has not been received");
+ }
+ }
+
+ public static void main(String[] args) throws Throwable {
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot = new Robot();
+ robot.setAutoDelay(250);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ JFrame frame = new JFrame("Test");
+ frame.setJMenuBar(createMenuBar());
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+
+ toolkit.realSync();
+
+ Util.hitMnemonics(robot, KeyEvent.VK_D);
+ toolkit.realSync();
+
+ // Press the S key many times (should not cause an action peformed)
+ int TIMES = 5;
+ for (int i = 0; i < TIMES; i++) {
+ Util.hitKeys(robot, KeyEvent.VK_S);
+ }
+ toolkit.realSync();
+
+ // Unique menu items.
+ actionExpected = true;
+ Util.hitMnemonics(robot, KeyEvent.VK_U);
+
+ robot.keyPress(KeyEvent.VK_S);
+ robot.keyRelease(KeyEvent.VK_S);
+ toolkit.realSync();
+
+ checkAction();
+
+ Util.hitMnemonics(robot, KeyEvent.VK_U);
+ robot.keyPress(KeyEvent.VK_M);
+ robot.keyRelease(KeyEvent.VK_M);
+ toolkit.realSync();
+
+ checkAction();
+
+ Util.hitMnemonics(robot, KeyEvent.VK_U);
+ Util.hitKeys(robot, KeyEvent.VK_T);
+ toolkit.realSync();
+
+ checkAction();
+ Util.hitMnemonics(robot, KeyEvent.VK_U);
+ Util.hitKeys(robot, KeyEvent.VK_W);
+ toolkit.realSync();
+
+ checkAction();
+
+ Util.hitMnemonics(robot, KeyEvent.VK_U);
+ Util.hitKeys(robot, KeyEvent.VK_U);
+ toolkit.realSync();
+
+ checkAction();
+ }
+}
diff --git a/test/javax/swing/JRootPane/4670486/bug4670486.java b/test/javax/swing/JRootPane/4670486/bug4670486.java
new file mode 100644
index 0000000..6682f8a
--- /dev/null
+++ b/test/javax/swing/JRootPane/4670486/bug4670486.java
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import sun.awt.SunToolkit;
+
+/**
+ * @test
+ * @bug 4670486
+ * @author Mark Davidson
+ * @summary Regression: Popup menu bindings doesn't work when a default button has been defined.
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main bug4670486
+ */
+public class bug4670486 {
+
+ public static volatile boolean actionExpected = false;
+ public static volatile boolean actionRecieved = false;
+
+ private static JMenuBar createMenuBar() {
+ JMenuBar menubar = new JMenuBar();
+
+ // Control with unique menu
+ JMenu menu = new JMenu("Unique Menu");
+ menu.setMnemonic('U');
+ menu.add(createMenuItem("Sunday", 'S'));
+ menu.add(createMenuItem("Monday", 'M'));
+
+ menu.add(createMenuItem("Tuesday", 'T'));
+ menu.add(createMenuItem("Wednesday", 'W'));
+ menu.add(createMenuItem("Thursday", 'U'));
+ menu.add(createMenuItem("Friday", 'F'));
+ menu.add(createMenuItem("Saturday", 'A'));
+
+ menubar.add(menu);
+
+ return menubar;
+ }
+
+ private static JPanel createPanel(JFrame frame) {
+ JPanel panel = new JPanel();
+ JButton button = new JButton("Button");
+ JButton button2 = new JButton("Button 2");
+ JButton button3 = new JButton("Button 3");
+
+ JRootPane root = frame.getRootPane();
+ root.setDefaultButton(button);
+
+ panel.add(button);
+ panel.add(button2);
+ panel.add(button3);
+
+ return panel;
+ }
+
+ /**
+ * Creates and returns the menu item.
+ */
+ private static JMenuItem createMenuItem(String name, char mnemonic) {
+ JMenuItem menuItem = new JMenuItem(name, mnemonic);
+ menuItem.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent evt) {
+ actionRecieved = true;
+ }
+ });
+
+ return menuItem;
+ }
+
+ public static void checkAction() {
+ if (actionRecieved == true) {
+ actionRecieved = false;
+ } else {
+ throw new RuntimeException("Action has not been received");
+ }
+ }
+
+ public static void main(String[] args) throws Throwable {
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot = new Robot();
+ robot.setAutoDelay(250);
+
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ JFrame frame = new JFrame("Test");
+ frame.setContentPane(createPanel(frame));
+ frame.setJMenuBar(createMenuBar());
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+
+ toolkit.realSync();
+
+ // Change the default button to
+ // force a call to BasicRootPaneUI.updateDefaultButtonBindings()
+ Util.hitKeys(robot, KeyEvent.VK_TAB);
+
+ // If the bug exists, then as soon as the menu appears,
+ // the VK_ENTER, VK_DOWN, VK_UP and VK_ESC will have no
+ // effect.
+ Util.hitMnemonics(robot, KeyEvent.VK_U);
+ Util.hitKeys(robot, KeyEvent.VK_ENTER);
+ toolkit.realSync();
+
+ checkAction();
+
+ Util.hitMnemonics(robot, KeyEvent.VK_U);
+ Util.hitKeys(robot, KeyEvent.VK_DOWN);
+ Util.hitKeys(robot, KeyEvent.VK_ENTER);
+ toolkit.realSync();
+
+ checkAction();
+ }
+}
diff --git a/test/javax/swing/JScrollBar/7163696/Test7163696.java b/test/javax/swing/JScrollBar/7163696/Test7163696.java
new file mode 100644
index 0000000..922bf2e
--- /dev/null
+++ b/test/javax/swing/JScrollBar/7163696/Test7163696.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7163696
+ * @summary Tests that JScrollBar scrolls to the left
+ * @author Sergey Malenkov
+ */
+
+import sun.awt.SunToolkit;
+
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+
+import javax.swing.JFrame;
+import javax.swing.JScrollBar;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UIManager.LookAndFeelInfo;
+
+public class Test7163696 implements Runnable {
+
+ private static final boolean AUTO = null != System.getProperty("test.src", null);
+
+ public static void main(String[] args) throws Exception {
+ new Test7163696().test();
+ }
+
+ private JScrollBar bar;
+
+ private void test() throws Exception {
+ Robot robot = new Robot();
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+ UIManager.setLookAndFeel(info.getClassName());
+
+ SwingUtilities.invokeAndWait(this);
+ toolkit.realSync(500); // after creation
+
+ Point point = this.bar.getLocation();
+ SwingUtilities.convertPointToScreen(point, this.bar);
+ point.x += this.bar.getWidth() >> 2;
+ point.y += this.bar.getHeight() >> 1;
+ robot.mouseMove(point.x, point.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ toolkit.realSync(500); // before validation
+ SwingUtilities.invokeAndWait(this);
+
+ if (this.bar != null) {
+ this.bar = null; // allows to reuse the instance
+ if (AUTO) { // error reporting only for automatic testing
+ throw new Error("TEST FAILED");
+ }
+ }
+ }
+ }
+
+ public void run() {
+ if (this.bar == null) {
+ this.bar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100);
+ this.bar.setPreferredSize(new Dimension(400, 20));
+
+ JFrame frame = new JFrame();
+ frame.add(this.bar);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ else if (40 != this.bar.getValue()) {
+ System.out.println("name = " + UIManager.getLookAndFeel().getName());
+ System.out.println("value = " + this.bar.getValue());
+ }
+ else {
+ SwingUtilities.getWindowAncestor(this.bar).dispose();
+ this.bar = null;
+ }
+ }
+}
diff --git a/test/javax/swing/JTree/8004298/bug8004298.java b/test/javax/swing/JTree/8004298/bug8004298.java
index 3d0ca5c..bafdee7 100644
--- a/test/javax/swing/JTree/8004298/bug8004298.java
+++ b/test/javax/swing/JTree/8004298/bug8004298.java
@@ -48,8 +48,13 @@
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- UIManager.setLookAndFeel(new WindowsLookAndFeel());
-
+ try {
+ UIManager.setLookAndFeel(new WindowsLookAndFeel());
+ } catch (javax.swing.UnsupportedLookAndFeelException ulafe) {
+ System.out.println(ulafe.getMessage());
+ System.out.println("The test is considered PASSED");
+ return;
+ }
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@@ -113,4 +118,4 @@
return super.getPathBounds(tree, path);
}
}
-}
\ No newline at end of file
+}
diff --git a/test/javax/swing/regtesthelpers/Util.java b/test/javax/swing/regtesthelpers/Util.java
index df7ab7a..3346071 100644
--- a/test/javax/swing/regtesthelpers/Util.java
+++ b/test/javax/swing/regtesthelpers/Util.java
@@ -146,6 +146,23 @@
}
/**
+ * Hits mnemonics by robot.
+ */
+ public static void hitMnemonics(Robot robot, int... keys) {
+
+ ArrayList<Integer> mnemonicKeyCodes = getSystemMnemonicKeyCodes();
+ for (Integer mnemonic : mnemonicKeyCodes) {
+ robot.keyPress(mnemonic);
+ }
+
+ hitKeys(robot, keys);
+
+ for (Integer mnemonic : mnemonicKeyCodes) {
+ robot.keyRelease(mnemonic);
+ }
+ }
+
+ /**
* Hits keys by robot.
*/
public static void hitKeys(Robot robot, int... keys) {
diff --git a/test/sun/net/www/http/HttpClient/IsAvailable.java b/test/sun/net/www/http/HttpClient/IsAvailable.java
new file mode 100644
index 0000000..d6012a4
--- /dev/null
+++ b/test/sun/net/www/http/HttpClient/IsAvailable.java
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8009650
+ * @summary HttpClient available() check throws SocketException when connection
+ * has been closed
+ */
+
+import java.net.URL;
+import java.net.ServerSocket;
+import sun.net.www.http.HttpClient;
+import java.security.*;
+import java.lang.reflect.Method;
+
+public class IsAvailable {
+
+ public static void main(String[] args) throws Exception {
+ int readTimeout = 20;
+ ServerSocket ss = new ServerSocket(0);
+
+ URL url1 = new URL("http://localhost:" + ss.getLocalPort());
+ HttpClient c1 = HttpClient.New(url1);
+
+ Method available = HttpClient.class.
+ getDeclaredMethod("available", null);
+ available.setAccessible(true);
+
+ c1.setReadTimeout(readTimeout);
+ boolean a = (boolean) available.invoke(c1);
+ if (!a) {
+ throw new RuntimeException("connection should be available");
+ }
+ if (c1.getReadTimeout() != readTimeout) {
+ throw new RuntimeException("read timeout has been altered");
+ }
+
+ c1.closeServer();
+
+ a = (boolean) available.invoke(c1);
+ if (a) {
+ throw new RuntimeException("connection shouldn't be available");
+ }
+
+ ss.close();
+ }
+}
diff --git a/test/sun/security/krb5/auto/KDC.java b/test/sun/security/krb5/auto/KDC.java
index 83cafe7..44330df 100644
--- a/test/sun/security/krb5/auto/KDC.java
+++ b/test/sun/security/krb5/auto/KDC.java
@@ -923,29 +923,29 @@
pas2 = new DerValue[] {
new DerValue(new ETypeInfo2(1, null, null).asn1Encode()),
new DerValue(new ETypeInfo2(1, "", null).asn1Encode()),
- new DerValue(new ETypeInfo2(1, OneKDC.REALM, new byte[]{1}).asn1Encode()),
+ new DerValue(new ETypeInfo2(1, realm, new byte[]{1}).asn1Encode()),
};
pas = new DerValue[] {
new DerValue(new ETypeInfo(1, null).asn1Encode()),
new DerValue(new ETypeInfo(1, "").asn1Encode()),
- new DerValue(new ETypeInfo(1, OneKDC.REALM).asn1Encode()),
+ new DerValue(new ETypeInfo(1, realm).asn1Encode()),
};
break;
case 2: // we still reject non-null s2kparams and prefer E2 over E
pas2 = new DerValue[] {
- new DerValue(new ETypeInfo2(1, OneKDC.REALM, new byte[]{1}).asn1Encode()),
+ new DerValue(new ETypeInfo2(1, realm, new byte[]{1}).asn1Encode()),
new DerValue(new ETypeInfo2(1, null, null).asn1Encode()),
new DerValue(new ETypeInfo2(1, "", null).asn1Encode()),
};
pas = new DerValue[] {
- new DerValue(new ETypeInfo(1, OneKDC.REALM).asn1Encode()),
+ new DerValue(new ETypeInfo(1, realm).asn1Encode()),
new DerValue(new ETypeInfo(1, null).asn1Encode()),
new DerValue(new ETypeInfo(1, "").asn1Encode()),
};
break;
case 3: // but only E is wrong
pas = new DerValue[] {
- new DerValue(new ETypeInfo(1, OneKDC.REALM).asn1Encode()),
+ new DerValue(new ETypeInfo(1, realm).asn1Encode()),
new DerValue(new ETypeInfo(1, null).asn1Encode()),
new DerValue(new ETypeInfo(1, "").asn1Encode()),
};
diff --git a/test/sun/security/krb5/config/DefUdpLimit.java b/test/sun/security/krb5/config/DefUdpLimit.java
new file mode 100644
index 0000000..ae1712d
--- /dev/null
+++ b/test/sun/security/krb5/config/DefUdpLimit.java
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8009875
+ * @summary Provide a default udp_preference_limit for krb5.conf
+ * @compile -XDignore.symbol.file DefUdpLimit.java
+ * @run main/othervm DefUdpLimit -1 1465
+ * @run main/othervm DefUdpLimit 0 0
+ * @run main/othervm DefUdpLimit 1234 1234
+ * @run main/othervm DefUdpLimit 12345 12345
+ * @run main/othervm DefUdpLimit 123456 32700
+ *
+ */
+
+import sun.security.krb5.KdcComm;
+
+import java.lang.reflect.Field;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+public class DefUdpLimit {
+
+ public static void main(String[] args) throws Exception {
+ int set = Integer.valueOf(args[0]);
+ int expected = Integer.valueOf(args[1]);
+ Field f = KdcComm.class.getDeclaredField("defaultUdpPrefLimit");
+ f.setAccessible(true);
+ writeConf(set);
+ int actual = (Integer)f.get(null);
+ if (actual != expected) {
+ throw new Exception("Expected: " + expected + ", get " + actual);
+ }
+ }
+
+ static void writeConf(int i) throws Exception {
+ String file = "krb5.conf." + i;
+ String content = "[libdefaults]\n";
+ if (i >= 0) {
+ content += "udp_preference_limit = " + i;
+ }
+ Files.write(Paths.get(file), content.getBytes());
+ System.setProperty("java.security.krb5.conf", file);
+ }
+}
+
diff --git a/test/sun/security/krb5/name/Immutable.java b/test/sun/security/krb5/name/Immutable.java
new file mode 100644
index 0000000..04bed4b
--- /dev/null
+++ b/test/sun/security/krb5/name/Immutable.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8005460
+ * @summary [findbugs] Probably returned array should be cloned
+ */
+
+import sun.security.krb5.PrincipalName;
+
+public class Immutable {
+ public static void main(String[] args) throws Exception {
+ PrincipalName pn1 = new PrincipalName("host/service@REALM");
+ PrincipalName pn2 = (PrincipalName)pn1.clone();
+ pn1.getNameStrings()[0] = "http";
+ if (!pn1.equals(pn2)) {
+ throw new Exception();
+ }
+ }
+}
diff --git a/test/sun/security/pkcs/pkcs9/UnknownAttribute.java b/test/sun/security/pkcs/pkcs9/UnknownAttribute.java
new file mode 100644
index 0000000..20cc24e
--- /dev/null
+++ b/test/sun/security/pkcs/pkcs9/UnknownAttribute.java
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8011867
+ * @summary Accept unknown PKCS #9 attributes
+ */
+
+import java.io.*;
+import java.util.Arrays;
+
+import sun.misc.HexDumpEncoder;
+import sun.security.pkcs.PKCS9Attribute;
+import sun.security.util.DerValue;
+import sun.security.util.ObjectIdentifier;
+
+public class UnknownAttribute {
+
+ public static void main(String[] args) throws Exception {
+ // Unknown attr
+ PKCS9Attribute p1 = new PKCS9Attribute(
+ PKCS9Attribute.CHALLENGE_PASSWORD_STR, "t0p5ecr3t");
+ if (!p1.isKnown()) {
+ throw new Exception();
+ }
+ // Unknown attr from DER
+ byte[] data = {
+ 0x30, 0x08, // SEQUENCE OF
+ 0x06, 0x02, 0x2A, 0x03, // OID 1.2.3 and
+ 0x31, 0x02, 0x05, 0x00 // an empty SET
+ };
+ PKCS9Attribute p2 = new PKCS9Attribute(new DerValue(data));
+ if (p2.isKnown()) {
+ throw new Exception();
+ }
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ p2.derEncode(bout);
+ new HexDumpEncoder().encodeBuffer(bout.toByteArray(), System.err);
+ if (!Arrays.equals(data, bout.toByteArray())) {
+ throw new Exception();
+ }
+ // Unknown attr from value
+ try {
+ new PKCS9Attribute(new ObjectIdentifier("1.2.3"), "hello");
+ throw new Exception();
+ } catch (IllegalArgumentException iae) {
+ // Good. Unknown attr must have byte[] value type
+ }
+ PKCS9Attribute p3 = new PKCS9Attribute(
+ new ObjectIdentifier("1.2.3"), new byte[]{0x31,0x02,0x05,0x00});
+ if (p3.isKnown()) {
+ throw new Exception();
+ }
+ bout = new ByteArrayOutputStream();
+ p3.derEncode(bout);
+ if (!Arrays.equals(data, bout.toByteArray())) {
+ throw new Exception();
+ }
+ }
+}
diff --git a/test/sun/security/tools/keytool/p12importks.sh b/test/sun/security/tools/keytool/p12importks.sh
new file mode 100644
index 0000000..efdb56a
--- /dev/null
+++ b/test/sun/security/tools/keytool/p12importks.sh
@@ -0,0 +1,118 @@
+#
+# 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.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# @test
+# @bug 8010125
+# @summary keytool -importkeystore could create a pkcs12 keystore with
+# different storepass and keypass
+#
+
+if [ "${TESTJAVA}" = "" ] ; then
+ JAVAC_CMD=`which javac`
+ TESTJAVA=`dirname $JAVAC_CMD`/..
+fi
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+ Windows_* )
+ FS="\\"
+ ;;
+ * )
+ FS="/"
+ ;;
+esac
+
+LANG=C
+KT=$TESTJAVA${FS}bin${FS}keytool
+
+# Part 1: JKS keystore with same storepass and keypass
+
+rm jks 2> /dev/null
+$KT -genkeypair -keystore jks -storetype jks -alias me -dname CN=Me \
+ -storepass pass1111 -keypass pass1111 || exit 11
+
+# Cannot only change storepass
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt \
+ -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+ -srcstorepass pass1111 \
+ -deststorepass pass2222 \
+ && exit 12
+
+# You can keep storepass unchanged
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt \
+ -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+ -srcstorepass pass1111 \
+ -deststorepass pass1111 \
+ || exit 13
+$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
+ -storepass pass1111 -keypass pass1111 || exit 14
+
+# Or change storepass and keypass both
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt \
+ -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+ -srcstorepass pass1111 \
+ -deststorepass pass2222 -destkeypass pass2222 \
+ || exit 15
+$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
+ -storepass pass2222 -keypass pass2222 || exit 16
+
+# Part 2: JKS keystore with different storepass and keypass
+# Must import by alias (-srckeypass is not available when importing all)
+
+rm jks 2> /dev/null
+$KT -genkeypair -keystore jks -storetype jks -alias me -dname CN=Me \
+ -storepass pass1111 -keypass pass2222 || exit 21
+
+# Can use old keypass as new storepass so new storepass and keypass are same
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt -srcalias me \
+ -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+ -srcstorepass pass1111 -srckeypass pass2222 \
+ -deststorepass pass2222 \
+ || exit 22
+$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
+ -storepass pass2222 -keypass pass2222 || exit 23
+
+# Or specify both storepass and keypass to brand new ones
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt -srcalias me \
+ -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+ -srcstorepass pass1111 -srckeypass pass2222 \
+ -deststorepass pass3333 -destkeypass pass3333 \
+ || exit 24
+$KT -certreq -storetype pkcs12 -keystore p12 -alias me \
+ -storepass pass3333 -keypass pass3333 || exit 25
+
+# Anyway you cannot make new storepass and keypass different
+rm p12 2> /dev/null
+$KT -importkeystore -noprompt -srcalias me \
+ -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \
+ -srcstorepass pass1111 -srckeypass pass2222 \
+ -deststorepass pass1111 \
+ && exit 26
+
+exit 0
diff --git a/test/sun/tools/jstat/gcCapacityOutput1.awk b/test/sun/tools/jstat/gcCapacityOutput1.awk
index da3c756..c59de5f 100644
--- a/test/sun/tools/jstat/gcCapacityOutput1.awk
+++ b/test/sun/tools/jstat/gcCapacityOutput1.awk
@@ -3,19 +3,19 @@
# that the numerical values conform to a specific pattern, rather than
# specific values.
#
-# NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC PGCMN PGCMX PGC PC YGC FGC
-# 2176.0 7232.0 2176.0 64.0 64.0 2048.0 6016.0 58304.0 6016.0 6016.0 8192.0 65536.0 8192.0 8192.0 0 0
+# NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC MCMN MCMX MC YGC FGC
+# 2176.0 7232.0 2176.0 64.0 64.0 2048.0 6016.0 58304.0 6016.0 6016.0 8192.0 65536.0 8192.0 8192.0 0
BEGIN {
headerlines=0; datalines=0; totallines=0
}
-/^ NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC PGCMN PGCMX PGC PC YGC FGC $/ {
+/^ NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC MCMN MCMX MC YGC FGC $/ {
headerlines++;
}
-/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+$/ {
+/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+$/ {
datalines++;
}
diff --git a/test/sun/tools/jstat/gcCauseOutput1.awk b/test/sun/tools/jstat/gcCauseOutput1.awk
index 0219697..973d2c0 100644
--- a/test/sun/tools/jstat/gcCauseOutput1.awk
+++ b/test/sun/tools/jstat/gcCauseOutput1.awk
@@ -11,7 +11,7 @@
headerlines=0; datalines=0; totallines=0
}
-/^ S0 S1 E O P YGC YGCT FGC FGCT GCT LGCC GCC $/ {
+/^ S0 S1 E O M YGC YGCT FGC FGCT GCT LGCC GCC $/ {
headerlines++;
}
diff --git a/test/sun/tools/jstat/gcPermCapacityOutput1.awk b/test/sun/tools/jstat/gcMetaCapacityOutput1.awk
similarity index 71%
rename from test/sun/tools/jstat/gcPermCapacityOutput1.awk
rename to test/sun/tools/jstat/gcMetaCapacityOutput1.awk
index 5d41c2f..c015dd6 100644
--- a/test/sun/tools/jstat/gcPermCapacityOutput1.awk
+++ b/test/sun/tools/jstat/gcMetaCapacityOutput1.awk
@@ -3,18 +3,18 @@
# that the numerical values conform to a specific pattern, rather than
# specific values.
#
-# PGCMN PGCMX PGC PC YGC FGC FGCT GCT
+# MCMN MCMX MC YGC FGC FGCT GCT
# 8192.0 65536.0 8192.0 8192.0 1 0 0.000 0.029
BEGIN {
headerlines=0; datalines=0; totallines=0
}
-/^ PGCMN PGCMX PGC PC YGC FGC FGCT GCT $/ {
+/^ MCMN MCMX MC YGC FGC FGCT GCT $/ {
headerlines++;
}
-/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ {
+/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ {
datalines++;
}
diff --git a/test/sun/tools/jstat/gcOldOutput1.awk b/test/sun/tools/jstat/gcOldOutput1.awk
index 3c1e368..df7c6b5 100644
--- a/test/sun/tools/jstat/gcOldOutput1.awk
+++ b/test/sun/tools/jstat/gcOldOutput1.awk
@@ -3,7 +3,7 @@
# that the numerical values conform to a specific pattern, rather than
# specific values.
#
-# PC PU OC OU YGC FGC FGCT GCT
+# MC MU OC OU YGC FGC FGCT GCT
# 8192.0 1877.3 6016.0 180.8 1 0 0.000 0.030
@@ -11,7 +11,7 @@
headerlines=0; datalines=0; totallines=0
}
-/^ PC PU OC OU YGC FGC FGCT GCT $/ {
+/^ MC MU OC OU YGC FGC FGCT GCT $/ {
headerlines++;
}
diff --git a/test/sun/tools/jstat/gcOutput1.awk b/test/sun/tools/jstat/gcOutput1.awk
index bfad48f..5ac5b28 100644
--- a/test/sun/tools/jstat/gcOutput1.awk
+++ b/test/sun/tools/jstat/gcOutput1.awk
@@ -3,7 +3,7 @@
# that the numerical values conform to a specific pattern, rather than
# specific values.
#
-# S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
+# S0C S1C S0U S1U EC EU OC OU MC MU YGC YGCT FGC FGCT GCT
# 64.0 64.0 0.0 0.0 2048.0 1711.2 6016.0 0.0 8192.0 1948.6 0 0.000 0 0.000 0.000
@@ -11,7 +11,7 @@
headerlines=0; datalines=0; totallines=0
}
-/^ S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT $/ {
+/^ S0C S1C S0U S1U EC EU OC OU MC MU YGC YGCT FGC FGCT GCT $/ {
headerlines++;
}
diff --git a/test/sun/tools/jstat/jstatGcPermCapacityOutput1.sh b/test/sun/tools/jstat/jstatGcMetaCapacityOutput1.sh
similarity index 78%
rename from test/sun/tools/jstat/jstatGcPermCapacityOutput1.sh
rename to test/sun/tools/jstat/jstatGcMetaCapacityOutput1.sh
index 04754fe..85aece1 100644
--- a/test/sun/tools/jstat/jstatGcPermCapacityOutput1.sh
+++ b/test/sun/tools/jstat/jstatGcMetaCapacityOutput1.sh
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 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
@@ -23,8 +23,8 @@
# @test
# @bug 4990825
-# @run shell jstatGcPermCapacityOutput1.sh
-# @summary Test that output of 'jstat -gcpermcapcaity 0' has expected line counts
+# @run shell jstatGcMetaCapacityOutput1.sh
+# @summary Test that output of 'jstat -gcmetacapacity 0' has expected line counts
. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
@@ -33,4 +33,4 @@
JSTAT="${TESTJAVA}/bin/jstat"
-${JSTAT} -J-XX:+UsePerfData -J-Duser.language=en -gcpermcapacity 0 2>&1 | awk -f ${TESTSRC}/gcPermCapacityOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -J-Duser.language=en -gcmetacapacity 0 2>&1 | awk -f ${TESTSRC}/gcMetaCapacityOutput1.awk
diff --git a/test/sun/tools/jstat/lineCounts1.awk b/test/sun/tools/jstat/lineCounts1.awk
index 4c1974d..33b2f08 100644
--- a/test/sun/tools/jstat/lineCounts1.awk
+++ b/test/sun/tools/jstat/lineCounts1.awk
@@ -3,7 +3,7 @@
# that the numerical values conform to a specific pattern, rather than
# specific values.
#
-# S0 S1 E O P YGC YGCT FGC FGCT GCT
+# S0 S1 E O M YGC YGCT FGC FGCT GCT
# 0.00 100.00 68.87 1.24 27.75 1 0.044 0 0.000 0.044
# 0.00 100.00 68.87 1.24 27.84 1 0.044 0 0.000 0.044
# 0.00 100.00 68.87 1.24 27.84 1 0.044 0 0.000 0.044
@@ -14,7 +14,7 @@
headerlines=0; datalines=0; totallines=0
}
-/^ S0 S1 E O P YGC YGCT FGC FGCT GCT $/ {
+/^ S0 S1 E O M YGC YGCT FGC FGCT GCT $/ {
headerlines++;
}
diff --git a/test/sun/tools/jstat/lineCounts2.awk b/test/sun/tools/jstat/lineCounts2.awk
index 51e3184..b1e8048 100644
--- a/test/sun/tools/jstat/lineCounts2.awk
+++ b/test/sun/tools/jstat/lineCounts2.awk
@@ -3,14 +3,14 @@
# that the numerical values conform to a specific pattern, rather than
# specific values.
#
-# S0 S1 E O P YGC YGCT FGC FGCT GCT
+# S0 S1 E O M YGC YGCT FGC FGCT GCT
# 0.00 100.00 68.87 1.24 27.75 1 0.044 0 0.000 0.044
BEGIN {
headerlines=0; datalines=0; totallines=0
}
-/^ S0 S1 E O P YGC YGCT FGC FGCT GCT $/ {
+/^ S0 S1 E O M YGC YGCT FGC FGCT GCT $/ {
headerlines++;
}
diff --git a/test/sun/tools/jstat/lineCounts3.awk b/test/sun/tools/jstat/lineCounts3.awk
index c50db50..e7c362f 100644
--- a/test/sun/tools/jstat/lineCounts3.awk
+++ b/test/sun/tools/jstat/lineCounts3.awk
@@ -3,7 +3,7 @@
# that the numerical values conform to a specific pattern, rather than
# specific values.
#
-# S0 S1 E O P YGC YGCT FGC FGCT GCT
+# S0 S1 E O M YGC YGCT FGC FGCT GCT
# 0.00 99.99 66.81 1.24 26.55 1 0.028 0 0.000 0.028
# 0.00 99.99 68.81 1.24 27.84 1 0.028 0 0.000 0.028
# 0.00 99.99 70.81 1.24 27.84 1 0.028 0 0.000 0.028
@@ -19,7 +19,7 @@
headerlines=0; datalines=0; totallines=0
}
-/^ S0 S1 E O P YGC YGCT FGC FGCT GCT $/ {
+/^ S0 S1 E O M YGC YGCT FGC FGCT GCT $/ {
headerlines++;
}
diff --git a/test/sun/tools/jstat/lineCounts4.awk b/test/sun/tools/jstat/lineCounts4.awk
index 3a36b11..af9487e 100644
--- a/test/sun/tools/jstat/lineCounts4.awk
+++ b/test/sun/tools/jstat/lineCounts4.awk
@@ -3,7 +3,7 @@
# that the numerical values conform to a specific pattern, rather than
# specific values.
#
-# S0 S1 E O P YGC YGCT FGC FGCT GCT
+# S0 S1 E O M YGC YGCT FGC FGCT GCT
# 0.00 99.99 66.81 1.24 26.55 1 0.028 0 0.000 0.028
# 0.00 99.99 68.81 1.24 27.84 1 0.028 0 0.000 0.028
# 0.00 99.99 70.81 1.24 27.84 1 0.028 0 0.000 0.028
@@ -22,7 +22,7 @@
datalines2=0;
}
-/^ S0 S1 E O P YGC YGCT FGC FGCT GCT $/ {
+/^ S0 S1 E O M YGC YGCT FGC FGCT GCT $/ {
headerlines++;
}
diff --git a/test/sun/tools/jstat/options1.out b/test/sun/tools/jstat/options1.out
index e6eaf66..18c2162 100644
--- a/test/sun/tools/jstat/options1.out
+++ b/test/sun/tools/jstat/options1.out
@@ -3,10 +3,10 @@
-gc
-gccapacity
-gccause
+-gcmetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
--gcpermcapacity
-gcutil
-printcompilation
diff --git a/test/sun/tools/jstat/options2.out b/test/sun/tools/jstat/options2.out
index 5d05d60..27da99b 100644
--- a/test/sun/tools/jstat/options2.out
+++ b/test/sun/tools/jstat/options2.out
@@ -4,10 +4,10 @@
-gc
-gccapacity
-gccause
+-gcmetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
--gcpermcapacity
-gcutil
-printcompilation
diff --git a/test/sun/tools/jstat/timeStamp1.awk b/test/sun/tools/jstat/timeStamp1.awk
index 907198b..825101b 100644
--- a/test/sun/tools/jstat/timeStamp1.awk
+++ b/test/sun/tools/jstat/timeStamp1.awk
@@ -3,14 +3,14 @@
# that the numerical values conform to a specific pattern, rather than
# specific values.
#
-# S0 S1 E O P YGC YGCT FGC FGCT GCT
+# S0 S1 E O M YGC YGCT FGC FGCT GCT
# 0.00 100.00 68.87 1.24 27.75 1 0.044 0 0.000 0.044
BEGIN {
headerlines=0; datalines=0; totallines=0
}
-/^Timestamp S0 S1 E O P YGC YGCT FGC FGCT GCT $/ {
+/^Timestamp S0 S1 E O M YGC YGCT FGC FGCT GCT $/ {
headerlines++;
}
diff --git a/test/sun/tools/jstatd/jstatGcutilOutput1.awk b/test/sun/tools/jstatd/jstatGcutilOutput1.awk
index 4c1974d..33b2f08 100644
--- a/test/sun/tools/jstatd/jstatGcutilOutput1.awk
+++ b/test/sun/tools/jstatd/jstatGcutilOutput1.awk
@@ -3,7 +3,7 @@
# that the numerical values conform to a specific pattern, rather than
# specific values.
#
-# S0 S1 E O P YGC YGCT FGC FGCT GCT
+# S0 S1 E O M YGC YGCT FGC FGCT GCT
# 0.00 100.00 68.87 1.24 27.75 1 0.044 0 0.000 0.044
# 0.00 100.00 68.87 1.24 27.84 1 0.044 0 0.000 0.044
# 0.00 100.00 68.87 1.24 27.84 1 0.044 0 0.000 0.044
@@ -14,7 +14,7 @@
headerlines=0; datalines=0; totallines=0
}
-/^ S0 S1 E O P YGC YGCT FGC FGCT GCT $/ {
+/^ S0 S1 E O M YGC YGCT FGC FGCT GCT $/ {
headerlines++;
}
diff --git a/test/sun/util/logging/PlatformLoggerTest.java b/test/sun/util/logging/PlatformLoggerTest.java
index 2501887..ac399c0 100644
--- a/test/sun/util/logging/PlatformLoggerTest.java
+++ b/test/sun/util/logging/PlatformLoggerTest.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6882376 6985460
+ * @bug 6882376 6985460 8010309
* @summary Test if java.util.logging.Logger is created before and after
* logging is enabled. Also validate some basic PlatformLogger
* operations. othervm mode to make sure java.util.logging
@@ -33,11 +33,12 @@
* @run main/othervm PlatformLoggerTest
*/
+import java.lang.reflect.Field;
import java.util.logging.*;
import sun.util.logging.PlatformLogger;
+import static sun.util.logging.PlatformLogger.Level.*;
public class PlatformLoggerTest {
- private static final int defaultEffectiveLevel = 0;
public static void main(String[] args) throws Exception {
final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo";
final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar";
@@ -69,41 +70,65 @@
checkLogger(GOO_PLATFORM_LOGGER, null);
checkLogger(BAR_LOGGER, Level.WARNING);
- foo.setLevel(PlatformLogger.SEVERE);
+ foo.setLevel(PlatformLogger.Level.SEVERE);
checkLogger(FOO_PLATFORM_LOGGER, Level.SEVERE);
+ checkPlatformLoggerLevels(foo, bar);
}
+ // don't use java.util.logging here to prevent it from initialized
private static void checkPlatformLogger(PlatformLogger logger, String name) {
if (!logger.getName().equals(name)) {
throw new RuntimeException("Invalid logger's name " +
logger.getName() + " but expected " + name);
}
- if (logger.getLevel() != defaultEffectiveLevel) {
+ if (logger.level() != null) {
throw new RuntimeException("Invalid default level for logger " +
- logger.getName());
+ logger.getName() + ": " + logger.level());
}
- if (logger.isLoggable(PlatformLogger.FINE) != false) {
- throw new RuntimeException("isLoggerable(FINE) returns true for logger " +
- logger.getName() + " but expected false");
- }
+ checkLoggable(logger, FINE, false);
- logger.setLevel(PlatformLogger.FINER);
- if (logger.getLevel() != Level.FINER.intValue()) {
- throw new RuntimeException("Invalid level for logger " +
- logger.getName() + " " + logger.getLevel());
- }
-
- if (logger.isLoggable(PlatformLogger.FINE) != true) {
- throw new RuntimeException("isLoggerable(FINE) returns false for logger " +
- logger.getName() + " but expected true");
- }
+ logger.setLevel(FINER);
+ checkLevel(logger, FINER);
+ checkLoggable(logger, FINER, true);
+ checkLoggable(logger, FINE, true);
+ checkLoggable(logger, FINEST, false);
logger.info("OK: Testing log message");
}
+ private static void checkLoggable(PlatformLogger logger, PlatformLogger.Level level, boolean expected) {
+ if (logger.isLoggable(level) != expected) {
+ throw new RuntimeException("logger " + logger.getName() + ": " + level +
+ (expected ? " not loggable" : " loggable"));
+ }
+
+ if (logger.isLoggable(level.intValue()) != expected) {
+ throw new RuntimeException("logger " + logger.getName() + ": " + level.intValue() +
+ (expected ? " not loggable" : " loggable"));
+ }
+
+ int value = level.intValue() + 5; // custom level value
+ if (expected && !logger.isLoggable(value)) {
+ throw new RuntimeException("logger " + logger.getName() + ": " + value +
+ " not loggable");
+ }
+ }
+
+ private static void checkLevel(PlatformLogger logger, PlatformLogger.Level level) {
+ if (logger.level() != level) {
+ throw new RuntimeException("Invalid level for logger " +
+ logger.getName() + ": " + logger.level() + " != " + level);
+ }
+
+ if (logger.getLevel() != level.intValue()) {
+ throw new RuntimeException("Invalid level for logger " +
+ logger.getName() + ": " + logger.getLevel() + " != " + level.intValue());
+ }
+ }
+
private static void checkLogger(String name, Level level) {
Logger logger = LogManager.getLogManager().getLogger(name);
if (logger == null) {
@@ -125,6 +150,81 @@
logger.info("Test info(String)");
}
+ private static void checkPlatformLoggerLevels(PlatformLogger... loggers) {
+ final Level[] levels = new Level[] {
+ Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST,
+ Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING
+ };
+
+ int count = PlatformLogger.Level.values().length;
+ if (levels.length != count) {
+ throw new RuntimeException("There are " + count +
+ " PlatformLogger.Level members, but " + levels.length +
+ " standard java.util.logging levels - the numbers should be equal.");
+ }
+ // check mappings
+ for (Level level : levels) {
+ checkPlatformLoggerLevelMapping(level);
+ }
+
+ for (Level level : levels) {
+ PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName());
+ for (PlatformLogger logger : loggers) {
+ logger.setLevel(platformLevel); // setLevel(PlatformLogger.Level)
+ checkLoggerLevel(logger, level);
+
+ logger.setLevel(ALL); // setLevel(int)
+ checkLoggerLevel(logger, Level.ALL);
+ }
+ }
+ }
+
+ private static void checkLoggerLevel(PlatformLogger logger, Level level) {
+ PlatformLogger.Level plevel = PlatformLogger.Level.valueOf(level.getName());
+ if (plevel != logger.level()) {
+ throw new RuntimeException("Retrieved PlatformLogger level "
+ + logger.level()
+ + " is not the same as set level " + plevel);
+ }
+
+ // check the level set in java.util.logging.Logger
+ Logger javaLogger = LogManager.getLogManager().getLogger(logger.getName());
+ Level javaLevel = javaLogger.getLevel();
+ if (javaLogger.getLevel() != level) {
+ throw new RuntimeException("Retrieved backing java.util.logging.Logger level "
+ + javaLevel + " is not the expected " + level);
+ }
+ }
+
+ private static void checkPlatformLoggerLevelMapping(Level level) {
+ // map the given level to PlatformLogger.Level of the same name and value
+ PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName());
+ if (platformLevel.intValue() != level.intValue()) {
+ throw new RuntimeException("Mismatched level: " + level
+ + " PlatformLogger.Level" + platformLevel);
+ }
+
+ try {
+ // validate if there is a public static final field in PlatformLogger
+ Field constantField = PlatformLogger.class.getField(level.getName());
+ int l = (int) constantField.get(null);
+ if (l != platformLevel.intValue()) {
+ throw new RuntimeException("static final " + level.getName() + " (" +
+ l + ") != " + platformLevel.intValue());
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("No public static PlatformLogger." + level.getName() +
+ " field", e);
+ }
+ if (!platformLevel.name().equals(level.getName()))
+ throw new RuntimeException("The value of PlatformLogger." + level.getName() + ".name() is "
+ + platformLevel.name() + " but expected " + level.getName());
+
+ if (platformLevel.intValue() != level.intValue())
+ throw new RuntimeException("The value of PlatformLogger." + level.intValue() + ".intValue() is "
+ + platformLevel.intValue() + " but expected " + level.intValue());
+ }
+
static Point[] getPoints() {
Point[] res = new Point[3];
res[0] = new Point(0,0);
diff --git a/test/vm/verifier/TestStaticIF.java b/test/vm/verifier/TestStaticIF.java
index 5a6776f..d3c3239 100644
--- a/test/vm/verifier/TestStaticIF.java
+++ b/test/vm/verifier/TestStaticIF.java
@@ -26,7 +26,7 @@
* @test
* @bug 8007736
* @summary Test static interface method.
- * @run main/othervm -Xverify:all -XX:-UseSplitVerifier TestStaticIF
+ * @run main/othervm -Xverify:all TestStaticIF
*/
public class TestStaticIF implements StaticMethodInInterface {