diff --git a/.hgtags b/.hgtags index 898e4a75668c25e209d91df689d7d6463da590b1..3bcfa342d461f0a75265c7074175b8eeab786ca4 100644 --- a/.hgtags +++ b/.hgtags @@ -1 +1,3 @@ 37a05a11f281b4d238e2f9e7ebb67c63f64d0e77 jdk7-b24 +75fca0b0ab83ab1392e615910cea020f66535390 jdk7-b25 +fb57027902e04ecafceae31a605e69b436c23d57 jdk7-b26 diff --git a/make/com/sun/Makefile b/make/com/sun/Makefile index de9f1a779327f824c3c407bc32d7a5c75d9f303c..10a8642c81724605e9f210ca0b0e8ae2c92282ed 100644 --- a/make/com/sun/Makefile +++ b/make/com/sun/Makefile @@ -41,7 +41,7 @@ endif # Omit mirror since it's built with the apt tool. SUBDIRS = $(SCRIPT_SUBDIR) image security crypto/provider jndi jmx \ java inputmethods org xml rowset net/httpserver net/ssl demo \ - tools jarsigner + tools jarsigner tracing all build clean clobber:: $(SUBDIRS-loop) diff --git a/make/com/sun/crypto/provider/Makefile b/make/com/sun/crypto/provider/Makefile index 3d948d03537bd156729be9691470f48ef4914d8a..64e4320b19a90dba7e346fb9746847c1a18e9d69 100644 --- a/make/com/sun/crypto/provider/Makefile +++ b/make/com/sun/crypto/provider/Makefile @@ -1,5 +1,5 @@ # -# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2007-2008 Sun Microsystems, 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 @@ -87,8 +87,7 @@ # sign Alias for sign-jar # sign-jar Builds/signs sunjce_provider.jar (no install) # -# obfus Builds/obfuscates/signs/installs -# sunjce_provider.jar +# obfus Builds/obfuscates/signs sunjce_provider.jar # # release Builds all targets in preparation # for workspace integration. @@ -101,8 +100,25 @@ BUILDDIR = ../../../.. PACKAGE = com.sun.crypto.provider PRODUCT = sun + +# +# The following is for when we need to do postprocessing +# (signing/obfuscation) against a read-only build. If the OUTPUTDIR +# isn't writable, the build currently crashes out. +# +ifndef OPENJDK + ifdef ALT_JCE_BUILD_DIR + # ===================================================== + # Where to place the output, in case we're building from a read-only + # build area. (e.g. a release engineering build.) + JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR} + IGNORE_WRITABLE_OUTPUTDIR_TEST=true + else + JCE_BUILD_DIR=${TEMPDIR} + endif +endif + include $(BUILDDIR)/common/Defs.gmk -include $(BUILDDIR)/javax/crypto/Defs-jce.gmk # # Location for the newly built classfiles. @@ -147,6 +163,8 @@ endif # OPENJDK # UNSIGNED_DIR = $(TEMPDIR)/unsigned +include $(BUILDDIR)/javax/crypto/Defs-jce.gmk + # ===================================================== # Build the unsigned sunjce_provider.jar file. @@ -184,44 +202,66 @@ ifndef OPENJDK # Sign the provider jar file. Not needed for OpenJDK. # -SIGNED_DIR = $(TEMPDIR)/signed +SIGNED_DIR = $(JCE_BUILD_DIR)/signed sign: sign-jar sign-jar: $(SIGNED_DIR)/sunjce_provider.jar +ifndef ALT_JCE_BUILD_DIR $(SIGNED_DIR)/sunjce_provider.jar: $(UNSIGNED_DIR)/sunjce_provider.jar - $(sign-file) +else +# +# We have to remove the build dependency, otherwise, we'll try to rebuild it +# which we can't do on a read-only filesystem. +# +$(SIGNED_DIR)/sunjce_provider.jar: + @if [ ! -r $(UNSIGNED_DIR)/sunjce_provider.jar ] ; then \ + $(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunjce_provider.jar"; \ + exit 1; \ + fi +endif + $(call sign-file, $(UNSIGNED_DIR)/sunjce_provider.jar) # ===================================================== # Obfuscate/sign/install the JDK build. Not needed for OpenJDK. # -OBFUS_DIR = $(TEMPDIR)/obfus +OBFUS_DIR = $(JCE_BUILD_DIR)/obfus/sunjce CLOSED_DIR = $(BUILDDIR)/closed/com/sun/crypto/provider obfus: $(OBFUS_DIR)/sunjce_provider.jar $(release-warning) -$(OBFUS_DIR)/sunjce_provider.jar: build-jar $(JCE_MANIFEST_FILE) +ifndef ALT_JCE_BUILD_DIR +$(OBFUS_DIR)/sunjce_provider.jar: build-jar $(JCE_MANIFEST_FILE) \ + $(OBFUS_DIR)/sunjce.dox +else +$(OBFUS_DIR)/sunjce_provider.jar: $(JCE_MANIFEST_FILE) $(OBFUS_DIR)/sunjce.dox + @if [ ! -d $(CLASSDESTDIR) ] ; then \ + $(ECHO) "Couldn't find $(CLASSDESTDIR)"; \ + exit 1; \ + fi +endif + @$(ECHO) ">>>Obfuscating SunJCE Provider..." $(presign) $(preobfus) - @$(ECHO) ">>>Obfuscating Sun JCE Provider..." $(prep-target) $(CD) $(OBFUS_DIR); \ - $(OBFUSCATOR) -fv \ - $(CURRENT_DIRECTORY)/$(CLOSED_DIR)/obfus/sunjce.dox + $(OBFUSCATOR) -fv sunjce.dox @$(CD) $(OBFUS_DIR); $(java-vm-cleanup) $(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ \ -C $(OBFUS_DIR)/build com \ $(JAR_JFLAGS) $(sign-target) - $(MKDIR) -p $(dir $(JAR_DESTFILE)) - $(RM) $(JAR_DESTFILE) - $(CP) $@ $(JAR_DESTFILE) @$(java-vm-cleanup) +$(OBFUS_DIR)/sunjce.dox: $(CLOSED_DIR)/obfus/sunjce.dox + @$(ECHO) ">>>Creating sunjce.dox" + $(prep-target) + $(SED) "s:@@TEMPDIR@@:$(ABS_TEMPDIR):" $< > $@ + # # The current obfuscator has a limitation in that it currently only # supports up to v49 class file format. Force v49 classfiles in our @@ -235,9 +275,9 @@ TARGET_CLASS_VERSION = 5 # release: $(OBFUS_DIR)/sunjce_provider.jar - $(RM) $(RELEASE_DIR)/sunjce_provider.jar - $(MKDIR) -p $(RELEASE_DIR) - $(CP) $(OBFUS_DIR)/sunjce_provider.jar $(RELEASE_DIR) + $(RM) $(JCE_BUILD_DIR)/release/sunjce_provider.jar + $(MKDIR) -p $(JCE_BUILD_DIR)/release + $(CP) $(OBFUS_DIR)/sunjce_provider.jar $(JCE_BUILD_DIR)/release $(release-warning) endif # OPENJDK @@ -275,7 +315,7 @@ endif # clobber clean:: - $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) + $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR) .PHONY: build-jar jar install-jar ifndef OPENJDK diff --git a/make/com/sun/tracing/Makefile b/make/com/sun/tracing/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..5ba19240244a1b466a8bf539f9232deb585bb46a --- /dev/null +++ b/make/com/sun/tracing/Makefile @@ -0,0 +1,26 @@ +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. +# + +# +# Makefile for building tracing classes +# + +BUILDDIR = ../../.. +PACKAGE = com.sun.tracing +PRODUCT = sun +include $(BUILDDIR)/common/Defs.gmk + +SUBDIRS = dtrace +all build: + $(SUBDIRS-loop) +clean clobber:: + $(SUBDIRS-loop) + +AUTO_FILES_JAVA_DIRS = com/sun/tracing + +# +# Rules. +# +include $(BUILDDIR)/common/Classes.gmk diff --git a/make/com/sun/tracing/dtrace/Makefile b/make/com/sun/tracing/dtrace/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..63ac588b50f329b130a04bd61b7f7a0a7c1fc18f --- /dev/null +++ b/make/com/sun/tracing/dtrace/Makefile @@ -0,0 +1,19 @@ +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. +# + +# +# Makefile for building dtrace extension +# +BUILDDIR = ../../../.. +PACKAGE = com.sun.tracing.dtrace +PRODUCT = sun +include $(BUILDDIR)/common/Defs.gmk + +AUTO_FILES_JAVA_DIRS = com/sun/tracing/dtrace + +# +# Rules. +# +include $(BUILDDIR)/common/Classes.gmk diff --git a/make/common/Defs-linux.gmk b/make/common/Defs-linux.gmk index 51d638f96ab8f66a0b259565bb0540b15cf10254..674b6f6a0e69717974b92813bdf24b98410d16e3 100644 --- a/make/common/Defs-linux.gmk +++ b/make/common/Defs-linux.gmk @@ -50,13 +50,13 @@ CC_DEPEND = -MM CC_DEPEND_FILTER = $(SED) -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)& $(dir $@)$*.$(DEPEND_SUFFIX)!g' ifndef PLATFORM_SRC - PLATFORM_SRC = $(JDK_TOPDIR)/src/solaris + PLATFORM_SRC = $(BUILDDIR)/../src/solaris endif # PLATFORM_SRC # Platform specific closed sources ifndef OPENJDK ifndef CLOSED_PLATFORM_SRC - CLOSED_PLATFORM_SRC = $(JDK_TOPDIR)/src/closed/solaris + CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris endif endif diff --git a/make/common/Defs-solaris.gmk b/make/common/Defs-solaris.gmk index 800c0b75ddbe2b90ebc06e76f82282c28dab19dd..052c0c88fc810b9ea7fcd0102709e980c9ca4d4b 100644 --- a/make/common/Defs-solaris.gmk +++ b/make/common/Defs-solaris.gmk @@ -45,13 +45,13 @@ include $(JDK_MAKE_SHARED_DIR)/Defs.gmk ifndef PLATFORM_SRC -PLATFORM_SRC = $(JDK_TOPDIR)/src/solaris +PLATFORM_SRC = $(BUILDDIR)/../src/solaris endif # PLATFORM_SRC # Platform specific closed sources ifndef OPENJDK ifndef CLOSED_PLATFORM_SRC - CLOSED_PLATFORM_SRC = $(JDK_TOPDIR)/src/closed/solaris + CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris endif endif diff --git a/make/common/Defs-windows.gmk b/make/common/Defs-windows.gmk index 6f53eb72f3bb52ea25fef3d72227c1579390a759..e9bdea85278ecaab844c89f706c817bf813f60a1 100644 --- a/make/common/Defs-windows.gmk +++ b/make/common/Defs-windows.gmk @@ -51,13 +51,13 @@ ifndef LIB_LOCATION endif # LIB_LOCATION ifndef PLATFORM_SRC - PLATFORM_SRC = $(JDK_TOPDIR)/src/windows + PLATFORM_SRC = $(BUILDDIR)/../src/windows endif # PLATFORM_SRC # Platform specific closed sources ifndef OPENJDK ifndef CLOSED_PLATFORM_SRC - CLOSED_PLATFORM_SRC = $(JDK_TOPDIR)/src/closed/windows + CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/windows endif endif @@ -367,7 +367,7 @@ else endif # Settings for the VERSIONINFO tap on windows. -VERSIONINFO_RESOURCE = $(JDK_TOPDIR)/src/windows/resource/version.rc +VERSIONINFO_RESOURCE = $(BUILDDIR)/../src/windows/resource/version.rc ifneq ($(JDK_BUILD_NUMBER),) COOKED_BUILD_NUMBER = $(shell $(ECHO) $(JDK_BUILD_NUMBER) | $(SED) -e 's/^b//' -e 's/^0//') diff --git a/make/common/Defs.gmk b/make/common/Defs.gmk index 9dd781b2f7e428fe4547437b833a42f0e5c4917a..e83095ae9179b2a82d8abc5e1ddfc84dfd09785a 100644 --- a/make/common/Defs.gmk +++ b/make/common/Defs.gmk @@ -32,6 +32,13 @@ # So when it includes other files, it must use JDK_TOPDIR. # +# Check for strange explicit settings (change to empty or true) +ifdef OPENJDK + ifneq ($(OPENJDK),true) + x:=$(error "OPENJDK (if defined) can only be set to true") + endif +endif + # # On Solaris, the 'make' utility from Sun will not work with these makefiles. # This little rule is only understood by Sun's make, and is harmless @@ -41,7 +48,15 @@ SUN_MAKE_TEST:sh = echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33 ifndef JDK_TOPDIR - JDK_TOPDIR=$(BUILDDIR)/.. + ifdef BUILDDIR + JDK_TOPDIR=$(BUILDDIR)/.. + else + JDK_TOPDIR:=$(error "ERROR: Cannot define top of jdk repository") + endif +endif +ifndef BUILDDIR + # Hack, due to deploy repository using this file. + BUILDDIR=$(JDK_TOPDIR)/make endif ifndef JDK_MAKE_SHARED_DIR JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared @@ -59,13 +74,13 @@ include $(JDK_TOPDIR)/make/common/CancelImplicits.gmk # there yet. # ifndef SHARE_SRC - SHARE_SRC = $(JDK_TOPDIR)/src/share + SHARE_SRC = $(BUILDDIR)/../src/share endif # Files that cannot be included in the OpenJDK distribution are # collected under a parent directory which contains just those files. ifndef CLOSED_SRC - CLOSED_SRC = $(JDK_TOPDIR)/src/closed + CLOSED_SRC = $(BUILDDIR)/../src/closed endif # If we have no closed directory, force it to an openjdk build @@ -79,19 +94,6 @@ ifeq ($(CLOSED_SRC_DIR_EXISTS), false) OPENJDK = true endif -# Check for strange explicit settings (change to empty or true) -ifdef OPENJDK - ifeq ($(OPENJDK),false) - # Silently treat as not defined - OPENJDK = - else - ifneq ($(OPENJDK),true) - dummy := $(warning "WARNING: OPENKJDK=$(OPENJDK) being treated as true") - OPENJDK = true - endif - endif -endif - # Define where closed directories are ifdef OPENJDK CLOSED_SRC = @@ -170,14 +172,6 @@ ifdef OPENJDK endif endif # OPENJDK -# Default output directory -ifdef OPENJDK -_OUTPUTDIR=$(JDK_TOPDIR)/build/$(PLATFORM)-$(ARCH)$(OPENJDK_SUFFIX) -else -_OUTPUTDIR=$(JDK_TOPDIR)/build/$(PLATFORM)-$(ARCH) -endif - - # # Get platform definitions # @@ -309,6 +303,8 @@ BUILDTOOLCLASSDIR = $(OUTPUTDIR)/btclasses # for build tool jar files BUILDTOOLJARDIR = $(OUTPUTDIR)/btjars ABS_BUILDTOOLJARDIR = $(ABS_OUTPUTDIR)/btjars +# for generated tool class files +BUILDTOOLBINDIR = $(OUTPUTDIR)/btbins # for generated java source files GENSRCDIR = $(OUTPUTDIR)/gensrc # for generated C source files (not javah) diff --git a/make/common/Rules.gmk b/make/common/Rules.gmk index 6fb7ca1cf00ca4570c296d48ff0b46cc99be6acf..5325eeaedfecbb875d772cf223a56da35a43602f 100644 --- a/make/common/Rules.gmk +++ b/make/common/Rules.gmk @@ -231,12 +231,14 @@ classes : $(CLASSES_INIT) .delete.classlist .compile.classlist .compile.classlist : $(JAVA_SOURCE_LIST) @$(MKDIR) -p $(CLASSDESTDIR) - @if [ `$(CAT) $(JAVA_SOURCE_LIST) | $(WC) -l` -ge 1 ] ; then \ - $(ECHO) "# Java sources to be compiled: (listed in file $(JAVA_SOURCE_LIST))"; \ - $(CAT) $(JAVA_SOURCE_LIST); \ + @$(RM) $<.filtered + @$(CAT) $< | $(NAWK) 'length>0' | $(SORT) -u > $<.filtered + @if [ `$(CAT) $<.filtered | $(WC) -l` -ge 1 ] ; then \ + $(ECHO) "# Java sources to be compiled: (listed in file $<)"; \ + $(CAT) $<.filtered; \ $(ECHO) "# Running javac:"; \ - $(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \ - $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \ + $(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \ + $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \ fi @$(java-vm-cleanup) diff --git a/make/common/shared/Compiler-gcc.gmk b/make/common/shared/Compiler-gcc.gmk index 74f9807e09d9d949088017ace192e60a64cfc0ae..d12adac959ecb4aac4a917f6cdd73b36bcb89869 100644 --- a/make/common/shared/Compiler-gcc.gmk +++ b/make/common/shared/Compiler-gcc.gmk @@ -45,10 +45,8 @@ ifeq ($(PLATFORM), windows) NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo ifeq ($(ARCH_DATA_MODEL), 32) CC_VER = UNKNOWN - CC_TYPE = UNKNOWN else CC_VER = UNKNOWN - CC_TYPE = UNKNOWN endif _LINK_VER :=$(shell $(LINK) 2>&1 | $(HEAD) -n 1) LINK_VER :=$(call GetVersion,"$(_LINK_VER)") diff --git a/make/common/shared/Compiler-msvc.gmk b/make/common/shared/Compiler-msvc.gmk index fbb8e8a5664192c0a4061bd75b5ed9dcd2533022..41509e51b09df163b2638422c5cee2a1aae95873 100644 --- a/make/common/shared/Compiler-msvc.gmk +++ b/make/common/shared/Compiler-msvc.gmk @@ -47,13 +47,13 @@ ifeq ($(PLATFORM), windows) # unset any GNU Make settings of MFLAGS and MAKEFLAGS which may mess up nmake NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo + # Compiler version and type (Always get word after "Version") + CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(SED) 's/.*\(Version.*\)/\1/' | $(NAWK) '{print $$2}') + # SDK-64 and MSVC6 put REBASE.EXE in a different places - go figure... ifeq ($(ARCH_DATA_MODEL), 32) - CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$8}') LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}') - CC_TYPE := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$5}') CC_MAJORVER :=$(call MajorVersion,$(CC_VER)) - REQUIRED_CCTYPE = Optimizing REQUIRED_CC_VER = 13.10.3077 REQUIRED_LINK_VER = 7.10.3077 ifeq ($(CC_MAJORVER), 12) @@ -85,9 +85,7 @@ ifeq ($(PLATFORM), windows) endif endif else - CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$7}') LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}') - CC_TYPE := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$4}') CC_MAJORVER :=$(call MajorVersion,$(CC_VER)) CC_MINORVER :=$(call MinorVersion,$(CC_VER)) CC_MICROVER :=$(call MicroVersion,$(CC_VER)) diff --git a/make/common/shared/Defs-control.gmk b/make/common/shared/Defs-control.gmk index ec94a2ed7ae031df100e4b03d989ddd3f1cabd68..ee31961617244c4d2548d1c65b9c9a714ff83ffb 100644 --- a/make/common/shared/Defs-control.gmk +++ b/make/common/shared/Defs-control.gmk @@ -36,7 +36,7 @@ ifndef JDK_MAKE_SHARED_DIR endif ifndef CONTROL_TOPDIR - CONTROL_TOPDIR=$(TOPDIR)/control + CONTROL_TOPDIR=$(TOPDIR) endif ifndef HOTSPOT_TOPDIR HOTSPOT_TOPDIR=$(TOPDIR)/hotspot @@ -69,8 +69,8 @@ endif # Get shared platform settings include $(JDK_MAKE_SHARED_DIR)/Platform.gmk -# Default output directory -_OUTPUTDIR=$(CONTROL_TOPDIR)/build/$(PLATFORM)-$(ARCH) +# Default directory immediately above the "build" output directory (OUTPUTDIR) +BUILD_PARENT_DIRECTORY=$(TOPDIR) # Get platform specific settings include $(JDK_MAKE_SHARED_DIR)/Defs.gmk diff --git a/make/common/shared/Defs-utils.gmk b/make/common/shared/Defs-utils.gmk index dc84d795b7616d8e992674f63373aa5cebd3b5c8..3886ee65ce4af7f965a2be12bb6c83c94a5a75cb 100644 --- a/make/common/shared/Defs-utils.gmk +++ b/make/common/shared/Defs-utils.gmk @@ -67,16 +67,6 @@ ifeq ($(PLATFORM),windows) UTILS_DEVTOOL_PATH=$(DEVTOOLS_PATH) endif -# Utilities ant and findbugs -ifndef ANT_HOME - ANT_HOME = $(JDK_DEVTOOLS_DIR)/share/ant/latest -endif -ANT = $(ANT_HOME)/bin/ant -ifndef FINDBUGS_HOME - FINDBUGS_HOME = $(JDK_DEVTOOLS_DIR)/share/findbugs/latest -endif -FINDBUGS = $(FINDBUGS_HOME)/bin/findbugs - # Utilities ADB = $(UTILS_COMMAND_PATH)adb AR = $(UTILS_CCS_BIN_PATH)ar diff --git a/make/common/shared/Defs.gmk b/make/common/shared/Defs.gmk index c2a8278bddf13ce75b88684b98311fed1dc2bd84..8fc28e239e01075829b83819f49d281f63ec26e7 100644 --- a/make/common/shared/Defs.gmk +++ b/make/common/shared/Defs.gmk @@ -1,5 +1,5 @@ # -# Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2005-2008 Sun Microsystems, 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 @@ -55,7 +55,10 @@ include $(JDK_MAKE_SHARED_DIR)/Defs-utils.gmk # Simple pwd path define PwdPath -$(shell cd $1 2> $(DEV_NULL) && pwd) +$(shell $(CD) $1 2> $(DEV_NULL) && $(PWD)) +endef +define AbsPwdPathCheck +$(shell $(CD) .. 2> $(DEV_NULL) && $(CD) $1 2> $(DEV_NULL) && $(PWD)) endef # Checks an ALT value for spaces (should be one word), @@ -262,7 +265,9 @@ ifdef BUILD_NUMBER FULL_VERSION = $(RELEASE)-$(BUILD_NUMBER) else BUILD_NUMBER = b00 - USER_RELEASE_SUFFIX := $(shell echo $(USER)_`date '+%d_%b_%Y_%H_%M' | tr "A-Z" "a-z"`) + BUILD_DATE := $(shell $(DATE) '+%Y_%m_%d_%H_%M') + CLEAN_USERNAME := $(shell $(ECHO) "$(USER)" | $(TR) -d -c '[:alnum:]') + USER_RELEASE_SUFFIX := $(shell $(ECHO) "$(CLEAN_USERNAME)_$(BUILD_DATE)" | $(TR) '[:upper:]' '[:lower:]' ) FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER) endif @@ -422,24 +427,64 @@ CACERTS_FILE:=$(call AltCheckSpaces,CACERTS_FILE) CACERTS_FILE:=$(call AltCheckValue,CACERTS_FILE) # OUTPUTDIR: Location of all output for the build -_BACKUP_OUTPUTDIR = $(TEMP_DISK)/$(USER)/jdk-outputdir ifdef ALT_OUTPUTDIR - _POSSIBLE_OUTPUTDIR =$(subst \,/,$(ALT_OUTPUTDIR)) + OUTPUTDIR:=$(subst \,/,$(ALT_OUTPUTDIR)) + # Assumes this is absolute (checks later) + ABS_OUTPUTDIR:=$(OUTPUTDIR) else ifndef _OUTPUTDIR - _OUTPUTDIR = $(_BACKUP_OUTPUTDIR) + # Default: Get "build" parent directory, which should always exist + ifndef BUILD_PARENT_DIRECTORY + BUILD_PARENT_DIRECTORY=$(BUILDDIR)/.. + endif + ABS_BUILD_PARENT_DIRECTORY:=$(call FullPath,$(BUILD_PARENT_DIRECTORY)) + ifdef OPENJDK + _OUTPUTDIRNAME=$(PLATFORM)-$(ARCH)$(OPENJDK_SUFFIX) + else + _OUTPUTDIRNAME=$(PLATFORM)-$(ARCH) + endif + _OUTPUTDIR=$(BUILD_PARENT_DIRECTORY)/build/$(_OUTPUTDIRNAME) + ABS_OUTPUTDIR:=$(ABS_BUILD_PARENT_DIRECTORY)/build/$(_OUTPUTDIRNAME) endif - _POSSIBLE_OUTPUTDIR =$(_OUTPUTDIR) -endif -_create_outputdir1:=$(shell mkdir -p $(_POSSIBLE_OUTPUTDIR) > $(DEV_NULL) 2>&1) -OUTPUTDIR:=$(call WriteDirExists,$(_POSSIBLE_OUTPUTDIR),$(_BACKUP_OUTPUTDIR)) -_create_outputdir2:=$(shell mkdir -p $(OUTPUTDIR) > $(DEV_NULL) 2>&1) -ifeq "$(OUTPUTDIR)" "$(_BACKUP_OUTPUTDIR)" - _outputdir_warning:=$(warning "WARNING: OUTPUTDIR '$(_POSSIBLE_OUTPUTDIR)' not writable, will use '$(_BACKUP_OUTPUTDIR)'") + OUTPUTDIR:=$(_OUTPUTDIR) endif +# Check for spaces and null value OUTPUTDIR:=$(call AltCheckSpaces,OUTPUTDIR) OUTPUTDIR:=$(call AltCheckValue,OUTPUTDIR) +# +# When signing the JCE framework and provider, we could be using built +# bits on a read-only filesystem. If so, this test will fail and crash +# the build. +# +ifndef IGNORE_WRITABLE_OUTPUTDIR_TEST +# Create the output directory and make sure it exists and is writable +_create_outputdir:=$(shell $(MKDIR) -p "$(OUTPUTDIR)" > $(DEV_NULL) 2>&1) +ifeq ($(call WriteDirExists,$(OUTPUTDIR),/dev/null),/dev/null) + _outputdir_error:=$(error "ERROR: OUTPUTDIR '$(OUTPUTDIR)' not created or not writable") +endif +endif + +# Define absolute path if needed and check for spaces and null value +ifndef ABS_OUTPUTDIR + ABS_OUTPUTDIR:=$(call FullPath,$(OUTPUTDIR)) +endif +ABS_OUTPUTDIR:=$(call AltCheckSpaces,ABS_OUTPUTDIR) +ABS_OUTPUTDIR:=$(call AltCheckValue,ABS_OUTPUTDIR) +# Make doubly sure this is a full path +ifeq ($(call AbsPwdPathCheck,$(ABS_OUTPUTDIR)), ) + ifdef ALT_OUTPUTDIR + _outputdir_error:=$(error "ERROR: Trouble with the absolute path for OUTPUTDIR '$(OUTPUTDIR)', was ALT_OUTPUTDIR '$(ALT_OUTPUTDIR)' an absolute path?") + else + _outputdir_error:=$(error "ERROR: Trouble with the absolute path for OUTPUTDIR '$(OUTPUTDIR)'") + endif +endif +_dir1:=$(call FullPath,$(ABS_OUTPUTDIR)) +_dir2:=$(call FullPath,$(OUTPUTDIR)) +ifneq ($(_dir1),$(_dir2)) + _outputdir_error:=$(error "ERROR: ABS_OUTPUTDIR '$(ABS_OUTPUTDIR)' is not the same directory as OUTPUTDIR '$(OUTPUTDIR)', '$(_dir1)'!='$(_dir2)'") +endif + # Bin directory # NOTE: ISA_DIR is usually empty, on Solaris it might be /sparcv9 or /amd64 BINDIR = $(OUTPUTDIR)/bin$(ISA_DIR) @@ -469,15 +514,30 @@ JDK_CUPS_HEADERS_PATH=$(JDK_DEVTOOLS_DIR)/share/cups/include endif endif +# Utilities ant and findbugs +ifeq ($(ANT_HOME),) + ANT_HOME := $(call DirExists,/usr/share/ant,$(JDK_DEVTOOLS_DIR)/share/ant/latest,) +endif +ifeq ($(ANT_HOME),) + ANT = ant +else + ANT = $(ANT_HOME)/bin/ant +endif +ifeq ($(FINDBUGS_HOME),) + FINDBUGS_HOME := $(call DirExists,/usr/share/findbugs,$(JDK_DEVTOOLS_DIR)/share/findbugs/latest,) +endif +ifeq ($(FINDBUGS_HOME),) + FINDBUGS = findbugs +else + FINDBUGS = $(FINDBUGS_HOME)/bin/findbugs +endif + ifdef ALT_COPYRIGHT_YEAR COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR) else COPYRIGHT_YEAR = $(shell $(DATE) '+%Y') endif -# Absolute path to output directory -ABS_OUTPUTDIR:=$(call FullPath,$(OUTPUTDIR)) - # Get shared compiler settings include $(JDK_MAKE_SHARED_DIR)/Compiler.gmk diff --git a/make/common/shared/Platform.gmk b/make/common/shared/Platform.gmk index f9f229a8548de54577d1f24fa150fbc82a4d90e6..32cb08e34737b10e8748fcb7480cc29194953d0b 100644 --- a/make/common/shared/Platform.gmk +++ b/make/common/shared/Platform.gmk @@ -93,20 +93,18 @@ SYSTEM_UNAME := $(shell uname) # Normal boot jdk is previous release, but a hard requirement is a 1.5 boot REQUIRED_BOOT_VER = 1.5 -#This is specific to OpenJDK build -ifdef OPENJDK - REQUIRED_FREETYPE_VERSION=2.3.0 -endif +# If we are using freetype, this is the required version +REQUIRED_FREETYPE_VERSION=2.3.0 # # Prune out all known SCM (Source Code Management) directories # so they will not be included when copying directory trees # or packaging up .jar files, etc. This applies to all workspaces. # -SCM_DIRs = .hg .svn CVS RCS SCCS Codemgr_wsdata deleted_files +SCM_DIRs = .hg .svn CVS RCS SCCS Codemgr_wsdata deleted_files .hgignore .hgtags # When changing SCM_DIRs also change SCM_DIRS_rexp and SCM_DIRS_prune: -SCM_DIRS_rexp = ".hg|.svn|CVS|RCS|SCCS|Codemgr_wsdata|deleted_files" -SCM_DIRS_prune = \( -name .hg -o -name .svn -o -name CVS -o -name RCS -o -name SCCS -o -name Codemgr_wsdata -o -name deleted_files \) -prune +SCM_DIRS_rexp = ".hg|.svn|CVS|RCS|SCCS|Codemgr_wsdata|deleted_files|.hgignore|.hgtags" +SCM_DIRS_prune = \( -name .hg -o -name .svn -o -name CVS -o -name RCS -o -name SCCS -o -name Codemgr_wsdata -o -name deleted_files -o -name .hgignore -o -name .hgtags \) -prune # Don't define this unless it's not defined ifndef VARIANT @@ -272,7 +270,7 @@ ifeq ($(SYSTEM_UNAME), Linux) REQUIRED_ALSA_VERSION = ^((0[.]9[.][1-9])|(1[.]0[.][0-9]))[0-9]* endif # How much RAM does this machine have: - MB_OF_MEMORY := $(shell free -m | fgrep Mem: | sed -e 's@\ \ *@ @g' | cut -d' ' -f2) + MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' ) endif # Windows with and without CYGWIN will be slightly different @@ -376,45 +374,35 @@ ifeq ($(PLATFORM), windows) REQUIRED_DXSDK_VER = 0x0700 OS_VENDOR = Microsoft # How much RAM does this machine have: - MB_OF_MEMORY := $(shell \ - if [ -f "C:/cygwin/bin/free.exe" ] ; then \ - ( C:/cygwin/bin/bash.exe -c "C:/cygwin/bin/free.exe -m" ) | \ - grep Mem: | \ - sed -e 's@\ \ *@ @g' | cut -d' ' -f2 ; \ - else \ - echo "512"; \ - fi) -endif - -# Machines with 512Mb or less of real memory are considered low memory -# build machines and adjustments will be made to prevent excessing -# system swapping during the build. -# If we don't know, assume 512. Subtract 128 from MB for VM MAX. -# Don't set VM max over 1024-128=896. -ifneq ($(MB_OF_MEMORY),) - LOW_MEMORY_MACHINE := $(shell \ - if [ $(MB_OF_MEMORY) -le 512 ] ; then \ - echo "true"; \ - else \ - echo "false"; \ - fi) - MAX_VM_MEMORY := $(shell \ - if [ $(MB_OF_MEMORY) -le 1024 ] ; then \ - expr $(MB_OF_MEMORY) '-' 128 ; \ - else \ - echo "896"; \ - fi) - MIN_VM_MEMORY := $(shell \ - if [ $(MAX_VM_MEMORY) -le 128 ] ; then \ - expr $(MAX_VM_MEMORY) '-' 8 ; \ - else \ - echo "128"; \ - fi) -else - MB_OF_MEMORY := unknown - LOW_MEMORY_MACHINE := true - MAX_VM_MEMORY := 384 - MIN_VM_MEMORY := 128 + ifeq ($(USING_CYGWIN),true) + # CYGWIN has the 'free' utility + _MB_OF_MEMORY := \ + $(shell free -m | grep Mem: | awk '{print $$2;}' ) + else + # Windows 2000 has the mem utility, but two memory areas + # extended memory is what is beyond 1024M + _B_OF_EXT_MEMORY := \ + $(shell mem 2> $(DEV_NULL) | grep 'total contiguous extended memory' | awk '{print $$1;}') + ifeq ($(_B_OF_EXT_MEMORY),) + _B_OF_MEMORY := \ + $(shell mem 2> $(DEV_NULL) | grep 'total conventional memory' | awk '{print $$1;}') + else + _B_OF_MEMORY := \ + $(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL)) + endif + ifeq ($(_B_OF_MEMORY),) + # Windows 2003 has the systeminfo utility use it if mem doesn't work + _MB_OF_MEMORY := \ + $(shell systeminfo 2> $(DEV_NULL) | grep 'Total Physical Memory:' | awk '{print $$4;}' | sed -e 's@,@@') + else + _MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL)) + endif + endif + ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY)) + MB_OF_MEMORY := $(_MB_OF_MEMORY) + else + MB_OF_MEMORY := 512 + endif endif REQUIRED_ZIP_VER = 2.2 @@ -454,6 +442,37 @@ ifneq ($(PLATFORM), windows) ARCH_VM_SUBDIR=jre/lib/$(LIBARCH) endif +# Machines with 512Mb or less of real memory are considered low memory +# build machines and adjustments will be made to prevent excessing +# system swapping during the build. +# If we don't know, assume 512. Subtract 128 from MB for VM MAX. +# Don't set VM max over 1024-128=896. +ifneq ($(MB_OF_MEMORY),) + LOW_MEMORY_MACHINE := $(shell \ + if [ $(MB_OF_MEMORY) -le 512 ] ; then \ + echo "true"; \ + else \ + echo "false"; \ + fi) + MAX_VM_MEMORY := $(shell \ + if [ $(MB_OF_MEMORY) -le 1024 ] ; then \ + expr $(MB_OF_MEMORY) '-' 128 2> $(DEV_NULL) ; \ + else \ + echo "896"; \ + fi) + MIN_VM_MEMORY := $(shell \ + if [ $(MAX_VM_MEMORY) -le 128 ] ; then \ + expr $(MAX_VM_MEMORY) '-' 8 2> $(DEV_NULL) ; \ + else \ + echo "128"; \ + fi) +else + MB_OF_MEMORY := unknown + LOW_MEMORY_MACHINE := true + MAX_VM_MEMORY := 384 + MIN_VM_MEMORY := 128 +endif + # If blanks in the username, use the first 4 words and pack them together _USER1:=$(subst ', ,$(_USER)) _USER2:=$(subst ", ,$(_USER1)) diff --git a/make/common/shared/Sanity.gmk b/make/common/shared/Sanity.gmk index a97ddddd534510649300c61d89d2837632b3b2c4..a6b19476c0b5c7bac83e2b4b03e954076d59ab39 100644 --- a/make/common/shared/Sanity.gmk +++ b/make/common/shared/Sanity.gmk @@ -105,13 +105,21 @@ ZIP_VER :=$(call GetVersion,"$(_ZIP_VER)") UNZIP_VER :=$(call GetVersion,"$(_UNZIP_VER)") BOOT_VER :=$(call GetVersion,"$(_BOOT_VER)") -REQUIRED_ANT_VER := 1.6.3 -_ANT_VER :=$(shell $(ANT) -version 2>&1 ) -ANT_VER :=$(call GetVersion,"$(_ANT_VER)") +REQUIRED_ANT_VER := 1.6.3 +ifeq ($(ANT_HOME),) + _ANT_VER:=$(shell JAVACMD="$(BOOTDIR)/bin/java" $(ANT) -version 2>&1 ) +else + _ANT_VER:=$(shell JAVACMD="$(BOOTDIR)/bin/java" ANT_HOME="$(ANT_HOME)" $(ANT) -version 2>&1 ) +endif +ANT_VER:=$(call GetVersion,"$(_ANT_VER)") -REQUIRED_FINDBUGS_VER := 1.1 -_FINDBUGS_VER :=$(shell $(FINDBUGS) -version 2>&1 ) -FINDBUGS_VER :=$(call GetVersion,"$(_FINDBUGS_VER)") +REQUIRED_FINDBUGS_VER := 1.2 +ifeq ($(FINDBUGS_HOME),) + _FINDBUGS_VER:=$(shell $(FINDBUGS) -javahome "$(BOOTDIR)" -textui -version 2>&1 ) +else + _FINDBUGS_VER:=$(shell FINDBUGS_HOME="$(FINDBUGS_HOME)" $(FINDBUGS) -javahome "$(BOOTDIR)" -textui -version 2>&1 ) +endif +FINDBUGS_VER:=$(call GetVersion,"$(_FINDBUGS_VER)") ifdef ALT_BINDIR ALT_BINDIR_VERSION := $(shell $(ALT_BINDIR)/java$(EXE_SUFFIX) -version 2>&1 | $(NAWK) -F'"' '{ print $$2 }') @@ -780,21 +788,17 @@ sane-cacerts: ifdef OPENJDK -#name of test program that prints out "Failed" if freetype is not good enough -FREETYPE_VERSION_CHECK_NAME = freetype_versioncheck -FREETYPE_VERSION_CHECK = $(TEMPDIR)/$(FREETYPE_VERSION_CHECK_NAME)$(EXE_SUFFIX) - -sane-freetype: - @-($(CD) $(BUILDDIR)/tools/freetypecheck && \ - $(MAKE) REQUIRED_FREETYPE_VERSION=$(REQUIRED_FREETYPE_VERSION) \ - FT_TEST=$(FREETYPE_VERSION_CHECK_NAME) \ - FT_HEADERS=$(FREETYPE_HEADERS_PATH) \ - FT_LIB=$(FREETYPE_LIB_PATH) \ - XARCH=$(XARCH)) - @if [ ! -r $(FREETYPE_VERSION_CHECK) -o \ - "`$(FREETYPE_VERSION_CHECK) | $(GREP) Fail`" != "" ]; then \ +# The freetypecheck Makefile prints out "Failed" if not good enough +$(TEMPDIR)/freetypeinfo: FRC + @$(prep-target) + @(($(CD) $(BUILDDIR)/tools/freetypecheck && $(MAKE)) || \ + $(ECHO) "Failed to build freetypecheck." ) > $@ + +sane-freetype: $(TEMPDIR)/freetypeinfo + @if [ "`$(CAT) $< | $(GREP) Fail`" != "" ]; then \ $(ECHO) "ERROR: FreeType version " $(REQUIRED_FREETYPE_VERSION) \ - "or higher is required. \n" >> $(ERROR_FILE) ; \ + " or higher is required. \n" \ + "`$(CAT) $<` \n" >> $(ERROR_FILE) ; \ fi else @@ -1331,7 +1335,7 @@ sane-compiler: sane-link ifndef OPENJDK @if [ "$(CC_CHECK)" != "same" ]; then \ $(ECHO) "WARNING: The $(PLATFORM) compiler is not version $(COMPILER_VERSION) $(REQUIRED_CC_VER) \n" \ - " Specifically the $(COMPILER_NAME) $(CC_TYPE) compiler. \n " \ + " Specifically the $(COMPILER_NAME) compiler. \n " \ " $(YOU_ARE_USING) compiler version: $(CC_VER) \n" \ " The compiler was obtained from the following location: \n" \ " $(COMPILER_PATH) \n" \ @@ -1564,31 +1568,31 @@ ifeq ($(ARCH_DATA_MODEL), 32) endif -###################################################### -# SECURITY_BASELINE_142 test -###################################################### -security_baseline_142: -ifeq ($(PLATFORM), windows) - @if [ -z "$(SECURITY_BASELINE_142)" ]; then \ - $(ECHO) "WARNING: Your SECURITY_BASELINE_142 setting is empty.\n" \ - " Setting it to the default value of 1.4.2_10.\n" \ - " It is recommended to set SECURITY_BASELINE_142.\n" \ - "" >> $(WARNING_FILE) ; \ - fi -endif - -###################################################### -# SECURITY_BASELINE_150 test -###################################################### -security_baseline_150: -ifeq ($(PLATFORM), windows) - @if [ -z "$(SECURITY_BASELINE_150)" ]; then \ - $(ECHO) "WARNING: Your SECURITY_BASELINE_150 setting is empty.\n" \ - " Setting it to the default value of 1.5.0_07.\n" \ - " It is recommended to set SECURITY_BASELINE_150.\n" \ - "" >> $(WARNING_FILE) ; \ - fi -endif +###################################################### +# SECURITY_BASELINE_142 test +###################################################### +security_baseline_142: +ifeq ($(PLATFORM), windows) + @if [ -z "$(SECURITY_BASELINE_142)" ]; then \ + $(ECHO) "WARNING: Your SECURITY_BASELINE_142 setting is empty.\n" \ + " Setting it to the default value of 1.4.2_10.\n" \ + " It is recommended to set SECURITY_BASELINE_142.\n" \ + "" >> $(WARNING_FILE) ; \ + fi +endif + +###################################################### +# SECURITY_BASELINE_150 test +###################################################### +security_baseline_150: +ifeq ($(PLATFORM), windows) + @if [ -z "$(SECURITY_BASELINE_150)" ]; then \ + $(ECHO) "WARNING: Your SECURITY_BASELINE_150 setting is empty.\n" \ + " Setting it to the default value of 1.5.0_07.\n" \ + " It is recommended to set SECURITY_BASELINE_150.\n" \ + "" >> $(WARNING_FILE) ; \ + fi +endif ###################################################### diff --git a/make/docs/CORE_PKGS.gmk b/make/docs/CORE_PKGS.gmk index dce55eea7563f66d47a9a420a095b3aad9917b0d..03d95a606aaf95b76b068769665c5d722927cea7 100644 --- a/make/docs/CORE_PKGS.gmk +++ b/make/docs/CORE_PKGS.gmk @@ -49,8 +49,8 @@ EXCLUDE_PKGS = \ # ACTIVE_JSR_PKGS are packages that are part of an active JSR process-- # one that is doing its own review. These packages are not included when # creating diff pages for the platform's JCP process. -# -# (see /java/pubs/apisrc/jdk/6.0/beta/make/docs/active_jsr_pkgs) +# +# (see /java/pubs/apisrc/jdk/6.0/beta/make/docs/active_jsr_pkgs) # Note: # This is a list of regular expressions. So foo.* matches "foo" and "foo.bar". # @@ -72,13 +72,13 @@ ACTIVE_JSR_PKGS= \ # CORE_PKGS is the list of packages that form the # Java API Specification. # -### ***IMPORTANT NOTE*** -### There is also a "REGEXP" variable in the docs/makefile that -### determines which table the packages go in on the main page. -### Currently, there is only table ("Platform Packages") and -### everything goes in it, so REGEXP is "*". But if that policy -### changes, packages added will need to be reflected in that -### list of wildcard expressions, as well. +### ***IMPORTANT NOTE*** +### There is also a "REGEXP" variable in the docs/makefile that +### determines which table the packages go in on the main page. +### Currently, there is only table ("Platform Packages") and +### everything goes in it, so REGEXP is "*". But if that policy +### changes, packages added will need to be reflected in that +### list of wildcard expressions, as well. ### CORE_PKGS = \ java.applet \ diff --git a/make/docs/Makefile b/make/docs/Makefile index 328244b9a97b1bebedea1b33c7e307c62cb24ae7..5a5b496da5121101d65ccbd962a35d0b91c1e071 100644 --- a/make/docs/Makefile +++ b/make/docs/Makefile @@ -272,6 +272,28 @@ SMARTCARDIO_DOCTITLE = "Java$(TRADEMARK) Smart Card I/O" SMARTCARDIO_JAVADOCHEADER = "Java Smart Card I/O" # SMARTCARDIO_PKGS is located in NON_CORE_PKGS.gmk +# +# Variables used by TRACING target +# + +TRACING_SOURCEPATH = $(TOPDIR)/src/share/classes +TRACING_DOCDIR = $(DOCSDIR)/jre/api/tracing + +TRACING_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \ + -encoding ascii \ + -nodeprecatedlist \ + -d $(TRACING_DOCDIR) \ + -sourcepath $(TRACING_SOURCEPATH) \ + -windowtitle $(TRACING_WINDOWTITLE) \ + -doctitle $(TRACING_DOCTITLE) \ + -header $(TRACING_JAVADOCHEADER) \ + -linkoffline ../../../../../api $(DOCSDIR)/api/ + +TRACING_WINDOWTITLE = "Tracing" +TRACING_DOCTITLE = "Java$(TRADEMARK) Platform Tracing" +TRACING_JAVADOCHEADER = "Platform Tracing" +# TRACING_PKGS is located in NON_CORE_PKGS.gmk + # # Variables used by HTTPSERVER target # @@ -420,6 +442,7 @@ ALL_OTHER_TARGETS = \ jaasdocs \ jgssdocs \ smartcardiodocs \ + tracingdocs \ httpserverdocs \ mgmtdocs \ attachdocs \ @@ -585,6 +608,14 @@ smartcardiodocs: $(JAVADOC_CMD) $(SMARTCARDIO_JAVADOCFLAGS) \ $(SMARTCARDIO_PKGS) +.PHONY: tracingdocs +tracingdocs: + @# ######## api-tracing ############################ + $(RM) -r $(TRACING_DOCDIR) + $(MKDIR) -p $(TRACING_DOCDIR) + $(JAVADOC) $(TRACING_JAVADOCFLAGS) \ + $(TRACING_PKGS) + .PHONY: httpserverdocs httpserverdocs: @# ######## api-httpserver ####################### diff --git a/make/docs/NON_CORE_PKGS.gmk b/make/docs/NON_CORE_PKGS.gmk index f40add343141d4a716cbd4322ded6f64154a6ac0..8c78c6ed78da2eaa93fdf34751ef60faed1e3ba1 100644 --- a/make/docs/NON_CORE_PKGS.gmk +++ b/make/docs/NON_CORE_PKGS.gmk @@ -84,6 +84,9 @@ TREEAPI_PKGS = com.sun.source.tree \ SMARTCARDIO_PKGS = javax.smartcardio +TRACING_PKGS = com.sun.tracing \ + com.sun.tracing.dtrace + # non-core packages in rt.jar NON_CORE_PKGS = $(DOMAPI_PKGS) \ $(MGMT_PKGS) \ @@ -91,4 +94,5 @@ NON_CORE_PKGS = $(DOMAPI_PKGS) \ $(JGSS_PKGS) \ $(OLD_JSSE_PKGS) \ $(HTTPSERVER_PKGS) \ - $(SMARTCARDIO_PKGS) + $(SMARTCARDIO_PKGS) \ + $(TRACING_PKGS) diff --git a/make/java/java/genlocales.gmk b/make/java/java/genlocales.gmk index 05ad9f36dd573906fc216ec9fb73229bf9b7e36c..8ea0a0f25594339267382d1d7760daa8ab1f6c1a 100644 --- a/make/java/java/genlocales.gmk +++ b/make/java/java/genlocales.gmk @@ -80,7 +80,8 @@ $(LocaleDataMetaInfo_Dest):$(LocaleDataMetaInfo_Src) $(LOCALEGEN_SH) @$(ECHO) $(subst .java,'\n',$(Euro_Resources_java)) >> $@.tmp.euro; @$(ECHO) $(subst .properties,'\n',$(NonEuro_Resources_properties)) > $@.tmp.noneuro; @$(ECHO) $(subst .java,'\n',$(NonEuro_Resources_java)) >> $@.tmp.noneuro; - NAWK=$(NAWK) SED=$(SED) $(SH) $(LOCALEGEN_SH) $(RESOURCE_NAMES) $@.tmp.euro \ + NAWK="$(NAWK)" SED="$(SED)" SORT="$(SORT)" \ + $(SH) $(LOCALEGEN_SH) $(RESOURCE_NAMES) $@.tmp.euro \ $@.tmp.noneuro $< $@ @$(RM) $@.tmp.euro $@.tmp.noneuro; diff --git a/make/java/java/localegen.sh b/make/java/java/localegen.sh index 70e26838bc419d0101bfe2913cb35de0802cb86e..b4506b9785425b2b130758fbe714ad12531fb67e 100644 --- a/make/java/java/localegen.sh +++ b/make/java/java/localegen.sh @@ -29,7 +29,7 @@ # This script is to generate the supported locale list string and replace the # LocaleDataMetaInfo-XLocales.java in /src/share/classes/sun/util # -# NAWK & SED is passed in as environment variables. +# SORT, NAWK & SED is passed in as environment variables. # # A list of resource base name list; @@ -47,7 +47,7 @@ OUTPUT_FILE=$5 localelist= getlocalelist() { localelist="" - localelist=`$NAWK -F$1_ '{print $2}' $2 | sort` + localelist=`$NAWK -F$1_ '{print $2}' $2 | $SORT` } sed_script="$SED -e \"s@^#warn .*@// -- This file was mechanically generated: Do not edit! -- //@\" " diff --git a/make/java/java/mapfile-vers b/make/java/java/mapfile-vers index 4599570449ea88ffc40c3ae433d52f5d2689a4c5..38f9e126d825266c11c686c7329970e67e5b2dfe 100644 --- a/make/java/java/mapfile-vers +++ b/make/java/java/mapfile-vers @@ -85,7 +85,6 @@ SUNWprivate_1.1 { Java_java_io_FileOutputStream_close0; Java_java_io_FileOutputStream_initIDs; Java_java_io_FileOutputStream_open; - Java_java_io_FileOutputStream_openAppend; Java_java_io_FileOutputStream_write; Java_java_io_FileOutputStream_writeBytes; Java_java_io_FileSystem_getFileSystem; diff --git a/make/java/jli/Makefile b/make/java/jli/Makefile index fb8868fd37dab991f1730a8e7e9ebdd70866fc71..236654fd4a9bd1d1eedabf46bf877efa580bd973 100644 --- a/make/java/jli/Makefile +++ b/make/java/jli/Makefile @@ -107,6 +107,7 @@ endif # PLATFORM ifeq ($(PLATFORM), windows) EXTRA_LIBS = advapi32.lib \ + comctl32.lib \ user32.lib JAVALIB = diff --git a/make/java/main/java/Makefile b/make/java/main/java/Makefile index ad924f6663e72df28eee5bb346e418381f6ff846..5c876294c98da4ea5aa0749fbb73483e1b25d2fd 100644 --- a/make/java/main/java/Makefile +++ b/make/java/main/java/Makefile @@ -43,7 +43,7 @@ include $(BUILDDIR)/common/Defs.gmk # Override the default version info with our own resource file (see 5106536) ifeq ($(PLATFORM), windows) -LDLIBS_COMMON += user32.lib +LDLIBS_COMMON += user32.lib comctl32.lib ifdef OPENJDK RC_FLAGS += -i "$(PLATFORM_SRC)/resource/icons" else diff --git a/make/java/main/javaw/Makefile b/make/java/main/javaw/Makefile index 9afb5d0133db74a76aedfc492b4591690c2e969f..1c03b23fab73e07d7436aa4ba1a44828257d0425 100644 --- a/make/java/main/javaw/Makefile +++ b/make/java/main/javaw/Makefile @@ -46,7 +46,7 @@ STATIC_JLI = true include $(BUILDDIR)/common/Defs.gmk OTHER_CPPFLAGS += -DJAVAW -LDLIBS_COMMON += user32.lib +LDLIBS_COMMON += user32.lib comctl32.lib # Override the default version info with our own resource file (see 5106536) ifeq ($(PLATFORM), windows) diff --git a/make/java/nio/Makefile b/make/java/nio/Makefile index 98a838831a27b6c0f6097ed403d1c740c248afd8..0a9070f8257b78ece943d227ddebc02a5eb468fd 100644 --- a/make/java/nio/Makefile +++ b/make/java/nio/Makefile @@ -191,7 +191,7 @@ sources: $(SPP) $(FILES_genout) GEN_BUFFER_SH = genBuffer.sh -GEN_BUFFER_CMD = SPP="$(SPP_CMD)" NAWK=$(NAWK) SED=$(SED) \ +GEN_BUFFER_CMD = SPP="$(SPP_CMD)" NAWK=$(NAWK) SED=$(SED) SH=$(SH) \ $(SH) $(GEN_BUFFER_SH) # Public abstract buffer classes @@ -582,7 +582,7 @@ $(BUF_GEN)/ByteBufferAsDoubleBuffer%L.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.jav GEN_CODER_SH = genCoder.sh -GEN_CODER_CMD = SPP="$(SPP_CMD)" SED=$(SED) NAWK=$(NAWK) $(SH) $(GEN_CODER_SH) +GEN_CODER_CMD = SPP="$(SPP_CMD)" SED=$(SED) NAWK=$(NAWK) SH=$(SH) $(SH) $(GEN_CODER_SH) $(CS_GEN)/CharsetDecoder.java: $(CS_SRC)/Charset-X-Coder.java $(GEN_CODER_SH) $(prep-target) @@ -602,7 +602,7 @@ $(CS_GEN)/CharsetEncoder.java: $(CS_SRC)/Charset-X-Coder.java $(GEN_CODER_SH) GEN_EX_SH = genExceptions.sh -GEN_EX_CMD = NAWK=$(NAWK) $(SHELL) $(GEN_EX_SH) +GEN_EX_CMD = NAWK=$(NAWK) SH=$(SH) $(SH) $(GEN_EX_SH) $(CH_GEN)/%Exception.java: genExceptions.sh $(CH_SRC)/exceptions $(prep-target) @@ -635,8 +635,8 @@ $(SCS_GEN)/StandardCharsets.java: genCharsetProvider.sh \ $(HASHER_JARFILE) $(SCS_SRC)/standard-charsets $(prep-target) @$(RM) $@.temp - NAWK=$(NAWK) TEMPDIR=$(TEMPDIR) \ + NAWK=$(NAWK) TEMPDIR=$(TEMPDIR) SH=$(SH) \ HASHER="$(BOOT_JAVA_CMD) -jar $(HASHER_JARFILE)" \ - $(SHELL) -e genCharsetProvider.sh $(SCS_SRC)/standard-charsets $(SCS_GEN) + $(SH) -e genCharsetProvider.sh $(SCS_SRC)/standard-charsets $(SCS_GEN) .PHONY: sources diff --git a/make/java/nio/genCharsetProvider.sh b/make/java/nio/genCharsetProvider.sh index 1c344dacabd65e5e29200093ef2e1285b7734b28..574722fb4a94f98792a2eab175b042c8ad970e06 100644 --- a/make/java/nio/genCharsetProvider.sh +++ b/make/java/nio/genCharsetProvider.sh @@ -48,7 +48,7 @@ echo '-->' $OUT # Header # -$SHELL addNotices.sh "$COPYRIGHT_YEARS" > $OUT +$SH ./addNotices.sh "$COPYRIGHT_YEARS" > $OUT cat <<__END__ >>$OUT diff --git a/make/java/nio/genExceptions.sh b/make/java/nio/genExceptions.sh index 0e2020c2c1fa8bedfc9e8afae6c4fb3c95047d78..2de5e9cd784e8f55c67a121e8744872690d73982 100644 --- a/make/java/nio/genExceptions.sh +++ b/make/java/nio/genExceptions.sh @@ -41,7 +41,7 @@ gen() { echo '-->' $DST/$ID.java out=$DST/${ID}.java - $SHELL addNotices.sh "$COPYRIGHT_YEARS" > $out + $SH ./addNotices.sh "$COPYRIGHT_YEARS" > $out cat >>$out <<__END__ diff --git a/make/java/sun_nio/FILES_java.gmk b/make/java/sun_nio/FILES_java.gmk index d7ca6cd93b1ee177dfdab0212316c26dff86d105..13f4fe88d27d9c00a43d6867d002a0462672fa94 100644 --- a/make/java/sun_nio/FILES_java.gmk +++ b/make/java/sun_nio/FILES_java.gmk @@ -33,6 +33,7 @@ FILES_java = \ sun/nio/cs/AbstractCharsetProvider.java \ sun/nio/cs/HistoricallyNamedCharset.java \ sun/nio/cs/Surrogate.java \ + sun/nio/cs/CharsetMapping.java \ sun/nio/cs/SingleByteEncoder.java \ sun/nio/cs/SingleByteDecoder.java \ sun/nio/cs/UnicodeEncoder.java \ diff --git a/make/javax/Makefile b/make/javax/Makefile index c81d5f103e31ef2c86e2e4c465a03409981c8538..678fe8926f80eeab2787c1fa72274eea14061bf1 100644 --- a/make/javax/Makefile +++ b/make/javax/Makefile @@ -30,24 +30,10 @@ BUILDDIR = .. include $(BUILDDIR)/common/Defs.gmk -# -# Files to compile -# -AUTO_FILES_JAVA_DIRS = \ - javax/naming \ - com/sun/naming/internal \ - javax/net \ - javax/script \ - javax/security/auth \ - javax/security/cert \ - javax/security/sasl \ - javax/smartcardio \ - javax/tools \ - javax/xml - # imageio uses xml, so build it last SUBDIRS = \ + others \ accessibility \ print \ swing \ @@ -63,8 +49,3 @@ all build: clean clobber:: $(SUBDIRS-loop) -# -# Rules -# -include $(BUILDDIR)/common/Classes.gmk - diff --git a/make/javax/crypto/Defs-jce.gmk b/make/javax/crypto/Defs-jce.gmk index c1ef30d5448132cd6f80dadc083a7c3ab5d16500..46fe1118dcac52774daa8fc986850e168b33ed51 100644 --- a/make/javax/crypto/Defs-jce.gmk +++ b/make/javax/crypto/Defs-jce.gmk @@ -1,5 +1,5 @@ # -# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2007-2008 Sun Microsystems, 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 @@ -31,7 +31,7 @@ include $(BUILDDIR)/common/Release.gmk JCE_MANIFEST_FILE = $(TEMPDIR)/manifest.mf $(JCE_MANIFEST_FILE): $(MAINMANIFEST) $(prep-target) - ( $(SED) "s/@@RELEASE@@/$(RELEASE)/" $(MAINMANIFEST); \ + ( $(SED) "s/@@RELEASE@@/$(RELEASE)/" $<; \ $(ECHO) "Extension-Name: javax.crypto"; \ $(ECHO) "Implementation-Vendor-Id: com.sun"; ) > $@ @@ -75,6 +75,7 @@ endef define sign-target $(BOOT_JARSIGNER_CMD) -keystore $(SIGNING_KEYSTORE) \ $@ $(SIGNING_ALIAS) < $(SIGNING_PASSPHRASE) + @$(java-vm-cleanup) @$(ECHO) "\nJar codesigning finished." endef @@ -88,13 +89,15 @@ define release-warning endef # -# Convenience macro for steps needed to sign a jar file. +# Convenience macros for signing a jar file. +# +# Call through $(call sign-file, target file) # define sign-file $(presign) - $(install-file) + $(prep-target) + $(CP) $1 $@ $(sign-target) - @$(java-vm-cleanup) endef # diff --git a/make/javax/crypto/Makefile b/make/javax/crypto/Makefile index 98b8a9158bf217f757abda589ea96329136b6b92..86588e855ef09f5706a79610c051dcacf3398ec3 100644 --- a/make/javax/crypto/Makefile +++ b/make/javax/crypto/Makefile @@ -1,5 +1,5 @@ # -# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2007-2008 Sun Microsystems, 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 @@ -96,7 +96,7 @@ # sign-jar Builds/signs jce.jar file (no install) # sign-policy Builds/signs policy files (no install) # -# obfus Builds/obfuscates/signs/installs jce.jar +# obfus Builds/obfuscates/signs jce.jar # # release Builds all targets in preparation # for workspace integration. @@ -110,8 +110,24 @@ BUILDDIR = ../.. PACKAGE = javax.crypto PRODUCT = sun +# +# The following is for when we need to do postprocessing +# (signing/obfuscation) against a read-only build. If the OUTPUTDIR +# isn't writable, the build currently crashes out. +# +ifndef OPENJDK + ifdef ALT_JCE_BUILD_DIR + # ===================================================== + # Where to place the output, in case we're building from a read-only + # build area. (e.g. a release engineering build.) + JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR} + IGNORE_WRITABLE_OUTPUTDIR_TEST=true + else + JCE_BUILD_DIR=${TEMPDIR} + endif +endif + include $(BUILDDIR)/common/Defs.gmk -include Defs-jce.gmk # # Location for the newly built classfiles. @@ -158,6 +174,8 @@ endif # OPENJDK # UNSIGNED_DIR = $(TEMPDIR)/unsigned +include Defs-jce.gmk + # ===================================================== # Build the unsigned jce.jar file. Signing/obfuscation comes later. @@ -299,7 +317,7 @@ ifndef OPENJDK # Sign the various jar files. Not needed for OpenJDK. # -SIGNED_DIR = $(TEMPDIR)/signed +SIGNED_DIR = $(JCE_BUILD_DIR)/signed SIGNED_POLICY_BUILDDIR = $(SIGNED_DIR)/policy SIGNED_POLICY_FILES = \ @@ -312,61 +330,87 @@ sign-jar: $(SIGNED_DIR)/jce.jar sign-policy: $(SIGNED_POLICY_FILES) +ifndef ALT_JCE_BUILD_DIR $(SIGNED_DIR)/jce.jar: $(UNSIGNED_DIR)/jce.jar - $(sign-file) +else +# +# We have to remove the build dependency, otherwise, we'll try to rebuild it +# which we can't do on a read-only filesystem. +# +$(SIGNED_DIR)/jce.jar: + @if [ ! -r $(UNSIGNED_DIR)/jce.jar ] ; then \ + $(ECHO) "Couldn't find $(UNSIGNED_DIR)/jce.jar"; \ + exit 1; \ + fi +endif + $(call sign-file, $(UNSIGNED_DIR)/jce.jar) $(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar: \ -$(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar - $(sign-file) + $(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar + $(call sign-file, $<) $(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar: \ -$(UNSIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar - $(sign-file) + $(UNSIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar + $(call sign-file, $<) $(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar: \ -$(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar - $(sign-file) + $(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar + $(call sign-file, $<) $(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar: \ -$(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar - $(sign-file) + $(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar + $(call sign-file, $<) # ===================================================== # Obfuscate/sign/install the JDK build. Not needed for OpenJDK. # -OBFUS_DIR = $(TEMPDIR)/obfus +OBFUS_DIR = $(JCE_BUILD_DIR)/obfus/jce CLOSED_DIR = $(BUILDDIR)/closed/javax/crypto obfus: $(OBFUS_DIR)/jce.jar $(release-warning) -$(OBFUS_DIR)/jce.jar: build-jar $(JCE_MANIFEST_FILE) +ifndef ALT_JCE_BUILD_DIR +$(OBFUS_DIR)/jce.jar: build-jar $(JCE_MANIFEST_FILE) $(OBFUS_DIR)/framework.dox +else +# +# We have to remove the build dependency, otherwise, we'll try to rebuild it +# which we can't do on a read-only filesystem. +# +$(OBFUS_DIR)/jce.jar: $(JCE_MANIFEST_FILE) $(OBFUS_DIR)/framework.dox + @if [ ! -d $(CLASSDESTDIR) ] ; then \ + $(ECHO) "Couldn't find $(CLASSDESTDIR)"; \ + exit 1; \ + fi +endif + @$(ECHO) ">>>Obfuscating JCE framework..." $(presign) $(preobfus) - @$(ECHO) ">>>Obfuscating JCE framework..." $(prep-target) $(CD) $(OBFUS_DIR); \ - $(OBFUSCATOR) -fv \ - $(CURRENT_DIRECTORY)/$(CLOSED_DIR)/obfus/framework.dox + $(OBFUSCATOR) -fv framework.dox @$(CD) $(OBFUS_DIR); $(java-vm-cleanup) + @# @# The sun.security.internal classes are currently not obfuscated @# due to an obfus problem. Manually copy them to the build directory @# so that they are included in the jce.jar file. + @# $(CP) -r $(CLASSDESTDIR)/sun $(OBFUS_DIR)/build - $(RM) $(UNSIGNED_DIR)/jce.jar $(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ \ -C $(OBFUS_DIR)/build javax \ -C $(OBFUS_DIR)/build sun \ $(JAR_JFLAGS) $(sign-target) - $(MKDIR) -p $(dir $(JAR_DESTFILE)) - $(RM) $(JAR_DESTFILE) - $(CP) $@ $(JAR_DESTFILE) @$(java-vm-cleanup) +$(OBFUS_DIR)/framework.dox: $(CLOSED_DIR)/obfus/framework.dox + @$(ECHO) ">>>Creating framework.dox" + $(prep-target) + $(SED) "s:@@TEMPDIR@@:$(ABS_TEMPDIR):" $< > $@ + # # The current obfuscator has a limitation in that it currently only # supports up to v49 class file format. Force v49 classfiles in our @@ -380,26 +424,27 @@ TARGET_CLASS_VERSION = 5 # unlimited policy file distribution, etc. # -release: $(OBFUS_DIR)/jce.jar sign-policy +release: $(OBFUS_DIR)/jce.jar sign-policy $(CLOSED_DIR)/doc/COPYRIGHT.html \ + $(CLOSED_DIR)/doc/README.txt $(RM) -r \ - $(RELEASE_DIR)/UnlimitedJCEPolicy \ - $(RELEASE_DIR)/jce.jar \ - $(RELEASE_DIR)/US_export_policy.jar \ - $(RELEASE_DIR)/local_policy.jar \ - $(RELEASE_DIR)/UnlimitedJCEPolicy.zip - $(MKDIR) -p $(RELEASE_DIR)/UnlimitedJCEPolicy - $(CP) $(OBFUS_DIR)/jce.jar $(RELEASE_DIR) - $(CP) -r \ - $(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar \ - $(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar \ - $(RELEASE_DIR) + $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy \ + $(JCE_BUILD_DIR)/release/jce.jar \ + $(JCE_BUILD_DIR)/release/US_export_policy.jar \ + $(JCE_BUILD_DIR)/release/local_policy.jar \ + $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy.zip + $(MKDIR) -p $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy + $(CP) $(OBFUS_DIR)/jce.jar $(JCE_BUILD_DIR)/release + $(CP) \ + $(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar \ + $(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar \ + $(JCE_BUILD_DIR)/release $(CP) \ $(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar \ - $(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar \ - $(RELEASE_DIR)/UnlimitedJCEPolicy - $(CP) $(CLOSED_DIR)/doc/COPYRIGHT.html \ - $(CLOSED_DIR)/doc/README.txt $(RELEASE_DIR)/UnlimitedJCEPolicy - cd $(RELEASE_DIR) ; \ + $(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar \ + $(CLOSED_DIR)/doc/COPYRIGHT.html \ + $(CLOSED_DIR)/doc/README.txt \ + $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy + cd $(JCE_BUILD_DIR)/release ; \ $(ZIPEXE) -qr UnlimitedJCEPolicy.zip UnlimitedJCEPolicy $(release-warning) @@ -478,7 +523,8 @@ endif clobber clean:: $(RM) -r $(JAR_DESTFILE) $(POLICY_DESTDIR)/US_export_policy.jar \ - $(POLICY_DESTDIR)/local_policy.jar $(DELETE_DIRS) $(TEMPDIR) + $(POLICY_DESTDIR)/local_policy.jar $(DELETE_DIRS) $(TEMPDIR) \ + $(JCE_BUILD_DIR) .PHONY: build-jar jar build-policy unlimited limited install-jar \ install-limited install-unlimited diff --git a/make/javax/others/Makefile b/make/javax/others/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..f5ce890138a7f7469f55a5a32b58ac62822239ab --- /dev/null +++ b/make/javax/others/Makefile @@ -0,0 +1,52 @@ +# +# Copyright 1998-2007 Sun Microsystems, 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. Sun designates this +# particular file as subject to the "Classpath" exception as provided +# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +# +# Makefile for building javax (other classes) +# + +BUILDDIR = ../.. +include $(BUILDDIR)/common/Defs.gmk + +# +# Files to compile +# +AUTO_FILES_JAVA_DIRS = \ + javax/naming \ + com/sun/naming/internal \ + javax/net \ + javax/script \ + javax/security/auth \ + javax/security/cert \ + javax/security/sasl \ + javax/smartcardio \ + javax/tools \ + javax/xml + +# +# Rules +# +include $(BUILDDIR)/common/Classes.gmk + diff --git a/make/sun/Makefile b/make/sun/Makefile index 588957b85423bfdb9982cc2e49ba66ac4efbf333..0ce9014e7e14cfce21e81676904f96ee0cce1e50 100644 --- a/make/sun/Makefile +++ b/make/sun/Makefile @@ -63,7 +63,7 @@ SUBDIRS = jar security javazic misc net audio $(RENDER_SUBDIR) image \ $(HEADLESS_SUBDIR) $(DGA_SUBDIR) \ font jpeg cmm applet rmi beans $(JDBC_SUBDIR) \ jawt text nio launcher management $(ORG_SUBDIR) \ - native2ascii serialver tools jconsole + native2ascii serialver tools jconsole tracing all build clean clobber:: $(SUBDIRS-loop) diff --git a/make/sun/nio/Makefile b/make/sun/nio/Makefile index c18e55a5cc7840025f22664694b626aadbc1e0ce..c8e8e37cbb4c88e872008c95fffef53749657cbc 100644 --- a/make/sun/nio/Makefile +++ b/make/sun/nio/Makefile @@ -1,5 +1,5 @@ # -# Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 1996-2008 Sun Microsystems, 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 @@ -73,11 +73,21 @@ build: $(CHARSETS_JAR) SERVICE_DESCRIPTION = java.nio.charset.spi.CharsetProvider SERVICE_DESCRIPTION_PATH = META-INF/services/$(SERVICE_DESCRIPTION) +GENCSDATASRC = $(BUILDDIR)/tools/CharsetMapping +FILES_MAP = $(GENCSDATASRC)/sjis0213.map +FILES_DAT = $(CLASSDESTDIR)/sun/nio/cs/ext/sjis0213.dat +CHARSETMAPPING_JARFILE = $(BUILDTOOLJARDIR)/charsetmapping.jar + +$(FILES_DAT): $(FILES_MAP) + @$(prep-target) + $(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE) \ + $(FILES_MAP) $(FILES_DAT) + $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH): \ $(SHARE_SRC)/classes/sun/nio/cs/ext/$(SERVICE_DESCRIPTION_PATH) $(install-file) -$(CHARSETS_JAR): $(FILES_class) $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH) +$(CHARSETS_JAR): $(FILES_class) $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH) $(FILES_DAT) $(BOOT_JAR_CMD) cf $(CHARSETS_JAR) \ -C $(CLASSDESTDIR) sun \ -C $(CLASSDESTDIR) $(SERVICE_DESCRIPTION_PATH) \ diff --git a/make/sun/security/mscapi/Makefile b/make/sun/security/mscapi/Makefile index e6b2372b69b4c6d10d1970dd5cb0a942c9d77e64..8223b5367093be199222d89b696628e3c4df3079 100644 --- a/make/sun/security/mscapi/Makefile +++ b/make/sun/security/mscapi/Makefile @@ -1,5 +1,5 @@ # -# Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2005-2008 Sun Microsystems, 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 @@ -92,8 +92,25 @@ BUILDDIR = ../../.. PACKAGE = sun.security.mscapi LIBRARY = sunmscapi PRODUCT = sun + +# +# The following is for when we need to do postprocessing +# (signing/obfuscation) against a read-only build. If the OUTPUTDIR +# isn't writable, the build currently crashes out. +# +ifndef OPENJDK + ifdef ALT_JCE_BUILD_DIR + # ===================================================== + # Where to place the output, in case we're building from a read-only + # build area. (e.g. a release engineering build.) + JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR} + IGNORE_WRITABLE_OUTPUTDIR_TEST=true + else + JCE_BUILD_DIR=${TEMPDIR} + endif +endif + include $(BUILDDIR)/common/Defs.gmk -include $(BUILDDIR)/javax/crypto/Defs-jce.gmk CPLUSPLUSLIBRARY=true @@ -163,6 +180,8 @@ all: build-jar install-prebuilt $(build-warning) endif +include $(BUILDDIR)/javax/crypto/Defs-jce.gmk + # ===================================================== # Build the unsigned sunmscapi.jar file. @@ -200,14 +219,26 @@ ifndef OPENJDK # Sign the provider jar file. Not needed for OpenJDK. # -SIGNED_DIR = $(TEMPDIR)/signed +SIGNED_DIR = $(JCE_BUILD_DIR)/signed sign: sign-jar sign-jar: $(SIGNED_DIR)/sunmscapi.jar +ifndef ALT_JCE_BUILD_DIR $(SIGNED_DIR)/sunmscapi.jar: $(UNSIGNED_DIR)/sunmscapi.jar - $(sign-file) +else +# +# We have to remove the build dependency, otherwise, we'll try to rebuild it +# which we can't do on a read-only filesystem. +# +$(SIGNED_DIR)/sunmscapi.jar: + @if [ ! -r $(UNSIGNED_DIR)/sunmscapi.jar ] ; then \ + $(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunmscapi.jar"; \ + exit 1; \ + fi +endif + $(call sign-file, $(UNSIGNED_DIR)/sunmscapi.jar) # ===================================================== @@ -215,9 +246,9 @@ $(SIGNED_DIR)/sunmscapi.jar: $(UNSIGNED_DIR)/sunmscapi.jar # release: $(SIGNED_DIR)/sunmscapi.jar - $(RM) $(RELEASE_DIR)/sunmscapi.jar - $(MKDIR) -p $(RELEASE_DIR) - $(CP) $(SIGNED_DIR)/sunmscapi.jar $(RELEASE_DIR) + $(RM) $(JCE_BUILD_DIR)/release/sunmscapi.jar + $(MKDIR) -p $(JCE_BUILD_DIR)/release + $(CP) $(SIGNED_DIR)/sunmscapi.jar $(JCE_BUILD_DIR)/release $(release-warning) endif # OPENJDK @@ -255,7 +286,7 @@ endif # clobber clean:: - $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) + $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR) .PHONY: build-jar jar install-jar ifndef OPENJDK diff --git a/make/sun/security/pkcs11/Makefile b/make/sun/security/pkcs11/Makefile index 32d77f90d94d0c06cb30d8a8fff2a3ba6df324aa..4508b20f843c57565082ee69b3a0563590b08163 100644 --- a/make/sun/security/pkcs11/Makefile +++ b/make/sun/security/pkcs11/Makefile @@ -1,5 +1,5 @@ # -# Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2003-2008 Sun Microsystems, 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 @@ -92,8 +92,25 @@ BUILDDIR = ../../.. PACKAGE = sun.security.pkcs11 LIBRARY = j2pkcs11 PRODUCT = sun + +# +# The following is for when we need to do postprocessing +# (signing/obfuscation) against a read-only build. If the OUTPUTDIR +# isn't writable, the build currently crashes out. +# +ifndef OPENJDK + ifdef ALT_JCE_BUILD_DIR + # ===================================================== + # Where to place the output, in case we're building from a read-only + # build area. (e.g. a release engineering build.) + JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR} + IGNORE_WRITABLE_OUTPUTDIR_TEST=true + else + JCE_BUILD_DIR=${TEMPDIR} + endif +endif + include $(BUILDDIR)/common/Defs.gmk -include $(BUILDDIR)/javax/crypto/Defs-jce.gmk # # C and Java Files @@ -163,6 +180,8 @@ all: build-jar install-prebuilt $(build-warning) endif +include $(BUILDDIR)/javax/crypto/Defs-jce.gmk + # ===================================================== # Build the unsigned sunpkcs11.jar file. @@ -200,14 +219,26 @@ ifndef OPENJDK # Sign the provider jar file. Not needed for OpenJDK. # -SIGNED_DIR = $(TEMPDIR)/signed +SIGNED_DIR = $(JCE_BUILD_DIR)/signed sign: sign-jar sign-jar: $(SIGNED_DIR)/sunpkcs11.jar +ifndef ALT_JCE_BUILD_DIR $(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar - $(sign-file) +else +# +# We have to remove the build dependency, otherwise, we'll try to rebuild it +# which we can't do on a read-only filesystem. +# +$(SIGNED_DIR)/sunpkcs11.jar: + @if [ ! -r $(UNSIGNED_DIR)/sunpkcs11.jar ] ; then \ + $(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunpkcs11.jar"; \ + exit 1; \ + fi +endif + $(call sign-file, $(UNSIGNED_DIR)/sunpkcs11.jar) # ===================================================== @@ -215,9 +246,9 @@ $(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar # release: $(SIGNED_DIR)/sunpkcs11.jar - $(RM) $(RELEASE_DIR)/sunpkcs11.jar - $(MKDIR) -p $(RELEASE_DIR) - $(CP) $(SIGNED_DIR)/sunpkcs11.jar $(RELEASE_DIR) + $(RM) $(JCE_BUILD_DIR)/release/sunpkcs11.jar + $(MKDIR) -p $(JCE_BUILD_DIR)/release + $(CP) $(SIGNED_DIR)/sunpkcs11.jar $(JCE_BUILD_DIR)/release $(release-warning) endif # OPENJDK @@ -255,7 +286,7 @@ endif # clobber clean:: - $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) + $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR) .PHONY: build-jar jar install-jar ifndef OPENJDK diff --git a/make/sun/splashscreen/Makefile b/make/sun/splashscreen/Makefile index 1b51d3a6484f2537734a7b1d8095752aa336b1f8..8a0dffe62c924f1bd29443ed408cf39b94badac0 100644 --- a/make/sun/splashscreen/Makefile +++ b/make/sun/splashscreen/Makefile @@ -85,3 +85,13 @@ vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen CPPFLAGS += -I$(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen -I$(SHARE_SRC)/native/$(PKGDIR)/splashscreen CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/image/jpeg -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3 +ifeq ($(PLATFORM), linux) + ifeq ($(ARCH_DATA_MODEL), 64) + # 64-bit gcc has problems compiling MMX instructions. + # Google it for more details. Possibly the newer versions of + # the PNG-library and/or the new compiler will not need this + # option in the future. + CPPFLAGS += -DPNG_NO_MMX_CODE + endif +endif + diff --git a/make/sun/tracing/Makefile b/make/sun/tracing/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..f7e21dd7a2bad2fab3e5791d6d79e82419c31908 --- /dev/null +++ b/make/sun/tracing/Makefile @@ -0,0 +1,26 @@ +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. +# + +# +# Makefile for building tracing package implementation classes +# + +BUILDDIR = ../.. +PACKAGE = sun.tracing +PRODUCT = sun +include $(BUILDDIR)/common/Defs.gmk + +SUBDIRS = dtrace +all build: + $(SUBDIRS-loop) +clean clobber:: + $(SUBDIRS-loop) + +AUTO_FILES_JAVA_DIRS = sun/tracing + +# +# Rules. +# +include $(BUILDDIR)/common/Classes.gmk diff --git a/make/sun/tracing/dtrace/Makefile b/make/sun/tracing/dtrace/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3f34086398f963f9ef99ce29630d66eb6b53e325 --- /dev/null +++ b/make/sun/tracing/dtrace/Makefile @@ -0,0 +1,59 @@ +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. +# + +# +# Makefile for building dtrace extension +# +BUILDDIR = ../../.. +PACKAGE = sun.tracing.dtrace +LIBRARY = jsdt +PRODUCT = sun +include $(BUILDDIR)/common/Defs.gmk + +# +# Use mapfile +# +FILES_m = mapfile-vers +include $(BUILDDIR)/common/Mapfile-vers.gmk + +NATIVE_DTRACE_DIR=native/sun/tracing/dtrace + +SRCDIR=$(SHARE_SRC)/$(NATIVE_DTRACE_DIR) +PSRCDIR=$(PLATFORM_SRC)/$(NATIVE_DTRACE_DIR) + +FILES_c = JVM.c jvm_symbols_md.c + +FILES_java = \ + sun/tracing/dtrace/Activation.java \ + sun/tracing/dtrace/DTraceProvider.java \ + sun/tracing/dtrace/DTraceProbe.java \ + sun/tracing/dtrace/DTraceProviderFactory.java \ + sun/tracing/dtrace/JVM.java + +FILES_export = $(FILES_java) + +ifeq ($(PLATFORM), linux) +OTHER_LDLIBS += -ldl +endif + +# +# Use JNI for generating header files +# +JAVAHFLAGS += -jni + +# +# Don't need to link against -ljava +# +JAVALIB= + +# +# Rules. +# +include $(BUILDDIR)/common/Library.gmk + +# +# Add to ambient vpath so we pick up the library files +# +vpath %.c $(SRCDIR):$(PSRCDIR) diff --git a/make/sun/tracing/dtrace/mapfile-vers b/make/sun/tracing/dtrace/mapfile-vers new file mode 100644 index 0000000000000000000000000000000000000000..4d5c359a0ac8e2cf6de4655a3cc21b3f001fb177 --- /dev/null +++ b/make/sun/tracing/dtrace/mapfile-vers @@ -0,0 +1,19 @@ +# +#ident "@(#)mapfile-vers 1.1 07/08/14" +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. +# + +# Define library interface. + +SUNWprivate_1.1 { + global: + Java_sun_tracing_dtrace_JVM_isSupported0; + Java_sun_tracing_dtrace_JVM_activate0; + Java_sun_tracing_dtrace_JVM_dispose0; + Java_sun_tracing_dtrace_JVM_isEnabled0; + Java_sun_tracing_dtrace_JVM_defineClass0; + local: + *; +}; diff --git a/make/sun/xawt/Makefile b/make/sun/xawt/Makefile index e0f59b738dbf4360cf67b8f2650d4b6740758a6e..4c56c5ea9a4a7ef445ec5854919a0e6ffd5a35bd 100644 --- a/make/sun/xawt/Makefile +++ b/make/sun/xawt/Makefile @@ -1,5 +1,5 @@ # -# Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2002-2008 Sun Microsystems, 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 @@ -246,7 +246,7 @@ $(SIZES): $(SIZERS) @if [ "$(DOCOMPARE)$(suffix $@)" = "true.64" ]; then \ $(ECHO) COMPARING $@ and $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \ $(DIFF) $@ $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \ - fi + fi $(TEMPDIR)/.gen.wrappers: $(SIZES) $(WRAPPER_GENERATOR_CLASS) $(XLIBTYPES) $(BOOT_JAVA_CMD) -cp $(WRAPPER_GENERATOR_TEMPDIR) WrapperGenerator \ @@ -256,10 +256,11 @@ touch.wrappers: $(TEMPDIR)/.gen.wrappers $(MKDIR) -p $(TEMPDIR) $(TOUCH) $(TEMPDIR)/.gen.wrappers -generated.clean: +generated.clean: $(RM) -r $(WRAPPER_GENERATOR_TEMPDIR) $(RM) -r $(WRAPPER_GENERATOR_DIR) $(RM) -r $(GEN_DIR)/*.java + $(RM) -r $(TEMPDIR)/.gen_icons ifdef OPENJDK ICONS_PATH_PREFIX=$(PLATFORM_SRC) diff --git a/make/tools/CharsetMapping/Makefile b/make/tools/CharsetMapping/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3ac068201cfdcb0c5f89dc860663d05b40ad69fe --- /dev/null +++ b/make/tools/CharsetMapping/Makefile @@ -0,0 +1,43 @@ +# +# Copyright 2008 Sun Microsystems, 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. Sun designates this +# particular file as subject to the "Classpath" exception as provided +# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +# +# Makefile for building the charsetmapping tool +# + +BUILDDIR = ../.. +PACKAGE = build.tools.charsetmapping +PRODUCT = tools +PROGRAM = charsetmapping +include $(BUILDDIR)/common/Defs.gmk + +BUILDTOOL_SOURCE_ROOT = $(BUILDDIR)/tools/src +BUILDTOOL_MAIN = $(PKGDIR)/GenerateMapping.java + +# +# Build tool jar rules. +# +include $(BUILDDIR)/common/BuildToolJar.gmk + diff --git a/make/tools/CharsetMapping/sjis0213.map b/make/tools/CharsetMapping/sjis0213.map new file mode 100644 index 0000000000000000000000000000000000000000..48b65d3bdc4db145c81f9043514bc3eea7708192 --- /dev/null +++ b/make/tools/CharsetMapping/sjis0213.map @@ -0,0 +1,11471 @@ +## Shift_JIS-2004 (JIS X 0213:2004 Appendix 1) vs Unicode mapping table +## +## Date: 13 May 2006 +## License: +## Copyright (C) 2001 earthian@tama.or.jp, All Rights Reserved. +## Copyright (C) 2001 I'O, All Rights Reserved. +## Copyright (C) 2006 Project X0213, All Rights Reserved. +## You can use, modify, distribute this table freely. +## Note: +## [1983] JIS codepoint defined by JIS X 0208-1983 +## [1990] JIS codepoint defined by JIS X 0208-1990 +## [2000] JIS codepoint defined by JIS X 0213:2000 +## [2004] JIS codepoint defined by JIS X 0213:2004 +## [Unicode3.1] UCS codepoint defined by Unicode 3.1 +## [Unicode3.2] UCS codepoint defined by Unicode 3.2 +## Fullwidth UCS fullwidth form (U+Fxxx) +## Windows Windows (CP932) mapping +## Some 0213 character can't represent by one UCS character. +## In this table, such characters are described as 'U+xxxx+xxxx'. +## +## +## (1)Added JIS0213 entries +## (2)Updated 2 entries +## 0x81b0 -> u+ff5e +## 0x815f -> u+ff3c +## +## JIS Unicode Name Note +## +## Note: Block f09f--f0fc has been moved to the correct(sorted) position +## +## GDB=1 GC=2 GCC=3> +## +# +# sjis0201 +# +0x20 U+0020 # SPACE +0x21 U+0021 # EXCLAMATION MARK +0x22 U+0022 # QUOTATION MARK +0x23 U+0023 # NUMBER SIGN +0x24 U+0024 # DOLLAR SIGN +0x25 U+0025 # PERCENT SIGN +0x26 U+0026 # AMPERSAND +0x27 U+0027 # APOSTROPHE +0x28 U+0028 # LEFT PARENTHESIS +0x29 U+0029 # RIGHT PARENTHESIS +0x2A U+002A # ASTERISK +0x2B U+002B # PLUS SIGN +0x2C U+002C # COMMA +0x2D U+002D # HYPHEN-MINUS +0x2E U+002E # FULL STOP +0x2F U+002F # SOLIDUS +0x30 U+0030 # DIGIT ZERO +0x31 U+0031 # DIGIT ONE +0x32 U+0032 # DIGIT TWO +0x33 U+0033 # DIGIT THREE +0x34 U+0034 # DIGIT FOUR +0x35 U+0035 # DIGIT FIVE +0x36 U+0036 # DIGIT SIX +0x37 U+0037 # DIGIT SEVEN +0x38 U+0038 # DIGIT EIGHT +0x39 U+0039 # DIGIT NINE +0x3A U+003A # COLON +0x3B U+003B # SEMICOLON +0x3C U+003C # LESS-THAN SIGN +0x3D U+003D # EQUALS SIGN +0x3E U+003E # GREATER-THAN SIGN +0x3F U+003F # QUESTION MARK +0x40 U+0040 # COMMERCIAL AT +0x41 U+0041 # LATIN CAPITAL LETTER A +0x42 U+0042 # LATIN CAPITAL LETTER B +0x43 U+0043 # LATIN CAPITAL LETTER C +0x44 U+0044 # LATIN CAPITAL LETTER D +0x45 U+0045 # LATIN CAPITAL LETTER E +0x46 U+0046 # LATIN CAPITAL LETTER F +0x47 U+0047 # LATIN CAPITAL LETTER G +0x48 U+0048 # LATIN CAPITAL LETTER H +0x49 U+0049 # LATIN CAPITAL LETTER I +0x4A U+004A # LATIN CAPITAL LETTER J +0x4B U+004B # LATIN CAPITAL LETTER K +0x4C U+004C # LATIN CAPITAL LETTER L +0x4D U+004D # LATIN CAPITAL LETTER M +0x4E U+004E # LATIN CAPITAL LETTER N +0x4F U+004F # LATIN CAPITAL LETTER O +0x50 U+0050 # LATIN CAPITAL LETTER P +0x51 U+0051 # LATIN CAPITAL LETTER Q +0x52 U+0052 # LATIN CAPITAL LETTER R +0x53 U+0053 # LATIN CAPITAL LETTER S +0x54 U+0054 # LATIN CAPITAL LETTER T +0x55 U+0055 # LATIN CAPITAL LETTER U +0x56 U+0056 # LATIN CAPITAL LETTER V +0x57 U+0057 # LATIN CAPITAL LETTER W +0x58 U+0058 # LATIN CAPITAL LETTER X +0x59 U+0059 # LATIN CAPITAL LETTER Y +0x5A U+005A # LATIN CAPITAL LETTER Z +0x5B U+005B # LEFT SQUARE BRACKET +0x5C U+005C # YEN SIGN +0x5D U+005D # RIGHT SQUARE BRACKET +0x5E U+005E # CIRCUMFLEX ACCENT +0x5F U+005F # LOW LINE +0x60 U+0060 # GRAVE ACCENT +0x61 U+0061 # LATIN SMALL LETTER A +0x62 U+0062 # LATIN SMALL LETTER B +0x63 U+0063 # LATIN SMALL LETTER C +0x64 U+0064 # LATIN SMALL LETTER D +0x65 U+0065 # LATIN SMALL LETTER E +0x66 U+0066 # LATIN SMALL LETTER F +0x67 U+0067 # LATIN SMALL LETTER G +0x68 U+0068 # LATIN SMALL LETTER H +0x69 U+0069 # LATIN SMALL LETTER I +0x6A U+006A # LATIN SMALL LETTER J +0x6B U+006B # LATIN SMALL LETTER K +0x6C U+006C # LATIN SMALL LETTER L +0x6D U+006D # LATIN SMALL LETTER M +0x6E U+006E # LATIN SMALL LETTER N +0x6F U+006F # LATIN SMALL LETTER O +0x70 U+0070 # LATIN SMALL LETTER P +0x71 U+0071 # LATIN SMALL LETTER Q +0x72 U+0072 # LATIN SMALL LETTER R +0x73 U+0073 # LATIN SMALL LETTER S +0x74 U+0074 # LATIN SMALL LETTER T +0x75 U+0075 # LATIN SMALL LETTER U +0x76 U+0076 # LATIN SMALL LETTER V +0x77 U+0077 # LATIN SMALL LETTER W +0x78 U+0078 # LATIN SMALL LETTER X +0x79 U+0079 # LATIN SMALL LETTER Y +0x7A U+007A # LATIN SMALL LETTER Z +0x7B U+007B # LEFT CURLY BRACKET +0x7C U+007C # VERTICAL LINE +0x7D U+007D # RIGHT CURLY BRACKET +0x7E U+007E # OVERLINE +0x7F U+007F # DELETE +0xA1 U+FF61 # HALFWIDTH IDEOGRAPHIC FULL STOP +0xA2 U+FF62 # HALFWIDTH LEFT CORNER BRACKET +0xA3 U+FF63 # HALFWIDTH RIGHT CORNER BRACKET +0xA4 U+FF64 # HALFWIDTH IDEOGRAPHIC COMMA +0xA5 U+FF65 # HALFWIDTH KATAKANA MIDDLE DOT +0xA6 U+FF66 # HALFWIDTH KATAKANA LETTER WO +0xA7 U+FF67 # HALFWIDTH KATAKANA LETTER SMALL A +0xA8 U+FF68 # HALFWIDTH KATAKANA LETTER SMALL I +0xA9 U+FF69 # HALFWIDTH KATAKANA LETTER SMALL U +0xAA U+FF6A # HALFWIDTH KATAKANA LETTER SMALL E +0xAB U+FF6B # HALFWIDTH KATAKANA LETTER SMALL O +0xAC U+FF6C # HALFWIDTH KATAKANA LETTER SMALL YA +0xAD U+FF6D # HALFWIDTH KATAKANA LETTER SMALL YU +0xAE U+FF6E # HALFWIDTH KATAKANA LETTER SMALL YO +0xAF U+FF6F # HALFWIDTH KATAKANA LETTER SMALL TU +0xB0 U+FF70 # HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK +0xB1 U+FF71 # HALFWIDTH KATAKANA LETTER A +0xB2 U+FF72 # HALFWIDTH KATAKANA LETTER I +0xB3 U+FF73 # HALFWIDTH KATAKANA LETTER U +0xB4 U+FF74 # HALFWIDTH KATAKANA LETTER E +0xB5 U+FF75 # HALFWIDTH KATAKANA LETTER O +0xB6 U+FF76 # HALFWIDTH KATAKANA LETTER KA +0xB7 U+FF77 # HALFWIDTH KATAKANA LETTER KI +0xB8 U+FF78 # HALFWIDTH KATAKANA LETTER KU +0xB9 U+FF79 # HALFWIDTH KATAKANA LETTER KE +0xBA U+FF7A # HALFWIDTH KATAKANA LETTER KO +0xBB U+FF7B # HALFWIDTH KATAKANA LETTER SA +0xBC U+FF7C # HALFWIDTH KATAKANA LETTER SI +0xBD U+FF7D # HALFWIDTH KATAKANA LETTER SU +0xBE U+FF7E # HALFWIDTH KATAKANA LETTER SE +0xBF U+FF7F # HALFWIDTH KATAKANA LETTER SO +0xC0 U+FF80 # HALFWIDTH KATAKANA LETTER TA +0xC1 U+FF81 # HALFWIDTH KATAKANA LETTER TI +0xC2 U+FF82 # HALFWIDTH KATAKANA LETTER TU +0xC3 U+FF83 # HALFWIDTH KATAKANA LETTER TE +0xC4 U+FF84 # HALFWIDTH KATAKANA LETTER TO +0xC5 U+FF85 # HALFWIDTH KATAKANA LETTER NA +0xC6 U+FF86 # HALFWIDTH KATAKANA LETTER NI +0xC7 U+FF87 # HALFWIDTH KATAKANA LETTER NU +0xC8 U+FF88 # HALFWIDTH KATAKANA LETTER NE +0xC9 U+FF89 # HALFWIDTH KATAKANA LETTER NO +0xCA U+FF8A # HALFWIDTH KATAKANA LETTER HA +0xCB U+FF8B # HALFWIDTH KATAKANA LETTER HI +0xCC U+FF8C # HALFWIDTH KATAKANA LETTER HU +0xCD U+FF8D # HALFWIDTH KATAKANA LETTER HE +0xCE U+FF8E # HALFWIDTH KATAKANA LETTER HO +0xCF U+FF8F # HALFWIDTH KATAKANA LETTER MA +0xD0 U+FF90 # HALFWIDTH KATAKANA LETTER MI +0xD1 U+FF91 # HALFWIDTH KATAKANA LETTER MU +0xD2 U+FF92 # HALFWIDTH KATAKANA LETTER ME +0xD3 U+FF93 # HALFWIDTH KATAKANA LETTER MO +0xD4 U+FF94 # HALFWIDTH KATAKANA LETTER YA +0xD5 U+FF95 # HALFWIDTH KATAKANA LETTER YU +0xD6 U+FF96 # HALFWIDTH KATAKANA LETTER YO +0xD7 U+FF97 # HALFWIDTH KATAKANA LETTER RA +0xD8 U+FF98 # HALFWIDTH KATAKANA LETTER RI +0xD9 U+FF99 # HALFWIDTH KATAKANA LETTER RU +0xDA U+FF9A # HALFWIDTH KATAKANA LETTER RE +0xDB U+FF9B # HALFWIDTH KATAKANA LETTER RO +0xDC U+FF9C # HALFWIDTH KATAKANA LETTER WA +0xDD U+FF9D # HALFWIDTH KATAKANA LETTER N +0xDE U+FF9E # HALFWIDTH KATAKANA VOICED SOUND MARK +0xDF U+FF9F # HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK +# +# sjis0213 +# +0x8140 U+3000 # IDEOGRAPHIC SPACE +0x8141 U+3001 # IDEOGRAPHIC COMMA +0x8142 U+3002 # IDEOGRAPHIC FULL STOP +0x8143 U+FF0C # FULLWIDTH COMMA +0x8144 U+FF0E # FULLWIDTH FULL STOP +0x8145 U+30FB # KATAKANA MIDDLE DOT +0x8146 U+FF1A # FULLWIDTH COLON +0x8147 U+FF1B # FULLWIDTH SEMICOLON +0x8148 U+FF1F # FULLWIDTH QUESTION MARK +0x8149 U+FF01 # FULLWIDTH EXCLAMATION MARK +0x814A U+309B # KATAKANA-HIRAGANA VOICED SOUND MARK +0x814B U+309C # KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK +0x814C U+00B4 # ACUTE ACCENT +0x814D U+FF40 # FULLWIDTH GRAVE ACCENT +0x814E U+00A8 # DIAERESIS +0x814F U+FF3E # FULLWIDTH CIRCUMFLEX ACCENT +0x8150 U+FFE3 # FULLWIDTH MACRON +0x8151 U+FF3F # FULLWIDTH LOW LINE +0x8152 U+30FD # KATAKANA ITERATION MARK +0x8153 U+30FE # KATAKANA VOICED ITERATION MARK +0x8154 U+309D # HIRAGANA ITERATION MARK +0x8155 U+309E # HIRAGANA VOICED ITERATION MARK +0x8156 U+3003 # DITTO MARK +0x8157 U+4EDD # +0x8158 U+3005 # IDEOGRAPHIC ITERATION MARK +0x8159 U+3006 # IDEOGRAPHIC CLOSING MARK +0x815A U+3007 # IDEOGRAPHIC NUMBER ZERO +0x815B U+30FC # KATAKANA-HIRAGANA PROLONGED SOUND MARK +0x815C U+2014 # EM DASH Windows: U+2015 +0x815D U+2010 # HYPHEN +0x815E U+FF0F # FULLWIDTH SOLIDUS +#0x815F U+005C # REVERSE SOLIDUS Fullwidth: U+FF3C +0x815F U+FF3C # REVERSE SOLIDUS Fullwidth: U+FF3C +0x8160 U+301C # WAVE DASH Windows: U+FF5E +0x8161 U+2016 # DOUBLE VERTICAL LINE Windows: U+2225 +0x8162 U+FF5C # FULLWIDTH VERTICAL LINE +0x8163 U+2026 # HORIZONTAL ELLIPSIS +0x8164 U+2025 # TWO DOT LEADER +0x8165 U+2018 # LEFT SINGLE QUOTATION MARK +0x8166 U+2019 # RIGHT SINGLE QUOTATION MARK +0x8167 U+201C # LEFT DOUBLE QUOTATION MARK +0x8168 U+201D # RIGHT DOUBLE QUOTATION MARK +0x8169 U+FF08 # FULLWIDTH LEFT PARENTHESIS +0x816A U+FF09 # FULLWIDTH RIGHT PARENTHESIS +0x816B U+3014 # LEFT TORTOISE SHELL BRACKET +0x816C U+3015 # RIGHT TORTOISE SHELL BRACKET +0x816D U+FF3B # FULLWIDTH LEFT SQUARE BRACKET +0x816E U+FF3D # FULLWIDTH RIGHT SQUARE BRACKET +0x816F U+FF5B # FULLWIDTH LEFT CURLY BRACKET +0x8170 U+FF5D # FULLWIDTH RIGHT CURLY BRACKET +0x8171 U+3008 # LEFT ANGLE BRACKET +0x8172 U+3009 # RIGHT ANGLE BRACKET +0x8173 U+300A # LEFT DOUBLE ANGLE BRACKET +0x8174 U+300B # RIGHT DOUBLE ANGLE BRACKET +0x8175 U+300C # LEFT CORNER BRACKET +0x8176 U+300D # RIGHT CORNER BRACKET +0x8177 U+300E # LEFT WHITE CORNER BRACKET +0x8178 U+300F # RIGHT WHITE CORNER BRACKET +0x8179 U+3010 # LEFT BLACK LENTICULAR BRACKET +0x817A U+3011 # RIGHT BLACK LENTICULAR BRACKET +0x817B U+FF0B # FULLWIDTH PLUS SIGN +0x817C U+2212 # MINUS SIGN Windows: U+FF0D +0x817D U+00B1 # PLUS-MINUS SIGN +0x817E U+00D7 # MULTIPLICATION SIGN +0x8180 U+00F7 # DIVISION SIGN +0x8181 U+FF1D # FULLWIDTH EQUALS SIGN +0x8182 U+2260 # NOT EQUAL TO +0x8183 U+FF1C # FULLWIDTH LESS-THAN SIGN +0x8184 U+FF1E # FULLWIDTH GREATER-THAN SIGN +0x8185 U+2266 # LESS-THAN OVER EQUAL TO +0x8186 U+2267 # GREATER-THAN OVER EQUAL TO +0x8187 U+221E # INFINITY +0x8188 U+2234 # THEREFORE +0x8189 U+2642 # MALE SIGN +0x818A U+2640 # FEMALE SIGN +0x818B U+00B0 # DEGREE SIGN +0x818C U+2032 # PRIME +0x818D U+2033 # DOUBLE PRIME +0x818E U+2103 # DEGREE CELSIUS +0x818F U+FFE5 # FULLWIDTH YEN SIGN +0x8190 U+FF04 # FULLWIDTH DOLLAR SIGN +0x8191 U+00A2 # CENT SIGN Windows: U+FFE0 +0x8192 U+00A3 # POUND SIGN Windows: U+FFE1 +0x8193 U+FF05 # FULLWIDTH PERCENT SIGN +0x8194 U+FF03 # FULLWIDTH NUMBER SIGN +0x8195 U+FF06 # FULLWIDTH AMPERSAND +0x8196 U+FF0A # FULLWIDTH ASTERISK +0x8197 U+FF20 # FULLWIDTH COMMERCIAL AT +0x8198 U+00A7 # SECTION SIGN +0x8199 U+2606 # WHITE STAR +0x819A U+2605 # BLACK STAR +0x819B U+25CB # WHITE CIRCLE +0x819C U+25CF # BLACK CIRCLE +0x819D U+25CE # BULLSEYE +0x819E U+25C7 # WHITE DIAMOND +0x819F U+25C6 # BLACK DIAMOND +0x81A0 U+25A1 # WHITE SQUARE +0x81A1 U+25A0 # BLACK SQUARE +0x81A2 U+25B3 # WHITE UP-POINTING TRIANGLE +0x81A3 U+25B2 # BLACK UP-POINTING TRIANGLE +0x81A4 U+25BD # WHITE DOWN-POINTING TRIANGLE +0x81A5 U+25BC # BLACK DOWN-POINTING TRIANGLE +0x81A6 U+203B # REFERENCE MARK +0x81A7 U+3012 # POSTAL MARK +0x81A8 U+2192 # RIGHTWARDS ARROW +0x81A9 U+2190 # LEFTWARDS ARROW +0x81AA U+2191 # UPWARDS ARROW +0x81AB U+2193 # DOWNWARDS ARROW +0x81AC U+3013 # GETA MARK +0x81AD U+FF07 # FULLWIDTH APOSTROPHE +0x81AE U+FF02 # FULLWIDTH QUOTATION MARK [2000] +0x81AF U+FF0D # FULLWIDTH HYPHEN-MINUS [2000] +#0x81B0 U+007E # TILDE [2000] Fullwidth: U+FF5E +0x81B0 U+FF5E # TILDE [2000] Fullwidth: U+FF5E +0x81B1 U+3033 # VERTICAL KANA REPEAT MARK UPPER HALF [2000] +0x81B2 U+3034 # VERTICAL KANA REPEAT WITH VOICED SOUND MARK UPPER HALF [2000] +0x81B3 U+3035 # VERTICAL KANA REPEAT MARK LOWER HALF [2000] +0x81B4 U+303B # VERTICAL IDEOGRAPHIC ITERATION MARK [2000] [Unicode3.2] +0x81B5 U+303C # MASU MARK [2000] [Unicode3.2] +0x81B6 U+30FF # KATAKANA DIGRAPH KOTO [2000] [Unicode3.2] +0x81B7 U+309F # HIRAGANA DIGRAPH YORI [2000] [Unicode3.2] +0x81B8 U+2208 # ELEMENT OF [1983] +0x81B9 U+220B # CONTAINS AS MEMBER [1983] +0x81BA U+2286 # SUBSET OF OR EQUAL TO [1983] +0x81BB U+2287 # SUPERSET OF OR EQUAL TO [1983] +0x81BC U+2282 # SUBSET OF [1983] +0x81BD U+2283 # SUPERSET OF [1983] +0x81BE U+222A # UNION [1983] +0x81BF U+2229 # INTERSECTION [1983] +0x81C0 U+2284 # NOT A SUBSET OF [2000] +0x81C1 U+2285 # NOT A SUPERSET OF [2000] +0x81C2 U+228A # SUBSET OF WITH NOT EQUAL TO [2000] +0x81C3 U+228B # SUPERSET OF WITH NOT EQUAL TO [2000] +0x81C4 U+2209 # NOT AN ELEMENT OF [2000] +0x81C5 U+2205 # EMPTY SET [2000] +0x81C6 U+2305 # PROJECTIVE [2000] +0x81C7 U+2306 # PERSPECTIVE [2000] +0x81C8 U+2227 # LOGICAL AND [1983] +0x81C9 U+2228 # LOGICAL OR [1983] +0x81CA U+00AC # NOT SIGN [1983] Windows: U+FFE2 +0x81CB U+21D2 # RIGHTWARDS DOUBLE ARROW [1983] +0x81CC U+21D4 # LEFT RIGHT DOUBLE ARROW [1983] +0x81CD U+2200 # FOR ALL [1983] +0x81CE U+2203 # THERE EXISTS [1983] +0x81CF U+2295 # CIRCLED PLUS [2000] +0x81D0 U+2296 # CIRCLED MINUS [2000] +0x81D1 U+2297 # CIRCLED TIMES [2000] +0x81D2 U+2225 # PARALLEL TO [2000] +0x81D3 U+2226 # NOT PARALLEL TO [2000] +0x81D4 U+FF5F # FULLWIDTH LEFT WHITE PARENTHESIS [2000] [Unicode3.2] +0x81D5 U+FF60 # FULLWIDTH RIGHT WHITE PARENTHESIS [2000] [Unicode3.2] +0x81D6 U+3018 # LEFT WHITE TORTOISE SHELL BRACKET [2000] +0x81D7 U+3019 # RIGHT WHITE TORTOISE SHELL BRACKET [2000] +0x81D8 U+3016 # LEFT WHITE LENTICULAR BRACKET [2000] +0x81D9 U+3017 # RIGHT WHITE LENTICULAR BRACKET [2000] +0x81DA U+2220 # ANGLE [1983] +0x81DB U+22A5 # UP TACK [1983] +0x81DC U+2312 # ARC [1983] +0x81DD U+2202 # PARTIAL DIFFERENTIAL [1983] +0x81DE U+2207 # NABLA [1983] +0x81DF U+2261 # IDENTICAL TO [1983] +0x81E0 U+2252 # APPROXIMATELY EQUAL TO OR THE IMAGE OF [1983] +0x81E1 U+226A # MUCH LESS-THAN [1983] +0x81E2 U+226B # MUCH GREATER-THAN [1983] +0x81E3 U+221A # SQUARE ROOT [1983] +0x81E4 U+223D # REVERSED TILDE [1983] +0x81E5 U+221D # PROPORTIONAL TO [1983] +0x81E6 U+2235 # BECAUSE [1983] +0x81E7 U+222B # INTEGRAL [1983] +0x81E8 U+222C # DOUBLE INTEGRAL [1983] +0x81E9 U+2262 # NOT IDENTICAL TO [2000] +0x81EA U+2243 # ASYMPTOTICALLY EQUAL TO [2000] +0x81EB U+2245 # APPROXIMATELY EQUAL TO [2000] +0x81EC U+2248 # ALMOST EQUAL TO [2000] +0x81ED U+2276 # LESS-THAN OR GREATER-THAN [2000] +0x81EE U+2277 # GREATER-THAN OR LESS-THAN [2000] +0x81EF U+2194 # LEFT RIGHT ARROW [2000] +0x81F0 U+212B # ANGSTROM SIGN [1983] +0x81F1 U+2030 # PER MILLE SIGN [1983] +0x81F2 U+266F # MUSIC SHARP SIGN [1983] +0x81F3 U+266D # MUSIC FLAT SIGN [1983] +0x81F4 U+266A # EIGHTH NOTE [1983] +0x81F5 U+2020 # DAGGER [1983] +0x81F6 U+2021 # DOUBLE DAGGER [1983] +0x81F7 U+00B6 # PILCROW SIGN [1983] +0x81F8 U+266E # MUSIC NATURAL SIGN [2000] +0x81F9 U+266B # BEAMED EIGHTH NOTES [2000] +0x81FA U+266C # BEAMED SIXTEENTH NOTES [2000] +0x81FB U+2669 # QUARTER NOTE [2000] +0x81FC U+25EF # LARGE CIRCLE [1983] +0x8240 U+25B7 # WHITE RIGHT-POINTING TRIANGLE [2000] +0x8241 U+25B6 # BLACK RIGHT-POINTING TRIANGLE [2000] +0x8242 U+25C1 # WHITE LEFT-POINTING TRIANGLE [2000] +0x8243 U+25C0 # BLACK LEFT-POINTING TRIANGLE [2000] +0x8244 U+2197 # NORTH EAST ARROW [2000] +0x8245 U+2198 # SOUTH EAST ARROW [2000] +0x8246 U+2196 # NORTH WEST ARROW [2000] +0x8247 U+2199 # SOUTH WEST ARROW [2000] +0x8248 U+21C4 # RIGHTWARDS ARROW OVER LEFTWARDS ARROW [2000] +0x8249 U+21E8 # RIGHTWARDS WHITE ARROW [2000] +0x824A U+21E6 # LEFTWARDS WHITE ARROW [2000] +0x824B U+21E7 # UPWARDS WHITE ARROW [2000] +0x824C U+21E9 # DOWNWARDS WHITE ARROW [2000] +0x824D U+2934 # ARROW POINTING RIGHTWARDS THEN CURVING UPWARDS [2000] [Unicode3.2] +0x824E U+2935 # ARROW POINTING RIGHTWARDS THEN CURVING DOWNWARDS [2000] [Unicode3.2] +0x824F U+FF10 # FULLWIDTH DIGIT ZERO +0x8250 U+FF11 # FULLWIDTH DIGIT ONE +0x8251 U+FF12 # FULLWIDTH DIGIT TWO +0x8252 U+FF13 # FULLWIDTH DIGIT THREE +0x8253 U+FF14 # FULLWIDTH DIGIT FOUR +0x8254 U+FF15 # FULLWIDTH DIGIT FIVE +0x8255 U+FF16 # FULLWIDTH DIGIT SIX +0x8256 U+FF17 # FULLWIDTH DIGIT SEVEN +0x8257 U+FF18 # FULLWIDTH DIGIT EIGHT +0x8258 U+FF19 # FULLWIDTH DIGIT NINE +0x8259 U+29BF # CIRCLED BULLET [2000] [Unicode3.2] +0x825A U+25C9 # FISHEYE [2000] +0x825B U+303D # PART ALTERNATION MARK [2000] [Unicode3.2] +0x825C U+FE46 # WHITE SESAME DOT [2000] [Unicode3.2] +0x825D U+FE45 # SESAME DOT [2000] [Unicode3.2] +0x825E U+25E6 # WHITE BULLET [2000] +0x825F U+2022 # BULLET [2000] +0x8260 U+FF21 # FULLWIDTH LATIN CAPITAL LETTER A +0x8261 U+FF22 # FULLWIDTH LATIN CAPITAL LETTER B +0x8262 U+FF23 # FULLWIDTH LATIN CAPITAL LETTER C +0x8263 U+FF24 # FULLWIDTH LATIN CAPITAL LETTER D +0x8264 U+FF25 # FULLWIDTH LATIN CAPITAL LETTER E +0x8265 U+FF26 # FULLWIDTH LATIN CAPITAL LETTER F +0x8266 U+FF27 # FULLWIDTH LATIN CAPITAL LETTER G +0x8267 U+FF28 # FULLWIDTH LATIN CAPITAL LETTER H +0x8268 U+FF29 # FULLWIDTH LATIN CAPITAL LETTER I +0x8269 U+FF2A # FULLWIDTH LATIN CAPITAL LETTER J +0x826A U+FF2B # FULLWIDTH LATIN CAPITAL LETTER K +0x826B U+FF2C # FULLWIDTH LATIN CAPITAL LETTER L +0x826C U+FF2D # FULLWIDTH LATIN CAPITAL LETTER M +0x826D U+FF2E # FULLWIDTH LATIN CAPITAL LETTER N +0x826E U+FF2F # FULLWIDTH LATIN CAPITAL LETTER O +0x826F U+FF30 # FULLWIDTH LATIN CAPITAL LETTER P +0x8270 U+FF31 # FULLWIDTH LATIN CAPITAL LETTER Q +0x8271 U+FF32 # FULLWIDTH LATIN CAPITAL LETTER R +0x8272 U+FF33 # FULLWIDTH LATIN CAPITAL LETTER S +0x8273 U+FF34 # FULLWIDTH LATIN CAPITAL LETTER T +0x8274 U+FF35 # FULLWIDTH LATIN CAPITAL LETTER U +0x8275 U+FF36 # FULLWIDTH LATIN CAPITAL LETTER V +0x8276 U+FF37 # FULLWIDTH LATIN CAPITAL LETTER W +0x8277 U+FF38 # FULLWIDTH LATIN CAPITAL LETTER X +0x8278 U+FF39 # FULLWIDTH LATIN CAPITAL LETTER Y +0x8279 U+FF3A # FULLWIDTH LATIN CAPITAL LETTER Z +0x827A U+2213 # MINUS-OR-PLUS SIGN [2000] +0x827B U+2135 # ALEF SYMBOL [2000] +0x827C U+210F # PLANCK CONSTANT OVER TWO PI [2000] +0x827D U+33CB # SQUARE HP [2000] +0x827E U+2113 # SCRIPT SMALL L [2000] +0x8280 U+2127 # INVERTED OHM SIGN [2000] +0x8281 U+FF41 # FULLWIDTH LATIN SMALL LETTER A +0x8282 U+FF42 # FULLWIDTH LATIN SMALL LETTER B +0x8283 U+FF43 # FULLWIDTH LATIN SMALL LETTER C +0x8284 U+FF44 # FULLWIDTH LATIN SMALL LETTER D +0x8285 U+FF45 # FULLWIDTH LATIN SMALL LETTER E +0x8286 U+FF46 # FULLWIDTH LATIN SMALL LETTER F +0x8287 U+FF47 # FULLWIDTH LATIN SMALL LETTER G +0x8288 U+FF48 # FULLWIDTH LATIN SMALL LETTER H +0x8289 U+FF49 # FULLWIDTH LATIN SMALL LETTER I +0x828A U+FF4A # FULLWIDTH LATIN SMALL LETTER J +0x828B U+FF4B # FULLWIDTH LATIN SMALL LETTER K +0x828C U+FF4C # FULLWIDTH LATIN SMALL LETTER L +0x828D U+FF4D # FULLWIDTH LATIN SMALL LETTER M +0x828E U+FF4E # FULLWIDTH LATIN SMALL LETTER N +0x828F U+FF4F # FULLWIDTH LATIN SMALL LETTER O +0x8290 U+FF50 # FULLWIDTH LATIN SMALL LETTER P +0x8291 U+FF51 # FULLWIDTH LATIN SMALL LETTER Q +0x8292 U+FF52 # FULLWIDTH LATIN SMALL LETTER R +0x8293 U+FF53 # FULLWIDTH LATIN SMALL LETTER S +0x8294 U+FF54 # FULLWIDTH LATIN SMALL LETTER T +0x8295 U+FF55 # FULLWIDTH LATIN SMALL LETTER U +0x8296 U+FF56 # FULLWIDTH LATIN SMALL LETTER V +0x8297 U+FF57 # FULLWIDTH LATIN SMALL LETTER W +0x8298 U+FF58 # FULLWIDTH LATIN SMALL LETTER X +0x8299 U+FF59 # FULLWIDTH LATIN SMALL LETTER Y +0x829A U+FF5A # FULLWIDTH LATIN SMALL LETTER Z +0x829B U+30A0 # KATAKANA-HIRAGANA DOUBLE HYPHEN [2000] [Unicode3.2] +0x829C U+2013 # EN DASH [2000] +0x829D U+29FA # DOUBLE PLUS [2000] [Unicode3.2] +0x829E U+29FB # TRIPLE PLUS [2000] [Unicode3.2] +0x829F U+3041 # HIRAGANA LETTER SMALL A +0x82A0 U+3042 # HIRAGANA LETTER A +0x82A1 U+3043 # HIRAGANA LETTER SMALL I +0x82A2 U+3044 # HIRAGANA LETTER I +0x82A3 U+3045 # HIRAGANA LETTER SMALL U +0x82A4 U+3046 # HIRAGANA LETTER U +0x82A5 U+3047 # HIRAGANA LETTER SMALL E +0x82A6 U+3048 # HIRAGANA LETTER E +0x82A7 U+3049 # HIRAGANA LETTER SMALL O +0x82A8 U+304A # HIRAGANA LETTER O +0x82A9 U+304B # HIRAGANA LETTER KA +0x82AA U+304C # HIRAGANA LETTER GA +0x82AB U+304D # HIRAGANA LETTER KI +0x82AC U+304E # HIRAGANA LETTER GI +0x82AD U+304F # HIRAGANA LETTER KU +0x82AE U+3050 # HIRAGANA LETTER GU +0x82AF U+3051 # HIRAGANA LETTER KE +0x82B0 U+3052 # HIRAGANA LETTER GE +0x82B1 U+3053 # HIRAGANA LETTER KO +0x82B2 U+3054 # HIRAGANA LETTER GO +0x82B3 U+3055 # HIRAGANA LETTER SA +0x82B4 U+3056 # HIRAGANA LETTER ZA +0x82B5 U+3057 # HIRAGANA LETTER SI +0x82B6 U+3058 # HIRAGANA LETTER ZI +0x82B7 U+3059 # HIRAGANA LETTER SU +0x82B8 U+305A # HIRAGANA LETTER ZU +0x82B9 U+305B # HIRAGANA LETTER SE +0x82BA U+305C # HIRAGANA LETTER ZE +0x82BB U+305D # HIRAGANA LETTER SO +0x82BC U+305E # HIRAGANA LETTER ZO +0x82BD U+305F # HIRAGANA LETTER TA +0x82BE U+3060 # HIRAGANA LETTER DA +0x82BF U+3061 # HIRAGANA LETTER TI +0x82C0 U+3062 # HIRAGANA LETTER DI +0x82C1 U+3063 # HIRAGANA LETTER SMALL TU +0x82C2 U+3064 # HIRAGANA LETTER TU +0x82C3 U+3065 # HIRAGANA LETTER DU +0x82C4 U+3066 # HIRAGANA LETTER TE +0x82C5 U+3067 # HIRAGANA LETTER DE +0x82C6 U+3068 # HIRAGANA LETTER TO +0x82C7 U+3069 # HIRAGANA LETTER DO +0x82C8 U+306A # HIRAGANA LETTER NA +0x82C9 U+306B # HIRAGANA LETTER NI +0x82CA U+306C # HIRAGANA LETTER NU +0x82CB U+306D # HIRAGANA LETTER NE +0x82CC U+306E # HIRAGANA LETTER NO +0x82CD U+306F # HIRAGANA LETTER HA +0x82CE U+3070 # HIRAGANA LETTER BA +0x82CF U+3071 # HIRAGANA LETTER PA +0x82D0 U+3072 # HIRAGANA LETTER HI +0x82D1 U+3073 # HIRAGANA LETTER BI +0x82D2 U+3074 # HIRAGANA LETTER PI +0x82D3 U+3075 # HIRAGANA LETTER HU +0x82D4 U+3076 # HIRAGANA LETTER BU +0x82D5 U+3077 # HIRAGANA LETTER PU +0x82D6 U+3078 # HIRAGANA LETTER HE +0x82D7 U+3079 # HIRAGANA LETTER BE +0x82D8 U+307A # HIRAGANA LETTER PE +0x82D9 U+307B # HIRAGANA LETTER HO +0x82DA U+307C # HIRAGANA LETTER BO +0x82DB U+307D # HIRAGANA LETTER PO +0x82DC U+307E # HIRAGANA LETTER MA +0x82DD U+307F # HIRAGANA LETTER MI +0x82DE U+3080 # HIRAGANA LETTER MU +0x82DF U+3081 # HIRAGANA LETTER ME +0x82E0 U+3082 # HIRAGANA LETTER MO +0x82E1 U+3083 # HIRAGANA LETTER SMALL YA +0x82E2 U+3084 # HIRAGANA LETTER YA +0x82E3 U+3085 # HIRAGANA LETTER SMALL YU +0x82E4 U+3086 # HIRAGANA LETTER YU +0x82E5 U+3087 # HIRAGANA LETTER SMALL YO +0x82E6 U+3088 # HIRAGANA LETTER YO +0x82E7 U+3089 # HIRAGANA LETTER RA +0x82E8 U+308A # HIRAGANA LETTER RI +0x82E9 U+308B # HIRAGANA LETTER RU +0x82EA U+308C # HIRAGANA LETTER RE +0x82EB U+308D # HIRAGANA LETTER RO +0x82EC U+308E # HIRAGANA LETTER SMALL WA +0x82ED U+308F # HIRAGANA LETTER WA +0x82EE U+3090 # HIRAGANA LETTER WI +0x82EF U+3091 # HIRAGANA LETTER WE +0x82F0 U+3092 # HIRAGANA LETTER WO +0x82F1 U+3093 # HIRAGANA LETTER N +0x82F2 U+3094 # HIRAGANA LETTER VU [2000] +0x82F3 U+3095 # HIRAGANA LETTER SMALL KA [2000] [Unicode3.2] +0x82F4 U+3096 # HIRAGANA LETTER SMALL KE [2000] [Unicode3.2] +0x82F5 U+304B+309A # [2000] +0x82F6 U+304D+309A # [2000] +0x82F7 U+304F+309A # [2000] +0x82F8 U+3051+309A # [2000] +0x82F9 U+3053+309A # [2000] +0x82FA # +0x82FB # +0x82FC # +0x8340 U+30A1 # KATAKANA LETTER SMALL A +0x8341 U+30A2 # KATAKANA LETTER A +0x8342 U+30A3 # KATAKANA LETTER SMALL I +0x8343 U+30A4 # KATAKANA LETTER I +0x8344 U+30A5 # KATAKANA LETTER SMALL U +0x8345 U+30A6 # KATAKANA LETTER U +0x8346 U+30A7 # KATAKANA LETTER SMALL E +0x8347 U+30A8 # KATAKANA LETTER E +0x8348 U+30A9 # KATAKANA LETTER SMALL O +0x8349 U+30AA # KATAKANA LETTER O +0x834A U+30AB # KATAKANA LETTER KA +0x834B U+30AC # KATAKANA LETTER GA +0x834C U+30AD # KATAKANA LETTER KI +0x834D U+30AE # KATAKANA LETTER GI +0x834E U+30AF # KATAKANA LETTER KU +0x834F U+30B0 # KATAKANA LETTER GU +0x8350 U+30B1 # KATAKANA LETTER KE +0x8351 U+30B2 # KATAKANA LETTER GE +0x8352 U+30B3 # KATAKANA LETTER KO +0x8353 U+30B4 # KATAKANA LETTER GO +0x8354 U+30B5 # KATAKANA LETTER SA +0x8355 U+30B6 # KATAKANA LETTER ZA +0x8356 U+30B7 # KATAKANA LETTER SI +0x8357 U+30B8 # KATAKANA LETTER ZI +0x8358 U+30B9 # KATAKANA LETTER SU +0x8359 U+30BA # KATAKANA LETTER ZU +0x835A U+30BB # KATAKANA LETTER SE +0x835B U+30BC # KATAKANA LETTER ZE +0x835C U+30BD # KATAKANA LETTER SO +0x835D U+30BE # KATAKANA LETTER ZO +0x835E U+30BF # KATAKANA LETTER TA +0x835F U+30C0 # KATAKANA LETTER DA +0x8360 U+30C1 # KATAKANA LETTER TI +0x8361 U+30C2 # KATAKANA LETTER DI +0x8362 U+30C3 # KATAKANA LETTER SMALL TU +0x8363 U+30C4 # KATAKANA LETTER TU +0x8364 U+30C5 # KATAKANA LETTER DU +0x8365 U+30C6 # KATAKANA LETTER TE +0x8366 U+30C7 # KATAKANA LETTER DE +0x8367 U+30C8 # KATAKANA LETTER TO +0x8368 U+30C9 # KATAKANA LETTER DO +0x8369 U+30CA # KATAKANA LETTER NA +0x836A U+30CB # KATAKANA LETTER NI +0x836B U+30CC # KATAKANA LETTER NU +0x836C U+30CD # KATAKANA LETTER NE +0x836D U+30CE # KATAKANA LETTER NO +0x836E U+30CF # KATAKANA LETTER HA +0x836F U+30D0 # KATAKANA LETTER BA +0x8370 U+30D1 # KATAKANA LETTER PA +0x8371 U+30D2 # KATAKANA LETTER HI +0x8372 U+30D3 # KATAKANA LETTER BI +0x8373 U+30D4 # KATAKANA LETTER PI +0x8374 U+30D5 # KATAKANA LETTER HU +0x8375 U+30D6 # KATAKANA LETTER BU +0x8376 U+30D7 # KATAKANA LETTER PU +0x8377 U+30D8 # KATAKANA LETTER HE +0x8378 U+30D9 # KATAKANA LETTER BE +0x8379 U+30DA # KATAKANA LETTER PE +0x837A U+30DB # KATAKANA LETTER HO +0x837B U+30DC # KATAKANA LETTER BO +0x837C U+30DD # KATAKANA LETTER PO +0x837D U+30DE # KATAKANA LETTER MA +0x837E U+30DF # KATAKANA LETTER MI +0x8380 U+30E0 # KATAKANA LETTER MU +0x8381 U+30E1 # KATAKANA LETTER ME +0x8382 U+30E2 # KATAKANA LETTER MO +0x8383 U+30E3 # KATAKANA LETTER SMALL YA +0x8384 U+30E4 # KATAKANA LETTER YA +0x8385 U+30E5 # KATAKANA LETTER SMALL YU +0x8386 U+30E6 # KATAKANA LETTER YU +0x8387 U+30E7 # KATAKANA LETTER SMALL YO +0x8388 U+30E8 # KATAKANA LETTER YO +0x8389 U+30E9 # KATAKANA LETTER RA +0x838A U+30EA # KATAKANA LETTER RI +0x838B U+30EB # KATAKANA LETTER RU +0x838C U+30EC # KATAKANA LETTER RE +0x838D U+30ED # KATAKANA LETTER RO +0x838E U+30EE # KATAKANA LETTER SMALL WA +0x838F U+30EF # KATAKANA LETTER WA +0x8390 U+30F0 # KATAKANA LETTER WI +0x8391 U+30F1 # KATAKANA LETTER WE +0x8392 U+30F2 # KATAKANA LETTER WO +0x8393 U+30F3 # KATAKANA LETTER N +0x8394 U+30F4 # KATAKANA LETTER VU +0x8395 U+30F5 # KATAKANA LETTER SMALL KA +0x8396 U+30F6 # KATAKANA LETTER SMALL KE +0x8397 U+30AB+309A # [2000] +0x8398 U+30AD+309A # [2000] +0x8399 U+30AF+309A # [2000] +0x839A U+30B1+309A # [2000] +0x839B U+30B3+309A # [2000] +0x839C U+30BB+309A # [2000] +0x839D U+30C4+309A # [2000] +0x839E U+30C8+309A # [2000] +0x839F U+0391 # GREEK CAPITAL LETTER ALPHA +0x83A0 U+0392 # GREEK CAPITAL LETTER BETA +0x83A1 U+0393 # GREEK CAPITAL LETTER GAMMA +0x83A2 U+0394 # GREEK CAPITAL LETTER DELTA +0x83A3 U+0395 # GREEK CAPITAL LETTER EPSILON +0x83A4 U+0396 # GREEK CAPITAL LETTER ZETA +0x83A5 U+0397 # GREEK CAPITAL LETTER ETA +0x83A6 U+0398 # GREEK CAPITAL LETTER THETA +0x83A7 U+0399 # GREEK CAPITAL LETTER IOTA +0x83A8 U+039A # GREEK CAPITAL LETTER KAPPA +0x83A9 U+039B # GREEK CAPITAL LETTER LAMDA +0x83AA U+039C # GREEK CAPITAL LETTER MU +0x83AB U+039D # GREEK CAPITAL LETTER NU +0x83AC U+039E # GREEK CAPITAL LETTER XI +0x83AD U+039F # GREEK CAPITAL LETTER OMICRON +0x83AE U+03A0 # GREEK CAPITAL LETTER PI +0x83AF U+03A1 # GREEK CAPITAL LETTER RHO +0x83B0 U+03A3 # GREEK CAPITAL LETTER SIGMA +0x83B1 U+03A4 # GREEK CAPITAL LETTER TAU +0x83B2 U+03A5 # GREEK CAPITAL LETTER UPSILON +0x83B3 U+03A6 # GREEK CAPITAL LETTER PHI +0x83B4 U+03A7 # GREEK CAPITAL LETTER CHI +0x83B5 U+03A8 # GREEK CAPITAL LETTER PSI +0x83B6 U+03A9 # GREEK CAPITAL LETTER OMEGA +0x83B7 U+2664 # WHITE SPADE SUIT [2000] +0x83B8 U+2660 # BLACK SPADE SUIT [2000] +0x83B9 U+2662 # WHITE DIAMOND SUIT [2000] +0x83BA U+2666 # BLACK DIAMOND SUIT [2000] +0x83BB U+2661 # WHITE HEART SUIT [2000] +0x83BC U+2665 # BLACK HEART SUIT [2000] +0x83BD U+2667 # WHITE CLUB SUIT [2000] +0x83BE U+2663 # BLACK CLUB SUIT [2000] +0x83BF U+03B1 # GREEK SMALL LETTER ALPHA +0x83C0 U+03B2 # GREEK SMALL LETTER BETA +0x83C1 U+03B3 # GREEK SMALL LETTER GAMMA +0x83C2 U+03B4 # GREEK SMALL LETTER DELTA +0x83C3 U+03B5 # GREEK SMALL LETTER EPSILON +0x83C4 U+03B6 # GREEK SMALL LETTER ZETA +0x83C5 U+03B7 # GREEK SMALL LETTER ETA +0x83C6 U+03B8 # GREEK SMALL LETTER THETA +0x83C7 U+03B9 # GREEK SMALL LETTER IOTA +0x83C8 U+03BA # GREEK SMALL LETTER KAPPA +0x83C9 U+03BB # GREEK SMALL LETTER LAMDA +0x83CA U+03BC # GREEK SMALL LETTER MU +0x83CB U+03BD # GREEK SMALL LETTER NU +0x83CC U+03BE # GREEK SMALL LETTER XI +0x83CD U+03BF # GREEK SMALL LETTER OMICRON +0x83CE U+03C0 # GREEK SMALL LETTER PI +0x83CF U+03C1 # GREEK SMALL LETTER RHO +0x83D0 U+03C3 # GREEK SMALL LETTER SIGMA +0x83D1 U+03C4 # GREEK SMALL LETTER TAU +0x83D2 U+03C5 # GREEK SMALL LETTER UPSILON +0x83D3 U+03C6 # GREEK SMALL LETTER PHI +0x83D4 U+03C7 # GREEK SMALL LETTER CHI +0x83D5 U+03C8 # GREEK SMALL LETTER PSI +0x83D6 U+03C9 # GREEK SMALL LETTER OMEGA +0x83D7 U+03C2 # GREEK SMALL LETTER FINAL SIGMA [2000] +0x83D8 U+24F5 # DOUBLE CIRCLED DIGIT ONE [2000] [Unicode3.2] +0x83D9 U+24F6 # DOUBLE CIRCLED DIGIT TWO [2000] [Unicode3.2] +0x83DA U+24F7 # DOUBLE CIRCLED DIGIT THREE [2000] [Unicode3.2] +0x83DB U+24F8 # DOUBLE CIRCLED DIGIT FOUR [2000] [Unicode3.2] +0x83DC U+24F9 # DOUBLE CIRCLED DIGIT FIVE [2000] [Unicode3.2] +0x83DD U+24FA # DOUBLE CIRCLED DIGIT SIX [2000] [Unicode3.2] +0x83DE U+24FB # DOUBLE CIRCLED DIGIT SEVEN [2000] [Unicode3.2] +0x83DF U+24FC # DOUBLE CIRCLED DIGIT EIGHT [2000] [Unicode3.2] +0x83E0 U+24FD # DOUBLE CIRCLED DIGIT NINE [2000] [Unicode3.2] +0x83E1 U+24FE # DOUBLE CIRCLED NUMBER TEN [2000] [Unicode3.2] +0x83E2 U+2616 # WHITE SHOGI PIECE [2000] [Unicode3.2] +0x83E3 U+2617 # BLACK SHOGI PIECE [2000] [Unicode3.2] +0x83E4 U+3020 # POSTAL MARK FACE [2000] +0x83E5 U+260E # BLACK TELEPHONE [2000] +0x83E6 U+2600 # BLACK SUN WITH RAYS [2000] +0x83E7 U+2601 # CLOUD [2000] +0x83E8 U+2602 # UMBRELLA [2000] +0x83E9 U+2603 # SNOWMAN [2000] +0x83EA U+2668 # HOT SPRINGS [2000] +0x83EB U+25B1 # WHITE PARALLELOGRAM [2000] +0x83EC U+31F0 # KATAKANA LETTER SMALL KU [2000] [Unicode3.2] +0x83ED U+31F1 # KATAKANA LETTER SMALL SI [2000] [Unicode3.2] +0x83EE U+31F2 # KATAKANA LETTER SMALL SU [2000] [Unicode3.2] +0x83EF U+31F3 # KATAKANA LETTER SMALL TO [2000] [Unicode3.2] +0x83F0 U+31F4 # KATAKANA LETTER SMALL NU [2000] [Unicode3.2] +0x83F1 U+31F5 # KATAKANA LETTER SMALL HA [2000] [Unicode3.2] +0x83F2 U+31F6 # KATAKANA LETTER SMALL HI [2000] [Unicode3.2] +0x83F3 U+31F7 # KATAKANA LETTER SMALL HU [2000] [Unicode3.2] +0x83F4 U+31F8 # KATAKANA LETTER SMALL HE [2000] [Unicode3.2] +0x83F5 U+31F9 # KATAKANA LETTER SMALL HO [2000] [Unicode3.2] +0x83F6 U+31F7+309A # [2000] +0x83F7 U+31FA # KATAKANA LETTER SMALL MU [2000] [Unicode3.2] +0x83F8 U+31FB # KATAKANA LETTER SMALL RA [2000] [Unicode3.2] +0x83F9 U+31FC # KATAKANA LETTER SMALL RI [2000] [Unicode3.2] +0x83FA U+31FD # KATAKANA LETTER SMALL RU [2000] [Unicode3.2] +0x83FB U+31FE # KATAKANA LETTER SMALL RE [2000] [Unicode3.2] +0x83FC U+31FF # KATAKANA LETTER SMALL RO [2000] [Unicode3.2] +0x8440 U+0410 # CYRILLIC CAPITAL LETTER A +0x8441 U+0411 # CYRILLIC CAPITAL LETTER BE +0x8442 U+0412 # CYRILLIC CAPITAL LETTER VE +0x8443 U+0413 # CYRILLIC CAPITAL LETTER GHE +0x8444 U+0414 # CYRILLIC CAPITAL LETTER DE +0x8445 U+0415 # CYRILLIC CAPITAL LETTER IE +0x8446 U+0401 # CYRILLIC CAPITAL LETTER IO +0x8447 U+0416 # CYRILLIC CAPITAL LETTER ZHE +0x8448 U+0417 # CYRILLIC CAPITAL LETTER ZE +0x8449 U+0418 # CYRILLIC CAPITAL LETTER I +0x844A U+0419 # CYRILLIC CAPITAL LETTER SHORT I +0x844B U+041A # CYRILLIC CAPITAL LETTER KA +0x844C U+041B # CYRILLIC CAPITAL LETTER EL +0x844D U+041C # CYRILLIC CAPITAL LETTER EM +0x844E U+041D # CYRILLIC CAPITAL LETTER EN +0x844F U+041E # CYRILLIC CAPITAL LETTER O +0x8450 U+041F # CYRILLIC CAPITAL LETTER PE +0x8451 U+0420 # CYRILLIC CAPITAL LETTER ER +0x8452 U+0421 # CYRILLIC CAPITAL LETTER ES +0x8453 U+0422 # CYRILLIC CAPITAL LETTER TE +0x8454 U+0423 # CYRILLIC CAPITAL LETTER U +0x8455 U+0424 # CYRILLIC CAPITAL LETTER EF +0x8456 U+0425 # CYRILLIC CAPITAL LETTER HA +0x8457 U+0426 # CYRILLIC CAPITAL LETTER TSE +0x8458 U+0427 # CYRILLIC CAPITAL LETTER CHE +0x8459 U+0428 # CYRILLIC CAPITAL LETTER SHA +0x845A U+0429 # CYRILLIC CAPITAL LETTER SHCHA +0x845B U+042A # CYRILLIC CAPITAL LETTER HARD SIGN +0x845C U+042B # CYRILLIC CAPITAL LETTER YERU +0x845D U+042C # CYRILLIC CAPITAL LETTER SOFT SIGN +0x845E U+042D # CYRILLIC CAPITAL LETTER E +0x845F U+042E # CYRILLIC CAPITAL LETTER YU +0x8460 U+042F # CYRILLIC CAPITAL LETTER YA +0x8461 U+23BE # DENTISTRY SYMBOL LIGHT VERTICAL AND TOP RIGHT [2000] [Unicode3.2] +0x8462 U+23BF # DENTISTRY SYMBOL LIGHT VERTICAL AND BOTTOM RIGHT [2000] [Unicode3.2] +0x8463 U+23C0 # DENTISTRY SYMBOL LIGHT VERTICAL WITH CIRCLE [2000] [Unicode3.2] +0x8464 U+23C1 # DENTISTRY SYMBOL LIGHT DOWN AND HORIZONTAL WITH CIRCLE [2000] [Unicode3.2] +0x8465 U+23C2 # DENTISTRY SYMBOL LIGHT UP AND HORIZONTAL WITH CIRCLE [2000] [Unicode3.2] +0x8466 U+23C3 # DENTISTRY SYMBOL LIGHT VERTICAL WITH TRIANGLE [2000] [Unicode3.2] +0x8467 U+23C4 # DENTISTRY SYMBOL LIGHT DOWN AND HORIZONTAL WITH TRIANGLE [2000] [Unicode3.2] +0x8468 U+23C5 # DENTISTRY SYMBOL LIGHT UP AND HORIZONTAL WITH TRIANGLE [2000] [Unicode3.2] +0x8469 U+23C6 # DENTISTRY SYMBOL LIGHT VERTICAL AND WAVE [2000] [Unicode3.2] +0x846A U+23C7 # DENTISTRY SYMBOL LIGHT DOWN AND HORIZONTAL WITH WAVE [2000] [Unicode3.2] +0x846B U+23C8 # DENTISTRY SYMBOL LIGHT UP AND HORIZONTAL WITH WAVE [2000] [Unicode3.2] +0x846C U+23C9 # DENTISTRY SYMBOL LIGHT DOWN AND HORIZONTAL [2000] [Unicode3.2] +0x846D U+23CA # DENTISTRY SYMBOL LIGHT UP AND HORIZONTAL [2000] [Unicode3.2] +0x846E U+23CB # DENTISTRY SYMBOL LIGHT VERTICAL AND TOP LEFT [2000] [Unicode3.2] +0x846F U+23CC # DENTISTRY SYMBOL LIGHT VERTICAL AND BOTTOM LEFT [2000] [Unicode3.2] +0x8470 U+0430 # CYRILLIC SMALL LETTER A +0x8471 U+0431 # CYRILLIC SMALL LETTER BE +0x8472 U+0432 # CYRILLIC SMALL LETTER VE +0x8473 U+0433 # CYRILLIC SMALL LETTER GHE +0x8474 U+0434 # CYRILLIC SMALL LETTER DE +0x8475 U+0435 # CYRILLIC SMALL LETTER IE +0x8476 U+0451 # CYRILLIC SMALL LETTER IO +0x8477 U+0436 # CYRILLIC SMALL LETTER ZHE +0x8478 U+0437 # CYRILLIC SMALL LETTER ZE +0x8479 U+0438 # CYRILLIC SMALL LETTER I +0x847A U+0439 # CYRILLIC SMALL LETTER SHORT I +0x847B U+043A # CYRILLIC SMALL LETTER KA +0x847C U+043B # CYRILLIC SMALL LETTER EL +0x847D U+043C # CYRILLIC SMALL LETTER EM +0x847E U+043D # CYRILLIC SMALL LETTER EN +0x8480 U+043E # CYRILLIC SMALL LETTER O +0x8481 U+043F # CYRILLIC SMALL LETTER PE +0x8482 U+0440 # CYRILLIC SMALL LETTER ER +0x8483 U+0441 # CYRILLIC SMALL LETTER ES +0x8484 U+0442 # CYRILLIC SMALL LETTER TE +0x8485 U+0443 # CYRILLIC SMALL LETTER U +0x8486 U+0444 # CYRILLIC SMALL LETTER EF +0x8487 U+0445 # CYRILLIC SMALL LETTER HA +0x8488 U+0446 # CYRILLIC SMALL LETTER TSE +0x8489 U+0447 # CYRILLIC SMALL LETTER CHE +0x848A U+0448 # CYRILLIC SMALL LETTER SHA +0x848B U+0449 # CYRILLIC SMALL LETTER SHCHA +0x848C U+044A # CYRILLIC SMALL LETTER HARD SIGN +0x848D U+044B # CYRILLIC SMALL LETTER YERU +0x848E U+044C # CYRILLIC SMALL LETTER SOFT SIGN +0x848F U+044D # CYRILLIC SMALL LETTER E +0x8490 U+044E # CYRILLIC SMALL LETTER YU +0x8491 U+044F # CYRILLIC SMALL LETTER YA +0x8492 U+30F7 # KATAKANA LETTER VA [2000] +0x8493 U+30F8 # KATAKANA LETTER VI [2000] +0x8494 U+30F9 # KATAKANA LETTER VE [2000] +0x8495 U+30FA # KATAKANA LETTER VO [2000] +0x8496 U+22DA # LESS-THAN EQUAL TO OR GREATER-THAN [2000] +0x8497 U+22DB # GREATER-THAN EQUAL TO OR LESS-THAN [2000] +0x8498 U+2153 # VULGAR FRACTION ONE THIRD [2000] +0x8499 U+2154 # VULGAR FRACTION TWO THIRDS [2000] +0x849A U+2155 # VULGAR FRACTION ONE FIFTH [2000] +0x849B U+2713 # CHECK MARK [2000] +0x849C U+2318 # PLACE OF INTEREST SIGN [2000] +0x849D U+2423 # OPEN BOX [2000] +0x849E U+23CE # RETURN SYMBOL [2000] [Unicode3.2] +0x849F U+2500 # BOX DRAWINGS LIGHT HORIZONTAL [1983] +0x84A0 U+2502 # BOX DRAWINGS LIGHT VERTICAL [1983] +0x84A1 U+250C # BOX DRAWINGS LIGHT DOWN AND RIGHT [1983] +0x84A2 U+2510 # BOX DRAWINGS LIGHT DOWN AND LEFT [1983] +0x84A3 U+2518 # BOX DRAWINGS LIGHT UP AND LEFT [1983] +0x84A4 U+2514 # BOX DRAWINGS LIGHT UP AND RIGHT [1983] +0x84A5 U+251C # BOX DRAWINGS LIGHT VERTICAL AND RIGHT [1983] +0x84A6 U+252C # BOX DRAWINGS LIGHT DOWN AND HORIZONTAL [1983] +0x84A7 U+2524 # BOX DRAWINGS LIGHT VERTICAL AND LEFT [1983] +0x84A8 U+2534 # BOX DRAWINGS LIGHT UP AND HORIZONTAL [1983] +0x84A9 U+253C # BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL [1983] +0x84AA U+2501 # BOX DRAWINGS HEAVY HORIZONTAL [1983] +0x84AB U+2503 # BOX DRAWINGS HEAVY VERTICAL [1983] +0x84AC U+250F # BOX DRAWINGS HEAVY DOWN AND RIGHT [1983] +0x84AD U+2513 # BOX DRAWINGS HEAVY DOWN AND LEFT [1983] +0x84AE U+251B # BOX DRAWINGS HEAVY UP AND LEFT [1983] +0x84AF U+2517 # BOX DRAWINGS HEAVY UP AND RIGHT [1983] +0x84B0 U+2523 # BOX DRAWINGS HEAVY VERTICAL AND RIGHT [1983] +0x84B1 U+2533 # BOX DRAWINGS HEAVY DOWN AND HORIZONTAL [1983] +0x84B2 U+252B # BOX DRAWINGS HEAVY VERTICAL AND LEFT [1983] +0x84B3 U+253B # BOX DRAWINGS HEAVY UP AND HORIZONTAL [1983] +0x84B4 U+254B # BOX DRAWINGS HEAVY VERTICAL AND HORIZONTAL [1983] +0x84B5 U+2520 # BOX DRAWINGS VERTICAL HEAVY AND RIGHT LIGHT [1983] +0x84B6 U+252F # BOX DRAWINGS DOWN LIGHT AND HORIZONTAL HEAVY [1983] +0x84B7 U+2528 # BOX DRAWINGS VERTICAL HEAVY AND LEFT LIGHT [1983] +0x84B8 U+2537 # BOX DRAWINGS UP LIGHT AND HORIZONTAL HEAVY [1983] +0x84B9 U+253F # BOX DRAWINGS VERTICAL LIGHT AND HORIZONTAL HEAVY [1983] +0x84BA U+251D # BOX DRAWINGS VERTICAL LIGHT AND RIGHT HEAVY [1983] +0x84BB U+2530 # BOX DRAWINGS DOWN HEAVY AND HORIZONTAL LIGHT [1983] +0x84BC U+2525 # BOX DRAWINGS VERTICAL LIGHT AND LEFT HEAVY [1983] +0x84BD U+2538 # BOX DRAWINGS UP HEAVY AND HORIZONTAL LIGHT [1983] +0x84BE U+2542 # BOX DRAWINGS VERTICAL HEAVY AND HORIZONTAL LIGHT [1983] +0x84BF U+3251 # CIRCLED NUMBER TWENTY ONE [2000] [Unicode3.2] +0x84C0 U+3252 # CIRCLED NUMBER TWENTY TWO [2000] [Unicode3.2] +0x84C1 U+3253 # CIRCLED NUMBER TWENTY THREE [2000] [Unicode3.2] +0x84C2 U+3254 # CIRCLED NUMBER TWENTY FOUR [2000] [Unicode3.2] +0x84C3 U+3255 # CIRCLED NUMBER TWENTY FIVE [2000] [Unicode3.2] +0x84C4 U+3256 # CIRCLED NUMBER TWENTY SIX [2000] [Unicode3.2] +0x84C5 U+3257 # CIRCLED NUMBER TWENTY SEVEN [2000] [Unicode3.2] +0x84C6 U+3258 # CIRCLED NUMBER TWENTY EIGHT [2000] [Unicode3.2] +0x84C7 U+3259 # CIRCLED NUMBER TWENTY NINE [2000] [Unicode3.2] +0x84C8 U+325A # CIRCLED NUMBER THIRTY [2000] [Unicode3.2] +0x84C9 U+325B # CIRCLED NUMBER THIRTY ONE [2000] [Unicode3.2] +0x84CA U+325C # CIRCLED NUMBER THIRTY TWO [2000] [Unicode3.2] +0x84CB U+325D # CIRCLED NUMBER THIRTY THREE [2000] [Unicode3.2] +0x84CC U+325E # CIRCLED NUMBER THIRTY FOUR [2000] [Unicode3.2] +0x84CD U+325F # CIRCLED NUMBER THIRTY FIVE [2000] [Unicode3.2] +0x84CE U+32B1 # CIRCLED NUMBER THIRTY SIX [2000] [Unicode3.2] +0x84CF U+32B2 # CIRCLED NUMBER THIRTY SEVEN [2000] [Unicode3.2] +0x84D0 U+32B3 # CIRCLED NUMBER THIRTY EIGHT [2000] [Unicode3.2] +0x84D1 U+32B4 # CIRCLED NUMBER THIRTY NINE [2000] [Unicode3.2] +0x84D2 U+32B5 # CIRCLED NUMBER FORTY [2000] [Unicode3.2] +0x84D3 U+32B6 # CIRCLED NUMBER FORTY ONE [2000] [Unicode3.2] +0x84D4 U+32B7 # CIRCLED NUMBER FORTY TWO [2000] [Unicode3.2] +0x84D5 U+32B8 # CIRCLED NUMBER FORTY THREE [2000] [Unicode3.2] +0x84D6 U+32B9 # CIRCLED NUMBER FORTY FOUR [2000] [Unicode3.2] +0x84D7 U+32BA # CIRCLED NUMBER FORTY FIVE [2000] [Unicode3.2] +0x84D8 U+32BB # CIRCLED NUMBER FORTY SIX [2000] [Unicode3.2] +0x84D9 U+32BC # CIRCLED NUMBER FORTY SEVEN [2000] [Unicode3.2] +0x84DA U+32BD # CIRCLED NUMBER FORTY EIGHT [2000] [Unicode3.2] +0x84DB U+32BE # CIRCLED NUMBER FORTY NINE [2000] [Unicode3.2] +0x84DC U+32BF # CIRCLED NUMBER FIFTY [2000] [Unicode3.2] +0x84DD # +0x84DE # +0x84DF # +0x84E0 # +0x84E1 # +0x84E2 # +0x84E3 # +0x84E4 # +0x84E5 U+25D0 # CIRCLE WITH LEFT HALF BLACK [2000] +0x84E6 U+25D1 # CIRCLE WITH RIGHT HALF BLACK [2000] +0x84E7 U+25D2 # CIRCLE WITH LOWER HALF BLACK [2000] +0x84E8 U+25D3 # CIRCLE WITH UPPER HALF BLACK [2000] +0x84E9 U+203C # DOUBLE EXCLAMATION MARK [2000] +0x84EA U+2047 # DOUBLE QUESTION MARK [2000] [Unicode3.2] +0x84EB U+2048 # QUESTION EXCLAMATION MARK [2000] +0x84EC U+2049 # EXCLAMATION QUESTION MARK [2000] +0x84ED U+01CD # LATIN CAPITAL LETTER A WITH CARON [2000] +0x84EE U+01CE # LATIN SMALL LETTER A WITH CARON [2000] +0x84EF U+01D0 # LATIN SMALL LETTER I WITH CARON [2000] +0x84F0 U+1E3E # LATIN CAPITAL LETTER M WITH ACUTE [2000] +0x84F1 U+1E3F # LATIN SMALL LETTER M WITH ACUTE [2000] +0x84F2 U+01F8 # LATIN CAPITAL LETTER N WITH GRAVE [2000] +0x84F3 U+01F9 # LATIN SMALL LETTER N WITH GRAVE [2000] +0x84F4 U+01D1 # LATIN CAPITAL LETTER O WITH CARON [2000] +0x84F5 U+01D2 # LATIN SMALL LETTER O WITH CARON [2000] +0x84F6 U+01D4 # LATIN SMALL LETTER U WITH CARON [2000] +0x84F7 U+01D6 # LATIN SMALL LETTER U WITH DIAERESIS AND MACRON [2000] +0x84F8 U+01D8 # LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE [2000] +0x84F9 U+01DA # LATIN SMALL LETTER U WITH DIAERESIS AND CARON [2000] +0x84FA U+01DC # LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE [2000] +0x84FB # +0x84FC # +0x8540 U+20AC # EURO SIGN [2000] +0x8541 U+00A0 # NO-BREAK SPACE [2000] +0x8542 U+00A1 # INVERTED EXCLAMATION MARK [2000] +0x8543 U+00A4 # CURRENCY SIGN [2000] +0x8544 U+00A6 # BROKEN BAR [2000] +0x8545 U+00A9 # COPYRIGHT SIGN [2000] +0x8546 U+00AA # FEMININE ORDINAL INDICATOR [2000] +0x8547 U+00AB # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK [2000] +0x8548 U+00AD # SOFT HYPHEN [2000] +0x8549 U+00AE # REGISTERED SIGN [2000] +0x854A U+00AF # MACRON [2000] +0x854B U+00B2 # SUPERSCRIPT TWO [2000] +0x854C U+00B3 # SUPERSCRIPT THREE [2000] +0x854D U+00B7 # MIDDLE DOT [2000] +0x854E U+00B8 # CEDILLA [2000] +0x854F U+00B9 # SUPERSCRIPT ONE [2000] +0x8550 U+00BA # MASCULINE ORDINAL INDICATOR [2000] +0x8551 U+00BB # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK [2000] +0x8552 U+00BC # VULGAR FRACTION ONE QUARTER [2000] +0x8553 U+00BD # VULGAR FRACTION ONE HALF [2000] +0x8554 U+00BE # VULGAR FRACTION THREE QUARTERS [2000] +0x8555 U+00BF # INVERTED QUESTION MARK [2000] +0x8556 U+00C0 # LATIN CAPITAL LETTER A WITH GRAVE [2000] +0x8557 U+00C1 # LATIN CAPITAL LETTER A WITH ACUTE [2000] +0x8558 U+00C2 # LATIN CAPITAL LETTER A WITH CIRCUMFLEX [2000] +0x8559 U+00C3 # LATIN CAPITAL LETTER A WITH TILDE [2000] +0x855A U+00C4 # LATIN CAPITAL LETTER A WITH DIAERESIS [2000] +0x855B U+00C5 # LATIN CAPITAL LETTER A WITH RING ABOVE [2000] +0x855C U+00C6 # LATIN CAPITAL LETTER AE [2000] +0x855D U+00C7 # LATIN CAPITAL LETTER C WITH CEDILLA [2000] +0x855E U+00C8 # LATIN CAPITAL LETTER E WITH GRAVE [2000] +0x855F U+00C9 # LATIN CAPITAL LETTER E WITH ACUTE [2000] +0x8560 U+00CA # LATIN CAPITAL LETTER E WITH CIRCUMFLEX [2000] +0x8561 U+00CB # LATIN CAPITAL LETTER E WITH DIAERESIS [2000] +0x8562 U+00CC # LATIN CAPITAL LETTER I WITH GRAVE [2000] +0x8563 U+00CD # LATIN CAPITAL LETTER I WITH ACUTE [2000] +0x8564 U+00CE # LATIN CAPITAL LETTER I WITH CIRCUMFLEX [2000] +0x8565 U+00CF # LATIN CAPITAL LETTER I WITH DIAERESIS [2000] +0x8566 U+00D0 # LATIN CAPITAL LETTER ETH [2000] +0x8567 U+00D1 # LATIN CAPITAL LETTER N WITH TILDE [2000] +0x8568 U+00D2 # LATIN CAPITAL LETTER O WITH GRAVE [2000] +0x8569 U+00D3 # LATIN CAPITAL LETTER O WITH ACUTE [2000] +0x856A U+00D4 # LATIN CAPITAL LETTER O WITH CIRCUMFLEX [2000] +0x856B U+00D5 # LATIN CAPITAL LETTER O WITH TILDE [2000] +0x856C U+00D6 # LATIN CAPITAL LETTER O WITH DIAERESIS [2000] +0x856D U+00D8 # LATIN CAPITAL LETTER O WITH STROKE [2000] +0x856E U+00D9 # LATIN CAPITAL LETTER U WITH GRAVE [2000] +0x856F U+00DA # LATIN CAPITAL LETTER U WITH ACUTE [2000] +0x8570 U+00DB # LATIN CAPITAL LETTER U WITH CIRCUMFLEX [2000] +0x8571 U+00DC # LATIN CAPITAL LETTER U WITH DIAERESIS [2000] +0x8572 U+00DD # LATIN CAPITAL LETTER Y WITH ACUTE [2000] +0x8573 U+00DE # LATIN CAPITAL LETTER THORN [2000] +0x8574 U+00DF # LATIN SMALL LETTER SHARP S [2000] +0x8575 U+00E0 # LATIN SMALL LETTER A WITH GRAVE [2000] +0x8576 U+00E1 # LATIN SMALL LETTER A WITH ACUTE [2000] +0x8577 U+00E2 # LATIN SMALL LETTER A WITH CIRCUMFLEX [2000] +0x8578 U+00E3 # LATIN SMALL LETTER A WITH TILDE [2000] +0x8579 U+00E4 # LATIN SMALL LETTER A WITH DIAERESIS [2000] +0x857A U+00E5 # LATIN SMALL LETTER A WITH RING ABOVE [2000] +0x857B U+00E6 # LATIN SMALL LETTER AE [2000] +0x857C U+00E7 # LATIN SMALL LETTER C WITH CEDILLA [2000] +0x857D U+00E8 # LATIN SMALL LETTER E WITH GRAVE [2000] +0x857E U+00E9 # LATIN SMALL LETTER E WITH ACUTE [2000] +0x8580 U+00EA # LATIN SMALL LETTER E WITH CIRCUMFLEX [2000] +0x8581 U+00EB # LATIN SMALL LETTER E WITH DIAERESIS [2000] +0x8582 U+00EC # LATIN SMALL LETTER I WITH GRAVE [2000] +0x8583 U+00ED # LATIN SMALL LETTER I WITH ACUTE [2000] +0x8584 U+00EE # LATIN SMALL LETTER I WITH CIRCUMFLEX [2000] +0x8585 U+00EF # LATIN SMALL LETTER I WITH DIAERESIS [2000] +0x8586 U+00F0 # LATIN SMALL LETTER ETH [2000] +0x8587 U+00F1 # LATIN SMALL LETTER N WITH TILDE [2000] +0x8588 U+00F2 # LATIN SMALL LETTER O WITH GRAVE [2000] +0x8589 U+00F3 # LATIN SMALL LETTER O WITH ACUTE [2000] +0x858A U+00F4 # LATIN SMALL LETTER O WITH CIRCUMFLEX [2000] +0x858B U+00F5 # LATIN SMALL LETTER O WITH TILDE [2000] +0x858C U+00F6 # LATIN SMALL LETTER O WITH DIAERESIS [2000] +0x858D U+00F8 # LATIN SMALL LETTER O WITH STROKE [2000] +0x858E U+00F9 # LATIN SMALL LETTER U WITH GRAVE [2000] +0x858F U+00FA # LATIN SMALL LETTER U WITH ACUTE [2000] +0x8590 U+00FB # LATIN SMALL LETTER U WITH CIRCUMFLEX [2000] +0x8591 U+00FC # LATIN SMALL LETTER U WITH DIAERESIS [2000] +0x8592 U+00FD # LATIN SMALL LETTER Y WITH ACUTE [2000] +0x8593 U+00FE # LATIN SMALL LETTER THORN [2000] +0x8594 U+00FF # LATIN SMALL LETTER Y WITH DIAERESIS [2000] +0x8595 U+0100 # LATIN CAPITAL LETTER A WITH MACRON [2000] +0x8596 U+012A # LATIN CAPITAL LETTER I WITH MACRON [2000] +0x8597 U+016A # LATIN CAPITAL LETTER U WITH MACRON [2000] +0x8598 U+0112 # LATIN CAPITAL LETTER E WITH MACRON [2000] +0x8599 U+014C # LATIN CAPITAL LETTER O WITH MACRON [2000] +0x859A U+0101 # LATIN SMALL LETTER A WITH MACRON [2000] +0x859B U+012B # LATIN SMALL LETTER I WITH MACRON [2000] +0x859C U+016B # LATIN SMALL LETTER U WITH MACRON [2000] +0x859D U+0113 # LATIN SMALL LETTER E WITH MACRON [2000] +0x859E U+014D # LATIN SMALL LETTER O WITH MACRON [2000] +0x859F U+0104 # LATIN CAPITAL LETTER A WITH OGONEK [2000] +0x85A0 U+02D8 # BREVE [2000] +0x85A1 U+0141 # LATIN CAPITAL LETTER L WITH STROKE [2000] +0x85A2 U+013D # LATIN CAPITAL LETTER L WITH CARON [2000] +0x85A3 U+015A # LATIN CAPITAL LETTER S WITH ACUTE [2000] +0x85A4 U+0160 # LATIN CAPITAL LETTER S WITH CARON [2000] +0x85A5 U+015E # LATIN CAPITAL LETTER S WITH CEDILLA [2000] +0x85A6 U+0164 # LATIN CAPITAL LETTER T WITH CARON [2000] +0x85A7 U+0179 # LATIN CAPITAL LETTER Z WITH ACUTE [2000] +0x85A8 U+017D # LATIN CAPITAL LETTER Z WITH CARON [2000] +0x85A9 U+017B # LATIN CAPITAL LETTER Z WITH DOT ABOVE [2000] +0x85AA U+0105 # LATIN SMALL LETTER A WITH OGONEK [2000] +0x85AB U+02DB # OGONEK [2000] +0x85AC U+0142 # LATIN SMALL LETTER L WITH STROKE [2000] +0x85AD U+013E # LATIN SMALL LETTER L WITH CARON [2000] +0x85AE U+015B # LATIN SMALL LETTER S WITH ACUTE [2000] +0x85AF U+02C7 # CARON [2000] +0x85B0 U+0161 # LATIN SMALL LETTER S WITH CARON [2000] +0x85B1 U+015F # LATIN SMALL LETTER S WITH CEDILLA [2000] +0x85B2 U+0165 # LATIN SMALL LETTER T WITH CARON [2000] +0x85B3 U+017A # LATIN SMALL LETTER Z WITH ACUTE [2000] +0x85B4 U+02DD # DOUBLE ACUTE ACCENT [2000] +0x85B5 U+017E # LATIN SMALL LETTER Z WITH CARON [2000] +0x85B6 U+017C # LATIN SMALL LETTER Z WITH DOT ABOVE [2000] +0x85B7 U+0154 # LATIN CAPITAL LETTER R WITH ACUTE [2000] +0x85B8 U+0102 # LATIN CAPITAL LETTER A WITH BREVE [2000] +0x85B9 U+0139 # LATIN CAPITAL LETTER L WITH ACUTE [2000] +0x85BA U+0106 # LATIN CAPITAL LETTER C WITH ACUTE [2000] +0x85BB U+010C # LATIN CAPITAL LETTER C WITH CARON [2000] +0x85BC U+0118 # LATIN CAPITAL LETTER E WITH OGONEK [2000] +0x85BD U+011A # LATIN CAPITAL LETTER E WITH CARON [2000] +0x85BE U+010E # LATIN CAPITAL LETTER D WITH CARON [2000] +0x85BF U+0143 # LATIN CAPITAL LETTER N WITH ACUTE [2000] +0x85C0 U+0147 # LATIN CAPITAL LETTER N WITH CARON [2000] +0x85C1 U+0150 # LATIN CAPITAL LETTER O WITH DOUBLE ACUTE [2000] +0x85C2 U+0158 # LATIN CAPITAL LETTER R WITH CARON [2000] +0x85C3 U+016E # LATIN CAPITAL LETTER U WITH RING ABOVE [2000] +0x85C4 U+0170 # LATIN CAPITAL LETTER U WITH DOUBLE ACUTE [2000] +0x85C5 U+0162 # LATIN CAPITAL LETTER T WITH CEDILLA [2000] +0x85C6 U+0155 # LATIN SMALL LETTER R WITH ACUTE [2000] +0x85C7 U+0103 # LATIN SMALL LETTER A WITH BREVE [2000] +0x85C8 U+013A # LATIN SMALL LETTER L WITH ACUTE [2000] +0x85C9 U+0107 # LATIN SMALL LETTER C WITH ACUTE [2000] +0x85CA U+010D # LATIN SMALL LETTER C WITH CARON [2000] +0x85CB U+0119 # LATIN SMALL LETTER E WITH OGONEK [2000] +0x85CC U+011B # LATIN SMALL LETTER E WITH CARON [2000] +0x85CD U+010F # LATIN SMALL LETTER D WITH CARON [2000] +0x85CE U+0111 # LATIN SMALL LETTER D WITH STROKE [2000] +0x85CF U+0144 # LATIN SMALL LETTER N WITH ACUTE [2000] +0x85D0 U+0148 # LATIN SMALL LETTER N WITH CARON [2000] +0x85D1 U+0151 # LATIN SMALL LETTER O WITH DOUBLE ACUTE [2000] +0x85D2 U+0159 # LATIN SMALL LETTER R WITH CARON [2000] +0x85D3 U+016F # LATIN SMALL LETTER U WITH RING ABOVE [2000] +0x85D4 U+0171 # LATIN SMALL LETTER U WITH DOUBLE ACUTE [2000] +0x85D5 U+0163 # LATIN SMALL LETTER T WITH CEDILLA [2000] +0x85D6 U+02D9 # DOT ABOVE [2000] +0x85D7 U+0108 # LATIN CAPITAL LETTER C WITH CIRCUMFLEX [2000] +0x85D8 U+011C # LATIN CAPITAL LETTER G WITH CIRCUMFLEX [2000] +0x85D9 U+0124 # LATIN CAPITAL LETTER H WITH CIRCUMFLEX [2000] +0x85DA U+0134 # LATIN CAPITAL LETTER J WITH CIRCUMFLEX [2000] +0x85DB U+015C # LATIN CAPITAL LETTER S WITH CIRCUMFLEX [2000] +0x85DC U+016C # LATIN CAPITAL LETTER U WITH BREVE [2000] +0x85DD U+0109 # LATIN SMALL LETTER C WITH CIRCUMFLEX [2000] +0x85DE U+011D # LATIN SMALL LETTER G WITH CIRCUMFLEX [2000] +0x85DF U+0125 # LATIN SMALL LETTER H WITH CIRCUMFLEX [2000] +0x85E0 U+0135 # LATIN SMALL LETTER J WITH CIRCUMFLEX [2000] +0x85E1 U+015D # LATIN SMALL LETTER S WITH CIRCUMFLEX [2000] +0x85E2 U+016D # LATIN SMALL LETTER U WITH BREVE [2000] +0x85E3 U+0271 # LATIN SMALL LETTER M WITH HOOK [2000] +0x85E4 U+028B # LATIN SMALL LETTER V WITH HOOK [2000] +0x85E5 U+027E # LATIN SMALL LETTER R WITH FISHHOOK [2000] +0x85E6 U+0283 # LATIN SMALL LETTER ESH [2000] +0x85E7 U+0292 # LATIN SMALL LETTER EZH [2000] +0x85E8 U+026C # LATIN SMALL LETTER L WITH BELT [2000] +0x85E9 U+026E # LATIN SMALL LETTER LEZH [2000] +0x85EA U+0279 # LATIN SMALL LETTER TURNED R [2000] +0x85EB U+0288 # LATIN SMALL LETTER T WITH RETROFLEX HOOK [2000] +0x85EC U+0256 # LATIN SMALL LETTER D WITH TAIL [2000] +0x85ED U+0273 # LATIN SMALL LETTER N WITH RETROFLEX HOOK [2000] +0x85EE U+027D # LATIN SMALL LETTER R WITH TAIL [2000] +0x85EF U+0282 # LATIN SMALL LETTER S WITH HOOK [2000] +0x85F0 U+0290 # LATIN SMALL LETTER Z WITH RETROFLEX HOOK [2000] +0x85F1 U+027B # LATIN SMALL LETTER TURNED R WITH HOOK [2000] +0x85F2 U+026D # LATIN SMALL LETTER L WITH RETROFLEX HOOK [2000] +0x85F3 U+025F # LATIN SMALL LETTER DOTLESS J WITH STROKE [2000] +0x85F4 U+0272 # LATIN SMALL LETTER N WITH LEFT HOOK [2000] +0x85F5 U+029D # LATIN SMALL LETTER J WITH CROSSED-TAIL [2000] +0x85F6 U+028E # LATIN SMALL LETTER TURNED Y [2000] +0x85F7 U+0261 # LATIN SMALL LETTER SCRIPT G [2000] +0x85F8 U+014B # LATIN SMALL LETTER ENG [2000] +0x85F9 U+0270 # LATIN SMALL LETTER TURNED M WITH LONG LEG [2000] +0x85FA U+0281 # LATIN LETTER SMALL CAPITAL INVERTED R [2000] +0x85FB U+0127 # LATIN SMALL LETTER H WITH STROKE [2000] +0x85FC U+0295 # LATIN LETTER PHARYNGEAL VOICED FRICATIVE [2000] +0x8640 U+0294 # LATIN LETTER GLOTTAL STOP [2000] +0x8641 U+0266 # LATIN SMALL LETTER H WITH HOOK [2000] +0x8642 U+0298 # LATIN LETTER BILABIAL CLICK [2000] +0x8643 U+01C2 # LATIN LETTER ALVEOLAR CLICK [2000] +0x8644 U+0253 # LATIN SMALL LETTER B WITH HOOK [2000] +0x8645 U+0257 # LATIN SMALL LETTER D WITH HOOK [2000] +0x8646 U+0284 # LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK [2000] +0x8647 U+0260 # LATIN SMALL LETTER G WITH HOOK [2000] +0x8648 U+0193 # LATIN CAPITAL LETTER G WITH HOOK [2000] +0x8649 U+0153 # LATIN SMALL LIGATURE OE [2000] +0x864A U+0152 # LATIN CAPITAL LIGATURE OE [2000] +0x864B U+0268 # LATIN SMALL LETTER I WITH STROKE [2000] +0x864C U+0289 # LATIN SMALL LETTER U BAR [2000] +0x864D U+0258 # LATIN SMALL LETTER REVERSED E [2000] +0x864E U+0275 # LATIN SMALL LETTER BARRED O [2000] +0x864F U+0259 # LATIN SMALL LETTER SCHWA [2000] +0x8650 U+025C # LATIN SMALL LETTER REVERSED OPEN E [2000] +0x8651 U+025E # LATIN SMALL LETTER CLOSED REVERSED OPEN E [2000] +0x8652 U+0250 # LATIN SMALL LETTER TURNED A [2000] +0x8653 U+026F # LATIN SMALL LETTER TURNED M [2000] +0x8654 U+028A # LATIN SMALL LETTER UPSILON [2000] +0x8655 U+0264 # LATIN SMALL LETTER RAMS HORN [2000] +0x8656 U+028C # LATIN SMALL LETTER TURNED V [2000] +0x8657 U+0254 # LATIN SMALL LETTER OPEN O [2000] +0x8658 U+0251 # LATIN SMALL LETTER ALPHA [2000] +0x8659 U+0252 # LATIN SMALL LETTER TURNED ALPHA [2000] +0x865A U+028D # LATIN SMALL LETTER TURNED W [2000] +0x865B U+0265 # LATIN SMALL LETTER TURNED H [2000] +0x865C U+02A2 # LATIN LETTER REVERSED GLOTTAL STOP WITH STROKE [2000] +0x865D U+02A1 # LATIN LETTER GLOTTAL STOP WITH STROKE [2000] +0x865E U+0255 # LATIN SMALL LETTER C WITH CURL [2000] +0x865F U+0291 # LATIN SMALL LETTER Z WITH CURL [2000] +0x8660 U+027A # LATIN SMALL LETTER TURNED R WITH LONG LEG [2000] +0x8661 U+0267 # LATIN SMALL LETTER HENG WITH HOOK [2000] +0x8662 U+025A # LATIN SMALL LETTER SCHWA WITH HOOK [2000] +0x8663 U+00E6+0300 # [2000] +0x8664 U+01FD # LATIN SMALL LETTER AE WITH ACUTE [2000] +0x8665 U+1F70 # GREEK SMALL LETTER ALPHA WITH VARIA [2000] +0x8666 U+1F71 # GREEK SMALL LETTER ALPHA WITH OXIA [2000] +0x8667 U+0254+0300 # [2000] +0x8668 U+0254+0301 # [2000] +0x8669 U+028C+0300 # [2000] +0x866A U+028C+0301 # [2000] +0x866B U+0259+0300 # [2000] +0x866C U+0259+0301 # [2000] +0x866D U+025A+0300 # [2000] +0x866E U+025A+0301 # [2000] +0x866F U+1F72 # GREEK SMALL LETTER EPSILON WITH VARIA [2000] +0x8670 U+1F73 # GREEK SMALL LETTER EPSILON WITH OXIA [2000] +0x8671 U+0361 # COMBINING DOUBLE INVERTED BREVE [2000] +0x8672 U+02C8 # MODIFIER LETTER VERTICAL LINE [2000] +0x8673 U+02CC # MODIFIER LETTER LOW VERTICAL LINE [2000] +0x8674 U+02D0 # MODIFIER LETTER TRIANGULAR COLON [2000] +0x8675 U+02D1 # MODIFIER LETTER HALF TRIANGULAR COLON [2000] +0x8676 U+0306 # COMBINING BREVE [2000] +0x8677 U+203F # UNDERTIE [2000] +0x8678 U+030B # COMBINING DOUBLE ACUTE ACCENT [2000] +0x8679 U+0301 # COMBINING ACUTE ACCENT [2000] +0x867A U+0304 # COMBINING MACRON [2000] +0x867B U+0300 # COMBINING GRAVE ACCENT [2000] +0x867C U+030F # COMBINING DOUBLE GRAVE ACCENT [2000] +0x867D U+030C # COMBINING CARON [2000] +0x867E U+0302 # COMBINING CIRCUMFLEX ACCENT [2000] +0x8680 U+02E5 # MODIFIER LETTER EXTRA-HIGH TONE BAR [2000] +0x8681 U+02E6 # MODIFIER LETTER HIGH TONE BAR [2000] +0x8682 U+02E7 # MODIFIER LETTER MID TONE BAR [2000] +0x8683 U+02E8 # MODIFIER LETTER LOW TONE BAR [2000] +0x8684 U+02E9 # MODIFIER LETTER EXTRA-LOW TONE BAR [2000] +0x8685 U+02E9+02E5 # [2000] +0x8686 U+02E5+02E9 # [2000] +0x8687 U+0325 # COMBINING RING BELOW [2000] +0x8688 U+032C # COMBINING CARON BELOW [2000] +0x8689 U+0339 # COMBINING RIGHT HALF RING BELOW [2000] +0x868A U+031C # COMBINING LEFT HALF RING BELOW [2000] +0x868B U+031F # COMBINING PLUS SIGN BELOW [2000] +0x868C U+0320 # COMBINING MINUS SIGN BELOW [2000] +0x868D U+0308 # COMBINING DIAERESIS [2000] +0x868E U+033D # COMBINING X ABOVE [2000] +0x868F U+0329 # COMBINING VERTICAL LINE BELOW [2000] +0x8690 U+032F # COMBINING INVERTED BREVE BELOW [2000] +0x8691 U+02DE # MODIFIER LETTER RHOTIC HOOK [2000] +0x8692 U+0324 # COMBINING DIAERESIS BELOW [2000] +0x8693 U+0330 # COMBINING TILDE BELOW [2000] +0x8694 U+033C # COMBINING SEAGULL BELOW [2000] +0x8695 U+0334 # COMBINING TILDE OVERLAY [2000] +0x8696 U+031D # COMBINING UP TACK BELOW [2000] +0x8697 U+031E # COMBINING DOWN TACK BELOW [2000] +0x8698 U+0318 # COMBINING LEFT TACK BELOW [2000] +0x8699 U+0319 # COMBINING RIGHT TACK BELOW [2000] +0x869A U+032A # COMBINING BRIDGE BELOW [2000] +0x869B U+033A # COMBINING INVERTED BRIDGE BELOW [2000] +0x869C U+033B # COMBINING SQUARE BELOW [2000] +0x869D U+0303 # COMBINING TILDE [2000] +0x869E U+031A # COMBINING LEFT ANGLE ABOVE [2000] +0x869F U+2776 # DINGBAT NEGATIVE CIRCLED DIGIT ONE [2000] +0x86A0 U+2777 # DINGBAT NEGATIVE CIRCLED DIGIT TWO [2000] +0x86A1 U+2778 # DINGBAT NEGATIVE CIRCLED DIGIT THREE [2000] +0x86A2 U+2779 # DINGBAT NEGATIVE CIRCLED DIGIT FOUR [2000] +0x86A3 U+277A # DINGBAT NEGATIVE CIRCLED DIGIT FIVE [2000] +0x86A4 U+277B # DINGBAT NEGATIVE CIRCLED DIGIT SIX [2000] +0x86A5 U+277C # DINGBAT NEGATIVE CIRCLED DIGIT SEVEN [2000] +0x86A6 U+277D # DINGBAT NEGATIVE CIRCLED DIGIT EIGHT [2000] +0x86A7 U+277E # DINGBAT NEGATIVE CIRCLED DIGIT NINE [2000] +0x86A8 U+277F # DINGBAT NEGATIVE CIRCLED NUMBER TEN [2000] +0x86A9 U+24EB # NEGATIVE CIRCLED NUMBER ELEVEN [2000] [Unicode3.2] +0x86AA U+24EC # NEGATIVE CIRCLED NUMBER TWELVE [2000] [Unicode3.2] +0x86AB U+24ED # NEGATIVE CIRCLED NUMBER THIRTEEN [2000] [Unicode3.2] +0x86AC U+24EE # NEGATIVE CIRCLED NUMBER FOURTEEN [2000] [Unicode3.2] +0x86AD U+24EF # NEGATIVE CIRCLED NUMBER FIFTEEN [2000] [Unicode3.2] +0x86AE U+24F0 # NEGATIVE CIRCLED NUMBER SIXTEEN [2000] [Unicode3.2] +0x86AF U+24F1 # NEGATIVE CIRCLED NUMBER SEVENTEEN [2000] [Unicode3.2] +0x86B0 U+24F2 # NEGATIVE CIRCLED NUMBER EIGHTEEN [2000] [Unicode3.2] +0x86B1 U+24F3 # NEGATIVE CIRCLED NUMBER NINETEEN [2000] [Unicode3.2] +0x86B2 U+24F4 # NEGATIVE CIRCLED NUMBER TWENTY [2000] [Unicode3.2] +0x86B3 U+2170 # SMALL ROMAN NUMERAL ONE [2000] +0x86B4 U+2171 # SMALL ROMAN NUMERAL TWO [2000] +0x86B5 U+2172 # SMALL ROMAN NUMERAL THREE [2000] +0x86B6 U+2173 # SMALL ROMAN NUMERAL FOUR [2000] +0x86B7 U+2174 # SMALL ROMAN NUMERAL FIVE [2000] +0x86B8 U+2175 # SMALL ROMAN NUMERAL SIX [2000] +0x86B9 U+2176 # SMALL ROMAN NUMERAL SEVEN [2000] +0x86BA U+2177 # SMALL ROMAN NUMERAL EIGHT [2000] +0x86BB U+2178 # SMALL ROMAN NUMERAL NINE [2000] +0x86BC U+2179 # SMALL ROMAN NUMERAL TEN [2000] +0x86BD U+217A # SMALL ROMAN NUMERAL ELEVEN [2000] +0x86BE U+217B # SMALL ROMAN NUMERAL TWELVE [2000] +0x86BF U+24D0 # CIRCLED LATIN SMALL LETTER A [2000] +0x86C0 U+24D1 # CIRCLED LATIN SMALL LETTER B [2000] +0x86C1 U+24D2 # CIRCLED LATIN SMALL LETTER C [2000] +0x86C2 U+24D3 # CIRCLED LATIN SMALL LETTER D [2000] +0x86C3 U+24D4 # CIRCLED LATIN SMALL LETTER E [2000] +0x86C4 U+24D5 # CIRCLED LATIN SMALL LETTER F [2000] +0x86C5 U+24D6 # CIRCLED LATIN SMALL LETTER G [2000] +0x86C6 U+24D7 # CIRCLED LATIN SMALL LETTER H [2000] +0x86C7 U+24D8 # CIRCLED LATIN SMALL LETTER I [2000] +0x86C8 U+24D9 # CIRCLED LATIN SMALL LETTER J [2000] +0x86C9 U+24DA # CIRCLED LATIN SMALL LETTER K [2000] +0x86CA U+24DB # CIRCLED LATIN SMALL LETTER L [2000] +0x86CB U+24DC # CIRCLED LATIN SMALL LETTER M [2000] +0x86CC U+24DD # CIRCLED LATIN SMALL LETTER N [2000] +0x86CD U+24DE # CIRCLED LATIN SMALL LETTER O [2000] +0x86CE U+24DF # CIRCLED LATIN SMALL LETTER P [2000] +0x86CF U+24E0 # CIRCLED LATIN SMALL LETTER Q [2000] +0x86D0 U+24E1 # CIRCLED LATIN SMALL LETTER R [2000] +0x86D1 U+24E2 # CIRCLED LATIN SMALL LETTER S [2000] +0x86D2 U+24E3 # CIRCLED LATIN SMALL LETTER T [2000] +0x86D3 U+24E4 # CIRCLED LATIN SMALL LETTER U [2000] +0x86D4 U+24E5 # CIRCLED LATIN SMALL LETTER V [2000] +0x86D5 U+24E6 # CIRCLED LATIN SMALL LETTER W [2000] +0x86D6 U+24E7 # CIRCLED LATIN SMALL LETTER X [2000] +0x86D7 U+24E8 # CIRCLED LATIN SMALL LETTER Y [2000] +0x86D8 U+24E9 # CIRCLED LATIN SMALL LETTER Z [2000] +0x86D9 U+32D0 # CIRCLED KATAKANA A [2000] +0x86DA U+32D1 # CIRCLED KATAKANA I [2000] +0x86DB U+32D2 # CIRCLED KATAKANA U [2000] +0x86DC U+32D3 # CIRCLED KATAKANA E [2000] +0x86DD U+32D4 # CIRCLED KATAKANA O [2000] +0x86DE U+32D5 # CIRCLED KATAKANA KA [2000] +0x86DF U+32D6 # CIRCLED KATAKANA KI [2000] +0x86E0 U+32D7 # CIRCLED KATAKANA KU [2000] +0x86E1 U+32D8 # CIRCLED KATAKANA KE [2000] +0x86E2 U+32D9 # CIRCLED KATAKANA KO [2000] +0x86E3 U+32DA # CIRCLED KATAKANA SA [2000] +0x86E4 U+32DB # CIRCLED KATAKANA SI [2000] +0x86E5 U+32DC # CIRCLED KATAKANA SU [2000] +0x86E6 U+32DD # CIRCLED KATAKANA SE [2000] +0x86E7 U+32DE # CIRCLED KATAKANA SO [2000] +0x86E8 U+32DF # CIRCLED KATAKANA TA [2000] +0x86E9 U+32E0 # CIRCLED KATAKANA TI [2000] +0x86EA U+32E1 # CIRCLED KATAKANA TU [2000] +0x86EB U+32E2 # CIRCLED KATAKANA TE [2000] +0x86EC U+32E3 # CIRCLED KATAKANA TO [2000] +0x86ED U+32FA # CIRCLED KATAKANA RO [2000] +0x86EE U+32E9 # CIRCLED KATAKANA HA [2000] +0x86EF U+32E5 # CIRCLED KATAKANA NI [2000] +0x86F0 U+32ED # CIRCLED KATAKANA HO [2000] +0x86F1 U+32EC # CIRCLED KATAKANA HE [2000] +0x86F2 # +0x86F3 # +0x86F4 # +0x86F5 # +0x86F6 # +0x86F7 # +0x86F8 # +0x86F9 # +0x86FA # +0x86FB U+2051 # TWO ASTERISKS ALIGNED VERTICALLY [2000] [Unicode3.2] +0x86FC U+2042 # ASTERISM [2000] +0x8740 U+2460 # CIRCLED DIGIT ONE [2000] +0x8741 U+2461 # CIRCLED DIGIT TWO [2000] +0x8742 U+2462 # CIRCLED DIGIT THREE [2000] +0x8743 U+2463 # CIRCLED DIGIT FOUR [2000] +0x8744 U+2464 # CIRCLED DIGIT FIVE [2000] +0x8745 U+2465 # CIRCLED DIGIT SIX [2000] +0x8746 U+2466 # CIRCLED DIGIT SEVEN [2000] +0x8747 U+2467 # CIRCLED DIGIT EIGHT [2000] +0x8748 U+2468 # CIRCLED DIGIT NINE [2000] +0x8749 U+2469 # CIRCLED NUMBER TEN [2000] +0x874A U+246A # CIRCLED NUMBER ELEVEN [2000] +0x874B U+246B # CIRCLED NUMBER TWELVE [2000] +0x874C U+246C # CIRCLED NUMBER THIRTEEN [2000] +0x874D U+246D # CIRCLED NUMBER FOURTEEN [2000] +0x874E U+246E # CIRCLED NUMBER FIFTEEN [2000] +0x874F U+246F # CIRCLED NUMBER SIXTEEN [2000] +0x8750 U+2470 # CIRCLED NUMBER SEVENTEEN [2000] +0x8751 U+2471 # CIRCLED NUMBER EIGHTEEN [2000] +0x8752 U+2472 # CIRCLED NUMBER NINETEEN [2000] +0x8753 U+2473 # CIRCLED NUMBER TWENTY [2000] +0x8754 U+2160 # ROMAN NUMERAL ONE [2000] +0x8755 U+2161 # ROMAN NUMERAL TWO [2000] +0x8756 U+2162 # ROMAN NUMERAL THREE [2000] +0x8757 U+2163 # ROMAN NUMERAL FOUR [2000] +0x8758 U+2164 # ROMAN NUMERAL FIVE [2000] +0x8759 U+2165 # ROMAN NUMERAL SIX [2000] +0x875A U+2166 # ROMAN NUMERAL SEVEN [2000] +0x875B U+2167 # ROMAN NUMERAL EIGHT [2000] +0x875C U+2168 # ROMAN NUMERAL NINE [2000] +0x875D U+2169 # ROMAN NUMERAL TEN [2000] +0x875E U+216A # ROMAN NUMERAL ELEVEN [2000] +0x875F U+3349 # SQUARE MIRI [2000] +0x8760 U+3314 # SQUARE KIRO [2000] +0x8761 U+3322 # SQUARE SENTI [2000] +0x8762 U+334D # SQUARE MEETORU [2000] +0x8763 U+3318 # SQUARE GURAMU [2000] +0x8764 U+3327 # SQUARE TON [2000] +0x8765 U+3303 # SQUARE AARU [2000] +0x8766 U+3336 # SQUARE HEKUTAARU [2000] +0x8767 U+3351 # SQUARE RITTORU [2000] +0x8768 U+3357 # SQUARE WATTO [2000] +0x8769 U+330D # SQUARE KARORII [2000] +0x876A U+3326 # SQUARE DORU [2000] +0x876B U+3323 # SQUARE SENTO [2000] +0x876C U+332B # SQUARE PAASENTO [2000] +0x876D U+334A # SQUARE MIRIBAARU [2000] +0x876E U+333B # SQUARE PEEZI [2000] +0x876F U+339C # SQUARE MM [2000] +0x8770 U+339D # SQUARE CM [2000] +0x8771 U+339E # SQUARE KM [2000] +0x8772 U+338E # SQUARE MG [2000] +0x8773 U+338F # SQUARE KG [2000] +0x8774 U+33C4 # SQUARE CC [2000] +0x8775 U+33A1 # SQUARE M SQUARED [2000] +0x8776 U+216B # ROMAN NUMERAL TWELVE [2000] +0x8777 # +0x8778 # +0x8779 # +0x877A # +0x877B # +0x877C # +0x877D # +0x877E U+337B # SQUARE ERA NAME HEISEI [2000] +0x8780 U+301D # REVERSED DOUBLE PRIME QUOTATION MARK [2000] +0x8781 U+301F # LOW DOUBLE PRIME QUOTATION MARK [2000] +0x8782 U+2116 # NUMERO SIGN [2000] +0x8783 U+33CD # SQUARE KK [2000] +0x8784 U+2121 # TELEPHONE SIGN [2000] +0x8785 U+32A4 # CIRCLED IDEOGRAPH HIGH [2000] +0x8786 U+32A5 # CIRCLED IDEOGRAPH CENTRE [2000] +0x8787 U+32A6 # CIRCLED IDEOGRAPH LOW [2000] +0x8788 U+32A7 # CIRCLED IDEOGRAPH LEFT [2000] +0x8789 U+32A8 # CIRCLED IDEOGRAPH RIGHT [2000] +0x878A U+3231 # PARENTHESIZED IDEOGRAPH STOCK [2000] +0x878B U+3232 # PARENTHESIZED IDEOGRAPH HAVE [2000] +0x878C U+3239 # PARENTHESIZED IDEOGRAPH REPRESENT [2000] +0x878D U+337E # SQUARE ERA NAME MEIZI [2000] +0x878E U+337D # SQUARE ERA NAME TAISYOU [2000] +0x878F U+337C # SQUARE ERA NAME SYOUWA [2000] +0x8790 # Windows: U+2252 +0x8791 # Windows: U+2261 +0x8792 # Windows: U+222B +0x8793 U+222E # CONTOUR INTEGRAL [2000] +0x8794 # Windows: U+2211 +0x8795 # Windows: U+221A +0x8796 # Windows: U+22A5 +0x8797 # Windows: U+2220 +0x8798 U+221F # RIGHT ANGLE [2000] +0x8799 U+22BF # RIGHT TRIANGLE [2000] +0x879A # Windows: U+2235 +0x879B # Windows: U+2229 +0x879C # Windows: U+222A +0x879D U+2756 # BLACK DIAMOND MINUS WHITE X [2000] +0x879E U+261E # WHITE RIGHT POINTING INDEX [2000] +0x879F U+4FF1 # [2004] +0x87A0 U+2000B # [2000] [Unicode3.1] +0x87A1 U+3402 # [2000] +0x87A2 U+4E28 # [2000] +0x87A3 U+4E2F # [2000] +0x87A4 U+4E30 # [2000] +0x87A5 U+4E8D # [2000] +0x87A6 U+4EE1 # [2000] +0x87A7 U+4EFD # [2000] +0x87A8 U+4EFF # [2000] +0x87A9 U+4F03 # [2000] +0x87AA U+4F0B # [2000] +0x87AB U+4F60 # [2000] +0x87AC U+4F48 # [2000] +0x87AD U+4F49 # [2000] +0x87AE U+4F56 # [2000] +0x87AF U+4F5F # [2000] +0x87B0 U+4F6A # [2000] +0x87B1 U+4F6C # [2000] +0x87B2 U+4F7E # [2000] +0x87B3 U+4F8A # [2000] +0x87B4 U+4F94 # [2000] +0x87B5 U+4F97 # [2000] +0x87B6 U+FA30 # CJK COMPATIBILITY IDEOGRAPH-FA30 [2000] [Unicode3.2] +0x87B7 U+4FC9 # [2000] +0x87B8 U+4FE0 # [2000] +0x87B9 U+5001 # [2000] +0x87BA U+5002 # [2000] +0x87BB U+500E # [2000] +0x87BC U+5018 # [2000] +0x87BD U+5027 # [2000] +0x87BE U+502E # [2000] +0x87BF U+5040 # [2000] +0x87C0 U+503B # [2000] +0x87C1 U+5041 # [2000] +0x87C2 U+5094 # [2000] +0x87C3 U+50CC # [2000] +0x87C4 U+50F2 # [2000] +0x87C5 U+50D0 # [2000] +0x87C6 U+50E6 # [2000] +0x87C7 U+FA31 # CJK COMPATIBILITY IDEOGRAPH-FA31 [2000] [Unicode3.2] +0x87C8 U+5106 # [2000] +0x87C9 U+5103 # [2000] +0x87CA U+510B # [2000] +0x87CB U+511E # [2000] +0x87CC U+5135 # [2000] +0x87CD U+514A # [2000] +0x87CE U+FA32 # CJK COMPATIBILITY IDEOGRAPH-FA32 [2000] [Unicode3.2] +0x87CF U+5155 # [2000] +0x87D0 U+5157 # [2000] +0x87D1 U+34B5 # [2000] +0x87D2 U+519D # [2000] +0x87D3 U+51C3 # [2000] +0x87D4 U+51CA # [2000] +0x87D5 U+51DE # [2000] +0x87D6 U+51E2 # [2000] +0x87D7 U+51EE # [2000] +0x87D8 U+5201 # [2000] +0x87D9 U+34DB # [2000] +0x87DA U+5213 # [2000] +0x87DB U+5215 # [2000] +0x87DC U+5249 # [2000] +0x87DD U+5257 # [2000] +0x87DE U+5261 # [2000] +0x87DF U+5293 # [2000] +0x87E0 U+52C8 # [2000] +0x87E1 U+FA33 # CJK COMPATIBILITY IDEOGRAPH-FA33 [2000] [Unicode3.2] +0x87E2 U+52CC # [2000] +0x87E3 U+52D0 # [2000] +0x87E4 U+52D6 # [2000] +0x87E5 U+52DB # [2000] +0x87E6 U+FA34 # CJK COMPATIBILITY IDEOGRAPH-FA34 [2000] [Unicode3.2] +0x87E7 U+52F0 # [2000] +0x87E8 U+52FB # [2000] +0x87E9 U+5300 # [2000] +0x87EA U+5307 # [2000] +0x87EB U+531C # [2000] +0x87EC U+FA35 # CJK COMPATIBILITY IDEOGRAPH-FA35 [2000] [Unicode3.2] +0x87ED U+5361 # [2000] +0x87EE U+5363 # [2000] +0x87EF U+537D # [2000] +0x87F0 U+5393 # [2000] +0x87F1 U+539D # [2000] +0x87F2 U+53B2 # [2000] +0x87F3 U+5412 # [2000] +0x87F4 U+5427 # [2000] +0x87F5 U+544D # [2000] +0x87F6 U+549C # [2000] +0x87F7 U+546B # [2000] +0x87F8 U+5474 # [2000] +0x87F9 U+547F # [2000] +0x87FA U+5488 # [2000] +0x87FB U+5496 # [2000] +0x87FC U+54A1 # [2000] +0x8840 U+54A9 # [2000] +0x8841 U+54C6 # [2000] +0x8842 U+54FF # [2000] +0x8843 U+550E # [2000] +0x8844 U+552B # [2000] +0x8845 U+5535 # [2000] +0x8846 U+5550 # [2000] +0x8847 U+555E # [2000] +0x8848 U+5581 # [2000] +0x8849 U+5586 # [2000] +0x884A U+558E # [2000] +0x884B U+FA36 # CJK COMPATIBILITY IDEOGRAPH-FA36 [2000] [Unicode3.2] +0x884C U+55AD # [2000] +0x884D U+55CE # [2000] +0x884E U+FA37 # CJK COMPATIBILITY IDEOGRAPH-FA37 [2000] [Unicode3.2] +0x884F U+5608 # [2000] +0x8850 U+560E # [2000] +0x8851 U+563B # [2000] +0x8852 U+5649 # [2000] +0x8853 U+5676 # [2000] +0x8854 U+5666 # [2000] +0x8855 U+FA38 # CJK COMPATIBILITY IDEOGRAPH-FA38 [2000] [Unicode3.2] +0x8856 U+566F # [2000] +0x8857 U+5671 # [2000] +0x8858 U+5672 # [2000] +0x8859 U+5699 # [2000] +0x885A U+569E # [2000] +0x885B U+56A9 # [2000] +0x885C U+56AC # [2000] +0x885D U+56B3 # [2000] +0x885E U+56C9 # [2000] +0x885F U+56CA # [2000] +0x8860 U+570A # [2000] +0x8861 U+2123D # [2000] [Unicode3.1] +0x8862 U+5721 # [2000] +0x8863 U+572F # [2000] +0x8864 U+5733 # [2000] +0x8865 U+5734 # [2000] +0x8866 U+5770 # [2000] +0x8867 U+5777 # [2000] +0x8868 U+577C # [2000] +0x8869 U+579C # [2000] +0x886A U+FA0F # CJK COMPATIBILITY IDEOGRAPH-FA0F [2000] +0x886B U+2131B # [2000] [Unicode3.1] +0x886C U+57B8 # [2000] +0x886D U+57C7 # [2000] +0x886E U+57C8 # [2000] +0x886F U+57CF # [2000] +0x8870 U+57E4 # [2000] +0x8871 U+57ED # [2000] +0x8872 U+57F5 # [2000] +0x8873 U+57F6 # [2000] +0x8874 U+57FF # [2000] +0x8875 U+5809 # [2000] +0x8876 U+FA10 # CJK COMPATIBILITY IDEOGRAPH-FA10 [2000] +0x8877 U+5861 # [2000] +0x8878 U+5864 # [2000] +0x8879 U+FA39 # CJK COMPATIBILITY IDEOGRAPH-FA39 [2000] [Unicode3.2] +0x887A U+587C # [2000] +0x887B U+5889 # [2000] +0x887C U+589E # [2000] +0x887D U+FA3A # CJK COMPATIBILITY IDEOGRAPH-FA3A [2000] [Unicode3.2] +0x887E U+58A9 # [2000] +0x8880 U+2146E # [2000] [Unicode3.1] +0x8881 U+58D2 # [2000] +0x8882 U+58CE # [2000] +0x8883 U+58D4 # [2000] +0x8884 U+58DA # [2000] +0x8885 U+58E0 # [2000] +0x8886 U+58E9 # [2000] +0x8887 U+590C # [2000] +0x8888 U+8641 # [2000] +0x8889 U+595D # [2000] +0x888A U+596D # [2000] +0x888B U+598B # [2000] +0x888C U+5992 # [2000] +0x888D U+59A4 # [2000] +0x888E U+59C3 # [2000] +0x888F U+59D2 # [2000] +0x8890 U+59DD # [2000] +0x8891 U+5A13 # [2000] +0x8892 U+5A23 # [2000] +0x8893 U+5A67 # [2000] +0x8894 U+5A6D # [2000] +0x8895 U+5A77 # [2000] +0x8896 U+5A7E # [2000] +0x8897 U+5A84 # [2000] +0x8898 U+5A9E # [2000] +0x8899 U+5AA7 # [2000] +0x889A U+5AC4 # [2000] +0x889B U+218BD # [2000] [Unicode3.1] +0x889C U+5B19 # [2000] +0x889D U+5B25 # [2000] +0x889E U+525D # [2004] +0x889F U+4E9C # +0x88A0 U+5516 # +0x88A1 U+5A03 # +0x88A2 U+963F # +0x88A3 U+54C0 # +0x88A4 U+611B # +0x88A5 U+6328 # +0x88A6 U+59F6 # +0x88A7 U+9022 # +0x88A8 U+8475 # +0x88A9 U+831C # +0x88AA U+7A50 # +0x88AB U+60AA # +0x88AC U+63E1 # +0x88AD U+6E25 # +0x88AE U+65ED # +0x88AF U+8466 # +0x88B0 U+82A6 # +0x88B1 U+9BF5 # +0x88B2 U+6893 # +0x88B3 U+5727 # +0x88B4 U+65A1 # +0x88B5 U+6271 # +0x88B6 U+5B9B # +0x88B7 U+59D0 # +0x88B8 U+867B # +0x88B9 U+98F4 # +0x88BA U+7D62 # +0x88BB U+7DBE # +0x88BC U+9B8E # +0x88BD U+6216 # +0x88BE U+7C9F # +0x88BF U+88B7 # +0x88C0 U+5B89 # +0x88C1 U+5EB5 # +0x88C2 U+6309 # +0x88C3 U+6697 # +0x88C4 U+6848 # +0x88C5 U+95C7 # +0x88C6 U+978D # +0x88C7 U+674F # +0x88C8 U+4EE5 # +0x88C9 U+4F0A # +0x88CA U+4F4D # +0x88CB U+4F9D # +0x88CC U+5049 # +0x88CD U+56F2 # +0x88CE U+5937 # +0x88CF U+59D4 # +0x88D0 U+5A01 # +0x88D1 U+5C09 # +0x88D2 U+60DF # +0x88D3 U+610F # +0x88D4 U+6170 # +0x88D5 U+6613 # +0x88D6 U+6905 # +0x88D7 U+70BA # +0x88D8 U+754F # +0x88D9 U+7570 # +0x88DA U+79FB # +0x88DB U+7DAD # +0x88DC U+7DEF # +0x88DD U+80C3 # +0x88DE U+840E # +0x88DF U+8863 # +0x88E0 U+8B02 # +0x88E1 U+9055 # +0x88E2 U+907A # +0x88E3 U+533B # +0x88E4 U+4E95 # +0x88E5 U+4EA5 # +0x88E6 U+57DF # +0x88E7 U+80B2 # +0x88E8 U+90C1 # +0x88E9 U+78EF # +0x88EA U+4E00 # +0x88EB U+58F1 # +0x88EC U+6EA2 # +0x88ED U+9038 # +0x88EE U+7A32 # +0x88EF U+8328 # +0x88F0 U+828B # +0x88F1 U+9C2F # +0x88F2 U+5141 # +0x88F3 U+5370 # +0x88F4 U+54BD # +0x88F5 U+54E1 # +0x88F6 U+56E0 # +0x88F7 U+59FB # +0x88F8 U+5F15 # +0x88F9 U+98F2 # +0x88FA U+6DEB # +0x88FB U+80E4 # +0x88FC U+852D # +0x8940 U+9662 # +0x8941 U+9670 # +0x8942 U+96A0 # +0x8943 U+97FB # +0x8944 U+540B # +0x8945 U+53F3 # +0x8946 U+5B87 # +0x8947 U+70CF # +0x8948 U+7FBD # +0x8949 U+8FC2 # +0x894A U+96E8 # +0x894B U+536F # +0x894C U+9D5C # +0x894D U+7ABA # +0x894E U+4E11 # +0x894F U+7893 # +0x8950 U+81FC # +0x8951 U+6E26 # +0x8952 U+5618 # +0x8953 U+5504 # +0x8954 U+6B1D # +0x8955 U+851A # +0x8956 U+9C3B # +0x8957 U+59E5 # +0x8958 U+53A9 # +0x8959 U+6D66 # +0x895A U+74DC # +0x895B U+958F # +0x895C U+5642 # +0x895D U+4E91 # +0x895E U+904B # +0x895F U+96F2 # +0x8960 U+834F # +0x8961 U+990C # +0x8962 U+53E1 # +0x8963 U+55B6 # +0x8964 U+5B30 # +0x8965 U+5F71 # +0x8966 U+6620 # +0x8967 U+66F3 # +0x8968 U+6804 # +0x8969 U+6C38 # +0x896A U+6CF3 # +0x896B U+6D29 # +0x896C U+745B # +0x896D U+76C8 # +0x896E U+7A4E # +0x896F U+9834 # +0x8970 U+82F1 # +0x8971 U+885B # +0x8972 U+8A60 # +0x8973 U+92ED # +0x8974 U+6DB2 # +0x8975 U+75AB # +0x8976 U+76CA # +0x8977 U+99C5 # +0x8978 U+60A6 # +0x8979 U+8B01 # +0x897A U+8D8A # +0x897B U+95B2 # +0x897C U+698E # +0x897D U+53AD # +0x897E U+5186 # +0x8980 U+5712 # +0x8981 U+5830 # +0x8982 U+5944 # +0x8983 U+5BB4 # +0x8984 U+5EF6 # +0x8985 U+6028 # +0x8986 U+63A9 # +0x8987 U+63F4 # +0x8988 U+6CBF # +0x8989 U+6F14 # +0x898A U+708E # +0x898B U+7114 # +0x898C U+7159 # +0x898D U+71D5 # +0x898E U+733F # +0x898F U+7E01 # +0x8990 U+8276 # +0x8991 U+82D1 # +0x8992 U+8597 # +0x8993 U+9060 # +0x8994 U+925B # +0x8995 U+9D1B # +0x8996 U+5869 # +0x8997 U+65BC # +0x8998 U+6C5A # +0x8999 U+7525 # +0x899A U+51F9 # +0x899B U+592E # +0x899C U+5965 # +0x899D U+5F80 # +0x899E U+5FDC # +0x899F U+62BC # +0x89A0 U+65FA # +0x89A1 U+6A2A # +0x89A2 U+6B27 # +0x89A3 U+6BB4 # +0x89A4 U+738B # +0x89A5 U+7FC1 # +0x89A6 U+8956 # +0x89A7 U+9D2C # +0x89A8 U+9D0E # +0x89A9 U+9EC4 # +0x89AA U+5CA1 # +0x89AB U+6C96 # +0x89AC U+837B # +0x89AD U+5104 # +0x89AE U+5C4B # +0x89AF U+61B6 # +0x89B0 U+81C6 # +0x89B1 U+6876 # +0x89B2 U+7261 # +0x89B3 U+4E59 # +0x89B4 U+4FFA # +0x89B5 U+5378 # +0x89B6 U+6069 # +0x89B7 U+6E29 # +0x89B8 U+7A4F # +0x89B9 U+97F3 # +0x89BA U+4E0B # +0x89BB U+5316 # +0x89BC U+4EEE # +0x89BD U+4F55 # +0x89BE U+4F3D # +0x89BF U+4FA1 # +0x89C0 U+4F73 # +0x89C1 U+52A0 # +0x89C2 U+53EF # +0x89C3 U+5609 # +0x89C4 U+590F # +0x89C5 U+5AC1 # +0x89C6 U+5BB6 # +0x89C7 U+5BE1 # +0x89C8 U+79D1 # +0x89C9 U+6687 # +0x89CA U+679C # +0x89CB U+67B6 # +0x89CC U+6B4C # +0x89CD U+6CB3 # +0x89CE U+706B # +0x89CF U+73C2 # +0x89D0 U+798D # +0x89D1 U+79BE # +0x89D2 U+7A3C # +0x89D3 U+7B87 # +0x89D4 U+82B1 # +0x89D5 U+82DB # +0x89D6 U+8304 # +0x89D7 U+8377 # +0x89D8 U+83EF # +0x89D9 U+83D3 # +0x89DA U+8766 # +0x89DB U+8AB2 # +0x89DC U+5629 # +0x89DD U+8CA8 # +0x89DE U+8FE6 # +0x89DF U+904E # +0x89E0 U+971E # +0x89E1 U+868A # +0x89E2 U+4FC4 # +0x89E3 U+5CE8 # +0x89E4 U+6211 # +0x89E5 U+7259 # +0x89E6 U+753B # +0x89E7 U+81E5 # +0x89E8 U+82BD # +0x89E9 U+86FE # +0x89EA U+8CC0 # +0x89EB U+96C5 # +0x89EC U+9913 # +0x89ED U+99D5 # +0x89EE U+4ECB # +0x89EF U+4F1A # +0x89F0 U+89E3 # +0x89F1 U+56DE # +0x89F2 U+584A # +0x89F3 U+58CA # +0x89F4 U+5EFB # +0x89F5 U+5FEB # +0x89F6 U+602A # +0x89F7 U+6094 # +0x89F8 U+6062 # +0x89F9 U+61D0 # +0x89FA U+6212 # +0x89FB U+62D0 # +0x89FC U+6539 # +0x8A40 U+9B41 # +0x8A41 U+6666 # +0x8A42 U+68B0 # +0x8A43 U+6D77 # +0x8A44 U+7070 # +0x8A45 U+754C # +0x8A46 U+7686 # +0x8A47 U+7D75 # +0x8A48 U+82A5 # +0x8A49 U+87F9 # +0x8A4A U+958B # +0x8A4B U+968E # +0x8A4C U+8C9D # +0x8A4D U+51F1 # +0x8A4E U+52BE # +0x8A4F U+5916 # +0x8A50 U+54B3 # +0x8A51 U+5BB3 # +0x8A52 U+5D16 # +0x8A53 U+6168 # +0x8A54 U+6982 # +0x8A55 U+6DAF # +0x8A56 U+788D # +0x8A57 U+84CB # +0x8A58 U+8857 # +0x8A59 U+8A72 # +0x8A5A U+93A7 # +0x8A5B U+9AB8 # +0x8A5C U+6D6C # +0x8A5D U+99A8 # +0x8A5E U+86D9 # +0x8A5F U+57A3 # +0x8A60 U+67FF # +0x8A61 U+86CE # +0x8A62 U+920E # +0x8A63 U+5283 # +0x8A64 U+5687 # +0x8A65 U+5404 # +0x8A66 U+5ED3 # +0x8A67 U+62E1 # +0x8A68 U+64B9 # +0x8A69 U+683C # +0x8A6A U+6838 # +0x8A6B U+6BBB # +0x8A6C U+7372 # +0x8A6D U+78BA # +0x8A6E U+7A6B # +0x8A6F U+899A # +0x8A70 U+89D2 # +0x8A71 U+8D6B # +0x8A72 U+8F03 # +0x8A73 U+90ED # +0x8A74 U+95A3 # +0x8A75 U+9694 # +0x8A76 U+9769 # +0x8A77 U+5B66 # +0x8A78 U+5CB3 # +0x8A79 U+697D # +0x8A7A U+984D # +0x8A7B U+984E # +0x8A7C U+639B # +0x8A7D U+7B20 # +0x8A7E U+6A2B # +0x8A80 U+6A7F # +0x8A81 U+68B6 # +0x8A82 U+9C0D # +0x8A83 U+6F5F # +0x8A84 U+5272 # +0x8A85 U+559D # +0x8A86 U+6070 # +0x8A87 U+62EC # +0x8A88 U+6D3B # +0x8A89 U+6E07 # +0x8A8A U+6ED1 # +0x8A8B U+845B # +0x8A8C U+8910 # +0x8A8D U+8F44 # +0x8A8E U+4E14 # +0x8A8F U+9C39 # +0x8A90 U+53F6 # +0x8A91 U+691B # +0x8A92 U+6A3A # +0x8A93 U+9784 # +0x8A94 U+682A # +0x8A95 U+515C # +0x8A96 U+7AC3 # +0x8A97 U+84B2 # +0x8A98 U+91DC # +0x8A99 U+938C # +0x8A9A U+565B # +0x8A9B U+9D28 # +0x8A9C U+6822 # +0x8A9D U+8305 # +0x8A9E U+8431 # +0x8A9F U+7CA5 # +0x8AA0 U+5208 # +0x8AA1 U+82C5 # +0x8AA2 U+74E6 # +0x8AA3 U+4E7E # +0x8AA4 U+4F83 # +0x8AA5 U+51A0 # +0x8AA6 U+5BD2 # +0x8AA7 U+520A # +0x8AA8 U+52D8 # +0x8AA9 U+52E7 # +0x8AAA U+5DFB # +0x8AAB U+559A # +0x8AAC U+582A # +0x8AAD U+59E6 # +0x8AAE U+5B8C # +0x8AAF U+5B98 # +0x8AB0 U+5BDB # +0x8AB1 U+5E72 # +0x8AB2 U+5E79 # +0x8AB3 U+60A3 # +0x8AB4 U+611F # +0x8AB5 U+6163 # +0x8AB6 U+61BE # +0x8AB7 U+63DB # +0x8AB8 U+6562 # +0x8AB9 U+67D1 # +0x8ABA U+6853 # +0x8ABB U+68FA # +0x8ABC U+6B3E # +0x8ABD U+6B53 # +0x8ABE U+6C57 # +0x8ABF U+6F22 # +0x8AC0 U+6F97 # +0x8AC1 U+6F45 # +0x8AC2 U+74B0 # +0x8AC3 U+7518 # +0x8AC4 U+76E3 # +0x8AC5 U+770B # +0x8AC6 U+7AFF # +0x8AC7 U+7BA1 # +0x8AC8 U+7C21 # +0x8AC9 U+7DE9 # +0x8ACA U+7F36 # +0x8ACB U+7FF0 # +0x8ACC U+809D # +0x8ACD U+8266 # +0x8ACE U+839E # +0x8ACF U+89B3 # +0x8AD0 U+8ACC # +0x8AD1 U+8CAB # +0x8AD2 U+9084 # +0x8AD3 U+9451 # +0x8AD4 U+9593 # +0x8AD5 U+9591 # +0x8AD6 U+95A2 # +0x8AD7 U+9665 # +0x8AD8 U+97D3 # +0x8AD9 U+9928 # +0x8ADA U+8218 # +0x8ADB U+4E38 # +0x8ADC U+542B # +0x8ADD U+5CB8 # +0x8ADE U+5DCC # +0x8ADF U+73A9 # +0x8AE0 U+764C # +0x8AE1 U+773C # +0x8AE2 U+5CA9 # +0x8AE3 U+7FEB # +0x8AE4 U+8D0B # +0x8AE5 U+96C1 # +0x8AE6 U+9811 # +0x8AE7 U+9854 # +0x8AE8 U+9858 # +0x8AE9 U+4F01 # +0x8AEA U+4F0E # +0x8AEB U+5371 # +0x8AEC U+559C # +0x8AED U+5668 # +0x8AEE U+57FA # +0x8AEF U+5947 # +0x8AF0 U+5B09 # +0x8AF1 U+5BC4 # +0x8AF2 U+5C90 # +0x8AF3 U+5E0C # +0x8AF4 U+5E7E # +0x8AF5 U+5FCC # +0x8AF6 U+63EE # +0x8AF7 U+673A # +0x8AF8 U+65D7 # +0x8AF9 U+65E2 # +0x8AFA U+671F # +0x8AFB U+68CB # +0x8AFC U+68C4 # +0x8B40 U+6A5F # +0x8B41 U+5E30 # +0x8B42 U+6BC5 # +0x8B43 U+6C17 # +0x8B44 U+6C7D # +0x8B45 U+757F # +0x8B46 U+7948 # +0x8B47 U+5B63 # +0x8B48 U+7A00 # +0x8B49 U+7D00 # +0x8B4A U+5FBD # +0x8B4B U+898F # +0x8B4C U+8A18 # +0x8B4D U+8CB4 # +0x8B4E U+8D77 # +0x8B4F U+8ECC # +0x8B50 U+8F1D # +0x8B51 U+98E2 # +0x8B52 U+9A0E # +0x8B53 U+9B3C # +0x8B54 U+4E80 # +0x8B55 U+507D # +0x8B56 U+5100 # +0x8B57 U+5993 # +0x8B58 U+5B9C # +0x8B59 U+622F # +0x8B5A U+6280 # +0x8B5B U+64EC # +0x8B5C U+6B3A # +0x8B5D U+72A0 # +0x8B5E U+7591 # +0x8B5F U+7947 # +0x8B60 U+7FA9 # +0x8B61 U+87FB # +0x8B62 U+8ABC # +0x8B63 U+8B70 # +0x8B64 U+63AC # +0x8B65 U+83CA # +0x8B66 U+97A0 # +0x8B67 U+5409 # +0x8B68 U+5403 # +0x8B69 U+55AB # +0x8B6A U+6854 # +0x8B6B U+6A58 # +0x8B6C U+8A70 # +0x8B6D U+7827 # +0x8B6E U+6775 # +0x8B6F U+9ECD # +0x8B70 U+5374 # +0x8B71 U+5BA2 # +0x8B72 U+811A # +0x8B73 U+8650 # +0x8B74 U+9006 # +0x8B75 U+4E18 # +0x8B76 U+4E45 # +0x8B77 U+4EC7 # +0x8B78 U+4F11 # +0x8B79 U+53CA # +0x8B7A U+5438 # +0x8B7B U+5BAE # +0x8B7C U+5F13 # +0x8B7D U+6025 # +0x8B7E U+6551 # +0x8B80 U+673D # +0x8B81 U+6C42 # +0x8B82 U+6C72 # +0x8B83 U+6CE3 # +0x8B84 U+7078 # +0x8B85 U+7403 # +0x8B86 U+7A76 # +0x8B87 U+7AAE # +0x8B88 U+7B08 # +0x8B89 U+7D1A # +0x8B8A U+7CFE # +0x8B8B U+7D66 # +0x8B8C U+65E7 # +0x8B8D U+725B # +0x8B8E U+53BB # +0x8B8F U+5C45 # +0x8B90 U+5DE8 # +0x8B91 U+62D2 # +0x8B92 U+62E0 # +0x8B93 U+6319 # +0x8B94 U+6E20 # +0x8B95 U+865A # +0x8B96 U+8A31 # +0x8B97 U+8DDD # +0x8B98 U+92F8 # +0x8B99 U+6F01 # +0x8B9A U+79A6 # +0x8B9B U+9B5A # +0x8B9C U+4EA8 # +0x8B9D U+4EAB # +0x8B9E U+4EAC # +0x8B9F U+4F9B # +0x8BA0 U+4FA0 # +0x8BA1 U+50D1 # +0x8BA2 U+5147 # +0x8BA3 U+7AF6 # +0x8BA4 U+5171 # +0x8BA5 U+51F6 # +0x8BA6 U+5354 # +0x8BA7 U+5321 # +0x8BA8 U+537F # +0x8BA9 U+53EB # +0x8BAA U+55AC # +0x8BAB U+5883 # +0x8BAC U+5CE1 # +0x8BAD U+5F37 # +0x8BAE U+5F4A # +0x8BAF U+602F # +0x8BB0 U+6050 # +0x8BB1 U+606D # +0x8BB2 U+631F # +0x8BB3 U+6559 # +0x8BB4 U+6A4B # +0x8BB5 U+6CC1 # +0x8BB6 U+72C2 # +0x8BB7 U+72ED # +0x8BB8 U+77EF # +0x8BB9 U+80F8 # +0x8BBA U+8105 # +0x8BBB U+8208 # +0x8BBC U+854E # +0x8BBD U+90F7 # +0x8BBE U+93E1 # +0x8BBF U+97FF # +0x8BC0 U+9957 # +0x8BC1 U+9A5A # +0x8BC2 U+4EF0 # +0x8BC3 U+51DD # +0x8BC4 U+5C2D # +0x8BC5 U+6681 # +0x8BC6 U+696D # +0x8BC7 U+5C40 # +0x8BC8 U+66F2 # +0x8BC9 U+6975 # +0x8BCA U+7389 # +0x8BCB U+6850 # +0x8BCC U+7C81 # +0x8BCD U+50C5 # +0x8BCE U+52E4 # +0x8BCF U+5747 # +0x8BD0 U+5DFE # +0x8BD1 U+9326 # +0x8BD2 U+65A4 # +0x8BD3 U+6B23 # +0x8BD4 U+6B3D # +0x8BD5 U+7434 # +0x8BD6 U+7981 # +0x8BD7 U+79BD # +0x8BD8 U+7B4B # +0x8BD9 U+7DCA # +0x8BDA U+82B9 # +0x8BDB U+83CC # +0x8BDC U+887F # +0x8BDD U+895F # +0x8BDE U+8B39 # +0x8BDF U+8FD1 # +0x8BE0 U+91D1 # +0x8BE1 U+541F # +0x8BE2 U+9280 # +0x8BE3 U+4E5D # +0x8BE4 U+5036 # +0x8BE5 U+53E5 # +0x8BE6 U+533A # +0x8BE7 U+72D7 # +0x8BE8 U+7396 # +0x8BE9 U+77E9 # +0x8BEA U+82E6 # +0x8BEB U+8EAF # +0x8BEC U+99C6 # +0x8BED U+99C8 # +0x8BEE U+99D2 # +0x8BEF U+5177 # +0x8BF0 U+611A # +0x8BF1 U+865E # +0x8BF2 U+55B0 # +0x8BF3 U+7A7A # +0x8BF4 U+5076 # +0x8BF5 U+5BD3 # +0x8BF6 U+9047 # +0x8BF7 U+9685 # +0x8BF8 U+4E32 # +0x8BF9 U+6ADB # +0x8BFA U+91E7 # +0x8BFB U+5C51 # +0x8BFC U+5C48 # +0x8C40 U+6398 # +0x8C41 U+7A9F # +0x8C42 U+6C93 # +0x8C43 U+9774 # +0x8C44 U+8F61 # +0x8C45 U+7AAA # +0x8C46 U+718A # +0x8C47 U+9688 # +0x8C48 U+7C82 # +0x8C49 U+6817 # +0x8C4A U+7E70 # +0x8C4B U+6851 # +0x8C4C U+936C # +0x8C4D U+52F2 # +0x8C4E U+541B # +0x8C4F U+85AB # +0x8C50 U+8A13 # +0x8C51 U+7FA4 # +0x8C52 U+8ECD # +0x8C53 U+90E1 # +0x8C54 U+5366 # +0x8C55 U+8888 # +0x8C56 U+7941 # +0x8C57 U+4FC2 # +0x8C58 U+50BE # +0x8C59 U+5211 # +0x8C5A U+5144 # +0x8C5B U+5553 # +0x8C5C U+572D # +0x8C5D U+73EA # +0x8C5E U+578B # +0x8C5F U+5951 # +0x8C60 U+5F62 # +0x8C61 U+5F84 # +0x8C62 U+6075 # +0x8C63 U+6176 # +0x8C64 U+6167 # +0x8C65 U+61A9 # +0x8C66 U+63B2 # +0x8C67 U+643A # +0x8C68 U+656C # +0x8C69 U+666F # +0x8C6A U+6842 # +0x8C6B U+6E13 # +0x8C6C U+7566 # +0x8C6D U+7A3D # +0x8C6E U+7CFB # +0x8C6F U+7D4C # +0x8C70 U+7D99 # +0x8C71 U+7E4B # +0x8C72 U+7F6B # +0x8C73 U+830E # +0x8C74 U+834A # +0x8C75 U+86CD # +0x8C76 U+8A08 # +0x8C77 U+8A63 # +0x8C78 U+8B66 # +0x8C79 U+8EFD # +0x8C7A U+981A # +0x8C7B U+9D8F # +0x8C7C U+82B8 # +0x8C7D U+8FCE # +0x8C7E U+9BE8 # +0x8C80 U+5287 # +0x8C81 U+621F # +0x8C82 U+6483 # +0x8C83 U+6FC0 # +0x8C84 U+9699 # +0x8C85 U+6841 # +0x8C86 U+5091 # +0x8C87 U+6B20 # +0x8C88 U+6C7A # +0x8C89 U+6F54 # +0x8C8A U+7A74 # +0x8C8B U+7D50 # +0x8C8C U+8840 # +0x8C8D U+8A23 # +0x8C8E U+6708 # +0x8C8F U+4EF6 # +0x8C90 U+5039 # +0x8C91 U+5026 # +0x8C92 U+5065 # +0x8C93 U+517C # +0x8C94 U+5238 # +0x8C95 U+5263 # +0x8C96 U+55A7 # +0x8C97 U+570F # +0x8C98 U+5805 # +0x8C99 U+5ACC # +0x8C9A U+5EFA # +0x8C9B U+61B2 # +0x8C9C U+61F8 # +0x8C9D U+62F3 # +0x8C9E U+6372 # +0x8C9F U+691C # +0x8CA0 U+6A29 # +0x8CA1 U+727D # +0x8CA2 U+72AC # +0x8CA3 U+732E # +0x8CA4 U+7814 # +0x8CA5 U+786F # +0x8CA6 U+7D79 # +0x8CA7 U+770C # +0x8CA8 U+80A9 # +0x8CA9 U+898B # +0x8CAA U+8B19 # +0x8CAB U+8CE2 # +0x8CAC U+8ED2 # +0x8CAD U+9063 # +0x8CAE U+9375 # +0x8CAF U+967A # +0x8CB0 U+9855 # +0x8CB1 U+9A13 # +0x8CB2 U+9E78 # +0x8CB3 U+5143 # +0x8CB4 U+539F # +0x8CB5 U+53B3 # +0x8CB6 U+5E7B # +0x8CB7 U+5F26 # +0x8CB8 U+6E1B # +0x8CB9 U+6E90 # +0x8CBA U+7384 # +0x8CBB U+73FE # +0x8CBC U+7D43 # +0x8CBD U+8237 # +0x8CBE U+8A00 # +0x8CBF U+8AFA # +0x8CC0 U+9650 # +0x8CC1 U+4E4E # +0x8CC2 U+500B # +0x8CC3 U+53E4 # +0x8CC4 U+547C # +0x8CC5 U+56FA # +0x8CC6 U+59D1 # +0x8CC7 U+5B64 # +0x8CC8 U+5DF1 # +0x8CC9 U+5EAB # +0x8CCA U+5F27 # +0x8CCB U+6238 # +0x8CCC U+6545 # +0x8CCD U+67AF # +0x8CCE U+6E56 # +0x8CCF U+72D0 # +0x8CD0 U+7CCA # +0x8CD1 U+88B4 # +0x8CD2 U+80A1 # +0x8CD3 U+80E1 # +0x8CD4 U+83F0 # +0x8CD5 U+864E # +0x8CD6 U+8A87 # +0x8CD7 U+8DE8 # +0x8CD8 U+9237 # +0x8CD9 U+96C7 # +0x8CDA U+9867 # +0x8CDB U+9F13 # +0x8CDC U+4E94 # +0x8CDD U+4E92 # +0x8CDE U+4F0D # +0x8CDF U+5348 # +0x8CE0 U+5449 # +0x8CE1 U+543E # +0x8CE2 U+5A2F # +0x8CE3 U+5F8C # +0x8CE4 U+5FA1 # +0x8CE5 U+609F # +0x8CE6 U+68A7 # +0x8CE7 U+6A8E # +0x8CE8 U+745A # +0x8CE9 U+7881 # +0x8CEA U+8A9E # +0x8CEB U+8AA4 # +0x8CEC U+8B77 # +0x8CED U+9190 # +0x8CEE U+4E5E # +0x8CEF U+9BC9 # +0x8CF0 U+4EA4 # +0x8CF1 U+4F7C # +0x8CF2 U+4FAF # +0x8CF3 U+5019 # +0x8CF4 U+5016 # +0x8CF5 U+5149 # +0x8CF6 U+516C # +0x8CF7 U+529F # +0x8CF8 U+52B9 # +0x8CF9 U+52FE # +0x8CFA U+539A # +0x8CFB U+53E3 # +0x8CFC U+5411 # +0x8D40 U+540E # +0x8D41 U+5589 # +0x8D42 U+5751 # +0x8D43 U+57A2 # +0x8D44 U+597D # +0x8D45 U+5B54 # +0x8D46 U+5B5D # +0x8D47 U+5B8F # +0x8D48 U+5DE5 # +0x8D49 U+5DE7 # +0x8D4A U+5DF7 # +0x8D4B U+5E78 # +0x8D4C U+5E83 # +0x8D4D U+5E9A # +0x8D4E U+5EB7 # +0x8D4F U+5F18 # +0x8D50 U+6052 # +0x8D51 U+614C # +0x8D52 U+6297 # +0x8D53 U+62D8 # +0x8D54 U+63A7 # +0x8D55 U+653B # +0x8D56 U+6602 # +0x8D57 U+6643 # +0x8D58 U+66F4 # +0x8D59 U+676D # +0x8D5A U+6821 # +0x8D5B U+6897 # +0x8D5C U+69CB # +0x8D5D U+6C5F # +0x8D5E U+6D2A # +0x8D5F U+6D69 # +0x8D60 U+6E2F # +0x8D61 U+6E9D # +0x8D62 U+7532 # +0x8D63 U+7687 # +0x8D64 U+786C # +0x8D65 U+7A3F # +0x8D66 U+7CE0 # +0x8D67 U+7D05 # +0x8D68 U+7D18 # +0x8D69 U+7D5E # +0x8D6A U+7DB1 # +0x8D6B U+8015 # +0x8D6C U+8003 # +0x8D6D U+80AF # +0x8D6E U+80B1 # +0x8D6F U+8154 # +0x8D70 U+818F # +0x8D71 U+822A # +0x8D72 U+8352 # +0x8D73 U+884C # +0x8D74 U+8861 # +0x8D75 U+8B1B # +0x8D76 U+8CA2 # +0x8D77 U+8CFC # +0x8D78 U+90CA # +0x8D79 U+9175 # +0x8D7A U+9271 # +0x8D7B U+783F # +0x8D7C U+92FC # +0x8D7D U+95A4 # +0x8D7E U+964D # +0x8D80 U+9805 # +0x8D81 U+9999 # +0x8D82 U+9AD8 # +0x8D83 U+9D3B # +0x8D84 U+525B # +0x8D85 U+52AB # +0x8D86 U+53F7 # +0x8D87 U+5408 # +0x8D88 U+58D5 # +0x8D89 U+62F7 # +0x8D8A U+6FE0 # +0x8D8B U+8C6A # +0x8D8C U+8F5F # +0x8D8D U+9EB9 # +0x8D8E U+514B # +0x8D8F U+523B # +0x8D90 U+544A # +0x8D91 U+56FD # +0x8D92 U+7A40 # +0x8D93 U+9177 # +0x8D94 U+9D60 # +0x8D95 U+9ED2 # +0x8D96 U+7344 # +0x8D97 U+6F09 # +0x8D98 U+8170 # +0x8D99 U+7511 # +0x8D9A U+5FFD # +0x8D9B U+60DA # +0x8D9C U+9AA8 # +0x8D9D U+72DB # +0x8D9E U+8FBC # +0x8D9F U+6B64 # +0x8DA0 U+9803 # +0x8DA1 U+4ECA # +0x8DA2 U+56F0 # +0x8DA3 U+5764 # +0x8DA4 U+58BE # +0x8DA5 U+5A5A # +0x8DA6 U+6068 # +0x8DA7 U+61C7 # +0x8DA8 U+660F # +0x8DA9 U+6606 # +0x8DAA U+6839 # +0x8DAB U+68B1 # +0x8DAC U+6DF7 # +0x8DAD U+75D5 # +0x8DAE U+7D3A # +0x8DAF U+826E # +0x8DB0 U+9B42 # +0x8DB1 U+4E9B # +0x8DB2 U+4F50 # +0x8DB3 U+53C9 # +0x8DB4 U+5506 # +0x8DB5 U+5D6F # +0x8DB6 U+5DE6 # +0x8DB7 U+5DEE # +0x8DB8 U+67FB # +0x8DB9 U+6C99 # +0x8DBA U+7473 # +0x8DBB U+7802 # +0x8DBC U+8A50 # +0x8DBD U+9396 # +0x8DBE U+88DF # +0x8DBF U+5750 # +0x8DC0 U+5EA7 # +0x8DC1 U+632B # +0x8DC2 U+50B5 # +0x8DC3 U+50AC # +0x8DC4 U+518D # +0x8DC5 U+6700 # +0x8DC6 U+54C9 # +0x8DC7 U+585E # +0x8DC8 U+59BB # +0x8DC9 U+5BB0 # +0x8DCA U+5F69 # +0x8DCB U+624D # +0x8DCC U+63A1 # +0x8DCD U+683D # +0x8DCE U+6B73 # +0x8DCF U+6E08 # +0x8DD0 U+707D # +0x8DD1 U+91C7 # +0x8DD2 U+7280 # +0x8DD3 U+7815 # +0x8DD4 U+7826 # +0x8DD5 U+796D # +0x8DD6 U+658E # +0x8DD7 U+7D30 # +0x8DD8 U+83DC # +0x8DD9 U+88C1 # +0x8DDA U+8F09 # +0x8DDB U+969B # +0x8DDC U+5264 # +0x8DDD U+5728 # +0x8DDE U+6750 # +0x8DDF U+7F6A # +0x8DE0 U+8CA1 # +0x8DE1 U+51B4 # +0x8DE2 U+5742 # +0x8DE3 U+962A # +0x8DE4 U+583A # +0x8DE5 U+698A # +0x8DE6 U+80B4 # +0x8DE7 U+54B2 # +0x8DE8 U+5D0E # +0x8DE9 U+57FC # +0x8DEA U+7895 # +0x8DEB U+9DFA # +0x8DEC U+4F5C # +0x8DED U+524A # +0x8DEE U+548B # +0x8DEF U+643E # +0x8DF0 U+6628 # +0x8DF1 U+6714 # +0x8DF2 U+67F5 # +0x8DF3 U+7A84 # +0x8DF4 U+7B56 # +0x8DF5 U+7D22 # +0x8DF6 U+932F # +0x8DF7 U+685C # +0x8DF8 U+9BAD # +0x8DF9 U+7B39 # +0x8DFA U+5319 # +0x8DFB U+518A # +0x8DFC U+5237 # +0x8E40 U+5BDF # +0x8E41 U+62F6 # +0x8E42 U+64AE # +0x8E43 U+64E6 # +0x8E44 U+672D # +0x8E45 U+6BBA # +0x8E46 U+85A9 # +0x8E47 U+96D1 # +0x8E48 U+7690 # +0x8E49 U+9BD6 # +0x8E4A U+634C # +0x8E4B U+9306 # +0x8E4C U+9BAB # +0x8E4D U+76BF # +0x8E4E U+6652 # +0x8E4F U+4E09 # +0x8E50 U+5098 # +0x8E51 U+53C2 # +0x8E52 U+5C71 # +0x8E53 U+60E8 # +0x8E54 U+6492 # +0x8E55 U+6563 # +0x8E56 U+685F # +0x8E57 U+71E6 # +0x8E58 U+73CA # +0x8E59 U+7523 # +0x8E5A U+7B97 # +0x8E5B U+7E82 # +0x8E5C U+8695 # +0x8E5D U+8B83 # +0x8E5E U+8CDB # +0x8E5F U+9178 # +0x8E60 U+9910 # +0x8E61 U+65AC # +0x8E62 U+66AB # +0x8E63 U+6B8B # +0x8E64 U+4ED5 # +0x8E65 U+4ED4 # +0x8E66 U+4F3A # +0x8E67 U+4F7F # +0x8E68 U+523A # +0x8E69 U+53F8 # +0x8E6A U+53F2 # +0x8E6B U+55E3 # +0x8E6C U+56DB # +0x8E6D U+58EB # +0x8E6E U+59CB # +0x8E6F U+59C9 # +0x8E70 U+59FF # +0x8E71 U+5B50 # +0x8E72 U+5C4D # +0x8E73 U+5E02 # +0x8E74 U+5E2B # +0x8E75 U+5FD7 # +0x8E76 U+601D # +0x8E77 U+6307 # +0x8E78 U+652F # +0x8E79 U+5B5C # +0x8E7A U+65AF # +0x8E7B U+65BD # +0x8E7C U+65E8 # +0x8E7D U+679D # +0x8E7E U+6B62 # +0x8E80 U+6B7B # +0x8E81 U+6C0F # +0x8E82 U+7345 # +0x8E83 U+7949 # +0x8E84 U+79C1 # +0x8E85 U+7CF8 # +0x8E86 U+7D19 # +0x8E87 U+7D2B # +0x8E88 U+80A2 # +0x8E89 U+8102 # +0x8E8A U+81F3 # +0x8E8B U+8996 # +0x8E8C U+8A5E # +0x8E8D U+8A69 # +0x8E8E U+8A66 # +0x8E8F U+8A8C # +0x8E90 U+8AEE # +0x8E91 U+8CC7 # +0x8E92 U+8CDC # +0x8E93 U+96CC # +0x8E94 U+98FC # +0x8E95 U+6B6F # +0x8E96 U+4E8B # +0x8E97 U+4F3C # +0x8E98 U+4F8D # +0x8E99 U+5150 # +0x8E9A U+5B57 # +0x8E9B U+5BFA # +0x8E9C U+6148 # +0x8E9D U+6301 # +0x8E9E U+6642 # +0x8E9F U+6B21 # +0x8EA0 U+6ECB # +0x8EA1 U+6CBB # +0x8EA2 U+723E # +0x8EA3 U+74BD # +0x8EA4 U+75D4 # +0x8EA5 U+78C1 # +0x8EA6 U+793A # +0x8EA7 U+800C # +0x8EA8 U+8033 # +0x8EA9 U+81EA # +0x8EAA U+8494 # +0x8EAB U+8F9E # +0x8EAC U+6C50 # +0x8EAD U+9E7F # +0x8EAE U+5F0F # +0x8EAF U+8B58 # +0x8EB0 U+9D2B # +0x8EB1 U+7AFA # +0x8EB2 U+8EF8 # +0x8EB3 U+5B8D # +0x8EB4 U+96EB # +0x8EB5 U+4E03 # +0x8EB6 U+53F1 # +0x8EB7 U+57F7 # +0x8EB8 U+5931 # +0x8EB9 U+5AC9 # +0x8EBA U+5BA4 # +0x8EBB U+6089 # +0x8EBC U+6E7F # +0x8EBD U+6F06 # +0x8EBE U+75BE # +0x8EBF U+8CEA # +0x8EC0 U+5B9F # +0x8EC1 U+8500 # +0x8EC2 U+7BE0 # +0x8EC3 U+5072 # +0x8EC4 U+67F4 # +0x8EC5 U+829D # +0x8EC6 U+5C61 # +0x8EC7 U+854A # +0x8EC8 U+7E1E # +0x8EC9 U+820E # +0x8ECA U+5199 # +0x8ECB U+5C04 # +0x8ECC U+6368 # +0x8ECD U+8D66 # +0x8ECE U+659C # +0x8ECF U+716E # +0x8ED0 U+793E # +0x8ED1 U+7D17 # +0x8ED2 U+8005 # +0x8ED3 U+8B1D # +0x8ED4 U+8ECA # +0x8ED5 U+906E # +0x8ED6 U+86C7 # +0x8ED7 U+90AA # +0x8ED8 U+501F # +0x8ED9 U+52FA # +0x8EDA U+5C3A # +0x8EDB U+6753 # +0x8EDC U+707C # +0x8EDD U+7235 # +0x8EDE U+914C # +0x8EDF U+91C8 # +0x8EE0 U+932B # +0x8EE1 U+82E5 # +0x8EE2 U+5BC2 # +0x8EE3 U+5F31 # +0x8EE4 U+60F9 # +0x8EE5 U+4E3B # +0x8EE6 U+53D6 # +0x8EE7 U+5B88 # +0x8EE8 U+624B # +0x8EE9 U+6731 # +0x8EEA U+6B8A # +0x8EEB U+72E9 # +0x8EEC U+73E0 # +0x8EED U+7A2E # +0x8EEE U+816B # +0x8EEF U+8DA3 # +0x8EF0 U+9152 # +0x8EF1 U+9996 # +0x8EF2 U+5112 # +0x8EF3 U+53D7 # +0x8EF4 U+546A # +0x8EF5 U+5BFF # +0x8EF6 U+6388 # +0x8EF7 U+6A39 # +0x8EF8 U+7DAC # +0x8EF9 U+9700 # +0x8EFA U+56DA # +0x8EFB U+53CE # +0x8EFC U+5468 # +0x8F40 U+5B97 # +0x8F41 U+5C31 # +0x8F42 U+5DDE # +0x8F43 U+4FEE # +0x8F44 U+6101 # +0x8F45 U+62FE # +0x8F46 U+6D32 # +0x8F47 U+79C0 # +0x8F48 U+79CB # +0x8F49 U+7D42 # +0x8F4A U+7E4D # +0x8F4B U+7FD2 # +0x8F4C U+81ED # +0x8F4D U+821F # +0x8F4E U+8490 # +0x8F4F U+8846 # +0x8F50 U+8972 # +0x8F51 U+8B90 # +0x8F52 U+8E74 # +0x8F53 U+8F2F # +0x8F54 U+9031 # +0x8F55 U+914B # +0x8F56 U+916C # +0x8F57 U+96C6 # +0x8F58 U+919C # +0x8F59 U+4EC0 # +0x8F5A U+4F4F # +0x8F5B U+5145 # +0x8F5C U+5341 # +0x8F5D U+5F93 # +0x8F5E U+620E # +0x8F5F U+67D4 # +0x8F60 U+6C41 # +0x8F61 U+6E0B # +0x8F62 U+7363 # +0x8F63 U+7E26 # +0x8F64 U+91CD # +0x8F65 U+9283 # +0x8F66 U+53D4 # +0x8F67 U+5919 # +0x8F68 U+5BBF # +0x8F69 U+6DD1 # +0x8F6A U+795D # +0x8F6B U+7E2E # +0x8F6C U+7C9B # +0x8F6D U+587E # +0x8F6E U+719F # +0x8F6F U+51FA # +0x8F70 U+8853 # +0x8F71 U+8FF0 # +0x8F72 U+4FCA # +0x8F73 U+5CFB # +0x8F74 U+6625 # +0x8F75 U+77AC # +0x8F76 U+7AE3 # +0x8F77 U+821C # +0x8F78 U+99FF # +0x8F79 U+51C6 # +0x8F7A U+5FAA # +0x8F7B U+65EC # +0x8F7C U+696F # +0x8F7D U+6B89 # +0x8F7E U+6DF3 # +0x8F80 U+6E96 # +0x8F81 U+6F64 # +0x8F82 U+76FE # +0x8F83 U+7D14 # +0x8F84 U+5DE1 # +0x8F85 U+9075 # +0x8F86 U+9187 # +0x8F87 U+9806 # +0x8F88 U+51E6 # +0x8F89 U+521D # +0x8F8A U+6240 # +0x8F8B U+6691 # +0x8F8C U+66D9 # +0x8F8D U+6E1A # +0x8F8E U+5EB6 # +0x8F8F U+7DD2 # +0x8F90 U+7F72 # +0x8F91 U+66F8 # +0x8F92 U+85AF # +0x8F93 U+85F7 # +0x8F94 U+8AF8 # +0x8F95 U+52A9 # +0x8F96 U+53D9 # +0x8F97 U+5973 # +0x8F98 U+5E8F # +0x8F99 U+5F90 # +0x8F9A U+6055 # +0x8F9B U+92E4 # +0x8F9C U+9664 # +0x8F9D U+50B7 # +0x8F9E U+511F # +0x8F9F U+52DD # +0x8FA0 U+5320 # +0x8FA1 U+5347 # +0x8FA2 U+53EC # +0x8FA3 U+54E8 # +0x8FA4 U+5546 # +0x8FA5 U+5531 # +0x8FA6 U+5617 # +0x8FA7 U+5968 # +0x8FA8 U+59BE # +0x8FA9 U+5A3C # +0x8FAA U+5BB5 # +0x8FAB U+5C06 # +0x8FAC U+5C0F # +0x8FAD U+5C11 # +0x8FAE U+5C1A # +0x8FAF U+5E84 # +0x8FB0 U+5E8A # +0x8FB1 U+5EE0 # +0x8FB2 U+5F70 # +0x8FB3 U+627F # +0x8FB4 U+6284 # +0x8FB5 U+62DB # +0x8FB6 U+638C # +0x8FB7 U+6377 # +0x8FB8 U+6607 # +0x8FB9 U+660C # +0x8FBA U+662D # +0x8FBB U+6676 # +0x8FBC U+677E # +0x8FBD U+68A2 # +0x8FBE U+6A1F # +0x8FBF U+6A35 # +0x8FC0 U+6CBC # +0x8FC1 U+6D88 # +0x8FC2 U+6E09 # +0x8FC3 U+6E58 # +0x8FC4 U+713C # +0x8FC5 U+7126 # +0x8FC6 U+7167 # +0x8FC7 U+75C7 # +0x8FC8 U+7701 # +0x8FC9 U+785D # +0x8FCA U+7901 # +0x8FCB U+7965 # +0x8FCC U+79F0 # +0x8FCD U+7AE0 # +0x8FCE U+7B11 # +0x8FCF U+7CA7 # +0x8FD0 U+7D39 # +0x8FD1 U+8096 # +0x8FD2 U+83D6 # +0x8FD3 U+848B # +0x8FD4 U+8549 # +0x8FD5 U+885D # +0x8FD6 U+88F3 # +0x8FD7 U+8A1F # +0x8FD8 U+8A3C # +0x8FD9 U+8A54 # +0x8FDA U+8A73 # +0x8FDB U+8C61 # +0x8FDC U+8CDE # +0x8FDD U+91A4 # +0x8FDE U+9266 # +0x8FDF U+937E # +0x8FE0 U+9418 # +0x8FE1 U+969C # +0x8FE2 U+9798 # +0x8FE3 U+4E0A # +0x8FE4 U+4E08 # +0x8FE5 U+4E1E # +0x8FE6 U+4E57 # +0x8FE7 U+5197 # +0x8FE8 U+5270 # +0x8FE9 U+57CE # +0x8FEA U+5834 # +0x8FEB U+58CC # +0x8FEC U+5B22 # +0x8FED U+5E38 # +0x8FEE U+60C5 # +0x8FEF U+64FE # +0x8FF0 U+6761 # +0x8FF1 U+6756 # +0x8FF2 U+6D44 # +0x8FF3 U+72B6 # +0x8FF4 U+7573 # +0x8FF5 U+7A63 # +0x8FF6 U+84B8 # +0x8FF7 U+8B72 # +0x8FF8 U+91B8 # +0x8FF9 U+9320 # +0x8FFA U+5631 # +0x8FFB U+57F4 # +0x8FFC U+98FE # +0x9040 U+62ED # +0x9041 U+690D # +0x9042 U+6B96 # +0x9043 U+71ED # +0x9044 U+7E54 # +0x9045 U+8077 # +0x9046 U+8272 # +0x9047 U+89E6 # +0x9048 U+98DF # +0x9049 U+8755 # +0x904A U+8FB1 # +0x904B U+5C3B # +0x904C U+4F38 # +0x904D U+4FE1 # +0x904E U+4FB5 # +0x904F U+5507 # +0x9050 U+5A20 # +0x9051 U+5BDD # +0x9052 U+5BE9 # +0x9053 U+5FC3 # +0x9054 U+614E # +0x9055 U+632F # +0x9056 U+65B0 # +0x9057 U+664B # +0x9058 U+68EE # +0x9059 U+699B # +0x905A U+6D78 # +0x905B U+6DF1 # +0x905C U+7533 # +0x905D U+75B9 # +0x905E U+771F # +0x905F U+795E # +0x9060 U+79E6 # +0x9061 U+7D33 # +0x9062 U+81E3 # +0x9063 U+82AF # +0x9064 U+85AA # +0x9065 U+89AA # +0x9066 U+8A3A # +0x9067 U+8EAB # +0x9068 U+8F9B # +0x9069 U+9032 # +0x906A U+91DD # +0x906B U+9707 # +0x906C U+4EBA # +0x906D U+4EC1 # +0x906E U+5203 # +0x906F U+5875 # +0x9070 U+58EC # +0x9071 U+5C0B # +0x9072 U+751A # +0x9073 U+5C3D # +0x9074 U+814E # +0x9075 U+8A0A # +0x9076 U+8FC5 # +0x9077 U+9663 # +0x9078 U+976D # +0x9079 U+7B25 # +0x907A U+8ACF # +0x907B U+9808 # +0x907C U+9162 # +0x907D U+56F3 # +0x907E U+53A8 # +0x9080 U+9017 # +0x9081 U+5439 # +0x9082 U+5782 # +0x9083 U+5E25 # +0x9084 U+63A8 # +0x9085 U+6C34 # +0x9086 U+708A # +0x9087 U+7761 # +0x9088 U+7C8B # +0x9089 U+7FE0 # +0x908A U+8870 # +0x908B U+9042 # +0x908C U+9154 # +0x908D U+9310 # +0x908E U+9318 # +0x908F U+968F # +0x9090 U+745E # +0x9091 U+9AC4 # +0x9092 U+5D07 # +0x9093 U+5D69 # +0x9094 U+6570 # +0x9095 U+67A2 # +0x9096 U+8DA8 # +0x9097 U+96DB # +0x9098 U+636E # +0x9099 U+6749 # +0x909A U+6919 # +0x909B U+83C5 # +0x909C U+9817 # +0x909D U+96C0 # +0x909E U+88FE # +0x909F U+6F84 # +0x90A0 U+647A # +0x90A1 U+5BF8 # +0x90A2 U+4E16 # +0x90A3 U+702C # +0x90A4 U+755D # +0x90A5 U+662F # +0x90A6 U+51C4 # +0x90A7 U+5236 # +0x90A8 U+52E2 # +0x90A9 U+59D3 # +0x90AA U+5F81 # +0x90AB U+6027 # +0x90AC U+6210 # +0x90AD U+653F # +0x90AE U+6574 # +0x90AF U+661F # +0x90B0 U+6674 # +0x90B1 U+68F2 # +0x90B2 U+6816 # +0x90B3 U+6B63 # +0x90B4 U+6E05 # +0x90B5 U+7272 # +0x90B6 U+751F # +0x90B7 U+76DB # +0x90B8 U+7CBE # +0x90B9 U+8056 # +0x90BA U+58F0 # +0x90BB U+88FD # +0x90BC U+897F # +0x90BD U+8AA0 # +0x90BE U+8A93 # +0x90BF U+8ACB # +0x90C0 U+901D # +0x90C1 U+9192 # +0x90C2 U+9752 # +0x90C3 U+9759 # +0x90C4 U+6589 # +0x90C5 U+7A0E # +0x90C6 U+8106 # +0x90C7 U+96BB # +0x90C8 U+5E2D # +0x90C9 U+60DC # +0x90CA U+621A # +0x90CB U+65A5 # +0x90CC U+6614 # +0x90CD U+6790 # +0x90CE U+77F3 # +0x90CF U+7A4D # +0x90D0 U+7C4D # +0x90D1 U+7E3E # +0x90D2 U+810A # +0x90D3 U+8CAC # +0x90D4 U+8D64 # +0x90D5 U+8DE1 # +0x90D6 U+8E5F # +0x90D7 U+78A9 # +0x90D8 U+5207 # +0x90D9 U+62D9 # +0x90DA U+63A5 # +0x90DB U+6442 # +0x90DC U+6298 # +0x90DD U+8A2D # +0x90DE U+7A83 # +0x90DF U+7BC0 # +0x90E0 U+8AAC # +0x90E1 U+96EA # +0x90E2 U+7D76 # +0x90E3 U+820C # +0x90E4 U+8749 # +0x90E5 U+4ED9 # +0x90E6 U+5148 # +0x90E7 U+5343 # +0x90E8 U+5360 # +0x90E9 U+5BA3 # +0x90EA U+5C02 # +0x90EB U+5C16 # +0x90EC U+5DDD # +0x90ED U+6226 # +0x90EE U+6247 # +0x90EF U+64B0 # +0x90F0 U+6813 # +0x90F1 U+6834 # +0x90F2 U+6CC9 # +0x90F3 U+6D45 # +0x90F4 U+6D17 # +0x90F5 U+67D3 # +0x90F6 U+6F5C # +0x90F7 U+714E # +0x90F8 U+717D # +0x90F9 U+65CB # +0x90FA U+7A7F # +0x90FB U+7BAD # +0x90FC U+7DDA # +0x9140 U+7E4A # +0x9141 U+7FA8 # +0x9142 U+817A # +0x9143 U+821B # +0x9144 U+8239 # +0x9145 U+85A6 # +0x9146 U+8A6E # +0x9147 U+8CCE # +0x9148 U+8DF5 # +0x9149 U+9078 # +0x914A U+9077 # +0x914B U+92AD # +0x914C U+9291 # +0x914D U+9583 # +0x914E U+9BAE # +0x914F U+524D # +0x9150 U+5584 # +0x9151 U+6F38 # +0x9152 U+7136 # +0x9153 U+5168 # +0x9154 U+7985 # +0x9155 U+7E55 # +0x9156 U+81B3 # +0x9157 U+7CCE # +0x9158 U+564C # +0x9159 U+5851 # +0x915A U+5CA8 # +0x915B U+63AA # +0x915C U+66FE # +0x915D U+66FD # +0x915E U+695A # +0x915F U+72D9 # +0x9160 U+758F # +0x9161 U+758E # +0x9162 U+790E # +0x9163 U+7956 # +0x9164 U+79DF # +0x9165 U+7C97 # +0x9166 U+7D20 # +0x9167 U+7D44 # +0x9168 U+8607 # +0x9169 U+8A34 # +0x916A U+963B # +0x916B U+9061 # +0x916C U+9F20 # +0x916D U+50E7 # +0x916E U+5275 # +0x916F U+53CC # +0x9170 U+53E2 # +0x9171 U+5009 # +0x9172 U+55AA # +0x9173 U+58EE # +0x9174 U+594F # +0x9175 U+723D # +0x9176 U+5B8B # +0x9177 U+5C64 # +0x9178 U+531D # +0x9179 U+60E3 # +0x917A U+60F3 # +0x917B U+635C # +0x917C U+6383 # +0x917D U+633F # +0x917E U+63BB # +0x9180 U+64CD # +0x9181 U+65E9 # +0x9182 U+66F9 # +0x9183 U+5DE3 # +0x9184 U+69CD # +0x9185 U+69FD # +0x9186 U+6F15 # +0x9187 U+71E5 # +0x9188 U+4E89 # +0x9189 U+75E9 # +0x918A U+76F8 # +0x918B U+7A93 # +0x918C U+7CDF # +0x918D U+7DCF # +0x918E U+7D9C # +0x918F U+8061 # +0x9190 U+8349 # +0x9191 U+8358 # +0x9192 U+846C # +0x9193 U+84BC # +0x9194 U+85FB # +0x9195 U+88C5 # +0x9196 U+8D70 # +0x9197 U+9001 # +0x9198 U+906D # +0x9199 U+9397 # +0x919A U+971C # +0x919B U+9A12 # +0x919C U+50CF # +0x919D U+5897 # +0x919E U+618E # +0x919F U+81D3 # +0x91A0 U+8535 # +0x91A1 U+8D08 # +0x91A2 U+9020 # +0x91A3 U+4FC3 # +0x91A4 U+5074 # +0x91A5 U+5247 # +0x91A6 U+5373 # +0x91A7 U+606F # +0x91A8 U+6349 # +0x91A9 U+675F # +0x91AA U+6E2C # +0x91AB U+8DB3 # +0x91AC U+901F # +0x91AD U+4FD7 # +0x91AE U+5C5E # +0x91AF U+8CCA # +0x91B0 U+65CF # +0x91B1 U+7D9A # +0x91B2 U+5352 # +0x91B3 U+8896 # +0x91B4 U+5176 # +0x91B5 U+63C3 # +0x91B6 U+5B58 # +0x91B7 U+5B6B # +0x91B8 U+5C0A # +0x91B9 U+640D # +0x91BA U+6751 # +0x91BB U+905C # +0x91BC U+4ED6 # +0x91BD U+591A # +0x91BE U+592A # +0x91BF U+6C70 # +0x91C0 U+8A51 # +0x91C1 U+553E # +0x91C2 U+5815 # +0x91C3 U+59A5 # +0x91C4 U+60F0 # +0x91C5 U+6253 # +0x91C6 U+67C1 # +0x91C7 U+8235 # +0x91C8 U+6955 # +0x91C9 U+9640 # +0x91CA U+99C4 # +0x91CB U+9A28 # +0x91CC U+4F53 # +0x91CD U+5806 # +0x91CE U+5BFE # +0x91CF U+8010 # +0x91D0 U+5CB1 # +0x91D1 U+5E2F # +0x91D2 U+5F85 # +0x91D3 U+6020 # +0x91D4 U+614B # +0x91D5 U+6234 # +0x91D6 U+66FF # +0x91D7 U+6CF0 # +0x91D8 U+6EDE # +0x91D9 U+80CE # +0x91DA U+817F # +0x91DB U+82D4 # +0x91DC U+888B # +0x91DD U+8CB8 # +0x91DE U+9000 # +0x91DF U+902E # +0x91E0 U+968A # +0x91E1 U+9EDB # +0x91E2 U+9BDB # +0x91E3 U+4EE3 # +0x91E4 U+53F0 # +0x91E5 U+5927 # +0x91E6 U+7B2C # +0x91E7 U+918D # +0x91E8 U+984C # +0x91E9 U+9DF9 # +0x91EA U+6EDD # +0x91EB U+7027 # +0x91EC U+5353 # +0x91ED U+5544 # +0x91EE U+5B85 # +0x91EF U+6258 # +0x91F0 U+629E # +0x91F1 U+62D3 # +0x91F2 U+6CA2 # +0x91F3 U+6FEF # +0x91F4 U+7422 # +0x91F5 U+8A17 # +0x91F6 U+9438 # +0x91F7 U+6FC1 # +0x91F8 U+8AFE # +0x91F9 U+8338 # +0x91FA U+51E7 # +0x91FB U+86F8 # +0x91FC U+53EA # +0x9240 U+53E9 # +0x9241 U+4F46 # +0x9242 U+9054 # +0x9243 U+8FB0 # +0x9244 U+596A # +0x9245 U+8131 # +0x9246 U+5DFD # +0x9247 U+7AEA # +0x9248 U+8FBF # +0x9249 U+68DA # +0x924A U+8C37 # +0x924B U+72F8 # +0x924C U+9C48 # +0x924D U+6A3D # +0x924E U+8AB0 # +0x924F U+4E39 # +0x9250 U+5358 # +0x9251 U+5606 # +0x9252 U+5766 # +0x9253 U+62C5 # +0x9254 U+63A2 # +0x9255 U+65E6 # +0x9256 U+6B4E # +0x9257 U+6DE1 # +0x9258 U+6E5B # +0x9259 U+70AD # +0x925A U+77ED # +0x925B U+7AEF # +0x925C U+7BAA # +0x925D U+7DBB # +0x925E U+803D # +0x925F U+80C6 # +0x9260 U+86CB # +0x9261 U+8A95 # +0x9262 U+935B # +0x9263 U+56E3 # +0x9264 U+58C7 # +0x9265 U+5F3E # +0x9266 U+65AD # +0x9267 U+6696 # +0x9268 U+6A80 # +0x9269 U+6BB5 # +0x926A U+7537 # +0x926B U+8AC7 # +0x926C U+5024 # +0x926D U+77E5 # +0x926E U+5730 # +0x926F U+5F1B # +0x9270 U+6065 # +0x9271 U+667A # +0x9272 U+6C60 # +0x9273 U+75F4 # +0x9274 U+7A1A # +0x9275 U+7F6E # +0x9276 U+81F4 # +0x9277 U+8718 # +0x9278 U+9045 # +0x9279 U+99B3 # +0x927A U+7BC9 # +0x927B U+755C # +0x927C U+7AF9 # +0x927D U+7B51 # +0x927E U+84C4 # +0x9280 U+9010 # +0x9281 U+79E9 # +0x9282 U+7A92 # +0x9283 U+8336 # +0x9284 U+5AE1 # +0x9285 U+7740 # +0x9286 U+4E2D # +0x9287 U+4EF2 # +0x9288 U+5B99 # +0x9289 U+5FE0 # +0x928A U+62BD # +0x928B U+663C # +0x928C U+67F1 # +0x928D U+6CE8 # +0x928E U+866B # +0x928F U+8877 # +0x9290 U+8A3B # +0x9291 U+914E # +0x9292 U+92F3 # +0x9293 U+99D0 # +0x9294 U+6A17 # +0x9295 U+7026 # +0x9296 U+732A # +0x9297 U+82E7 # +0x9298 U+8457 # +0x9299 U+8CAF # +0x929A U+4E01 # +0x929B U+5146 # +0x929C U+51CB # +0x929D U+558B # +0x929E U+5BF5 # +0x929F U+5E16 # +0x92A0 U+5E33 # +0x92A1 U+5E81 # +0x92A2 U+5F14 # +0x92A3 U+5F35 # +0x92A4 U+5F6B # +0x92A5 U+5FB4 # +0x92A6 U+61F2 # +0x92A7 U+6311 # +0x92A8 U+66A2 # +0x92A9 U+671D # +0x92AA U+6F6E # +0x92AB U+7252 # +0x92AC U+753A # +0x92AD U+773A # +0x92AE U+8074 # +0x92AF U+8139 # +0x92B0 U+8178 # +0x92B1 U+8776 # +0x92B2 U+8ABF # +0x92B3 U+8ADC # +0x92B4 U+8D85 # +0x92B5 U+8DF3 # +0x92B6 U+929A # +0x92B7 U+9577 # +0x92B8 U+9802 # +0x92B9 U+9CE5 # +0x92BA U+52C5 # +0x92BB U+6357 # +0x92BC U+76F4 # +0x92BD U+6715 # +0x92BE U+6C88 # +0x92BF U+73CD # +0x92C0 U+8CC3 # +0x92C1 U+93AE # +0x92C2 U+9673 # +0x92C3 U+6D25 # +0x92C4 U+589C # +0x92C5 U+690E # +0x92C6 U+69CC # +0x92C7 U+8FFD # +0x92C8 U+939A # +0x92C9 U+75DB # +0x92CA U+901A # +0x92CB U+585A # +0x92CC U+6802 # +0x92CD U+63B4 # +0x92CE U+69FB # +0x92CF U+4F43 # +0x92D0 U+6F2C # +0x92D1 U+67D8 # +0x92D2 U+8FBB # +0x92D3 U+8526 # +0x92D4 U+7DB4 # +0x92D5 U+9354 # +0x92D6 U+693F # +0x92D7 U+6F70 # +0x92D8 U+576A # +0x92D9 U+58F7 # +0x92DA U+5B2C # +0x92DB U+7D2C # +0x92DC U+722A # +0x92DD U+540A # +0x92DE U+91E3 # +0x92DF U+9DB4 # +0x92E0 U+4EAD # +0x92E1 U+4F4E # +0x92E2 U+505C # +0x92E3 U+5075 # +0x92E4 U+5243 # +0x92E5 U+8C9E # +0x92E6 U+5448 # +0x92E7 U+5824 # +0x92E8 U+5B9A # +0x92E9 U+5E1D # +0x92EA U+5E95 # +0x92EB U+5EAD # +0x92EC U+5EF7 # +0x92ED U+5F1F # +0x92EE U+608C # +0x92EF U+62B5 # +0x92F0 U+633A # +0x92F1 U+63D0 # +0x92F2 U+68AF # +0x92F3 U+6C40 # +0x92F4 U+7887 # +0x92F5 U+798E # +0x92F6 U+7A0B # +0x92F7 U+7DE0 # +0x92F8 U+8247 # +0x92F9 U+8A02 # +0x92FA U+8AE6 # +0x92FB U+8E44 # +0x92FC U+9013 # +0x9340 U+90B8 # +0x9341 U+912D # +0x9342 U+91D8 # +0x9343 U+9F0E # +0x9344 U+6CE5 # +0x9345 U+6458 # +0x9346 U+64E2 # +0x9347 U+6575 # +0x9348 U+6EF4 # +0x9349 U+7684 # +0x934A U+7B1B # +0x934B U+9069 # +0x934C U+93D1 # +0x934D U+6EBA # +0x934E U+54F2 # +0x934F U+5FB9 # +0x9350 U+64A4 # +0x9351 U+8F4D # +0x9352 U+8FED # +0x9353 U+9244 # +0x9354 U+5178 # +0x9355 U+586B # +0x9356 U+5929 # +0x9357 U+5C55 # +0x9358 U+5E97 # +0x9359 U+6DFB # +0x935A U+7E8F # +0x935B U+751C # +0x935C U+8CBC # +0x935D U+8EE2 # +0x935E U+985B # +0x935F U+70B9 # +0x9360 U+4F1D # +0x9361 U+6BBF # +0x9362 U+6FB1 # +0x9363 U+7530 # +0x9364 U+96FB # +0x9365 U+514E # +0x9366 U+5410 # +0x9367 U+5835 # +0x9368 U+5857 # +0x9369 U+59AC # +0x936A U+5C60 # +0x936B U+5F92 # +0x936C U+6597 # +0x936D U+675C # +0x936E U+6E21 # +0x936F U+767B # +0x9370 U+83DF # +0x9371 U+8CED # +0x9372 U+9014 # +0x9373 U+90FD # +0x9374 U+934D # +0x9375 U+7825 # +0x9376 U+783A # +0x9377 U+52AA # +0x9378 U+5EA6 # +0x9379 U+571F # +0x937A U+5974 # +0x937B U+6012 # +0x937C U+5012 # +0x937D U+515A # +0x937E U+51AC # +0x9380 U+51CD # +0x9381 U+5200 # +0x9382 U+5510 # +0x9383 U+5854 # +0x9384 U+5858 # +0x9385 U+5957 # +0x9386 U+5B95 # +0x9387 U+5CF6 # +0x9388 U+5D8B # +0x9389 U+60BC # +0x938A U+6295 # +0x938B U+642D # +0x938C U+6771 # +0x938D U+6843 # +0x938E U+68BC # +0x938F U+68DF # +0x9390 U+76D7 # +0x9391 U+6DD8 # +0x9392 U+6E6F # +0x9393 U+6D9B # +0x9394 U+706F # +0x9395 U+71C8 # +0x9396 U+5F53 # +0x9397 U+75D8 # +0x9398 U+7977 # +0x9399 U+7B49 # +0x939A U+7B54 # +0x939B U+7B52 # +0x939C U+7CD6 # +0x939D U+7D71 # +0x939E U+5230 # +0x939F U+8463 # +0x93A0 U+8569 # +0x93A1 U+85E4 # +0x93A2 U+8A0E # +0x93A3 U+8B04 # +0x93A4 U+8C46 # +0x93A5 U+8E0F # +0x93A6 U+9003 # +0x93A7 U+900F # +0x93A8 U+9419 # +0x93A9 U+9676 # +0x93AA U+982D # +0x93AB U+9A30 # +0x93AC U+95D8 # +0x93AD U+50CD # +0x93AE U+52D5 # +0x93AF U+540C # +0x93B0 U+5802 # +0x93B1 U+5C0E # +0x93B2 U+61A7 # +0x93B3 U+649E # +0x93B4 U+6D1E # +0x93B5 U+77B3 # +0x93B6 U+7AE5 # +0x93B7 U+80F4 # +0x93B8 U+8404 # +0x93B9 U+9053 # +0x93BA U+9285 # +0x93BB U+5CE0 # +0x93BC U+9D07 # +0x93BD U+533F # +0x93BE U+5F97 # +0x93BF U+5FB3 # +0x93C0 U+6D9C # +0x93C1 U+7279 # +0x93C2 U+7763 # +0x93C3 U+79BF # +0x93C4 U+7BE4 # +0x93C5 U+6BD2 # +0x93C6 U+72EC # +0x93C7 U+8AAD # +0x93C8 U+6803 # +0x93C9 U+6A61 # +0x93CA U+51F8 # +0x93CB U+7A81 # +0x93CC U+6934 # +0x93CD U+5C4A # +0x93CE U+9CF6 # +0x93CF U+82EB # +0x93D0 U+5BC5 # +0x93D1 U+9149 # +0x93D2 U+701E # +0x93D3 U+5678 # +0x93D4 U+5C6F # +0x93D5 U+60C7 # +0x93D6 U+6566 # +0x93D7 U+6C8C # +0x93D8 U+8C5A # +0x93D9 U+9041 # +0x93DA U+9813 # +0x93DB U+5451 # +0x93DC U+66C7 # +0x93DD U+920D # +0x93DE U+5948 # +0x93DF U+90A3 # +0x93E0 U+5185 # +0x93E1 U+4E4D # +0x93E2 U+51EA # +0x93E3 U+8599 # +0x93E4 U+8B0E # +0x93E5 U+7058 # +0x93E6 U+637A # +0x93E7 U+934B # +0x93E8 U+6962 # +0x93E9 U+99B4 # +0x93EA U+7E04 # +0x93EB U+7577 # +0x93EC U+5357 # +0x93ED U+6960 # +0x93EE U+8EDF # +0x93EF U+96E3 # +0x93F0 U+6C5D # +0x93F1 U+4E8C # +0x93F2 U+5C3C # +0x93F3 U+5F10 # +0x93F4 U+8FE9 # +0x93F5 U+5302 # +0x93F6 U+8CD1 # +0x93F7 U+8089 # +0x93F8 U+8679 # +0x93F9 U+5EFF # +0x93FA U+65E5 # +0x93FB U+4E73 # +0x93FC U+5165 # +0x9440 U+5982 # +0x9441 U+5C3F # +0x9442 U+97EE # +0x9443 U+4EFB # +0x9444 U+598A # +0x9445 U+5FCD # +0x9446 U+8A8D # +0x9447 U+6FE1 # +0x9448 U+79B0 # +0x9449 U+7962 # +0x944A U+5BE7 # +0x944B U+8471 # +0x944C U+732B # +0x944D U+71B1 # +0x944E U+5E74 # +0x944F U+5FF5 # +0x9450 U+637B # +0x9451 U+649A # +0x9452 U+71C3 # +0x9453 U+7C98 # +0x9454 U+4E43 # +0x9455 U+5EFC # +0x9456 U+4E4B # +0x9457 U+57DC # +0x9458 U+56A2 # +0x9459 U+60A9 # +0x945A U+6FC3 # +0x945B U+7D0D # +0x945C U+80FD # +0x945D U+8133 # +0x945E U+81BF # +0x945F U+8FB2 # +0x9460 U+8997 # +0x9461 U+86A4 # +0x9462 U+5DF4 # +0x9463 U+628A # +0x9464 U+64AD # +0x9465 U+8987 # +0x9466 U+6777 # +0x9467 U+6CE2 # +0x9468 U+6D3E # +0x9469 U+7436 # +0x946A U+7834 # +0x946B U+5A46 # +0x946C U+7F75 # +0x946D U+82AD # +0x946E U+99AC # +0x946F U+4FF3 # +0x9470 U+5EC3 # +0x9471 U+62DD # +0x9472 U+6392 # +0x9473 U+6557 # +0x9474 U+676F # +0x9475 U+76C3 # +0x9476 U+724C # +0x9477 U+80CC # +0x9478 U+80BA # +0x9479 U+8F29 # +0x947A U+914D # +0x947B U+500D # +0x947C U+57F9 # +0x947D U+5A92 # +0x947E U+6885 # +0x9480 U+6973 # +0x9481 U+7164 # +0x9482 U+72FD # +0x9483 U+8CB7 # +0x9484 U+58F2 # +0x9485 U+8CE0 # +0x9486 U+966A # +0x9487 U+9019 # +0x9488 U+877F # +0x9489 U+79E4 # +0x948A U+77E7 # +0x948B U+8429 # +0x948C U+4F2F # +0x948D U+5265 # +0x948E U+535A # +0x948F U+62CD # +0x9490 U+67CF # +0x9491 U+6CCA # +0x9492 U+767D # +0x9493 U+7B94 # +0x9494 U+7C95 # +0x9495 U+8236 # +0x9496 U+8584 # +0x9497 U+8FEB # +0x9498 U+66DD # +0x9499 U+6F20 # +0x949A U+7206 # +0x949B U+7E1B # +0x949C U+83AB # +0x949D U+99C1 # +0x949E U+9EA6 # +0x949F U+51FD # +0x94A0 U+7BB1 # +0x94A1 U+7872 # +0x94A2 U+7BB8 # +0x94A3 U+8087 # +0x94A4 U+7B48 # +0x94A5 U+6AE8 # +0x94A6 U+5E61 # +0x94A7 U+808C # +0x94A8 U+7551 # +0x94A9 U+7560 # +0x94AA U+516B # +0x94AB U+9262 # +0x94AC U+6E8C # +0x94AD U+767A # +0x94AE U+9197 # +0x94AF U+9AEA # +0x94B0 U+4F10 # +0x94B1 U+7F70 # +0x94B2 U+629C # +0x94B3 U+7B4F # +0x94B4 U+95A5 # +0x94B5 U+9CE9 # +0x94B6 U+567A # +0x94B7 U+5859 # +0x94B8 U+86E4 # +0x94B9 U+96BC # +0x94BA U+4F34 # +0x94BB U+5224 # +0x94BC U+534A # +0x94BD U+53CD # +0x94BE U+53DB # +0x94BF U+5E06 # +0x94C0 U+642C # +0x94C1 U+6591 # +0x94C2 U+677F # +0x94C3 U+6C3E # +0x94C4 U+6C4E # +0x94C5 U+7248 # +0x94C6 U+72AF # +0x94C7 U+73ED # +0x94C8 U+7554 # +0x94C9 U+7E41 # +0x94CA U+822C # +0x94CB U+85E9 # +0x94CC U+8CA9 # +0x94CD U+7BC4 # +0x94CE U+91C6 # +0x94CF U+7169 # +0x94D0 U+9812 # +0x94D1 U+98EF # +0x94D2 U+633D # +0x94D3 U+6669 # +0x94D4 U+756A # +0x94D5 U+76E4 # +0x94D6 U+78D0 # +0x94D7 U+8543 # +0x94D8 U+86EE # +0x94D9 U+532A # +0x94DA U+5351 # +0x94DB U+5426 # +0x94DC U+5983 # +0x94DD U+5E87 # +0x94DE U+5F7C # +0x94DF U+60B2 # +0x94E0 U+6249 # +0x94E1 U+6279 # +0x94E2 U+62AB # +0x94E3 U+6590 # +0x94E4 U+6BD4 # +0x94E5 U+6CCC # +0x94E6 U+75B2 # +0x94E7 U+76AE # +0x94E8 U+7891 # +0x94E9 U+79D8 # +0x94EA U+7DCB # +0x94EB U+7F77 # +0x94EC U+80A5 # +0x94ED U+88AB # +0x94EE U+8AB9 # +0x94EF U+8CBB # +0x94F0 U+907F # +0x94F1 U+975E # +0x94F2 U+98DB # +0x94F3 U+6A0B # +0x94F4 U+7C38 # +0x94F5 U+5099 # +0x94F6 U+5C3E # +0x94F7 U+5FAE # +0x94F8 U+6787 # +0x94F9 U+6BD8 # +0x94FA U+7435 # +0x94FB U+7709 # +0x94FC U+7F8E # +0x9540 U+9F3B # +0x9541 U+67CA # +0x9542 U+7A17 # +0x9543 U+5339 # +0x9544 U+758B # +0x9545 U+9AED # +0x9546 U+5F66 # +0x9547 U+819D # +0x9548 U+83F1 # +0x9549 U+8098 # +0x954A U+5F3C # +0x954B U+5FC5 # +0x954C U+7562 # +0x954D U+7B46 # +0x954E U+903C # +0x954F U+6867 # +0x9550 U+59EB # +0x9551 U+5A9B # +0x9552 U+7D10 # +0x9553 U+767E # +0x9554 U+8B2C # +0x9555 U+4FF5 # +0x9556 U+5F6A # +0x9557 U+6A19 # +0x9558 U+6C37 # +0x9559 U+6F02 # +0x955A U+74E2 # +0x955B U+7968 # +0x955C U+8868 # +0x955D U+8A55 # +0x955E U+8C79 # +0x955F U+5EDF # +0x9560 U+63CF # +0x9561 U+75C5 # +0x9562 U+79D2 # +0x9563 U+82D7 # +0x9564 U+9328 # +0x9565 U+92F2 # +0x9566 U+849C # +0x9567 U+86ED # +0x9568 U+9C2D # +0x9569 U+54C1 # +0x956A U+5F6C # +0x956B U+658C # +0x956C U+6D5C # +0x956D U+7015 # +0x956E U+8CA7 # +0x956F U+8CD3 # +0x9570 U+983B # +0x9571 U+654F # +0x9572 U+74F6 # +0x9573 U+4E0D # +0x9574 U+4ED8 # +0x9575 U+57E0 # +0x9576 U+592B # +0x9577 U+5A66 # +0x9578 U+5BCC # +0x9579 U+51A8 # +0x957A U+5E03 # +0x957B U+5E9C # +0x957C U+6016 # +0x957D U+6276 # +0x957E U+6577 # +0x9580 U+65A7 # +0x9581 U+666E # +0x9582 U+6D6E # +0x9583 U+7236 # +0x9584 U+7B26 # +0x9585 U+8150 # +0x9586 U+819A # +0x9587 U+8299 # +0x9588 U+8B5C # +0x9589 U+8CA0 # +0x958A U+8CE6 # +0x958B U+8D74 # +0x958C U+961C # +0x958D U+9644 # +0x958E U+4FAE # +0x958F U+64AB # +0x9590 U+6B66 # +0x9591 U+821E # +0x9592 U+8461 # +0x9593 U+856A # +0x9594 U+90E8 # +0x9595 U+5C01 # +0x9596 U+6953 # +0x9597 U+98A8 # +0x9598 U+847A # +0x9599 U+8557 # +0x959A U+4F0F # +0x959B U+526F # +0x959C U+5FA9 # +0x959D U+5E45 # +0x959E U+670D # +0x959F U+798F # +0x95A0 U+8179 # +0x95A1 U+8907 # +0x95A2 U+8986 # +0x95A3 U+6DF5 # +0x95A4 U+5F17 # +0x95A5 U+6255 # +0x95A6 U+6CB8 # +0x95A7 U+4ECF # +0x95A8 U+7269 # +0x95A9 U+9B92 # +0x95AA U+5206 # +0x95AB U+543B # +0x95AC U+5674 # +0x95AD U+58B3 # +0x95AE U+61A4 # +0x95AF U+626E # +0x95B0 U+711A # +0x95B1 U+596E # +0x95B2 U+7C89 # +0x95B3 U+7CDE # +0x95B4 U+7D1B # +0x95B5 U+96F0 # +0x95B6 U+6587 # +0x95B7 U+805E # +0x95B8 U+4E19 # +0x95B9 U+4F75 # +0x95BA U+5175 # +0x95BB U+5840 # +0x95BC U+5E63 # +0x95BD U+5E73 # +0x95BE U+5F0A # +0x95BF U+67C4 # +0x95C0 U+4E26 # +0x95C1 U+853D # +0x95C2 U+9589 # +0x95C3 U+965B # +0x95C4 U+7C73 # +0x95C5 U+9801 # +0x95C6 U+50FB # +0x95C7 U+58C1 # +0x95C8 U+7656 # +0x95C9 U+78A7 # +0x95CA U+5225 # +0x95CB U+77A5 # +0x95CC U+8511 # +0x95CD U+7B86 # +0x95CE U+504F # +0x95CF U+5909 # +0x95D0 U+7247 # +0x95D1 U+7BC7 # +0x95D2 U+7DE8 # +0x95D3 U+8FBA # +0x95D4 U+8FD4 # +0x95D5 U+904D # +0x95D6 U+4FBF # +0x95D7 U+52C9 # +0x95D8 U+5A29 # +0x95D9 U+5F01 # +0x95DA U+97AD # +0x95DB U+4FDD # +0x95DC U+8217 # +0x95DD U+92EA # +0x95DE U+5703 # +0x95DF U+6355 # +0x95E0 U+6B69 # +0x95E1 U+752B # +0x95E2 U+88DC # +0x95E3 U+8F14 # +0x95E4 U+7A42 # +0x95E5 U+52DF # +0x95E6 U+5893 # +0x95E7 U+6155 # +0x95E8 U+620A # +0x95E9 U+66AE # +0x95EA U+6BCD # +0x95EB U+7C3F # +0x95EC U+83E9 # +0x95ED U+5023 # +0x95EE U+4FF8 # +0x95EF U+5305 # +0x95F0 U+5446 # +0x95F1 U+5831 # +0x95F2 U+5949 # +0x95F3 U+5B9D # +0x95F4 U+5CF0 # +0x95F5 U+5CEF # +0x95F6 U+5D29 # +0x95F7 U+5E96 # +0x95F8 U+62B1 # +0x95F9 U+6367 # +0x95FA U+653E # +0x95FB U+65B9 # +0x95FC U+670B # +0x9640 U+6CD5 # +0x9641 U+6CE1 # +0x9642 U+70F9 # +0x9643 U+7832 # +0x9644 U+7E2B # +0x9645 U+80DE # +0x9646 U+82B3 # +0x9647 U+840C # +0x9648 U+84EC # +0x9649 U+8702 # +0x964A U+8912 # +0x964B U+8A2A # +0x964C U+8C4A # +0x964D U+90A6 # +0x964E U+92D2 # +0x964F U+98FD # +0x9650 U+9CF3 # +0x9651 U+9D6C # +0x9652 U+4E4F # +0x9653 U+4EA1 # +0x9654 U+508D # +0x9655 U+5256 # +0x9656 U+574A # +0x9657 U+59A8 # +0x9658 U+5E3D # +0x9659 U+5FD8 # +0x965A U+5FD9 # +0x965B U+623F # +0x965C U+66B4 # +0x965D U+671B # +0x965E U+67D0 # +0x965F U+68D2 # +0x9660 U+5192 # +0x9661 U+7D21 # +0x9662 U+80AA # +0x9663 U+81A8 # +0x9664 U+8B00 # +0x9665 U+8C8C # +0x9666 U+8CBF # +0x9667 U+927E # +0x9668 U+9632 # +0x9669 U+5420 # +0x966A U+982C # +0x966B U+5317 # +0x966C U+50D5 # +0x966D U+535C # +0x966E U+58A8 # +0x966F U+64B2 # +0x9670 U+6734 # +0x9671 U+7267 # +0x9672 U+7766 # +0x9673 U+7A46 # +0x9674 U+91E6 # +0x9675 U+52C3 # +0x9676 U+6CA1 # +0x9677 U+6B86 # +0x9678 U+5800 # +0x9679 U+5E4C # +0x967A U+5954 # +0x967B U+672C # +0x967C U+7FFB # +0x967D U+51E1 # +0x967E U+76C6 # +0x9680 U+6469 # +0x9681 U+78E8 # +0x9682 U+9B54 # +0x9683 U+9EBB # +0x9684 U+57CB # +0x9685 U+59B9 # +0x9686 U+6627 # +0x9687 U+679A # +0x9688 U+6BCE # +0x9689 U+54E9 # +0x968A U+69D9 # +0x968B U+5E55 # +0x968C U+819C # +0x968D U+6795 # +0x968E U+9BAA # +0x968F U+67FE # +0x9690 U+9C52 # +0x9691 U+685D # +0x9692 U+4EA6 # +0x9693 U+4FE3 # +0x9694 U+53C8 # +0x9695 U+62B9 # +0x9696 U+672B # +0x9697 U+6CAB # +0x9698 U+8FC4 # +0x9699 U+4FAD # +0x969A U+7E6D # +0x969B U+9EBF # +0x969C U+4E07 # +0x969D U+6162 # +0x969E U+6E80 # +0x969F U+6F2B # +0x96A0 U+8513 # +0x96A1 U+5473 # +0x96A2 U+672A # +0x96A3 U+9B45 # +0x96A4 U+5DF3 # +0x96A5 U+7B95 # +0x96A6 U+5CAC # +0x96A7 U+5BC6 # +0x96A8 U+871C # +0x96A9 U+6E4A # +0x96AA U+84D1 # +0x96AB U+7A14 # +0x96AC U+8108 # +0x96AD U+5999 # +0x96AE U+7C8D # +0x96AF U+6C11 # +0x96B0 U+7720 # +0x96B1 U+52D9 # +0x96B2 U+5922 # +0x96B3 U+7121 # +0x96B4 U+725F # +0x96B5 U+77DB # +0x96B6 U+9727 # +0x96B7 U+9D61 # +0x96B8 U+690B # +0x96B9 U+5A7F # +0x96BA U+5A18 # +0x96BB U+51A5 # +0x96BC U+540D # +0x96BD U+547D # +0x96BE U+660E # +0x96BF U+76DF # +0x96C0 U+8FF7 # +0x96C1 U+9298 # +0x96C2 U+9CF4 # +0x96C3 U+59EA # +0x96C4 U+725D # +0x96C5 U+6EC5 # +0x96C6 U+514D # +0x96C7 U+68C9 # +0x96C8 U+7DBF # +0x96C9 U+7DEC # +0x96CA U+9762 # +0x96CB U+9EBA # +0x96CC U+6478 # +0x96CD U+6A21 # +0x96CE U+8302 # +0x96CF U+5984 # +0x96D0 U+5B5F # +0x96D1 U+6BDB # +0x96D2 U+731B # +0x96D3 U+76F2 # +0x96D4 U+7DB2 # +0x96D5 U+8017 # +0x96D6 U+8499 # +0x96D7 U+5132 # +0x96D8 U+6728 # +0x96D9 U+9ED9 # +0x96DA U+76EE # +0x96DB U+6762 # +0x96DC U+52FF # +0x96DD U+9905 # +0x96DE U+5C24 # +0x96DF U+623B # +0x96E0 U+7C7E # +0x96E1 U+8CB0 # +0x96E2 U+554F # +0x96E3 U+60B6 # +0x96E4 U+7D0B # +0x96E5 U+9580 # +0x96E6 U+5301 # +0x96E7 U+4E5F # +0x96E8 U+51B6 # +0x96E9 U+591C # +0x96EA U+723A # +0x96EB U+8036 # +0x96EC U+91CE # +0x96ED U+5F25 # +0x96EE U+77E2 # +0x96EF U+5384 # +0x96F0 U+5F79 # +0x96F1 U+7D04 # +0x96F2 U+85AC # +0x96F3 U+8A33 # +0x96F4 U+8E8D # +0x96F5 U+9756 # +0x96F6 U+67F3 # +0x96F7 U+85AE # +0x96F8 U+9453 # +0x96F9 U+6109 # +0x96FA U+6108 # +0x96FB U+6CB9 # +0x96FC U+7652 # +0x9740 U+8AED # +0x9741 U+8F38 # +0x9742 U+552F # +0x9743 U+4F51 # +0x9744 U+512A # +0x9745 U+52C7 # +0x9746 U+53CB # +0x9747 U+5BA5 # +0x9748 U+5E7D # +0x9749 U+60A0 # +0x974A U+6182 # +0x974B U+63D6 # +0x974C U+6709 # +0x974D U+67DA # +0x974E U+6E67 # +0x974F U+6D8C # +0x9750 U+7336 # +0x9751 U+7337 # +0x9752 U+7531 # +0x9753 U+7950 # +0x9754 U+88D5 # +0x9755 U+8A98 # +0x9756 U+904A # +0x9757 U+9091 # +0x9758 U+90F5 # +0x9759 U+96C4 # +0x975A U+878D # +0x975B U+5915 # +0x975C U+4E88 # +0x975D U+4F59 # +0x975E U+4E0E # +0x975F U+8A89 # +0x9760 U+8F3F # +0x9761 U+9810 # +0x9762 U+50AD # +0x9763 U+5E7C # +0x9764 U+5996 # +0x9765 U+5BB9 # +0x9766 U+5EB8 # +0x9767 U+63DA # +0x9768 U+63FA # +0x9769 U+64C1 # +0x976A U+66DC # +0x976B U+694A # +0x976C U+69D8 # +0x976D U+6D0B # +0x976E U+6EB6 # +0x976F U+7194 # +0x9770 U+7528 # +0x9771 U+7AAF # +0x9772 U+7F8A # +0x9773 U+8000 # +0x9774 U+8449 # +0x9775 U+84C9 # +0x9776 U+8981 # +0x9777 U+8B21 # +0x9778 U+8E0A # +0x9779 U+9065 # +0x977A U+967D # +0x977B U+990A # +0x977C U+617E # +0x977D U+6291 # +0x977E U+6B32 # +0x9780 U+6C83 # +0x9781 U+6D74 # +0x9782 U+7FCC # +0x9783 U+7FFC # +0x9784 U+6DC0 # +0x9785 U+7F85 # +0x9786 U+87BA # +0x9787 U+88F8 # +0x9788 U+6765 # +0x9789 U+83B1 # +0x978A U+983C # +0x978B U+96F7 # +0x978C U+6D1B # +0x978D U+7D61 # +0x978E U+843D # +0x978F U+916A # +0x9790 U+4E71 # +0x9791 U+5375 # +0x9792 U+5D50 # +0x9793 U+6B04 # +0x9794 U+6FEB # +0x9795 U+85CD # +0x9796 U+862D # +0x9797 U+89A7 # +0x9798 U+5229 # +0x9799 U+540F # +0x979A U+5C65 # +0x979B U+674E # +0x979C U+68A8 # +0x979D U+7406 # +0x979E U+7483 # +0x979F U+75E2 # +0x97A0 U+88CF # +0x97A1 U+88E1 # +0x97A2 U+91CC # +0x97A3 U+96E2 # +0x97A4 U+9678 # +0x97A5 U+5F8B # +0x97A6 U+7387 # +0x97A7 U+7ACB # +0x97A8 U+844E # +0x97A9 U+63A0 # +0x97AA U+7565 # +0x97AB U+5289 # +0x97AC U+6D41 # +0x97AD U+6E9C # +0x97AE U+7409 # +0x97AF U+7559 # +0x97B0 U+786B # +0x97B1 U+7C92 # +0x97B2 U+9686 # +0x97B3 U+7ADC # +0x97B4 U+9F8D # +0x97B5 U+4FB6 # +0x97B6 U+616E # +0x97B7 U+65C5 # +0x97B8 U+865C # +0x97B9 U+4E86 # +0x97BA U+4EAE # +0x97BB U+50DA # +0x97BC U+4E21 # +0x97BD U+51CC # +0x97BE U+5BEE # +0x97BF U+6599 # +0x97C0 U+6881 # +0x97C1 U+6DBC # +0x97C2 U+731F # +0x97C3 U+7642 # +0x97C4 U+77AD # +0x97C5 U+7A1C # +0x97C6 U+7CE7 # +0x97C7 U+826F # +0x97C8 U+8AD2 # +0x97C9 U+907C # +0x97CA U+91CF # +0x97CB U+9675 # +0x97CC U+9818 # +0x97CD U+529B # +0x97CE U+7DD1 # +0x97CF U+502B # +0x97D0 U+5398 # +0x97D1 U+6797 # +0x97D2 U+6DCB # +0x97D3 U+71D0 # +0x97D4 U+7433 # +0x97D5 U+81E8 # +0x97D6 U+8F2A # +0x97D7 U+96A3 # +0x97D8 U+9C57 # +0x97D9 U+9E9F # +0x97DA U+7460 # +0x97DB U+5841 # +0x97DC U+6D99 # +0x97DD U+7D2F # +0x97DE U+985E # +0x97DF U+4EE4 # +0x97E0 U+4F36 # +0x97E1 U+4F8B # +0x97E2 U+51B7 # +0x97E3 U+52B1 # +0x97E4 U+5DBA # +0x97E5 U+601C # +0x97E6 U+73B2 # +0x97E7 U+793C # +0x97E8 U+82D3 # +0x97E9 U+9234 # +0x97EA U+96B7 # +0x97EB U+96F6 # +0x97EC U+970A # +0x97ED U+9E97 # +0x97EE U+9F62 # +0x97EF U+66A6 # +0x97F0 U+6B74 # +0x97F1 U+5217 # +0x97F2 U+52A3 # +0x97F3 U+70C8 # +0x97F4 U+88C2 # +0x97F5 U+5EC9 # +0x97F6 U+604B # +0x97F7 U+6190 # +0x97F8 U+6F23 # +0x97F9 U+7149 # +0x97FA U+7C3E # +0x97FB U+7DF4 # +0x97FC U+806F # +0x9840 U+84EE # +0x9841 U+9023 # +0x9842 U+932C # +0x9843 U+5442 # +0x9844 U+9B6F # +0x9845 U+6AD3 # +0x9846 U+7089 # +0x9847 U+8CC2 # +0x9848 U+8DEF # +0x9849 U+9732 # +0x984A U+52B4 # +0x984B U+5A41 # +0x984C U+5ECA # +0x984D U+5F04 # +0x984E U+6717 # +0x984F U+697C # +0x9850 U+6994 # +0x9851 U+6D6A # +0x9852 U+6F0F # +0x9853 U+7262 # +0x9854 U+72FC # +0x9855 U+7BED # +0x9856 U+8001 # +0x9857 U+807E # +0x9858 U+874B # +0x9859 U+90CE # +0x985A U+516D # +0x985B U+9E93 # +0x985C U+7984 # +0x985D U+808B # +0x985E U+9332 # +0x985F U+8AD6 # +0x9860 U+502D # +0x9861 U+548C # +0x9862 U+8A71 # +0x9863 U+6B6A # +0x9864 U+8CC4 # +0x9865 U+8107 # +0x9866 U+60D1 # +0x9867 U+67A0 # +0x9868 U+9DF2 # +0x9869 U+4E99 # +0x986A U+4E98 # +0x986B U+9C10 # +0x986C U+8A6B # +0x986D U+85C1 # +0x986E U+8568 # +0x986F U+6900 # +0x9870 U+6E7E # +0x9871 U+7897 # +0x9872 U+8155 # +0x9873 U+20B9F # [2004] [Unicode3.1] +0x9874 U+5B41 # [2000] +0x9875 U+5B56 # [2000] +0x9876 U+5B7D # [2000] +0x9877 U+5B93 # [2000] +0x9878 U+5BD8 # [2000] +0x9879 U+5BEC # [2000] +0x987A U+5C12 # [2000] +0x987B U+5C1E # [2000] +0x987C U+5C23 # [2000] +0x987D U+5C2B # [2000] +0x987E U+378D # [2000] +0x9880 U+5C62 # [2000] +0x9881 U+FA3B # CJK COMPATIBILITY IDEOGRAPH-FA3B [2000] [Unicode3.2] +0x9882 U+FA3C # CJK COMPATIBILITY IDEOGRAPH-FA3C [2000] [Unicode3.2] +0x9883 U+216B4 # [2000] [Unicode3.1] +0x9884 U+5C7A # [2000] +0x9885 U+5C8F # [2000] +0x9886 U+5C9F # [2000] +0x9887 U+5CA3 # [2000] +0x9888 U+5CAA # [2000] +0x9889 U+5CBA # [2000] +0x988A U+5CCB # [2000] +0x988B U+5CD0 # [2000] +0x988C U+5CD2 # [2000] +0x988D U+5CF4 # [2000] +0x988E U+21E34 # [2000] [Unicode3.1] +0x988F U+37E2 # [2000] +0x9890 U+5D0D # [2000] +0x9891 U+5D27 # [2000] +0x9892 U+FA11 # CJK COMPATIBILITY IDEOGRAPH-FA11 [2000] +0x9893 U+5D46 # [2000] +0x9894 U+5D47 # [2000] +0x9895 U+5D53 # [2000] +0x9896 U+5D4A # [2000] +0x9897 U+5D6D # [2000] +0x9898 U+5D81 # [2000] +0x9899 U+5DA0 # [2000] +0x989A U+5DA4 # [2000] +0x989B U+5DA7 # [2000] +0x989C U+5DB8 # [2000] +0x989D U+5DCB # [2000] +0x989E U+541E # [2004] +0x989F U+5F0C # +0x98A0 U+4E10 # +0x98A1 U+4E15 # +0x98A2 U+4E2A # +0x98A3 U+4E31 # +0x98A4 U+4E36 # +0x98A5 U+4E3C # +0x98A6 U+4E3F # +0x98A7 U+4E42 # +0x98A8 U+4E56 # +0x98A9 U+4E58 # +0x98AA U+4E82 # +0x98AB U+4E85 # +0x98AC U+8C6B # +0x98AD U+4E8A # +0x98AE U+8212 # +0x98AF U+5F0D # +0x98B0 U+4E8E # +0x98B1 U+4E9E # +0x98B2 U+4E9F # +0x98B3 U+4EA0 # +0x98B4 U+4EA2 # +0x98B5 U+4EB0 # +0x98B6 U+4EB3 # +0x98B7 U+4EB6 # +0x98B8 U+4ECE # +0x98B9 U+4ECD # +0x98BA U+4EC4 # +0x98BB U+4EC6 # +0x98BC U+4EC2 # +0x98BD U+4ED7 # +0x98BE U+4EDE # +0x98BF U+4EED # +0x98C0 U+4EDF # +0x98C1 U+4EF7 # +0x98C2 U+4F09 # +0x98C3 U+4F5A # +0x98C4 U+4F30 # +0x98C5 U+4F5B # +0x98C6 U+4F5D # +0x98C7 U+4F57 # +0x98C8 U+4F47 # +0x98C9 U+4F76 # +0x98CA U+4F88 # +0x98CB U+4F8F # +0x98CC U+4F98 # +0x98CD U+4F7B # +0x98CE U+4F69 # +0x98CF U+4F70 # +0x98D0 U+4F91 # +0x98D1 U+4F6F # +0x98D2 U+4F86 # +0x98D3 U+4F96 # +0x98D4 U+5118 # +0x98D5 U+4FD4 # +0x98D6 U+4FDF # +0x98D7 U+4FCE # +0x98D8 U+4FD8 # +0x98D9 U+4FDB # +0x98DA U+4FD1 # +0x98DB U+4FDA # +0x98DC U+4FD0 # +0x98DD U+4FE4 # +0x98DE U+4FE5 # +0x98DF U+501A # +0x98E0 U+5028 # +0x98E1 U+5014 # +0x98E2 U+502A # +0x98E3 U+5025 # +0x98E4 U+5005 # +0x98E5 U+4F1C # +0x98E6 U+4FF6 # +0x98E7 U+5021 # +0x98E8 U+5029 # +0x98E9 U+502C # +0x98EA U+4FFE # +0x98EB U+4FEF # +0x98EC U+5011 # +0x98ED U+5006 # +0x98EE U+5043 # +0x98EF U+5047 # +0x98F0 U+6703 # +0x98F1 U+5055 # +0x98F2 U+5050 # +0x98F3 U+5048 # +0x98F4 U+505A # +0x98F5 U+5056 # +0x98F6 U+506C # +0x98F7 U+5078 # +0x98F8 U+5080 # +0x98F9 U+509A # +0x98FA U+5085 # +0x98FB U+50B4 # +0x98FC U+50B2 # +0x9940 U+50C9 # +0x9941 U+50CA # +0x9942 U+50B3 # +0x9943 U+50C2 # +0x9944 U+50D6 # +0x9945 U+50DE # +0x9946 U+50E5 # +0x9947 U+50ED # +0x9948 U+50E3 # +0x9949 U+50EE # +0x994A U+50F9 # +0x994B U+50F5 # +0x994C U+5109 # +0x994D U+5101 # +0x994E U+5102 # +0x994F U+5116 # +0x9950 U+5115 # +0x9951 U+5114 # +0x9952 U+511A # +0x9953 U+5121 # +0x9954 U+513A # +0x9955 U+5137 # +0x9956 U+513C # +0x9957 U+513B # +0x9958 U+513F # +0x9959 U+5140 # +0x995A U+5152 # +0x995B U+514C # +0x995C U+5154 # +0x995D U+5162 # +0x995E U+7AF8 # +0x995F U+5169 # +0x9960 U+516A # +0x9961 U+516E # +0x9962 U+5180 # +0x9963 U+5182 # +0x9964 U+56D8 # +0x9965 U+518C # +0x9966 U+5189 # +0x9967 U+518F # +0x9968 U+5191 # +0x9969 U+5193 # +0x996A U+5195 # +0x996B U+5196 # +0x996C U+51A4 # +0x996D U+51A6 # +0x996E U+51A2 # +0x996F U+51A9 # +0x9970 U+51AA # +0x9971 U+51AB # +0x9972 U+51B3 # +0x9973 U+51B1 # +0x9974 U+51B2 # +0x9975 U+51B0 # +0x9976 U+51B5 # +0x9977 U+51BD # +0x9978 U+51C5 # +0x9979 U+51C9 # +0x997A U+51DB # +0x997B U+51E0 # +0x997C U+8655 # +0x997D U+51E9 # +0x997E U+51ED # +0x9980 U+51F0 # +0x9981 U+51F5 # +0x9982 U+51FE # +0x9983 U+5204 # +0x9984 U+520B # +0x9985 U+5214 # +0x9986 U+520E # +0x9987 U+5227 # +0x9988 U+522A # +0x9989 U+522E # +0x998A U+5233 # +0x998B U+5239 # +0x998C U+524F # +0x998D U+5244 # +0x998E U+524B # +0x998F U+524C # +0x9990 U+525E # +0x9991 U+5254 # +0x9992 U+526A # +0x9993 U+5274 # +0x9994 U+5269 # +0x9995 U+5273 # +0x9996 U+527F # +0x9997 U+527D # +0x9998 U+528D # +0x9999 U+5294 # +0x999A U+5292 # +0x999B U+5271 # +0x999C U+5288 # +0x999D U+5291 # +0x999E U+8FA8 # +0x999F U+8FA7 # +0x99A0 U+52AC # +0x99A1 U+52AD # +0x99A2 U+52BC # +0x99A3 U+52B5 # +0x99A4 U+52C1 # +0x99A5 U+52CD # +0x99A6 U+52D7 # +0x99A7 U+52DE # +0x99A8 U+52E3 # +0x99A9 U+52E6 # +0x99AA U+98ED # +0x99AB U+52E0 # +0x99AC U+52F3 # +0x99AD U+52F5 # +0x99AE U+52F8 # +0x99AF U+52F9 # +0x99B0 U+5306 # +0x99B1 U+5308 # +0x99B2 U+7538 # +0x99B3 U+530D # +0x99B4 U+5310 # +0x99B5 U+530F # +0x99B6 U+5315 # +0x99B7 U+531A # +0x99B8 U+5323 # +0x99B9 U+532F # +0x99BA U+5331 # +0x99BB U+5333 # +0x99BC U+5338 # +0x99BD U+5340 # +0x99BE U+5346 # +0x99BF U+5345 # +0x99C0 U+4E17 # +0x99C1 U+5349 # +0x99C2 U+534D # +0x99C3 U+51D6 # +0x99C4 U+535E # +0x99C5 U+5369 # +0x99C6 U+536E # +0x99C7 U+5918 # +0x99C8 U+537B # +0x99C9 U+5377 # +0x99CA U+5382 # +0x99CB U+5396 # +0x99CC U+53A0 # +0x99CD U+53A6 # +0x99CE U+53A5 # +0x99CF U+53AE # +0x99D0 U+53B0 # +0x99D1 U+53B6 # +0x99D2 U+53C3 # +0x99D3 U+7C12 # +0x99D4 U+96D9 # +0x99D5 U+53DF # +0x99D6 U+66FC # +0x99D7 U+71EE # +0x99D8 U+53EE # +0x99D9 U+53E8 # +0x99DA U+53ED # +0x99DB U+53FA # +0x99DC U+5401 # +0x99DD U+543D # +0x99DE U+5440 # +0x99DF U+542C # +0x99E0 U+542D # +0x99E1 U+543C # +0x99E2 U+542E # +0x99E3 U+5436 # +0x99E4 U+5429 # +0x99E5 U+541D # +0x99E6 U+544E # +0x99E7 U+548F # +0x99E8 U+5475 # +0x99E9 U+548E # +0x99EA U+545F # +0x99EB U+5471 # +0x99EC U+5477 # +0x99ED U+5470 # +0x99EE U+5492 # +0x99EF U+547B # +0x99F0 U+5480 # +0x99F1 U+5476 # +0x99F2 U+5484 # +0x99F3 U+5490 # +0x99F4 U+5486 # +0x99F5 U+54C7 # +0x99F6 U+54A2 # +0x99F7 U+54B8 # +0x99F8 U+54A5 # +0x99F9 U+54AC # +0x99FA U+54C4 # +0x99FB U+54C8 # +0x99FC U+54A8 # +0x9A40 U+54AB # +0x9A41 U+54C2 # +0x9A42 U+54A4 # +0x9A43 U+54BE # +0x9A44 U+54BC # +0x9A45 U+54D8 # +0x9A46 U+54E5 # +0x9A47 U+54E6 # +0x9A48 U+550F # +0x9A49 U+5514 # +0x9A4A U+54FD # +0x9A4B U+54EE # +0x9A4C U+54ED # +0x9A4D U+54FA # +0x9A4E U+54E2 # +0x9A4F U+5539 # +0x9A50 U+5540 # +0x9A51 U+5563 # +0x9A52 U+554C # +0x9A53 U+552E # +0x9A54 U+555C # +0x9A55 U+5545 # +0x9A56 U+5556 # +0x9A57 U+5557 # +0x9A58 U+5538 # +0x9A59 U+5533 # +0x9A5A U+555D # +0x9A5B U+5599 # +0x9A5C U+5580 # +0x9A5D U+54AF # +0x9A5E U+558A # +0x9A5F U+559F # +0x9A60 U+557B # +0x9A61 U+557E # +0x9A62 U+5598 # +0x9A63 U+559E # +0x9A64 U+55AE # +0x9A65 U+557C # +0x9A66 U+5583 # +0x9A67 U+55A9 # +0x9A68 U+5587 # +0x9A69 U+55A8 # +0x9A6A U+55DA # +0x9A6B U+55C5 # +0x9A6C U+55DF # +0x9A6D U+55C4 # +0x9A6E U+55DC # +0x9A6F U+55E4 # +0x9A70 U+55D4 # +0x9A71 U+5614 # +0x9A72 U+55F7 # +0x9A73 U+5616 # +0x9A74 U+55FE # +0x9A75 U+55FD # +0x9A76 U+561B # +0x9A77 U+55F9 # +0x9A78 U+564E # +0x9A79 U+5650 # +0x9A7A U+71DF # +0x9A7B U+5634 # +0x9A7C U+5636 # +0x9A7D U+5632 # +0x9A7E U+5638 # +0x9A80 U+566B # +0x9A81 U+5664 # +0x9A82 U+562F # +0x9A83 U+566C # +0x9A84 U+566A # +0x9A85 U+5686 # +0x9A86 U+5680 # +0x9A87 U+568A # +0x9A88 U+56A0 # +0x9A89 U+5694 # +0x9A8A U+568F # +0x9A8B U+56A5 # +0x9A8C U+56AE # +0x9A8D U+56B6 # +0x9A8E U+56B4 # +0x9A8F U+56C2 # +0x9A90 U+56BC # +0x9A91 U+56C1 # +0x9A92 U+56C3 # +0x9A93 U+56C0 # +0x9A94 U+56C8 # +0x9A95 U+56CE # +0x9A96 U+56D1 # +0x9A97 U+56D3 # +0x9A98 U+56D7 # +0x9A99 U+56EE # +0x9A9A U+56F9 # +0x9A9B U+5700 # +0x9A9C U+56FF # +0x9A9D U+5704 # +0x9A9E U+5709 # +0x9A9F U+5708 # +0x9AA0 U+570B # +0x9AA1 U+570D # +0x9AA2 U+5713 # +0x9AA3 U+5718 # +0x9AA4 U+5716 # +0x9AA5 U+55C7 # +0x9AA6 U+571C # +0x9AA7 U+5726 # +0x9AA8 U+5737 # +0x9AA9 U+5738 # +0x9AAA U+574E # +0x9AAB U+573B # +0x9AAC U+5740 # +0x9AAD U+574F # +0x9AAE U+5769 # +0x9AAF U+57C0 # +0x9AB0 U+5788 # +0x9AB1 U+5761 # +0x9AB2 U+577F # +0x9AB3 U+5789 # +0x9AB4 U+5793 # +0x9AB5 U+57A0 # +0x9AB6 U+57B3 # +0x9AB7 U+57A4 # +0x9AB8 U+57AA # +0x9AB9 U+57B0 # +0x9ABA U+57C3 # +0x9ABB U+57C6 # +0x9ABC U+57D4 # +0x9ABD U+57D2 # +0x9ABE U+57D3 # +0x9ABF U+580A # +0x9AC0 U+57D6 # +0x9AC1 U+57E3 # +0x9AC2 U+580B # +0x9AC3 U+5819 # +0x9AC4 U+581D # +0x9AC5 U+5872 # +0x9AC6 U+5821 # +0x9AC7 U+5862 # +0x9AC8 U+584B # +0x9AC9 U+5870 # +0x9ACA U+6BC0 # +0x9ACB U+5852 # +0x9ACC U+583D # +0x9ACD U+5879 # +0x9ACE U+5885 # +0x9ACF U+58B9 # +0x9AD0 U+589F # +0x9AD1 U+58AB # +0x9AD2 U+58BA # +0x9AD3 U+58DE # +0x9AD4 U+58BB # +0x9AD5 U+58B8 # +0x9AD6 U+58AE # +0x9AD7 U+58C5 # +0x9AD8 U+58D3 # +0x9AD9 U+58D1 # +0x9ADA U+58D7 # +0x9ADB U+58D9 # +0x9ADC U+58D8 # +0x9ADD U+58E5 # +0x9ADE U+58DC # +0x9ADF U+58E4 # +0x9AE0 U+58DF # +0x9AE1 U+58EF # +0x9AE2 U+58FA # +0x9AE3 U+58F9 # +0x9AE4 U+58FB # +0x9AE5 U+58FC # +0x9AE6 U+58FD # +0x9AE7 U+5902 # +0x9AE8 U+590A # +0x9AE9 U+5910 # +0x9AEA U+591B # +0x9AEB U+68A6 # +0x9AEC U+5925 # +0x9AED U+592C # +0x9AEE U+592D # +0x9AEF U+5932 # +0x9AF0 U+5938 # +0x9AF1 U+593E # +0x9AF2 U+7AD2 # +0x9AF3 U+5955 # +0x9AF4 U+5950 # +0x9AF5 U+594E # +0x9AF6 U+595A # +0x9AF7 U+5958 # +0x9AF8 U+5962 # +0x9AF9 U+5960 # +0x9AFA U+5967 # +0x9AFB U+596C # +0x9AFC U+5969 # +0x9B40 U+5978 # +0x9B41 U+5981 # +0x9B42 U+599D # +0x9B43 U+4F5E # +0x9B44 U+4FAB # +0x9B45 U+59A3 # +0x9B46 U+59B2 # +0x9B47 U+59C6 # +0x9B48 U+59E8 # +0x9B49 U+59DC # +0x9B4A U+598D # +0x9B4B U+59D9 # +0x9B4C U+59DA # +0x9B4D U+5A25 # +0x9B4E U+5A1F # +0x9B4F U+5A11 # +0x9B50 U+5A1C # +0x9B51 U+5A09 # +0x9B52 U+5A1A # +0x9B53 U+5A40 # +0x9B54 U+5A6C # +0x9B55 U+5A49 # +0x9B56 U+5A35 # +0x9B57 U+5A36 # +0x9B58 U+5A62 # +0x9B59 U+5A6A # +0x9B5A U+5A9A # +0x9B5B U+5ABC # +0x9B5C U+5ABE # +0x9B5D U+5ACB # +0x9B5E U+5AC2 # +0x9B5F U+5ABD # +0x9B60 U+5AE3 # +0x9B61 U+5AD7 # +0x9B62 U+5AE6 # +0x9B63 U+5AE9 # +0x9B64 U+5AD6 # +0x9B65 U+5AFA # +0x9B66 U+5AFB # +0x9B67 U+5B0C # +0x9B68 U+5B0B # +0x9B69 U+5B16 # +0x9B6A U+5B32 # +0x9B6B U+5AD0 # +0x9B6C U+5B2A # +0x9B6D U+5B36 # +0x9B6E U+5B3E # +0x9B6F U+5B43 # +0x9B70 U+5B45 # +0x9B71 U+5B40 # +0x9B72 U+5B51 # +0x9B73 U+5B55 # +0x9B74 U+5B5A # +0x9B75 U+5B5B # +0x9B76 U+5B65 # +0x9B77 U+5B69 # +0x9B78 U+5B70 # +0x9B79 U+5B73 # +0x9B7A U+5B75 # +0x9B7B U+5B78 # +0x9B7C U+6588 # +0x9B7D U+5B7A # +0x9B7E U+5B80 # +0x9B80 U+5B83 # +0x9B81 U+5BA6 # +0x9B82 U+5BB8 # +0x9B83 U+5BC3 # +0x9B84 U+5BC7 # +0x9B85 U+5BC9 # +0x9B86 U+5BD4 # +0x9B87 U+5BD0 # +0x9B88 U+5BE4 # +0x9B89 U+5BE6 # +0x9B8A U+5BE2 # +0x9B8B U+5BDE # +0x9B8C U+5BE5 # +0x9B8D U+5BEB # +0x9B8E U+5BF0 # +0x9B8F U+5BF6 # +0x9B90 U+5BF3 # +0x9B91 U+5C05 # +0x9B92 U+5C07 # +0x9B93 U+5C08 # +0x9B94 U+5C0D # +0x9B95 U+5C13 # +0x9B96 U+5C20 # +0x9B97 U+5C22 # +0x9B98 U+5C28 # +0x9B99 U+5C38 # +0x9B9A U+5C39 # +0x9B9B U+5C41 # +0x9B9C U+5C46 # +0x9B9D U+5C4E # +0x9B9E U+5C53 # +0x9B9F U+5C50 # +0x9BA0 U+5C4F # +0x9BA1 U+5B71 # +0x9BA2 U+5C6C # +0x9BA3 U+5C6E # +0x9BA4 U+4E62 # +0x9BA5 U+5C76 # +0x9BA6 U+5C79 # +0x9BA7 U+5C8C # +0x9BA8 U+5C91 # +0x9BA9 U+5C94 # +0x9BAA U+599B # +0x9BAB U+5CAB # +0x9BAC U+5CBB # +0x9BAD U+5CB6 # +0x9BAE U+5CBC # +0x9BAF U+5CB7 # +0x9BB0 U+5CC5 # +0x9BB1 U+5CBE # +0x9BB2 U+5CC7 # +0x9BB3 U+5CD9 # +0x9BB4 U+5CE9 # +0x9BB5 U+5CFD # +0x9BB6 U+5CFA # +0x9BB7 U+5CED # +0x9BB8 U+5D8C # +0x9BB9 U+5CEA # +0x9BBA U+5D0B # +0x9BBB U+5D15 # +0x9BBC U+5D17 # +0x9BBD U+5D5C # +0x9BBE U+5D1F # +0x9BBF U+5D1B # +0x9BC0 U+5D11 # +0x9BC1 U+5D14 # +0x9BC2 U+5D22 # +0x9BC3 U+5D1A # +0x9BC4 U+5D19 # +0x9BC5 U+5D18 # +0x9BC6 U+5D4C # +0x9BC7 U+5D52 # +0x9BC8 U+5D4E # +0x9BC9 U+5D4B # +0x9BCA U+5D6C # +0x9BCB U+5D73 # +0x9BCC U+5D76 # +0x9BCD U+5D87 # +0x9BCE U+5D84 # +0x9BCF U+5D82 # +0x9BD0 U+5DA2 # +0x9BD1 U+5D9D # +0x9BD2 U+5DAC # +0x9BD3 U+5DAE # +0x9BD4 U+5DBD # +0x9BD5 U+5D90 # +0x9BD6 U+5DB7 # +0x9BD7 U+5DBC # +0x9BD8 U+5DC9 # +0x9BD9 U+5DCD # +0x9BDA U+5DD3 # +0x9BDB U+5DD2 # +0x9BDC U+5DD6 # +0x9BDD U+5DDB # +0x9BDE U+5DEB # +0x9BDF U+5DF2 # +0x9BE0 U+5DF5 # +0x9BE1 U+5E0B # +0x9BE2 U+5E1A # +0x9BE3 U+5E19 # +0x9BE4 U+5E11 # +0x9BE5 U+5E1B # +0x9BE6 U+5E36 # +0x9BE7 U+5E37 # +0x9BE8 U+5E44 # +0x9BE9 U+5E43 # +0x9BEA U+5E40 # +0x9BEB U+5E4E # +0x9BEC U+5E57 # +0x9BED U+5E54 # +0x9BEE U+5E5F # +0x9BEF U+5E62 # +0x9BF0 U+5E64 # +0x9BF1 U+5E47 # +0x9BF2 U+5E75 # +0x9BF3 U+5E76 # +0x9BF4 U+5E7A # +0x9BF5 U+9EBC # +0x9BF6 U+5E7F # +0x9BF7 U+5EA0 # +0x9BF8 U+5EC1 # +0x9BF9 U+5EC2 # +0x9BFA U+5EC8 # +0x9BFB U+5ED0 # +0x9BFC U+5ECF # +0x9C40 U+5ED6 # +0x9C41 U+5EE3 # +0x9C42 U+5EDD # +0x9C43 U+5EDA # +0x9C44 U+5EDB # +0x9C45 U+5EE2 # +0x9C46 U+5EE1 # +0x9C47 U+5EE8 # +0x9C48 U+5EE9 # +0x9C49 U+5EEC # +0x9C4A U+5EF1 # +0x9C4B U+5EF3 # +0x9C4C U+5EF0 # +0x9C4D U+5EF4 # +0x9C4E U+5EF8 # +0x9C4F U+5EFE # +0x9C50 U+5F03 # +0x9C51 U+5F09 # +0x9C52 U+5F5D # +0x9C53 U+5F5C # +0x9C54 U+5F0B # +0x9C55 U+5F11 # +0x9C56 U+5F16 # +0x9C57 U+5F29 # +0x9C58 U+5F2D # +0x9C59 U+5F38 # +0x9C5A U+5F41 # +0x9C5B U+5F48 # +0x9C5C U+5F4C # +0x9C5D U+5F4E # +0x9C5E U+5F2F # +0x9C5F U+5F51 # +0x9C60 U+5F56 # +0x9C61 U+5F57 # +0x9C62 U+5F59 # +0x9C63 U+5F61 # +0x9C64 U+5F6D # +0x9C65 U+5F73 # +0x9C66 U+5F77 # +0x9C67 U+5F83 # +0x9C68 U+5F82 # +0x9C69 U+5F7F # +0x9C6A U+5F8A # +0x9C6B U+5F88 # +0x9C6C U+5F91 # +0x9C6D U+5F87 # +0x9C6E U+5F9E # +0x9C6F U+5F99 # +0x9C70 U+5F98 # +0x9C71 U+5FA0 # +0x9C72 U+5FA8 # +0x9C73 U+5FAD # +0x9C74 U+5FBC # +0x9C75 U+5FD6 # +0x9C76 U+5FFB # +0x9C77 U+5FE4 # +0x9C78 U+5FF8 # +0x9C79 U+5FF1 # +0x9C7A U+5FDD # +0x9C7B U+60B3 # +0x9C7C U+5FFF # +0x9C7D U+6021 # +0x9C7E U+6060 # +0x9C80 U+6019 # +0x9C81 U+6010 # +0x9C82 U+6029 # +0x9C83 U+600E # +0x9C84 U+6031 # +0x9C85 U+601B # +0x9C86 U+6015 # +0x9C87 U+602B # +0x9C88 U+6026 # +0x9C89 U+600F # +0x9C8A U+603A # +0x9C8B U+605A # +0x9C8C U+6041 # +0x9C8D U+606A # +0x9C8E U+6077 # +0x9C8F U+605F # +0x9C90 U+604A # +0x9C91 U+6046 # +0x9C92 U+604D # +0x9C93 U+6063 # +0x9C94 U+6043 # +0x9C95 U+6064 # +0x9C96 U+6042 # +0x9C97 U+606C # +0x9C98 U+606B # +0x9C99 U+6059 # +0x9C9A U+6081 # +0x9C9B U+608D # +0x9C9C U+60E7 # +0x9C9D U+6083 # +0x9C9E U+609A # +0x9C9F U+6084 # +0x9CA0 U+609B # +0x9CA1 U+6096 # +0x9CA2 U+6097 # +0x9CA3 U+6092 # +0x9CA4 U+60A7 # +0x9CA5 U+608B # +0x9CA6 U+60E1 # +0x9CA7 U+60B8 # +0x9CA8 U+60E0 # +0x9CA9 U+60D3 # +0x9CAA U+60B4 # +0x9CAB U+5FF0 # +0x9CAC U+60BD # +0x9CAD U+60C6 # +0x9CAE U+60B5 # +0x9CAF U+60D8 # +0x9CB0 U+614D # +0x9CB1 U+6115 # +0x9CB2 U+6106 # +0x9CB3 U+60F6 # +0x9CB4 U+60F7 # +0x9CB5 U+6100 # +0x9CB6 U+60F4 # +0x9CB7 U+60FA # +0x9CB8 U+6103 # +0x9CB9 U+6121 # +0x9CBA U+60FB # +0x9CBB U+60F1 # +0x9CBC U+610D # +0x9CBD U+610E # +0x9CBE U+6147 # +0x9CBF U+613E # +0x9CC0 U+6128 # +0x9CC1 U+6127 # +0x9CC2 U+614A # +0x9CC3 U+613F # +0x9CC4 U+613C # +0x9CC5 U+612C # +0x9CC6 U+6134 # +0x9CC7 U+613D # +0x9CC8 U+6142 # +0x9CC9 U+6144 # +0x9CCA U+6173 # +0x9CCB U+6177 # +0x9CCC U+6158 # +0x9CCD U+6159 # +0x9CCE U+615A # +0x9CCF U+616B # +0x9CD0 U+6174 # +0x9CD1 U+616F # +0x9CD2 U+6165 # +0x9CD3 U+6171 # +0x9CD4 U+615F # +0x9CD5 U+615D # +0x9CD6 U+6153 # +0x9CD7 U+6175 # +0x9CD8 U+6199 # +0x9CD9 U+6196 # +0x9CDA U+6187 # +0x9CDB U+61AC # +0x9CDC U+6194 # +0x9CDD U+619A # +0x9CDE U+618A # +0x9CDF U+6191 # +0x9CE0 U+61AB # +0x9CE1 U+61AE # +0x9CE2 U+61CC # +0x9CE3 U+61CA # +0x9CE4 U+61C9 # +0x9CE5 U+61F7 # +0x9CE6 U+61C8 # +0x9CE7 U+61C3 # +0x9CE8 U+61C6 # +0x9CE9 U+61BA # +0x9CEA U+61CB # +0x9CEB U+7F79 # +0x9CEC U+61CD # +0x9CED U+61E6 # +0x9CEE U+61E3 # +0x9CEF U+61F6 # +0x9CF0 U+61FA # +0x9CF1 U+61F4 # +0x9CF2 U+61FF # +0x9CF3 U+61FD # +0x9CF4 U+61FC # +0x9CF5 U+61FE # +0x9CF6 U+6200 # +0x9CF7 U+6208 # +0x9CF8 U+6209 # +0x9CF9 U+620D # +0x9CFA U+620C # +0x9CFB U+6214 # +0x9CFC U+621B # +0x9D40 U+621E # +0x9D41 U+6221 # +0x9D42 U+622A # +0x9D43 U+622E # +0x9D44 U+6230 # +0x9D45 U+6232 # +0x9D46 U+6233 # +0x9D47 U+6241 # +0x9D48 U+624E # +0x9D49 U+625E # +0x9D4A U+6263 # +0x9D4B U+625B # +0x9D4C U+6260 # +0x9D4D U+6268 # +0x9D4E U+627C # +0x9D4F U+6282 # +0x9D50 U+6289 # +0x9D51 U+627E # +0x9D52 U+6292 # +0x9D53 U+6293 # +0x9D54 U+6296 # +0x9D55 U+62D4 # +0x9D56 U+6283 # +0x9D57 U+6294 # +0x9D58 U+62D7 # +0x9D59 U+62D1 # +0x9D5A U+62BB # +0x9D5B U+62CF # +0x9D5C U+62FF # +0x9D5D U+62C6 # +0x9D5E U+64D4 # +0x9D5F U+62C8 # +0x9D60 U+62DC # +0x9D61 U+62CC # +0x9D62 U+62CA # +0x9D63 U+62C2 # +0x9D64 U+62C7 # +0x9D65 U+629B # +0x9D66 U+62C9 # +0x9D67 U+630C # +0x9D68 U+62EE # +0x9D69 U+62F1 # +0x9D6A U+6327 # +0x9D6B U+6302 # +0x9D6C U+6308 # +0x9D6D U+62EF # +0x9D6E U+62F5 # +0x9D6F U+6350 # +0x9D70 U+633E # +0x9D71 U+634D # +0x9D72 U+641C # +0x9D73 U+634F # +0x9D74 U+6396 # +0x9D75 U+638E # +0x9D76 U+6380 # +0x9D77 U+63AB # +0x9D78 U+6376 # +0x9D79 U+63A3 # +0x9D7A U+638F # +0x9D7B U+6389 # +0x9D7C U+639F # +0x9D7D U+63B5 # +0x9D7E U+636B # +0x9D80 U+6369 # +0x9D81 U+63BE # +0x9D82 U+63E9 # +0x9D83 U+63C0 # +0x9D84 U+63C6 # +0x9D85 U+63E3 # +0x9D86 U+63C9 # +0x9D87 U+63D2 # +0x9D88 U+63F6 # +0x9D89 U+63C4 # +0x9D8A U+6416 # +0x9D8B U+6434 # +0x9D8C U+6406 # +0x9D8D U+6413 # +0x9D8E U+6426 # +0x9D8F U+6436 # +0x9D90 U+651D # +0x9D91 U+6417 # +0x9D92 U+6428 # +0x9D93 U+640F # +0x9D94 U+6467 # +0x9D95 U+646F # +0x9D96 U+6476 # +0x9D97 U+644E # +0x9D98 U+652A # +0x9D99 U+6495 # +0x9D9A U+6493 # +0x9D9B U+64A5 # +0x9D9C U+64A9 # +0x9D9D U+6488 # +0x9D9E U+64BC # +0x9D9F U+64DA # +0x9DA0 U+64D2 # +0x9DA1 U+64C5 # +0x9DA2 U+64C7 # +0x9DA3 U+64BB # +0x9DA4 U+64D8 # +0x9DA5 U+64C2 # +0x9DA6 U+64F1 # +0x9DA7 U+64E7 # +0x9DA8 U+8209 # +0x9DA9 U+64E0 # +0x9DAA U+64E1 # +0x9DAB U+62AC # +0x9DAC U+64E3 # +0x9DAD U+64EF # +0x9DAE U+652C # +0x9DAF U+64F6 # +0x9DB0 U+64F4 # +0x9DB1 U+64F2 # +0x9DB2 U+64FA # +0x9DB3 U+6500 # +0x9DB4 U+64FD # +0x9DB5 U+6518 # +0x9DB6 U+651C # +0x9DB7 U+6505 # +0x9DB8 U+6524 # +0x9DB9 U+6523 # +0x9DBA U+652B # +0x9DBB U+6534 # +0x9DBC U+6535 # +0x9DBD U+6537 # +0x9DBE U+6536 # +0x9DBF U+6538 # +0x9DC0 U+754B # +0x9DC1 U+6548 # +0x9DC2 U+6556 # +0x9DC3 U+6555 # +0x9DC4 U+654D # +0x9DC5 U+6558 # +0x9DC6 U+655E # +0x9DC7 U+655D # +0x9DC8 U+6572 # +0x9DC9 U+6578 # +0x9DCA U+6582 # +0x9DCB U+6583 # +0x9DCC U+8B8A # +0x9DCD U+659B # +0x9DCE U+659F # +0x9DCF U+65AB # +0x9DD0 U+65B7 # +0x9DD1 U+65C3 # +0x9DD2 U+65C6 # +0x9DD3 U+65C1 # +0x9DD4 U+65C4 # +0x9DD5 U+65CC # +0x9DD6 U+65D2 # +0x9DD7 U+65DB # +0x9DD8 U+65D9 # +0x9DD9 U+65E0 # +0x9DDA U+65E1 # +0x9DDB U+65F1 # +0x9DDC U+6772 # +0x9DDD U+660A # +0x9DDE U+6603 # +0x9DDF U+65FB # +0x9DE0 U+6773 # +0x9DE1 U+6635 # +0x9DE2 U+6636 # +0x9DE3 U+6634 # +0x9DE4 U+661C # +0x9DE5 U+664F # +0x9DE6 U+6644 # +0x9DE7 U+6649 # +0x9DE8 U+6641 # +0x9DE9 U+665E # +0x9DEA U+665D # +0x9DEB U+6664 # +0x9DEC U+6667 # +0x9DED U+6668 # +0x9DEE U+665F # +0x9DEF U+6662 # +0x9DF0 U+6670 # +0x9DF1 U+6683 # +0x9DF2 U+6688 # +0x9DF3 U+668E # +0x9DF4 U+6689 # +0x9DF5 U+6684 # +0x9DF6 U+6698 # +0x9DF7 U+669D # +0x9DF8 U+66C1 # +0x9DF9 U+66B9 # +0x9DFA U+66C9 # +0x9DFB U+66BE # +0x9DFC U+66BC # +0x9E40 U+66C4 # +0x9E41 U+66B8 # +0x9E42 U+66D6 # +0x9E43 U+66DA # +0x9E44 U+66E0 # +0x9E45 U+663F # +0x9E46 U+66E6 # +0x9E47 U+66E9 # +0x9E48 U+66F0 # +0x9E49 U+66F5 # +0x9E4A U+66F7 # +0x9E4B U+670F # +0x9E4C U+6716 # +0x9E4D U+671E # +0x9E4E U+6726 # +0x9E4F U+6727 # +0x9E50 U+9738 # +0x9E51 U+672E # +0x9E52 U+673F # +0x9E53 U+6736 # +0x9E54 U+6741 # +0x9E55 U+6738 # +0x9E56 U+6737 # +0x9E57 U+6746 # +0x9E58 U+675E # +0x9E59 U+6760 # +0x9E5A U+6759 # +0x9E5B U+6763 # +0x9E5C U+6764 # +0x9E5D U+6789 # +0x9E5E U+6770 # +0x9E5F U+67A9 # +0x9E60 U+677C # +0x9E61 U+676A # +0x9E62 U+678C # +0x9E63 U+678B # +0x9E64 U+67A6 # +0x9E65 U+67A1 # +0x9E66 U+6785 # +0x9E67 U+67B7 # +0x9E68 U+67EF # +0x9E69 U+67B4 # +0x9E6A U+67EC # +0x9E6B U+67B3 # +0x9E6C U+67E9 # +0x9E6D U+67B8 # +0x9E6E U+67E4 # +0x9E6F U+67DE # +0x9E70 U+67DD # +0x9E71 U+67E2 # +0x9E72 U+67EE # +0x9E73 U+67B9 # +0x9E74 U+67CE # +0x9E75 U+67C6 # +0x9E76 U+67E7 # +0x9E77 U+6A9C # +0x9E78 U+681E # +0x9E79 U+6846 # +0x9E7A U+6829 # +0x9E7B U+6840 # +0x9E7C U+684D # +0x9E7D U+6832 # +0x9E7E U+684E # +0x9E80 U+68B3 # +0x9E81 U+682B # +0x9E82 U+6859 # +0x9E83 U+6863 # +0x9E84 U+6877 # +0x9E85 U+687F # +0x9E86 U+689F # +0x9E87 U+688F # +0x9E88 U+68AD # +0x9E89 U+6894 # +0x9E8A U+689D # +0x9E8B U+689B # +0x9E8C U+6883 # +0x9E8D U+6AAE # +0x9E8E U+68B9 # +0x9E8F U+6874 # +0x9E90 U+68B5 # +0x9E91 U+68A0 # +0x9E92 U+68BA # +0x9E93 U+690F # +0x9E94 U+688D # +0x9E95 U+687E # +0x9E96 U+6901 # +0x9E97 U+68CA # +0x9E98 U+6908 # +0x9E99 U+68D8 # +0x9E9A U+6922 # +0x9E9B U+6926 # +0x9E9C U+68E1 # +0x9E9D U+690C # +0x9E9E U+68CD # +0x9E9F U+68D4 # +0x9EA0 U+68E7 # +0x9EA1 U+68D5 # +0x9EA2 U+6936 # +0x9EA3 U+6912 # +0x9EA4 U+6904 # +0x9EA5 U+68D7 # +0x9EA6 U+68E3 # +0x9EA7 U+6925 # +0x9EA8 U+68F9 # +0x9EA9 U+68E0 # +0x9EAA U+68EF # +0x9EAB U+6928 # +0x9EAC U+692A # +0x9EAD U+691A # +0x9EAE U+6923 # +0x9EAF U+6921 # +0x9EB0 U+68C6 # +0x9EB1 U+6979 # +0x9EB2 U+6977 # +0x9EB3 U+695C # +0x9EB4 U+6978 # +0x9EB5 U+696B # +0x9EB6 U+6954 # +0x9EB7 U+697E # +0x9EB8 U+696E # +0x9EB9 U+6939 # +0x9EBA U+6974 # +0x9EBB U+693D # +0x9EBC U+6959 # +0x9EBD U+6930 # +0x9EBE U+6961 # +0x9EBF U+695E # +0x9EC0 U+695D # +0x9EC1 U+6981 # +0x9EC2 U+696A # +0x9EC3 U+69B2 # +0x9EC4 U+69AE # +0x9EC5 U+69D0 # +0x9EC6 U+69BF # +0x9EC7 U+69C1 # +0x9EC8 U+69D3 # +0x9EC9 U+69BE # +0x9ECA U+69CE # +0x9ECB U+5BE8 # +0x9ECC U+69CA # +0x9ECD U+69DD # +0x9ECE U+69BB # +0x9ECF U+69C3 # +0x9ED0 U+69A7 # +0x9ED1 U+6A2E # +0x9ED2 U+6991 # +0x9ED3 U+69A0 # +0x9ED4 U+699C # +0x9ED5 U+6995 # +0x9ED6 U+69B4 # +0x9ED7 U+69DE # +0x9ED8 U+69E8 # +0x9ED9 U+6A02 # +0x9EDA U+6A1B # +0x9EDB U+69FF # +0x9EDC U+6B0A # +0x9EDD U+69F9 # +0x9EDE U+69F2 # +0x9EDF U+69E7 # +0x9EE0 U+6A05 # +0x9EE1 U+69B1 # +0x9EE2 U+6A1E # +0x9EE3 U+69ED # +0x9EE4 U+6A14 # +0x9EE5 U+69EB # +0x9EE6 U+6A0A # +0x9EE7 U+6A12 # +0x9EE8 U+6AC1 # +0x9EE9 U+6A23 # +0x9EEA U+6A13 # +0x9EEB U+6A44 # +0x9EEC U+6A0C # +0x9EED U+6A72 # +0x9EEE U+6A36 # +0x9EEF U+6A78 # +0x9EF0 U+6A47 # +0x9EF1 U+6A62 # +0x9EF2 U+6A59 # +0x9EF3 U+6A66 # +0x9EF4 U+6A48 # +0x9EF5 U+6A38 # +0x9EF6 U+6A22 # +0x9EF7 U+6A90 # +0x9EF8 U+6A8D # +0x9EF9 U+6AA0 # +0x9EFA U+6A84 # +0x9EFB U+6AA2 # +0x9EFC U+6AA3 # +0x9F40 U+6A97 # +0x9F41 U+8617 # +0x9F42 U+6ABB # +0x9F43 U+6AC3 # +0x9F44 U+6AC2 # +0x9F45 U+6AB8 # +0x9F46 U+6AB3 # +0x9F47 U+6AAC # +0x9F48 U+6ADE # +0x9F49 U+6AD1 # +0x9F4A U+6ADF # +0x9F4B U+6AAA # +0x9F4C U+6ADA # +0x9F4D U+6AEA # +0x9F4E U+6AFB # +0x9F4F U+6B05 # +0x9F50 U+8616 # +0x9F51 U+6AFA # +0x9F52 U+6B12 # +0x9F53 U+6B16 # +0x9F54 U+9B31 # +0x9F55 U+6B1F # +0x9F56 U+6B38 # +0x9F57 U+6B37 # +0x9F58 U+76DC # +0x9F59 U+6B39 # +0x9F5A U+98EE # +0x9F5B U+6B47 # +0x9F5C U+6B43 # +0x9F5D U+6B49 # +0x9F5E U+6B50 # +0x9F5F U+6B59 # +0x9F60 U+6B54 # +0x9F61 U+6B5B # +0x9F62 U+6B5F # +0x9F63 U+6B61 # +0x9F64 U+6B78 # +0x9F65 U+6B79 # +0x9F66 U+6B7F # +0x9F67 U+6B80 # +0x9F68 U+6B84 # +0x9F69 U+6B83 # +0x9F6A U+6B8D # +0x9F6B U+6B98 # +0x9F6C U+6B95 # +0x9F6D U+6B9E # +0x9F6E U+6BA4 # +0x9F6F U+6BAA # +0x9F70 U+6BAB # +0x9F71 U+6BAF # +0x9F72 U+6BB2 # +0x9F73 U+6BB1 # +0x9F74 U+6BB3 # +0x9F75 U+6BB7 # +0x9F76 U+6BBC # +0x9F77 U+6BC6 # +0x9F78 U+6BCB # +0x9F79 U+6BD3 # +0x9F7A U+6BDF # +0x9F7B U+6BEC # +0x9F7C U+6BEB # +0x9F7D U+6BF3 # +0x9F7E U+6BEF # +0x9F80 U+9EBE # +0x9F81 U+6C08 # +0x9F82 U+6C13 # +0x9F83 U+6C14 # +0x9F84 U+6C1B # +0x9F85 U+6C24 # +0x9F86 U+6C23 # +0x9F87 U+6C5E # +0x9F88 U+6C55 # +0x9F89 U+6C62 # +0x9F8A U+6C6A # +0x9F8B U+6C82 # +0x9F8C U+6C8D # +0x9F8D U+6C9A # +0x9F8E U+6C81 # +0x9F8F U+6C9B # +0x9F90 U+6C7E # +0x9F91 U+6C68 # +0x9F92 U+6C73 # +0x9F93 U+6C92 # +0x9F94 U+6C90 # +0x9F95 U+6CC4 # +0x9F96 U+6CF1 # +0x9F97 U+6CD3 # +0x9F98 U+6CBD # +0x9F99 U+6CD7 # +0x9F9A U+6CC5 # +0x9F9B U+6CDD # +0x9F9C U+6CAE # +0x9F9D U+6CB1 # +0x9F9E U+6CBE # +0x9F9F U+6CBA # +0x9FA0 U+6CDB # +0x9FA1 U+6CEF # +0x9FA2 U+6CD9 # +0x9FA3 U+6CEA # +0x9FA4 U+6D1F # +0x9FA5 U+884D # +0x9FA6 U+6D36 # +0x9FA7 U+6D2B # +0x9FA8 U+6D3D # +0x9FA9 U+6D38 # +0x9FAA U+6D19 # +0x9FAB U+6D35 # +0x9FAC U+6D33 # +0x9FAD U+6D12 # +0x9FAE U+6D0C # +0x9FAF U+6D63 # +0x9FB0 U+6D93 # +0x9FB1 U+6D64 # +0x9FB2 U+6D5A # +0x9FB3 U+6D79 # +0x9FB4 U+6D59 # +0x9FB5 U+6D8E # +0x9FB6 U+6D95 # +0x9FB7 U+6FE4 # +0x9FB8 U+6D85 # +0x9FB9 U+6DF9 # +0x9FBA U+6E15 # +0x9FBB U+6E0A # +0x9FBC U+6DB5 # +0x9FBD U+6DC7 # +0x9FBE U+6DE6 # +0x9FBF U+6DB8 # +0x9FC0 U+6DC6 # +0x9FC1 U+6DEC # +0x9FC2 U+6DDE # +0x9FC3 U+6DCC # +0x9FC4 U+6DE8 # +0x9FC5 U+6DD2 # +0x9FC6 U+6DC5 # +0x9FC7 U+6DFA # +0x9FC8 U+6DD9 # +0x9FC9 U+6DE4 # +0x9FCA U+6DD5 # +0x9FCB U+6DEA # +0x9FCC U+6DEE # +0x9FCD U+6E2D # +0x9FCE U+6E6E # +0x9FCF U+6E2E # +0x9FD0 U+6E19 # +0x9FD1 U+6E72 # +0x9FD2 U+6E5F # +0x9FD3 U+6E3E # +0x9FD4 U+6E23 # +0x9FD5 U+6E6B # +0x9FD6 U+6E2B # +0x9FD7 U+6E76 # +0x9FD8 U+6E4D # +0x9FD9 U+6E1F # +0x9FDA U+6E43 # +0x9FDB U+6E3A # +0x9FDC U+6E4E # +0x9FDD U+6E24 # +0x9FDE U+6EFF # +0x9FDF U+6E1D # +0x9FE0 U+6E38 # +0x9FE1 U+6E82 # +0x9FE2 U+6EAA # +0x9FE3 U+6E98 # +0x9FE4 U+6EC9 # +0x9FE5 U+6EB7 # +0x9FE6 U+6ED3 # +0x9FE7 U+6EBD # +0x9FE8 U+6EAF # +0x9FE9 U+6EC4 # +0x9FEA U+6EB2 # +0x9FEB U+6ED4 # +0x9FEC U+6ED5 # +0x9FED U+6E8F # +0x9FEE U+6EA5 # +0x9FEF U+6EC2 # +0x9FF0 U+6E9F # +0x9FF1 U+6F41 # +0x9FF2 U+6F11 # +0x9FF3 U+704C # +0x9FF4 U+6EEC # +0x9FF5 U+6EF8 # +0x9FF6 U+6EFE # +0x9FF7 U+6F3F # +0x9FF8 U+6EF2 # +0x9FF9 U+6F31 # +0x9FFA U+6EEF # +0x9FFB U+6F32 # +0x9FFC U+6ECC # +0xE040 U+6F3E # +0xE041 U+6F13 # +0xE042 U+6EF7 # +0xE043 U+6F86 # +0xE044 U+6F7A # +0xE045 U+6F78 # +0xE046 U+6F81 # +0xE047 U+6F80 # +0xE048 U+6F6F # +0xE049 U+6F5B # +0xE04A U+6FF3 # +0xE04B U+6F6D # +0xE04C U+6F82 # +0xE04D U+6F7C # +0xE04E U+6F58 # +0xE04F U+6F8E # +0xE050 U+6F91 # +0xE051 U+6FC2 # +0xE052 U+6F66 # +0xE053 U+6FB3 # +0xE054 U+6FA3 # +0xE055 U+6FA1 # +0xE056 U+6FA4 # +0xE057 U+6FB9 # +0xE058 U+6FC6 # +0xE059 U+6FAA # +0xE05A U+6FDF # +0xE05B U+6FD5 # +0xE05C U+6FEC # +0xE05D U+6FD4 # +0xE05E U+6FD8 # +0xE05F U+6FF1 # +0xE060 U+6FEE # +0xE061 U+6FDB # +0xE062 U+7009 # +0xE063 U+700B # +0xE064 U+6FFA # +0xE065 U+7011 # +0xE066 U+7001 # +0xE067 U+700F # +0xE068 U+6FFE # +0xE069 U+701B # +0xE06A U+701A # +0xE06B U+6F74 # +0xE06C U+701D # +0xE06D U+7018 # +0xE06E U+701F # +0xE06F U+7030 # +0xE070 U+703E # +0xE071 U+7032 # +0xE072 U+7051 # +0xE073 U+7063 # +0xE074 U+7099 # +0xE075 U+7092 # +0xE076 U+70AF # +0xE077 U+70F1 # +0xE078 U+70AC # +0xE079 U+70B8 # +0xE07A U+70B3 # +0xE07B U+70AE # +0xE07C U+70DF # +0xE07D U+70CB # +0xE07E U+70DD # +0xE080 U+70D9 # +0xE081 U+7109 # +0xE082 U+70FD # +0xE083 U+711C # +0xE084 U+7119 # +0xE085 U+7165 # +0xE086 U+7155 # +0xE087 U+7188 # +0xE088 U+7166 # +0xE089 U+7162 # +0xE08A U+714C # +0xE08B U+7156 # +0xE08C U+716C # +0xE08D U+718F # +0xE08E U+71FB # +0xE08F U+7184 # +0xE090 U+7195 # +0xE091 U+71A8 # +0xE092 U+71AC # +0xE093 U+71D7 # +0xE094 U+71B9 # +0xE095 U+71BE # +0xE096 U+71D2 # +0xE097 U+71C9 # +0xE098 U+71D4 # +0xE099 U+71CE # +0xE09A U+71E0 # +0xE09B U+71EC # +0xE09C U+71E7 # +0xE09D U+71F5 # +0xE09E U+71FC # +0xE09F U+71F9 # +0xE0A0 U+71FF # +0xE0A1 U+720D # +0xE0A2 U+7210 # +0xE0A3 U+721B # +0xE0A4 U+7228 # +0xE0A5 U+722D # +0xE0A6 U+722C # +0xE0A7 U+7230 # +0xE0A8 U+7232 # +0xE0A9 U+723B # +0xE0AA U+723C # +0xE0AB U+723F # +0xE0AC U+7240 # +0xE0AD U+7246 # +0xE0AE U+724B # +0xE0AF U+7258 # +0xE0B0 U+7274 # +0xE0B1 U+727E # +0xE0B2 U+7282 # +0xE0B3 U+7281 # +0xE0B4 U+7287 # +0xE0B5 U+7292 # +0xE0B6 U+7296 # +0xE0B7 U+72A2 # +0xE0B8 U+72A7 # +0xE0B9 U+72B9 # +0xE0BA U+72B2 # +0xE0BB U+72C3 # +0xE0BC U+72C6 # +0xE0BD U+72C4 # +0xE0BE U+72CE # +0xE0BF U+72D2 # +0xE0C0 U+72E2 # +0xE0C1 U+72E0 # +0xE0C2 U+72E1 # +0xE0C3 U+72F9 # +0xE0C4 U+72F7 # +0xE0C5 U+500F # +0xE0C6 U+7317 # +0xE0C7 U+730A # +0xE0C8 U+731C # +0xE0C9 U+7316 # +0xE0CA U+731D # +0xE0CB U+7334 # +0xE0CC U+732F # +0xE0CD U+7329 # +0xE0CE U+7325 # +0xE0CF U+733E # +0xE0D0 U+734E # +0xE0D1 U+734F # +0xE0D2 U+9ED8 # +0xE0D3 U+7357 # +0xE0D4 U+736A # +0xE0D5 U+7368 # +0xE0D6 U+7370 # +0xE0D7 U+7378 # +0xE0D8 U+7375 # +0xE0D9 U+737B # +0xE0DA U+737A # +0xE0DB U+73C8 # +0xE0DC U+73B3 # +0xE0DD U+73CE # +0xE0DE U+73BB # +0xE0DF U+73C0 # +0xE0E0 U+73E5 # +0xE0E1 U+73EE # +0xE0E2 U+73DE # +0xE0E3 U+74A2 # +0xE0E4 U+7405 # +0xE0E5 U+746F # +0xE0E6 U+7425 # +0xE0E7 U+73F8 # +0xE0E8 U+7432 # +0xE0E9 U+743A # +0xE0EA U+7455 # +0xE0EB U+743F # +0xE0EC U+745F # +0xE0ED U+7459 # +0xE0EE U+7441 # +0xE0EF U+745C # +0xE0F0 U+7469 # +0xE0F1 U+7470 # +0xE0F2 U+7463 # +0xE0F3 U+746A # +0xE0F4 U+7476 # +0xE0F5 U+747E # +0xE0F6 U+748B # +0xE0F7 U+749E # +0xE0F8 U+74A7 # +0xE0F9 U+74CA # +0xE0FA U+74CF # +0xE0FB U+74D4 # +0xE0FC U+73F1 # +0xE140 U+74E0 # +0xE141 U+74E3 # +0xE142 U+74E7 # +0xE143 U+74E9 # +0xE144 U+74EE # +0xE145 U+74F2 # +0xE146 U+74F0 # +0xE147 U+74F1 # +0xE148 U+74F8 # +0xE149 U+74F7 # +0xE14A U+7504 # +0xE14B U+7503 # +0xE14C U+7505 # +0xE14D U+750C # +0xE14E U+750E # +0xE14F U+750D # +0xE150 U+7515 # +0xE151 U+7513 # +0xE152 U+751E # +0xE153 U+7526 # +0xE154 U+752C # +0xE155 U+753C # +0xE156 U+7544 # +0xE157 U+754D # +0xE158 U+754A # +0xE159 U+7549 # +0xE15A U+755B # +0xE15B U+7546 # +0xE15C U+755A # +0xE15D U+7569 # +0xE15E U+7564 # +0xE15F U+7567 # +0xE160 U+756B # +0xE161 U+756D # +0xE162 U+7578 # +0xE163 U+7576 # +0xE164 U+7586 # +0xE165 U+7587 # +0xE166 U+7574 # +0xE167 U+758A # +0xE168 U+7589 # +0xE169 U+7582 # +0xE16A U+7594 # +0xE16B U+759A # +0xE16C U+759D # +0xE16D U+75A5 # +0xE16E U+75A3 # +0xE16F U+75C2 # +0xE170 U+75B3 # +0xE171 U+75C3 # +0xE172 U+75B5 # +0xE173 U+75BD # +0xE174 U+75B8 # +0xE175 U+75BC # +0xE176 U+75B1 # +0xE177 U+75CD # +0xE178 U+75CA # +0xE179 U+75D2 # +0xE17A U+75D9 # +0xE17B U+75E3 # +0xE17C U+75DE # +0xE17D U+75FE # +0xE17E U+75FF # +0xE180 U+75FC # +0xE181 U+7601 # +0xE182 U+75F0 # +0xE183 U+75FA # +0xE184 U+75F2 # +0xE185 U+75F3 # +0xE186 U+760B # +0xE187 U+760D # +0xE188 U+7609 # +0xE189 U+761F # +0xE18A U+7627 # +0xE18B U+7620 # +0xE18C U+7621 # +0xE18D U+7622 # +0xE18E U+7624 # +0xE18F U+7634 # +0xE190 U+7630 # +0xE191 U+763B # +0xE192 U+7647 # +0xE193 U+7648 # +0xE194 U+7646 # +0xE195 U+765C # +0xE196 U+7658 # +0xE197 U+7661 # +0xE198 U+7662 # +0xE199 U+7668 # +0xE19A U+7669 # +0xE19B U+766A # +0xE19C U+7667 # +0xE19D U+766C # +0xE19E U+7670 # +0xE19F U+7672 # +0xE1A0 U+7676 # +0xE1A1 U+7678 # +0xE1A2 U+767C # +0xE1A3 U+7680 # +0xE1A4 U+7683 # +0xE1A5 U+7688 # +0xE1A6 U+768B # +0xE1A7 U+768E # +0xE1A8 U+7696 # +0xE1A9 U+7693 # +0xE1AA U+7699 # +0xE1AB U+769A # +0xE1AC U+76B0 # +0xE1AD U+76B4 # +0xE1AE U+76B8 # +0xE1AF U+76B9 # +0xE1B0 U+76BA # +0xE1B1 U+76C2 # +0xE1B2 U+76CD # +0xE1B3 U+76D6 # +0xE1B4 U+76D2 # +0xE1B5 U+76DE # +0xE1B6 U+76E1 # +0xE1B7 U+76E5 # +0xE1B8 U+76E7 # +0xE1B9 U+76EA # +0xE1BA U+862F # +0xE1BB U+76FB # +0xE1BC U+7708 # +0xE1BD U+7707 # +0xE1BE U+7704 # +0xE1BF U+7729 # +0xE1C0 U+7724 # +0xE1C1 U+771E # +0xE1C2 U+7725 # +0xE1C3 U+7726 # +0xE1C4 U+771B # +0xE1C5 U+7737 # +0xE1C6 U+7738 # +0xE1C7 U+7747 # +0xE1C8 U+775A # +0xE1C9 U+7768 # +0xE1CA U+776B # +0xE1CB U+775B # +0xE1CC U+7765 # +0xE1CD U+777F # +0xE1CE U+777E # +0xE1CF U+7779 # +0xE1D0 U+778E # +0xE1D1 U+778B # +0xE1D2 U+7791 # +0xE1D3 U+77A0 # +0xE1D4 U+779E # +0xE1D5 U+77B0 # +0xE1D6 U+77B6 # +0xE1D7 U+77B9 # +0xE1D8 U+77BF # +0xE1D9 U+77BC # +0xE1DA U+77BD # +0xE1DB U+77BB # +0xE1DC U+77C7 # +0xE1DD U+77CD # +0xE1DE U+77D7 # +0xE1DF U+77DA # +0xE1E0 U+77DC # +0xE1E1 U+77E3 # +0xE1E2 U+77EE # +0xE1E3 U+77FC # +0xE1E4 U+780C # +0xE1E5 U+7812 # +0xE1E6 U+7926 # +0xE1E7 U+7820 # +0xE1E8 U+792A # +0xE1E9 U+7845 # +0xE1EA U+788E # +0xE1EB U+7874 # +0xE1EC U+7886 # +0xE1ED U+787C # +0xE1EE U+789A # +0xE1EF U+788C # +0xE1F0 U+78A3 # +0xE1F1 U+78B5 # +0xE1F2 U+78AA # +0xE1F3 U+78AF # +0xE1F4 U+78D1 # +0xE1F5 U+78C6 # +0xE1F6 U+78CB # +0xE1F7 U+78D4 # +0xE1F8 U+78BE # +0xE1F9 U+78BC # +0xE1FA U+78C5 # +0xE1FB U+78CA # +0xE1FC U+78EC # +0xE240 U+78E7 # +0xE241 U+78DA # +0xE242 U+78FD # +0xE243 U+78F4 # +0xE244 U+7907 # +0xE245 U+7912 # +0xE246 U+7911 # +0xE247 U+7919 # +0xE248 U+792C # +0xE249 U+792B # +0xE24A U+7940 # +0xE24B U+7960 # +0xE24C U+7957 # +0xE24D U+795F # +0xE24E U+795A # +0xE24F U+7955 # +0xE250 U+7953 # +0xE251 U+797A # +0xE252 U+797F # +0xE253 U+798A # +0xE254 U+799D # +0xE255 U+79A7 # +0xE256 U+9F4B # +0xE257 U+79AA # +0xE258 U+79AE # +0xE259 U+79B3 # +0xE25A U+79B9 # +0xE25B U+79BA # +0xE25C U+79C9 # +0xE25D U+79D5 # +0xE25E U+79E7 # +0xE25F U+79EC # +0xE260 U+79E1 # +0xE261 U+79E3 # +0xE262 U+7A08 # +0xE263 U+7A0D # +0xE264 U+7A18 # +0xE265 U+7A19 # +0xE266 U+7A20 # +0xE267 U+7A1F # +0xE268 U+7980 # +0xE269 U+7A31 # +0xE26A U+7A3B # +0xE26B U+7A3E # +0xE26C U+7A37 # +0xE26D U+7A43 # +0xE26E U+7A57 # +0xE26F U+7A49 # +0xE270 U+7A61 # +0xE271 U+7A62 # +0xE272 U+7A69 # +0xE273 U+9F9D # +0xE274 U+7A70 # +0xE275 U+7A79 # +0xE276 U+7A7D # +0xE277 U+7A88 # +0xE278 U+7A97 # +0xE279 U+7A95 # +0xE27A U+7A98 # +0xE27B U+7A96 # +0xE27C U+7AA9 # +0xE27D U+7AC8 # +0xE27E U+7AB0 # +0xE280 U+7AB6 # +0xE281 U+7AC5 # +0xE282 U+7AC4 # +0xE283 U+7ABF # +0xE284 U+9083 # +0xE285 U+7AC7 # +0xE286 U+7ACA # +0xE287 U+7ACD # +0xE288 U+7ACF # +0xE289 U+7AD5 # +0xE28A U+7AD3 # +0xE28B U+7AD9 # +0xE28C U+7ADA # +0xE28D U+7ADD # +0xE28E U+7AE1 # +0xE28F U+7AE2 # +0xE290 U+7AE6 # +0xE291 U+7AED # +0xE292 U+7AF0 # +0xE293 U+7B02 # +0xE294 U+7B0F # +0xE295 U+7B0A # +0xE296 U+7B06 # +0xE297 U+7B33 # +0xE298 U+7B18 # +0xE299 U+7B19 # +0xE29A U+7B1E # +0xE29B U+7B35 # +0xE29C U+7B28 # +0xE29D U+7B36 # +0xE29E U+7B50 # +0xE29F U+7B7A # +0xE2A0 U+7B04 # +0xE2A1 U+7B4D # +0xE2A2 U+7B0B # +0xE2A3 U+7B4C # +0xE2A4 U+7B45 # +0xE2A5 U+7B75 # +0xE2A6 U+7B65 # +0xE2A7 U+7B74 # +0xE2A8 U+7B67 # +0xE2A9 U+7B70 # +0xE2AA U+7B71 # +0xE2AB U+7B6C # +0xE2AC U+7B6E # +0xE2AD U+7B9D # +0xE2AE U+7B98 # +0xE2AF U+7B9F # +0xE2B0 U+7B8D # +0xE2B1 U+7B9C # +0xE2B2 U+7B9A # +0xE2B3 U+7B8B # +0xE2B4 U+7B92 # +0xE2B5 U+7B8F # +0xE2B6 U+7B5D # +0xE2B7 U+7B99 # +0xE2B8 U+7BCB # +0xE2B9 U+7BC1 # +0xE2BA U+7BCC # +0xE2BB U+7BCF # +0xE2BC U+7BB4 # +0xE2BD U+7BC6 # +0xE2BE U+7BDD # +0xE2BF U+7BE9 # +0xE2C0 U+7C11 # +0xE2C1 U+7C14 # +0xE2C2 U+7BE6 # +0xE2C3 U+7BE5 # +0xE2C4 U+7C60 # +0xE2C5 U+7C00 # +0xE2C6 U+7C07 # +0xE2C7 U+7C13 # +0xE2C8 U+7BF3 # +0xE2C9 U+7BF7 # +0xE2CA U+7C17 # +0xE2CB U+7C0D # +0xE2CC U+7BF6 # +0xE2CD U+7C23 # +0xE2CE U+7C27 # +0xE2CF U+7C2A # +0xE2D0 U+7C1F # +0xE2D1 U+7C37 # +0xE2D2 U+7C2B # +0xE2D3 U+7C3D # +0xE2D4 U+7C4C # +0xE2D5 U+7C43 # +0xE2D6 U+7C54 # +0xE2D7 U+7C4F # +0xE2D8 U+7C40 # +0xE2D9 U+7C50 # +0xE2DA U+7C58 # +0xE2DB U+7C5F # +0xE2DC U+7C64 # +0xE2DD U+7C56 # +0xE2DE U+7C65 # +0xE2DF U+7C6C # +0xE2E0 U+7C75 # +0xE2E1 U+7C83 # +0xE2E2 U+7C90 # +0xE2E3 U+7CA4 # +0xE2E4 U+7CAD # +0xE2E5 U+7CA2 # +0xE2E6 U+7CAB # +0xE2E7 U+7CA1 # +0xE2E8 U+7CA8 # +0xE2E9 U+7CB3 # +0xE2EA U+7CB2 # +0xE2EB U+7CB1 # +0xE2EC U+7CAE # +0xE2ED U+7CB9 # +0xE2EE U+7CBD # +0xE2EF U+7CC0 # +0xE2F0 U+7CC5 # +0xE2F1 U+7CC2 # +0xE2F2 U+7CD8 # +0xE2F3 U+7CD2 # +0xE2F4 U+7CDC # +0xE2F5 U+7CE2 # +0xE2F6 U+9B3B # +0xE2F7 U+7CEF # +0xE2F8 U+7CF2 # +0xE2F9 U+7CF4 # +0xE2FA U+7CF6 # +0xE2FB U+7CFA # +0xE2FC U+7D06 # +0xE340 U+7D02 # +0xE341 U+7D1C # +0xE342 U+7D15 # +0xE343 U+7D0A # +0xE344 U+7D45 # +0xE345 U+7D4B # +0xE346 U+7D2E # +0xE347 U+7D32 # +0xE348 U+7D3F # +0xE349 U+7D35 # +0xE34A U+7D46 # +0xE34B U+7D73 # +0xE34C U+7D56 # +0xE34D U+7D4E # +0xE34E U+7D72 # +0xE34F U+7D68 # +0xE350 U+7D6E # +0xE351 U+7D4F # +0xE352 U+7D63 # +0xE353 U+7D93 # +0xE354 U+7D89 # +0xE355 U+7D5B # +0xE356 U+7D8F # +0xE357 U+7D7D # +0xE358 U+7D9B # +0xE359 U+7DBA # +0xE35A U+7DAE # +0xE35B U+7DA3 # +0xE35C U+7DB5 # +0xE35D U+7DC7 # +0xE35E U+7DBD # +0xE35F U+7DAB # +0xE360 U+7E3D # +0xE361 U+7DA2 # +0xE362 U+7DAF # +0xE363 U+7DDC # +0xE364 U+7DB8 # +0xE365 U+7D9F # +0xE366 U+7DB0 # +0xE367 U+7DD8 # +0xE368 U+7DDD # +0xE369 U+7DE4 # +0xE36A U+7DDE # +0xE36B U+7DFB # +0xE36C U+7DF2 # +0xE36D U+7DE1 # +0xE36E U+7E05 # +0xE36F U+7E0A # +0xE370 U+7E23 # +0xE371 U+7E21 # +0xE372 U+7E12 # +0xE373 U+7E31 # +0xE374 U+7E1F # +0xE375 U+7E09 # +0xE376 U+7E0B # +0xE377 U+7E22 # +0xE378 U+7E46 # +0xE379 U+7E66 # +0xE37A U+7E3B # +0xE37B U+7E35 # +0xE37C U+7E39 # +0xE37D U+7E43 # +0xE37E U+7E37 # +0xE380 U+7E32 # +0xE381 U+7E3A # +0xE382 U+7E67 # +0xE383 U+7E5D # +0xE384 U+7E56 # +0xE385 U+7E5E # +0xE386 U+7E59 # +0xE387 U+7E5A # +0xE388 U+7E79 # +0xE389 U+7E6A # +0xE38A U+7E69 # +0xE38B U+7E7C # +0xE38C U+7E7B # +0xE38D U+7E83 # +0xE38E U+7DD5 # +0xE38F U+7E7D # +0xE390 U+8FAE # +0xE391 U+7E7F # +0xE392 U+7E88 # +0xE393 U+7E89 # +0xE394 U+7E8C # +0xE395 U+7E92 # +0xE396 U+7E90 # +0xE397 U+7E93 # +0xE398 U+7E94 # +0xE399 U+7E96 # +0xE39A U+7E8E # +0xE39B U+7E9B # +0xE39C U+7E9C # +0xE39D U+7F38 # +0xE39E U+7F3A # +0xE39F U+7F45 # +0xE3A0 U+7F4C # +0xE3A1 U+7F4D # +0xE3A2 U+7F4E # +0xE3A3 U+7F50 # +0xE3A4 U+7F51 # +0xE3A5 U+7F55 # +0xE3A6 U+7F54 # +0xE3A7 U+7F58 # +0xE3A8 U+7F5F # +0xE3A9 U+7F60 # +0xE3AA U+7F68 # +0xE3AB U+7F69 # +0xE3AC U+7F67 # +0xE3AD U+7F78 # +0xE3AE U+7F82 # +0xE3AF U+7F86 # +0xE3B0 U+7F83 # +0xE3B1 U+7F88 # +0xE3B2 U+7F87 # +0xE3B3 U+7F8C # +0xE3B4 U+7F94 # +0xE3B5 U+7F9E # +0xE3B6 U+7F9D # +0xE3B7 U+7F9A # +0xE3B8 U+7FA3 # +0xE3B9 U+7FAF # +0xE3BA U+7FB2 # +0xE3BB U+7FB9 # +0xE3BC U+7FAE # +0xE3BD U+7FB6 # +0xE3BE U+7FB8 # +0xE3BF U+8B71 # +0xE3C0 U+7FC5 # +0xE3C1 U+7FC6 # +0xE3C2 U+7FCA # +0xE3C3 U+7FD5 # +0xE3C4 U+7FD4 # +0xE3C5 U+7FE1 # +0xE3C6 U+7FE6 # +0xE3C7 U+7FE9 # +0xE3C8 U+7FF3 # +0xE3C9 U+7FF9 # +0xE3CA U+98DC # +0xE3CB U+8006 # +0xE3CC U+8004 # +0xE3CD U+800B # +0xE3CE U+8012 # +0xE3CF U+8018 # +0xE3D0 U+8019 # +0xE3D1 U+801C # +0xE3D2 U+8021 # +0xE3D3 U+8028 # +0xE3D4 U+803F # +0xE3D5 U+803B # +0xE3D6 U+804A # +0xE3D7 U+8046 # +0xE3D8 U+8052 # +0xE3D9 U+8058 # +0xE3DA U+805A # +0xE3DB U+805F # +0xE3DC U+8062 # +0xE3DD U+8068 # +0xE3DE U+8073 # +0xE3DF U+8072 # +0xE3E0 U+8070 # +0xE3E1 U+8076 # +0xE3E2 U+8079 # +0xE3E3 U+807D # +0xE3E4 U+807F # +0xE3E5 U+8084 # +0xE3E6 U+8086 # +0xE3E7 U+8085 # +0xE3E8 U+809B # +0xE3E9 U+8093 # +0xE3EA U+809A # +0xE3EB U+80AD # +0xE3EC U+5190 # +0xE3ED U+80AC # +0xE3EE U+80DB # +0xE3EF U+80E5 # +0xE3F0 U+80D9 # +0xE3F1 U+80DD # +0xE3F2 U+80C4 # +0xE3F3 U+80DA # +0xE3F4 U+80D6 # +0xE3F5 U+8109 # +0xE3F6 U+80EF # +0xE3F7 U+80F1 # +0xE3F8 U+811B # +0xE3F9 U+8129 # +0xE3FA U+8123 # +0xE3FB U+812F # +0xE3FC U+814B # +0xE440 U+968B # +0xE441 U+8146 # +0xE442 U+813E # +0xE443 U+8153 # +0xE444 U+8151 # +0xE445 U+80FC # +0xE446 U+8171 # +0xE447 U+816E # +0xE448 U+8165 # +0xE449 U+8166 # +0xE44A U+8174 # +0xE44B U+8183 # +0xE44C U+8188 # +0xE44D U+818A # +0xE44E U+8180 # +0xE44F U+8182 # +0xE450 U+81A0 # +0xE451 U+8195 # +0xE452 U+81A4 # +0xE453 U+81A3 # +0xE454 U+815F # +0xE455 U+8193 # +0xE456 U+81A9 # +0xE457 U+81B0 # +0xE458 U+81B5 # +0xE459 U+81BE # +0xE45A U+81B8 # +0xE45B U+81BD # +0xE45C U+81C0 # +0xE45D U+81C2 # +0xE45E U+81BA # +0xE45F U+81C9 # +0xE460 U+81CD # +0xE461 U+81D1 # +0xE462 U+81D9 # +0xE463 U+81D8 # +0xE464 U+81C8 # +0xE465 U+81DA # +0xE466 U+81DF # +0xE467 U+81E0 # +0xE468 U+81E7 # +0xE469 U+81FA # +0xE46A U+81FB # +0xE46B U+81FE # +0xE46C U+8201 # +0xE46D U+8202 # +0xE46E U+8205 # +0xE46F U+8207 # +0xE470 U+820A # +0xE471 U+820D # +0xE472 U+8210 # +0xE473 U+8216 # +0xE474 U+8229 # +0xE475 U+822B # +0xE476 U+8238 # +0xE477 U+8233 # +0xE478 U+8240 # +0xE479 U+8259 # +0xE47A U+8258 # +0xE47B U+825D # +0xE47C U+825A # +0xE47D U+825F # +0xE47E U+8264 # +0xE480 U+8262 # +0xE481 U+8268 # +0xE482 U+826A # +0xE483 U+826B # +0xE484 U+822E # +0xE485 U+8271 # +0xE486 U+8277 # +0xE487 U+8278 # +0xE488 U+827E # +0xE489 U+828D # +0xE48A U+8292 # +0xE48B U+82AB # +0xE48C U+829F # +0xE48D U+82BB # +0xE48E U+82AC # +0xE48F U+82E1 # +0xE490 U+82E3 # +0xE491 U+82DF # +0xE492 U+82D2 # +0xE493 U+82F4 # +0xE494 U+82F3 # +0xE495 U+82FA # +0xE496 U+8393 # +0xE497 U+8303 # +0xE498 U+82FB # +0xE499 U+82F9 # +0xE49A U+82DE # +0xE49B U+8306 # +0xE49C U+82DC # +0xE49D U+8309 # +0xE49E U+82D9 # +0xE49F U+8335 # +0xE4A0 U+8334 # +0xE4A1 U+8316 # +0xE4A2 U+8332 # +0xE4A3 U+8331 # +0xE4A4 U+8340 # +0xE4A5 U+8339 # +0xE4A6 U+8350 # +0xE4A7 U+8345 # +0xE4A8 U+832F # +0xE4A9 U+832B # +0xE4AA U+8317 # +0xE4AB U+8318 # +0xE4AC U+8385 # +0xE4AD U+839A # +0xE4AE U+83AA # +0xE4AF U+839F # +0xE4B0 U+83A2 # +0xE4B1 U+8396 # +0xE4B2 U+8323 # +0xE4B3 U+838E # +0xE4B4 U+8387 # +0xE4B5 U+838A # +0xE4B6 U+837C # +0xE4B7 U+83B5 # +0xE4B8 U+8373 # +0xE4B9 U+8375 # +0xE4BA U+83A0 # +0xE4BB U+8389 # +0xE4BC U+83A8 # +0xE4BD U+83F4 # +0xE4BE U+8413 # +0xE4BF U+83EB # +0xE4C0 U+83CE # +0xE4C1 U+83FD # +0xE4C2 U+8403 # +0xE4C3 U+83D8 # +0xE4C4 U+840B # +0xE4C5 U+83C1 # +0xE4C6 U+83F7 # +0xE4C7 U+8407 # +0xE4C8 U+83E0 # +0xE4C9 U+83F2 # +0xE4CA U+840D # +0xE4CB U+8422 # +0xE4CC U+8420 # +0xE4CD U+83BD # +0xE4CE U+8438 # +0xE4CF U+8506 # +0xE4D0 U+83FB # +0xE4D1 U+846D # +0xE4D2 U+842A # +0xE4D3 U+843C # +0xE4D4 U+855A # +0xE4D5 U+8484 # +0xE4D6 U+8477 # +0xE4D7 U+846B # +0xE4D8 U+84AD # +0xE4D9 U+846E # +0xE4DA U+8482 # +0xE4DB U+8469 # +0xE4DC U+8446 # +0xE4DD U+842C # +0xE4DE U+846F # +0xE4DF U+8479 # +0xE4E0 U+8435 # +0xE4E1 U+84CA # +0xE4E2 U+8462 # +0xE4E3 U+84B9 # +0xE4E4 U+84BF # +0xE4E5 U+849F # +0xE4E6 U+84D9 # +0xE4E7 U+84CD # +0xE4E8 U+84BB # +0xE4E9 U+84DA # +0xE4EA U+84D0 # +0xE4EB U+84C1 # +0xE4EC U+84C6 # +0xE4ED U+84D6 # +0xE4EE U+84A1 # +0xE4EF U+8521 # +0xE4F0 U+84FF # +0xE4F1 U+84F4 # +0xE4F2 U+8517 # +0xE4F3 U+8518 # +0xE4F4 U+852C # +0xE4F5 U+851F # +0xE4F6 U+8515 # +0xE4F7 U+8514 # +0xE4F8 U+84FC # +0xE4F9 U+8540 # +0xE4FA U+8563 # +0xE4FB U+8558 # +0xE4FC U+8548 # +0xE540 U+8541 # +0xE541 U+8602 # +0xE542 U+854B # +0xE543 U+8555 # +0xE544 U+8580 # +0xE545 U+85A4 # +0xE546 U+8588 # +0xE547 U+8591 # +0xE548 U+858A # +0xE549 U+85A8 # +0xE54A U+856D # +0xE54B U+8594 # +0xE54C U+859B # +0xE54D U+85EA # +0xE54E U+8587 # +0xE54F U+859C # +0xE550 U+8577 # +0xE551 U+857E # +0xE552 U+8590 # +0xE553 U+85C9 # +0xE554 U+85BA # +0xE555 U+85CF # +0xE556 U+85B9 # +0xE557 U+85D0 # +0xE558 U+85D5 # +0xE559 U+85DD # +0xE55A U+85E5 # +0xE55B U+85DC # +0xE55C U+85F9 # +0xE55D U+860A # +0xE55E U+8613 # +0xE55F U+860B # +0xE560 U+85FE # +0xE561 U+85FA # +0xE562 U+8606 # +0xE563 U+8622 # +0xE564 U+861A # +0xE565 U+8630 # +0xE566 U+863F # +0xE567 U+864D # +0xE568 U+4E55 # +0xE569 U+8654 # +0xE56A U+865F # +0xE56B U+8667 # +0xE56C U+8671 # +0xE56D U+8693 # +0xE56E U+86A3 # +0xE56F U+86A9 # +0xE570 U+86AA # +0xE571 U+868B # +0xE572 U+868C # +0xE573 U+86B6 # +0xE574 U+86AF # +0xE575 U+86C4 # +0xE576 U+86C6 # +0xE577 U+86B0 # +0xE578 U+86C9 # +0xE579 U+8823 # +0xE57A U+86AB # +0xE57B U+86D4 # +0xE57C U+86DE # +0xE57D U+86E9 # +0xE57E U+86EC # +0xE580 U+86DF # +0xE581 U+86DB # +0xE582 U+86EF # +0xE583 U+8712 # +0xE584 U+8706 # +0xE585 U+8708 # +0xE586 U+8700 # +0xE587 U+8703 # +0xE588 U+86FB # +0xE589 U+8711 # +0xE58A U+8709 # +0xE58B U+870D # +0xE58C U+86F9 # +0xE58D U+870A # +0xE58E U+8734 # +0xE58F U+873F # +0xE590 U+8737 # +0xE591 U+873B # +0xE592 U+8725 # +0xE593 U+8729 # +0xE594 U+871A # +0xE595 U+8760 # +0xE596 U+875F # +0xE597 U+8778 # +0xE598 U+874C # +0xE599 U+874E # +0xE59A U+8774 # +0xE59B U+8757 # +0xE59C U+8768 # +0xE59D U+876E # +0xE59E U+8759 # +0xE59F U+8753 # +0xE5A0 U+8763 # +0xE5A1 U+876A # +0xE5A2 U+8805 # +0xE5A3 U+87A2 # +0xE5A4 U+879F # +0xE5A5 U+8782 # +0xE5A6 U+87AF # +0xE5A7 U+87CB # +0xE5A8 U+87BD # +0xE5A9 U+87C0 # +0xE5AA U+87D0 # +0xE5AB U+96D6 # +0xE5AC U+87AB # +0xE5AD U+87C4 # +0xE5AE U+87B3 # +0xE5AF U+87C7 # +0xE5B0 U+87C6 # +0xE5B1 U+87BB # +0xE5B2 U+87EF # +0xE5B3 U+87F2 # +0xE5B4 U+87E0 # +0xE5B5 U+880F # +0xE5B6 U+880D # +0xE5B7 U+87FE # +0xE5B8 U+87F6 # +0xE5B9 U+87F7 # +0xE5BA U+880E # +0xE5BB U+87D2 # +0xE5BC U+8811 # +0xE5BD U+8816 # +0xE5BE U+8815 # +0xE5BF U+8822 # +0xE5C0 U+8821 # +0xE5C1 U+8831 # +0xE5C2 U+8836 # +0xE5C3 U+8839 # +0xE5C4 U+8827 # +0xE5C5 U+883B # +0xE5C6 U+8844 # +0xE5C7 U+8842 # +0xE5C8 U+8852 # +0xE5C9 U+8859 # +0xE5CA U+885E # +0xE5CB U+8862 # +0xE5CC U+886B # +0xE5CD U+8881 # +0xE5CE U+887E # +0xE5CF U+889E # +0xE5D0 U+8875 # +0xE5D1 U+887D # +0xE5D2 U+88B5 # +0xE5D3 U+8872 # +0xE5D4 U+8882 # +0xE5D5 U+8897 # +0xE5D6 U+8892 # +0xE5D7 U+88AE # +0xE5D8 U+8899 # +0xE5D9 U+88A2 # +0xE5DA U+888D # +0xE5DB U+88A4 # +0xE5DC U+88B0 # +0xE5DD U+88BF # +0xE5DE U+88B1 # +0xE5DF U+88C3 # +0xE5E0 U+88C4 # +0xE5E1 U+88D4 # +0xE5E2 U+88D8 # +0xE5E3 U+88D9 # +0xE5E4 U+88DD # +0xE5E5 U+88F9 # +0xE5E6 U+8902 # +0xE5E7 U+88FC # +0xE5E8 U+88F4 # +0xE5E9 U+88E8 # +0xE5EA U+88F2 # +0xE5EB U+8904 # +0xE5EC U+890C # +0xE5ED U+890A # +0xE5EE U+8913 # +0xE5EF U+8943 # +0xE5F0 U+891E # +0xE5F1 U+8925 # +0xE5F2 U+892A # +0xE5F3 U+892B # +0xE5F4 U+8941 # +0xE5F5 U+8944 # +0xE5F6 U+893B # +0xE5F7 U+8936 # +0xE5F8 U+8938 # +0xE5F9 U+894C # +0xE5FA U+891D # +0xE5FB U+8960 # +0xE5FC U+895E # +0xE640 U+8966 # +0xE641 U+8964 # +0xE642 U+896D # +0xE643 U+896A # +0xE644 U+896F # +0xE645 U+8974 # +0xE646 U+8977 # +0xE647 U+897E # +0xE648 U+8983 # +0xE649 U+8988 # +0xE64A U+898A # +0xE64B U+8993 # +0xE64C U+8998 # +0xE64D U+89A1 # +0xE64E U+89A9 # +0xE64F U+89A6 # +0xE650 U+89AC # +0xE651 U+89AF # +0xE652 U+89B2 # +0xE653 U+89BA # +0xE654 U+89BD # +0xE655 U+89BF # +0xE656 U+89C0 # +0xE657 U+89DA # +0xE658 U+89DC # +0xE659 U+89DD # +0xE65A U+89E7 # +0xE65B U+89F4 # +0xE65C U+89F8 # +0xE65D U+8A03 # +0xE65E U+8A16 # +0xE65F U+8A10 # +0xE660 U+8A0C # +0xE661 U+8A1B # +0xE662 U+8A1D # +0xE663 U+8A25 # +0xE664 U+8A36 # +0xE665 U+8A41 # +0xE666 U+8A5B # +0xE667 U+8A52 # +0xE668 U+8A46 # +0xE669 U+8A48 # +0xE66A U+8A7C # +0xE66B U+8A6D # +0xE66C U+8A6C # +0xE66D U+8A62 # +0xE66E U+8A85 # +0xE66F U+8A82 # +0xE670 U+8A84 # +0xE671 U+8AA8 # +0xE672 U+8AA1 # +0xE673 U+8A91 # +0xE674 U+8AA5 # +0xE675 U+8AA6 # +0xE676 U+8A9A # +0xE677 U+8AA3 # +0xE678 U+8AC4 # +0xE679 U+8ACD # +0xE67A U+8AC2 # +0xE67B U+8ADA # +0xE67C U+8AEB # +0xE67D U+8AF3 # +0xE67E U+8AE7 # +0xE680 U+8AE4 # +0xE681 U+8AF1 # +0xE682 U+8B14 # +0xE683 U+8AE0 # +0xE684 U+8AE2 # +0xE685 U+8AF7 # +0xE686 U+8ADE # +0xE687 U+8ADB # +0xE688 U+8B0C # +0xE689 U+8B07 # +0xE68A U+8B1A # +0xE68B U+8AE1 # +0xE68C U+8B16 # +0xE68D U+8B10 # +0xE68E U+8B17 # +0xE68F U+8B20 # +0xE690 U+8B33 # +0xE691 U+97AB # +0xE692 U+8B26 # +0xE693 U+8B2B # +0xE694 U+8B3E # +0xE695 U+8B28 # +0xE696 U+8B41 # +0xE697 U+8B4C # +0xE698 U+8B4F # +0xE699 U+8B4E # +0xE69A U+8B49 # +0xE69B U+8B56 # +0xE69C U+8B5B # +0xE69D U+8B5A # +0xE69E U+8B6B # +0xE69F U+8B5F # +0xE6A0 U+8B6C # +0xE6A1 U+8B6F # +0xE6A2 U+8B74 # +0xE6A3 U+8B7D # +0xE6A4 U+8B80 # +0xE6A5 U+8B8C # +0xE6A6 U+8B8E # +0xE6A7 U+8B92 # +0xE6A8 U+8B93 # +0xE6A9 U+8B96 # +0xE6AA U+8B99 # +0xE6AB U+8B9A # +0xE6AC U+8C3A # +0xE6AD U+8C41 # +0xE6AE U+8C3F # +0xE6AF U+8C48 # +0xE6B0 U+8C4C # +0xE6B1 U+8C4E # +0xE6B2 U+8C50 # +0xE6B3 U+8C55 # +0xE6B4 U+8C62 # +0xE6B5 U+8C6C # +0xE6B6 U+8C78 # +0xE6B7 U+8C7A # +0xE6B8 U+8C82 # +0xE6B9 U+8C89 # +0xE6BA U+8C85 # +0xE6BB U+8C8A # +0xE6BC U+8C8D # +0xE6BD U+8C8E # +0xE6BE U+8C94 # +0xE6BF U+8C7C # +0xE6C0 U+8C98 # +0xE6C1 U+621D # +0xE6C2 U+8CAD # +0xE6C3 U+8CAA # +0xE6C4 U+8CBD # +0xE6C5 U+8CB2 # +0xE6C6 U+8CB3 # +0xE6C7 U+8CAE # +0xE6C8 U+8CB6 # +0xE6C9 U+8CC8 # +0xE6CA U+8CC1 # +0xE6CB U+8CE4 # +0xE6CC U+8CE3 # +0xE6CD U+8CDA # +0xE6CE U+8CFD # +0xE6CF U+8CFA # +0xE6D0 U+8CFB # +0xE6D1 U+8D04 # +0xE6D2 U+8D05 # +0xE6D3 U+8D0A # +0xE6D4 U+8D07 # +0xE6D5 U+8D0F # +0xE6D6 U+8D0D # +0xE6D7 U+8D10 # +0xE6D8 U+9F4E # +0xE6D9 U+8D13 # +0xE6DA U+8CCD # +0xE6DB U+8D14 # +0xE6DC U+8D16 # +0xE6DD U+8D67 # +0xE6DE U+8D6D # +0xE6DF U+8D71 # +0xE6E0 U+8D73 # +0xE6E1 U+8D81 # +0xE6E2 U+8D99 # +0xE6E3 U+8DC2 # +0xE6E4 U+8DBE # +0xE6E5 U+8DBA # +0xE6E6 U+8DCF # +0xE6E7 U+8DDA # +0xE6E8 U+8DD6 # +0xE6E9 U+8DCC # +0xE6EA U+8DDB # +0xE6EB U+8DCB # +0xE6EC U+8DEA # +0xE6ED U+8DEB # +0xE6EE U+8DDF # +0xE6EF U+8DE3 # +0xE6F0 U+8DFC # +0xE6F1 U+8E08 # +0xE6F2 U+8E09 # +0xE6F3 U+8DFF # +0xE6F4 U+8E1D # +0xE6F5 U+8E1E # +0xE6F6 U+8E10 # +0xE6F7 U+8E1F # +0xE6F8 U+8E42 # +0xE6F9 U+8E35 # +0xE6FA U+8E30 # +0xE6FB U+8E34 # +0xE6FC U+8E4A # +0xE740 U+8E47 # +0xE741 U+8E49 # +0xE742 U+8E4C # +0xE743 U+8E50 # +0xE744 U+8E48 # +0xE745 U+8E59 # +0xE746 U+8E64 # +0xE747 U+8E60 # +0xE748 U+8E2A # +0xE749 U+8E63 # +0xE74A U+8E55 # +0xE74B U+8E76 # +0xE74C U+8E72 # +0xE74D U+8E7C # +0xE74E U+8E81 # +0xE74F U+8E87 # +0xE750 U+8E85 # +0xE751 U+8E84 # +0xE752 U+8E8B # +0xE753 U+8E8A # +0xE754 U+8E93 # +0xE755 U+8E91 # +0xE756 U+8E94 # +0xE757 U+8E99 # +0xE758 U+8EAA # +0xE759 U+8EA1 # +0xE75A U+8EAC # +0xE75B U+8EB0 # +0xE75C U+8EC6 # +0xE75D U+8EB1 # +0xE75E U+8EBE # +0xE75F U+8EC5 # +0xE760 U+8EC8 # +0xE761 U+8ECB # +0xE762 U+8EDB # +0xE763 U+8EE3 # +0xE764 U+8EFC # +0xE765 U+8EFB # +0xE766 U+8EEB # +0xE767 U+8EFE # +0xE768 U+8F0A # +0xE769 U+8F05 # +0xE76A U+8F15 # +0xE76B U+8F12 # +0xE76C U+8F19 # +0xE76D U+8F13 # +0xE76E U+8F1C # +0xE76F U+8F1F # +0xE770 U+8F1B # +0xE771 U+8F0C # +0xE772 U+8F26 # +0xE773 U+8F33 # +0xE774 U+8F3B # +0xE775 U+8F39 # +0xE776 U+8F45 # +0xE777 U+8F42 # +0xE778 U+8F3E # +0xE779 U+8F4C # +0xE77A U+8F49 # +0xE77B U+8F46 # +0xE77C U+8F4E # +0xE77D U+8F57 # +0xE77E U+8F5C # +0xE780 U+8F62 # +0xE781 U+8F63 # +0xE782 U+8F64 # +0xE783 U+8F9C # +0xE784 U+8F9F # +0xE785 U+8FA3 # +0xE786 U+8FAD # +0xE787 U+8FAF # +0xE788 U+8FB7 # +0xE789 U+8FDA # +0xE78A U+8FE5 # +0xE78B U+8FE2 # +0xE78C U+8FEA # +0xE78D U+8FEF # +0xE78E U+9087 # +0xE78F U+8FF4 # +0xE790 U+9005 # +0xE791 U+8FF9 # +0xE792 U+8FFA # +0xE793 U+9011 # +0xE794 U+9015 # +0xE795 U+9021 # +0xE796 U+900D # +0xE797 U+901E # +0xE798 U+9016 # +0xE799 U+900B # +0xE79A U+9027 # +0xE79B U+9036 # +0xE79C U+9035 # +0xE79D U+9039 # +0xE79E U+8FF8 # +0xE79F U+904F # +0xE7A0 U+9050 # +0xE7A1 U+9051 # +0xE7A2 U+9052 # +0xE7A3 U+900E # +0xE7A4 U+9049 # +0xE7A5 U+903E # +0xE7A6 U+9056 # +0xE7A7 U+9058 # +0xE7A8 U+905E # +0xE7A9 U+9068 # +0xE7AA U+906F # +0xE7AB U+9076 # +0xE7AC U+96A8 # +0xE7AD U+9072 # +0xE7AE U+9082 # +0xE7AF U+907D # +0xE7B0 U+9081 # +0xE7B1 U+9080 # +0xE7B2 U+908A # +0xE7B3 U+9089 # +0xE7B4 U+908F # +0xE7B5 U+90A8 # +0xE7B6 U+90AF # +0xE7B7 U+90B1 # +0xE7B8 U+90B5 # +0xE7B9 U+90E2 # +0xE7BA U+90E4 # +0xE7BB U+6248 # +0xE7BC U+90DB # +0xE7BD U+9102 # +0xE7BE U+9112 # +0xE7BF U+9119 # +0xE7C0 U+9132 # +0xE7C1 U+9130 # +0xE7C2 U+914A # +0xE7C3 U+9156 # +0xE7C4 U+9158 # +0xE7C5 U+9163 # +0xE7C6 U+9165 # +0xE7C7 U+9169 # +0xE7C8 U+9173 # +0xE7C9 U+9172 # +0xE7CA U+918B # +0xE7CB U+9189 # +0xE7CC U+9182 # +0xE7CD U+91A2 # +0xE7CE U+91AB # +0xE7CF U+91AF # +0xE7D0 U+91AA # +0xE7D1 U+91B5 # +0xE7D2 U+91B4 # +0xE7D3 U+91BA # +0xE7D4 U+91C0 # +0xE7D5 U+91C1 # +0xE7D6 U+91C9 # +0xE7D7 U+91CB # +0xE7D8 U+91D0 # +0xE7D9 U+91D6 # +0xE7DA U+91DF # +0xE7DB U+91E1 # +0xE7DC U+91DB # +0xE7DD U+91FC # +0xE7DE U+91F5 # +0xE7DF U+91F6 # +0xE7E0 U+921E # +0xE7E1 U+91FF # +0xE7E2 U+9214 # +0xE7E3 U+922C # +0xE7E4 U+9215 # +0xE7E5 U+9211 # +0xE7E6 U+925E # +0xE7E7 U+9257 # +0xE7E8 U+9245 # +0xE7E9 U+9249 # +0xE7EA U+9264 # +0xE7EB U+9248 # +0xE7EC U+9295 # +0xE7ED U+923F # +0xE7EE U+924B # +0xE7EF U+9250 # +0xE7F0 U+929C # +0xE7F1 U+9296 # +0xE7F2 U+9293 # +0xE7F3 U+929B # +0xE7F4 U+925A # +0xE7F5 U+92CF # +0xE7F6 U+92B9 # +0xE7F7 U+92B7 # +0xE7F8 U+92E9 # +0xE7F9 U+930F # +0xE7FA U+92FA # +0xE7FB U+9344 # +0xE7FC U+932E # +0xE840 U+9319 # +0xE841 U+9322 # +0xE842 U+931A # +0xE843 U+9323 # +0xE844 U+933A # +0xE845 U+9335 # +0xE846 U+933B # +0xE847 U+935C # +0xE848 U+9360 # +0xE849 U+937C # +0xE84A U+936E # +0xE84B U+9356 # +0xE84C U+93B0 # +0xE84D U+93AC # +0xE84E U+93AD # +0xE84F U+9394 # +0xE850 U+93B9 # +0xE851 U+93D6 # +0xE852 U+93D7 # +0xE853 U+93E8 # +0xE854 U+93E5 # +0xE855 U+93D8 # +0xE856 U+93C3 # +0xE857 U+93DD # +0xE858 U+93D0 # +0xE859 U+93C8 # +0xE85A U+93E4 # +0xE85B U+941A # +0xE85C U+9414 # +0xE85D U+9413 # +0xE85E U+9403 # +0xE85F U+9407 # +0xE860 U+9410 # +0xE861 U+9436 # +0xE862 U+942B # +0xE863 U+9435 # +0xE864 U+9421 # +0xE865 U+943A # +0xE866 U+9441 # +0xE867 U+9452 # +0xE868 U+9444 # +0xE869 U+945B # +0xE86A U+9460 # +0xE86B U+9462 # +0xE86C U+945E # +0xE86D U+946A # +0xE86E U+9229 # +0xE86F U+9470 # +0xE870 U+9475 # +0xE871 U+9477 # +0xE872 U+947D # +0xE873 U+945A # +0xE874 U+947C # +0xE875 U+947E # +0xE876 U+9481 # +0xE877 U+947F # +0xE878 U+9582 # +0xE879 U+9587 # +0xE87A U+958A # +0xE87B U+9594 # +0xE87C U+9596 # +0xE87D U+9598 # +0xE87E U+9599 # +0xE880 U+95A0 # +0xE881 U+95A8 # +0xE882 U+95A7 # +0xE883 U+95AD # +0xE884 U+95BC # +0xE885 U+95BB # +0xE886 U+95B9 # +0xE887 U+95BE # +0xE888 U+95CA # +0xE889 U+6FF6 # +0xE88A U+95C3 # +0xE88B U+95CD # +0xE88C U+95CC # +0xE88D U+95D5 # +0xE88E U+95D4 # +0xE88F U+95D6 # +0xE890 U+95DC # +0xE891 U+95E1 # +0xE892 U+95E5 # +0xE893 U+95E2 # +0xE894 U+9621 # +0xE895 U+9628 # +0xE896 U+962E # +0xE897 U+962F # +0xE898 U+9642 # +0xE899 U+964C # +0xE89A U+964F # +0xE89B U+964B # +0xE89C U+9677 # +0xE89D U+965C # +0xE89E U+965E # +0xE89F U+965D # +0xE8A0 U+965F # +0xE8A1 U+9666 # +0xE8A2 U+9672 # +0xE8A3 U+966C # +0xE8A4 U+968D # +0xE8A5 U+9698 # +0xE8A6 U+9695 # +0xE8A7 U+9697 # +0xE8A8 U+96AA # +0xE8A9 U+96A7 # +0xE8AA U+96B1 # +0xE8AB U+96B2 # +0xE8AC U+96B0 # +0xE8AD U+96B4 # +0xE8AE U+96B6 # +0xE8AF U+96B8 # +0xE8B0 U+96B9 # +0xE8B1 U+96CE # +0xE8B2 U+96CB # +0xE8B3 U+96C9 # +0xE8B4 U+96CD # +0xE8B5 U+894D # +0xE8B6 U+96DC # +0xE8B7 U+970D # +0xE8B8 U+96D5 # +0xE8B9 U+96F9 # +0xE8BA U+9704 # +0xE8BB U+9706 # +0xE8BC U+9708 # +0xE8BD U+9713 # +0xE8BE U+970E # +0xE8BF U+9711 # +0xE8C0 U+970F # +0xE8C1 U+9716 # +0xE8C2 U+9719 # +0xE8C3 U+9724 # +0xE8C4 U+972A # +0xE8C5 U+9730 # +0xE8C6 U+9739 # +0xE8C7 U+973D # +0xE8C8 U+973E # +0xE8C9 U+9744 # +0xE8CA U+9746 # +0xE8CB U+9748 # +0xE8CC U+9742 # +0xE8CD U+9749 # +0xE8CE U+975C # +0xE8CF U+9760 # +0xE8D0 U+9764 # +0xE8D1 U+9766 # +0xE8D2 U+9768 # +0xE8D3 U+52D2 # +0xE8D4 U+976B # +0xE8D5 U+9771 # +0xE8D6 U+9779 # +0xE8D7 U+9785 # +0xE8D8 U+977C # +0xE8D9 U+9781 # +0xE8DA U+977A # +0xE8DB U+9786 # +0xE8DC U+978B # +0xE8DD U+978F # +0xE8DE U+9790 # +0xE8DF U+979C # +0xE8E0 U+97A8 # +0xE8E1 U+97A6 # +0xE8E2 U+97A3 # +0xE8E3 U+97B3 # +0xE8E4 U+97B4 # +0xE8E5 U+97C3 # +0xE8E6 U+97C6 # +0xE8E7 U+97C8 # +0xE8E8 U+97CB # +0xE8E9 U+97DC # +0xE8EA U+97ED # +0xE8EB U+9F4F # +0xE8EC U+97F2 # +0xE8ED U+7ADF # +0xE8EE U+97F6 # +0xE8EF U+97F5 # +0xE8F0 U+980F # +0xE8F1 U+980C # +0xE8F2 U+9838 # +0xE8F3 U+9824 # +0xE8F4 U+9821 # +0xE8F5 U+9837 # +0xE8F6 U+983D # +0xE8F7 U+9846 # +0xE8F8 U+984F # +0xE8F9 U+984B # +0xE8FA U+986B # +0xE8FB U+986F # +0xE8FC U+9870 # +0xE940 U+9871 # +0xE941 U+9874 # +0xE942 U+9873 # +0xE943 U+98AA # +0xE944 U+98AF # +0xE945 U+98B1 # +0xE946 U+98B6 # +0xE947 U+98C4 # +0xE948 U+98C3 # +0xE949 U+98C6 # +0xE94A U+98E9 # +0xE94B U+98EB # +0xE94C U+9903 # +0xE94D U+9909 # +0xE94E U+9912 # +0xE94F U+9914 # +0xE950 U+9918 # +0xE951 U+9921 # +0xE952 U+991D # +0xE953 U+991E # +0xE954 U+9924 # +0xE955 U+9920 # +0xE956 U+992C # +0xE957 U+992E # +0xE958 U+993D # +0xE959 U+993E # +0xE95A U+9942 # +0xE95B U+9949 # +0xE95C U+9945 # +0xE95D U+9950 # +0xE95E U+994B # +0xE95F U+9951 # +0xE960 U+9952 # +0xE961 U+994C # +0xE962 U+9955 # +0xE963 U+9997 # +0xE964 U+9998 # +0xE965 U+99A5 # +0xE966 U+99AD # +0xE967 U+99AE # +0xE968 U+99BC # +0xE969 U+99DF # +0xE96A U+99DB # +0xE96B U+99DD # +0xE96C U+99D8 # +0xE96D U+99D1 # +0xE96E U+99ED # +0xE96F U+99EE # +0xE970 U+99F1 # +0xE971 U+99F2 # +0xE972 U+99FB # +0xE973 U+99F8 # +0xE974 U+9A01 # +0xE975 U+9A0F # +0xE976 U+9A05 # +0xE977 U+99E2 # +0xE978 U+9A19 # +0xE979 U+9A2B # +0xE97A U+9A37 # +0xE97B U+9A45 # +0xE97C U+9A42 # +0xE97D U+9A40 # +0xE97E U+9A43 # +0xE980 U+9A3E # +0xE981 U+9A55 # +0xE982 U+9A4D # +0xE983 U+9A5B # +0xE984 U+9A57 # +0xE985 U+9A5F # +0xE986 U+9A62 # +0xE987 U+9A65 # +0xE988 U+9A64 # +0xE989 U+9A69 # +0xE98A U+9A6B # +0xE98B U+9A6A # +0xE98C U+9AAD # +0xE98D U+9AB0 # +0xE98E U+9ABC # +0xE98F U+9AC0 # +0xE990 U+9ACF # +0xE991 U+9AD1 # +0xE992 U+9AD3 # +0xE993 U+9AD4 # +0xE994 U+9ADE # +0xE995 U+9ADF # +0xE996 U+9AE2 # +0xE997 U+9AE3 # +0xE998 U+9AE6 # +0xE999 U+9AEF # +0xE99A U+9AEB # +0xE99B U+9AEE # +0xE99C U+9AF4 # +0xE99D U+9AF1 # +0xE99E U+9AF7 # +0xE99F U+9AFB # +0xE9A0 U+9B06 # +0xE9A1 U+9B18 # +0xE9A2 U+9B1A # +0xE9A3 U+9B1F # +0xE9A4 U+9B22 # +0xE9A5 U+9B23 # +0xE9A6 U+9B25 # +0xE9A7 U+9B27 # +0xE9A8 U+9B28 # +0xE9A9 U+9B29 # +0xE9AA U+9B2A # +0xE9AB U+9B2E # +0xE9AC U+9B2F # +0xE9AD U+9B32 # +0xE9AE U+9B44 # +0xE9AF U+9B43 # +0xE9B0 U+9B4F # +0xE9B1 U+9B4D # +0xE9B2 U+9B4E # +0xE9B3 U+9B51 # +0xE9B4 U+9B58 # +0xE9B5 U+9B74 # +0xE9B6 U+9B93 # +0xE9B7 U+9B83 # +0xE9B8 U+9B91 # +0xE9B9 U+9B96 # +0xE9BA U+9B97 # +0xE9BB U+9B9F # +0xE9BC U+9BA0 # +0xE9BD U+9BA8 # +0xE9BE U+9BB4 # +0xE9BF U+9BC0 # +0xE9C0 U+9BCA # +0xE9C1 U+9BB9 # +0xE9C2 U+9BC6 # +0xE9C3 U+9BCF # +0xE9C4 U+9BD1 # +0xE9C5 U+9BD2 # +0xE9C6 U+9BE3 # +0xE9C7 U+9BE2 # +0xE9C8 U+9BE4 # +0xE9C9 U+9BD4 # +0xE9CA U+9BE1 # +0xE9CB U+9C3A # +0xE9CC U+9BF2 # +0xE9CD U+9BF1 # +0xE9CE U+9BF0 # +0xE9CF U+9C15 # +0xE9D0 U+9C14 # +0xE9D1 U+9C09 # +0xE9D2 U+9C13 # +0xE9D3 U+9C0C # +0xE9D4 U+9C06 # +0xE9D5 U+9C08 # +0xE9D6 U+9C12 # +0xE9D7 U+9C0A # +0xE9D8 U+9C04 # +0xE9D9 U+9C2E # +0xE9DA U+9C1B # +0xE9DB U+9C25 # +0xE9DC U+9C24 # +0xE9DD U+9C21 # +0xE9DE U+9C30 # +0xE9DF U+9C47 # +0xE9E0 U+9C32 # +0xE9E1 U+9C46 # +0xE9E2 U+9C3E # +0xE9E3 U+9C5A # +0xE9E4 U+9C60 # +0xE9E5 U+9C67 # +0xE9E6 U+9C76 # +0xE9E7 U+9C78 # +0xE9E8 U+9CE7 # +0xE9E9 U+9CEC # +0xE9EA U+9CF0 # +0xE9EB U+9D09 # +0xE9EC U+9D08 # +0xE9ED U+9CEB # +0xE9EE U+9D03 # +0xE9EF U+9D06 # +0xE9F0 U+9D2A # +0xE9F1 U+9D26 # +0xE9F2 U+9DAF # +0xE9F3 U+9D23 # +0xE9F4 U+9D1F # +0xE9F5 U+9D44 # +0xE9F6 U+9D15 # +0xE9F7 U+9D12 # +0xE9F8 U+9D41 # +0xE9F9 U+9D3F # +0xE9FA U+9D3E # +0xE9FB U+9D46 # +0xE9FC U+9D48 # +0xEA40 U+9D5D # +0xEA41 U+9D5E # +0xEA42 U+9D64 # +0xEA43 U+9D51 # +0xEA44 U+9D50 # +0xEA45 U+9D59 # +0xEA46 U+9D72 # +0xEA47 U+9D89 # +0xEA48 U+9D87 # +0xEA49 U+9DAB # +0xEA4A U+9D6F # +0xEA4B U+9D7A # +0xEA4C U+9D9A # +0xEA4D U+9DA4 # +0xEA4E U+9DA9 # +0xEA4F U+9DB2 # +0xEA50 U+9DC4 # +0xEA51 U+9DC1 # +0xEA52 U+9DBB # +0xEA53 U+9DB8 # +0xEA54 U+9DBA # +0xEA55 U+9DC6 # +0xEA56 U+9DCF # +0xEA57 U+9DC2 # +0xEA58 U+9DD9 # +0xEA59 U+9DD3 # +0xEA5A U+9DF8 # +0xEA5B U+9DE6 # +0xEA5C U+9DED # +0xEA5D U+9DEF # +0xEA5E U+9DFD # +0xEA5F U+9E1A # +0xEA60 U+9E1B # +0xEA61 U+9E1E # +0xEA62 U+9E75 # +0xEA63 U+9E79 # +0xEA64 U+9E7D # +0xEA65 U+9E81 # +0xEA66 U+9E88 # +0xEA67 U+9E8B # +0xEA68 U+9E8C # +0xEA69 U+9E92 # +0xEA6A U+9E95 # +0xEA6B U+9E91 # +0xEA6C U+9E9D # +0xEA6D U+9EA5 # +0xEA6E U+9EA9 # +0xEA6F U+9EB8 # +0xEA70 U+9EAA # +0xEA71 U+9EAD # +0xEA72 U+9761 # +0xEA73 U+9ECC # +0xEA74 U+9ECE # +0xEA75 U+9ECF # +0xEA76 U+9ED0 # +0xEA77 U+9ED4 # +0xEA78 U+9EDC # +0xEA79 U+9EDE # +0xEA7A U+9EDD # +0xEA7B U+9EE0 # +0xEA7C U+9EE5 # +0xEA7D U+9EE8 # +0xEA7E U+9EEF # +0xEA80 U+9EF4 # +0xEA81 U+9EF6 # +0xEA82 U+9EF7 # +0xEA83 U+9EF9 # +0xEA84 U+9EFB # +0xEA85 U+9EFC # +0xEA86 U+9EFD # +0xEA87 U+9F07 # +0xEA88 U+9F08 # +0xEA89 U+76B7 # +0xEA8A U+9F15 # +0xEA8B U+9F21 # +0xEA8C U+9F2C # +0xEA8D U+9F3E # +0xEA8E U+9F4A # +0xEA8F U+9F52 # +0xEA90 U+9F54 # +0xEA91 U+9F63 # +0xEA92 U+9F5F # +0xEA93 U+9F60 # +0xEA94 U+9F61 # +0xEA95 U+9F66 # +0xEA96 U+9F67 # +0xEA97 U+9F6C # +0xEA98 U+9F6A # +0xEA99 U+9F77 # +0xEA9A U+9F72 # +0xEA9B U+9F76 # +0xEA9C U+9F95 # +0xEA9D U+9F9C # +0xEA9E U+9FA0 # +0xEA9F U+582F # [1983] +0xEAA0 U+69C7 # [1983] +0xEAA1 U+9059 # [1983] +0xEAA2 U+7464 # [1983] +0xEAA3 U+51DC # [1990] +0xEAA4 U+7199 # [1990] +0xEAA5 U+5653 # [2004] +0xEAA6 U+5DE2 # [2000] +0xEAA7 U+5E14 # [2000] +0xEAA8 U+5E18 # [2000] +0xEAA9 U+5E58 # [2000] +0xEAAA U+5E5E # [2000] +0xEAAB U+5EBE # [2000] +0xEAAC U+F928 # CJK COMPATIBILITY IDEOGRAPH-F928 [2000] +0xEAAD U+5ECB # [2000] +0xEAAE U+5EF9 # [2000] +0xEAAF U+5F00 # [2000] +0xEAB0 U+5F02 # [2000] +0xEAB1 U+5F07 # [2000] +0xEAB2 U+5F1D # [2000] +0xEAB3 U+5F23 # [2000] +0xEAB4 U+5F34 # [2000] +0xEAB5 U+5F36 # [2000] +0xEAB6 U+5F3D # [2000] +0xEAB7 U+5F40 # [2000] +0xEAB8 U+5F45 # [2000] +0xEAB9 U+5F54 # [2000] +0xEABA U+5F58 # [2000] +0xEABB U+5F64 # [2000] +0xEABC U+5F67 # [2000] +0xEABD U+5F7D # [2000] +0xEABE U+5F89 # [2000] +0xEABF U+5F9C # [2000] +0xEAC0 U+5FA7 # [2000] +0xEAC1 U+5FAF # [2000] +0xEAC2 U+5FB5 # [2000] +0xEAC3 U+5FB7 # [2000] +0xEAC4 U+5FC9 # [2000] +0xEAC5 U+5FDE # [2000] +0xEAC6 U+5FE1 # [2000] +0xEAC7 U+5FE9 # [2000] +0xEAC8 U+600D # [2000] +0xEAC9 U+6014 # [2000] +0xEACA U+6018 # [2000] +0xEACB U+6033 # [2000] +0xEACC U+6035 # [2000] +0xEACD U+6047 # [2000] +0xEACE U+FA3D # CJK COMPATIBILITY IDEOGRAPH-FA3D [2000] [Unicode3.2] +0xEACF U+609D # [2000] +0xEAD0 U+609E # [2000] +0xEAD1 U+60CB # [2000] +0xEAD2 U+60D4 # [2000] +0xEAD3 U+60D5 # [2000] +0xEAD4 U+60DD # [2000] +0xEAD5 U+60F8 # [2000] +0xEAD6 U+611C # [2000] +0xEAD7 U+612B # [2000] +0xEAD8 U+6130 # [2000] +0xEAD9 U+6137 # [2000] +0xEADA U+FA3E # CJK COMPATIBILITY IDEOGRAPH-FA3E [2000] [Unicode3.2] +0xEADB U+618D # [2000] +0xEADC U+FA3F # CJK COMPATIBILITY IDEOGRAPH-FA3F [2000] [Unicode3.2] +0xEADD U+61BC # [2000] +0xEADE U+61B9 # [2000] +0xEADF U+FA40 # CJK COMPATIBILITY IDEOGRAPH-FA40 [2000] [Unicode3.2] +0xEAE0 U+6222 # [2000] +0xEAE1 U+623E # [2000] +0xEAE2 U+6243 # [2000] +0xEAE3 U+6256 # [2000] +0xEAE4 U+625A # [2000] +0xEAE5 U+626F # [2000] +0xEAE6 U+6285 # [2000] +0xEAE7 U+62C4 # [2000] +0xEAE8 U+62D6 # [2000] +0xEAE9 U+62FC # [2000] +0xEAEA U+630A # [2000] +0xEAEB U+6318 # [2000] +0xEAEC U+6339 # [2000] +0xEAED U+6343 # [2000] +0xEAEE U+6365 # [2000] +0xEAEF U+637C # [2000] +0xEAF0 U+63E5 # [2000] +0xEAF1 U+63ED # [2000] +0xEAF2 U+63F5 # [2000] +0xEAF3 U+6410 # [2000] +0xEAF4 U+6414 # [2000] +0xEAF5 U+6422 # [2000] +0xEAF6 U+6479 # [2000] +0xEAF7 U+6451 # [2000] +0xEAF8 U+6460 # [2000] +0xEAF9 U+646D # [2000] +0xEAFA U+64CE # [2000] +0xEAFB U+64BE # [2000] +0xEAFC U+64BF # [2000] +0xEB40 U+64C4 # [2000] +0xEB41 U+64CA # [2000] +0xEB42 U+64D0 # [2000] +0xEB43 U+64F7 # [2000] +0xEB44 U+64FB # [2000] +0xEB45 U+6522 # [2000] +0xEB46 U+6529 # [2000] +0xEB47 U+FA41 # CJK COMPATIBILITY IDEOGRAPH-FA41 [2000] [Unicode3.2] +0xEB48 U+6567 # [2000] +0xEB49 U+659D # [2000] +0xEB4A U+FA42 # CJK COMPATIBILITY IDEOGRAPH-FA42 [2000] [Unicode3.2] +0xEB4B U+6600 # [2000] +0xEB4C U+6609 # [2000] +0xEB4D U+6615 # [2000] +0xEB4E U+661E # [2000] +0xEB4F U+663A # [2000] +0xEB50 U+6622 # [2000] +0xEB51 U+6624 # [2000] +0xEB52 U+662B # [2000] +0xEB53 U+6630 # [2000] +0xEB54 U+6631 # [2000] +0xEB55 U+6633 # [2000] +0xEB56 U+66FB # [2000] +0xEB57 U+6648 # [2000] +0xEB58 U+664C # [2000] +0xEB59 U+231C4 # [2000] [Unicode3.1] +0xEB5A U+6659 # [2000] +0xEB5B U+665A # [2000] +0xEB5C U+6661 # [2000] +0xEB5D U+6665 # [2000] +0xEB5E U+6673 # [2000] +0xEB5F U+6677 # [2000] +0xEB60 U+6678 # [2000] +0xEB61 U+668D # [2000] +0xEB62 U+FA43 # CJK COMPATIBILITY IDEOGRAPH-FA43 [2000] [Unicode3.2] +0xEB63 U+66A0 # [2000] +0xEB64 U+66B2 # [2000] +0xEB65 U+66BB # [2000] +0xEB66 U+66C6 # [2000] +0xEB67 U+66C8 # [2000] +0xEB68 U+3B22 # [2000] +0xEB69 U+66DB # [2000] +0xEB6A U+66E8 # [2000] +0xEB6B U+66FA # [2000] +0xEB6C U+6713 # [2000] +0xEB6D U+F929 # CJK COMPATIBILITY IDEOGRAPH-F929 [2000] +0xEB6E U+6733 # [2000] +0xEB6F U+6766 # [2000] +0xEB70 U+6747 # [2000] +0xEB71 U+6748 # [2000] +0xEB72 U+677B # [2000] +0xEB73 U+6781 # [2000] +0xEB74 U+6793 # [2000] +0xEB75 U+6798 # [2000] +0xEB76 U+679B # [2000] +0xEB77 U+67BB # [2000] +0xEB78 U+67F9 # [2000] +0xEB79 U+67C0 # [2000] +0xEB7A U+67D7 # [2000] +0xEB7B U+67FC # [2000] +0xEB7C U+6801 # [2000] +0xEB7D U+6852 # [2000] +0xEB7E U+681D # [2000] +0xEB80 U+682C # [2000] +0xEB81 U+6831 # [2000] +0xEB82 U+685B # [2000] +0xEB83 U+6872 # [2000] +0xEB84 U+6875 # [2000] +0xEB85 U+FA44 # CJK COMPATIBILITY IDEOGRAPH-FA44 [2000] [Unicode3.2] +0xEB86 U+68A3 # [2000] +0xEB87 U+68A5 # [2000] +0xEB88 U+68B2 # [2000] +0xEB89 U+68C8 # [2000] +0xEB8A U+68D0 # [2000] +0xEB8B U+68E8 # [2000] +0xEB8C U+68ED # [2000] +0xEB8D U+68F0 # [2000] +0xEB8E U+68F1 # [2000] +0xEB8F U+68FC # [2000] +0xEB90 U+690A # [2000] +0xEB91 U+6949 # [2000] +0xEB92 U+235C4 # [2000] [Unicode3.1] +0xEB93 U+6935 # [2000] +0xEB94 U+6942 # [2000] +0xEB95 U+6957 # [2000] +0xEB96 U+6963 # [2000] +0xEB97 U+6964 # [2000] +0xEB98 U+6968 # [2000] +0xEB99 U+6980 # [2000] +0xEB9A U+FA14 # CJK COMPATIBILITY IDEOGRAPH-FA14 [2000] +0xEB9B U+69A5 # [2000] +0xEB9C U+69AD # [2000] +0xEB9D U+69CF # [2000] +0xEB9E U+3BB6 # [2000] +0xEB9F U+3BC3 # [2000] +0xEBA0 U+69E2 # [2000] +0xEBA1 U+69E9 # [2000] +0xEBA2 U+69EA # [2000] +0xEBA3 U+69F5 # [2000] +0xEBA4 U+69F6 # [2000] +0xEBA5 U+6A0F # [2000] +0xEBA6 U+6A15 # [2000] +0xEBA7 U+2373F # [2000] [Unicode3.1] +0xEBA8 U+6A3B # [2000] +0xEBA9 U+6A3E # [2000] +0xEBAA U+6A45 # [2000] +0xEBAB U+6A50 # [2000] +0xEBAC U+6A56 # [2000] +0xEBAD U+6A5B # [2000] +0xEBAE U+6A6B # [2000] +0xEBAF U+6A73 # [2000] +0xEBB0 U+23763 # [2000] [Unicode3.1] +0xEBB1 U+6A89 # [2000] +0xEBB2 U+6A94 # [2000] +0xEBB3 U+6A9D # [2000] +0xEBB4 U+6A9E # [2000] +0xEBB5 U+6AA5 # [2000] +0xEBB6 U+6AE4 # [2000] +0xEBB7 U+6AE7 # [2000] +0xEBB8 U+3C0F # [2000] +0xEBB9 U+F91D # CJK COMPATIBILITY IDEOGRAPH-F91D [2000] +0xEBBA U+6B1B # [2000] +0xEBBB U+6B1E # [2000] +0xEBBC U+6B2C # [2000] +0xEBBD U+6B35 # [2000] +0xEBBE U+6B46 # [2000] +0xEBBF U+6B56 # [2000] +0xEBC0 U+6B60 # [2000] +0xEBC1 U+6B65 # [2000] +0xEBC2 U+6B67 # [2000] +0xEBC3 U+6B77 # [2000] +0xEBC4 U+6B82 # [2000] +0xEBC5 U+6BA9 # [2000] +0xEBC6 U+6BAD # [2000] +0xEBC7 U+F970 # CJK COMPATIBILITY IDEOGRAPH-F970 [2000] +0xEBC8 U+6BCF # [2000] +0xEBC9 U+6BD6 # [2000] +0xEBCA U+6BD7 # [2000] +0xEBCB U+6BFF # [2000] +0xEBCC U+6C05 # [2000] +0xEBCD U+6C10 # [2000] +0xEBCE U+6C33 # [2000] +0xEBCF U+6C59 # [2000] +0xEBD0 U+6C5C # [2000] +0xEBD1 U+6CAA # [2000] +0xEBD2 U+6C74 # [2000] +0xEBD3 U+6C76 # [2000] +0xEBD4 U+6C85 # [2000] +0xEBD5 U+6C86 # [2000] +0xEBD6 U+6C98 # [2000] +0xEBD7 U+6C9C # [2000] +0xEBD8 U+6CFB # [2000] +0xEBD9 U+6CC6 # [2000] +0xEBDA U+6CD4 # [2000] +0xEBDB U+6CE0 # [2000] +0xEBDC U+6CEB # [2000] +0xEBDD U+6CEE # [2000] +0xEBDE U+23CFE # [2000] [Unicode3.1] +0xEBDF U+6D04 # [2000] +0xEBE0 U+6D0E # [2000] +0xEBE1 U+6D2E # [2000] +0xEBE2 U+6D31 # [2000] +0xEBE3 U+6D39 # [2000] +0xEBE4 U+6D3F # [2000] +0xEBE5 U+6D58 # [2000] +0xEBE6 U+6D65 # [2000] +0xEBE7 U+FA45 # CJK COMPATIBILITY IDEOGRAPH-FA45 [2000] [Unicode3.2] +0xEBE8 U+6D82 # [2000] +0xEBE9 U+6D87 # [2000] +0xEBEA U+6D89 # [2000] +0xEBEB U+6D94 # [2000] +0xEBEC U+6DAA # [2000] +0xEBED U+6DAC # [2000] +0xEBEE U+6DBF # [2000] +0xEBEF U+6DC4 # [2000] +0xEBF0 U+6DD6 # [2000] +0xEBF1 U+6DDA # [2000] +0xEBF2 U+6DDB # [2000] +0xEBF3 U+6DDD # [2000] +0xEBF4 U+6DFC # [2000] +0xEBF5 U+FA46 # CJK COMPATIBILITY IDEOGRAPH-FA46 [2000] [Unicode3.2] +0xEBF6 U+6E34 # [2000] +0xEBF7 U+6E44 # [2000] +0xEBF8 U+6E5C # [2000] +0xEBF9 U+6E5E # [2000] +0xEBFA U+6EAB # [2000] +0xEBFB U+6EB1 # [2000] +0xEBFC U+6EC1 # [2000] +0xEC40 U+6EC7 # [2000] +0xEC41 U+6ECE # [2000] +0xEC42 U+6F10 # [2000] +0xEC43 U+6F1A # [2000] +0xEC44 U+FA47 # CJK COMPATIBILITY IDEOGRAPH-FA47 [2000] [Unicode3.2] +0xEC45 U+6F2A # [2000] +0xEC46 U+6F2F # [2000] +0xEC47 U+6F33 # [2000] +0xEC48 U+6F51 # [2000] +0xEC49 U+6F59 # [2000] +0xEC4A U+6F5E # [2000] +0xEC4B U+6F61 # [2000] +0xEC4C U+6F62 # [2000] +0xEC4D U+6F7E # [2000] +0xEC4E U+6F88 # [2000] +0xEC4F U+6F8C # [2000] +0xEC50 U+6F8D # [2000] +0xEC51 U+6F94 # [2000] +0xEC52 U+6FA0 # [2000] +0xEC53 U+6FA7 # [2000] +0xEC54 U+6FB6 # [2000] +0xEC55 U+6FBC # [2000] +0xEC56 U+6FC7 # [2000] +0xEC57 U+6FCA # [2000] +0xEC58 U+6FF9 # [2000] +0xEC59 U+6FF0 # [2000] +0xEC5A U+6FF5 # [2000] +0xEC5B U+7005 # [2000] +0xEC5C U+7006 # [2000] +0xEC5D U+7028 # [2000] +0xEC5E U+704A # [2000] +0xEC5F U+705D # [2000] +0xEC60 U+705E # [2000] +0xEC61 U+704E # [2000] +0xEC62 U+7064 # [2000] +0xEC63 U+7075 # [2000] +0xEC64 U+7085 # [2000] +0xEC65 U+70A4 # [2000] +0xEC66 U+70AB # [2000] +0xEC67 U+70B7 # [2000] +0xEC68 U+70D4 # [2000] +0xEC69 U+70D8 # [2000] +0xEC6A U+70E4 # [2000] +0xEC6B U+710F # [2000] +0xEC6C U+712B # [2000] +0xEC6D U+711E # [2000] +0xEC6E U+7120 # [2000] +0xEC6F U+712E # [2000] +0xEC70 U+7130 # [2000] +0xEC71 U+7146 # [2000] +0xEC72 U+7147 # [2000] +0xEC73 U+7151 # [2000] +0xEC74 U+FA48 # CJK COMPATIBILITY IDEOGRAPH-FA48 [2000] [Unicode3.2] +0xEC75 U+7152 # [2000] +0xEC76 U+715C # [2000] +0xEC77 U+7160 # [2000] +0xEC78 U+7168 # [2000] +0xEC79 U+FA15 # CJK COMPATIBILITY IDEOGRAPH-FA15 [2000] +0xEC7A U+7185 # [2000] +0xEC7B U+7187 # [2000] +0xEC7C U+7192 # [2000] +0xEC7D U+71C1 # [2000] +0xEC7E U+71BA # [2000] +0xEC80 U+71C4 # [2000] +0xEC81 U+71FE # [2000] +0xEC82 U+7200 # [2000] +0xEC83 U+7215 # [2000] +0xEC84 U+7255 # [2000] +0xEC85 U+7256 # [2000] +0xEC86 U+3E3F # [2000] +0xEC87 U+728D # [2000] +0xEC88 U+729B # [2000] +0xEC89 U+72BE # [2000] +0xEC8A U+72C0 # [2000] +0xEC8B U+72FB # [2000] +0xEC8C U+247F1 # [2000] [Unicode3.1] +0xEC8D U+7327 # [2000] +0xEC8E U+7328 # [2000] +0xEC8F U+FA16 # CJK COMPATIBILITY IDEOGRAPH-FA16 [2000] +0xEC90 U+7350 # [2000] +0xEC91 U+7366 # [2000] +0xEC92 U+737C # [2000] +0xEC93 U+7395 # [2000] +0xEC94 U+739F # [2000] +0xEC95 U+73A0 # [2000] +0xEC96 U+73A2 # [2000] +0xEC97 U+73A6 # [2000] +0xEC98 U+73AB # [2000] +0xEC99 U+73C9 # [2000] +0xEC9A U+73CF # [2000] +0xEC9B U+73D6 # [2000] +0xEC9C U+73D9 # [2000] +0xEC9D U+73E3 # [2000] +0xEC9E U+73E9 # [2000] +0xEC9F U+7407 # [2000] +0xECA0 U+740A # [2000] +0xECA1 U+741A # [2000] +0xECA2 U+741B # [2000] +0xECA3 U+FA4A # CJK COMPATIBILITY IDEOGRAPH-FA4A [2000] [Unicode3.2] +0xECA4 U+7426 # [2000] +0xECA5 U+7428 # [2000] +0xECA6 U+742A # [2000] +0xECA7 U+742B # [2000] +0xECA8 U+742C # [2000] +0xECA9 U+742E # [2000] +0xECAA U+742F # [2000] +0xECAB U+7430 # [2000] +0xECAC U+7444 # [2000] +0xECAD U+7446 # [2000] +0xECAE U+7447 # [2000] +0xECAF U+744B # [2000] +0xECB0 U+7457 # [2000] +0xECB1 U+7462 # [2000] +0xECB2 U+746B # [2000] +0xECB3 U+746D # [2000] +0xECB4 U+7486 # [2000] +0xECB5 U+7487 # [2000] +0xECB6 U+7489 # [2000] +0xECB7 U+7498 # [2000] +0xECB8 U+749C # [2000] +0xECB9 U+749F # [2000] +0xECBA U+74A3 # [2000] +0xECBB U+7490 # [2000] +0xECBC U+74A6 # [2000] +0xECBD U+74A8 # [2000] +0xECBE U+74A9 # [2000] +0xECBF U+74B5 # [2000] +0xECC0 U+74BF # [2000] +0xECC1 U+74C8 # [2000] +0xECC2 U+74C9 # [2000] +0xECC3 U+74DA # [2000] +0xECC4 U+74FF # [2000] +0xECC5 U+7501 # [2000] +0xECC6 U+7517 # [2000] +0xECC7 U+752F # [2000] +0xECC8 U+756F # [2000] +0xECC9 U+7579 # [2000] +0xECCA U+7592 # [2000] +0xECCB U+3F72 # [2000] +0xECCC U+75CE # [2000] +0xECCD U+75E4 # [2000] +0xECCE U+7600 # [2000] +0xECCF U+7602 # [2000] +0xECD0 U+7608 # [2000] +0xECD1 U+7615 # [2000] +0xECD2 U+7616 # [2000] +0xECD3 U+7619 # [2000] +0xECD4 U+761E # [2000] +0xECD5 U+762D # [2000] +0xECD6 U+7635 # [2000] +0xECD7 U+7643 # [2000] +0xECD8 U+764B # [2000] +0xECD9 U+7664 # [2000] +0xECDA U+7665 # [2000] +0xECDB U+766D # [2000] +0xECDC U+766F # [2000] +0xECDD U+7671 # [2000] +0xECDE U+7681 # [2000] +0xECDF U+769B # [2000] +0xECE0 U+769D # [2000] +0xECE1 U+769E # [2000] +0xECE2 U+76A6 # [2000] +0xECE3 U+76AA # [2000] +0xECE4 U+76B6 # [2000] +0xECE5 U+76C5 # [2000] +0xECE6 U+76CC # [2000] +0xECE7 U+76CE # [2000] +0xECE8 U+76D4 # [2000] +0xECE9 U+76E6 # [2000] +0xECEA U+76F1 # [2000] +0xECEB U+76FC # [2000] +0xECEC U+770A # [2000] +0xECED U+7719 # [2000] +0xECEE U+7734 # [2000] +0xECEF U+7736 # [2000] +0xECF0 U+7746 # [2000] +0xECF1 U+774D # [2000] +0xECF2 U+774E # [2000] +0xECF3 U+775C # [2000] +0xECF4 U+775F # [2000] +0xECF5 U+7762 # [2000] +0xECF6 U+777A # [2000] +0xECF7 U+7780 # [2000] +0xECF8 U+7794 # [2000] +0xECF9 U+77AA # [2000] +0xECFA U+77E0 # [2000] +0xECFB U+782D # [2000] +0xECFC U+2548E # [2000] [Unicode3.1] +0xED40 U+7843 # [2000] +0xED41 U+784E # [2000] +0xED42 U+784F # [2000] +0xED43 U+7851 # [2000] +0xED44 U+7868 # [2000] +0xED45 U+786E # [2000] +0xED46 U+FA4B # CJK COMPATIBILITY IDEOGRAPH-FA4B [2000] [Unicode3.2] +0xED47 U+78B0 # [2000] +0xED48 U+2550E # [2000] [Unicode3.1] +0xED49 U+78AD # [2000] +0xED4A U+78E4 # [2000] +0xED4B U+78F2 # [2000] +0xED4C U+7900 # [2000] +0xED4D U+78F7 # [2000] +0xED4E U+791C # [2000] +0xED4F U+792E # [2000] +0xED50 U+7931 # [2000] +0xED51 U+7934 # [2000] +0xED52 U+FA4C # CJK COMPATIBILITY IDEOGRAPH-FA4C [2000] [Unicode3.2] +0xED53 U+FA4D # CJK COMPATIBILITY IDEOGRAPH-FA4D [2000] [Unicode3.2] +0xED54 U+7945 # [2000] +0xED55 U+7946 # [2000] +0xED56 U+FA4E # CJK COMPATIBILITY IDEOGRAPH-FA4E [2000] [Unicode3.2] +0xED57 U+FA4F # CJK COMPATIBILITY IDEOGRAPH-FA4F [2000] [Unicode3.2] +0xED58 U+FA50 # CJK COMPATIBILITY IDEOGRAPH-FA50 [2000] [Unicode3.2] +0xED59 U+795C # [2000] +0xED5A U+FA51 # CJK COMPATIBILITY IDEOGRAPH-FA51 [2000] [Unicode3.2] +0xED5B U+FA19 # CJK COMPATIBILITY IDEOGRAPH-FA19 [2000] +0xED5C U+FA1A # CJK COMPATIBILITY IDEOGRAPH-FA1A [2000] +0xED5D U+7979 # [2000] +0xED5E U+FA52 # CJK COMPATIBILITY IDEOGRAPH-FA52 [2000] [Unicode3.2] +0xED5F U+FA53 # CJK COMPATIBILITY IDEOGRAPH-FA53 [2000] [Unicode3.2] +0xED60 U+FA1B # CJK COMPATIBILITY IDEOGRAPH-FA1B [2000] +0xED61 U+7998 # [2000] +0xED62 U+79B1 # [2000] +0xED63 U+79B8 # [2000] +0xED64 U+79C8 # [2000] +0xED65 U+79CA # [2000] +0xED66 U+25771 # [2000] [Unicode3.1] +0xED67 U+79D4 # [2000] +0xED68 U+79DE # [2000] +0xED69 U+79EB # [2000] +0xED6A U+79ED # [2000] +0xED6B U+7A03 # [2000] +0xED6C U+FA54 # CJK COMPATIBILITY IDEOGRAPH-FA54 [2000] [Unicode3.2] +0xED6D U+7A39 # [2000] +0xED6E U+7A5D # [2000] +0xED6F U+7A6D # [2000] +0xED70 U+FA55 # CJK COMPATIBILITY IDEOGRAPH-FA55 [2000] [Unicode3.2] +0xED71 U+7A85 # [2000] +0xED72 U+7AA0 # [2000] +0xED73 U+259C4 # [2000] [Unicode3.1] +0xED74 U+7AB3 # [2000] +0xED75 U+7ABB # [2000] +0xED76 U+7ACE # [2000] +0xED77 U+7AEB # [2000] +0xED78 U+7AFD # [2000] +0xED79 U+7B12 # [2000] +0xED7A U+7B2D # [2000] +0xED7B U+7B3B # [2000] +0xED7C U+7B47 # [2000] +0xED7D U+7B4E # [2000] +0xED7E U+7B60 # [2000] +0xED80 U+7B6D # [2000] +0xED81 U+7B6F # [2000] +0xED82 U+7B72 # [2000] +0xED83 U+7B9E # [2000] +0xED84 U+FA56 # CJK COMPATIBILITY IDEOGRAPH-FA56 [2000] [Unicode3.2] +0xED85 U+7BD7 # [2000] +0xED86 U+7BD9 # [2000] +0xED87 U+7C01 # [2000] +0xED88 U+7C31 # [2000] +0xED89 U+7C1E # [2000] +0xED8A U+7C20 # [2000] +0xED8B U+7C33 # [2000] +0xED8C U+7C36 # [2000] +0xED8D U+4264 # [2000] +0xED8E U+25DA1 # [2000] [Unicode3.1] +0xED8F U+7C59 # [2000] +0xED90 U+7C6D # [2000] +0xED91 U+7C79 # [2000] +0xED92 U+7C8F # [2000] +0xED93 U+7C94 # [2000] +0xED94 U+7CA0 # [2000] +0xED95 U+7CBC # [2000] +0xED96 U+7CD5 # [2000] +0xED97 U+7CD9 # [2000] +0xED98 U+7CDD # [2000] +0xED99 U+7D07 # [2000] +0xED9A U+7D08 # [2000] +0xED9B U+7D13 # [2000] +0xED9C U+7D1D # [2000] +0xED9D U+7D23 # [2000] +0xED9E U+7D31 # [2000] +0xED9F U+7D41 # [2000] +0xEDA0 U+7D48 # [2000] +0xEDA1 U+7D53 # [2000] +0xEDA2 U+7D5C # [2000] +0xEDA3 U+7D7A # [2000] +0xEDA4 U+7D83 # [2000] +0xEDA5 U+7D8B # [2000] +0xEDA6 U+7DA0 # [2000] +0xEDA7 U+7DA6 # [2000] +0xEDA8 U+7DC2 # [2000] +0xEDA9 U+7DCC # [2000] +0xEDAA U+7DD6 # [2000] +0xEDAB U+7DE3 # [2000] +0xEDAC U+FA57 # CJK COMPATIBILITY IDEOGRAPH-FA57 [2000] [Unicode3.2] +0xEDAD U+7E28 # [2000] +0xEDAE U+7E08 # [2000] +0xEDAF U+7E11 # [2000] +0xEDB0 U+7E15 # [2000] +0xEDB1 U+FA59 # CJK COMPATIBILITY IDEOGRAPH-FA59 [2000] [Unicode3.2] +0xEDB2 U+7E47 # [2000] +0xEDB3 U+7E52 # [2000] +0xEDB4 U+7E61 # [2000] +0xEDB5 U+7E8A # [2000] +0xEDB6 U+7E8D # [2000] +0xEDB7 U+7F47 # [2000] +0xEDB8 U+FA5A # CJK COMPATIBILITY IDEOGRAPH-FA5A [2000] [Unicode3.2] +0xEDB9 U+7F91 # [2000] +0xEDBA U+7F97 # [2000] +0xEDBB U+7FBF # [2000] +0xEDBC U+7FCE # [2000] +0xEDBD U+7FDB # [2000] +0xEDBE U+7FDF # [2000] +0xEDBF U+7FEC # [2000] +0xEDC0 U+7FEE # [2000] +0xEDC1 U+7FFA # [2000] +0xEDC2 U+FA5B # CJK COMPATIBILITY IDEOGRAPH-FA5B [2000] [Unicode3.2] +0xEDC3 U+8014 # [2000] +0xEDC4 U+8026 # [2000] +0xEDC5 U+8035 # [2000] +0xEDC6 U+8037 # [2000] +0xEDC7 U+803C # [2000] +0xEDC8 U+80CA # [2000] +0xEDC9 U+80D7 # [2000] +0xEDCA U+80E0 # [2000] +0xEDCB U+80F3 # [2000] +0xEDCC U+8118 # [2000] +0xEDCD U+814A # [2000] +0xEDCE U+8160 # [2000] +0xEDCF U+8167 # [2000] +0xEDD0 U+8168 # [2000] +0xEDD1 U+816D # [2000] +0xEDD2 U+81BB # [2000] +0xEDD3 U+81CA # [2000] +0xEDD4 U+81CF # [2000] +0xEDD5 U+81D7 # [2000] +0xEDD6 U+FA5C # CJK COMPATIBILITY IDEOGRAPH-FA5C [2000] [Unicode3.2] +0xEDD7 U+4453 # [2000] +0xEDD8 U+445B # [2000] +0xEDD9 U+8260 # [2000] +0xEDDA U+8274 # [2000] +0xEDDB U+26AFF # [2000] [Unicode3.1] +0xEDDC U+828E # [2000] +0xEDDD U+82A1 # [2000] +0xEDDE U+82A3 # [2000] +0xEDDF U+82A4 # [2000] +0xEDE0 U+82A9 # [2000] +0xEDE1 U+82AE # [2000] +0xEDE2 U+82B7 # [2000] +0xEDE3 U+82BE # [2000] +0xEDE4 U+82BF # [2000] +0xEDE5 U+82C6 # [2000] +0xEDE6 U+82D5 # [2000] +0xEDE7 U+82FD # [2000] +0xEDE8 U+82FE # [2000] +0xEDE9 U+8300 # [2000] +0xEDEA U+8301 # [2000] +0xEDEB U+8362 # [2000] +0xEDEC U+8322 # [2000] +0xEDED U+832D # [2000] +0xEDEE U+833A # [2000] +0xEDEF U+8343 # [2000] +0xEDF0 U+8347 # [2000] +0xEDF1 U+8351 # [2000] +0xEDF2 U+8355 # [2000] +0xEDF3 U+837D # [2000] +0xEDF4 U+8386 # [2000] +0xEDF5 U+8392 # [2000] +0xEDF6 U+8398 # [2000] +0xEDF7 U+83A7 # [2000] +0xEDF8 U+83A9 # [2000] +0xEDF9 U+83BF # [2000] +0xEDFA U+83C0 # [2000] +0xEDFB U+83C7 # [2000] +0xEDFC U+83CF # [2000] +0xEE40 U+83D1 # [2000] +0xEE41 U+83E1 # [2000] +0xEE42 U+83EA # [2000] +0xEE43 U+8401 # [2000] +0xEE44 U+8406 # [2000] +0xEE45 U+840A # [2000] +0xEE46 U+FA5F # CJK COMPATIBILITY IDEOGRAPH-FA5F [2000] [Unicode3.2] +0xEE47 U+8448 # [2000] +0xEE48 U+845F # [2000] +0xEE49 U+8470 # [2000] +0xEE4A U+8473 # [2000] +0xEE4B U+8485 # [2000] +0xEE4C U+849E # [2000] +0xEE4D U+84AF # [2000] +0xEE4E U+84B4 # [2000] +0xEE4F U+84BA # [2000] +0xEE50 U+84C0 # [2000] +0xEE51 U+84C2 # [2000] +0xEE52 U+26E40 # [2000] [Unicode3.1] +0xEE53 U+8532 # [2000] +0xEE54 U+851E # [2000] +0xEE55 U+8523 # [2000] +0xEE56 U+852F # [2000] +0xEE57 U+8559 # [2000] +0xEE58 U+8564 # [2000] +0xEE59 U+FA1F # CJK COMPATIBILITY IDEOGRAPH-FA1F [2000] +0xEE5A U+85AD # [2000] +0xEE5B U+857A # [2000] +0xEE5C U+858C # [2000] +0xEE5D U+858F # [2000] +0xEE5E U+85A2 # [2000] +0xEE5F U+85B0 # [2000] +0xEE60 U+85CB # [2000] +0xEE61 U+85CE # [2000] +0xEE62 U+85ED # [2000] +0xEE63 U+8612 # [2000] +0xEE64 U+85FF # [2000] +0xEE65 U+8604 # [2000] +0xEE66 U+8605 # [2000] +0xEE67 U+8610 # [2000] +0xEE68 U+270F4 # [2000] [Unicode3.1] +0xEE69 U+8618 # [2000] +0xEE6A U+8629 # [2000] +0xEE6B U+8638 # [2000] +0xEE6C U+8657 # [2000] +0xEE6D U+865B # [2000] +0xEE6E U+F936 # CJK COMPATIBILITY IDEOGRAPH-F936 [2000] +0xEE6F U+8662 # [2000] +0xEE70 U+459D # [2000] +0xEE71 U+866C # [2000] +0xEE72 U+8675 # [2000] +0xEE73 U+8698 # [2000] +0xEE74 U+86B8 # [2000] +0xEE75 U+86FA # [2000] +0xEE76 U+86FC # [2000] +0xEE77 U+86FD # [2000] +0xEE78 U+870B # [2000] +0xEE79 U+8771 # [2000] +0xEE7A U+8787 # [2000] +0xEE7B U+8788 # [2000] +0xEE7C U+87AC # [2000] +0xEE7D U+87AD # [2000] +0xEE7E U+87B5 # [2000] +0xEE80 U+45EA # [2000] +0xEE81 U+87D6 # [2000] +0xEE82 U+87EC # [2000] +0xEE83 U+8806 # [2000] +0xEE84 U+880A # [2000] +0xEE85 U+8810 # [2000] +0xEE86 U+8814 # [2000] +0xEE87 U+881F # [2000] +0xEE88 U+8898 # [2000] +0xEE89 U+88AA # [2000] +0xEE8A U+88CA # [2000] +0xEE8B U+88CE # [2000] +0xEE8C U+27684 # [2000] [Unicode3.1] +0xEE8D U+88F5 # [2000] +0xEE8E U+891C # [2000] +0xEE8F U+FA60 # CJK COMPATIBILITY IDEOGRAPH-FA60 [2000] [Unicode3.2] +0xEE90 U+8918 # [2000] +0xEE91 U+8919 # [2000] +0xEE92 U+891A # [2000] +0xEE93 U+8927 # [2000] +0xEE94 U+8930 # [2000] +0xEE95 U+8932 # [2000] +0xEE96 U+8939 # [2000] +0xEE97 U+8940 # [2000] +0xEE98 U+8994 # [2000] +0xEE99 U+FA61 # CJK COMPATIBILITY IDEOGRAPH-FA61 [2000] [Unicode3.2] +0xEE9A U+89D4 # [2000] +0xEE9B U+89E5 # [2000] +0xEE9C U+89F6 # [2000] +0xEE9D U+8A12 # [2000] +0xEE9E U+8A15 # [2000] +0xEE9F U+8A22 # [2000] +0xEEA0 U+8A37 # [2000] +0xEEA1 U+8A47 # [2000] +0xEEA2 U+8A4E # [2000] +0xEEA3 U+8A5D # [2000] +0xEEA4 U+8A61 # [2000] +0xEEA5 U+8A75 # [2000] +0xEEA6 U+8A79 # [2000] +0xEEA7 U+8AA7 # [2000] +0xEEA8 U+8AD0 # [2000] +0xEEA9 U+8ADF # [2000] +0xEEAA U+8AF4 # [2000] +0xEEAB U+8AF6 # [2000] +0xEEAC U+FA22 # CJK COMPATIBILITY IDEOGRAPH-FA22 [2000] +0xEEAD U+FA62 # CJK COMPATIBILITY IDEOGRAPH-FA62 [2000] [Unicode3.2] +0xEEAE U+FA63 # CJK COMPATIBILITY IDEOGRAPH-FA63 [2000] [Unicode3.2] +0xEEAF U+8B46 # [2000] +0xEEB0 U+8B54 # [2000] +0xEEB1 U+8B59 # [2000] +0xEEB2 U+8B69 # [2000] +0xEEB3 U+8B9D # [2000] +0xEEB4 U+8C49 # [2000] +0xEEB5 U+8C68 # [2000] +0xEEB6 U+FA64 # CJK COMPATIBILITY IDEOGRAPH-FA64 [2000] [Unicode3.2] +0xEEB7 U+8CE1 # [2000] +0xEEB8 U+8CF4 # [2000] +0xEEB9 U+8CF8 # [2000] +0xEEBA U+8CFE # [2000] +0xEEBB U+FA65 # CJK COMPATIBILITY IDEOGRAPH-FA65 [2000] [Unicode3.2] +0xEEBC U+8D12 # [2000] +0xEEBD U+8D1B # [2000] +0xEEBE U+8DAF # [2000] +0xEEBF U+8DCE # [2000] +0xEEC0 U+8DD1 # [2000] +0xEEC1 U+8DD7 # [2000] +0xEEC2 U+8E20 # [2000] +0xEEC3 U+8E23 # [2000] +0xEEC4 U+8E3D # [2000] +0xEEC5 U+8E70 # [2000] +0xEEC6 U+8E7B # [2000] +0xEEC7 U+28277 # [2000] [Unicode3.1] +0xEEC8 U+8EC0 # [2000] +0xEEC9 U+4844 # [2000] +0xEECA U+8EFA # [2000] +0xEECB U+8F1E # [2000] +0xEECC U+8F2D # [2000] +0xEECD U+8F36 # [2000] +0xEECE U+8F54 # [2000] +0xEECF U+283CD # [2000] [Unicode3.1] +0xEED0 U+8FA6 # [2000] +0xEED1 U+8FB5 # [2000] +0xEED2 U+8FE4 # [2000] +0xEED3 U+8FE8 # [2000] +0xEED4 U+8FEE # [2000] +0xEED5 U+9008 # [2000] +0xEED6 U+902D # [2000] +0xEED7 U+FA67 # CJK COMPATIBILITY IDEOGRAPH-FA67 [2000] [Unicode3.2] +0xEED8 U+9088 # [2000] +0xEED9 U+9095 # [2000] +0xEEDA U+9097 # [2000] +0xEEDB U+9099 # [2000] +0xEEDC U+909B # [2000] +0xEEDD U+90A2 # [2000] +0xEEDE U+90B3 # [2000] +0xEEDF U+90BE # [2000] +0xEEE0 U+90C4 # [2000] +0xEEE1 U+90C5 # [2000] +0xEEE2 U+90C7 # [2000] +0xEEE3 U+90D7 # [2000] +0xEEE4 U+90DD # [2000] +0xEEE5 U+90DE # [2000] +0xEEE6 U+90EF # [2000] +0xEEE7 U+90F4 # [2000] +0xEEE8 U+FA26 # CJK COMPATIBILITY IDEOGRAPH-FA26 [2000] +0xEEE9 U+9114 # [2000] +0xEEEA U+9115 # [2000] +0xEEEB U+9116 # [2000] +0xEEEC U+9122 # [2000] +0xEEED U+9123 # [2000] +0xEEEE U+9127 # [2000] +0xEEEF U+912F # [2000] +0xEEF0 U+9131 # [2000] +0xEEF1 U+9134 # [2000] +0xEEF2 U+913D # [2000] +0xEEF3 U+9148 # [2000] +0xEEF4 U+915B # [2000] +0xEEF5 U+9183 # [2000] +0xEEF6 U+919E # [2000] +0xEEF7 U+91AC # [2000] +0xEEF8 U+91B1 # [2000] +0xEEF9 U+91BC # [2000] +0xEEFA U+91D7 # [2000] +0xEEFB U+91FB # [2000] +0xEEFC U+91E4 # [2000] +0xEF40 U+91E5 # [2000] +0xEF41 U+91ED # [2000] +0xEF42 U+91F1 # [2000] +0xEF43 U+9207 # [2000] +0xEF44 U+9210 # [2000] +0xEF45 U+9238 # [2000] +0xEF46 U+9239 # [2000] +0xEF47 U+923A # [2000] +0xEF48 U+923C # [2000] +0xEF49 U+9240 # [2000] +0xEF4A U+9243 # [2000] +0xEF4B U+924F # [2000] +0xEF4C U+9278 # [2000] +0xEF4D U+9288 # [2000] +0xEF4E U+92C2 # [2000] +0xEF4F U+92CB # [2000] +0xEF50 U+92CC # [2000] +0xEF51 U+92D3 # [2000] +0xEF52 U+92E0 # [2000] +0xEF53 U+92FF # [2000] +0xEF54 U+9304 # [2000] +0xEF55 U+931F # [2000] +0xEF56 U+9321 # [2000] +0xEF57 U+9325 # [2000] +0xEF58 U+9348 # [2000] +0xEF59 U+9349 # [2000] +0xEF5A U+934A # [2000] +0xEF5B U+9364 # [2000] +0xEF5C U+9365 # [2000] +0xEF5D U+936A # [2000] +0xEF5E U+9370 # [2000] +0xEF5F U+939B # [2000] +0xEF60 U+93A3 # [2000] +0xEF61 U+93BA # [2000] +0xEF62 U+93C6 # [2000] +0xEF63 U+93DE # [2000] +0xEF64 U+93DF # [2000] +0xEF65 U+9404 # [2000] +0xEF66 U+93FD # [2000] +0xEF67 U+9433 # [2000] +0xEF68 U+944A # [2000] +0xEF69 U+9463 # [2000] +0xEF6A U+946B # [2000] +0xEF6B U+9471 # [2000] +0xEF6C U+9472 # [2000] +0xEF6D U+958E # [2000] +0xEF6E U+959F # [2000] +0xEF6F U+95A6 # [2000] +0xEF70 U+95A9 # [2000] +0xEF71 U+95AC # [2000] +0xEF72 U+95B6 # [2000] +0xEF73 U+95BD # [2000] +0xEF74 U+95CB # [2000] +0xEF75 U+95D0 # [2000] +0xEF76 U+95D3 # [2000] +0xEF77 U+49B0 # [2000] +0xEF78 U+95DA # [2000] +0xEF79 U+95DE # [2000] +0xEF7A U+9658 # [2000] +0xEF7B U+9684 # [2000] +0xEF7C U+F9DC # CJK COMPATIBILITY IDEOGRAPH-F9DC [2000] +0xEF7D U+969D # [2000] +0xEF7E U+96A4 # [2000] +0xEF80 U+96A5 # [2000] +0xEF81 U+96D2 # [2000] +0xEF82 U+96DE # [2000] +0xEF83 U+FA68 # CJK COMPATIBILITY IDEOGRAPH-FA68 [2000] [Unicode3.2] +0xEF84 U+96E9 # [2000] +0xEF85 U+96EF # [2000] +0xEF86 U+9733 # [2000] +0xEF87 U+973B # [2000] +0xEF88 U+974D # [2000] +0xEF89 U+974E # [2000] +0xEF8A U+974F # [2000] +0xEF8B U+975A # [2000] +0xEF8C U+976E # [2000] +0xEF8D U+9773 # [2000] +0xEF8E U+9795 # [2000] +0xEF8F U+97AE # [2000] +0xEF90 U+97BA # [2000] +0xEF91 U+97C1 # [2000] +0xEF92 U+97C9 # [2000] +0xEF93 U+97DE # [2000] +0xEF94 U+97DB # [2000] +0xEF95 U+97F4 # [2000] +0xEF96 U+FA69 # CJK COMPATIBILITY IDEOGRAPH-FA69 [2000] [Unicode3.2] +0xEF97 U+980A # [2000] +0xEF98 U+981E # [2000] +0xEF99 U+982B # [2000] +0xEF9A U+9830 # [2000] +0xEF9B U+FA6A # CJK COMPATIBILITY IDEOGRAPH-FA6A [2000] [Unicode3.2] +0xEF9C U+9852 # [2000] +0xEF9D U+9853 # [2000] +0xEF9E U+9856 # [2000] +0xEF9F U+9857 # [2000] +0xEFA0 U+9859 # [2000] +0xEFA1 U+985A # [2000] +0xEFA2 U+F9D0 # CJK COMPATIBILITY IDEOGRAPH-F9D0 [2000] +0xEFA3 U+9865 # [2000] +0xEFA4 U+986C # [2000] +0xEFA5 U+98BA # [2000] +0xEFA6 U+98C8 # [2000] +0xEFA7 U+98E7 # [2000] +0xEFA8 U+9958 # [2000] +0xEFA9 U+999E # [2000] +0xEFAA U+9A02 # [2000] +0xEFAB U+9A03 # [2000] +0xEFAC U+9A24 # [2000] +0xEFAD U+9A2D # [2000] +0xEFAE U+9A2E # [2000] +0xEFAF U+9A38 # [2000] +0xEFB0 U+9A4A # [2000] +0xEFB1 U+9A4E # [2000] +0xEFB2 U+9A52 # [2000] +0xEFB3 U+9AB6 # [2000] +0xEFB4 U+9AC1 # [2000] +0xEFB5 U+9AC3 # [2000] +0xEFB6 U+9ACE # [2000] +0xEFB7 U+9AD6 # [2000] +0xEFB8 U+9AF9 # [2000] +0xEFB9 U+9B02 # [2000] +0xEFBA U+9B08 # [2000] +0xEFBB U+9B20 # [2000] +0xEFBC U+4C17 # [2000] +0xEFBD U+9B2D # [2000] +0xEFBE U+9B5E # [2000] +0xEFBF U+9B79 # [2000] +0xEFC0 U+9B66 # [2000] +0xEFC1 U+9B72 # [2000] +0xEFC2 U+9B75 # [2000] +0xEFC3 U+9B84 # [2000] +0xEFC4 U+9B8A # [2000] +0xEFC5 U+9B8F # [2000] +0xEFC6 U+9B9E # [2000] +0xEFC7 U+9BA7 # [2000] +0xEFC8 U+9BC1 # [2000] +0xEFC9 U+9BCE # [2000] +0xEFCA U+9BE5 # [2000] +0xEFCB U+9BF8 # [2000] +0xEFCC U+9BFD # [2000] +0xEFCD U+9C00 # [2000] +0xEFCE U+9C23 # [2000] +0xEFCF U+9C41 # [2000] +0xEFD0 U+9C4F # [2000] +0xEFD1 U+9C50 # [2000] +0xEFD2 U+9C53 # [2000] +0xEFD3 U+9C63 # [2000] +0xEFD4 U+9C65 # [2000] +0xEFD5 U+9C77 # [2000] +0xEFD6 U+9D1D # [2000] +0xEFD7 U+9D1E # [2000] +0xEFD8 U+9D43 # [2000] +0xEFD9 U+9D47 # [2000] +0xEFDA U+9D52 # [2000] +0xEFDB U+9D63 # [2000] +0xEFDC U+9D70 # [2000] +0xEFDD U+9D7C # [2000] +0xEFDE U+9D8A # [2000] +0xEFDF U+9D96 # [2000] +0xEFE0 U+9DC0 # [2000] +0xEFE1 U+9DAC # [2000] +0xEFE2 U+9DBC # [2000] +0xEFE3 U+9DD7 # [2000] +0xEFE4 U+2A190 # [2000] [Unicode3.1] +0xEFE5 U+9DE7 # [2000] +0xEFE6 U+9E07 # [2000] +0xEFE7 U+9E15 # [2000] +0xEFE8 U+9E7C # [2000] +0xEFE9 U+9E9E # [2000] +0xEFEA U+9EA4 # [2000] +0xEFEB U+9EAC # [2000] +0xEFEC U+9EAF # [2000] +0xEFED U+9EB4 # [2000] +0xEFEE U+9EB5 # [2000] +0xEFEF U+9EC3 # [2000] +0xEFF0 U+9ED1 # [2000] +0xEFF1 U+9F10 # [2000] +0xEFF2 U+9F39 # [2000] +0xEFF3 U+9F57 # [2000] +0xEFF4 U+9F90 # [2000] +0xEFF5 U+9F94 # [2000] +0xEFF6 U+9F97 # [2000] +0xEFF7 U+9FA2 # [2000] +0xEFF8 U+59F8 # [2004] +0xEFF9 U+5C5B # [2004] +0xEFFA U+5E77 # [2004] +0xEFFB U+7626 # [2004] +0xEFFC U+7E6B # [2004] +0xF040 U+20089 # [2000] [Unicode3.1] +0xF041 U+4E02 # [2000] +0xF042 U+4E0F # [2000] +0xF043 U+4E12 # [2000] +0xF044 U+4E29 # [2000] +0xF045 U+4E2B # [2000] +0xF046 U+4E2E # [2000] +0xF047 U+4E40 # [2000] +0xF048 U+4E47 # [2000] +0xF049 U+4E48 # [2000] +0xF04A U+200A2 # [2000] [Unicode3.1] +0xF04B U+4E51 # [2000] +0xF04C U+3406 # [2000] +0xF04D U+200A4 # [2000] [Unicode3.1] +0xF04E U+4E5A # [2000] +0xF04F U+4E69 # [2000] +0xF050 U+4E9D # [2000] +0xF051 U+342C # [2000] +0xF052 U+342E # [2000] +0xF053 U+4EB9 # [2000] +0xF054 U+4EBB # [2000] +0xF055 U+201A2 # [2000] [Unicode3.1] +0xF056 U+4EBC # [2000] +0xF057 U+4EC3 # [2000] +0xF058 U+4EC8 # [2000] +0xF059 U+4ED0 # [2000] +0xF05A U+4EEB # [2000] +0xF05B U+4EDA # [2000] +0xF05C U+4EF1 # [2000] +0xF05D U+4EF5 # [2000] +0xF05E U+4F00 # [2000] +0xF05F U+4F16 # [2000] +0xF060 U+4F64 # [2000] +0xF061 U+4F37 # [2000] +0xF062 U+4F3E # [2000] +0xF063 U+4F54 # [2000] +0xF064 U+4F58 # [2000] +0xF065 U+20213 # [2000] [Unicode3.1] +0xF066 U+4F77 # [2000] +0xF067 U+4F78 # [2000] +0xF068 U+4F7A # [2000] +0xF069 U+4F7D # [2000] +0xF06A U+4F82 # [2000] +0xF06B U+4F85 # [2000] +0xF06C U+4F92 # [2000] +0xF06D U+4F9A # [2000] +0xF06E U+4FE6 # [2000] +0xF06F U+4FB2 # [2000] +0xF070 U+4FBE # [2000] +0xF071 U+4FC5 # [2000] +0xF072 U+4FCB # [2000] +0xF073 U+4FCF # [2000] +0xF074 U+4FD2 # [2000] +0xF075 U+346A # [2000] +0xF076 U+4FF2 # [2000] +0xF077 U+5000 # [2000] +0xF078 U+5010 # [2000] +0xF079 U+5013 # [2000] +0xF07A U+501C # [2000] +0xF07B U+501E # [2000] +0xF07C U+5022 # [2000] +0xF07D U+3468 # [2000] +0xF07E U+5042 # [2000] +0xF080 U+5046 # [2000] +0xF081 U+504E # [2000] +0xF082 U+5053 # [2000] +0xF083 U+5057 # [2000] +0xF084 U+5063 # [2000] +0xF085 U+5066 # [2000] +0xF086 U+506A # [2000] +0xF087 U+5070 # [2000] +0xF088 U+50A3 # [2000] +0xF089 U+5088 # [2000] +0xF08A U+5092 # [2000] +0xF08B U+5093 # [2000] +0xF08C U+5095 # [2000] +0xF08D U+5096 # [2000] +0xF08E U+509C # [2000] +0xF08F U+50AA # [2000] +0xF090 U+2032B # [2000] [Unicode3.1] +0xF091 U+50B1 # [2000] +0xF092 U+50BA # [2000] +0xF093 U+50BB # [2000] +0xF094 U+50C4 # [2000] +0xF095 U+50C7 # [2000] +0xF096 U+50F3 # [2000] +0xF097 U+20381 # [2000] [Unicode3.1] +0xF098 U+50CE # [2000] +0xF099 U+20371 # [2000] [Unicode3.1] +0xF09A U+50D4 # [2000] +0xF09B U+50D9 # [2000] +0xF09C U+50E1 # [2000] +0xF09D U+50E9 # [2000] +0xF09E U+3492 # [2000] +0xF09F U+5B96 # [2000] +0xF0A0 U+5BAC # [2000] +0xF0A1 U+3761 # [2000] +0xF0A2 U+5BC0 # [2000] +0xF0A3 U+3762 # [2000] +0xF0A4 U+5BCE # [2000] +0xF0A5 U+5BD6 # [2000] +0xF0A6 U+376C # [2000] +0xF0A7 U+376B # [2000] +0xF0A8 U+5BF1 # [2000] +0xF0A9 U+5BFD # [2000] +0xF0AA U+3775 # [2000] +0xF0AB U+5C03 # [2000] +0xF0AC U+5C29 # [2000] +0xF0AD U+5C30 # [2000] +0xF0AE U+21C56 # [2000] [Unicode3.1] +0xF0AF U+5C5F # [2000] +0xF0B0 U+5C63 # [2000] +0xF0B1 U+5C67 # [2000] +0xF0B2 U+5C68 # [2000] +0xF0B3 U+5C69 # [2000] +0xF0B4 U+5C70 # [2000] +0xF0B5 U+21D2D # [2000] [Unicode3.1] +0xF0B6 U+21D45 # [2000] [Unicode3.1] +0xF0B7 U+5C7C # [2000] +0xF0B8 U+21D78 # [2000] [Unicode3.1] +0xF0B9 U+21D62 # [2000] [Unicode3.1] +0xF0BA U+5C88 # [2000] +0xF0BB U+5C8A # [2000] +0xF0BC U+37C1 # [2000] +0xF0BD U+21DA1 # [2000] [Unicode3.1] +0xF0BE U+21D9C # [2000] [Unicode3.1] +0xF0BF U+5CA0 # [2000] +0xF0C0 U+5CA2 # [2000] +0xF0C1 U+5CA6 # [2000] +0xF0C2 U+5CA7 # [2000] +0xF0C3 U+21D92 # [2000] [Unicode3.1] +0xF0C4 U+5CAD # [2000] +0xF0C5 U+5CB5 # [2000] +0xF0C6 U+21DB7 # [2000] [Unicode3.1] +0xF0C7 U+5CC9 # [2000] +0xF0C8 U+21DE0 # [2000] [Unicode3.1] +0xF0C9 U+21E33 # [2000] [Unicode3.1] +0xF0CA U+5D06 # [2000] +0xF0CB U+5D10 # [2000] +0xF0CC U+5D2B # [2000] +0xF0CD U+5D1D # [2000] +0xF0CE U+5D20 # [2000] +0xF0CF U+5D24 # [2000] +0xF0D0 U+5D26 # [2000] +0xF0D1 U+5D31 # [2000] +0xF0D2 U+5D39 # [2000] +0xF0D3 U+5D42 # [2000] +0xF0D4 U+37E8 # [2000] +0xF0D5 U+5D61 # [2000] +0xF0D6 U+5D6A # [2000] +0xF0D7 U+37F4 # [2000] +0xF0D8 U+5D70 # [2000] +0xF0D9 U+21F1E # [2000] [Unicode3.1] +0xF0DA U+37FD # [2000] +0xF0DB U+5D88 # [2000] +0xF0DC U+3800 # [2000] +0xF0DD U+5D92 # [2000] +0xF0DE U+5D94 # [2000] +0xF0DF U+5D97 # [2000] +0xF0E0 U+5D99 # [2000] +0xF0E1 U+5DB0 # [2000] +0xF0E2 U+5DB2 # [2000] +0xF0E3 U+5DB4 # [2000] +0xF0E4 U+21F76 # [2000] [Unicode3.1] +0xF0E5 U+5DB9 # [2000] +0xF0E6 U+5DD1 # [2000] +0xF0E7 U+5DD7 # [2000] +0xF0E8 U+5DD8 # [2000] +0xF0E9 U+5DE0 # [2000] +0xF0EA U+21FFA # [2000] [Unicode3.1] +0xF0EB U+5DE4 # [2000] +0xF0EC U+5DE9 # [2000] +0xF0ED U+382F # [2000] +0xF0EE U+5E00 # [2000] +0xF0EF U+3836 # [2000] +0xF0F0 U+5E12 # [2000] +0xF0F1 U+5E15 # [2000] +0xF0F2 U+3840 # [2000] +0xF0F3 U+5E1F # [2000] +0xF0F4 U+5E2E # [2000] +0xF0F5 U+5E3E # [2000] +0xF0F6 U+5E49 # [2000] +0xF0F7 U+385C # [2000] +0xF0F8 U+5E56 # [2000] +0xF0F9 U+3861 # [2000] +0xF0FA U+5E6B # [2000] +0xF0FB U+5E6C # [2000] +0xF0FC U+5E6D # [2000] +0xF140 U+5108 # [2000] +0xF141 U+203F9 # [2000] [Unicode3.1] +0xF142 U+5117 # [2000] +0xF143 U+511B # [2000] +0xF144 U+2044A # [2000] [Unicode3.1] +0xF145 U+5160 # [2000] +0xF146 U+20509 # [2000] [Unicode3.1] +0xF147 U+5173 # [2000] +0xF148 U+5183 # [2000] +0xF149 U+518B # [2000] +0xF14A U+34BC # [2000] +0xF14B U+5198 # [2000] +0xF14C U+51A3 # [2000] +0xF14D U+51AD # [2000] +0xF14E U+34C7 # [2000] +0xF14F U+51BC # [2000] +0xF150 U+205D6 # [2000] [Unicode3.1] +0xF151 U+20628 # [2000] [Unicode3.1] +0xF152 U+51F3 # [2000] +0xF153 U+51F4 # [2000] +0xF154 U+5202 # [2000] +0xF155 U+5212 # [2000] +0xF156 U+5216 # [2000] +0xF157 U+2074F # [2000] [Unicode3.1] +0xF158 U+5255 # [2000] +0xF159 U+525C # [2000] +0xF15A U+526C # [2000] +0xF15B U+5277 # [2000] +0xF15C U+5284 # [2000] +0xF15D U+5282 # [2000] +0xF15E U+20807 # [2000] [Unicode3.1] +0xF15F U+5298 # [2000] +0xF160 U+2083A # [2000] [Unicode3.1] +0xF161 U+52A4 # [2000] +0xF162 U+52A6 # [2000] +0xF163 U+52AF # [2000] +0xF164 U+52BA # [2000] +0xF165 U+52BB # [2000] +0xF166 U+52CA # [2000] +0xF167 U+351F # [2000] +0xF168 U+52D1 # [2000] +0xF169 U+208B9 # [2000] [Unicode3.1] +0xF16A U+52F7 # [2000] +0xF16B U+530A # [2000] +0xF16C U+530B # [2000] +0xF16D U+5324 # [2000] +0xF16E U+5335 # [2000] +0xF16F U+533E # [2000] +0xF170 U+5342 # [2000] +0xF171 U+2097C # [2000] [Unicode3.1] +0xF172 U+2099D # [2000] [Unicode3.1] +0xF173 U+5367 # [2000] +0xF174 U+536C # [2000] +0xF175 U+537A # [2000] +0xF176 U+53A4 # [2000] +0xF177 U+53B4 # [2000] +0xF178 U+20AD3 # [2000] [Unicode3.1] +0xF179 U+53B7 # [2000] +0xF17A U+53C0 # [2000] +0xF17B U+20B1D # [2000] [Unicode3.1] +0xF17C U+355D # [2000] +0xF17D U+355E # [2000] +0xF17E U+53D5 # [2000] +0xF180 U+53DA # [2000] +0xF181 U+3563 # [2000] +0xF182 U+53F4 # [2000] +0xF183 U+53F5 # [2000] +0xF184 U+5455 # [2000] +0xF185 U+5424 # [2000] +0xF186 U+5428 # [2000] +0xF187 U+356E # [2000] +0xF188 U+5443 # [2000] +0xF189 U+5462 # [2000] +0xF18A U+5466 # [2000] +0xF18B U+546C # [2000] +0xF18C U+548A # [2000] +0xF18D U+548D # [2000] +0xF18E U+5495 # [2000] +0xF18F U+54A0 # [2000] +0xF190 U+54A6 # [2000] +0xF191 U+54AD # [2000] +0xF192 U+54AE # [2000] +0xF193 U+54B7 # [2000] +0xF194 U+54BA # [2000] +0xF195 U+54BF # [2000] +0xF196 U+54C3 # [2000] +0xF197 U+20D45 # [2000] [Unicode3.1] +0xF198 U+54EC # [2000] +0xF199 U+54EF # [2000] +0xF19A U+54F1 # [2000] +0xF19B U+54F3 # [2000] +0xF19C U+5500 # [2000] +0xF19D U+5501 # [2000] +0xF19E U+5509 # [2000] +0xF19F U+553C # [2000] +0xF1A0 U+5541 # [2000] +0xF1A1 U+35A6 # [2000] +0xF1A2 U+5547 # [2000] +0xF1A3 U+554A # [2000] +0xF1A4 U+35A8 # [2000] +0xF1A5 U+5560 # [2000] +0xF1A6 U+5561 # [2000] +0xF1A7 U+5564 # [2000] +0xF1A8 U+20DE1 # [2000] [Unicode3.1] +0xF1A9 U+557D # [2000] +0xF1AA U+5582 # [2000] +0xF1AB U+5588 # [2000] +0xF1AC U+5591 # [2000] +0xF1AD U+35C5 # [2000] +0xF1AE U+55D2 # [2000] +0xF1AF U+20E95 # [2000] [Unicode3.1] +0xF1B0 U+20E6D # [2000] [Unicode3.1] +0xF1B1 U+55BF # [2000] +0xF1B2 U+55C9 # [2000] +0xF1B3 U+55CC # [2000] +0xF1B4 U+55D1 # [2000] +0xF1B5 U+55DD # [2000] +0xF1B6 U+35DA # [2000] +0xF1B7 U+55E2 # [2000] +0xF1B8 U+20E64 # [2000] [Unicode3.1] +0xF1B9 U+55E9 # [2000] +0xF1BA U+5628 # [2000] +0xF1BB U+20F5F # [2000] [Unicode3.1] +0xF1BC U+5607 # [2000] +0xF1BD U+5610 # [2000] +0xF1BE U+5630 # [2000] +0xF1BF U+5637 # [2000] +0xF1C0 U+35F4 # [2000] +0xF1C1 U+563D # [2000] +0xF1C2 U+563F # [2000] +0xF1C3 U+5640 # [2000] +0xF1C4 U+5647 # [2000] +0xF1C5 U+565E # [2000] +0xF1C6 U+5660 # [2000] +0xF1C7 U+566D # [2000] +0xF1C8 U+3605 # [2000] +0xF1C9 U+5688 # [2000] +0xF1CA U+568C # [2000] +0xF1CB U+5695 # [2000] +0xF1CC U+569A # [2000] +0xF1CD U+569D # [2000] +0xF1CE U+56A8 # [2000] +0xF1CF U+56AD # [2000] +0xF1D0 U+56B2 # [2000] +0xF1D1 U+56C5 # [2000] +0xF1D2 U+56CD # [2000] +0xF1D3 U+56DF # [2000] +0xF1D4 U+56E8 # [2000] +0xF1D5 U+56F6 # [2000] +0xF1D6 U+56F7 # [2000] +0xF1D7 U+21201 # [2000] [Unicode3.1] +0xF1D8 U+5715 # [2000] +0xF1D9 U+5723 # [2000] +0xF1DA U+21255 # [2000] [Unicode3.1] +0xF1DB U+5729 # [2000] +0xF1DC U+2127B # [2000] [Unicode3.1] +0xF1DD U+5745 # [2000] +0xF1DE U+5746 # [2000] +0xF1DF U+574C # [2000] +0xF1E0 U+574D # [2000] +0xF1E1 U+21274 # [2000] [Unicode3.1] +0xF1E2 U+5768 # [2000] +0xF1E3 U+576F # [2000] +0xF1E4 U+5773 # [2000] +0xF1E5 U+5774 # [2000] +0xF1E6 U+5775 # [2000] +0xF1E7 U+577B # [2000] +0xF1E8 U+212E4 # [2000] [Unicode3.1] +0xF1E9 U+212D7 # [2000] [Unicode3.1] +0xF1EA U+57AC # [2000] +0xF1EB U+579A # [2000] +0xF1EC U+579D # [2000] +0xF1ED U+579E # [2000] +0xF1EE U+57A8 # [2000] +0xF1EF U+57D7 # [2000] +0xF1F0 U+212FD # [2000] [Unicode3.1] +0xF1F1 U+57CC # [2000] +0xF1F2 U+21336 # [2000] [Unicode3.1] +0xF1F3 U+21344 # [2000] [Unicode3.1] +0xF1F4 U+57DE # [2000] +0xF1F5 U+57E6 # [2000] +0xF1F6 U+57F0 # [2000] +0xF1F7 U+364A # [2000] +0xF1F8 U+57F8 # [2000] +0xF1F9 U+57FB # [2000] +0xF1FA U+57FD # [2000] +0xF1FB U+5804 # [2000] +0xF1FC U+581E # [2000] +0xF240 U+5820 # [2000] +0xF241 U+5827 # [2000] +0xF242 U+5832 # [2000] +0xF243 U+5839 # [2000] +0xF244 U+213C4 # [2000] [Unicode3.1] +0xF245 U+5849 # [2000] +0xF246 U+584C # [2000] +0xF247 U+5867 # [2000] +0xF248 U+588A # [2000] +0xF249 U+588B # [2000] +0xF24A U+588D # [2000] +0xF24B U+588F # [2000] +0xF24C U+5890 # [2000] +0xF24D U+5894 # [2000] +0xF24E U+589D # [2000] +0xF24F U+58AA # [2000] +0xF250 U+58B1 # [2000] +0xF251 U+2146D # [2000] [Unicode3.1] +0xF252 U+58C3 # [2000] +0xF253 U+58CD # [2000] +0xF254 U+58E2 # [2000] +0xF255 U+58F3 # [2000] +0xF256 U+58F4 # [2000] +0xF257 U+5905 # [2000] +0xF258 U+5906 # [2000] +0xF259 U+590B # [2000] +0xF25A U+590D # [2000] +0xF25B U+5914 # [2000] +0xF25C U+5924 # [2000] +0xF25D U+215D7 # [2000] [Unicode3.1] +0xF25E U+3691 # [2000] +0xF25F U+593D # [2000] +0xF260 U+3699 # [2000] +0xF261 U+5946 # [2000] +0xF262 U+3696 # [2000] +0xF263 U+26C29 # [2000] [Unicode3.1] +0xF264 U+595B # [2000] +0xF265 U+595F # [2000] +0xF266 U+21647 # [2000] [Unicode3.1] +0xF267 U+5975 # [2000] +0xF268 U+5976 # [2000] +0xF269 U+597C # [2000] +0xF26A U+599F # [2000] +0xF26B U+59AE # [2000] +0xF26C U+59BC # [2000] +0xF26D U+59C8 # [2000] +0xF26E U+59CD # [2000] +0xF26F U+59DE # [2000] +0xF270 U+59E3 # [2000] +0xF271 U+59E4 # [2000] +0xF272 U+59E7 # [2000] +0xF273 U+59EE # [2000] +0xF274 U+21706 # [2000] [Unicode3.1] +0xF275 U+21742 # [2000] [Unicode3.1] +0xF276 U+36CF # [2000] +0xF277 U+5A0C # [2000] +0xF278 U+5A0D # [2000] +0xF279 U+5A17 # [2000] +0xF27A U+5A27 # [2000] +0xF27B U+5A2D # [2000] +0xF27C U+5A55 # [2000] +0xF27D U+5A65 # [2000] +0xF27E U+5A7A # [2000] +0xF280 U+5A8B # [2000] +0xF281 U+5A9C # [2000] +0xF282 U+5A9F # [2000] +0xF283 U+5AA0 # [2000] +0xF284 U+5AA2 # [2000] +0xF285 U+5AB1 # [2000] +0xF286 U+5AB3 # [2000] +0xF287 U+5AB5 # [2000] +0xF288 U+5ABA # [2000] +0xF289 U+5ABF # [2000] +0xF28A U+5ADA # [2000] +0xF28B U+5ADC # [2000] +0xF28C U+5AE0 # [2000] +0xF28D U+5AE5 # [2000] +0xF28E U+5AF0 # [2000] +0xF28F U+5AEE # [2000] +0xF290 U+5AF5 # [2000] +0xF291 U+5B00 # [2000] +0xF292 U+5B08 # [2000] +0xF293 U+5B17 # [2000] +0xF294 U+5B34 # [2000] +0xF295 U+5B2D # [2000] +0xF296 U+5B4C # [2000] +0xF297 U+5B52 # [2000] +0xF298 U+5B68 # [2000] +0xF299 U+5B6F # [2000] +0xF29A U+5B7C # [2000] +0xF29B U+5B7F # [2000] +0xF29C U+5B81 # [2000] +0xF29D U+5B84 # [2000] +0xF29E U+219C3 # [2000] [Unicode3.1] +0xF29F U+5E6E # [2000] +0xF2A0 U+2217B # [2000] [Unicode3.1] +0xF2A1 U+5EA5 # [2000] +0xF2A2 U+5EAA # [2000] +0xF2A3 U+5EAC # [2000] +0xF2A4 U+5EB9 # [2000] +0xF2A5 U+5EBF # [2000] +0xF2A6 U+5EC6 # [2000] +0xF2A7 U+5ED2 # [2000] +0xF2A8 U+5ED9 # [2000] +0xF2A9 U+2231E # [2000] [Unicode3.1] +0xF2AA U+5EFD # [2000] +0xF2AB U+5F08 # [2000] +0xF2AC U+5F0E # [2000] +0xF2AD U+5F1C # [2000] +0xF2AE U+223AD # [2000] [Unicode3.1] +0xF2AF U+5F1E # [2000] +0xF2B0 U+5F47 # [2000] +0xF2B1 U+5F63 # [2000] +0xF2B2 U+5F72 # [2000] +0xF2B3 U+5F7E # [2000] +0xF2B4 U+5F8F # [2000] +0xF2B5 U+5FA2 # [2000] +0xF2B6 U+5FA4 # [2000] +0xF2B7 U+5FB8 # [2000] +0xF2B8 U+5FC4 # [2000] +0xF2B9 U+38FA # [2000] +0xF2BA U+5FC7 # [2000] +0xF2BB U+5FCB # [2000] +0xF2BC U+5FD2 # [2000] +0xF2BD U+5FD3 # [2000] +0xF2BE U+5FD4 # [2000] +0xF2BF U+5FE2 # [2000] +0xF2C0 U+5FEE # [2000] +0xF2C1 U+5FEF # [2000] +0xF2C2 U+5FF3 # [2000] +0xF2C3 U+5FFC # [2000] +0xF2C4 U+3917 # [2000] +0xF2C5 U+6017 # [2000] +0xF2C6 U+6022 # [2000] +0xF2C7 U+6024 # [2000] +0xF2C8 U+391A # [2000] +0xF2C9 U+604C # [2000] +0xF2CA U+607F # [2000] +0xF2CB U+608A # [2000] +0xF2CC U+6095 # [2000] +0xF2CD U+60A8 # [2000] +0xF2CE U+226F3 # [2000] [Unicode3.1] +0xF2CF U+60B0 # [2000] +0xF2D0 U+60B1 # [2000] +0xF2D1 U+60BE # [2000] +0xF2D2 U+60C8 # [2000] +0xF2D3 U+60D9 # [2000] +0xF2D4 U+60DB # [2000] +0xF2D5 U+60EE # [2000] +0xF2D6 U+60F2 # [2000] +0xF2D7 U+60F5 # [2000] +0xF2D8 U+6110 # [2000] +0xF2D9 U+6112 # [2000] +0xF2DA U+6113 # [2000] +0xF2DB U+6119 # [2000] +0xF2DC U+611E # [2000] +0xF2DD U+613A # [2000] +0xF2DE U+396F # [2000] +0xF2DF U+6141 # [2000] +0xF2E0 U+6146 # [2000] +0xF2E1 U+6160 # [2000] +0xF2E2 U+617C # [2000] +0xF2E3 U+2285B # [2000] [Unicode3.1] +0xF2E4 U+6192 # [2000] +0xF2E5 U+6193 # [2000] +0xF2E6 U+6197 # [2000] +0xF2E7 U+6198 # [2000] +0xF2E8 U+61A5 # [2000] +0xF2E9 U+61A8 # [2000] +0xF2EA U+61AD # [2000] +0xF2EB U+228AB # [2000] [Unicode3.1] +0xF2EC U+61D5 # [2000] +0xF2ED U+61DD # [2000] +0xF2EE U+61DF # [2000] +0xF2EF U+61F5 # [2000] +0xF2F0 U+2298F # [2000] [Unicode3.1] +0xF2F1 U+6215 # [2000] +0xF2F2 U+6223 # [2000] +0xF2F3 U+6229 # [2000] +0xF2F4 U+6246 # [2000] +0xF2F5 U+624C # [2000] +0xF2F6 U+6251 # [2000] +0xF2F7 U+6252 # [2000] +0xF2F8 U+6261 # [2000] +0xF2F9 U+6264 # [2000] +0xF2FA U+627B # [2000] +0xF2FB U+626D # [2000] +0xF2FC U+6273 # [2000] +0xF340 U+6299 # [2000] +0xF341 U+62A6 # [2000] +0xF342 U+62D5 # [2000] +0xF343 U+22AB8 # [2000] [Unicode3.1] +0xF344 U+62FD # [2000] +0xF345 U+6303 # [2000] +0xF346 U+630D # [2000] +0xF347 U+6310 # [2000] +0xF348 U+22B4F # [2000] [Unicode3.1] +0xF349 U+22B50 # [2000] [Unicode3.1] +0xF34A U+6332 # [2000] +0xF34B U+6335 # [2000] +0xF34C U+633B # [2000] +0xF34D U+633C # [2000] +0xF34E U+6341 # [2000] +0xF34F U+6344 # [2000] +0xF350 U+634E # [2000] +0xF351 U+22B46 # [2000] [Unicode3.1] +0xF352 U+6359 # [2000] +0xF353 U+22C1D # [2000] [Unicode3.1] +0xF354 U+22BA6 # [2000] [Unicode3.1] +0xF355 U+636C # [2000] +0xF356 U+6384 # [2000] +0xF357 U+6399 # [2000] +0xF358 U+22C24 # [2000] [Unicode3.1] +0xF359 U+6394 # [2000] +0xF35A U+63BD # [2000] +0xF35B U+63F7 # [2000] +0xF35C U+63D4 # [2000] +0xF35D U+63D5 # [2000] +0xF35E U+63DC # [2000] +0xF35F U+63E0 # [2000] +0xF360 U+63EB # [2000] +0xF361 U+63EC # [2000] +0xF362 U+63F2 # [2000] +0xF363 U+6409 # [2000] +0xF364 U+641E # [2000] +0xF365 U+6425 # [2000] +0xF366 U+6429 # [2000] +0xF367 U+642F # [2000] +0xF368 U+645A # [2000] +0xF369 U+645B # [2000] +0xF36A U+645D # [2000] +0xF36B U+6473 # [2000] +0xF36C U+647D # [2000] +0xF36D U+6487 # [2000] +0xF36E U+6491 # [2000] +0xF36F U+649D # [2000] +0xF370 U+649F # [2000] +0xF371 U+64CB # [2000] +0xF372 U+64CC # [2000] +0xF373 U+64D5 # [2000] +0xF374 U+64D7 # [2000] +0xF375 U+22DE1 # [2000] [Unicode3.1] +0xF376 U+64E4 # [2000] +0xF377 U+64E5 # [2000] +0xF378 U+64FF # [2000] +0xF379 U+6504 # [2000] +0xF37A U+3A6E # [2000] +0xF37B U+650F # [2000] +0xF37C U+6514 # [2000] +0xF37D U+6516 # [2000] +0xF37E U+3A73 # [2000] +0xF380 U+651E # [2000] +0xF381 U+6532 # [2000] +0xF382 U+6544 # [2000] +0xF383 U+6554 # [2000] +0xF384 U+656B # [2000] +0xF385 U+657A # [2000] +0xF386 U+6581 # [2000] +0xF387 U+6584 # [2000] +0xF388 U+6585 # [2000] +0xF389 U+658A # [2000] +0xF38A U+65B2 # [2000] +0xF38B U+65B5 # [2000] +0xF38C U+65B8 # [2000] +0xF38D U+65BF # [2000] +0xF38E U+65C2 # [2000] +0xF38F U+65C9 # [2000] +0xF390 U+65D4 # [2000] +0xF391 U+3AD6 # [2000] +0xF392 U+65F2 # [2000] +0xF393 U+65F9 # [2000] +0xF394 U+65FC # [2000] +0xF395 U+6604 # [2000] +0xF396 U+6608 # [2000] +0xF397 U+6621 # [2000] +0xF398 U+662A # [2000] +0xF399 U+6645 # [2000] +0xF39A U+6651 # [2000] +0xF39B U+664E # [2000] +0xF39C U+3AEA # [2000] +0xF39D U+231C3 # [2000] [Unicode3.1] +0xF39E U+6657 # [2000] +0xF39F U+665B # [2000] +0xF3A0 U+6663 # [2000] +0xF3A1 U+231F5 # [2000] [Unicode3.1] +0xF3A2 U+231B6 # [2000] [Unicode3.1] +0xF3A3 U+666A # [2000] +0xF3A4 U+666B # [2000] +0xF3A5 U+666C # [2000] +0xF3A6 U+666D # [2000] +0xF3A7 U+667B # [2000] +0xF3A8 U+6680 # [2000] +0xF3A9 U+6690 # [2000] +0xF3AA U+6692 # [2000] +0xF3AB U+6699 # [2000] +0xF3AC U+3B0E # [2000] +0xF3AD U+66AD # [2000] +0xF3AE U+66B1 # [2000] +0xF3AF U+66B5 # [2000] +0xF3B0 U+3B1A # [2000] +0xF3B1 U+66BF # [2000] +0xF3B2 U+3B1C # [2000] +0xF3B3 U+66EC # [2000] +0xF3B4 U+3AD7 # [2000] +0xF3B5 U+6701 # [2000] +0xF3B6 U+6705 # [2000] +0xF3B7 U+6712 # [2000] +0xF3B8 U+23372 # [2000] [Unicode3.1] +0xF3B9 U+6719 # [2000] +0xF3BA U+233D3 # [2000] [Unicode3.1] +0xF3BB U+233D2 # [2000] [Unicode3.1] +0xF3BC U+674C # [2000] +0xF3BD U+674D # [2000] +0xF3BE U+6754 # [2000] +0xF3BF U+675D # [2000] +0xF3C0 U+233D0 # [2000] [Unicode3.1] +0xF3C1 U+233E4 # [2000] [Unicode3.1] +0xF3C2 U+233D5 # [2000] [Unicode3.1] +0xF3C3 U+6774 # [2000] +0xF3C4 U+6776 # [2000] +0xF3C5 U+233DA # [2000] [Unicode3.1] +0xF3C6 U+6792 # [2000] +0xF3C7 U+233DF # [2000] [Unicode3.1] +0xF3C8 U+8363 # [2000] +0xF3C9 U+6810 # [2000] +0xF3CA U+67B0 # [2000] +0xF3CB U+67B2 # [2000] +0xF3CC U+67C3 # [2000] +0xF3CD U+67C8 # [2000] +0xF3CE U+67D2 # [2000] +0xF3CF U+67D9 # [2000] +0xF3D0 U+67DB # [2000] +0xF3D1 U+67F0 # [2000] +0xF3D2 U+67F7 # [2000] +0xF3D3 U+2344A # [2000] [Unicode3.1] +0xF3D4 U+23451 # [2000] [Unicode3.1] +0xF3D5 U+2344B # [2000] [Unicode3.1] +0xF3D6 U+6818 # [2000] +0xF3D7 U+681F # [2000] +0xF3D8 U+682D # [2000] +0xF3D9 U+23465 # [2000] [Unicode3.1] +0xF3DA U+6833 # [2000] +0xF3DB U+683B # [2000] +0xF3DC U+683E # [2000] +0xF3DD U+6844 # [2000] +0xF3DE U+6845 # [2000] +0xF3DF U+6849 # [2000] +0xF3E0 U+684C # [2000] +0xF3E1 U+6855 # [2000] +0xF3E2 U+6857 # [2000] +0xF3E3 U+3B77 # [2000] +0xF3E4 U+686B # [2000] +0xF3E5 U+686E # [2000] +0xF3E6 U+687A # [2000] +0xF3E7 U+687C # [2000] +0xF3E8 U+6882 # [2000] +0xF3E9 U+6890 # [2000] +0xF3EA U+6896 # [2000] +0xF3EB U+3B6D # [2000] +0xF3EC U+6898 # [2000] +0xF3ED U+6899 # [2000] +0xF3EE U+689A # [2000] +0xF3EF U+689C # [2000] +0xF3F0 U+68AA # [2000] +0xF3F1 U+68AB # [2000] +0xF3F2 U+68B4 # [2000] +0xF3F3 U+68BB # [2000] +0xF3F4 U+68FB # [2000] +0xF3F5 U+234E4 # [2000] [Unicode3.1] +0xF3F6 U+2355A # [2000] [Unicode3.1] +0xF3F7 U+FA13 # CJK COMPATIBILITY IDEOGRAPH-FA13 [2000] +0xF3F8 U+68C3 # [2000] +0xF3F9 U+68C5 # [2000] +0xF3FA U+68CC # [2000] +0xF3FB U+68CF # [2000] +0xF3FC U+68D6 # [2000] +0xF440 U+68D9 # [2000] +0xF441 U+68E4 # [2000] +0xF442 U+68E5 # [2000] +0xF443 U+68EC # [2000] +0xF444 U+68F7 # [2000] +0xF445 U+6903 # [2000] +0xF446 U+6907 # [2000] +0xF447 U+3B87 # [2000] +0xF448 U+3B88 # [2000] +0xF449 U+23594 # [2000] [Unicode3.1] +0xF44A U+693B # [2000] +0xF44B U+3B8D # [2000] +0xF44C U+6946 # [2000] +0xF44D U+6969 # [2000] +0xF44E U+696C # [2000] +0xF44F U+6972 # [2000] +0xF450 U+697A # [2000] +0xF451 U+697F # [2000] +0xF452 U+6992 # [2000] +0xF453 U+3BA4 # [2000] +0xF454 U+6996 # [2000] +0xF455 U+6998 # [2000] +0xF456 U+69A6 # [2000] +0xF457 U+69B0 # [2000] +0xF458 U+69B7 # [2000] +0xF459 U+69BA # [2000] +0xF45A U+69BC # [2000] +0xF45B U+69C0 # [2000] +0xF45C U+69D1 # [2000] +0xF45D U+69D6 # [2000] +0xF45E U+23639 # [2000] [Unicode3.1] +0xF45F U+23647 # [2000] [Unicode3.1] +0xF460 U+6A30 # [2000] +0xF461 U+23638 # [2000] [Unicode3.1] +0xF462 U+2363A # [2000] [Unicode3.1] +0xF463 U+69E3 # [2000] +0xF464 U+69EE # [2000] +0xF465 U+69EF # [2000] +0xF466 U+69F3 # [2000] +0xF467 U+3BCD # [2000] +0xF468 U+69F4 # [2000] +0xF469 U+69FE # [2000] +0xF46A U+6A11 # [2000] +0xF46B U+6A1A # [2000] +0xF46C U+6A1D # [2000] +0xF46D U+2371C # [2000] [Unicode3.1] +0xF46E U+6A32 # [2000] +0xF46F U+6A33 # [2000] +0xF470 U+6A34 # [2000] +0xF471 U+6A3F # [2000] +0xF472 U+6A46 # [2000] +0xF473 U+6A49 # [2000] +0xF474 U+6A7A # [2000] +0xF475 U+6A4E # [2000] +0xF476 U+6A52 # [2000] +0xF477 U+6A64 # [2000] +0xF478 U+2370C # [2000] [Unicode3.1] +0xF479 U+6A7E # [2000] +0xF47A U+6A83 # [2000] +0xF47B U+6A8B # [2000] +0xF47C U+3BF0 # [2000] +0xF47D U+6A91 # [2000] +0xF47E U+6A9F # [2000] +0xF480 U+6AA1 # [2000] +0xF481 U+23764 # [2000] [Unicode3.1] +0xF482 U+6AAB # [2000] +0xF483 U+6ABD # [2000] +0xF484 U+6AC6 # [2000] +0xF485 U+6AD4 # [2000] +0xF486 U+6AD0 # [2000] +0xF487 U+6ADC # [2000] +0xF488 U+6ADD # [2000] +0xF489 U+237FF # [2000] [Unicode3.1] +0xF48A U+237E7 # [2000] [Unicode3.1] +0xF48B U+6AEC # [2000] +0xF48C U+6AF1 # [2000] +0xF48D U+6AF2 # [2000] +0xF48E U+6AF3 # [2000] +0xF48F U+6AFD # [2000] +0xF490 U+23824 # [2000] [Unicode3.1] +0xF491 U+6B0B # [2000] +0xF492 U+6B0F # [2000] +0xF493 U+6B10 # [2000] +0xF494 U+6B11 # [2000] +0xF495 U+2383D # [2000] [Unicode3.1] +0xF496 U+6B17 # [2000] +0xF497 U+3C26 # [2000] +0xF498 U+6B2F # [2000] +0xF499 U+6B4A # [2000] +0xF49A U+6B58 # [2000] +0xF49B U+6B6C # [2000] +0xF49C U+6B75 # [2000] +0xF49D U+6B7A # [2000] +0xF49E U+6B81 # [2000] +0xF49F U+6B9B # [2000] +0xF4A0 U+6BAE # [2000] +0xF4A1 U+23A98 # [2000] [Unicode3.1] +0xF4A2 U+6BBD # [2000] +0xF4A3 U+6BBE # [2000] +0xF4A4 U+6BC7 # [2000] +0xF4A5 U+6BC8 # [2000] +0xF4A6 U+6BC9 # [2000] +0xF4A7 U+6BDA # [2000] +0xF4A8 U+6BE6 # [2000] +0xF4A9 U+6BE7 # [2000] +0xF4AA U+6BEE # [2000] +0xF4AB U+6BF1 # [2000] +0xF4AC U+6C02 # [2000] +0xF4AD U+6C0A # [2000] +0xF4AE U+6C0E # [2000] +0xF4AF U+6C35 # [2000] +0xF4B0 U+6C36 # [2000] +0xF4B1 U+6C3A # [2000] +0xF4B2 U+23C7F # [2000] [Unicode3.1] +0xF4B3 U+6C3F # [2000] +0xF4B4 U+6C4D # [2000] +0xF4B5 U+6C5B # [2000] +0xF4B6 U+6C6D # [2000] +0xF4B7 U+6C84 # [2000] +0xF4B8 U+6C89 # [2000] +0xF4B9 U+3CC3 # [2000] +0xF4BA U+6C94 # [2000] +0xF4BB U+6C95 # [2000] +0xF4BC U+6C97 # [2000] +0xF4BD U+6CAD # [2000] +0xF4BE U+6CC2 # [2000] +0xF4BF U+6CD0 # [2000] +0xF4C0 U+3CD2 # [2000] +0xF4C1 U+6CD6 # [2000] +0xF4C2 U+6CDA # [2000] +0xF4C3 U+6CDC # [2000] +0xF4C4 U+6CE9 # [2000] +0xF4C5 U+6CEC # [2000] +0xF4C6 U+6CED # [2000] +0xF4C7 U+23D00 # [2000] [Unicode3.1] +0xF4C8 U+6D00 # [2000] +0xF4C9 U+6D0A # [2000] +0xF4CA U+6D24 # [2000] +0xF4CB U+6D26 # [2000] +0xF4CC U+6D27 # [2000] +0xF4CD U+6C67 # [2000] +0xF4CE U+6D2F # [2000] +0xF4CF U+6D3C # [2000] +0xF4D0 U+6D5B # [2000] +0xF4D1 U+6D5E # [2000] +0xF4D2 U+6D60 # [2000] +0xF4D3 U+6D70 # [2000] +0xF4D4 U+6D80 # [2000] +0xF4D5 U+6D81 # [2000] +0xF4D6 U+6D8A # [2000] +0xF4D7 U+6D8D # [2000] +0xF4D8 U+6D91 # [2000] +0xF4D9 U+6D98 # [2000] +0xF4DA U+23D40 # [2000] [Unicode3.1] +0xF4DB U+6E17 # [2000] +0xF4DC U+23DFA # [2000] [Unicode3.1] +0xF4DD U+23DF9 # [2000] [Unicode3.1] +0xF4DE U+23DD3 # [2000] [Unicode3.1] +0xF4DF U+6DAB # [2000] +0xF4E0 U+6DAE # [2000] +0xF4E1 U+6DB4 # [2000] +0xF4E2 U+6DC2 # [2000] +0xF4E3 U+6D34 # [2000] +0xF4E4 U+6DC8 # [2000] +0xF4E5 U+6DCE # [2000] +0xF4E6 U+6DCF # [2000] +0xF4E7 U+6DD0 # [2000] +0xF4E8 U+6DDF # [2000] +0xF4E9 U+6DE9 # [2000] +0xF4EA U+6DF6 # [2000] +0xF4EB U+6E36 # [2000] +0xF4EC U+6E1E # [2000] +0xF4ED U+6E22 # [2000] +0xF4EE U+6E27 # [2000] +0xF4EF U+3D11 # [2000] +0xF4F0 U+6E32 # [2000] +0xF4F1 U+6E3C # [2000] +0xF4F2 U+6E48 # [2000] +0xF4F3 U+6E49 # [2000] +0xF4F4 U+6E4B # [2000] +0xF4F5 U+6E4C # [2000] +0xF4F6 U+6E4F # [2000] +0xF4F7 U+6E51 # [2000] +0xF4F8 U+6E53 # [2000] +0xF4F9 U+6E54 # [2000] +0xF4FA U+6E57 # [2000] +0xF4FB U+6E63 # [2000] +0xF4FC U+3D1E # [2000] +0xF540 U+6E93 # [2000] +0xF541 U+6EA7 # [2000] +0xF542 U+6EB4 # [2000] +0xF543 U+6EBF # [2000] +0xF544 U+6EC3 # [2000] +0xF545 U+6ECA # [2000] +0xF546 U+6ED9 # [2000] +0xF547 U+6F35 # [2000] +0xF548 U+6EEB # [2000] +0xF549 U+6EF9 # [2000] +0xF54A U+6EFB # [2000] +0xF54B U+6F0A # [2000] +0xF54C U+6F0C # [2000] +0xF54D U+6F18 # [2000] +0xF54E U+6F25 # [2000] +0xF54F U+6F36 # [2000] +0xF550 U+6F3C # [2000] +0xF551 U+23F7E # [2000] [Unicode3.1] +0xF552 U+6F52 # [2000] +0xF553 U+6F57 # [2000] +0xF554 U+6F5A # [2000] +0xF555 U+6F60 # [2000] +0xF556 U+6F68 # [2000] +0xF557 U+6F98 # [2000] +0xF558 U+6F7D # [2000] +0xF559 U+6F90 # [2000] +0xF55A U+6F96 # [2000] +0xF55B U+6FBE # [2000] +0xF55C U+6F9F # [2000] +0xF55D U+6FA5 # [2000] +0xF55E U+6FAF # [2000] +0xF55F U+3D64 # [2000] +0xF560 U+6FB5 # [2000] +0xF561 U+6FC8 # [2000] +0xF562 U+6FC9 # [2000] +0xF563 U+6FDA # [2000] +0xF564 U+6FDE # [2000] +0xF565 U+6FE9 # [2000] +0xF566 U+24096 # [2000] [Unicode3.1] +0xF567 U+6FFC # [2000] +0xF568 U+7000 # [2000] +0xF569 U+7007 # [2000] +0xF56A U+700A # [2000] +0xF56B U+7023 # [2000] +0xF56C U+24103 # [2000] [Unicode3.1] +0xF56D U+7039 # [2000] +0xF56E U+703A # [2000] +0xF56F U+703C # [2000] +0xF570 U+7043 # [2000] +0xF571 U+7047 # [2000] +0xF572 U+704B # [2000] +0xF573 U+3D9A # [2000] +0xF574 U+7054 # [2000] +0xF575 U+7065 # [2000] +0xF576 U+7069 # [2000] +0xF577 U+706C # [2000] +0xF578 U+706E # [2000] +0xF579 U+7076 # [2000] +0xF57A U+707E # [2000] +0xF57B U+7081 # [2000] +0xF57C U+7086 # [2000] +0xF57D U+7095 # [2000] +0xF57E U+7097 # [2000] +0xF580 U+70BB # [2000] +0xF581 U+241C6 # [2000] [Unicode3.1] +0xF582 U+709F # [2000] +0xF583 U+70B1 # [2000] +0xF584 U+241FE # [2000] [Unicode3.1] +0xF585 U+70EC # [2000] +0xF586 U+70CA # [2000] +0xF587 U+70D1 # [2000] +0xF588 U+70D3 # [2000] +0xF589 U+70DC # [2000] +0xF58A U+7103 # [2000] +0xF58B U+7104 # [2000] +0xF58C U+7106 # [2000] +0xF58D U+7107 # [2000] +0xF58E U+7108 # [2000] +0xF58F U+710C # [2000] +0xF590 U+3DC0 # [2000] +0xF591 U+712F # [2000] +0xF592 U+7131 # [2000] +0xF593 U+7150 # [2000] +0xF594 U+714A # [2000] +0xF595 U+7153 # [2000] +0xF596 U+715E # [2000] +0xF597 U+3DD4 # [2000] +0xF598 U+7196 # [2000] +0xF599 U+7180 # [2000] +0xF59A U+719B # [2000] +0xF59B U+71A0 # [2000] +0xF59C U+71A2 # [2000] +0xF59D U+71AE # [2000] +0xF59E U+71AF # [2000] +0xF59F U+71B3 # [2000] +0xF5A0 U+243BC # [2000] [Unicode3.1] +0xF5A1 U+71CB # [2000] +0xF5A2 U+71D3 # [2000] +0xF5A3 U+71D9 # [2000] +0xF5A4 U+71DC # [2000] +0xF5A5 U+7207 # [2000] +0xF5A6 U+3E05 # [2000] +0xF5A7 U+FA49 # CJK COMPATIBILITY IDEOGRAPH-FA49 [2000] [Unicode3.2] +0xF5A8 U+722B # [2000] +0xF5A9 U+7234 # [2000] +0xF5AA U+7238 # [2000] +0xF5AB U+7239 # [2000] +0xF5AC U+4E2C # [2000] +0xF5AD U+7242 # [2000] +0xF5AE U+7253 # [2000] +0xF5AF U+7257 # [2000] +0xF5B0 U+7263 # [2000] +0xF5B1 U+24629 # [2000] [Unicode3.1] +0xF5B2 U+726E # [2000] +0xF5B3 U+726F # [2000] +0xF5B4 U+7278 # [2000] +0xF5B5 U+727F # [2000] +0xF5B6 U+728E # [2000] +0xF5B7 U+246A5 # [2000] [Unicode3.1] +0xF5B8 U+72AD # [2000] +0xF5B9 U+72AE # [2000] +0xF5BA U+72B0 # [2000] +0xF5BB U+72B1 # [2000] +0xF5BC U+72C1 # [2000] +0xF5BD U+3E60 # [2000] +0xF5BE U+72CC # [2000] +0xF5BF U+3E66 # [2000] +0xF5C0 U+3E68 # [2000] +0xF5C1 U+72F3 # [2000] +0xF5C2 U+72FA # [2000] +0xF5C3 U+7307 # [2000] +0xF5C4 U+7312 # [2000] +0xF5C5 U+7318 # [2000] +0xF5C6 U+7319 # [2000] +0xF5C7 U+3E83 # [2000] +0xF5C8 U+7339 # [2000] +0xF5C9 U+732C # [2000] +0xF5CA U+7331 # [2000] +0xF5CB U+7333 # [2000] +0xF5CC U+733D # [2000] +0xF5CD U+7352 # [2000] +0xF5CE U+3E94 # [2000] +0xF5CF U+736B # [2000] +0xF5D0 U+736C # [2000] +0xF5D1 U+24896 # [2000] [Unicode3.1] +0xF5D2 U+736E # [2000] +0xF5D3 U+736F # [2000] +0xF5D4 U+7371 # [2000] +0xF5D5 U+7377 # [2000] +0xF5D6 U+7381 # [2000] +0xF5D7 U+7385 # [2000] +0xF5D8 U+738A # [2000] +0xF5D9 U+7394 # [2000] +0xF5DA U+7398 # [2000] +0xF5DB U+739C # [2000] +0xF5DC U+739E # [2000] +0xF5DD U+73A5 # [2000] +0xF5DE U+73A8 # [2000] +0xF5DF U+73B5 # [2000] +0xF5E0 U+73B7 # [2000] +0xF5E1 U+73B9 # [2000] +0xF5E2 U+73BC # [2000] +0xF5E3 U+73BF # [2000] +0xF5E4 U+73C5 # [2000] +0xF5E5 U+73CB # [2000] +0xF5E6 U+73E1 # [2000] +0xF5E7 U+73E7 # [2000] +0xF5E8 U+73F9 # [2000] +0xF5E9 U+7413 # [2000] +0xF5EA U+73FA # [2000] +0xF5EB U+7401 # [2000] +0xF5EC U+7424 # [2000] +0xF5ED U+7431 # [2000] +0xF5EE U+7439 # [2000] +0xF5EF U+7453 # [2000] +0xF5F0 U+7440 # [2000] +0xF5F1 U+7443 # [2000] +0xF5F2 U+744D # [2000] +0xF5F3 U+7452 # [2000] +0xF5F4 U+745D # [2000] +0xF5F5 U+7471 # [2000] +0xF5F6 U+7481 # [2000] +0xF5F7 U+7485 # [2000] +0xF5F8 U+7488 # [2000] +0xF5F9 U+24A4D # [2000] [Unicode3.1] +0xF5FA U+7492 # [2000] +0xF5FB U+7497 # [2000] +0xF5FC U+7499 # [2000] +0xF640 U+74A0 # [2000] +0xF641 U+74A1 # [2000] +0xF642 U+74A5 # [2000] +0xF643 U+74AA # [2000] +0xF644 U+74AB # [2000] +0xF645 U+74B9 # [2000] +0xF646 U+74BB # [2000] +0xF647 U+74BA # [2000] +0xF648 U+74D6 # [2000] +0xF649 U+74D8 # [2000] +0xF64A U+74DE # [2000] +0xF64B U+74EF # [2000] +0xF64C U+74EB # [2000] +0xF64D U+24B56 # [2000] [Unicode3.1] +0xF64E U+74FA # [2000] +0xF64F U+24B6F # [2000] [Unicode3.1] +0xF650 U+7520 # [2000] +0xF651 U+7524 # [2000] +0xF652 U+752A # [2000] +0xF653 U+3F57 # [2000] +0xF654 U+24C16 # [2000] [Unicode3.1] +0xF655 U+753D # [2000] +0xF656 U+753E # [2000] +0xF657 U+7540 # [2000] +0xF658 U+7548 # [2000] +0xF659 U+754E # [2000] +0xF65A U+7550 # [2000] +0xF65B U+7552 # [2000] +0xF65C U+756C # [2000] +0xF65D U+7572 # [2000] +0xF65E U+7571 # [2000] +0xF65F U+757A # [2000] +0xF660 U+757D # [2000] +0xF661 U+757E # [2000] +0xF662 U+7581 # [2000] +0xF663 U+24D14 # [2000] [Unicode3.1] +0xF664 U+758C # [2000] +0xF665 U+3F75 # [2000] +0xF666 U+75A2 # [2000] +0xF667 U+3F77 # [2000] +0xF668 U+75B0 # [2000] +0xF669 U+75B7 # [2000] +0xF66A U+75BF # [2000] +0xF66B U+75C0 # [2000] +0xF66C U+75C6 # [2000] +0xF66D U+75CF # [2000] +0xF66E U+75D3 # [2000] +0xF66F U+75DD # [2000] +0xF670 U+75DF # [2000] +0xF671 U+75E0 # [2000] +0xF672 U+75E7 # [2000] +0xF673 U+75EC # [2000] +0xF674 U+75EE # [2000] +0xF675 U+75F1 # [2000] +0xF676 U+75F9 # [2000] +0xF677 U+7603 # [2000] +0xF678 U+7618 # [2000] +0xF679 U+7607 # [2000] +0xF67A U+760F # [2000] +0xF67B U+3FAE # [2000] +0xF67C U+24E0E # [2000] [Unicode3.1] +0xF67D U+7613 # [2000] +0xF67E U+761B # [2000] +0xF680 U+761C # [2000] +0xF681 U+24E37 # [2000] [Unicode3.1] +0xF682 U+7625 # [2000] +0xF683 U+7628 # [2000] +0xF684 U+763C # [2000] +0xF685 U+7633 # [2000] +0xF686 U+24E6A # [2000] [Unicode3.1] +0xF687 U+3FC9 # [2000] +0xF688 U+7641 # [2000] +0xF689 U+24E8B # [2000] [Unicode3.1] +0xF68A U+7649 # [2000] +0xF68B U+7655 # [2000] +0xF68C U+3FD7 # [2000] +0xF68D U+766E # [2000] +0xF68E U+7695 # [2000] +0xF68F U+769C # [2000] +0xF690 U+76A1 # [2000] +0xF691 U+76A0 # [2000] +0xF692 U+76A7 # [2000] +0xF693 U+76A8 # [2000] +0xF694 U+76AF # [2000] +0xF695 U+2504A # [2000] [Unicode3.1] +0xF696 U+76C9 # [2000] +0xF697 U+25055 # [2000] [Unicode3.1] +0xF698 U+76E8 # [2000] +0xF699 U+76EC # [2000] +0xF69A U+25122 # [2000] [Unicode3.1] +0xF69B U+7717 # [2000] +0xF69C U+771A # [2000] +0xF69D U+772D # [2000] +0xF69E U+7735 # [2000] +0xF69F U+251A9 # [2000] [Unicode3.1] +0xF6A0 U+4039 # [2000] +0xF6A1 U+251E5 # [2000] [Unicode3.1] +0xF6A2 U+251CD # [2000] [Unicode3.1] +0xF6A3 U+7758 # [2000] +0xF6A4 U+7760 # [2000] +0xF6A5 U+776A # [2000] +0xF6A6 U+2521E # [2000] [Unicode3.1] +0xF6A7 U+7772 # [2000] +0xF6A8 U+777C # [2000] +0xF6A9 U+777D # [2000] +0xF6AA U+2524C # [2000] [Unicode3.1] +0xF6AB U+4058 # [2000] +0xF6AC U+779A # [2000] +0xF6AD U+779F # [2000] +0xF6AE U+77A2 # [2000] +0xF6AF U+77A4 # [2000] +0xF6B0 U+77A9 # [2000] +0xF6B1 U+77DE # [2000] +0xF6B2 U+77DF # [2000] +0xF6B3 U+77E4 # [2000] +0xF6B4 U+77E6 # [2000] +0xF6B5 U+77EA # [2000] +0xF6B6 U+77EC # [2000] +0xF6B7 U+4093 # [2000] +0xF6B8 U+77F0 # [2000] +0xF6B9 U+77F4 # [2000] +0xF6BA U+77FB # [2000] +0xF6BB U+2542E # [2000] [Unicode3.1] +0xF6BC U+7805 # [2000] +0xF6BD U+7806 # [2000] +0xF6BE U+7809 # [2000] +0xF6BF U+780D # [2000] +0xF6C0 U+7819 # [2000] +0xF6C1 U+7821 # [2000] +0xF6C2 U+782C # [2000] +0xF6C3 U+7847 # [2000] +0xF6C4 U+7864 # [2000] +0xF6C5 U+786A # [2000] +0xF6C6 U+254D9 # [2000] [Unicode3.1] +0xF6C7 U+788A # [2000] +0xF6C8 U+7894 # [2000] +0xF6C9 U+78A4 # [2000] +0xF6CA U+789D # [2000] +0xF6CB U+789E # [2000] +0xF6CC U+789F # [2000] +0xF6CD U+78BB # [2000] +0xF6CE U+78C8 # [2000] +0xF6CF U+78CC # [2000] +0xF6D0 U+78CE # [2000] +0xF6D1 U+78D5 # [2000] +0xF6D2 U+78E0 # [2000] +0xF6D3 U+78E1 # [2000] +0xF6D4 U+78E6 # [2000] +0xF6D5 U+78F9 # [2000] +0xF6D6 U+78FA # [2000] +0xF6D7 U+78FB # [2000] +0xF6D8 U+78FE # [2000] +0xF6D9 U+255A7 # [2000] [Unicode3.1] +0xF6DA U+7910 # [2000] +0xF6DB U+791B # [2000] +0xF6DC U+7930 # [2000] +0xF6DD U+7925 # [2000] +0xF6DE U+793B # [2000] +0xF6DF U+794A # [2000] +0xF6E0 U+7958 # [2000] +0xF6E1 U+795B # [2000] +0xF6E2 U+4105 # [2000] +0xF6E3 U+7967 # [2000] +0xF6E4 U+7972 # [2000] +0xF6E5 U+7994 # [2000] +0xF6E6 U+7995 # [2000] +0xF6E7 U+7996 # [2000] +0xF6E8 U+799B # [2000] +0xF6E9 U+79A1 # [2000] +0xF6EA U+79A9 # [2000] +0xF6EB U+79B4 # [2000] +0xF6EC U+79BB # [2000] +0xF6ED U+79C2 # [2000] +0xF6EE U+79C7 # [2000] +0xF6EF U+79CC # [2000] +0xF6F0 U+79CD # [2000] +0xF6F1 U+79D6 # [2000] +0xF6F2 U+4148 # [2000] +0xF6F3 U+257A9 # [2000] [Unicode3.1] +0xF6F4 U+257B4 # [2000] [Unicode3.1] +0xF6F5 U+414F # [2000] +0xF6F6 U+7A0A # [2000] +0xF6F7 U+7A11 # [2000] +0xF6F8 U+7A15 # [2000] +0xF6F9 U+7A1B # [2000] +0xF6FA U+7A1E # [2000] +0xF6FB U+4163 # [2000] +0xF6FC U+7A2D # [2000] +0xF740 U+7A38 # [2000] +0xF741 U+7A47 # [2000] +0xF742 U+7A4C # [2000] +0xF743 U+7A56 # [2000] +0xF744 U+7A59 # [2000] +0xF745 U+7A5C # [2000] +0xF746 U+7A5F # [2000] +0xF747 U+7A60 # [2000] +0xF748 U+7A67 # [2000] +0xF749 U+7A6A # [2000] +0xF74A U+7A75 # [2000] +0xF74B U+7A78 # [2000] +0xF74C U+7A82 # [2000] +0xF74D U+7A8A # [2000] +0xF74E U+7A90 # [2000] +0xF74F U+7AA3 # [2000] +0xF750 U+7AAC # [2000] +0xF751 U+259D4 # [2000] [Unicode3.1] +0xF752 U+41B4 # [2000] +0xF753 U+7AB9 # [2000] +0xF754 U+7ABC # [2000] +0xF755 U+7ABE # [2000] +0xF756 U+41BF # [2000] +0xF757 U+7ACC # [2000] +0xF758 U+7AD1 # [2000] +0xF759 U+7AE7 # [2000] +0xF75A U+7AE8 # [2000] +0xF75B U+7AF4 # [2000] +0xF75C U+25AE4 # [2000] [Unicode3.1] +0xF75D U+25AE3 # [2000] [Unicode3.1] +0xF75E U+7B07 # [2000] +0xF75F U+25AF1 # [2000] [Unicode3.1] +0xF760 U+7B3D # [2000] +0xF761 U+7B27 # [2000] +0xF762 U+7B2A # [2000] +0xF763 U+7B2E # [2000] +0xF764 U+7B2F # [2000] +0xF765 U+7B31 # [2000] +0xF766 U+41E6 # [2000] +0xF767 U+41F3 # [2000] +0xF768 U+7B7F # [2000] +0xF769 U+7B41 # [2000] +0xF76A U+41EE # [2000] +0xF76B U+7B55 # [2000] +0xF76C U+7B79 # [2000] +0xF76D U+7B64 # [2000] +0xF76E U+7B66 # [2000] +0xF76F U+7B69 # [2000] +0xF770 U+7B73 # [2000] +0xF771 U+25BB2 # [2000] [Unicode3.1] +0xF772 U+4207 # [2000] +0xF773 U+7B90 # [2000] +0xF774 U+7B91 # [2000] +0xF775 U+7B9B # [2000] +0xF776 U+420E # [2000] +0xF777 U+7BAF # [2000] +0xF778 U+7BB5 # [2000] +0xF779 U+7BBC # [2000] +0xF77A U+7BC5 # [2000] +0xF77B U+7BCA # [2000] +0xF77C U+25C4B # [2000] [Unicode3.1] +0xF77D U+25C64 # [2000] [Unicode3.1] +0xF77E U+7BD4 # [2000] +0xF780 U+7BD6 # [2000] +0xF781 U+7BDA # [2000] +0xF782 U+7BEA # [2000] +0xF783 U+7BF0 # [2000] +0xF784 U+7C03 # [2000] +0xF785 U+7C0B # [2000] +0xF786 U+7C0E # [2000] +0xF787 U+7C0F # [2000] +0xF788 U+7C26 # [2000] +0xF789 U+7C45 # [2000] +0xF78A U+7C4A # [2000] +0xF78B U+7C51 # [2000] +0xF78C U+7C57 # [2000] +0xF78D U+7C5E # [2000] +0xF78E U+7C61 # [2000] +0xF78F U+7C69 # [2000] +0xF790 U+7C6E # [2000] +0xF791 U+7C6F # [2000] +0xF792 U+7C70 # [2000] +0xF793 U+25E2E # [2000] [Unicode3.1] +0xF794 U+25E56 # [2000] [Unicode3.1] +0xF795 U+25E65 # [2000] [Unicode3.1] +0xF796 U+7CA6 # [2000] +0xF797 U+25E62 # [2000] [Unicode3.1] +0xF798 U+7CB6 # [2000] +0xF799 U+7CB7 # [2000] +0xF79A U+7CBF # [2000] +0xF79B U+25ED8 # [2000] [Unicode3.1] +0xF79C U+7CC4 # [2000] +0xF79D U+25EC2 # [2000] [Unicode3.1] +0xF79E U+7CC8 # [2000] +0xF79F U+7CCD # [2000] +0xF7A0 U+25EE8 # [2000] [Unicode3.1] +0xF7A1 U+7CD7 # [2000] +0xF7A2 U+25F23 # [2000] [Unicode3.1] +0xF7A3 U+7CE6 # [2000] +0xF7A4 U+7CEB # [2000] +0xF7A5 U+25F5C # [2000] [Unicode3.1] +0xF7A6 U+7CF5 # [2000] +0xF7A7 U+7D03 # [2000] +0xF7A8 U+7D09 # [2000] +0xF7A9 U+42C6 # [2000] +0xF7AA U+7D12 # [2000] +0xF7AB U+7D1E # [2000] +0xF7AC U+25FE0 # [2000] [Unicode3.1] +0xF7AD U+25FD4 # [2000] [Unicode3.1] +0xF7AE U+7D3D # [2000] +0xF7AF U+7D3E # [2000] +0xF7B0 U+7D40 # [2000] +0xF7B1 U+7D47 # [2000] +0xF7B2 U+2600C # [2000] [Unicode3.1] +0xF7B3 U+25FFB # [2000] [Unicode3.1] +0xF7B4 U+42D6 # [2000] +0xF7B5 U+7D59 # [2000] +0xF7B6 U+7D5A # [2000] +0xF7B7 U+7D6A # [2000] +0xF7B8 U+7D70 # [2000] +0xF7B9 U+42DD # [2000] +0xF7BA U+7D7F # [2000] +0xF7BB U+26017 # [2000] [Unicode3.1] +0xF7BC U+7D86 # [2000] +0xF7BD U+7D88 # [2000] +0xF7BE U+7D8C # [2000] +0xF7BF U+7D97 # [2000] +0xF7C0 U+26060 # [2000] [Unicode3.1] +0xF7C1 U+7D9D # [2000] +0xF7C2 U+7DA7 # [2000] +0xF7C3 U+7DAA # [2000] +0xF7C4 U+7DB6 # [2000] +0xF7C5 U+7DB7 # [2000] +0xF7C6 U+7DC0 # [2000] +0xF7C7 U+7DD7 # [2000] +0xF7C8 U+7DD9 # [2000] +0xF7C9 U+7DE6 # [2000] +0xF7CA U+7DF1 # [2000] +0xF7CB U+7DF9 # [2000] +0xF7CC U+4302 # [2000] +0xF7CD U+260ED # [2000] [Unicode3.1] +0xF7CE U+FA58 # CJK COMPATIBILITY IDEOGRAPH-FA58 [2000] [Unicode3.2] +0xF7CF U+7E10 # [2000] +0xF7D0 U+7E17 # [2000] +0xF7D1 U+7E1D # [2000] +0xF7D2 U+7E20 # [2000] +0xF7D3 U+7E27 # [2000] +0xF7D4 U+7E2C # [2000] +0xF7D5 U+7E45 # [2000] +0xF7D6 U+7E73 # [2000] +0xF7D7 U+7E75 # [2000] +0xF7D8 U+7E7E # [2000] +0xF7D9 U+7E86 # [2000] +0xF7DA U+7E87 # [2000] +0xF7DB U+432B # [2000] +0xF7DC U+7E91 # [2000] +0xF7DD U+7E98 # [2000] +0xF7DE U+7E9A # [2000] +0xF7DF U+4343 # [2000] +0xF7E0 U+7F3C # [2000] +0xF7E1 U+7F3B # [2000] +0xF7E2 U+7F3E # [2000] +0xF7E3 U+7F43 # [2000] +0xF7E4 U+7F44 # [2000] +0xF7E5 U+7F4F # [2000] +0xF7E6 U+34C1 # [2000] +0xF7E7 U+26270 # [2000] [Unicode3.1] +0xF7E8 U+7F52 # [2000] +0xF7E9 U+26286 # [2000] [Unicode3.1] +0xF7EA U+7F61 # [2000] +0xF7EB U+7F63 # [2000] +0xF7EC U+7F64 # [2000] +0xF7ED U+7F6D # [2000] +0xF7EE U+7F7D # [2000] +0xF7EF U+7F7E # [2000] +0xF7F0 U+2634C # [2000] [Unicode3.1] +0xF7F1 U+7F90 # [2000] +0xF7F2 U+517B # [2000] +0xF7F3 U+23D0E # [2000] [Unicode3.1] +0xF7F4 U+7F96 # [2000] +0xF7F5 U+7F9C # [2000] +0xF7F6 U+7FAD # [2000] +0xF7F7 U+26402 # [2000] [Unicode3.1] +0xF7F8 U+7FC3 # [2000] +0xF7F9 U+7FCF # [2000] +0xF7FA U+7FE3 # [2000] +0xF7FB U+7FE5 # [2000] +0xF7FC U+7FEF # [2000] +0xF840 U+7FF2 # [2000] +0xF841 U+8002 # [2000] +0xF842 U+800A # [2000] +0xF843 U+8008 # [2000] +0xF844 U+800E # [2000] +0xF845 U+8011 # [2000] +0xF846 U+8016 # [2000] +0xF847 U+8024 # [2000] +0xF848 U+802C # [2000] +0xF849 U+8030 # [2000] +0xF84A U+8043 # [2000] +0xF84B U+8066 # [2000] +0xF84C U+8071 # [2000] +0xF84D U+8075 # [2000] +0xF84E U+807B # [2000] +0xF84F U+8099 # [2000] +0xF850 U+809C # [2000] +0xF851 U+80A4 # [2000] +0xF852 U+80A7 # [2000] +0xF853 U+80B8 # [2000] +0xF854 U+2667E # [2000] [Unicode3.1] +0xF855 U+80C5 # [2000] +0xF856 U+80D5 # [2000] +0xF857 U+80D8 # [2000] +0xF858 U+80E6 # [2000] +0xF859 U+266B0 # [2000] [Unicode3.1] +0xF85A U+810D # [2000] +0xF85B U+80F5 # [2000] +0xF85C U+80FB # [2000] +0xF85D U+43EE # [2000] +0xF85E U+8135 # [2000] +0xF85F U+8116 # [2000] +0xF860 U+811E # [2000] +0xF861 U+43F0 # [2000] +0xF862 U+8124 # [2000] +0xF863 U+8127 # [2000] +0xF864 U+812C # [2000] +0xF865 U+2671D # [2000] [Unicode3.1] +0xF866 U+813D # [2000] +0xF867 U+4408 # [2000] +0xF868 U+8169 # [2000] +0xF869 U+4417 # [2000] +0xF86A U+8181 # [2000] +0xF86B U+441C # [2000] +0xF86C U+8184 # [2000] +0xF86D U+8185 # [2000] +0xF86E U+4422 # [2000] +0xF86F U+8198 # [2000] +0xF870 U+81B2 # [2000] +0xF871 U+81C1 # [2000] +0xF872 U+81C3 # [2000] +0xF873 U+81D6 # [2000] +0xF874 U+81DB # [2000] +0xF875 U+268DD # [2000] [Unicode3.1] +0xF876 U+81E4 # [2000] +0xF877 U+268EA # [2000] [Unicode3.1] +0xF878 U+81EC # [2000] +0xF879 U+26951 # [2000] [Unicode3.1] +0xF87A U+81FD # [2000] +0xF87B U+81FF # [2000] +0xF87C U+2696F # [2000] [Unicode3.1] +0xF87D U+8204 # [2000] +0xF87E U+269DD # [2000] [Unicode3.1] +0xF880 U+8219 # [2000] +0xF881 U+8221 # [2000] +0xF882 U+8222 # [2000] +0xF883 U+26A1E # [2000] [Unicode3.1] +0xF884 U+8232 # [2000] +0xF885 U+8234 # [2000] +0xF886 U+823C # [2000] +0xF887 U+8246 # [2000] +0xF888 U+8249 # [2000] +0xF889 U+8245 # [2000] +0xF88A U+26A58 # [2000] [Unicode3.1] +0xF88B U+824B # [2000] +0xF88C U+4476 # [2000] +0xF88D U+824F # [2000] +0xF88E U+447A # [2000] +0xF88F U+8257 # [2000] +0xF890 U+26A8C # [2000] [Unicode3.1] +0xF891 U+825C # [2000] +0xF892 U+8263 # [2000] +0xF893 U+26AB7 # [2000] [Unicode3.1] +0xF894 U+FA5D # CJK COMPATIBILITY IDEOGRAPH-FA5D [2000] [Unicode3.2] +0xF895 U+FA5E # CJK COMPATIBILITY IDEOGRAPH-FA5E [2000] [Unicode3.2] +0xF896 U+8279 # [2000] +0xF897 U+4491 # [2000] +0xF898 U+827D # [2000] +0xF899 U+827F # [2000] +0xF89A U+8283 # [2000] +0xF89B U+828A # [2000] +0xF89C U+8293 # [2000] +0xF89D U+82A7 # [2000] +0xF89E U+82A8 # [2000] +0xF89F U+82B2 # [2000] +0xF8A0 U+82B4 # [2000] +0xF8A1 U+82BA # [2000] +0xF8A2 U+82BC # [2000] +0xF8A3 U+82E2 # [2000] +0xF8A4 U+82E8 # [2000] +0xF8A5 U+82F7 # [2000] +0xF8A6 U+8307 # [2000] +0xF8A7 U+8308 # [2000] +0xF8A8 U+830C # [2000] +0xF8A9 U+8354 # [2000] +0xF8AA U+831B # [2000] +0xF8AB U+831D # [2000] +0xF8AC U+8330 # [2000] +0xF8AD U+833C # [2000] +0xF8AE U+8344 # [2000] +0xF8AF U+8357 # [2000] +0xF8B0 U+44BE # [2000] +0xF8B1 U+837F # [2000] +0xF8B2 U+44D4 # [2000] +0xF8B3 U+44B3 # [2000] +0xF8B4 U+838D # [2000] +0xF8B5 U+8394 # [2000] +0xF8B6 U+8395 # [2000] +0xF8B7 U+839B # [2000] +0xF8B8 U+839D # [2000] +0xF8B9 U+83C9 # [2000] +0xF8BA U+83D0 # [2000] +0xF8BB U+83D4 # [2000] +0xF8BC U+83DD # [2000] +0xF8BD U+83E5 # [2000] +0xF8BE U+83F9 # [2000] +0xF8BF U+840F # [2000] +0xF8C0 U+8411 # [2000] +0xF8C1 U+8415 # [2000] +0xF8C2 U+26C73 # [2000] [Unicode3.1] +0xF8C3 U+8417 # [2000] +0xF8C4 U+8439 # [2000] +0xF8C5 U+844A # [2000] +0xF8C6 U+844F # [2000] +0xF8C7 U+8451 # [2000] +0xF8C8 U+8452 # [2000] +0xF8C9 U+8459 # [2000] +0xF8CA U+845A # [2000] +0xF8CB U+845C # [2000] +0xF8CC U+26CDD # [2000] [Unicode3.1] +0xF8CD U+8465 # [2000] +0xF8CE U+8476 # [2000] +0xF8CF U+8478 # [2000] +0xF8D0 U+847C # [2000] +0xF8D1 U+8481 # [2000] +0xF8D2 U+450D # [2000] +0xF8D3 U+84DC # [2000] +0xF8D4 U+8497 # [2000] +0xF8D5 U+84A6 # [2000] +0xF8D6 U+84BE # [2000] +0xF8D7 U+4508 # [2000] +0xF8D8 U+84CE # [2000] +0xF8D9 U+84CF # [2000] +0xF8DA U+84D3 # [2000] +0xF8DB U+26E65 # [2000] [Unicode3.1] +0xF8DC U+84E7 # [2000] +0xF8DD U+84EA # [2000] +0xF8DE U+84EF # [2000] +0xF8DF U+84F0 # [2000] +0xF8E0 U+84F1 # [2000] +0xF8E1 U+84FA # [2000] +0xF8E2 U+84FD # [2000] +0xF8E3 U+850C # [2000] +0xF8E4 U+851B # [2000] +0xF8E5 U+8524 # [2000] +0xF8E6 U+8525 # [2000] +0xF8E7 U+852B # [2000] +0xF8E8 U+8534 # [2000] +0xF8E9 U+854F # [2000] +0xF8EA U+856F # [2000] +0xF8EB U+4525 # [2000] +0xF8EC U+4543 # [2000] +0xF8ED U+853E # [2000] +0xF8EE U+8551 # [2000] +0xF8EF U+8553 # [2000] +0xF8F0 U+855E # [2000] +0xF8F1 U+8561 # [2000] +0xF8F2 U+8562 # [2000] +0xF8F3 U+26F94 # [2000] [Unicode3.1] +0xF8F4 U+857B # [2000] +0xF8F5 U+857D # [2000] +0xF8F6 U+857F # [2000] +0xF8F7 U+8581 # [2000] +0xF8F8 U+8586 # [2000] +0xF8F9 U+8593 # [2000] +0xF8FA U+859D # [2000] +0xF8FB U+859F # [2000] +0xF8FC U+26FF8 # [2000] [Unicode3.1] +0xF940 U+26FF6 # [2000] [Unicode3.1] +0xF941 U+26FF7 # [2000] [Unicode3.1] +0xF942 U+85B7 # [2000] +0xF943 U+85BC # [2000] +0xF944 U+85C7 # [2000] +0xF945 U+85CA # [2000] +0xF946 U+85D8 # [2000] +0xF947 U+85D9 # [2000] +0xF948 U+85DF # [2000] +0xF949 U+85E1 # [2000] +0xF94A U+85E6 # [2000] +0xF94B U+85F6 # [2000] +0xF94C U+8600 # [2000] +0xF94D U+8611 # [2000] +0xF94E U+861E # [2000] +0xF94F U+8621 # [2000] +0xF950 U+8624 # [2000] +0xF951 U+8627 # [2000] +0xF952 U+2710D # [2000] [Unicode3.1] +0xF953 U+8639 # [2000] +0xF954 U+863C # [2000] +0xF955 U+27139 # [2000] [Unicode3.1] +0xF956 U+8640 # [2000] +0xF957 U+FA20 # CJK COMPATIBILITY IDEOGRAPH-FA20 [2000] +0xF958 U+8653 # [2000] +0xF959 U+8656 # [2000] +0xF95A U+866F # [2000] +0xF95B U+8677 # [2000] +0xF95C U+867A # [2000] +0xF95D U+8687 # [2000] +0xF95E U+8689 # [2000] +0xF95F U+868D # [2000] +0xF960 U+8691 # [2000] +0xF961 U+869C # [2000] +0xF962 U+869D # [2000] +0xF963 U+86A8 # [2000] +0xF964 U+FA21 # CJK COMPATIBILITY IDEOGRAPH-FA21 [2000] +0xF965 U+86B1 # [2000] +0xF966 U+86B3 # [2000] +0xF967 U+86C1 # [2000] +0xF968 U+86C3 # [2000] +0xF969 U+86D1 # [2000] +0xF96A U+86D5 # [2000] +0xF96B U+86D7 # [2000] +0xF96C U+86E3 # [2000] +0xF96D U+86E6 # [2000] +0xF96E U+45B8 # [2000] +0xF96F U+8705 # [2000] +0xF970 U+8707 # [2000] +0xF971 U+870E # [2000] +0xF972 U+8710 # [2000] +0xF973 U+8713 # [2000] +0xF974 U+8719 # [2000] +0xF975 U+871F # [2000] +0xF976 U+8721 # [2000] +0xF977 U+8723 # [2000] +0xF978 U+8731 # [2000] +0xF979 U+873A # [2000] +0xF97A U+873E # [2000] +0xF97B U+8740 # [2000] +0xF97C U+8743 # [2000] +0xF97D U+8751 # [2000] +0xF97E U+8758 # [2000] +0xF980 U+8764 # [2000] +0xF981 U+8765 # [2000] +0xF982 U+8772 # [2000] +0xF983 U+877C # [2000] +0xF984 U+273DB # [2000] [Unicode3.1] +0xF985 U+273DA # [2000] [Unicode3.1] +0xF986 U+87A7 # [2000] +0xF987 U+8789 # [2000] +0xF988 U+878B # [2000] +0xF989 U+8793 # [2000] +0xF98A U+87A0 # [2000] +0xF98B U+273FE # [2000] [Unicode3.1] +0xF98C U+45E5 # [2000] +0xF98D U+87BE # [2000] +0xF98E U+27410 # [2000] [Unicode3.1] +0xF98F U+87C1 # [2000] +0xF990 U+87CE # [2000] +0xF991 U+87F5 # [2000] +0xF992 U+87DF # [2000] +0xF993 U+27449 # [2000] [Unicode3.1] +0xF994 U+87E3 # [2000] +0xF995 U+87E5 # [2000] +0xF996 U+87E6 # [2000] +0xF997 U+87EA # [2000] +0xF998 U+87EB # [2000] +0xF999 U+87ED # [2000] +0xF99A U+8801 # [2000] +0xF99B U+8803 # [2000] +0xF99C U+880B # [2000] +0xF99D U+8813 # [2000] +0xF99E U+8828 # [2000] +0xF99F U+882E # [2000] +0xF9A0 U+8832 # [2000] +0xF9A1 U+883C # [2000] +0xF9A2 U+460F # [2000] +0xF9A3 U+884A # [2000] +0xF9A4 U+8858 # [2000] +0xF9A5 U+885F # [2000] +0xF9A6 U+8864 # [2000] +0xF9A7 U+27615 # [2000] [Unicode3.1] +0xF9A8 U+27614 # [2000] [Unicode3.1] +0xF9A9 U+8869 # [2000] +0xF9AA U+27631 # [2000] [Unicode3.1] +0xF9AB U+886F # [2000] +0xF9AC U+88A0 # [2000] +0xF9AD U+88BC # [2000] +0xF9AE U+88BD # [2000] +0xF9AF U+88BE # [2000] +0xF9B0 U+88C0 # [2000] +0xF9B1 U+88D2 # [2000] +0xF9B2 U+27693 # [2000] [Unicode3.1] +0xF9B3 U+88D1 # [2000] +0xF9B4 U+88D3 # [2000] +0xF9B5 U+88DB # [2000] +0xF9B6 U+88F0 # [2000] +0xF9B7 U+88F1 # [2000] +0xF9B8 U+4641 # [2000] +0xF9B9 U+8901 # [2000] +0xF9BA U+2770E # [2000] [Unicode3.1] +0xF9BB U+8937 # [2000] +0xF9BC U+27723 # [2000] [Unicode3.1] +0xF9BD U+8942 # [2000] +0xF9BE U+8945 # [2000] +0xF9BF U+8949 # [2000] +0xF9C0 U+27752 # [2000] [Unicode3.1] +0xF9C1 U+4665 # [2000] +0xF9C2 U+8962 # [2000] +0xF9C3 U+8980 # [2000] +0xF9C4 U+8989 # [2000] +0xF9C5 U+8990 # [2000] +0xF9C6 U+899F # [2000] +0xF9C7 U+89B0 # [2000] +0xF9C8 U+89B7 # [2000] +0xF9C9 U+89D6 # [2000] +0xF9CA U+89D8 # [2000] +0xF9CB U+89EB # [2000] +0xF9CC U+46A1 # [2000] +0xF9CD U+89F1 # [2000] +0xF9CE U+89F3 # [2000] +0xF9CF U+89FD # [2000] +0xF9D0 U+89FF # [2000] +0xF9D1 U+46AF # [2000] +0xF9D2 U+8A11 # [2000] +0xF9D3 U+8A14 # [2000] +0xF9D4 U+27985 # [2000] [Unicode3.1] +0xF9D5 U+8A21 # [2000] +0xF9D6 U+8A35 # [2000] +0xF9D7 U+8A3E # [2000] +0xF9D8 U+8A45 # [2000] +0xF9D9 U+8A4D # [2000] +0xF9DA U+8A58 # [2000] +0xF9DB U+8AAE # [2000] +0xF9DC U+8A90 # [2000] +0xF9DD U+8AB7 # [2000] +0xF9DE U+8ABE # [2000] +0xF9DF U+8AD7 # [2000] +0xF9E0 U+8AFC # [2000] +0xF9E1 U+27A84 # [2000] [Unicode3.1] +0xF9E2 U+8B0A # [2000] +0xF9E3 U+8B05 # [2000] +0xF9E4 U+8B0D # [2000] +0xF9E5 U+8B1C # [2000] +0xF9E6 U+8B1F # [2000] +0xF9E7 U+8B2D # [2000] +0xF9E8 U+8B43 # [2000] +0xF9E9 U+470C # [2000] +0xF9EA U+8B51 # [2000] +0xF9EB U+8B5E # [2000] +0xF9EC U+8B76 # [2000] +0xF9ED U+8B7F # [2000] +0xF9EE U+8B81 # [2000] +0xF9EF U+8B8B # [2000] +0xF9F0 U+8B94 # [2000] +0xF9F1 U+8B95 # [2000] +0xF9F2 U+8B9C # [2000] +0xF9F3 U+8B9E # [2000] +0xF9F4 U+8C39 # [2000] +0xF9F5 U+27BB3 # [2000] [Unicode3.1] +0xF9F6 U+8C3D # [2000] +0xF9F7 U+27BBE # [2000] [Unicode3.1] +0xF9F8 U+27BC7 # [2000] [Unicode3.1] +0xF9F9 U+8C45 # [2000] +0xF9FA U+8C47 # [2000] +0xF9FB U+8C4F # [2000] +0xF9FC U+8C54 # [2000] +0xFA40 U+8C57 # [2000] +0xFA41 U+8C69 # [2000] +0xFA42 U+8C6D # [2000] +0xFA43 U+8C73 # [2000] +0xFA44 U+27CB8 # [2000] [Unicode3.1] +0xFA45 U+8C93 # [2000] +0xFA46 U+8C92 # [2000] +0xFA47 U+8C99 # [2000] +0xFA48 U+4764 # [2000] +0xFA49 U+8C9B # [2000] +0xFA4A U+8CA4 # [2000] +0xFA4B U+8CD6 # [2000] +0xFA4C U+8CD5 # [2000] +0xFA4D U+8CD9 # [2000] +0xFA4E U+27DA0 # [2000] [Unicode3.1] +0xFA4F U+8CF0 # [2000] +0xFA50 U+8CF1 # [2000] +0xFA51 U+27E10 # [2000] [Unicode3.1] +0xFA52 U+8D09 # [2000] +0xFA53 U+8D0E # [2000] +0xFA54 U+8D6C # [2000] +0xFA55 U+8D84 # [2000] +0xFA56 U+8D95 # [2000] +0xFA57 U+8DA6 # [2000] +0xFA58 U+27FB7 # [2000] [Unicode3.1] +0xFA59 U+8DC6 # [2000] +0xFA5A U+8DC8 # [2000] +0xFA5B U+8DD9 # [2000] +0xFA5C U+8DEC # [2000] +0xFA5D U+8E0C # [2000] +0xFA5E U+47FD # [2000] +0xFA5F U+8DFD # [2000] +0xFA60 U+8E06 # [2000] +0xFA61 U+2808A # [2000] [Unicode3.1] +0xFA62 U+8E14 # [2000] +0xFA63 U+8E16 # [2000] +0xFA64 U+8E21 # [2000] +0xFA65 U+8E22 # [2000] +0xFA66 U+8E27 # [2000] +0xFA67 U+280BB # [2000] [Unicode3.1] +0xFA68 U+4816 # [2000] +0xFA69 U+8E36 # [2000] +0xFA6A U+8E39 # [2000] +0xFA6B U+8E4B # [2000] +0xFA6C U+8E54 # [2000] +0xFA6D U+8E62 # [2000] +0xFA6E U+8E6C # [2000] +0xFA6F U+8E6D # [2000] +0xFA70 U+8E6F # [2000] +0xFA71 U+8E98 # [2000] +0xFA72 U+8E9E # [2000] +0xFA73 U+8EAE # [2000] +0xFA74 U+8EB3 # [2000] +0xFA75 U+8EB5 # [2000] +0xFA76 U+8EB6 # [2000] +0xFA77 U+8EBB # [2000] +0xFA78 U+28282 # [2000] [Unicode3.1] +0xFA79 U+8ED1 # [2000] +0xFA7A U+8ED4 # [2000] +0xFA7B U+484E # [2000] +0xFA7C U+8EF9 # [2000] +0xFA7D U+282F3 # [2000] [Unicode3.1] +0xFA7E U+8F00 # [2000] +0xFA80 U+8F08 # [2000] +0xFA81 U+8F17 # [2000] +0xFA82 U+8F2B # [2000] +0xFA83 U+8F40 # [2000] +0xFA84 U+8F4A # [2000] +0xFA85 U+8F58 # [2000] +0xFA86 U+2840C # [2000] [Unicode3.1] +0xFA87 U+8FA4 # [2000] +0xFA88 U+8FB4 # [2000] +0xFA89 U+FA66 # CJK COMPATIBILITY IDEOGRAPH-FA66 [2000] [Unicode3.2] +0xFA8A U+8FB6 # [2000] +0xFA8B U+28455 # [2000] [Unicode3.1] +0xFA8C U+8FC1 # [2000] +0xFA8D U+8FC6 # [2000] +0xFA8E U+FA24 # CJK COMPATIBILITY IDEOGRAPH-FA24 [2000] +0xFA8F U+8FCA # [2000] +0xFA90 U+8FCD # [2000] +0xFA91 U+8FD3 # [2000] +0xFA92 U+8FD5 # [2000] +0xFA93 U+8FE0 # [2000] +0xFA94 U+8FF1 # [2000] +0xFA95 U+8FF5 # [2000] +0xFA96 U+8FFB # [2000] +0xFA97 U+9002 # [2000] +0xFA98 U+900C # [2000] +0xFA99 U+9037 # [2000] +0xFA9A U+2856B # [2000] [Unicode3.1] +0xFA9B U+9043 # [2000] +0xFA9C U+9044 # [2000] +0xFA9D U+905D # [2000] +0xFA9E U+285C8 # [2000] [Unicode3.1] +0xFA9F U+285C9 # [2000] [Unicode3.1] +0xFAA0 U+9085 # [2000] +0xFAA1 U+908C # [2000] +0xFAA2 U+9090 # [2000] +0xFAA3 U+961D # [2000] +0xFAA4 U+90A1 # [2000] +0xFAA5 U+48B5 # [2000] +0xFAA6 U+90B0 # [2000] +0xFAA7 U+90B6 # [2000] +0xFAA8 U+90C3 # [2000] +0xFAA9 U+90C8 # [2000] +0xFAAA U+286D7 # [2000] [Unicode3.1] +0xFAAB U+90DC # [2000] +0xFAAC U+90DF # [2000] +0xFAAD U+286FA # [2000] [Unicode3.1] +0xFAAE U+90F6 # [2000] +0xFAAF U+90F2 # [2000] +0xFAB0 U+9100 # [2000] +0xFAB1 U+90EB # [2000] +0xFAB2 U+90FE # [2000] +0xFAB3 U+90FF # [2000] +0xFAB4 U+9104 # [2000] +0xFAB5 U+9106 # [2000] +0xFAB6 U+9118 # [2000] +0xFAB7 U+911C # [2000] +0xFAB8 U+911E # [2000] +0xFAB9 U+9137 # [2000] +0xFABA U+9139 # [2000] +0xFABB U+913A # [2000] +0xFABC U+9146 # [2000] +0xFABD U+9147 # [2000] +0xFABE U+9157 # [2000] +0xFABF U+9159 # [2000] +0xFAC0 U+9161 # [2000] +0xFAC1 U+9164 # [2000] +0xFAC2 U+9174 # [2000] +0xFAC3 U+9179 # [2000] +0xFAC4 U+9185 # [2000] +0xFAC5 U+918E # [2000] +0xFAC6 U+91A8 # [2000] +0xFAC7 U+91AE # [2000] +0xFAC8 U+91B3 # [2000] +0xFAC9 U+91B6 # [2000] +0xFACA U+91C3 # [2000] +0xFACB U+91C4 # [2000] +0xFACC U+91DA # [2000] +0xFACD U+28949 # [2000] [Unicode3.1] +0xFACE U+28946 # [2000] [Unicode3.1] +0xFACF U+91EC # [2000] +0xFAD0 U+91EE # [2000] +0xFAD1 U+9201 # [2000] +0xFAD2 U+920A # [2000] +0xFAD3 U+9216 # [2000] +0xFAD4 U+9217 # [2000] +0xFAD5 U+2896B # [2000] [Unicode3.1] +0xFAD6 U+9233 # [2000] +0xFAD7 U+9242 # [2000] +0xFAD8 U+9247 # [2000] +0xFAD9 U+924A # [2000] +0xFADA U+924E # [2000] +0xFADB U+9251 # [2000] +0xFADC U+9256 # [2000] +0xFADD U+9259 # [2000] +0xFADE U+9260 # [2000] +0xFADF U+9261 # [2000] +0xFAE0 U+9265 # [2000] +0xFAE1 U+9267 # [2000] +0xFAE2 U+9268 # [2000] +0xFAE3 U+28987 # [2000] [Unicode3.1] +0xFAE4 U+28988 # [2000] [Unicode3.1] +0xFAE5 U+927C # [2000] +0xFAE6 U+927D # [2000] +0xFAE7 U+927F # [2000] +0xFAE8 U+9289 # [2000] +0xFAE9 U+928D # [2000] +0xFAEA U+9297 # [2000] +0xFAEB U+9299 # [2000] +0xFAEC U+929F # [2000] +0xFAED U+92A7 # [2000] +0xFAEE U+92AB # [2000] +0xFAEF U+289BA # [2000] [Unicode3.1] +0xFAF0 U+289BB # [2000] [Unicode3.1] +0xFAF1 U+92B2 # [2000] +0xFAF2 U+92BF # [2000] +0xFAF3 U+92C0 # [2000] +0xFAF4 U+92C6 # [2000] +0xFAF5 U+92CE # [2000] +0xFAF6 U+92D0 # [2000] +0xFAF7 U+92D7 # [2000] +0xFAF8 U+92D9 # [2000] +0xFAF9 U+92E5 # [2000] +0xFAFA U+92E7 # [2000] +0xFAFB U+9311 # [2000] +0xFAFC U+28A1E # [2000] [Unicode3.1] +0xFB40 U+28A29 # [2000] [Unicode3.1] +0xFB41 U+92F7 # [2000] +0xFB42 U+92F9 # [2000] +0xFB43 U+92FB # [2000] +0xFB44 U+9302 # [2000] +0xFB45 U+930D # [2000] +0xFB46 U+9315 # [2000] +0xFB47 U+931D # [2000] +0xFB48 U+931E # [2000] +0xFB49 U+9327 # [2000] +0xFB4A U+9329 # [2000] +0xFB4B U+28A71 # [2000] [Unicode3.1] +0xFB4C U+28A43 # [2000] [Unicode3.1] +0xFB4D U+9347 # [2000] +0xFB4E U+9351 # [2000] +0xFB4F U+9357 # [2000] +0xFB50 U+935A # [2000] +0xFB51 U+936B # [2000] +0xFB52 U+9371 # [2000] +0xFB53 U+9373 # [2000] +0xFB54 U+93A1 # [2000] +0xFB55 U+28A99 # [2000] [Unicode3.1] +0xFB56 U+28ACD # [2000] [Unicode3.1] +0xFB57 U+9388 # [2000] +0xFB58 U+938B # [2000] +0xFB59 U+938F # [2000] +0xFB5A U+939E # [2000] +0xFB5B U+93F5 # [2000] +0xFB5C U+28AE4 # [2000] [Unicode3.1] +0xFB5D U+28ADD # [2000] [Unicode3.1] +0xFB5E U+93F1 # [2000] +0xFB5F U+93C1 # [2000] +0xFB60 U+93C7 # [2000] +0xFB61 U+93DC # [2000] +0xFB62 U+93E2 # [2000] +0xFB63 U+93E7 # [2000] +0xFB64 U+9409 # [2000] +0xFB65 U+940F # [2000] +0xFB66 U+9416 # [2000] +0xFB67 U+9417 # [2000] +0xFB68 U+93FB # [2000] +0xFB69 U+9432 # [2000] +0xFB6A U+9434 # [2000] +0xFB6B U+943B # [2000] +0xFB6C U+9445 # [2000] +0xFB6D U+28BC1 # [2000] [Unicode3.1] +0xFB6E U+28BEF # [2000] [Unicode3.1] +0xFB6F U+946D # [2000] +0xFB70 U+946F # [2000] +0xFB71 U+9578 # [2000] +0xFB72 U+9579 # [2000] +0xFB73 U+9586 # [2000] +0xFB74 U+958C # [2000] +0xFB75 U+958D # [2000] +0xFB76 U+28D10 # [2000] [Unicode3.1] +0xFB77 U+95AB # [2000] +0xFB78 U+95B4 # [2000] +0xFB79 U+28D71 # [2000] [Unicode3.1] +0xFB7A U+95C8 # [2000] +0xFB7B U+28DFB # [2000] [Unicode3.1] +0xFB7C U+28E1F # [2000] [Unicode3.1] +0xFB7D U+962C # [2000] +0xFB7E U+9633 # [2000] +0xFB80 U+9634 # [2000] +0xFB81 U+28E36 # [2000] [Unicode3.1] +0xFB82 U+963C # [2000] +0xFB83 U+9641 # [2000] +0xFB84 U+9661 # [2000] +0xFB85 U+28E89 # [2000] [Unicode3.1] +0xFB86 U+9682 # [2000] +0xFB87 U+28EEB # [2000] [Unicode3.1] +0xFB88 U+969A # [2000] +0xFB89 U+28F32 # [2000] [Unicode3.1] +0xFB8A U+49E7 # [2000] +0xFB8B U+96A9 # [2000] +0xFB8C U+96AF # [2000] +0xFB8D U+96B3 # [2000] +0xFB8E U+96BA # [2000] +0xFB8F U+96BD # [2000] +0xFB90 U+49FA # [2000] +0xFB91 U+28FF8 # [2000] [Unicode3.1] +0xFB92 U+96D8 # [2000] +0xFB93 U+96DA # [2000] +0xFB94 U+96DD # [2000] +0xFB95 U+4A04 # [2000] +0xFB96 U+9714 # [2000] +0xFB97 U+9723 # [2000] +0xFB98 U+4A29 # [2000] +0xFB99 U+9736 # [2000] +0xFB9A U+9741 # [2000] +0xFB9B U+9747 # [2000] +0xFB9C U+9755 # [2000] +0xFB9D U+9757 # [2000] +0xFB9E U+975B # [2000] +0xFB9F U+976A # [2000] +0xFBA0 U+292A0 # [2000] [Unicode3.1] +0xFBA1 U+292B1 # [2000] [Unicode3.1] +0xFBA2 U+9796 # [2000] +0xFBA3 U+979A # [2000] +0xFBA4 U+979E # [2000] +0xFBA5 U+97A2 # [2000] +0xFBA6 U+97B1 # [2000] +0xFBA7 U+97B2 # [2000] +0xFBA8 U+97BE # [2000] +0xFBA9 U+97CC # [2000] +0xFBAA U+97D1 # [2000] +0xFBAB U+97D4 # [2000] +0xFBAC U+97D8 # [2000] +0xFBAD U+97D9 # [2000] +0xFBAE U+97E1 # [2000] +0xFBAF U+97F1 # [2000] +0xFBB0 U+9804 # [2000] +0xFBB1 U+980D # [2000] +0xFBB2 U+980E # [2000] +0xFBB3 U+9814 # [2000] +0xFBB4 U+9816 # [2000] +0xFBB5 U+4ABC # [2000] +0xFBB6 U+29490 # [2000] [Unicode3.1] +0xFBB7 U+9823 # [2000] +0xFBB8 U+9832 # [2000] +0xFBB9 U+9833 # [2000] +0xFBBA U+9825 # [2000] +0xFBBB U+9847 # [2000] +0xFBBC U+9866 # [2000] +0xFBBD U+98AB # [2000] +0xFBBE U+98AD # [2000] +0xFBBF U+98B0 # [2000] +0xFBC0 U+295CF # [2000] [Unicode3.1] +0xFBC1 U+98B7 # [2000] +0xFBC2 U+98B8 # [2000] +0xFBC3 U+98BB # [2000] +0xFBC4 U+98BC # [2000] +0xFBC5 U+98BF # [2000] +0xFBC6 U+98C2 # [2000] +0xFBC7 U+98C7 # [2000] +0xFBC8 U+98CB # [2000] +0xFBC9 U+98E0 # [2000] +0xFBCA U+2967F # [2000] [Unicode3.1] +0xFBCB U+98E1 # [2000] +0xFBCC U+98E3 # [2000] +0xFBCD U+98E5 # [2000] +0xFBCE U+98EA # [2000] +0xFBCF U+98F0 # [2000] +0xFBD0 U+98F1 # [2000] +0xFBD1 U+98F3 # [2000] +0xFBD2 U+9908 # [2000] +0xFBD3 U+4B3B # [2000] +0xFBD4 U+296F0 # [2000] [Unicode3.1] +0xFBD5 U+9916 # [2000] +0xFBD6 U+9917 # [2000] +0xFBD7 U+29719 # [2000] [Unicode3.1] +0xFBD8 U+991A # [2000] +0xFBD9 U+991B # [2000] +0xFBDA U+991C # [2000] +0xFBDB U+29750 # [2000] [Unicode3.1] +0xFBDC U+9931 # [2000] +0xFBDD U+9932 # [2000] +0xFBDE U+9933 # [2000] +0xFBDF U+993A # [2000] +0xFBE0 U+993B # [2000] +0xFBE1 U+993C # [2000] +0xFBE2 U+9940 # [2000] +0xFBE3 U+9941 # [2000] +0xFBE4 U+9946 # [2000] +0xFBE5 U+994D # [2000] +0xFBE6 U+994E # [2000] +0xFBE7 U+995C # [2000] +0xFBE8 U+995F # [2000] +0xFBE9 U+9960 # [2000] +0xFBEA U+99A3 # [2000] +0xFBEB U+99A6 # [2000] +0xFBEC U+99B9 # [2000] +0xFBED U+99BD # [2000] +0xFBEE U+99BF # [2000] +0xFBEF U+99C3 # [2000] +0xFBF0 U+99C9 # [2000] +0xFBF1 U+99D4 # [2000] +0xFBF2 U+99D9 # [2000] +0xFBF3 U+99DE # [2000] +0xFBF4 U+298C6 # [2000] [Unicode3.1] +0xFBF5 U+99F0 # [2000] +0xFBF6 U+99F9 # [2000] +0xFBF7 U+99FC # [2000] +0xFBF8 U+9A0A # [2000] +0xFBF9 U+9A11 # [2000] +0xFBFA U+9A16 # [2000] +0xFBFB U+9A1A # [2000] +0xFBFC U+9A20 # [2000] +0xFC40 U+9A31 # [2000] +0xFC41 U+9A36 # [2000] +0xFC42 U+9A44 # [2000] +0xFC43 U+9A4C # [2000] +0xFC44 U+9A58 # [2000] +0xFC45 U+4BC2 # [2000] +0xFC46 U+9AAF # [2000] +0xFC47 U+4BCA # [2000] +0xFC48 U+9AB7 # [2000] +0xFC49 U+4BD2 # [2000] +0xFC4A U+9AB9 # [2000] +0xFC4B U+29A72 # [2000] [Unicode3.1] +0xFC4C U+9AC6 # [2000] +0xFC4D U+9AD0 # [2000] +0xFC4E U+9AD2 # [2000] +0xFC4F U+9AD5 # [2000] +0xFC50 U+4BE8 # [2000] +0xFC51 U+9ADC # [2000] +0xFC52 U+9AE0 # [2000] +0xFC53 U+9AE5 # [2000] +0xFC54 U+9AE9 # [2000] +0xFC55 U+9B03 # [2000] +0xFC56 U+9B0C # [2000] +0xFC57 U+9B10 # [2000] +0xFC58 U+9B12 # [2000] +0xFC59 U+9B16 # [2000] +0xFC5A U+9B1C # [2000] +0xFC5B U+9B2B # [2000] +0xFC5C U+9B33 # [2000] +0xFC5D U+9B3D # [2000] +0xFC5E U+4C20 # [2000] +0xFC5F U+9B4B # [2000] +0xFC60 U+9B63 # [2000] +0xFC61 U+9B65 # [2000] +0xFC62 U+9B6B # [2000] +0xFC63 U+9B6C # [2000] +0xFC64 U+9B73 # [2000] +0xFC65 U+9B76 # [2000] +0xFC66 U+9B77 # [2000] +0xFC67 U+9BA6 # [2000] +0xFC68 U+9BAC # [2000] +0xFC69 U+9BB1 # [2000] +0xFC6A U+29DDB # [2000] [Unicode3.1] +0xFC6B U+29E3D # [2000] [Unicode3.1] +0xFC6C U+9BB2 # [2000] +0xFC6D U+9BB8 # [2000] +0xFC6E U+9BBE # [2000] +0xFC6F U+9BC7 # [2000] +0xFC70 U+9BF3 # [2000] +0xFC71 U+9BD8 # [2000] +0xFC72 U+9BDD # [2000] +0xFC73 U+9BE7 # [2000] +0xFC74 U+9BEA # [2000] +0xFC75 U+9BEB # [2000] +0xFC76 U+9BEF # [2000] +0xFC77 U+9BEE # [2000] +0xFC78 U+29E15 # [2000] [Unicode3.1] +0xFC79 U+9BFA # [2000] +0xFC7A U+29E8A # [2000] [Unicode3.1] +0xFC7B U+9BF7 # [2000] +0xFC7C U+29E49 # [2000] [Unicode3.1] +0xFC7D U+9C16 # [2000] +0xFC7E U+9C18 # [2000] +0xFC80 U+9C19 # [2000] +0xFC81 U+9C1A # [2000] +0xFC82 U+9C1D # [2000] +0xFC83 U+9C22 # [2000] +0xFC84 U+9C27 # [2000] +0xFC85 U+9C29 # [2000] +0xFC86 U+9C2A # [2000] +0xFC87 U+29EC4 # [2000] [Unicode3.1] +0xFC88 U+9C31 # [2000] +0xFC89 U+9C36 # [2000] +0xFC8A U+9C37 # [2000] +0xFC8B U+9C45 # [2000] +0xFC8C U+9C5C # [2000] +0xFC8D U+29EE9 # [2000] [Unicode3.1] +0xFC8E U+9C49 # [2000] +0xFC8F U+9C4A # [2000] +0xFC90 U+29EDB # [2000] [Unicode3.1] +0xFC91 U+9C54 # [2000] +0xFC92 U+9C58 # [2000] +0xFC93 U+9C5B # [2000] +0xFC94 U+9C5D # [2000] +0xFC95 U+9C5F # [2000] +0xFC96 U+9C69 # [2000] +0xFC97 U+9C6A # [2000] +0xFC98 U+9C6B # [2000] +0xFC99 U+9C6D # [2000] +0xFC9A U+9C6E # [2000] +0xFC9B U+9C70 # [2000] +0xFC9C U+9C72 # [2000] +0xFC9D U+9C75 # [2000] +0xFC9E U+9C7A # [2000] +0xFC9F U+9CE6 # [2000] +0xFCA0 U+9CF2 # [2000] +0xFCA1 U+9D0B # [2000] +0xFCA2 U+9D02 # [2000] +0xFCA3 U+29FCE # [2000] [Unicode3.1] +0xFCA4 U+9D11 # [2000] +0xFCA5 U+9D17 # [2000] +0xFCA6 U+9D18 # [2000] +0xFCA7 U+2A02F # [2000] [Unicode3.1] +0xFCA8 U+4CC4 # [2000] +0xFCA9 U+2A01A # [2000] [Unicode3.1] +0xFCAA U+9D32 # [2000] +0xFCAB U+4CD1 # [2000] +0xFCAC U+9D42 # [2000] +0xFCAD U+9D4A # [2000] +0xFCAE U+9D5F # [2000] +0xFCAF U+9D62 # [2000] +0xFCB0 U+2A0F9 # [2000] [Unicode3.1] +0xFCB1 U+9D69 # [2000] +0xFCB2 U+9D6B # [2000] +0xFCB3 U+2A082 # [2000] [Unicode3.1] +0xFCB4 U+9D73 # [2000] +0xFCB5 U+9D76 # [2000] +0xFCB6 U+9D77 # [2000] +0xFCB7 U+9D7E # [2000] +0xFCB8 U+9D84 # [2000] +0xFCB9 U+9D8D # [2000] +0xFCBA U+9D99 # [2000] +0xFCBB U+9DA1 # [2000] +0xFCBC U+9DBF # [2000] +0xFCBD U+9DB5 # [2000] +0xFCBE U+9DB9 # [2000] +0xFCBF U+9DBD # [2000] +0xFCC0 U+9DC3 # [2000] +0xFCC1 U+9DC7 # [2000] +0xFCC2 U+9DC9 # [2000] +0xFCC3 U+9DD6 # [2000] +0xFCC4 U+9DDA # [2000] +0xFCC5 U+9DDF # [2000] +0xFCC6 U+9DE0 # [2000] +0xFCC7 U+9DE3 # [2000] +0xFCC8 U+9DF4 # [2000] +0xFCC9 U+4D07 # [2000] +0xFCCA U+9E0A # [2000] +0xFCCB U+9E02 # [2000] +0xFCCC U+9E0D # [2000] +0xFCCD U+9E19 # [2000] +0xFCCE U+9E1C # [2000] +0xFCCF U+9E1D # [2000] +0xFCD0 U+9E7B # [2000] +0xFCD1 U+22218 # [2000] [Unicode3.1] +0xFCD2 U+9E80 # [2000] +0xFCD3 U+9E85 # [2000] +0xFCD4 U+9E9B # [2000] +0xFCD5 U+9EA8 # [2000] +0xFCD6 U+2A38C # [2000] [Unicode3.1] +0xFCD7 U+9EBD # [2000] +0xFCD8 U+2A437 # [2000] [Unicode3.1] +0xFCD9 U+9EDF # [2000] +0xFCDA U+9EE7 # [2000] +0xFCDB U+9EEE # [2000] +0xFCDC U+9EFF # [2000] +0xFCDD U+9F02 # [2000] +0xFCDE U+4D77 # [2000] +0xFCDF U+9F03 # [2000] +0xFCE0 U+9F17 # [2000] +0xFCE1 U+9F19 # [2000] +0xFCE2 U+9F2F # [2000] +0xFCE3 U+9F37 # [2000] +0xFCE4 U+9F3A # [2000] +0xFCE5 U+9F3D # [2000] +0xFCE6 U+9F41 # [2000] +0xFCE7 U+9F45 # [2000] +0xFCE8 U+9F46 # [2000] +0xFCE9 U+9F53 # [2000] +0xFCEA U+9F55 # [2000] +0xFCEB U+9F58 # [2000] +0xFCEC U+2A5F1 # [2000] [Unicode3.1] +0xFCED U+9F5D # [2000] +0xFCEE U+2A602 # [2000] [Unicode3.1] +0xFCEF U+9F69 # [2000] +0xFCF0 U+2A61A # [2000] [Unicode3.1] +0xFCF1 U+9F6D # [2000] +0xFCF2 U+9F70 # [2000] +0xFCF3 U+9F75 # [2000] +0xFCF4 U+2A6B2 # [2000] [Unicode3.1] diff --git a/make/tools/Makefile b/make/tools/Makefile index 0428e3c5585948333d742dbbf517aa1cc30cba51..be1c59a7cfaee45a32e66e8c472c263d5809452b 100644 --- a/make/tools/Makefile +++ b/make/tools/Makefile @@ -40,6 +40,7 @@ SUBDIRS = \ dir_diff \ dtdbuilder \ fontchecker \ + freetypecheck \ generate_break_iterator \ GenerateCharacter \ generatecurrencydata \ @@ -50,7 +51,8 @@ SUBDIRS = \ jdwpgen \ makeclasslist \ strip_properties \ - winver + winver \ + CharsetMapping all build clean clobber:: $(SUBDIRS-loop) @@ -58,4 +60,5 @@ all build clean clobber:: clean clobber:: $(RM) -r $(BUILDTOOLCLASSDIR) $(RM) -r $(BUILDTOOLJARDIR) + $(RM) -r $(BUILDTOOLBINDIR) diff --git a/make/tools/freetypecheck/Makefile b/make/tools/freetypecheck/Makefile index c2a3e644ba7def7cb51056b06796015f9ceb23be..c96854309f2be927f37ce6a0b0498344b79f74d6 100644 --- a/make/tools/freetypecheck/Makefile +++ b/make/tools/freetypecheck/Makefile @@ -22,48 +22,58 @@ # CA 95054 USA or visit www.sun.com if you need additional information or # have any questions. -# Builds test program for freetype sanity check. -# -# Makefile should be called with following input parameters -# FT_TEST - full name of test program -# FT_HEADERS - path to freetype headers -# FT_LIB - location of directory with library -# XARCH - xarch option if required +# Builds and runs test program for freetype sanity check. BUILDDIR = ../.. include $(BUILDDIR)/common/Defs.gmk -#test program is expected in the TEMPDIR -FT_TEST_PATH = $(TEMPDIR)/$(FT_TEST) - -all: $(FT_TEST_PATH) +# Default name +FT_TEST = $(BUILDTOOLBINDIR)/freetype_versioncheck$(EXE_SUFFIX) -FT_OPTIONS = -I$(FT_HEADERS) -I$(FT_HEADERS)/freetype2 -FT_OPTIONS += $(XARCH) +# Used on openjdk only +ifeq ($(OPENJDK),true) -#add runtime library search path +# Start with CFLAGS (which gets us the required -xarch setting on solaris) ifeq ($(PLATFORM), windows) - FREETYPE_LIB=$(FT_LIB)/freetype.lib - FREETYPE_DLL=$(FT_LIB)/freetype.dll - DFLAG=/D + FT_OPTIONS = /nologo $(CC_OBJECT_OUTPUT_FLAG)$(TEMPDIR) + FREETYPE_DLL = $(FREETYPE_LIB_PATH)/freetype.dll + FT_LD_OPTIONS = $(FREETYPE_LIB_PATH)/freetype.lib else - FT_OPTIONS += -L$(FT_LIB) - DFLAG = -D - - #add runtime lib search path to ensure test will be runnable + FT_OPTIONS = $(CFLAGS) + FT_LD_OPTIONS = -L$(FREETYPE_LIB_PATH) + # Add runtime lib search path to ensure test will be runnable ifeq ($(PLATFORM), solaris) - FT_OPTIONS += -R $(FT_LIB) -lfreetype + FT_LD_OPTIONS += -R $(FREETYPE_LIB_PATH) -lfreetype else #linux - FT_OPTIONS += -Wl,-rpath -Wl,$(FT_LIB) -lfreetype + FT_LD_OPTIONS += -Wl,-rpath -Wl,$(FREETYPE_LIB_PATH) -lfreetype endif endif +FT_OPTIONS += -I$(FREETYPE_HEADERS_PATH) +FT_OPTIONS += -I$(FREETYPE_HEADERS_PATH)/freetype2 +FT_OPTIONS += -DREQUIRED_FREETYPE_VERSION=$(REQUIRED_FREETYPE_VERSION) +FT_LD_OPTIONS += $(LFLAGS_$(COMPILER_VERSION)) -FT_OPTIONS += $(DFLAG)REQUIRED_FREETYPE_VERSION=$(REQUIRED_FREETYPE_VERSION) +# Create test program +all: $(FT_TEST) + @$(FT_TEST) -# On windows we need to copy dll to test dir -# ti ensure it will be found in runtime -$(FT_TEST_PATH): freetypecheck.c - @$(CC) $(FT_OPTIONS) $(CC_PROGRAM_OUTPUT_FLAG)$@ $< $(FREETYPE_LIB) $(LFLAGS_$(COMPILER_VERSION)) +# On windows we need to copy dll to test dir to ensure it will be found +# at runtime +$(FT_TEST): freetypecheck.c + @$(prep-target) + @$(CC) $(FT_OPTIONS) $(CC_PROGRAM_OUTPUT_FLAG)$@ $< $(FT_LD_OPTIONS) ifeq ($(PLATFORM), windows) @$(CP) $(FREETYPE_DLL) `dirname $@` endif + +else + +# Inform user this is openjdk only +all: + @$(ECHO) "The freetype files are only used with OpenJDK" + +endif + +clean:: + $(RM) $(FT_TEST) + diff --git a/make/tools/freetypecheck/freetypecheck.c b/make/tools/freetypecheck/freetypecheck.c index 00f460d7dc11dcbf32c173608e0c3d83d7dca0e3..12b26f7e88b725ea4a7c047f28990ae3ccc9bb6f 100644 --- a/make/tools/freetypecheck/freetypecheck.c +++ b/make/tools/freetypecheck/freetypecheck.c @@ -26,13 +26,16 @@ /* Test program for freetype sanity check. Prints "Failed" messages to STDOUT if check fails. */ +#include +#include + #include "ft2build.h" #include FT_FREETYPE_H #define QUOTEMACRO(x) QUOTEME(x) #define QUOTEME(x) #x -int main(char** argv, int argc) { +int main(int argc, char** argv) { char v[50]; FT_Int major, minor, patch; FT_Library library; diff --git a/make/tools/src/build/tools/charsetmapping/CharsetMapping.java b/make/tools/src/build/tools/charsetmapping/CharsetMapping.java new file mode 100644 index 0000000000000000000000000000000000000000..9637449e09a453a2024bd0fcded32eec8a26410b --- /dev/null +++ b/make/tools/src/build/tools/charsetmapping/CharsetMapping.java @@ -0,0 +1,271 @@ +/* + * Copyright 2008 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package build.tools.charsetmapping; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.*; + +public class CharsetMapping { + public final static char UNMAPPABLE_DECODING = '\uFFFD'; + public final static int UNMAPPABLE_ENCODING = -1; + + public static class Entry { + public int bs; //byte sequence reps + public int cp; //Unicode codepoint + public int cp2; //CC of composite + + public Entry () {} + public Entry (int bytes, int cp, int cp2) { + this.bs = bytes; + this.cp = cp; + this.cp2 = cp2; + } + } + + static Comparator comparatorCP = + new Comparator() { + public int compare(Entry m1, Entry m2) { + return m1.cp - m2.cp; + } + public boolean equals(Object obj) { + return this == obj; + } + }; + + public static class Parser { + static final Pattern basic = Pattern.compile("(?:0x)?(\\p{XDigit}++)\\s++(?:0x)?(\\p{XDigit}++)?\\s*+.*"); + static final int gBS = 1; + static final int gCP = 2; + static final int gCP2 = 3; + + BufferedReader reader; + boolean closed; + Matcher matcher; + int gbs, gcp, gcp2; + + public Parser (InputStream in, Pattern p, int gbs, int gcp, int gcp2) + throws IOException + { + this.reader = new BufferedReader(new InputStreamReader(in)); + this.closed = false; + this.matcher = p.matcher(""); + this.gbs = gbs; + this.gcp = gcp; + this.gcp2 = gcp2; + } + + public Parser (InputStream in, Pattern p) throws IOException { + this(in, p, gBS, gCP, gCP2); + } + + public Parser (InputStream in) throws IOException { + this(in, basic, gBS, gCP, gCP2); + } + + protected boolean isDirective(String line) { + return line.startsWith("#"); + } + + protected Entry parse(Matcher matcher, Entry mapping) { + mapping.bs = Integer.parseInt(matcher.group(gbs), 16); + mapping.cp = Integer.parseInt(matcher.group(gcp), 16); + if (gcp2 <= matcher.groupCount() && + matcher.group(gcp2) != null) + mapping.cp2 = Integer.parseInt(matcher.group(gcp2), 16); + else + mapping.cp2 = 0; + return mapping; + } + + public Entry next() throws Exception { + return next(new Entry()); + } + + // returns null and closes the input stream if the eof has beenreached. + public Entry next(Entry mapping) throws Exception { + if (closed) + return null; + String line; + while ((line = reader.readLine()) != null) { + if (isDirective(line)) + continue; + matcher.reset(line); + if (!matcher.lookingAt()) { + //System.out.println("Missed: " + line); + continue; + } + return parse(matcher, mapping); + } + reader.close(); + closed = true; + return null; + } + } + + // tags of different charset mapping tables + private final static int MAP_SINGLEBYTE = 0x1; // 0..256 : c + private final static int MAP_DOUBLEBYTE1 = 0x2; // min..max: c + private final static int MAP_DOUBLEBYTE2 = 0x3; // min..max: c [DB2] + private final static int MAP_SUPPLEMENT = 0x5; // db,c + private final static int MAP_SUPPLEMENT_C2B = 0x6; // c,db + private final static int MAP_COMPOSITE = 0x7; // db,base,cc + private final static int MAP_INDEXC2B = 0x8; // index table of c->bb + + private static final void writeShort(OutputStream out, int data) + throws IOException + { + out.write((data >>> 8) & 0xFF); + out.write((data ) & 0xFF); + } + + private static final void writeShortArray(OutputStream out, + int type, + int[] array, + int off, + int size) // exclusive + throws IOException + { + writeShort(out, type); + writeShort(out, size); + for (int i = off; i < size; i++) { + writeShort(out, array[off+i]); + } + } + + public static final void writeSIZE(OutputStream out, int data) + throws IOException + { + out.write((data >>> 24) & 0xFF); + out.write((data >>> 16) & 0xFF); + out.write((data >>> 8) & 0xFF); + out.write((data ) & 0xFF); + } + + public static void writeINDEXC2B(OutputStream out, int[] indexC2B) + throws IOException + { + writeShort(out, MAP_INDEXC2B); + writeShort(out, indexC2B.length); + int off = 0; + for (int i = 0; i < indexC2B.length; i++) { + if (indexC2B[i] != 0) { + writeShort(out, off); + off += 256; + } else { + writeShort(out, -1); + } + } + } + + public static void writeSINGLEBYTE(OutputStream out, int[] sb) + throws IOException + { + writeShortArray(out, MAP_SINGLEBYTE, sb, 0, 256); + } + + private static void writeDOUBLEBYTE(OutputStream out, + int type, + int[] db, + int b1Min, int b1Max, + int b2Min, int b2Max) + throws IOException + { + writeShort(out, type); + writeShort(out, b1Min); + writeShort(out, b1Max); + writeShort(out, b2Min); + writeShort(out, b2Max); + writeShort(out, (b1Max - b1Min + 1) * (b2Max - b2Min + 1)); + + for (int b1 = b1Min; b1 <= b1Max; b1++) { + for (int b2 = b2Min; b2 <= b2Max; b2++) { + writeShort(out, db[b1 * 256 + b2]); + } + } + } + public static void writeDOUBLEBYTE1(OutputStream out, + int[] db, + int b1Min, int b1Max, + int b2Min, int b2Max) + throws IOException + { + writeDOUBLEBYTE(out, MAP_DOUBLEBYTE1, db, b1Min, b1Max, b2Min, b2Max); + } + + public static void writeDOUBLEBYTE2(OutputStream out, + int[] db, + int b1Min, int b1Max, + int b2Min, int b2Max) + throws IOException + { + writeDOUBLEBYTE(out, MAP_DOUBLEBYTE2, db, b1Min, b1Max, b2Min, b2Max); + } + + // the c2b table is output as well + public static void writeSUPPLEMENT(OutputStream out, Entry[] supp, int size) + throws IOException + { + writeShort(out, MAP_SUPPLEMENT); + writeShort(out, size * 2); + // db at first half, cc at the low half + for (int i = 0; i < size; i++) { + writeShort(out, supp[i].bs); + } + for (int i = 0; i < size; i++) { + writeShort(out, supp[i].cp); + } + + //c2b + writeShort(out, MAP_SUPPLEMENT_C2B); + writeShort(out, size*2); + Arrays.sort(supp, 0, size, comparatorCP); + for (int i = 0; i < size; i++) { + writeShort(out, supp[i].cp); + } + for (int i = 0; i < size; i++) { + writeShort(out, supp[i].bs); + } + } + + public static void writeCOMPOSITE(OutputStream out, Entry[] comp, int size) + throws IOException + { + writeShort(out, MAP_COMPOSITE); + writeShort(out, size*3); + // comp is sorted already + for (int i = 0; i < size; i++) { + writeShort(out, (char)comp[i].bs); + writeShort(out, (char)comp[i].cp); + writeShort(out, (char)comp[i].cp2); + } + } +} diff --git a/make/tools/src/build/tools/charsetmapping/GenerateMapping.java b/make/tools/src/build/tools/charsetmapping/GenerateMapping.java new file mode 100644 index 0000000000000000000000000000000000000000..e1f1d86ab79fba869efb8d3520139731a3323cee --- /dev/null +++ b/make/tools/src/build/tools/charsetmapping/GenerateMapping.java @@ -0,0 +1,98 @@ +/* + * Copyright 2008 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package build.tools.charsetmapping; + +import java.io.*; +import java.util.regex.*; +import static build.tools.charsetmapping.CharsetMapping.*; + +public class GenerateMapping { + public static void main(String argv[]) throws IOException { + if (argv.length < 2) { + System.out.println("Usage: java GenCSData fMap fDat"); + System.exit(1); + } + genDataJIS0213(new FileInputStream(argv[0]), + new FileOutputStream(argv[1])); + } + + // regex pattern to parse the "jis0213.map" file + static Pattern sjis0213 = Pattern.compile("0x(\\p{XDigit}++)\\s++U\\+(\\p{XDigit}++)(?:\\+(\\p{XDigit}++))?\\s++#.*"); + private static void genDataJIS0213(InputStream in, OutputStream out) + { + int[] sb = new int[0x100]; // singlebyte + int[] db = new int[0x10000]; // doublebyte + int[] indexC2B = new int[256]; + Entry[] supp = new Entry[0x10000]; + Entry[] comp = new Entry[0x100]; + int suppTotal = 0; + int compTotal = 0; + + int b1Min1 = 0x81; + int b1Max1 = 0x9f; + int b1Min2 = 0xe0; + int b1Max2 = 0xfc; + int b2Min = 0x40; + int b2Max = 0xfe; + + //init + for (int i = 0; i < 0x80; i++) sb[i] = i; + for (int i = 0x80; i < 0x100; i++) sb[i] = UNMAPPABLE_DECODING; + for (int i = 0; i < 0x10000; i++) db[i] = UNMAPPABLE_DECODING; + try { + Parser p = new Parser(in, sjis0213); + Entry e = null; + while ((e = p.next()) != null) { + if (e.cp2 != 0) { + comp[compTotal++] = e; + } else { + if (e.cp <= 0xffff) { + if (e.bs <= 0xff) + sb[e.bs] = e.cp; + else + db[e.bs] = e.cp; + indexC2B[e.cp>>8] = 1; + } else { + supp[suppTotal++] = e; + } + } + } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + // c2b Index Table, always the first one + writeINDEXC2B(baos, indexC2B); + writeSINGLEBYTE(baos, sb); + writeDOUBLEBYTE1(baos, db, b1Min1, b1Max1, b2Min, b2Max); + writeDOUBLEBYTE2(baos, db, b1Min2, b1Max2, b2Min, b2Max); + writeSUPPLEMENT(baos, supp, suppTotal); + writeCOMPOSITE(baos, comp, compTotal); + writeSIZE(out, baos.size()); + baos.writeTo(out); + out.close(); + } catch (Exception x) { + x.printStackTrace(); + } + } +} diff --git a/make/tools/src/build/tools/jdwpgen/CommandNode.java b/make/tools/src/build/tools/jdwpgen/CommandNode.java index 4cdda4249cb142a0eee5e488546a85d62b06fce6..ec8666453ae08dc91e1ef872fc81564c2db2b8c1 100644 --- a/make/tools/src/build/tools/jdwpgen/CommandNode.java +++ b/make/tools/src/build/tools/jdwpgen/CommandNode.java @@ -32,9 +32,9 @@ class CommandNode extends AbstractCommandNode { void constrain(Context ctx) { if (components.size() == 3) { - Node out = (Node)components.get(0); - Node reply = (Node)components.get(1); - Node error = (Node)components.get(2); + Node out = components.get(0); + Node reply = components.get(1); + Node error = components.get(2); if (!(out instanceof OutNode)) { error("Expected 'Out' item, got: " + out); } @@ -45,7 +45,7 @@ class CommandNode extends AbstractCommandNode { error("Expected 'ErrorSet' item, got: " + error); } } else if (components.size() == 1) { - Node evt = (Node)components.get(0); + Node evt = components.get(0); if (!(evt instanceof EventNode)) { error("Expected 'Event' item, got: " + evt); } diff --git a/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java b/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java index 6d688dd7f72a478ebcc9b993b8bb6fdb80c29374..325ebc9ef46154e5c4a0883f65a27ee37e187432 100644 --- a/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java +++ b/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java @@ -98,7 +98,7 @@ class ConstantSetNode extends AbstractNamedNode { if (constantMap == null) { return ""; } - String com = (String) constantMap.get(key); + String com = constantMap.get(key); if(com == null){ return ""; } else { diff --git a/make/tools/src/build/tools/jdwpgen/RepeatNode.java b/make/tools/src/build/tools/jdwpgen/RepeatNode.java index 40d4e0899bd570da0621cf169d91a427c62d44d7..4c8f20982f2bfae3688602f5d700689f8877f661 100644 --- a/make/tools/src/build/tools/jdwpgen/RepeatNode.java +++ b/make/tools/src/build/tools/jdwpgen/RepeatNode.java @@ -37,7 +37,7 @@ class RepeatNode extends AbstractTypeNode { if (components.size() != 1) { error("Repeat must have exactly one member, use Group for more"); } - member = (Node)(components.get(0)); + member = components.get(0); if (!(member instanceof TypeNode)) { error("Repeat member must be type specifier"); } diff --git a/make/tools/winver/bin/winver.exe b/make/tools/winver/bin/winver.exe old mode 100644 new mode 100755 diff --git a/src/share/bin/emessages.h b/src/share/bin/emessages.h index f11c396ad60185501a7125c9b198fb33c778171a..03824bba5d1570138953afcd333d194c5257f263 100644 --- a/src/share/bin/emessages.h +++ b/src/share/bin/emessages.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2008 Sun Microsystems, 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 @@ -50,7 +50,7 @@ #define JAR_ERROR2 "Error: Unable to access jarfile %s" #define JAR_ERROR3 "Error: Invalid or corrupt jarfile %s" -#define CLS_ERROR1 "Error: Could not find the main class.\n" JNI_ERROR +#define CLS_ERROR1 "Error: Could not find the main class %s.\n" JNI_ERROR #define CLS_ERROR2 "Error: Failed to load Main Class: %s\n%s" #define CLS_ERROR3 "Error: No main method found in specified class.\n" GEN_ERROR #define CLS_ERROR4 "Error: Main method not public\n" GEN_ERROR diff --git a/src/share/bin/java.c b/src/share/bin/java.c index 2e86de9a401a4e2b1cc08c8b434b71d449e4eee3..f7cbcdc95bce46ab467dd1af347b882dd9ac5c95 100644 --- a/src/share/bin/java.c +++ b/src/share/bin/java.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1995-2008 Sun Microsystems, 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 @@ -205,9 +205,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ _wc_enabled = cpwildcard; _ergo_policy = ergo; - if (javaw == JNI_TRUE) - SetJavaw(); - + InitLauncher(javaw); DumpState(); /* @@ -416,7 +414,7 @@ JavaMain(void * _args) mainClass = LoadClass(env, classname); if(mainClass == NULL) { /* exception occured */ ReportExceptionDescription(env); - ReportErrorMessage(CLS_ERROR1); + ReportErrorMessage(CLS_ERROR1, classname); goto leave; } (*env)->ReleaseStringUTFChars(env, mainClassName, classname); @@ -435,7 +433,7 @@ JavaMain(void * _args) mainClass = LoadClass(env, classname); if(mainClass == NULL) { /* exception occured */ ReportExceptionDescription(env); - ReportErrorMessage(CLS_ERROR1); + ReportErrorMessage(CLS_ERROR1, classname); goto leave; } (*env)->ReleaseStringUTFChars(env, mainClassName, classname); diff --git a/src/share/bin/java.h b/src/share/bin/java.h index c86c5d107db40bc68c6d096c40e6866886ef07e7..291b6755690bf836deffd7216cb1752e2c79da21 100644 --- a/src/share/bin/java.h +++ b/src/share/bin/java.h @@ -172,7 +172,6 @@ const char* GetDotVersion(); const char* GetFullVersion(); jboolean IsJavaArgs(); jboolean IsJavaw(); -void SetJavaw(); jint GetErgoPolicy(); jboolean ServerClassMachine(); @@ -180,5 +179,9 @@ jboolean ServerClassMachine(); static int ContinueInNewThread(InvocationFunctions* ifn, int argc, char** argv, char* jarfile, char* classname, int ret); +/* + * Initialize platform specific settings + */ +void InitLauncher(jboolean javaw); #endif /* _JAVA_H_ */ diff --git a/src/share/bin/main.c b/src/share/bin/main.c index 7052159f2672d7a4f12c69bf208c9aa011651ce1..88d9190a555eb86c99bd2c43bd2a3a60187db2b8 100644 --- a/src/share/bin/main.c +++ b/src/share/bin/main.c @@ -64,8 +64,6 @@ main(int argc, char ** argv) margv = argv; #endif /* JAVAW */ - JLI_SetTraceLauncher(); - return JLI_Launch(margc, margv, sizeof(const_jargs) / sizeof(char *), const_jargs, sizeof(const_appclasspath) / sizeof(char *), const_appclasspath, diff --git a/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java b/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java index afb9b3e94a559cfeee86fd5e8f3d58bcc84af791..ee5ed5a9229797b3f93e470dde01d3a8dbed7d69 100644 --- a/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java +++ b/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java @@ -34,6 +34,7 @@ import java.security.KeyRep; import java.security.GeneralSecurityException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; import java.security.spec.InvalidKeySpecException; import javax.crypto.Mac; import javax.crypto.SecretKey; @@ -107,12 +108,17 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey { throw new InvalidKeySpecException("Key length is negative"); } try { - this.prf = Mac.getInstance(prfAlgo, new SunJCE()); + this.prf = Mac.getInstance(prfAlgo, "SunJCE"); } catch (NoSuchAlgorithmException nsae) { // not gonna happen; re-throw just in case InvalidKeySpecException ike = new InvalidKeySpecException(); ike.initCause(nsae); throw ike; + } catch (NoSuchProviderException nspe) { + // Again, not gonna happen; re-throw just in case + InvalidKeySpecException ike = new InvalidKeySpecException(); + ike.initCause(nspe); + throw ike; } this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength); } diff --git a/src/share/classes/com/sun/inputmethods/internal/indicim/resources/DisplayNames.properties b/src/share/classes/com/sun/inputmethods/internal/indicim/resources/DisplayNames.properties index e592c36caba0207519290ad5481130315a4802f3..f0feb6395c034f33c150f09061e2453ce4881610 100644 --- a/src/share/classes/com/sun/inputmethods/internal/indicim/resources/DisplayNames.properties +++ b/src/share/classes/com/sun/inputmethods/internal/indicim/resources/DisplayNames.properties @@ -1,5 +1,6 @@ -# -# Default Input method display names for Indic input methods -# - -DisplayName.Devanagari = Devanagari Input Method +# +# Default Input method display names for Indic input methods +# + +DisplayName.Devanagari = Devanagari Input Method + diff --git a/src/share/classes/com/sun/inputmethods/internal/thaiim/resources/DisplayNames.properties b/src/share/classes/com/sun/inputmethods/internal/thaiim/resources/DisplayNames.properties index f88a4bf2dcaa8817cadb516ff9610f604babeb0c..e4528a49a5337f0fe21ffbbe1b06062ac5708f4e 100644 --- a/src/share/classes/com/sun/inputmethods/internal/thaiim/resources/DisplayNames.properties +++ b/src/share/classes/com/sun/inputmethods/internal/thaiim/resources/DisplayNames.properties @@ -1,5 +1,6 @@ -# -# Default Input method display names for Thai input methods -# - -DisplayName.Thai = Thai Input Method +# +# Default Input method display names for Thai input methods +# + +DisplayName.Thai = Thai Input Method + diff --git a/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java b/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java index a637aa14745e1b46923cd7dc995c0f5e4469ccb7..eea8d4309ebea9640673756fa2b6d923c87c2b23 100644 --- a/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java +++ b/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java @@ -34,8 +34,6 @@ import java.util.Set; import java.util.HashSet; import java.util.WeakHashMap; import java.lang.ref.WeakReference; -import java.io.PrintWriter; -import java.io.StringWriter; import java.security.AccessControlContext; import java.security.Permission; import java.security.ProtectionDomain; @@ -51,7 +49,6 @@ import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.IntrospectionException; import javax.management.InvalidAttributeValueException; -import javax.management.JMException; import javax.management.JMRuntimeException; import javax.management.ListenerNotFoundException; import javax.management.MalformedObjectNameException; @@ -84,11 +81,10 @@ import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER; import com.sun.jmx.mbeanserver.DynamicMBean2; import com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository; import com.sun.jmx.mbeanserver.MBeanInstantiator; -import com.sun.jmx.mbeanserver.MXBeanSupport; import com.sun.jmx.mbeanserver.Repository; import com.sun.jmx.mbeanserver.NamedObject; -import com.sun.jmx.defaults.ServiceName; import com.sun.jmx.mbeanserver.Introspector; +import com.sun.jmx.mbeanserver.Util; import com.sun.jmx.remote.util.EnvHelp; /** @@ -623,18 +619,9 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { List result = new ArrayList(domains.length); for (int i = 0; i < domains.length; i++) { try { - ObjectName domain = new ObjectName(domains[i] + ":x=x"); + ObjectName domain = Util.newObjectName(domains[i] + ":x=x"); checkMBeanPermission((String) null, null, domain, "getDomains"); result.add(domains[i]); - } catch (MalformedObjectNameException e) { - // Should never occur... But let's log it just in case. - if (MBEANSERVER_LOGGER.isLoggable(Level.SEVERE)) { - MBEANSERVER_LOGGER.logp(Level.SEVERE, - DefaultMBeanServerInterceptor.class.getName(), - "getDomains", - "Failed to check permission for domain = " + - domains[i], e); - } } catch (SecurityException e) { // OK: Do not add this domain to the list } diff --git a/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java b/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java index b68fd28ffa75af2f269185e3ad39baec4fc09e6c..2a72f3d222f4e334e4cb7c20b9f915318f62cd39 100644 --- a/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java +++ b/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java @@ -43,6 +43,13 @@ import javax.management.MBeanInfo; import javax.management.NotCompliantMBeanException; import com.sun.jmx.mbeanserver.Util; +import com.sun.jmx.remote.util.EnvHelp; +import java.beans.BeanInfo; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Array; +import java.lang.reflect.InvocationTargetException; +import javax.management.AttributeNotFoundException; +import javax.management.openmbean.CompositeData; /** * This class contains the methods for performing all the tests needed to verify @@ -482,4 +489,33 @@ public class Introspector { return null; } + + public static Object elementFromComplex(Object complex, String element) + throws AttributeNotFoundException { + try { + if (complex.getClass().isArray() && element.equals("length")) { + return Array.getLength(complex); + } else if (complex instanceof CompositeData) { + return ((CompositeData) complex).get(element); + } else { + // Java Beans introspection + // + BeanInfo bi = java.beans.Introspector.getBeanInfo(complex.getClass()); + PropertyDescriptor[] pds = bi.getPropertyDescriptors(); + for (PropertyDescriptor pd : pds) + if (pd.getName().equals(element)) + return pd.getReadMethod().invoke(complex); + throw new AttributeNotFoundException( + "Could not find the getter method for the property " + + element + " using the Java Beans introspector"); + } + } catch (InvocationTargetException e) { + throw new IllegalArgumentException(e); + } catch (AttributeNotFoundException e) { + throw e; + } catch (Exception e) { + throw EnvHelp.initCause( + new AttributeNotFoundException(e.getMessage()), e); + } + } } diff --git a/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java b/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java index f908a352a2bd11c237add2d856bd3de0b839da09..5975f1a391bebe23be88cd70f5a90f537d306ec4 100644 --- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java +++ b/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java @@ -107,10 +107,7 @@ class MBeanAnalyzer { private MBeanAnalyzer(Class mbeanInterface, MBeanIntrospector introspector) throws NotCompliantMBeanException { - if (!mbeanInterface.isInterface()) { - throw new NotCompliantMBeanException("Not an interface: " + - mbeanInterface.getName()); - } + introspector.checkCompliance(mbeanInterface); try { initMaps(mbeanInterface, introspector); @@ -121,11 +118,10 @@ class MBeanAnalyzer { // Introspect the mbeanInterface and initialize this object's maps. // - private void initMaps(Class mbeanInterface, + private void initMaps(Class mbeanType, MBeanIntrospector introspector) throws Exception { - final Method[] methodArray = mbeanInterface.getMethods(); - - final List methods = eliminateCovariantMethods(methodArray); + final List methods1 = introspector.getMethods(mbeanType); + final List methods = eliminateCovariantMethods(methods1); /* Run through the methods to detect inconsistencies and to enable us to give getter and setter together to visitAttribute. */ @@ -234,13 +230,13 @@ class MBeanAnalyzer { but existing code may depend on it and users may be used to seeing operations or attributes appear in a particular order. */ static List - eliminateCovariantMethods(Method[] methodArray) { + eliminateCovariantMethods(List startMethods) { // We are assuming that you never have very many methods with the // same name, so it is OK to use algorithms that are quadratic // in the number of methods with the same name. - final int len = methodArray.length; - final Method[] sorted = methodArray.clone(); + final int len = startMethods.size(); + final Method[] sorted = startMethods.toArray(new Method[len]); Arrays.sort(sorted,MethodOrder.instance); final Set overridden = newSet(); for (int i=1;i { } } - final List methods = newList(Arrays.asList(methodArray)); + final List methods = newList(startMethods); methods.removeAll(overridden); return methods; } diff --git a/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java b/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java index c191005d6219cd1b91cd8d0db6cd53819be1642d..ea7dbdade336bff56e3ae03251995c16202b529f 100644 --- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java +++ b/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java @@ -34,6 +34,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; +import java.util.Arrays; import java.util.List; import java.util.WeakHashMap; @@ -169,6 +170,19 @@ abstract class MBeanIntrospector { */ abstract Descriptor getMBeanDescriptor(Class resourceClass); + void checkCompliance(Class mbeanType) throws NotCompliantMBeanException { + if (!mbeanType.isInterface()) { + throw new NotCompliantMBeanException("Not an interface: " + + mbeanType.getName()); + } + } + + /** + * Get the methods to be analyzed to build the MBean interface. + */ + List getMethods(final Class mbeanType) throws Exception { + return Arrays.asList(mbeanType.getMethods()); + } final PerInterface getPerInterface(Class mbeanInterface) throws NotCompliantMBeanException { diff --git a/src/share/classes/com/sun/jmx/mbeanserver/NotificationMBeanSupport.java b/src/share/classes/com/sun/jmx/mbeanserver/NotificationMBeanSupport.java new file mode 100644 index 0000000000000000000000000000000000000000..f1e3a13c891c1d4a62b24dbe96ce156fefaddbfd --- /dev/null +++ b/src/share/classes/com/sun/jmx/mbeanserver/NotificationMBeanSupport.java @@ -0,0 +1,81 @@ +/* + * Copyright 2007 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package com.sun.jmx.mbeanserver; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import javax.management.NotCompliantMBeanException; +import javax.management.Notification; + +/** + *

A variant of {@code StandardMBeanSupport} where the only + * methods included are public getters. This is used by + * {@code QueryNotificationFilter} to pretend that a Notification is + * an MBean so it can have a query evaluated on it. Standard queries + * never set attributes or invoke methods but custom queries could and + * we don't want to allow that. Also we don't want to fail if a + * Notification happens to have inconsistent types in a pair of getX and + * setX methods, and we want to include the Object.getClass() method. + */ +public class NotificationMBeanSupport extends StandardMBeanSupport { + public NotificationMBeanSupport(T n) + throws NotCompliantMBeanException { + super(n, Util.>cast(n.getClass())); + } + + @Override + MBeanIntrospector getMBeanIntrospector() { + return introspector; + } + + private static class Introspector extends StandardMBeanIntrospector { + @Override + void checkCompliance(Class mbeanType) {} + + @Override + List getMethods(final Class mbeanType) + throws Exception { + List methods = new ArrayList(); + for (Method m : mbeanType.getMethods()) { + String name = m.getName(); + Class ret = m.getReturnType(); + if (m.getParameterTypes().length == 0) { + if ((name.startsWith("is") && name.length() > 2 && + ret == boolean.class) || + (name.startsWith("get") && name.length() > 3 && + ret != void.class)) { + methods.add(m); + } + } + } + return methods; + } + + } + private static final MBeanIntrospector introspector = + new Introspector(); +} diff --git a/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java b/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java index b4a8a44f11532edd06781e242e0108694599ae5e..25ac0a28e10cdeb7e70e0aa82206f9f35a1e120e 100644 --- a/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java +++ b/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java @@ -438,7 +438,7 @@ public abstract class OpenConverter { c.getClassLoader() == null); final List methods = - MBeanAnalyzer.eliminateCovariantMethods(c.getMethods()); + MBeanAnalyzer.eliminateCovariantMethods(Arrays.asList(c.getMethods())); final SortedMap getterMap = newSortedMap(); /* Select public methods that look like "T getX()" or "boolean @@ -1118,11 +1118,11 @@ public abstract class OpenConverter { final Class propertyNamesClass = ConstructorProperties.class; Class targetClass = getTargetClass(); - Constructor[] constrs = targetClass.getConstructors(); + Constructor[] constrs = targetClass.getConstructors(); // Applicable if and only if there are any annotated constructors - List annotatedConstrList = newList(); - for (Constructor constr : constrs) { + List> annotatedConstrList = newList(); + for (Constructor constr : constrs) { if (Modifier.isPublic(constr.getModifiers()) && constr.getAnnotation(propertyNamesClass) != null) annotatedConstrList.add(constr); @@ -1152,7 +1152,7 @@ public abstract class OpenConverter { // Also remember the set of properties in that constructor // so we can test unambiguity. Set getterIndexSets = newSet(); - for (Constructor constr : annotatedConstrList) { + for (Constructor constr : annotatedConstrList) { String[] propertyNames = constr.getAnnotation(propertyNamesClass).value(); @@ -1309,10 +1309,10 @@ public abstract class OpenConverter { } private static class Constr { - final Constructor constructor; + final Constructor constructor; final int[] paramIndexes; final BitSet presentParams; - Constr(Constructor constructor, int[] paramIndexes, + Constr(Constructor constructor, int[] paramIndexes, BitSet presentParams) { this.constructor = constructor; this.paramIndexes = paramIndexes; diff --git a/src/share/classes/com/sun/jmx/mbeanserver/Repository.java b/src/share/classes/com/sun/jmx/mbeanserver/Repository.java index e33492d945e25dff913e5cb53cb76eb8d168633f..38a1fc6d4f431f96092a7b1378f6b478cd058ed9 100644 --- a/src/share/classes/com/sun/jmx/mbeanserver/Repository.java +++ b/src/share/classes/com/sun/jmx/mbeanserver/Repository.java @@ -415,17 +415,8 @@ public class Repository { boolean to_default_domain = false; // Set domain to default if domain is empty and not already set - if (dom.length() == 0) { - try { - name = new ObjectName(domain + name.toString()); - } catch (MalformedObjectNameException e) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - Repository.class.getName(), "addMBean", - "Unexpected MalformedObjectNameException", e); - } - } - } + if (dom.length() == 0) + name = Util.newObjectName(domain + name.toString()); // Do we have default domain ? if (dom == domain) { diff --git a/src/share/classes/com/sun/jmx/mbeanserver/Util.java b/src/share/classes/com/sun/jmx/mbeanserver/Util.java index 712b4e378a88255d604f0bb1254d6daaa22f3259..f2dbe60bbdfde06c7c836444a10b71e44dbfbb7c 100644 --- a/src/share/classes/com/sun/jmx/mbeanserver/Util.java +++ b/src/share/classes/com/sun/jmx/mbeanserver/Util.java @@ -38,6 +38,8 @@ import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; public class Util { static Map newMap() { @@ -85,6 +87,14 @@ public class Util { return new ArrayList(c); } + public static ObjectName newObjectName(String s) { + try { + return new ObjectName(s); + } catch (MalformedObjectNameException e) { + throw new IllegalArgumentException(e); + } + } + /* This method can be used by code that is deliberately violating the * allowed checked casts. Rather than marking the whole method containing * the code with @SuppressWarnings, you can use a call to this method for diff --git a/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java b/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java index 45c1b55a861810eeb8ca24bb4959013b678c847c..f736dc500bd4cdbf4e234ad71a8d2a65233dd3fa 100644 --- a/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java +++ b/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java @@ -25,6 +25,8 @@ package com.sun.management; +import java.lang.management.PlatformManagedObject; + /** * Diagnostic management interface for the HotSpot Virtual Machine. * The diagnostic MBean is registered to the platform MBeanServer @@ -35,8 +37,13 @@ package com.sun.management; *

* com.sun.management:type=HotSpotDiagnostic *
+.* + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * + * @see ManagementFactory#getPlatformMXBeans(Class) */ -public interface HotSpotDiagnosticMXBean { +public interface HotSpotDiagnosticMXBean extends PlatformManagedObject { /** * Dumps the heap to the outputFile file in the same * format as the hprof heap dump. diff --git a/src/share/classes/com/sun/management/package.html b/src/share/classes/com/sun/management/package.html index 8a1a4a5381c8837e5f2231aedb9a31df91a40634..372d9c4cc54b16219d07949b01ecafbafefb6df4 100644 --- a/src/share/classes/com/sun/management/package.html +++ b/src/share/classes/com/sun/management/package.html @@ -1,4 +1,4 @@ -CTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd b/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd index d69852ff8421c3400819831b6c16b56ce3f8d0af..3a08c64f4b6a93c30b83468c3827df0fe0231c9c 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd @@ -1,347 +1,347 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties b/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties index 1b8e97bfd633971f6c88b0130b4bca5cba396c54..8c8b2ab1f8dc85b7ff0a6a10ae90d5c95ddd9b35 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties @@ -1,123 +1,123 @@ -algorithm.alreadyRegistered = URI {0} already assigned to class {1} -algorithm.classDoesNotExist = Cannot register URI {0} to class {1} because this class does not exist in CLASSPATH -algorithm.ClassDoesNotExist = Class {0} does not exist -algorithm.extendsWrongClass = Cannot register URI {0} to class {1} because it does not extend {2} -algorithms.CannotUseAlgorithmParameterSpecOnDSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating DSA signatures. -algorithms.CannotUseAlgorithmParameterSpecOnRSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating RSA signatures. -algorithms.CannotUseSecureRandomOnMAC = Sorry, but you cannot use a SecureRandom object for creating MACs. -algorithms.HMACOutputLengthOnlyForHMAC = A HMACOutputLength can only be specified for HMAC integrity algorithms -algorithms.NoSuchAlgorithm = The requested algorithm {0} does not exist. Original Message was: {1} -algorithms.NoSuchMap = The algorithm URI "{0}" could not be mapped to a JCE algorithm -algorithms.NoSuchProvider = The specified Provider {0} does not exist. Original Message was: {1} -algorithms.operationOnlyVerification = A public key can only used for verification of a signature. -algorithms.WrongKeyForThisOperation = Sorry, you supplied the wrong key type for this operation! You supplied a {0} but a {1} is needed. -attributeValueIllegal = The attribute {0} has value {1} but must be {2} -c14n.Canonicalizer.Exception = Exception during Canonicalization: Original Message was {0} -c14n.Canonicalizer.IllegalNode = Illegal node type {0}, node name was {1} -c14n.Canonicalizer.NoSuchCanonicalizer = No canonicalizer found with URI {0} -c14n.Canonicalizer.ParserConfigurationException = ParserConfigurationException during Canonicalization: Original Message was {0} -c14n.Canonicalizer.RelativeNamespace = Element {0} has a relative namespace: {1}="{2}" -c14n.Canonicalizer.SAXException = SAXException during Canonicalization: Original Message was {0} -c14n.Canonicalizer.TraversalNotSupported = This DOM document does not support Traversal {0} -c14n.Canonicalizer.UnsupportedEncoding = Unsupported encoding {0} -c14n.Canonicalizer.UnsupportedOperation = This canonicalizer does not support this operation -c14n.XMLUtils.circumventBug2650forgotten = The tree has not been prepared for canonicalization using XMLUtils#circumventBug2650(Document) -certificate.noSki.lowVersion = Certificate cannot contain a SubjectKeyIdentifier because it is only X509v{0} -certificate.noSki.notOctetString = Certificates SubjectKeyIdentifier is not a OctetString -certificate.noSki.null = Certificate does not contain a SubjectKeyIdentifier -defaultNamespaceCannotBeSetHere = Default namespace cannot be set here -ElementProxy.nullElement = Cannot create an ElementProxy from a null argument -empty = {0} -encryption.algorithmCannotBeUsedForEncryptedData = encryption.algorithmCannotBeUsedForEncryptedData {0} -encryption.algorithmCannotEatInitParams = encryption.algorithmCannotEatInitParams -encryption.algorithmCannotEncryptDecrypt = encryption.algorithmCannotEncryptDecrypt -encryption.algorithmCannotWrapUnWrap = encryption.algorithmCannotWrapUnWrap -encryption.ExplicitKeySizeMismatch = The xenc:KeySize element requests a key size of {0} bit but the algorithm implements {1} bit -encryption.nonceLongerThanDecryptedPlaintext = The given nonce is longer than the available plaintext. I Cannot strip away this. -encryption.RSAOAEP.dataHashWrong = data hash wrong -encryption.RSAOAEP.dataStartWrong = data wrong start {0} -encryption.RSAOAEP.dataTooShort = data too short -encryption.RSAPKCS15.blockTruncated = block truncated -encryption.RSAPKCS15.noDataInBlock = no data in block -encryption.RSAPKCS15.unknownBlockType = unknown block type -encryption.nokey = No Key Encryption Key loaded and cannot determine using key resolvers -endorsed.jdk1.4.0 = Since it seems that nobody reads our installation notes, we must do it in the exception messages. Hope you read them. You did NOT use the endorsed mechanism from JDK 1.4 properly; look at how to solve this problem. -errorMessages.InvalidDigestValueException = INVALID signature -- check reference resolution. -errorMessages.InvalidSignatureValueException = INVALID signature -- core validation failed. -errorMessages.IOException = Other file I/O and similar exceptions. -errorMessages.MissingKeyFailureException = Cannot verify because of missing public key. Provide it via addResource and try again. -errorMessages.MissingResourceFailureException = Cannot verify because of unresolved references. Provide it via addResource and try again. -errorMessages.NoSuchAlgorithmException = Unknown Algorithm {0} -errorMessages.NotYetImplementedException = Functionality not yet there. -errorMessages.XMLSignatureException = Verification failed for some other reason. -decoding.divisible.four = It should be divisible by four -decoding.general = Error while decoding -FileKeyStorageImpl.addToDefaultFromRemoteNotImplemented = Method addToDefaultFromRemote() not yet implemented. -FileKeyStorageImpl.NoCert.Context = Not found such a X509Certificate including context {0} -FileKeyStorageImpl.NoCert.IssNameSerNo = Not found such a X509Certificate with IssuerName {0} and serial number {1} -FileKeyStorageImpl.NoCert.SubjName = Not found such a X509Certificate including SubjectName {0} -generic.dontHaveConstructionElement = I do not have a construction Element -generic.EmptyMessage = {0} -generic.NotYetImplemented = {0} Not YET implemented ;-(( -java.security.InvalidKeyException = Invalid key -java.security.NoSuchProviderException = Unknown or unsupported provider -java.security.UnknownKeyType = Unknown or unsupported key type {0} -KeyInfo.needKeyResolver = More than one keyResovler have to be registered -KeyInfo.nokey = Cannot get key from {0} -KeyInfo.noKey = Cannot get the public key -KeyInfo.wrongNumberOfObject = Need {0} keyObjects -KeyInfo.wrongUse = This object was made for getting {0} -keyResolver.alreadyRegistered = {1} class has already been registered for {0} -KeyResolver.needStorageResolver = Need a StorageResolver to retrieve a Certificate from a {0} -KeyResoverSpiImpl.cannotGetCert = Cannot get the Certificate that include or in {1} in implement class {0} -KeyResoverSpiImpl.elementGeneration = Cannot make {1} element in implement class {0} -KeyResoverSpiImpl.getPoublicKey = Cannot get the public key from implement class {0} -KeyResoverSpiImpl.InvalidElement = Cannot set (2) Element in implement class {0} -KeyResoverSpiImpl.keyStore = KeyStorage error in implement class {0} -KeyResoverSpiImpl.need.Element = {1} type of Element is needed in implement class {0} -KeyResoverSpiImpl.wrongCRLElement = Cannot make CRL from {1} in implement class {0} -KeyResoverSpiImpl.wrongKeyObject = Need {1} type of KeyObject for generation Element in implement class{0} -KeyResoverSpiImpl.wrongNumberOfObject = Need {1} keyObject in implement class {0} -KeyStore.alreadyRegistered = {0} Class has already been registered for {1} -KeyStore.register = {1} type class register error in class {0} -KeyStore.registerStore.register = Registeration error for type {0} -KeyValue.IllegalArgument = Cannot create a {0} from {1} -namespacePrefixAlreadyUsedByOtherURI = Namespace prefix {0} already used by other URI {1} -notYetInitialized = The module {0} is not yet initialized -prefix.AlreadyAssigned = You want to assign {0} as prefix for namespace {1} but it is already assigned for {2} -signature.Canonicalizer.UnknownCanonicalizer = Unknown canonicalizer. No handler installed for URI {0} -signature.DSA.invalidFormat = Invalid ASN.1 encoding of the DSA signature -signature.Generation.signBeforeGetValue = You have to XMLSignature.sign(java.security.PrivateKey) first -signature.signaturePropertyHasNoTarget = The Target attribute of the SignatureProperty must be set -signature.Transform.ErrorDuringTransform = A {1} was thrown during the {0} transform -signature.Transform.NotYetImplemented = Transform {0} not yet implemented -signature.Transform.NullPointerTransform = Null pointer as URI. Programming bug? -signature.Transform.UnknownTransform = Unknown transformation. No handler installed for URI {0} -signature.Transform.node = Current Node: {0} -signature.Transform.nodeAndType = Current Node: {0}, type: {1} -signature.Util.BignumNonPositive = bigInteger.signum() must be positive -signature.Util.NonTextNode = Not a text node -signature.Util.TooManyChilds = Too many childs of Type {0} in {1} -signature.Verification.certificateError = Certificate error -signature.Verification.IndexOutOfBounds = Index {0} illegal. We only have {1} References -signature.Verification.internalError = Internal error -signature.Verification.InvalidDigestOrReference = Invalid digest of reference {0} -signature.Verification.keyStore = KeyStore error -signature.Verification.MissingID = Cannot resolve element with ID {0} -signature.Verification.MissingResources = Cannot resolve external resource {0} -signature.Verification.NoSignatureElement = Input document contains no {0} Element in namespace {1} -signature.Verification.Reference.NoInput = The Reference for URI {0} has no XMLSignatureInput -signature.Verification.SignatureError = Signature error -signature.XMLSignatureInput.MissingConstuctor = Cannot construct a XMLSignatureInput from class {0} -signature.XMLSignatureInput.SerializeDOM = Input initialized with DOM Element. Use Canonicalization to serialize it -signature.XMLSignatureInput.nodesetReference = Unable to convert to nodeset the reference -transform.Init.IllegalContextArgument = Invalid context argument of class {0}. Must be String, org.w3c.dom.NodeList or java.io.InputStream. -transform.init.NotInitialized = -transform.init.wrongURI = Initialized with wrong URI. How could this happen? We implement {0} but {1} was used during initialization -utils.Base64.IllegalBitlength = Illegal byte length; Data to be decoded must be a multiple of 4 -Base64Decoding = Error while decoding -utils.resolver.noClass = Could not find a resolver for URI {0} and Base {1} -xml.WrongContent = Cannot find {0} in {1} -xml.WrongElement = Cannot create a {0} from a {1} element -xpath.funcHere.documentsDiffer = The XPath is not in the same document as the context node -xpath.funcHere.noXPathContext = Try to evaluate an XPath which uses the here() function but XPath is not inside an ds:XPath Element. XPath was : {0} +algorithm.alreadyRegistered = URI {0} already assigned to class {1} +algorithm.classDoesNotExist = Cannot register URI {0} to class {1} because this class does not exist in CLASSPATH +algorithm.ClassDoesNotExist = Class {0} does not exist +algorithm.extendsWrongClass = Cannot register URI {0} to class {1} because it does not extend {2} +algorithms.CannotUseAlgorithmParameterSpecOnDSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating DSA signatures. +algorithms.CannotUseAlgorithmParameterSpecOnRSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating RSA signatures. +algorithms.CannotUseSecureRandomOnMAC = Sorry, but you cannot use a SecureRandom object for creating MACs. +algorithms.HMACOutputLengthOnlyForHMAC = A HMACOutputLength can only be specified for HMAC integrity algorithms +algorithms.NoSuchAlgorithm = The requested algorithm {0} does not exist. Original Message was: {1} +algorithms.NoSuchMap = The algorithm URI "{0}" could not be mapped to a JCE algorithm +algorithms.NoSuchProvider = The specified Provider {0} does not exist. Original Message was: {1} +algorithms.operationOnlyVerification = A public key can only used for verification of a signature. +algorithms.WrongKeyForThisOperation = Sorry, you supplied the wrong key type for this operation! You supplied a {0} but a {1} is needed. +attributeValueIllegal = The attribute {0} has value {1} but must be {2} +c14n.Canonicalizer.Exception = Exception during Canonicalization: Original Message was {0} +c14n.Canonicalizer.IllegalNode = Illegal node type {0}, node name was {1} +c14n.Canonicalizer.NoSuchCanonicalizer = No canonicalizer found with URI {0} +c14n.Canonicalizer.ParserConfigurationException = ParserConfigurationException during Canonicalization: Original Message was {0} +c14n.Canonicalizer.RelativeNamespace = Element {0} has a relative namespace: {1}="{2}" +c14n.Canonicalizer.SAXException = SAXException during Canonicalization: Original Message was {0} +c14n.Canonicalizer.TraversalNotSupported = This DOM document does not support Traversal {0} +c14n.Canonicalizer.UnsupportedEncoding = Unsupported encoding {0} +c14n.Canonicalizer.UnsupportedOperation = This canonicalizer does not support this operation +c14n.XMLUtils.circumventBug2650forgotten = The tree has not been prepared for canonicalization using XMLUtils#circumventBug2650(Document) +certificate.noSki.lowVersion = Certificate cannot contain a SubjectKeyIdentifier because it is only X509v{0} +certificate.noSki.notOctetString = Certificates SubjectKeyIdentifier is not a OctetString +certificate.noSki.null = Certificate does not contain a SubjectKeyIdentifier +defaultNamespaceCannotBeSetHere = Default namespace cannot be set here +ElementProxy.nullElement = Cannot create an ElementProxy from a null argument +empty = {0} +encryption.algorithmCannotBeUsedForEncryptedData = encryption.algorithmCannotBeUsedForEncryptedData {0} +encryption.algorithmCannotEatInitParams = encryption.algorithmCannotEatInitParams +encryption.algorithmCannotEncryptDecrypt = encryption.algorithmCannotEncryptDecrypt +encryption.algorithmCannotWrapUnWrap = encryption.algorithmCannotWrapUnWrap +encryption.ExplicitKeySizeMismatch = The xenc:KeySize element requests a key size of {0} bit but the algorithm implements {1} bit +encryption.nonceLongerThanDecryptedPlaintext = The given nonce is longer than the available plaintext. I Cannot strip away this. +encryption.RSAOAEP.dataHashWrong = data hash wrong +encryption.RSAOAEP.dataStartWrong = data wrong start {0} +encryption.RSAOAEP.dataTooShort = data too short +encryption.RSAPKCS15.blockTruncated = block truncated +encryption.RSAPKCS15.noDataInBlock = no data in block +encryption.RSAPKCS15.unknownBlockType = unknown block type +encryption.nokey = No Key Encryption Key loaded and cannot determine using key resolvers +endorsed.jdk1.4.0 = Since it seems that nobody reads our installation notes, we must do it in the exception messages. Hope you read them. You did NOT use the endorsed mechanism from JDK 1.4 properly; look at how to solve this problem. +errorMessages.InvalidDigestValueException = INVALID signature -- check reference resolution. +errorMessages.InvalidSignatureValueException = INVALID signature -- core validation failed. +errorMessages.IOException = Other file I/O and similar exceptions. +errorMessages.MissingKeyFailureException = Cannot verify because of missing public key. Provide it via addResource and try again. +errorMessages.MissingResourceFailureException = Cannot verify because of unresolved references. Provide it via addResource and try again. +errorMessages.NoSuchAlgorithmException = Unknown Algorithm {0} +errorMessages.NotYetImplementedException = Functionality not yet there. +errorMessages.XMLSignatureException = Verification failed for some other reason. +decoding.divisible.four = It should be divisible by four +decoding.general = Error while decoding +FileKeyStorageImpl.addToDefaultFromRemoteNotImplemented = Method addToDefaultFromRemote() not yet implemented. +FileKeyStorageImpl.NoCert.Context = Not found such a X509Certificate including context {0} +FileKeyStorageImpl.NoCert.IssNameSerNo = Not found such a X509Certificate with IssuerName {0} and serial number {1} +FileKeyStorageImpl.NoCert.SubjName = Not found such a X509Certificate including SubjectName {0} +generic.dontHaveConstructionElement = I do not have a construction Element +generic.EmptyMessage = {0} +generic.NotYetImplemented = {0} Not YET implemented ;-(( +java.security.InvalidKeyException = Invalid key +java.security.NoSuchProviderException = Unknown or unsupported provider +java.security.UnknownKeyType = Unknown or unsupported key type {0} +KeyInfo.needKeyResolver = More than one keyResovler have to be registered +KeyInfo.nokey = Cannot get key from {0} +KeyInfo.noKey = Cannot get the public key +KeyInfo.wrongNumberOfObject = Need {0} keyObjects +KeyInfo.wrongUse = This object was made for getting {0} +keyResolver.alreadyRegistered = {1} class has already been registered for {0} +KeyResolver.needStorageResolver = Need a StorageResolver to retrieve a Certificate from a {0} +KeyResoverSpiImpl.cannotGetCert = Cannot get the Certificate that include or in {1} in implement class {0} +KeyResoverSpiImpl.elementGeneration = Cannot make {1} element in implement class {0} +KeyResoverSpiImpl.getPoublicKey = Cannot get the public key from implement class {0} +KeyResoverSpiImpl.InvalidElement = Cannot set (2) Element in implement class {0} +KeyResoverSpiImpl.keyStore = KeyStorage error in implement class {0} +KeyResoverSpiImpl.need.Element = {1} type of Element is needed in implement class {0} +KeyResoverSpiImpl.wrongCRLElement = Cannot make CRL from {1} in implement class {0} +KeyResoverSpiImpl.wrongKeyObject = Need {1} type of KeyObject for generation Element in implement class{0} +KeyResoverSpiImpl.wrongNumberOfObject = Need {1} keyObject in implement class {0} +KeyStore.alreadyRegistered = {0} Class has already been registered for {1} +KeyStore.register = {1} type class register error in class {0} +KeyStore.registerStore.register = Registeration error for type {0} +KeyValue.IllegalArgument = Cannot create a {0} from {1} +namespacePrefixAlreadyUsedByOtherURI = Namespace prefix {0} already used by other URI {1} +notYetInitialized = The module {0} is not yet initialized +prefix.AlreadyAssigned = You want to assign {0} as prefix for namespace {1} but it is already assigned for {2} +signature.Canonicalizer.UnknownCanonicalizer = Unknown canonicalizer. No handler installed for URI {0} +signature.DSA.invalidFormat = Invalid ASN.1 encoding of the DSA signature +signature.Generation.signBeforeGetValue = You have to XMLSignature.sign(java.security.PrivateKey) first +signature.signaturePropertyHasNoTarget = The Target attribute of the SignatureProperty must be set +signature.Transform.ErrorDuringTransform = A {1} was thrown during the {0} transform +signature.Transform.NotYetImplemented = Transform {0} not yet implemented +signature.Transform.NullPointerTransform = Null pointer as URI. Programming bug? +signature.Transform.UnknownTransform = Unknown transformation. No handler installed for URI {0} +signature.Transform.node = Current Node: {0} +signature.Transform.nodeAndType = Current Node: {0}, type: {1} +signature.Util.BignumNonPositive = bigInteger.signum() must be positive +signature.Util.NonTextNode = Not a text node +signature.Util.TooManyChilds = Too many childs of Type {0} in {1} +signature.Verification.certificateError = Certificate error +signature.Verification.IndexOutOfBounds = Index {0} illegal. We only have {1} References +signature.Verification.internalError = Internal error +signature.Verification.InvalidDigestOrReference = Invalid digest of reference {0} +signature.Verification.keyStore = KeyStore error +signature.Verification.MissingID = Cannot resolve element with ID {0} +signature.Verification.MissingResources = Cannot resolve external resource {0} +signature.Verification.NoSignatureElement = Input document contains no {0} Element in namespace {1} +signature.Verification.Reference.NoInput = The Reference for URI {0} has no XMLSignatureInput +signature.Verification.SignatureError = Signature error +signature.XMLSignatureInput.MissingConstuctor = Cannot construct a XMLSignatureInput from class {0} +signature.XMLSignatureInput.SerializeDOM = Input initialized with DOM Element. Use Canonicalization to serialize it +signature.XMLSignatureInput.nodesetReference = Unable to convert to nodeset the reference +transform.Init.IllegalContextArgument = Invalid context argument of class {0}. Must be String, org.w3c.dom.NodeList or java.io.InputStream. +transform.init.NotInitialized = +transform.init.wrongURI = Initialized with wrong URI. How could this happen? We implement {0} but {1} was used during initialization +utils.Base64.IllegalBitlength = Illegal byte length; Data to be decoded must be a multiple of 4 +Base64Decoding = Error while decoding +utils.resolver.noClass = Could not find a resolver for URI {0} and Base {1} +xml.WrongContent = Cannot find {0} in {1} +xml.WrongElement = Cannot create a {0} from a {1} element +xpath.funcHere.documentsDiffer = The XPath is not in the same document as the context node +xpath.funcHere.noXPathContext = Try to evaluate an XPath which uses the here() function but XPath is not inside an ds:XPath Element. XPath was : {0} diff --git a/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpec.java b/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpec.java index 07b38826496fec00f7685cfe797932d0dda00ab0..96a9ef5322b1d24d8aed95e1e44371389e8e56a3 100644 --- a/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpec.java +++ b/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpec.java @@ -91,9 +91,7 @@ abstract public class EventRequestSpec { void attemptImmediateResolve(VirtualMachine vm) { // try to resolve immediately - Iterator iter = vm.allClasses().iterator(); - while (iter.hasNext()) { - ReferenceType refType = (ReferenceType)iter.next(); + for (ReferenceType refType : vm.allClasses()) { if (refSpec.matches(refType)) { try { resolve(refType); diff --git a/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpecList.java b/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpecList.java index dcc9b0c351708ebf24629a9aac40f6528be536ce..e04c851f186f95c4313a94cb9cb63d45cf0e5f3e 100644 --- a/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpecList.java +++ b/src/share/classes/com/sun/tools/example/debug/bdi/EventRequestSpecList.java @@ -47,9 +47,8 @@ class EventRequestSpecList { */ void resolve(ReferenceType refType) { synchronized(eventRequestSpecs) { - Iterator iter = eventRequestSpecs.iterator(); - while (iter.hasNext()) { - ((EventRequestSpec)iter.next()).attemptResolve(refType); + for (EventRequestSpec spec : eventRequestSpecs) { + spec.attemptResolve(refType); } } } @@ -79,7 +78,7 @@ class EventRequestSpecList { BreakpointSpec createMethodBreakpoint(String classPattern, - String methodId, List methodArgs) { + String methodId, List methodArgs) { ReferenceTypeSpec refSpec = new PatternReferenceTypeSpec(classPattern); return new MethodBreakpointSpec(this, refSpec, @@ -132,47 +131,48 @@ class EventRequestSpecList { // -------- notify routines -------------------- - private Vector specListeners() { - return (Vector)runtime.specListeners.clone(); + @SuppressWarnings("unchecked") + private Vector specListeners() { + return (Vector)runtime.specListeners.clone(); } void notifySet(EventRequestSpec spec) { - Vector l = specListeners(); + Vector l = specListeners(); SpecEvent evt = new SpecEvent(spec); for (int i = 0; i < l.size(); i++) { - spec.notifySet((SpecListener)l.elementAt(i), evt); + spec.notifySet(l.elementAt(i), evt); } } void notifyDeferred(EventRequestSpec spec) { - Vector l = specListeners(); + Vector l = specListeners(); SpecEvent evt = new SpecEvent(spec); for (int i = 0; i < l.size(); i++) { - spec.notifyDeferred((SpecListener)l.elementAt(i), evt); + spec.notifyDeferred(l.elementAt(i), evt); } } void notifyDeleted(EventRequestSpec spec) { - Vector l = specListeners(); + Vector l = specListeners(); SpecEvent evt = new SpecEvent(spec); for (int i = 0; i < l.size(); i++) { - spec.notifyDeleted((SpecListener)l.elementAt(i), evt); + spec.notifyDeleted(l.elementAt(i), evt); } } void notifyResolved(EventRequestSpec spec) { - Vector l = specListeners(); + Vector l = specListeners(); SpecEvent evt = new SpecEvent(spec); for (int i = 0; i < l.size(); i++) { - spec.notifyResolved((SpecListener)l.elementAt(i), evt); + spec.notifyResolved(l.elementAt(i), evt); } } void notifyError(EventRequestSpec spec, Exception exc) { - Vector l = specListeners(); + Vector l = specListeners(); SpecErrorEvent evt = new SpecErrorEvent(spec, exc); for (int i = 0; i < l.size(); i++) { - spec.notifyError((SpecListener)l.elementAt(i), evt); + spec.notifyError(l.elementAt(i), evt); } } } diff --git a/src/share/classes/com/sun/tools/example/debug/bdi/ExecutionManager.java b/src/share/classes/com/sun/tools/example/debug/bdi/ExecutionManager.java index e533bb54c83a9b601ca1ed5e92f7efc16cc289f6..245590ec7fd661f44234b9a67954db2b18394932 100644 --- a/src/share/classes/com/sun/tools/example/debug/bdi/ExecutionManager.java +++ b/src/share/classes/com/sun/tools/example/debug/bdi/ExecutionManager.java @@ -232,10 +232,7 @@ public class ExecutionManager { if (pattern.startsWith("*.")) { // Wildcard matches any leading package name. pattern = pattern.substring(1); - List classes = vm().allClasses(); - Iterator iter = classes.iterator(); - while (iter.hasNext()) { - ReferenceType type = ((ReferenceType)iter.next()); + for (ReferenceType type : vm().allClasses()) { if (type.name().endsWith(pattern)) { result.add(type); } @@ -278,7 +275,7 @@ public class ExecutionManager { public ThreadGroupReference systemThreadGroup() throws NoSessionException { ensureActiveSession(); - return (ThreadGroupReference)vm().topLevelThreadGroups().get(0); + return vm().topLevelThreadGroups().get(0); } /* @@ -349,10 +346,9 @@ public class ExecutionManager { * attach sessions. */ VirtualMachineManager mgr = Bootstrap.virtualMachineManager(); - List connectors = mgr.attachingConnectors(); - AttachingConnector connector = (AttachingConnector)connectors.get(0); + AttachingConnector connector = mgr.attachingConnectors().get(0); Map arguments = connector.defaultArguments(); - ((Connector.Argument)arguments.get("port")).setValue(portName); + arguments.get("port").setValue(portName); Session newSession = internalAttach(connector, arguments); if (newSession != null) { @@ -504,10 +500,7 @@ public class ExecutionManager { * if so, it gets removed here. */ EventRequestManager mgr = vm().eventRequestManager(); - List requests = mgr.stepRequests(); - Iterator iter = requests.iterator(); - while (iter.hasNext()) { - StepRequest request = (StepRequest)iter.next(); + for (StepRequest request : mgr.stepRequests()) { if (request.thread().equals(thread)) { mgr.deleteEventRequest(request); break; @@ -591,7 +584,7 @@ public class ExecutionManager { if (session == null || thread == null) { return null; } - ThreadInfo info = (ThreadInfo)threadInfoMap.get(thread); + ThreadInfo info = threadInfoMap.get(thread); if (info == null) { //### Should not hardcode initial frame count and prefetch here! //info = new ThreadInfo(thread, 10, 10); @@ -607,24 +600,22 @@ public class ExecutionManager { void validateThreadInfo() { session.interrupted = true; - Iterator iter = threadInfoList.iterator(); - while (iter.hasNext()) { - ((ThreadInfo)iter.next()).validate(); + for (ThreadInfo threadInfo : threadInfoList) { + threadInfo.validate(); } } private void invalidateThreadInfo() { if (session != null) { session.interrupted = false; - Iterator iter = threadInfoList.iterator(); - while (iter.hasNext()) { - ((ThreadInfo)iter.next()).invalidate(); + for (ThreadInfo threadInfo : threadInfoList) { + threadInfo.invalidate(); } } } void removeThreadInfo(ThreadReference thread) { - ThreadInfo info = (ThreadInfo)threadInfoMap.get(thread); + ThreadInfo info = threadInfoMap.get(thread); if (info != null) { info.invalidate(); threadInfoMap.remove(thread); @@ -702,7 +693,7 @@ public class ExecutionManager { while (inputBuffer.size() < 1) { inputLock.wait(); } - line = (String)inputBuffer.removeLast(); + line = inputBuffer.removeLast(); } catch (InterruptedException e) {} } } @@ -774,7 +765,7 @@ public class ExecutionManager { public BreakpointSpec createMethodBreakpoint(String classPattern, - String methodId, List methodArgs) { + String methodId, List methodArgs) { return specList.createMethodBreakpoint(classPattern, methodId, methodArgs); } @@ -811,7 +802,7 @@ public class ExecutionManager { specList.install(spec, vm()); } - public List eventRequestSpecs() { + public List eventRequestSpecs() { return specList.eventRequestSpecs(); } } diff --git a/src/share/classes/com/sun/tools/example/debug/bdi/JDIEventSource.java b/src/share/classes/com/sun/tools/example/debug/bdi/JDIEventSource.java index 2bd45c2fc387e47a7ae0149da0787fd1026ddf0b..97fc6a7f2b0c3c3529d4f657141df10dadd1461c 100644 --- a/src/share/classes/com/sun/tools/example/debug/bdi/JDIEventSource.java +++ b/src/share/classes/com/sun/tools/example/debug/bdi/JDIEventSource.java @@ -82,9 +82,7 @@ class JDIEventSource extends Thread { boolean interrupted = es.suspendedAll(); es.notify(firstListener); boolean wantInterrupt = JDIEventSource.this.wantInterrupt; - for (Iterator it = session.runtime.jdiListeners.iterator(); - it.hasNext(); ) { - JDIListener jl = (JDIListener)it.next(); + for (JDIListener jl : session.runtime.jdiListeners) { es.notify(jl); } if (interrupted && !wantInterrupt) { diff --git a/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java b/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java index 0d9c0cc05dd58acdc033dedb75d16c93cac73666..29f05ced6b7dedc894a44665a30f2ac4360f97fa 100644 --- a/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java +++ b/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java @@ -58,12 +58,12 @@ public class LineBreakpointSpec extends BreakpointSpec { LineNotFoundException { Location location = null; try { - List locs = clazz.locationsOfLine(lineNumber()); + List locs = clazz.locationsOfLine(lineNumber()); if (locs.size() == 0) { throw new LineNotFoundException(); } // TODO handle multiple locations - location = (Location)locs.get(0); + location = locs.get(0); if (location.method() == null) { throw new LineNotFoundException(); } diff --git a/src/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java b/src/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java index 6a4f5e5a2633e022ff275dce42da86542d0d24f6..0732ed9c2c1965ee50097ee1c029cda16745d7d0 100644 --- a/src/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java +++ b/src/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java @@ -34,11 +34,11 @@ import java.util.Iterator; public class MethodBreakpointSpec extends BreakpointSpec { String methodId; - List methodArgs; + List methodArgs; MethodBreakpointSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec, - String methodId, List methodArgs) { + String methodId, List methodArgs) { super(specs, refSpec); this.methodId = methodId; this.methodArgs = methodArgs; @@ -76,7 +76,7 @@ public class MethodBreakpointSpec extends BreakpointSpec { return methodId; } - public List methodArgs() { + public List methodArgs() { return methodArgs; } @@ -120,14 +120,13 @@ public class MethodBreakpointSpec extends BreakpointSpec { buffer.append('.'); buffer.append(methodId); if (methodArgs != null) { - Iterator iter = methodArgs.iterator(); boolean first = true; buffer.append('('); - while (iter.hasNext()) { + for (String name : methodArgs) { if (!first) { buffer.append(','); } - buffer.append((String)iter.next()); + buffer.append(name); first = false; } buffer.append(")"); @@ -151,8 +150,8 @@ public class MethodBreakpointSpec extends BreakpointSpec { * and if the number of arguments in the method matches the * number of names passed */ - private boolean compareArgTypes(Method method, List nameList) { - List argTypeNames = method.argumentTypeNames(); + private boolean compareArgTypes(Method method, List nameList) { + List argTypeNames = method.argumentTypeNames(); // If argument counts differ, we can stop here if (argTypeNames.size() != nameList.size()) { @@ -162,8 +161,8 @@ public class MethodBreakpointSpec extends BreakpointSpec { // Compare each argument type's name int nTypes = argTypeNames.size(); for (int i = 0; i < nTypes; ++i) { - String comp1 = (String)argTypeNames.get(i); - String comp2 = (String)nameList.get(i); + String comp1 = argTypeNames.get(i); + String comp2 = nameList.get(i); if (! comp1.equals(comp2)) { /* * We have to handle varargs. EG, the @@ -288,22 +287,17 @@ public class MethodBreakpointSpec extends BreakpointSpec { List argTypeNames = null; if (methodArgs() != null) { argTypeNames = new ArrayList(methodArgs().size()); - Iterator iter = methodArgs().iterator(); - while (iter.hasNext()) { - String name = (String)iter.next(); + for (String name : methodArgs()) { name = normalizeArgTypeName(name); argTypeNames.add(name); } } // Check each method in the class for matches - Iterator iter = clazz.methods().iterator(); Method firstMatch = null; // first method with matching name Method exactMatch = null; // (only) method with same name & sig int matchCount = 0; // > 1 implies overload - while (iter.hasNext()) { - Method candidate = (Method)iter.next(); - + for (Method candidate : clazz.methods()) { if (candidate.name().equals(methodName())) { matchCount++; diff --git a/src/share/classes/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java b/src/share/classes/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java index d9b375cfde8eb326dc5203a81349fc931ea22983..d41901320dd81f54c7521f37e34693b936b7093a 100644 --- a/src/share/classes/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java +++ b/src/share/classes/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java @@ -36,7 +36,7 @@ import java.util.Iterator; * Descend the tree of thread groups. * @author Robert G. Field */ -public class ThreadGroupIterator implements Iterator { +public class ThreadGroupIterator implements Iterator { private final Stack> stack = new Stack>(); @@ -56,8 +56,8 @@ public class ThreadGroupIterator implements Iterator { } */ - private Iterator top() { - return (Iterator)stack.peek(); + private Iterator top() { + return stack.peek(); } /** @@ -77,12 +77,12 @@ public class ThreadGroupIterator implements Iterator { return !stack.isEmpty(); } - public Object next() { + public ThreadGroupReference next() { return nextThreadGroup(); } public ThreadGroupReference nextThreadGroup() { - ThreadGroupReference tg = (ThreadGroupReference)top().next(); + ThreadGroupReference tg = top().next(); push(tg.threadGroups()); return tg; } diff --git a/src/share/classes/com/sun/tools/example/debug/bdi/ThreadIterator.java b/src/share/classes/com/sun/tools/example/debug/bdi/ThreadIterator.java index 36b71e460238dd9c413c79da2d85566e862ab676..bfe57d14a92d304efb30ee5a05f4759b09184333 100644 --- a/src/share/classes/com/sun/tools/example/debug/bdi/ThreadIterator.java +++ b/src/share/classes/com/sun/tools/example/debug/bdi/ThreadIterator.java @@ -30,8 +30,8 @@ import com.sun.jdi.ThreadReference; import java.util.List; import java.util.Iterator; -public class ThreadIterator implements Iterator { - Iterator it = null; +public class ThreadIterator implements Iterator { + Iterator it = null; ThreadGroupIterator tgi; public ThreadIterator(ThreadGroupReference tg) { @@ -53,12 +53,12 @@ public class ThreadIterator implements Iterator { return true; } - public Object next() { + public ThreadReference next() { return it.next(); } public ThreadReference nextThread() { - return (ThreadReference)next(); + return next(); } public void remove() { diff --git a/src/share/classes/com/sun/tools/example/debug/expr/LValue.java b/src/share/classes/com/sun/tools/example/debug/expr/LValue.java index 6b65e0c57a2bcbee79066f86a1b7b8f55016ea11..ae9711d9f0929ed0ac8a9c179c44756d94de9066 100644 --- a/src/share/classes/com/sun/tools/example/debug/expr/LValue.java +++ b/src/share/classes/com/sun/tools/example/debug/expr/LValue.java @@ -191,11 +191,12 @@ abstract class LValue { return field; } - static List methodsByName(ReferenceType refType, String name, int kind) { - List list = refType.methodsByName(name); - Iterator iter = list.iterator(); + static List methodsByName(ReferenceType refType, + String name, int kind) { + List list = refType.methodsByName(name); + Iterator iter = list.iterator(); while (iter.hasNext()) { - Method method = (Method)iter.next(); + Method method = iter.next(); boolean isStatic = method.isStatic(); if (((kind == STATIC) && !isStatic) || ((kind == INSTANCE) && isStatic)) { @@ -231,21 +232,21 @@ abstract class LValue { * argType is not assignable from the type of the argument value. * IE, one is an Apple and the other is an Orange. */ - static int argumentsMatch(List argTypes, List arguments) { + static int argumentsMatch(List argTypes, List arguments) { if (argTypes.size() != arguments.size()) { return DIFFERENT; } - Iterator typeIter = argTypes.iterator(); - Iterator valIter = arguments.iterator(); + Iterator typeIter = argTypes.iterator(); + Iterator valIter = arguments.iterator(); int result = SAME; // If any pair aren't the same, change the // result to ASSIGNABLE. If any pair aren't // assignable, return DIFFERENT while (typeIter.hasNext()) { - Type argType = (Type)typeIter.next(); - Value value = (Value)valIter.next(); + Type argType = typeIter.next(); + Value value = valIter.next(); if (value == null) { // Null values can be passed to any non-primitive argument if (primitiveTypeNames.contains(argType.name())) { @@ -333,7 +334,7 @@ abstract class LValue { if (fromType instanceof ArrayType) { return isArrayAssignableTo((ArrayType)fromType, toType); } - List interfaces; + List interfaces; if (fromType instanceof ClassType) { ClassType superclazz = ((ClassType)fromType).superclass(); if ((superclazz != null) && isAssignableTo(superclazz, toType)) { @@ -344,9 +345,7 @@ abstract class LValue { // fromType must be an InterfaceType interfaces = ((InterfaceType)fromType).superinterfaces(); } - Iterator iter = interfaces.iterator(); - while (iter.hasNext()) { - InterfaceType interfaze = (InterfaceType)iter.next(); + for (InterfaceType interfaze : interfaces) { if (isAssignableTo(interfaze, toType)) { return true; } @@ -354,7 +353,8 @@ abstract class LValue { return false; } - static Method resolveOverload(List overloads, List arguments) + static Method resolveOverload(List overloads, + List arguments) throws ParseException { // If there is only one method to call, we'll just choose @@ -362,7 +362,7 @@ abstract class LValue { // the invoke will return a better error message than we // could generate here. if (overloads.size() == 1) { - return (Method)overloads.get(0); + return overloads.get(0); } // Resolving overloads is beyond the scope of this exercise. @@ -374,12 +374,10 @@ abstract class LValue { // methods to call. And, since casts aren't implemented, // the user can't use them to pick a particular overload to call. // IE, the user is out of luck in this case. - Iterator iter = overloads.iterator(); Method retVal = null; int assignableCount = 0; - while (iter.hasNext()) { - Method mm = (Method)iter.next(); - List argTypes; + for (Method mm : overloads) { + List argTypes; try { argTypes = mm.argumentTypes(); } catch (ClassNotLoadedException ee) { @@ -443,7 +441,7 @@ abstract class LValue { final ObjectReference obj; final ThreadReference thread; final Field matchingField; - final List overloads; + final List overloads; Method matchingMethod = null; List methodArguments = null; @@ -510,7 +508,7 @@ abstract class LValue { final ReferenceType refType; final ThreadReference thread; final Field matchingField; - final List overloads; + final List overloads; Method matchingMethod = null; List methodArguments = null; @@ -765,7 +763,7 @@ abstract class LValue { static LValue makeNewObject(VirtualMachine vm, ExpressionParser.GetFrame frameGetter, String className, List arguments) throws ParseException { - List classes = vm.classesByName(className); + List classes = vm.classesByName(className); if (classes.size() == 0) { throw new ParseException("No class named: " + className); } @@ -774,7 +772,7 @@ abstract class LValue { throw new ParseException("More than one class named: " + className); } - ReferenceType refType = (ReferenceType)classes.get(0); + ReferenceType refType = classes.get(0); if (!(refType instanceof ClassType)) { @@ -784,9 +782,9 @@ abstract class LValue { ClassType classType = (ClassType)refType; List methods = new ArrayList(classType.methods()); // writable - Iterator iter = methods.iterator(); + Iterator iter = methods.iterator(); while (iter.hasNext()) { - Method method = (Method)iter.next(); + Method method = iter.next(); if (!method.isConstructor()) { iter.remove(); } @@ -858,13 +856,13 @@ abstract class LValue { } // check for class name while (izer.hasMoreTokens()) { - List classes = vm.classesByName(first); + List classes = vm.classesByName(first); if (classes.size() > 0) { if (classes.size() > 1) { throw new ParseException("More than one class named: " + first); } else { - ReferenceType refType = (ReferenceType)classes.get(0); + ReferenceType refType = classes.get(0); LValue lval = new LValueStaticMember(refType, izer.nextToken(), thread); return nFields(lval, izer, thread); diff --git a/src/share/classes/com/sun/tools/example/debug/gui/ClassTreeTool.java b/src/share/classes/com/sun/tools/example/debug/gui/ClassTreeTool.java index 6ddb558c4f251fb3fb7ae3d7c190a4e5419549c2..bea3a2745e74a68c12aec94106467e500847b358 100644 --- a/src/share/classes/com/sun/tools/example/debug/gui/ClassTreeTool.java +++ b/src/share/classes/com/sun/tools/example/debug/gui/ClassTreeTool.java @@ -124,9 +124,7 @@ public class ClassTreeTool extends JPanel { public void sessionStart(EventObject e) { // Get system classes and any others loaded before attaching. try { - Iterator iter = runtime.allClasses().iterator(); - while (iter.hasNext()) { - ReferenceType type = ((ReferenceType)iter.next()); + for (ReferenceType type : runtime.allClasses()) { root.addClass(type); } } catch (VMDisconnectedException ee) { diff --git a/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java b/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java index e0f96e013164d0214f59cbb7fa50a4db1c65a4f9..7b6aaf5469567847d860dce3d7c5be9c9402fd78 100644 --- a/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java +++ b/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java @@ -77,7 +77,7 @@ public class CommandInterpreter { while (ti.hasNext()) { tlist.add(ti.nextThread()); } - threads = (ThreadReference[])tlist.toArray(new ThreadReference[tlist.size()]); + threads = tlist.toArray(new ThreadReference[tlist.size()]); } return threads; } @@ -146,11 +146,9 @@ public class CommandInterpreter { // Command: classes private void commandClasses() throws NoSessionException { - List list = runtime.allClasses(); OutputSink out = env.getOutputSink(); //out.println("** classes list **"); - for (int i = 0 ; i < list.size() ; i++) { - ReferenceType refType = (ReferenceType)list.get(i); + for (ReferenceType refType : runtime.allClasses()) { out.println(refType.name()); } out.show(); @@ -167,16 +165,16 @@ public class CommandInterpreter { String idClass = t.nextToken(); ReferenceType cls = findClass(idClass); if (cls != null) { - List methods = cls.allMethods(); + List methods = cls.allMethods(); OutputSink out = env.getOutputSink(); for (int i = 0; i < methods.size(); i++) { - Method method = (Method)methods.get(i); + Method method = methods.get(i); out.print(method.declaringType().name() + " " + method.name() + "("); - Iterator it = method.argumentTypeNames().iterator(); + Iterator it = method.argumentTypeNames().iterator(); if (it.hasNext()) { while (true) { - out.print((String)it.next()); + out.print(it.next()); if (!it.hasNext()) { break; } @@ -193,10 +191,10 @@ public class CommandInterpreter { } private ReferenceType findClass(String pattern) throws NoSessionException { - List results = runtime.findClassesMatchingPattern(pattern); + List results = runtime.findClassesMatchingPattern(pattern); if (results.size() > 0) { //### Should handle multiple results sensibly. - return (ReferenceType)results.get(0); + return results.get(0); } return null; } @@ -235,11 +233,11 @@ public class CommandInterpreter { private int printThreadGroup(OutputSink out, ThreadGroupReference tg, int iThread) { out.println("Group " + tg.name() + ":"); - List tlist = tg.threads(); + List tlist = tg.threads(); int maxId = 0; int maxName = 0; for (int i = 0 ; i < tlist.size() ; i++) { - ThreadReference thr = (ThreadReference)tlist.get(i); + ThreadReference thr = tlist.get(i); int len = Utils.description(thr).length(); if (len > maxId) maxId = len; @@ -254,7 +252,7 @@ public class CommandInterpreter { String maxNumString = String.valueOf(iThread + tlist.size()); int maxNumDigits = maxNumString.length(); for (int i = 0 ; i < tlist.size() ; i++) { - ThreadReference thr = (ThreadReference)tlist.get(i); + ThreadReference thr = tlist.get(i); char buf[] = new char[80]; for (int j = 0; j < 79; j++) { buf[j] = ' '; @@ -283,9 +281,7 @@ public class CommandInterpreter { sbOut.setLength(79); out.println(sbOut.toString()); } - List tglist = tg.threadGroups(); - for (int ig = 0; ig < tglist.size(); ig++) { - ThreadGroupReference tg0 = (ThreadGroupReference)tglist.get(ig); + for (ThreadGroupReference tg0 : tg.threadGroups()) { if (!tg.equals(tg0)) { // TODO ref mgt iThread += printThreadGroup(out, tg0, iThread + tlist.size()); } @@ -733,7 +729,7 @@ public class CommandInterpreter { if (token.toLowerCase().equals("all")) { ThreadIterator it = allThreads(); while (it.hasNext()) { - ThreadReference thread = (ThreadReference)it.next(); + ThreadReference thread = it.next(); out.println(thread.name() + ": "); dumpStack(thread, showPC); } @@ -755,7 +751,7 @@ public class CommandInterpreter { //env.failure("Target VM must be in interrupted state."); //env.failure("Current thread isn't suspended."); //### Should handle extremely long stack traces sensibly for user. - List stack = null; + List stack = null; try { stack = thread.frames(); } catch (IncompatibleThreadStateException e) { @@ -772,7 +768,7 @@ public class CommandInterpreter { OutputSink out = env.getOutputSink(); int nFrames = stack.size(); for (int i = frameIndex; i < nFrames; i++) { - StackFrame frame = (StackFrame)stack.get(i); + StackFrame frame = stack.get(i); Location loc = frame.location(); Method meth = loc.method(); out.print(" [" + (i + 1) + "] "); @@ -780,7 +776,7 @@ public class CommandInterpreter { out.print('.'); out.print(meth.name()); out.print(" ("); - if (meth instanceof Method && ((Method)meth).isNative()) { + if (meth.isNative()) { out.print("native method"); } else if (loc.lineNumber() != -1) { try { @@ -806,14 +802,13 @@ public class CommandInterpreter { private void listEventRequests() throws NoSessionException { // Print set breakpoints - Iterator iter = runtime.eventRequestSpecs().iterator(); - if (!iter.hasNext()) { + List specs = runtime.eventRequestSpecs(); + if (specs.isEmpty()) { env.notice("No breakpoints/watchpoints/exceptions set."); } else { OutputSink out = env.getOutputSink(); out.println("Current breakpoints/watchpoints/exceptions set:"); - while (iter.hasNext()) { - EventRequestSpec bp = (EventRequestSpec)iter.next(); + for (EventRequestSpec bp : specs) { out.println("\t" + bp); } out.show(); @@ -926,13 +921,13 @@ public class CommandInterpreter { //### need 'clear all' BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken()); if (bpSpec != null) { - Iterator iter = runtime.eventRequestSpecs().iterator(); - if (!iter.hasNext()) { + List specs = runtime.eventRequestSpecs(); + + if (specs.isEmpty()) { env.notice("No breakpoints set."); } else { - List toDelete = new ArrayList(); - while (iter.hasNext()) { - BreakpointSpec spec = (BreakpointSpec)iter.next(); + List toDelete = new ArrayList(); + for (EventRequestSpec spec : specs) { if (spec.equals(bpSpec)) { toDelete.add(spec); } @@ -941,7 +936,7 @@ public class CommandInterpreter { if (toDelete.size() <= 1) { env.notice("No matching breakpoint set."); } - for (BreakpointSpec spec : toDelete) { + for (EventRequestSpec spec : toDelete) { runtime.delete(spec); } } @@ -988,7 +983,7 @@ public class CommandInterpreter { lineno = Integer.valueOf(id).intValue(); } catch (NumberFormatException nfe) { // It isn't -- see if it's a method name. - List meths = refType.methodsByName(id); + List meths = refType.methodsByName(id); if (meths == null || meths.size() == 0) { env.failure(id + " is not a valid line number or " + @@ -1001,7 +996,7 @@ public class CommandInterpreter { refType.name()); return; } - loc = ((Method)meths.get(0)).location(); + loc = meths.get(0).location(); lineno = loc.lineNumber(); } } @@ -1121,7 +1116,7 @@ public class CommandInterpreter { return; } - List vars; + List vars; try { vars = frame.visibleVariables(); if (vars == null || vars.size() == 0) { @@ -1136,15 +1131,13 @@ public class CommandInterpreter { OutputSink out = env.getOutputSink(); out.println("Method arguments:"); - for (Iterator it = vars.iterator(); it.hasNext(); ) { - LocalVariable var = (LocalVariable)it.next(); + for (LocalVariable var : vars) { if (var.isArgument()) { printVar(out, var, frame); } } out.println("Local variables:"); - for (Iterator it = vars.iterator(); it.hasNext(); ) { - LocalVariable var = (LocalVariable)it.next(); + for (LocalVariable var : vars) { if (!var.isArgument()) { printVar(out, var, frame); } @@ -1245,8 +1238,7 @@ public class CommandInterpreter { private void dump(OutputSink out, ObjectReference obj, ReferenceType refType, ReferenceType refTypeBase) { - for (Iterator it = refType.fields().iterator(); it.hasNext(); ) { - Field field = (Field)it.next(); + for (Field field : refType.fields()) { out.print(" "); if (!refType.equals(refTypeBase)) { out.print(refType.name() + "."); @@ -1261,9 +1253,8 @@ public class CommandInterpreter { dump(out, obj, sup, refTypeBase); } } else if (refType instanceof InterfaceType) { - List sups = ((InterfaceType)refType).superinterfaces(); - for (Iterator it = sups.iterator(); it.hasNext(); ) { - dump(out, obj, (ReferenceType)it.next(), refTypeBase); + for (InterfaceType sup : ((InterfaceType)refType).superinterfaces()) { + dump(out, obj, sup, refTypeBase); } } } diff --git a/src/share/classes/com/sun/tools/example/debug/gui/JDBFileFilter.java b/src/share/classes/com/sun/tools/example/debug/gui/JDBFileFilter.java index ddb71921dc1816a22fbddfba83094e8b34730db4..5963ef2e0dfb115838bc866c4631675cc2ad9ac2 100644 --- a/src/share/classes/com/sun/tools/example/debug/gui/JDBFileFilter.java +++ b/src/share/classes/com/sun/tools/example/debug/gui/JDBFileFilter.java @@ -201,11 +201,11 @@ public class JDBFileFilter extends FileFilter { if(description == null || isExtensionListInDescription()) { fullDescription = description==null ? "(" : description + " ("; // build the description from the extension list - Enumeration extensions = filters.keys(); + Enumeration extensions = filters.keys(); if(extensions != null) { - fullDescription += "." + (String) extensions.nextElement(); + fullDescription += "." + extensions.nextElement(); while (extensions.hasMoreElements()) { - fullDescription += ", " + (String) extensions.nextElement(); + fullDescription += ", " + extensions.nextElement(); } } fullDescription += ")"; diff --git a/src/share/classes/com/sun/tools/example/debug/gui/LaunchTool.java b/src/share/classes/com/sun/tools/example/debug/gui/LaunchTool.java index 7aed53869e15fe8d1f45325a36608cb2037f6c99..fc115b9078eb0f69b95ac5c38ec68de6e4ec8498 100644 --- a/src/share/classes/com/sun/tools/example/debug/gui/LaunchTool.java +++ b/src/share/classes/com/sun/tools/example/debug/gui/LaunchTool.java @@ -131,14 +131,13 @@ class LaunchTool { final JPanel radioPanel = new JPanel(); final ButtonGroup radioGroup = new ButtonGroup(); VirtualMachineManager manager = Bootstrap.virtualMachineManager(); - List all = manager.allConnectors(); + List all = manager.allConnectors(); Map modelToConnector = new HashMap(all.size(), 0.5f); dialog.setModal(true); dialog.setTitle("Select Connector Type"); radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS)); - for (Iterator it = all.iterator(); it.hasNext(); ) { - Connector connector = (Connector)it.next(); + for (Connector connector : all) { JRadioButton radio = new JRadioButton(connector.description()); modelToConnector.put(radio.getModel(), connector); radioPanel.add(radio); @@ -166,7 +165,7 @@ class LaunchTool { dialog.show(); return oked[0] ? - (Connector)(modelToConnector.get(radioGroup.getSelection())) : + modelToConnector.get(radioGroup.getSelection()) : null; } @@ -188,13 +187,12 @@ class LaunchTool { // guts.add(new JLabel(connector.description())); final List argReps = new ArrayList(args.size()); - for (Iterator it = args.values().iterator(); it.hasNext(); ) { - Object arg = it.next(); + for (Connector.Argument arg : args.values()) { ArgRep ar; if (arg instanceof Connector.BooleanArgument) { ar = new BooleanArgRep((Connector.BooleanArgument)arg, guts); } else { - ar = new StringArgRep((Connector.Argument)arg, guts); + ar = new StringArgRep(arg, guts); } argReps.add(ar); } @@ -202,8 +200,7 @@ class LaunchTool { JPanel buttonPanel = okCancel( dialog, new ActionListener() { public void actionPerformed(ActionEvent event) { - for (Iterator it = argReps.iterator(); it.hasNext(); ) { - ArgRep ar = (ArgRep)it.next(); + for (ArgRep ar : argReps) { if (!ar.isSpecified()) { JOptionPane.showMessageDialog(dialog, ar.arg.label() + diff --git a/src/share/classes/com/sun/tools/example/debug/gui/SearchPath.java b/src/share/classes/com/sun/tools/example/debug/gui/SearchPath.java index 45f7ac7eb4dff22612f320d2f25a6320d6a15847..1d61c8fa068c76201b2f53d15813ec9b9c4baf4c 100644 --- a/src/share/classes/com/sun/tools/example/debug/gui/SearchPath.java +++ b/src/share/classes/com/sun/tools/example/debug/gui/SearchPath.java @@ -42,7 +42,7 @@ public class SearchPath { dlist.add(st.nextToken()); } pathString = searchPath; - pathArray = (String[])dlist.toArray(new String[dlist.size()]); + pathArray = dlist.toArray(new String[dlist.size()]); } public boolean isEmpty() { @@ -54,7 +54,7 @@ public class SearchPath { } public String[] asArray() { - return (String[])pathArray.clone(); + return pathArray.clone(); } public File resolve(String relativeFileName) { @@ -89,7 +89,7 @@ public class SearchPath { } } } - return (String[])s.toArray(new String[s.size()]); + return s.toArray(new String[s.size()]); } } diff --git a/src/share/classes/com/sun/tools/example/debug/gui/SourceManager.java b/src/share/classes/com/sun/tools/example/debug/gui/SourceManager.java index 56667100dd13c19051219c20ef11e848311d6049..7173b5f1014c1ef7b4247fa23ed266619bf42f05 100644 --- a/src/share/classes/com/sun/tools/example/debug/gui/SourceManager.java +++ b/src/share/classes/com/sun/tools/example/debug/gui/SourceManager.java @@ -113,7 +113,7 @@ public class SourceManager { * Returns null if not available. */ public SourceModel sourceForClass(ReferenceType refType) { - SourceModel sm = (SourceModel)classToSource.get(refType); + SourceModel sm = classToSource.get(refType); if (sm != null) { return sm; } @@ -140,10 +140,10 @@ public class SourceManager { */ //### Use hash table for this? public SourceModel sourceForFile(File path) { - Iterator iter = sourceList.iterator(); + Iterator iter = sourceList.iterator(); SourceModel sm = null; while (iter.hasNext()) { - SourceModel candidate = (SourceModel)iter.next(); + SourceModel candidate = iter.next(); if (candidate.fileName().equals(path)) { sm = candidate; iter.remove(); // Will move to start of list. diff --git a/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java b/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java index 6bb1e551e420e53369b1e4dbb50920ddac0ccfb5..75cdca6857d0f9c9478623441f4c3e5c79144049 100644 --- a/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java +++ b/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java @@ -187,22 +187,17 @@ public class SourceModel extends AbstractListModel { * when sourceLines is set. */ private void markClassLines(ReferenceType refType) { - List methods = refType.methods(); - for (Iterator mit = methods.iterator(); mit.hasNext();) { - Method meth = (Method)mit.next(); + for (Method meth : refType.methods()) { try { - List lines = meth.allLineLocations(); - for (Iterator lit = lines.iterator(); lit.hasNext();) { - Location loc = (Location)lit.next(); + for (Location loc : meth.allLineLocations()) { showExecutable(loc.lineNumber(), refType); } } catch (AbsentInformationException exc) { // do nothing } } - List bps = env.getExecutionManager().eventRequestManager().breakpointRequests(); - for (Iterator it = bps.iterator(); it.hasNext();) { - BreakpointRequest bp = (BreakpointRequest)it.next(); + for (BreakpointRequest bp : + env.getExecutionManager().eventRequestManager().breakpointRequests()) { if (bp.location() != null) { Location loc = bp.location(); if (loc.declaringType().equals(refType)) { @@ -224,8 +219,8 @@ public class SourceModel extends AbstractListModel { } finally { reader.close(); } - for (Iterator it = classes.iterator(); it.hasNext();) { - markClassLines((ClassType)it.next()); + for (ReferenceType refType : classes) { + markClassLines(refType); } } diff --git a/src/share/classes/com/sun/tools/example/debug/gui/StackTraceTool.java b/src/share/classes/com/sun/tools/example/debug/gui/StackTraceTool.java index 7f4c857895aa54937a77f1f9cfd2823a07e074d4..78476f0d98b820a0f827161c59eedb8e76f281a0 100644 --- a/src/share/classes/com/sun/tools/example/debug/gui/StackTraceTool.java +++ b/src/share/classes/com/sun/tools/example/debug/gui/StackTraceTool.java @@ -139,7 +139,7 @@ public class StackTraceTool extends JPanel { String methName = meth.declaringType().name() + '.' + meth.name(); String position = ""; - if (meth instanceof Method && ((Method)meth).isNative()) { + if (meth.isNative()) { position = " (native method)"; } else if (loc.lineNumber() != -1) { position = ":" + loc.lineNumber(); diff --git a/src/share/classes/com/sun/tools/example/debug/gui/ThreadTreeTool.java b/src/share/classes/com/sun/tools/example/debug/gui/ThreadTreeTool.java index 3b6d5fc4181f86f6372d74bef77caf28481ae0d1..955c5b6cbc19b45f0e3b3d3ce3686af384e7d1b4 100644 --- a/src/share/classes/com/sun/tools/example/debug/gui/ThreadTreeTool.java +++ b/src/share/classes/com/sun/tools/example/debug/gui/ThreadTreeTool.java @@ -133,9 +133,7 @@ public class ThreadTreeTool extends JPanel { public void sessionStart(EventObject e) { try { - Iterator iter = runtime.allThreads().iterator(); - while (iter.hasNext()) { - ThreadReference thread = ((ThreadReference)iter.next()); + for (ThreadReference thread : runtime.allThreads()) { root.addThread(thread); } } catch (VMDisconnectedException ee) { @@ -244,16 +242,16 @@ public class ThreadTreeTool extends JPanel { } } - private void addThread(List threadPath, ThreadReference thread) { + private void addThread(List threadPath, ThreadReference thread) { int size = threadPath.size(); if (size == 0) { return; } else if (size == 1) { - String name = (String)threadPath.get(0); + String name = threadPath.get(0); insertNode(name, thread); } else { - String head = (String)threadPath.get(0); - List tail = threadPath.subList(1, size); + String head = threadPath.get(0); + List tail = threadPath.subList(1, size); ThreadTreeNode child = insertNode(head, null); child.addThread(tail, thread); } @@ -288,17 +286,17 @@ public class ThreadTreeTool extends JPanel { } } - private void removeThread(List threadPath, ThreadReference thread) { + private void removeThread(List threadPath, ThreadReference thread) { int size = threadPath.size(); if (size == 0) { return; } else if (size == 1) { - String name = (String)threadPath.get(0); + String name = threadPath.get(0); ThreadTreeNode child = findLeafNode(thread, name); treeModel.removeNodeFromParent(child); } else { - String head = (String)threadPath.get(0); - List tail = threadPath.subList(1, size); + String head = threadPath.get(0); + List tail = threadPath.subList(1, size); ThreadTreeNode child = findInternalNode(head); child.removeThread(tail, thread); if (child.isThreadGroup() && child.getChildCount() < 1) { diff --git a/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java b/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java index c79f17e36082d86c70258e203ad142a342cff90d..c6d437d29e6118b9aaf3a52d05f763bdfaa307ba 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java @@ -34,7 +34,7 @@ import java.util.Iterator; class BreakpointSpec extends EventRequestSpec { String methodId; - List methodArgs; + List methodArgs; int lineNumber; BreakpointSpec(ReferenceTypeSpec refSpec, int lineNumber) { @@ -45,7 +45,7 @@ class BreakpointSpec extends EventRequestSpec { } BreakpointSpec(ReferenceTypeSpec refSpec, String methodId, - List methodArgs) throws MalformedMemberNameException { + List methodArgs) throws MalformedMemberNameException { super(refSpec); this.methodId = methodId; this.methodArgs = methodArgs; @@ -83,7 +83,7 @@ class BreakpointSpec extends EventRequestSpec { return lineNumber; } - List methodArgs() { + List methodArgs() { return methodArgs; } @@ -146,14 +146,13 @@ class BreakpointSpec extends EventRequestSpec { buffer.append('.'); buffer.append(methodId); if (methodArgs != null) { - Iterator iter = methodArgs.iterator(); boolean first = true; buffer.append('('); - while (iter.hasNext()) { + for (String arg : methodArgs) { if (!first) { buffer.append(','); } - buffer.append((String)iter.next()); + buffer.append(arg); first = false; } buffer.append(")"); @@ -176,12 +175,12 @@ class BreakpointSpec extends EventRequestSpec { location = method.location(); } else { // let AbsentInformationException be thrown - List locs = refType.locationsOfLine(lineNumber()); + List locs = refType.locationsOfLine(lineNumber()); if (locs.size() == 0) { throw new LineNotFoundException(); } // TO DO: handle multiple locations - location = (Location)locs.get(0); + location = locs.get(0); if (location.method() == null) { throw new LineNotFoundException(); } @@ -202,8 +201,8 @@ class BreakpointSpec extends EventRequestSpec { * and if the number of arguments in the method matches the * number of names passed */ - private boolean compareArgTypes(Method method, List nameList) { - List argTypeNames = method.argumentTypeNames(); + private boolean compareArgTypes(Method method, List nameList) { + List argTypeNames = method.argumentTypeNames(); // If argument counts differ, we can stop here if (argTypeNames.size() != nameList.size()) { @@ -213,8 +212,8 @@ class BreakpointSpec extends EventRequestSpec { // Compare each argument type's name int nTypes = argTypeNames.size(); for (int i = 0; i < nTypes; ++i) { - String comp1 = (String)argTypeNames.get(i); - String comp2 = (String)nameList.get(i); + String comp1 = argTypeNames.get(i); + String comp2 = nameList.get(i); if (! comp1.equals(comp2)) { /* * We have to handle varargs. EG, the @@ -331,22 +330,17 @@ class BreakpointSpec extends EventRequestSpec { List argTypeNames = null; if (methodArgs() != null) { argTypeNames = new ArrayList(methodArgs().size()); - Iterator iter = methodArgs().iterator(); - while (iter.hasNext()) { - String name = (String)iter.next(); + for (String name : methodArgs()) { name = normalizeArgTypeName(name); argTypeNames.add(name); } } // Check each method in the class for matches - Iterator iter = refType.methods().iterator(); Method firstMatch = null; // first method with matching name Method exactMatch = null; // (only) method with same name & sig int matchCount = 0; // > 1 implies overload - while (iter.hasNext()) { - Method candidate = (Method)iter.next(); - + for (Method candidate : refType.methods()) { if (candidate.name().equals(methodName())) { matchCount++; diff --git a/src/share/classes/com/sun/tools/example/debug/tty/Commands.java b/src/share/classes/com/sun/tools/example/debug/tty/Commands.java index 0f913eabaec690c8bc5ef90dec849277db59f52a..e607d7165d4b82025888ee7b20274b10d9224535 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/Commands.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/Commands.java @@ -157,16 +157,16 @@ class Commands { buf.append(method.name()); buf.append("("); - List args = method.argumentTypeNames(); + List args = method.argumentTypeNames(); int lastParam = args.size() - 1; // output param types except for the last for (int ii = 0; ii < lastParam; ii++) { - buf.append((String)args.get(ii)); + buf.append(args.get(ii)); buf.append(", "); } if (lastParam >= 0) { // output the last param - String lastStr = (String)args.get(lastParam); + String lastStr = args.get(lastParam); if (method.isVarArgs()) { // lastParam is an array. Replace the [] with ... buf.append(lastStr.substring(0, lastStr.length() - 2)); @@ -180,12 +180,11 @@ class Commands { } void commandConnectors(VirtualMachineManager vmm) { - Iterator iter = vmm.allConnectors().iterator(); - if (iter.hasNext()) { + Collection ccs = vmm.allConnectors(); + if (ccs.isEmpty()) { MessageOutput.println("Connectors available"); } - while (iter.hasNext()) { - Connector cc = (Connector)iter.next(); + for (Connector cc : ccs) { String transportName = cc.transport() == null ? "null" : cc.transport().name(); MessageOutput.println(); @@ -193,10 +192,7 @@ class Commands { new Object [] {cc.name(), transportName}); MessageOutput.println("Connector description", cc.description()); - Iterator argIter = cc.defaultArguments().values().iterator(); - if (argIter.hasNext()) { - while (argIter.hasNext()) { - Connector.Argument aa = (Connector.Argument)argIter.next(); + for (Connector.Argument aa : cc.defaultArguments().values()) { MessageOutput.println(); boolean requiredArgument = aa.mustSpecify(); @@ -215,16 +211,12 @@ class Commands { } } - } } void commandClasses() { - List list = Env.vm().allClasses(); - StringBuffer classList = new StringBuffer(); - for (int i = 0 ; i < list.size() ; i++) { - ReferenceType refType = (ReferenceType)list.get(i); + for (ReferenceType refType : Env.vm().allClasses()) { classList.append(refType.name()); classList.append("\n"); } @@ -232,7 +224,7 @@ class Commands { } void commandClass(StringTokenizer t) { - List list = Env.vm().allClasses(); + List list = Env.vm().allClasses(); if (!t.hasMoreTokens()) { MessageOutput.println("No class specified."); @@ -265,51 +257,31 @@ class Commands { superclass = showAll ? superclass.superclass() : null; } - List interfaces = showAll ? clazz.allInterfaces() - : clazz.interfaces(); - Iterator iter = interfaces.iterator(); - while (iter.hasNext()) { - InterfaceType interfaze = (InterfaceType)iter.next(); + List interfaces = + showAll ? clazz.allInterfaces() : clazz.interfaces(); + for (InterfaceType interfaze : interfaces) { MessageOutput.println("implements:", interfaze.name()); } - List subs = clazz.subclasses(); - iter = subs.iterator(); - while (iter.hasNext()) { - ClassType sub = (ClassType)iter.next(); + for (ClassType sub : clazz.subclasses()) { MessageOutput.println("subclass:", sub.name()); } - List nested = clazz.nestedTypes(); - iter = nested.iterator(); - while (iter.hasNext()) { - ReferenceType nest = (ReferenceType)iter.next(); + for (ReferenceType nest : clazz.nestedTypes()) { MessageOutput.println("nested:", nest.name()); } } else if (type instanceof InterfaceType) { InterfaceType interfaze = (InterfaceType)type; MessageOutput.println("Interface:", interfaze.name()); - List supers = interfaze.superinterfaces(); - Iterator iter = supers.iterator(); - while (iter.hasNext()) { - InterfaceType superinterface = (InterfaceType)iter.next(); + for (InterfaceType superinterface : interfaze.superinterfaces()) { MessageOutput.println("extends:", superinterface.name()); } - List subs = interfaze.subinterfaces(); - iter = subs.iterator(); - while (iter.hasNext()) { - InterfaceType sub = (InterfaceType)iter.next(); + for (InterfaceType sub : interfaze.subinterfaces()) { MessageOutput.println("subinterface:", sub.name()); } - List implementors = interfaze.implementors(); - iter = implementors.iterator(); - while (iter.hasNext()) { - ClassType implementor = (ClassType)iter.next(); + for (ClassType implementor : interfaze.implementors()) { MessageOutput.println("implementor:", implementor.name()); } - List nested = interfaze.nestedTypes(); - iter = nested.iterator(); - while (iter.hasNext()) { - ReferenceType nest = (ReferenceType)iter.next(); + for (ReferenceType nest : interfaze.nestedTypes()) { MessageOutput.println("nested:", nest.name()); } } else { // array type @@ -327,10 +299,8 @@ class Commands { String idClass = t.nextToken(); ReferenceType cls = Env.getReferenceTypeFromToken(idClass); if (cls != null) { - List methods = cls.allMethods(); StringBuffer methodsList = new StringBuffer(); - for (int i = 0; i < methods.size(); i++) { - Method method = (Method)methods.get(i); + for (Method method : cls.allMethods()) { methodsList.append(method.declaringType().name()); methodsList.append(" "); methodsList.append(typedName(method)); @@ -351,11 +321,10 @@ class Commands { String idClass = t.nextToken(); ReferenceType cls = Env.getReferenceTypeFromToken(idClass); if (cls != null) { - List fields = cls.allFields(); - List visible = cls.visibleFields(); + List fields = cls.allFields(); + List visible = cls.visibleFields(); StringBuffer fieldsList = new StringBuffer(); - for (int i = 0; i < fields.size(); i++) { - Field field = (Field)fields.get(i); + for (Field field : fields) { String s; if (!visible.contains(field)) { s = MessageOutput.format("list field typename and name hidden", @@ -386,7 +355,7 @@ class Commands { int maxIdLength = 0; int maxNameLength = 0; while (threadIter.hasNext()) { - ThreadReference thr = (ThreadReference)threadIter.next(); + ThreadReference thr = threadIter.next(); maxIdLength = Math.max(maxIdLength, Env.description(thr).length()); maxNameLength = Math.max(maxNameLength, @@ -395,7 +364,7 @@ class Commands { threadIter = new ThreadIterator(tg); while (threadIter.hasNext()) { - ThreadReference thr = (ThreadReference)threadIter.next(); + ThreadReference thr = threadIter.next(); if (thr.threadGroup() == null) { continue; } @@ -588,9 +557,7 @@ class Commands { private List allThreads(ThreadGroupReference group) { List list = new ArrayList(); list.addAll(group.threads()); - Iterator iter = group.threadGroups().iterator(); - while (iter.hasNext()) { - ThreadGroupReference child = (ThreadGroupReference)iter.next(); + for (ThreadGroupReference child : group.threadGroups()) { list.addAll(allThreads(child)); } return list; @@ -641,10 +608,7 @@ class Commands { * if so, it gets removed here. */ EventRequestManager mgr = Env.vm().eventRequestManager(); - List requests = mgr.stepRequests(); - Iterator iter = requests.iterator(); - while (iter.hasNext()) { - StepRequest request = (StepRequest)iter.next(); + for (StepRequest request : mgr.stepRequests()) { if (request.thread().equals(thread)) { mgr.deleteEventRequest(request); break; @@ -768,9 +732,7 @@ class Commands { boolean noExceptions = true; // Print a listing of the catch patterns currently in place - Iterator iter = Env.specList.eventRequestSpecs().iterator(); - while (iter.hasNext()) { - EventRequestSpec spec = (EventRequestSpec)iter.next(); + for (EventRequestSpec spec : Env.specList.eventRequestSpecs()) { if (spec instanceof ExceptionSpec) { if (noExceptions) { noExceptions = false; @@ -928,7 +890,7 @@ class Commands { } private void dumpStack(ThreadInfo threadInfo, boolean showPC) { - List stack = null; + List stack = null; try { stack = threadInfo.getStack(); } catch (IncompatibleThreadStateException e) { @@ -940,7 +902,7 @@ class Commands { } else { int nFrames = stack.size(); for (int i = threadInfo.getCurrentFrameIndex(); i < nFrames; i++) { - StackFrame frame = (StackFrame)stack.get(i); + StackFrame frame = stack.get(i); dumpFrame (i, showPC, frame); } } @@ -956,7 +918,7 @@ class Commands { long lineNumber = loc.lineNumber(); String methodInfo = null; - if (meth instanceof Method && ((Method)meth).isNative()) { + if (meth.isNative()) { methodInfo = MessageOutput.format("native method"); } else if (lineNumber != -1) { try { @@ -994,9 +956,7 @@ class Commands { } else { String token = t.nextToken(); if (token.toLowerCase().equals("all")) { - Iterator iter = ThreadInfo.threads().iterator(); - while (iter.hasNext()) { - ThreadInfo threadInfo = (ThreadInfo)iter.next(); + for (ThreadInfo threadInfo : ThreadInfo.threads()) { MessageOutput.println("Thread:", threadInfo.getThread().name()); dumpStack(threadInfo, showPC); @@ -1051,9 +1011,7 @@ class Commands { boolean noBreakpoints = true; // Print set breakpoints - Iterator iter = Env.specList.eventRequestSpecs().iterator(); - while (iter.hasNext()) { - EventRequestSpec spec = (EventRequestSpec)iter.next(); + for (EventRequestSpec spec : Env.specList.eventRequestSpecs()) { if (spec instanceof BreakpointSpec) { if (noBreakpoints) { noBreakpoints = false; @@ -1075,7 +1033,7 @@ class Commands { protected BreakpointSpec parseBreakpointSpec(StringTokenizer t, String atForm, String inForm) { - EventRequestSpec breakpoint = null; + BreakpointSpec breakpoint = null; try { String token = t.nextToken(":( \t\n\r"); @@ -1149,7 +1107,7 @@ class Commands { printBreakpointCommandUsage(atForm, inForm); return null; } - return (BreakpointSpec)breakpoint; + return breakpoint; } private void resolveNow(EventRequestSpec spec) { @@ -1209,8 +1167,8 @@ class Commands { } } - private List parseWatchpointSpec(StringTokenizer t) { - List list = new ArrayList(); + private List parseWatchpointSpec(StringTokenizer t) { + List list = new ArrayList(); boolean access = false; boolean modification = false; int suspendPolicy = EventRequest.SUSPEND_ALL; @@ -1242,7 +1200,7 @@ class Commands { fieldName = fieldName.substring(dot+1); try { - EventRequestSpec spec; + WatchpointSpec spec; if (access) { spec = Env.specList.createAccessWatchpoint(className, fieldName); @@ -1269,9 +1227,8 @@ class Commands { return; } - Iterator iter = parseWatchpointSpec(t).iterator(); - while (iter.hasNext()) { - resolveNow((WatchpointSpec)iter.next()); + for (WatchpointSpec spec : parseWatchpointSpec(t)) { + resolveNow(spec); } } @@ -1281,9 +1238,7 @@ class Commands { return; } - Iterator iter = parseWatchpointSpec(t).iterator(); - while (iter.hasNext()) { - WatchpointSpec spec = (WatchpointSpec)iter.next(); + for (WatchpointSpec spec : parseWatchpointSpec(t)) { if (Env.specList.delete(spec)) { MessageOutput.println("Removed:", spec.toString()); } else { @@ -1482,7 +1437,7 @@ class Commands { lineno = n.intValue(); } catch (java.text.ParseException jtpe) { // It isn't -- see if it's a method name. - List meths = refType.methodsByName(id); + List meths = refType.methodsByName(id); if (meths == null || meths.size() == 0) { MessageOutput.println("is not a valid line number or method name for", new Object [] {id, refType.name()}); @@ -1492,7 +1447,7 @@ class Commands { new Object [] {id, refType.name()}); return; } - loc = ((Method)meths.get(0)).location(); + loc = meths.get(0).location(); lineno = loc.lineNumber(); } } @@ -1539,14 +1494,11 @@ class Commands { try { ReferenceType refType = Env.getReferenceTypeFromToken(idClass); if (refType != null) { - List lines = null; + List lines = null; if (idMethod == null) { lines = refType.allLineLocations(); } else { - List methods = refType.allMethods(); - Iterator iter = methods.iterator(); - while (iter.hasNext()) { - Method method = (Method)iter.next(); + for (Method method : refType.allMethods()) { if (method.name().equals(idMethod)) { lines = method.allLineLocations(); } @@ -1555,9 +1507,7 @@ class Commands { MessageOutput.println("is not a valid method name", idMethod); } } - Iterator iter = lines.iterator(); - while (iter.hasNext()) { - Location line = (Location)iter.next(); + for (Location line : lines) { MessageOutput.printDirectln(line.toString());// Special case: use printDirectln() } } else { @@ -1620,21 +1570,19 @@ class Commands { MessageOutput.println("No local variables"); return; } - Map values = frame.getValues(vars); + Map values = frame.getValues(vars); MessageOutput.println("Method arguments:"); - for (Iterator it = vars.iterator(); it.hasNext(); ) { - LocalVariable var = (LocalVariable)it.next(); + for (LocalVariable var : vars) { if (var.isArgument()) { - Value val = (Value)values.get(var); + Value val = values.get(var); printVar(var, val); } } MessageOutput.println("Local variables:"); - for (Iterator it = vars.iterator(); it.hasNext(); ) { - LocalVariable var = (LocalVariable)it.next(); + for (LocalVariable var : vars) { if (!var.isArgument()) { - Value val = (Value)values.get(var); + Value val = values.get(var); printVar(var, val); } } @@ -1647,9 +1595,8 @@ class Commands { private void dump(ObjectReference obj, ReferenceType refType, ReferenceType refTypeBase) { - for (Iterator it = refType.fields().iterator(); it.hasNext(); ) { + for (Field field : refType.fields()) { StringBuffer o = new StringBuffer(); - Field field = (Field)it.next(); o.append(" "); if (!refType.equals(refTypeBase)) { o.append(refType.name()); @@ -1666,14 +1613,13 @@ class Commands { dump(obj, sup, refTypeBase); } } else if (refType instanceof InterfaceType) { - List sups = ((InterfaceType)refType).superinterfaces(); - for (Iterator it = sups.iterator(); it.hasNext(); ) { - dump(obj, (ReferenceType)it.next(), refTypeBase); + for (InterfaceType sup : ((InterfaceType)refType).superinterfaces()) { + dump(obj, sup, refTypeBase); } } else { /* else refType is an instanceof ArrayType */ if (obj instanceof ArrayReference) { - for (Iterator it = ((ArrayReference)obj).getValues().iterator(); + for (Iterator it = ((ArrayReference)obj).getValues().iterator(); it.hasNext(); ) { MessageOutput.printDirect(it.next().toString());// Special case: use printDirect() if (it.hasNext()) { @@ -1770,13 +1716,11 @@ class Commands { new Object [] {owner.name(), new Integer (object.entryCount())}); } - List waiters = object.waitingThreads(); + List waiters = object.waitingThreads(); if (waiters.size() == 0) { MessageOutput.println("No waiters"); } else { - Iterator iter = waiters.iterator(); - while (iter.hasNext()) { - ThreadReference waiter = (ThreadReference)iter.next(); + for (ThreadReference waiter : waiters) { MessageOutput.println("Waiting thread:", waiter.name()); } } @@ -1800,13 +1744,11 @@ class Commands { ThreadReference thread = threadInfo.getThread(); try { MessageOutput.println("Monitor information for thread", thread.name()); - List owned = thread.ownedMonitors(); + List owned = thread.ownedMonitors(); if (owned.size() == 0) { MessageOutput.println("No monitors owned"); } else { - Iterator iter = owned.iterator(); - while (iter.hasNext()) { - ObjectReference monitor = (ObjectReference)iter.next(); + for (ObjectReference monitor : owned) { MessageOutput.println("Owned monitor:", monitor.toString()); } } @@ -1833,9 +1775,7 @@ class Commands { } String token = t.nextToken(); if (token.toLowerCase().equals("all")) { - Iterator iter = ThreadInfo.threads().iterator(); - while (iter.hasNext()) { - ThreadInfo threadInfo = (ThreadInfo)iter.next(); + for (ThreadInfo threadInfo : ThreadInfo.threads()) { printThreadLockInfo(threadInfo); } } else { @@ -1930,14 +1870,12 @@ class Commands { void commandSave(final StringTokenizer t) { // Undocumented command: useful for testing. if (!t.hasMoreTokens()) { - Set keys = Env.getSaveKeys(); - Iterator iter = keys.iterator(); - if (!iter.hasNext()) { + Set keys = Env.getSaveKeys(); + if (keys.isEmpty()) { MessageOutput.println("No saved values"); return; } - while (iter.hasNext()) { - String key = (String)iter.next(); + for (String key : keys) { Value value = Env.getSavedValue(key); if ((value instanceof ObjectReference) && ((ObjectReference)value).isCollected()) { @@ -1976,7 +1914,7 @@ class Commands { // Overloading is not handled here. String methodName = t.nextToken(); - List classes = Env.vm().classesByName(className); + List classes = Env.vm().classesByName(className); // TO DO: handle multiple classes found if (classes.size() == 0) { if (className.indexOf('.') < 0) { @@ -1987,17 +1925,14 @@ class Commands { return; } - ReferenceType rt = (ReferenceType)classes.get(0); + ReferenceType rt = classes.get(0); if (!(rt instanceof ClassType)) { MessageOutput.println("not a class", className); return; } byte[] bytecodes = null; - List list = rt.methodsByName(methodName); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - Method method = (Method)iter.next(); + for (Method method : rt.methodsByName(methodName)) { if (!method.isAbstract()) { bytecodes = method.bytecodes(); break; @@ -2047,7 +1982,7 @@ class Commands { MessageOutput.println("Specify classes to redefine"); } else { String className = t.nextToken(); - List classes = Env.vm().classesByName(className); + List classes = Env.vm().classesByName(className); if (classes.size() == 0) { MessageOutput.println("No class named", className); return; @@ -2057,7 +1992,7 @@ class Commands { return; } Env.setSourcePath(Env.getSourcePath()); - ReferenceType refType = (ReferenceType)classes.get(0); + ReferenceType refType = classes.get(0); if (!t.hasMoreTokens()) { MessageOutput.println("Specify file name for class", className); return; @@ -2074,7 +2009,8 @@ class Commands { new Object [] {fileName, exc.toString()}); return; } - Map map = new HashMap(); + Map map + = new HashMap(); map.put(refType, bytes); try { Env.vm().redefineClasses(map); diff --git a/src/share/classes/com/sun/tools/example/debug/tty/Env.java b/src/share/classes/com/sun/tools/example/debug/tty/Env.java index be3fb306a578a36a6bc29a4ac9f1631f2a99778f..9d848a0205b1d6337d2ea7d942a3d7a6f83d50cd 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/Env.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/Env.java @@ -89,7 +89,7 @@ class Env { sourceCache.clear(); } - static void setSourcePath(List srcList) { + static void setSourcePath(List srcList) { sourceMapper = new SourceMapper(srcList); sourceCache.clear(); } @@ -106,10 +106,8 @@ class Env { } static String excludesString() { - Iterator iter = excludes().iterator(); StringBuffer buffer = new StringBuffer(); - while (iter.hasNext()) { - String pattern = (String)iter.next(); + for (String pattern : excludes()) { buffer.append(pattern); buffer.append(","); } @@ -117,25 +115,19 @@ class Env { } static void addExcludes(StepRequest request) { - Iterator iter = excludes().iterator(); - while (iter.hasNext()) { - String pattern = (String)iter.next(); + for (String pattern : excludes()) { request.addClassExclusionFilter(pattern); } } static void addExcludes(MethodEntryRequest request) { - Iterator iter = excludes().iterator(); - while (iter.hasNext()) { - String pattern = (String)iter.next(); + for (String pattern : excludes()) { request.addClassExclusionFilter(pattern); } } static void addExcludes(MethodExitRequest request) { - Iterator iter = excludes().iterator(); - while (iter.hasNext()) { - String pattern = (String)iter.next(); + for (String pattern : excludes()) { request.addClassExclusionFilter(pattern); } } @@ -175,10 +167,10 @@ class Env { try { String fileName = location.sourceName(); - Iterator iter = sourceCache.iterator(); + Iterator iter = sourceCache.iterator(); SourceCode code = null; while (iter.hasNext()) { - SourceCode candidate = (SourceCode)iter.next(); + SourceCode candidate = iter.next(); if (candidate.fileName().equals(fileName)) { code = candidate; iter.remove(); @@ -269,10 +261,7 @@ class Env { // loaded class whose name matches this limited regular // expression is selected. idToken = idToken.substring(1); - List classes = Env.vm().allClasses(); - Iterator iter = classes.iterator(); - while (iter.hasNext()) { - ReferenceType type = ((ReferenceType)iter.next()); + for (ReferenceType type : Env.vm().allClasses()) { if (type.name().endsWith(idToken)) { cls = type; break; @@ -280,21 +269,21 @@ class Env { } } else { // It's a class name - List classes = Env.vm().classesByName(idToken); + List classes = Env.vm().classesByName(idToken); if (classes.size() > 0) { // TO DO: handle multiples - cls = (ReferenceType)classes.get(0); + cls = classes.get(0); } } return cls; } - static Set getSaveKeys() { + static Set getSaveKeys() { return savedValues.keySet(); } static Value getSavedValue(String key) { - return (Value)savedValues.get(key); + return savedValues.get(key); } static void setSavedValue(String key, Value value) { @@ -327,7 +316,7 @@ class Env { if (index >= sourceLines.size()) { return null; } else { - return (String)sourceLines.get(index); + return sourceLines.get(index); } } } diff --git a/src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java b/src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java index 27ef3913ece560c7320a33377809cc6a4acc180a..ee80f9df5387f183f958993563e83af069bd9822 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java @@ -150,7 +150,7 @@ public class EventHandler implements Runnable { EventSet eventSet = queue.remove(); EventIterator iter = eventSet.eventIterator(); while (iter.hasNext()) { - handleExitEvent((Event)iter.next()); + handleExitEvent(iter.next()); } } catch (InterruptedException exc) { // ignore @@ -183,7 +183,7 @@ public class EventHandler implements Runnable { * If any event in the set has a thread associated with it, * they all will, so just grab the first one. */ - Event event = (Event)set.iterator().next(); // Is there a better way? + Event event = set.iterator().next(); // Is there a better way? thread = eventThread(event); } else { thread = null; diff --git a/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpec.java b/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpec.java index bb86c2f3af09fa0ee9db4ab71a27c253d052df63..7169e33f6f026777eef7f7feb3a25ae88839ab0c 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpec.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpec.java @@ -101,10 +101,8 @@ abstract class EventRequestSpec { * so that is all we need to examine. */ ArrayList deleteList = new ArrayList(); - Iterator iter = - Env.vm().eventRequestManager().exceptionRequests().iterator(); - while (iter.hasNext()) { - ExceptionRequest er = (ExceptionRequest)iter.next(); + for (ExceptionRequest er : + Env.vm().eventRequestManager().exceptionRequests()) { if (prs.matches(er.exception())) { deleteList.add (er); } @@ -115,9 +113,7 @@ abstract class EventRequestSpec { } private EventRequest resolveAgainstPreparedClasses() throws Exception { - Iterator iter = Env.vm().allClasses().iterator(); - while (iter.hasNext()) { - ReferenceType refType = (ReferenceType)iter.next(); + for (ReferenceType refType : Env.vm().allClasses()) { if (refType.isPrepared() && refSpec.matches(refType)) { resolved = resolveEventRequest(refType); } diff --git a/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpecList.java b/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpecList.java index 2f3286d1a7e9c1b0f7a76a290a3a3ba0245e66aa..e5741efc706d85f11ba7cd14d4d425a1e0141345 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpecList.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/EventRequestSpecList.java @@ -55,9 +55,7 @@ class EventRequestSpecList { boolean resolve(ClassPrepareEvent event) { boolean failure = false; synchronized(eventRequestSpecs) { - Iterator iter = eventRequestSpecs.iterator(); - while (iter.hasNext()) { - EventRequestSpec spec = (EventRequestSpec)iter.next(); + for (EventRequestSpec spec : eventRequestSpecs) { if (!spec.isResolved()) { try { EventRequest eventRequest = spec.resolve(event); @@ -77,9 +75,7 @@ class EventRequestSpecList { } void resolveAll() { - Iterator iter = eventRequestSpecs.iterator(); - while (iter.hasNext()) { - EventRequestSpec spec = (EventRequestSpec)iter.next(); + for (EventRequestSpec spec : eventRequestSpecs) { try { EventRequest eventRequest = spec.resolveEagerly(); if (eventRequest != null) { @@ -106,16 +102,16 @@ class EventRequestSpecList { } } - EventRequestSpec createBreakpoint(String classPattern, - int line) throws ClassNotFoundException { + BreakpointSpec createBreakpoint(String classPattern, int line) + throws ClassNotFoundException { ReferenceTypeSpec refSpec = new PatternReferenceTypeSpec(classPattern); return new BreakpointSpec(refSpec, line); } - EventRequestSpec createBreakpoint(String classPattern, + BreakpointSpec createBreakpoint(String classPattern, String methodId, - List methodArgs) + List methodArgs) throws MalformedMemberNameException, ClassNotFoundException { ReferenceTypeSpec refSpec = @@ -132,7 +128,7 @@ class EventRequestSpecList { return new ExceptionSpec(refSpec, notifyCaught, notifyUncaught); } - EventRequestSpec createAccessWatchpoint(String classPattern, + WatchpointSpec createAccessWatchpoint(String classPattern, String fieldId) throws MalformedMemberNameException, ClassNotFoundException { @@ -141,7 +137,7 @@ class EventRequestSpecList { return new AccessWatchpointSpec(refSpec, fieldId); } - EventRequestSpec createModificationWatchpoint(String classPattern, + WatchpointSpec createModificationWatchpoint(String classPattern, String fieldId) throws MalformedMemberNameException, ClassNotFoundException { @@ -154,7 +150,7 @@ class EventRequestSpecList { synchronized (eventRequestSpecs) { int inx = eventRequestSpecs.indexOf(proto); if (inx != -1) { - EventRequestSpec spec = (EventRequestSpec)eventRequestSpecs.get(inx); + EventRequestSpec spec = eventRequestSpecs.get(inx); spec.remove(); eventRequestSpecs.remove(inx); return true; diff --git a/src/share/classes/com/sun/tools/example/debug/tty/SourceMapper.java b/src/share/classes/com/sun/tools/example/debug/tty/SourceMapper.java index da8af944890afdbbe78537e756f34d5ff950a73f..618f41a622c28c4a131325513ccca8711e1b964a 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/SourceMapper.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/SourceMapper.java @@ -39,15 +39,13 @@ class SourceMapper { private final String[] dirs; - SourceMapper(List sourcepath) { + SourceMapper(List sourcepath) { /* * sourcepath can arrive from the debugee as a List. * (via PathSearchingVirtualMachine.classPath()) */ List dirList = new ArrayList(); - Iterator iter = sourcepath.iterator(); - while (iter.hasNext()) { - String element = (String)iter.next(); + for (String element : sourcepath) { //XXX remove .jar and .zip files; we want only directories on //the source path. (Bug ID 4186582) if ( ! (element.endsWith(".jar") || @@ -55,7 +53,7 @@ class SourceMapper { dirList.add(element); } } - dirs = (String[])dirList.toArray(new String[0]); + dirs = dirList.toArray(new String[0]); } SourceMapper(String sourcepath) { @@ -79,7 +77,7 @@ class SourceMapper { dirList.add(s); } } - dirs = (String[])dirList.toArray(new String[0]); + dirs = dirList.toArray(new String[0]); } /* diff --git a/src/share/classes/com/sun/tools/example/debug/tty/TTY.java b/src/share/classes/com/sun/tools/example/debug/tty/TTY.java index 620891af757d4001f24bb680b2bf4ce9c21c75ec..ec1dc51c6da8cb97bcd83651f1b32a2ec8e907ac 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/TTY.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/TTY.java @@ -160,9 +160,7 @@ public class TTY implements EventNotifier { // here the next time. Env.setAtExitMethod(null); EventRequestManager erm = Env.vm().eventRequestManager(); - Iterator it = erm.methodExitRequests().iterator(); - while (it.hasNext()) { - EventRequest eReq = (EventRequest)it.next(); + for (EventRequest eReq : erm.methodExitRequests()) { if (eReq.equals(me.request())) { eReq.disable(); } @@ -178,9 +176,8 @@ public class TTY implements EventNotifier { public void vmInterrupted() { Thread.yield(); // fetch output printCurrentLocation(); - Iterator it = monitorCommands.iterator(); - while (it.hasNext()) { - StringTokenizer t = new StringTokenizer((String)it.next()); + for (String cmd : monitorCommands) { + StringTokenizer t = new StringTokenizer(cmd); t.nextToken(); // get rid of monitor number executeCommand(t); } @@ -563,9 +560,8 @@ public class TTY implements EventNotifier { ++monitorCount; monitorCommands.add(monitorCount + ": " + t.nextToken("")); } else { - Iterator it = monitorCommands.iterator(); - while (it.hasNext()) { - MessageOutput.printDirectln((String)it.next());// Special case: use printDirectln() + for (String cmd : monitorCommands) { + MessageOutput.printDirectln(cmd);// Special case: use printDirectln() } } } @@ -581,9 +577,7 @@ public class TTY implements EventNotifier { return; } String monStr = monTok + ":"; - Iterator it = monitorCommands.iterator(); - while (it.hasNext()) { - String cmd = (String)it.next(); + for (String cmd : monitorCommands) { StringTokenizer ct = new StringTokenizer(cmd); if (ct.nextToken().equals(monStr)) { monitorCommands.remove(cmd); @@ -768,10 +762,8 @@ public class TTY implements EventNotifier { } private static boolean supportsSharedMemory() { - List connectors = Bootstrap.virtualMachineManager().allConnectors(); - Iterator iter = connectors.iterator(); - while (iter.hasNext()) { - Connector connector = (Connector)iter.next(); + for (Connector connector : + Bootstrap.virtualMachineManager().allConnectors()) { if (connector.transport() == null) { continue; } diff --git a/src/share/classes/com/sun/tools/example/debug/tty/ThreadGroupIterator.java b/src/share/classes/com/sun/tools/example/debug/tty/ThreadGroupIterator.java index c62a882200376cdc490c7f90f3d7bead662494b4..dc2dc118074379405dc3d850c1957b5ce6c1f13d 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/ThreadGroupIterator.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/ThreadGroupIterator.java @@ -36,7 +36,7 @@ import java.util.Iterator; * Descend the tree of thread groups. * @author Robert G. Field */ -class ThreadGroupIterator implements Iterator { +class ThreadGroupIterator implements Iterator { private final Stack> stack = new Stack>(); ThreadGroupIterator(List tgl) { @@ -53,8 +53,8 @@ class ThreadGroupIterator implements Iterator { this(Env.vm().topLevelThreadGroups()); } - private Iterator top() { - return (Iterator)stack.peek(); + private Iterator top() { + return stack.peek(); } /** @@ -74,12 +74,12 @@ class ThreadGroupIterator implements Iterator { return !stack.isEmpty(); } - public Object next() { + public ThreadGroupReference next() { return nextThreadGroup(); } public ThreadGroupReference nextThreadGroup() { - ThreadGroupReference tg = (ThreadGroupReference)top().next(); + ThreadGroupReference tg = top().next(); push(tg.threadGroups()); return tg; } diff --git a/src/share/classes/com/sun/tools/example/debug/tty/ThreadInfo.java b/src/share/classes/com/sun/tools/example/debug/tty/ThreadInfo.java index 97c6a88082818c2cf86916c30b3a658a2de84623..e823821c04c47c78540df44ed3e5ff4ae7760794 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/ThreadInfo.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/ThreadInfo.java @@ -56,9 +56,7 @@ class ThreadInfo { private static void initThreads() { if (!gotInitialThreads) { - Iterator iter = Env.vm().allThreads().iterator(); - while (iter.hasNext()) { - ThreadReference thread = (ThreadReference)iter.next(); + for (ThreadReference thread : Env.vm().allThreads()) { threads.add(new ThreadInfo(thread)); } gotInitialThreads = true; @@ -113,9 +111,7 @@ class ThreadInfo { current = null; group = null; synchronized (threads) { - Iterator iter = threads().iterator(); - while (iter.hasNext()) { - ThreadInfo ti = (ThreadInfo)iter.next(); + for (ThreadInfo ti : threads()) { ti.invalidate(); } } @@ -163,8 +159,7 @@ class ThreadInfo { if (group == null) { // Current thread group defaults to the first top level // thread group. - setThreadGroup((ThreadGroupReference) - Env.vm().topLevelThreadGroups().get(0)); + setThreadGroup(Env.vm().topLevelThreadGroups().get(0)); } return group; } @@ -173,9 +168,7 @@ class ThreadInfo { ThreadInfo retInfo = null; synchronized (threads) { - Iterator iter = threads().iterator(); - while (iter.hasNext()) { - ThreadInfo ti = (ThreadInfo)iter.next(); + for (ThreadInfo ti : threads()) { if (ti.thread.uniqueID() == id) { retInfo = ti; break; @@ -208,7 +201,7 @@ class ThreadInfo { * * @return a List of the stack frames. */ - List getStack() throws IncompatibleThreadStateException { + List getStack() throws IncompatibleThreadStateException { return thread.frames(); } diff --git a/src/share/classes/com/sun/tools/example/debug/tty/ThreadIterator.java b/src/share/classes/com/sun/tools/example/debug/tty/ThreadIterator.java index b753cf742a36ff7bcebf08d97cdd41bb5c01fff6..8baff8ebd48cb8065dda4934874746ab4b6ac19d 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/ThreadIterator.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/ThreadIterator.java @@ -30,8 +30,8 @@ import com.sun.jdi.ThreadReference; import java.util.List; import java.util.Iterator; -class ThreadIterator implements Iterator { - Iterator it = null; +class ThreadIterator implements Iterator { + Iterator it = null; ThreadGroupIterator tgi; ThreadIterator(ThreadGroupReference tg) { @@ -56,12 +56,12 @@ class ThreadIterator implements Iterator { return true; } - public Object next() { + public ThreadReference next() { return it.next(); } public ThreadReference nextThread() { - return (ThreadReference)next(); + return next(); } public void remove() { diff --git a/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java b/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java index 6d3c3be20f858991adddd212bde90fad6b908456..7ab34280f899e01a9d620e99fa9ff94ca138637e 100644 --- a/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java +++ b/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java @@ -61,10 +61,8 @@ class VMConnection { } private Connector findConnector(String name) { - List connectors = Bootstrap.virtualMachineManager().allConnectors(); - Iterator iter = connectors.iterator(); - while (iter.hasNext()) { - Connector connector = (Connector)iter.next(); + for (Connector connector : + Bootstrap.virtualMachineManager().allConnectors()) { if (connector.name().equals(name)) { return connector; } @@ -108,7 +106,7 @@ class VMConnection { String value = token.substring(index + 1, token.length() - 1); // Remove comma delimiter - Connector.Argument argument = (Connector.Argument)arguments.get(name); + Connector.Argument argument = arguments.get(name); if (argument == null) { throw new IllegalArgumentException (MessageOutput.format("Argument is not defined for connector:", @@ -195,7 +193,7 @@ class VMConnection { return false; } - Connector.Argument argument = (Connector.Argument)connectorArgs.get(name); + Connector.Argument argument = connectorArgs.get(name); if (argument == null) { return false; } @@ -204,7 +202,7 @@ class VMConnection { } String connectorArg(String name) { - Connector.Argument argument = (Connector.Argument)connectorArgs.get(name); + Connector.Argument argument = connectorArgs.get(name); if (argument == null) { return ""; } diff --git a/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java b/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java index 60c48f1bce4ac8daad25b46a6319b6068f39d5ec..4fc235f7e2a036979e496fe1aa6935519645cf5d 100644 --- a/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java +++ b/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java @@ -99,8 +99,7 @@ class ClassQuery extends QueryHandler { } out.println("

Instance Data Members:

"); - JavaField[] ff = clazz.getFields(); - ff = (JavaField[]) ff.clone(); + JavaField[] ff = clazz.getFields().clone(); ArraySorter.sort(ff, new Comparer() { public int compare(Object lhs, Object rhs) { JavaField left = (JavaField) lhs; diff --git a/src/share/classes/com/sun/tools/hat/internal/server/PlatformClasses.java b/src/share/classes/com/sun/tools/hat/internal/server/PlatformClasses.java index 1f6d3bf9d8fe654763d6fd571ba38b0d0fedda29..24db65e2fe730b541abab9d34b0183a71aa3d5c0 100644 --- a/src/share/classes/com/sun/tools/hat/internal/server/PlatformClasses.java +++ b/src/share/classes/com/sun/tools/hat/internal/server/PlatformClasses.java @@ -90,9 +90,7 @@ public class PlatformClasses { // is the right thing to do anyway. } } - int num = list.size(); - names = new String[num]; - names = (String[]) list.toArray(names); + names = list.toArray(new String[list.size()]); } return names; } diff --git a/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java b/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java index 23e9369050d73efd1b3f62f7c3247278419f8a34..48d60f9d8b9cf9b65abdbc75653a0d536f4c5a6c 100644 --- a/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java +++ b/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java @@ -119,7 +119,7 @@ abstract class AbstractLauncher extends ConnectorImpl implements LaunchingConnec String[] tokenArray = new String[tokenList.size()]; for (int i = 0; i < tokenList.size(); i++) { - tokenArray[i] = (String)tokenList.get(i); + tokenArray[i] = tokenList.get(i); } return tokenArray; } diff --git a/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java b/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java index fbb613b119aaaef6e4dc77a39c4d689c7b8d26f9..3e68aa727467b247241ae79bb8c07dffcd72e852 100644 --- a/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java @@ -95,11 +95,8 @@ public class ClassTypeImpl extends ReferenceTypeImpl } public List subclasses() { - List all = vm.allClasses(); List subs = new ArrayList(); - Iterator iter = all.iterator(); - while (iter.hasNext()) { - ReferenceType refType = (ReferenceType)iter.next(); + for (ReferenceType refType : vm.allClasses()) { if (refType instanceof ClassType) { ClassType clazz = (ClassType)refType; ClassType superclass = clazz.superclass(); @@ -223,7 +220,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl List arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); - ValueImpl[] args = (ValueImpl[])arguments.toArray(new ValueImpl[0]); + ValueImpl[] args = arguments.toArray(new ValueImpl[0]); JDWP.ClassType.InvokeMethod ret; try { PacketStream stream = @@ -271,7 +268,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl List arguments = method.validateAndPrepareArgumentsForInvoke( origArguments); - ValueImpl[] args = (ValueImpl[])arguments.toArray(new ValueImpl[0]); + ValueImpl[] args = arguments.toArray(new ValueImpl[0]); JDWP.ClassType.NewInstance ret = null; try { PacketStream stream = @@ -301,11 +298,8 @@ public class ClassTypeImpl extends ReferenceTypeImpl } public Method concreteMethodByName(String name, String signature) { - List methods = visibleMethods(); Method method = null; - Iterator iter = methods.iterator(); - while (iter.hasNext()) { - Method candidate = (Method)iter.next(); + for (Method candidate : visibleMethods()) { if (candidate.name().equals(name) && candidate.signature().equals(signature) && !candidate.isAbstract()) { @@ -330,9 +324,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl * Avoid duplicate checking on each method by iterating through * duplicate-free allInterfaces() rather than recursing */ - Iterator iter = allInterfaces().iterator(); - while (iter.hasNext()) { - InterfaceType interfaze = (InterfaceType)iter.next(); + for (InterfaceType interfaze : allInterfaces()) { list.addAll(interfaze.methods()); } diff --git a/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java b/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java index b5d52e6c3e8f094bd13bd5624d323ebcf4bb3b96..6e44338cdfd7537922d6a5e0e15159e1ae2c22df 100644 --- a/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java @@ -247,7 +247,7 @@ public class ConcreteMethodImpl extends MethodImpl { public byte[] bytecodes() { byte[] bytecodes = (bytecodesRef == null) ? null : - (byte[])bytecodesRef.get(); + bytecodesRef.get(); if (bytecodes == null) { try { bytecodes = JDWP.Method.Bytecodes. @@ -262,7 +262,7 @@ public class ConcreteMethodImpl extends MethodImpl { * to return the cached bytecodes directly; instead, we * make a clone at the cost of using more memory. */ - return (byte[])bytecodes.clone(); + return bytecodes.clone(); } int argSlotCount() throws AbsentInformationException { @@ -279,7 +279,7 @@ public class ConcreteMethodImpl extends MethodImpl { String stratumID = stratum.id(); SoftLocationXRefs info = (softOtherLocationXRefsRef == null) ? null : - (SoftLocationXRefs)softOtherLocationXRefsRef.get(); + softOtherLocationXRefsRef.get(); if (info != null && info.stratumID.equals(stratumID)) { return info; } @@ -348,7 +348,7 @@ public class ConcreteMethodImpl extends MethodImpl { private SoftLocationXRefs getBaseLocations() { SoftLocationXRefs info = (softBaseLocationXRefsRef == null) ? null : - (SoftLocationXRefs)softBaseLocationXRefsRef.get(); + softBaseLocationXRefsRef.get(); if (info != null) { return info; } diff --git a/src/share/classes/com/sun/tools/jdi/EventSetImpl.java b/src/share/classes/com/sun/tools/jdi/EventSetImpl.java index da96ad494ce04474c3a1c86b160e1cdb76e14aac..1a2c61c7bc94866110c10330f789f3c2e5fd455b 100644 --- a/src/share/classes/com/sun/tools/jdi/EventSetImpl.java +++ b/src/share/classes/com/sun/tools/jdi/EventSetImpl.java @@ -56,10 +56,8 @@ public class EventSetImpl extends ArrayList implements EventSet { public String toString() { String string = "event set, policy:" + suspendPolicy + ", count:" + this.size() + " = {"; - Iterator iter = this.iterator(); boolean first = true; - while (iter.hasNext()) { - Event event = (Event)iter.next(); + for (Event event : this) { if (!first) { string += ", "; } @@ -787,9 +785,7 @@ public class EventSetImpl extends ArrayList implements EventSet { } private ThreadReference eventThread() { - Iterator iter = this.iterator(); - while (iter.hasNext()) { - Event event = (Event)iter.next(); + for (Event event : this) { if (event instanceof ThreadedEventImpl) { return ((ThreadedEventImpl)event).thread(); } @@ -846,7 +842,7 @@ public class EventSetImpl extends ArrayList implements EventSet { } public Event nextEvent() { - return (Event)next(); + return next(); } public void remove() { diff --git a/src/share/classes/com/sun/tools/jdi/JNITypeParser.java b/src/share/classes/com/sun/tools/jdi/JNITypeParser.java index 6151d5293e2293225f13fcb6da94062a98bed726..6add99fa6eb9030d01fddedfa01248b44a8c414d 100644 --- a/src/share/classes/com/sun/tools/jdi/JNITypeParser.java +++ b/src/share/classes/com/sun/tools/jdi/JNITypeParser.java @@ -82,7 +82,7 @@ public class JNITypeParser { } String typeName() { - return (String)typeNameList().get(typeNameList().size()-1); + return typeNameList().get(typeNameList().size()-1); } List argumentTypeNames() { @@ -90,7 +90,7 @@ public class JNITypeParser { } String signature() { - return (String)signatureList().get(signatureList().size()-1); + return signatureList().get(signatureList().size()-1); } List argumentSignatures() { diff --git a/src/share/classes/com/sun/tools/jdi/MethodImpl.java b/src/share/classes/com/sun/tools/jdi/MethodImpl.java index 396649355212d4f85877a1f1ccd265c93297bbab..4ad9da94882fcde2a8924b2bff38f394e9b28ff8 100644 --- a/src/share/classes/com/sun/tools/jdi/MethodImpl.java +++ b/src/share/classes/com/sun/tools/jdi/MethodImpl.java @@ -158,7 +158,7 @@ public abstract class MethodImpl extends TypeComponentImpl Type argumentType(int index) throws ClassNotLoadedException { ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType(); - String signature = (String)argumentSignatures().get(index); + String signature = argumentSignatures().get(index); return enclosing.findType(signature); } @@ -263,10 +263,10 @@ public abstract class MethodImpl extends TypeComponentImpl return argumentType(index); } public String typeName(){ - return (String)argumentTypeNames().get(index); + return argumentTypeNames().get(index); } public String signature() { - return (String)argumentSignatures().get(index); + return argumentSignatures().get(index); } public Type findType(String signature) throws ClassNotLoadedException { return MethodImpl.this.findType(signature); @@ -307,7 +307,7 @@ public abstract class MethodImpl extends TypeComponentImpl arguments.add(argArray); return; } - Value nthArgValue = (Value)arguments.get(paramCount - 1); + Value nthArgValue = arguments.get(paramCount - 1); if (nthArgValue == null) { return; } @@ -371,7 +371,7 @@ public abstract class MethodImpl extends TypeComponentImpl } for (int i = 0; i < argSize; i++) { - Value value = (Value)arguments.get(i); + Value value = arguments.get(i); value = ValueImpl.prepareForAssignment(value, new ArgumentContainer(i)); arguments.set(i, value); @@ -386,11 +386,11 @@ public abstract class MethodImpl extends TypeComponentImpl sb.append(name()); sb.append("("); boolean first = true; - for (Iterator it = argumentTypeNames().iterator(); it.hasNext();) { + for (String name : argumentTypeNames()) { if (!first) { sb.append(", "); } - sb.append((String)it.next()); + sb.append(name); first = false; } sb.append(")"); diff --git a/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java index 82aed8e96bee90785afd1ee2ce3fbc5ca95ce2e4..79f84cdb2b4cad567ed0b9ccf8dce761d6fed303 100644 --- a/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java @@ -383,7 +383,7 @@ public class ObjectReferenceImpl extends ValueImpl List arguments = method.validateAndPrepareArgumentsForInvoke( origArguments); - ValueImpl[] args = (ValueImpl[])arguments.toArray(new ValueImpl[0]); + ValueImpl[] args = arguments.toArray(new ValueImpl[0]); JDWP.ObjectReference.InvokeMethod ret; try { PacketStream stream = @@ -583,7 +583,7 @@ public class ObjectReferenceImpl extends ValueImpl // Validate assignment ReferenceType destType = (ReferenceTypeImpl)destination.type(); ReferenceTypeImpl myType = (ReferenceTypeImpl)referenceType(); - if (!myType.isAssignableTo((ReferenceType)destType)) { + if (!myType.isAssignableTo(destType)) { JNITypeParser parser = new JNITypeParser(destType.signature()); String destTypeName = parser.typeName(); throw new InvalidTypeException("Can't assign " + diff --git a/src/share/classes/com/sun/tools/jdi/PacketStream.java b/src/share/classes/com/sun/tools/jdi/PacketStream.java index 5ad2fd1b451b2bcda342d13e7010b98b00058502..65db8b31740bef3bdf9d45bd289ab1289cf90e23 100644 --- a/src/share/classes/com/sun/tools/jdi/PacketStream.java +++ b/src/share/classes/com/sun/tools/jdi/PacketStream.java @@ -485,7 +485,7 @@ class PacketStream { * Read field represented as vm specific byte sequence. */ Field readField() { - ReferenceTypeImpl refType = (ReferenceTypeImpl)readReferenceType(); + ReferenceTypeImpl refType = readReferenceType(); long fieldRef = readFieldRef(); return refType.getFieldMirror(fieldRef); } diff --git a/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java b/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java index 4af0e8e8a45939900bf4fc15747a7f2cb504dcca..f66c202f74439c6eebe828d38d447c1d0cb776e3 100644 --- a/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java @@ -59,7 +59,7 @@ implements ReferenceType { private boolean constantPoolInfoGotten = false; private int constanPoolCount; private byte[] constantPoolBytes; - private SoftReference constantPoolBytesRef = null; + private SoftReference constantPoolBytesRef = null; /* to mark a SourceFile request that returned a genuine JDWP.Error.ABSENT_INFORMATION */ private static final String ABSENT_BASE_SOURCE_NAME = "**ABSENT_BASE_SOURCE_NAME**"; @@ -352,13 +352,10 @@ implements ReferenceType { abstract List inheritedTypes(); void addVisibleFields(List visibleList, Map visibleTable, List ambiguousNames) { - List list = visibleFields(); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - Field field = (Field)iter.next(); + for (Field field : visibleFields()) { String name = field.name(); if (!ambiguousNames.contains(name)) { - Field duplicate = (Field)visibleTable.get(name); + Field duplicate = visibleTable.get(name); if (duplicate == null) { visibleList.add(field); visibleTable.put(name, field); @@ -402,10 +399,8 @@ implements ReferenceType { * hide. */ List retList = new ArrayList(fields()); - iter = retList.iterator(); - while (iter.hasNext()) { - Field field = (Field)iter.next(); - Field hidden = (Field)visibleTable.get(field.name()); + for (Field field : retList) { + Field hidden = visibleTable.get(field.name()); if (hidden != null) { visibleList.remove(hidden); } @@ -515,12 +510,9 @@ implements ReferenceType { * methods. */ void addToMethodMap(Map methodMap, List methodList) { - Iterator iter = methodList.iterator(); - while (iter.hasNext()) { - Method method = (Method)iter.next(); + for (Method method : methodList) methodMap.put(method.name().concat(method.signature()), method); } - } abstract void addVisibleMethods(Map methodMap); @@ -549,9 +541,7 @@ implements ReferenceType { public List methodsByName(String name) { List methods = visibleMethods(); ArrayList retList = new ArrayList(methods.size()); - Iterator iter = methods.iterator(); - while (iter.hasNext()) { - Method candidate = (Method)iter.next(); + for (Method candidate : methods) { if (candidate.name().equals(name)) { retList.add(candidate); } @@ -563,9 +553,7 @@ implements ReferenceType { public List methodsByName(String name, String signature) { List methods = visibleMethods(); ArrayList retList = new ArrayList(methods.size()); - Iterator iter = methods.iterator(); - while (iter.hasNext()) { - Method candidate = (Method)iter.next(); + for (Method candidate : methods) { if (candidate.name().equals(name) && candidate.signature().equals(signature)) { retList.add(candidate); @@ -706,7 +694,7 @@ implements ReferenceType { } public String sourceName() throws AbsentInformationException { - return (String)(sourceNames(vm.getDefaultStratum()).get(0)); + return sourceNames(vm.getDefaultStratum()).get(0); } public List sourceNames(String stratumID) @@ -796,7 +784,7 @@ implements ReferenceType { if (!vm.canGetSourceDebugExtension()) { return NO_SDE_INFO_MARK; } - SDE sde = (sdeRef == null) ? null : (SDE)sdeRef.get(); + SDE sde = (sdeRef == null) ? null : sdeRef.get(); if (sde == null) { String extension = null; try { @@ -1034,13 +1022,13 @@ implements ReferenceType { throw exc; } if (constantPoolBytesRef != null) { - byte[] cpbytes = (byte[])constantPoolBytesRef.get(); + byte[] cpbytes = constantPoolBytesRef.get(); /* * Arrays are always modifiable, so it is a little unsafe * to return the cached bytecodes directly; instead, we * make a clone at the cost of using more memory. */ - return (byte[])cpbytes.clone(); + return cpbytes.clone(); } else { return null; } diff --git a/src/share/classes/com/sun/tools/jdi/SDE.java b/src/share/classes/com/sun/tools/jdi/SDE.java index dd054c1ba0c275e53cf20218721da3f82ff319ee..6f46c81f81195a5d2b463baabb17b713973c5753 100644 --- a/src/share/classes/com/sun/tools/jdi/SDE.java +++ b/src/share/classes/com/sun/tools/jdi/SDE.java @@ -327,7 +327,7 @@ class SDE { ignoreWhite(); while (((ch = sdeRead()) != '\n') && (ch != '\r')) { - sb.append((char)ch); + sb.append(ch); } // check for CR LF if ((ch == '\r') && (sdePeek() == '\n')) { diff --git a/src/share/classes/com/sun/tools/jdi/StackFrameImpl.java b/src/share/classes/com/sun/tools/jdi/StackFrameImpl.java index 5cfd2cbc9011a6611765ac037fe0c255038aac16..a6f867379a0614f0ef1ee794aa775cf948390b94 100644 --- a/src/share/classes/com/sun/tools/jdi/StackFrameImpl.java +++ b/src/share/classes/com/sun/tools/jdi/StackFrameImpl.java @@ -162,7 +162,7 @@ public class StackFrameImpl extends MirrorImpl for (LocalVariable variable : allVariables) { String name = variable.name(); if (variable.isVisible(this)) { - LocalVariable existing = (LocalVariable)map.get(name); + LocalVariable existing = map.get(name); if ((existing == null) || ((LocalVariableImpl)variable).hides(existing)) { map.put(name, variable); @@ -330,7 +330,7 @@ public class StackFrameImpl extends MirrorImpl slot = 1; } for (int ii = 0; ii < count; ++ii) { - char sigChar = (char)argSigs.get(ii).charAt(0); + char sigChar = argSigs.get(ii).charAt(0); slots[ii] = new JDWP.StackFrame.GetValues.SlotInfo(slot++,(byte)sigChar); if (sigChar == 'J' || sigChar == 'D') { slot++; diff --git a/src/share/classes/com/sun/tools/jdi/TargetVM.java b/src/share/classes/com/sun/tools/jdi/TargetVM.java index 2ff9bb1d1264982663c89884d8e15f1dec0e85a9..54ae6af0de4a617f3fbe98c992cee69f87812e31 100644 --- a/src/share/classes/com/sun/tools/jdi/TargetVM.java +++ b/src/share/classes/com/sun/tools/jdi/TargetVM.java @@ -148,7 +148,7 @@ public class TargetVM implements Runnable { idString = String.valueOf(p.id); synchronized(waitingQueue) { - p2 = (Packet)waitingQueue.get(idString); + p2 = waitingQueue.get(idString); if (p2 != null) waitingQueue.remove(idString); diff --git a/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java index 4e1286ba2e4a515b05d4e1c64dc6a225826cdf46..8dac1f3a3307bca5c13cae013300517584e939b2 100644 --- a/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java @@ -86,30 +86,22 @@ public class ThreadGroupReferenceImpl extends ObjectReferenceImpl } public void suspend() { - List threads = threads(); - Iterator iter = threads.iterator(); - while (iter.hasNext()) { - ((ThreadReference)iter.next()).suspend(); + for (ThreadReference thread : threads()) { + thread.suspend(); } - List groups = threadGroups(); - iter = groups.iterator(); - while (iter.hasNext()) { - ((ThreadGroupReference)iter.next()).suspend(); + for (ThreadGroupReference threadGroup : threadGroups()) { + threadGroup.suspend(); } } public void resume() { - List threads = threads(); - Iterator iter = threads.iterator(); - while (iter.hasNext()) { - ((ThreadReference)iter.next()).resume(); + for (ThreadReference thread : threads()) { + thread.resume(); } - List groups = threadGroups(); - iter = groups.iterator(); - while (iter.hasNext()) { - ((ThreadGroupReference)iter.next()).resume(); + for (ThreadGroupReference threadGroup : threadGroups()) { + threadGroup.resume(); } } diff --git a/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java b/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java index 54cb8974b72753f51c5182f49222558f1467d5dc..e6dd311e15253cd299d903c99c3c9b8084099c43 100644 --- a/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java +++ b/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java @@ -1191,8 +1191,7 @@ class VirtualMachineImpl extends MirrorImpl } requests = new JDWP.VirtualMachine.DisposeObjects.Request[size]; for (int i = 0; i < requests.length; i++) { - SoftObjectReference ref = - (SoftObjectReference)batchedDisposeRequests.get(i); + SoftObjectReference ref = batchedDisposeRequests.get(i); if ((traceFlags & TRACE_OBJREFS) != 0) { printTrace("Disposing object " + ref.key().longValue() + " (ref count = " + ref.count() + ")"); @@ -1436,7 +1435,7 @@ class VirtualMachineImpl extends MirrorImpl } ObjectReferenceImpl object() { - return (ObjectReferenceImpl)get(); + return get(); } } } diff --git a/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java b/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java index 97131841074edbe40448c8ddbb54821ea3ce3768..2efcdd65154c53575813ebd858dda51beb545fbe 100644 --- a/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java +++ b/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java @@ -92,7 +92,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManagerService { Connector connector; try { - connector = (Connector)connectors.next(); + connector = connectors.next(); } catch (ThreadDeath x) { throw x; } catch (Exception x) { @@ -121,7 +121,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManagerService { TransportService transportService; try { - transportService = (TransportService)transportServices.next(); + transportService = transportServices.next(); } catch (ThreadDeath x) { throw x; } catch (Exception x) { diff --git a/src/share/classes/com/sun/tracing/Probe.java b/src/share/classes/com/sun/tracing/Probe.java new file mode 100644 index 0000000000000000000000000000000000000000..6eca3aec930de640576d12f596014e3a70d4103b --- /dev/null +++ b/src/share/classes/com/sun/tracing/Probe.java @@ -0,0 +1,51 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing; + +/** + * The {@code Probe} interface represents a tracepoint. + * + * A {@code Probe} instance is obtained by calling the + * {@code Provider.getProbe()} method of a provider instance created by + * {@code ProviderFactory.createProvider()}. A {@code Probe} can be used to + * trigger a probe manually (provided the correct arguments are passed to + * it), or to check a probe to see if anything is currently tracing it. + *

+ * A tracing check can be used to avoid lengthy work that might be + * needed to set up the probe's arguments. However, checking + * whether the probe is enabled generally takes the same amount of time + * as actually triggering the probe. So, you should only check a probe's status + * without triggering it if setting up the arguments is very expensive. + *

+ * Users do not need to implement this interface: instances are + * created automatically by the system when a {@code Provider)} instance is + * created. + *

+ * @since 1.7 + */ + +public interface Probe { + /** + * Checks whether there is an active trace of this probe. + * + * @return true if an active trace is detected. + */ + boolean isEnabled(); + + /** + * Determines whether a tracepoint is enabled. + * + * Typically, users do not need to use this method. It is called + * automatically when a Provider's instance method is called. Calls to + * this method expect the arguments to match the declared parameters for + * the method associated with the probe. + * + * @param args the parameters to pass to the method. + * @throws IllegalArgumentException if the provided parameters do not + * match the method declaration for this probe. + */ + void trigger(Object ... args); +} diff --git a/src/share/classes/com/sun/tracing/ProbeName.java b/src/share/classes/com/sun/tracing/ProbeName.java new file mode 100644 index 0000000000000000000000000000000000000000..ecda19a7ea330359f9810beca01c550bd7156592 --- /dev/null +++ b/src/share/classes/com/sun/tracing/ProbeName.java @@ -0,0 +1,28 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + +/** + * An annotation used to override the name of a probe. + *

+ * This annotation can be added to a method in a user-defined {@code Provider} + * interface, to set the name that will be used for the generated probe + * associated with that method. Without this annotation, the name will be the + * name of the method. + *

+ * @since 1.7 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface ProbeName { + String value(); +} + diff --git a/src/share/classes/com/sun/tracing/Provider.java b/src/share/classes/com/sun/tracing/Provider.java new file mode 100644 index 0000000000000000000000000000000000000000..95264f0e4181d7567af087713f68c6df605148d9 --- /dev/null +++ b/src/share/classes/com/sun/tracing/Provider.java @@ -0,0 +1,56 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing; + +/** + * {@code Provider} is a superinterface for user-defined tracing providers. + *

+ * To define tracepoints, users must extend this interface + * and then use a {@code ProviderFactory} to create an instance of the + * newly-defined interface. Each method in the defined interface represents a + * tracepoint (or probe), which can be triggered by calling the associated + * method on the returned instance. + *

+ * This interface also contains a {@code getProbe()} method, which can be + * used to get direct handles to the {@code Probe} objects themselves. + * {@code Probe} objects can be triggered manually, or they can be queried to + * check their state. + *

+ * When an application has finished triggering probes, it should call + * {@code dispose()} to free up any system resources associated with the + * Provider. + *

+ * All methods declared in a subclass of this interface should have a + * {@code void} return type. Methods can have parameters, and when called the + * values of the arguments will be passed to the tracing implementation. + * If any methods do not have a {@code void} return type, an + * {@code java.lang.IllegalArgumentException} will be thrown when the + * provider is registered. + * @since 1.7 + */ + +public interface Provider { + /** + * Retrieves a reference to a Probe object, which is used to check status + * or to trigger the probe manually. + * + * If the provided method parameter is not a method of the provider + * interface, or if the provider interface has been disposed, then + * this returns null + * + * @param method a method declared in the provider. + * @return the specified probe represented by that method, or null. + */ + Probe getProbe(java.lang.reflect.Method method); + + /** + * Disposes system resources associated with this provider. + * + * After calling this method, triggering the probes will have no effect. + * Additional calls to this method after the first call are ignored. + */ + void dispose(); +} diff --git a/src/share/classes/com/sun/tracing/ProviderFactory.java b/src/share/classes/com/sun/tracing/ProviderFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..768a6bebb8df931f8aa34da6463f5c3336c8ea30 --- /dev/null +++ b/src/share/classes/com/sun/tracing/ProviderFactory.java @@ -0,0 +1,110 @@ + +package com.sun.tracing; + +import java.util.HashSet; +import java.io.PrintStream; +import java.lang.reflect.Field; +import java.util.logging.Logger; + +import sun.tracing.NullProviderFactory; +import sun.tracing.PrintStreamProviderFactory; +import sun.tracing.MultiplexProviderFactory; +import sun.tracing.dtrace.DTraceProviderFactory; + +/** + * {@code ProviderFactory} is a factory class used to create instances of + * providers. + * + * To enable tracing in an application, this class must be used to create + * instances of the provider interfaces defined by users. + * The system-defined factory is obtained by using the + * {@code getDefaultFactory()} static method. The resulting instance can be + * used to create any number of providers. + * + * @since 1.7 + */ +public abstract class ProviderFactory { + + protected ProviderFactory() {} + + /** + * Creates an implementation of a Provider interface. + * + * @param cls the provider interface to be defined. + * @return an implementation of {@code cls}, whose methods, when called, + * will trigger tracepoints in the application. + * @throws NullPointerException if cls is null + * @throws IllegalArgumentException if the class definition contains + * non-void methods + */ + public abstract T createProvider(Class cls); + + /** + * Returns an implementation of a {@code ProviderFactory} which + * creates instances of Providers. + * + * The created Provider instances will be linked to all appropriate + * and enabled system-defined tracing mechanisms in the JDK. + * + * @return a {@code ProviderFactory} that is used to create Providers. + */ + public static ProviderFactory getDefaultFactory() { + HashSet factories = new HashSet(); + + // Try to instantiate a DTraceProviderFactory + String prop = null; + try { prop = System.getProperty("com.sun.tracing.dtrace"); } + catch (java.security.AccessControlException e) { + Logger.getAnonymousLogger().fine( + "Cannot access property com.sun.tracing.dtrace"); + } + if ( (prop == null || !prop.equals("disable")) && + DTraceProviderFactory.isSupported() ) { + factories.add(new DTraceProviderFactory()); + } + + // Try to instantiate an output stream factory + try { prop = System.getProperty("sun.tracing.stream"); } + catch (java.security.AccessControlException e) { + Logger.getAnonymousLogger().fine( + "Cannot access property sun.tracing.stream"); + } + if (prop != null) { + for (String spec : prop.split(",")) { + PrintStream ps = getPrintStreamFromSpec(spec); + if (ps != null) { + factories.add(new PrintStreamProviderFactory(ps)); + } + } + } + + // See how many factories we instantiated, and return an appropriate + // factory that encapsulates that. + if (factories.size() == 0) { + return new NullProviderFactory(); + } else if (factories.size() == 1) { + return factories.toArray(new ProviderFactory[1])[0]; + } else { + return new MultiplexProviderFactory(factories); + } + } + + private static PrintStream getPrintStreamFromSpec(String spec) { + try { + // spec is in the form of ., where is + // a fully specified class name, and is a static member + // in that class. The must be a 'PrintStream' or subtype + // in order to be used. + int fieldpos = spec.lastIndexOf('.'); + Class cls = Class.forName(spec.substring(0, fieldpos)); + Field f = cls.getField(spec.substring(fieldpos + 1)); + Class fieldType = f.getType(); + return (PrintStream)f.get(null); + } catch (Exception e) { + Logger.getAnonymousLogger().warning( + "Could not parse sun.tracing.stream property: " + e); + } + return null; + } +} + diff --git a/src/share/classes/com/sun/tracing/ProviderName.java b/src/share/classes/com/sun/tracing/ProviderName.java new file mode 100644 index 0000000000000000000000000000000000000000..4e63237500dc73cec1fef626ce040ed1bae05ec9 --- /dev/null +++ b/src/share/classes/com/sun/tracing/ProviderName.java @@ -0,0 +1,28 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + +/** + * An annotation used to specify the name of a provider. + *

+ * This annotation can be added to a user-defined {@code Provider} + * interface, to set the name that will be used + * for the provider in the generated probes. Without this annotation, + * the simple class name of the provider interface is used. + *

+ * @since 1.7 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface ProviderName { + String value(); +} + diff --git a/src/share/classes/com/sun/tracing/dtrace/ArgsAttributes.java b/src/share/classes/com/sun/tracing/dtrace/ArgsAttributes.java new file mode 100644 index 0000000000000000000000000000000000000000..2d915439d65677a0342febf1259989e2acf175b8 --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/ArgsAttributes.java @@ -0,0 +1,33 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing.dtrace; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + + +/** + * This annotation describes the interface attributes of the probe arguments in + * a single provider. + * + * This annotation can be added to a user-defined {@code Provider} specification + * interface to set the stability attributes of the probe arguments, for + * all the probes specified in that provider. + *

+ * If this annotation is not present, the interface attributes for the + * arguments are Private/Private/Unknown. + *

+ * @see Solaris Dynamic Tracing Guide, Chapter 39: Stability + * @since 1.7 + */ + +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE }) +public @interface ArgsAttributes { + Attributes value(); +} diff --git a/src/share/classes/com/sun/tracing/dtrace/Attributes.java b/src/share/classes/com/sun/tracing/dtrace/Attributes.java new file mode 100644 index 0000000000000000000000000000000000000000..52a3a493e1cc376edf6ed2c1d87840ed3396216b --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/Attributes.java @@ -0,0 +1,46 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing.dtrace; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + + +/** + * This annotation describes the interface's field attributes + * for the probes in a provider. + * + * This annotation provides the contents of field-specific annotations + * that specify the stability attributes and dependency class of a + * particular field, for the probes in a provider. + *

+ * The default interface attributes for unspecified fields is + * Private/Private/Unknown. + *

+ * @see Solaris Dynamic Tracing Guide, Chapter 39: Stability + * @since 1.7 + */ + +@Retention(RetentionPolicy.RUNTIME) +@Target({}) +public @interface Attributes { + /** + * The stability level of the name. + */ + StabilityLevel name() default StabilityLevel.PRIVATE; + + /** + * The stability level of the data. + */ + StabilityLevel data() default StabilityLevel.PRIVATE; + + /** + * The interface attribute's dependency class. + */ + DependencyClass dependency() default DependencyClass.UNKNOWN; +} diff --git a/src/share/classes/com/sun/tracing/dtrace/DependencyClass.java b/src/share/classes/com/sun/tracing/dtrace/DependencyClass.java new file mode 100644 index 0000000000000000000000000000000000000000..e60494555a8d3ef16cf31baeacd586bab308bd2e --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/DependencyClass.java @@ -0,0 +1,57 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing.dtrace; + +/** + * Enumeration for the DTrace dependency classes. + * + * @see Solaris Dynamic Tracing Guide for details, Chapter 39: Stability + * @since 1.7 + */ +public enum DependencyClass { + /** + * The interface has an unknown set of architectural dependencies. + */ + UNKNOWN (0), + /** + * The interface is specific to the CPU model of the current system. + */ + CPU (1), + /** + * The interface is specific to the hardware platform of the current + * system. + */ + PLATFORM (2), + /** + * The interface is specific to the hardware platform group of the + * current system. + */ + GROUP (3), + /** + * The interface is specific to the instruction set architecture (ISA) + * supported by the microprocessors on this system. + */ + ISA (4), + /** + * The interface is common to all Solaris systems regardless of the + * underlying hardware. + */ + COMMON (5); + + public String toDisplayString() { + return toString().substring(0,1) + + toString().substring(1).toLowerCase(); + } + + public int getEncoding() { return encoding; } + + private int encoding; + + private DependencyClass(int encoding) { + this.encoding = encoding; + } +} + diff --git a/src/share/classes/com/sun/tracing/dtrace/FunctionAttributes.java b/src/share/classes/com/sun/tracing/dtrace/FunctionAttributes.java new file mode 100644 index 0000000000000000000000000000000000000000..ed28f3859c37cfb8b2cf390db11f3273e7cc8d72 --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/FunctionAttributes.java @@ -0,0 +1,31 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing.dtrace; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + +/** + * This annotation describes the interface attributes of the + * {@code function} field for a single provider. + * + * This annotation can be added to a user-defined {@code Provider} specification + * interface to set the stability attributes of the {@code function} field for + * all probes specified in that provider. + *

+ * If this annotation is not present, the interface attributes for the + * {@code function} field are Private/Private/Unknown. + *

+ * @see Solaris Dynamic Tracing Guide, Chapter 39: Stability + * @since 1.7 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE }) +public @interface FunctionAttributes { + Attributes value(); +} diff --git a/src/share/classes/com/sun/tracing/dtrace/FunctionName.java b/src/share/classes/com/sun/tracing/dtrace/FunctionName.java new file mode 100644 index 0000000000000000000000000000000000000000..2c1b18c847dc8de8e5e358fd6473cecbdcadcfeb --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/FunctionName.java @@ -0,0 +1,27 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing.dtrace; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + +/** + * An annotation used to specify the {@code function} field for a DTrace probe. + * + * This annotation can be added to a method in a user-defined Provider + * specification interface to set the {@code function} field that is used + * for the generated DTrace probe associated with that method. + *

+ * @since 1.7 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface FunctionName { + String value(); +} + diff --git a/src/share/classes/com/sun/tracing/dtrace/ModuleAttributes.java b/src/share/classes/com/sun/tracing/dtrace/ModuleAttributes.java new file mode 100644 index 0000000000000000000000000000000000000000..429f8bb726c076a345af8ecdd4050018b94aae50 --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/ModuleAttributes.java @@ -0,0 +1,31 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing.dtrace; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + +/** + * This annotation is used to describe the interface attributes of the + * {@code module} field for a single provider. + * + * This annotation can be added to a user-defined Provider specification + * interface to set the stability attributes of the {@code module} field for + * all probes specified in that provider. + *

+ * If this annotation is not present, the interface attributes for the + * {@code module} field is Private/Private/Unknown. + *

+ * @see Solaris Dynamic Tracing Guide, Chapter 39: Stability + * @since 1.7 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE }) +public @interface ModuleAttributes { + Attributes value(); +} diff --git a/src/share/classes/com/sun/tracing/dtrace/ModuleName.java b/src/share/classes/com/sun/tracing/dtrace/ModuleName.java new file mode 100644 index 0000000000000000000000000000000000000000..4aa64044fc61b74bbbdf55844f92cb6e19b5f8a8 --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/ModuleName.java @@ -0,0 +1,27 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing.dtrace; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + +/** + * An annotation used to specify the {@code module} field for a DTrace probe. + * + * This annotation can be added to a method in a user-defined Provider + * specification interface to set the {@code module} field that will be used + * for the generated DTrace probe associated with that method. + *

+ * @since 1.7 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface ModuleName { + String value(); +} + diff --git a/src/share/classes/com/sun/tracing/dtrace/NameAttributes.java b/src/share/classes/com/sun/tracing/dtrace/NameAttributes.java new file mode 100644 index 0000000000000000000000000000000000000000..2730851e8bb8d0541adddb0f636e04948776ea83 --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/NameAttributes.java @@ -0,0 +1,31 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing.dtrace; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + +/** + * This annotation describes the interface attributes of the + * {@code name} field for a single provider. + * + * This annotation can be added to a user-defined Provider specification + * interface to set the stability attributes of the {@code name} field for + * all probes specified in that provider. + *

+ * If this annotation is not present, the interface attributes for the + * {@code name} field will be Private/Private/Unknown. + *

+ * @see Solaris Dynamic Tracing Guide, Chapter 39: Stability + * @since 1.7 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE }) +public @interface NameAttributes { + Attributes value(); +} diff --git a/src/share/classes/com/sun/tracing/dtrace/ProviderAttributes.java b/src/share/classes/com/sun/tracing/dtrace/ProviderAttributes.java new file mode 100644 index 0000000000000000000000000000000000000000..f16ff5f11c972dc6f562ac4f4fa0531d76a6a8f6 --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/ProviderAttributes.java @@ -0,0 +1,31 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing.dtrace; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + +/** + * This annotation is used to describe the interface attributes of the + * {@code provider} field for a single provider. + * + * This annotation can be added to a user-defined Provider specification + * interface to set the stability attributes of the {@code provider} field for + * all probes specified in that provider. + *

+ * If this annotation is not present, the interface attributes for the + * {@code provider} field will be Private/Private/Unknown. + *

+ * @see Solaris Dynamic Tracing Guide, Chapter 39: Stability + * @since 1.7 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE }) +public @interface ProviderAttributes { + Attributes value(); +} diff --git a/src/share/classes/com/sun/tracing/dtrace/StabilityLevel.java b/src/share/classes/com/sun/tracing/dtrace/StabilityLevel.java new file mode 100644 index 0000000000000000000000000000000000000000..d06ba0935149817624b31ba6a067047bb8f6464d --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/StabilityLevel.java @@ -0,0 +1,68 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tracing.dtrace; + +/** + * Enumeration for the DTrace stability levels. + * + * @see Solaris Dynamic Tracing Guide, Chapter 39: Stability + * @since 1.7 + */ +public enum StabilityLevel { + /** + * The interface is private to DTrace and represents an implementation + * detail of DTrace. + */ + INTERNAL (0), + /** + * The interface is private to Sun for use by other Sun products. It is + * not yet publicly documented for use by customers and ISVs. + */ + PRIVATE (1), + /** + * The interface is supported in the current release but is scheduled + * to be removed, most likely in a future minor release. + */ + OBSOLETE (2), + /** + * The interface is controlled by an entity other than Sun. + */ + EXTERNAL (3), + /** + * The interface gives developers early access to new or + * rapidly changing technology or to an implementation artifact that is + * essential for observing or debugging system behavior. A more + * stable solution is anticipated in the future. + */ + UNSTABLE (4), + /** + * The interface might eventually become Standard or Stable but is + * still in transition. + */ + EVOLVING (5), + /** + * The interface is a mature interface under Sun's control. + */ + STABLE (6), + /** + * The interface complies with an industry standard. + */ + STANDARD (7); + + String toDisplayString() { + return toString().substring(0,1) + + toString().substring(1).toLowerCase(); + } + + public int getEncoding() { return encoding; } + + private int encoding; + + private StabilityLevel(int encoding) { + this.encoding = encoding; + } +} + diff --git a/src/share/classes/com/sun/tracing/dtrace/package-info.java b/src/share/classes/com/sun/tracing/dtrace/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..365a048caa8653d3f21da204a428aa7ace16e8c0 --- /dev/null +++ b/src/share/classes/com/sun/tracing/dtrace/package-info.java @@ -0,0 +1,62 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/** + * This package contains annotations and enumerations that are used to + * add DTrace-specific information to a tracing provider. + *

+ * The DTrace-specific annotations modify the attributes of a DTrace provider + * implementation when it is used by the tracing subsystem. The annotations are + * added to a {@code com.sun.tracing} provider specification to control + * specific attributes of the provider as it relates to DTrace. + *

+ * Any other tracing subsystems supported by the system will ignore these + * annotations. + *

+ * DTrace probes have additional fields and stability attributes that are + * not accounted for in the generic tracing package. If unspecified, the + * default values are used for the stability and dependency attributes of + * probes, as well as for the module and field names of the generated probes. + * The values can be specified by adding the appropriate annotations to the + * provider specification. + *

+ * The {@code FunctionName} annotation is used to annotate the tracepoint + * methods defined in the provider specification. The value of this annotation + * is used as the {@code function} field in the generated DTrace probes. It + * is typically set to the name of the enclosing function where the + * tracepoint is triggered. + *

+ * The {@code ModuleName} annotation is used to annotate the provider + * specification itself and applies to all the probes in the provider. It + * sets the value of the {@code module} field in the generated DTrace probes. + *

+ * The remaining annotations, are also applied to the provider itself, and + * are used to set the stability and dependency attributes of all probes in + * that provider. Each probe field and the probe arguments can be + * independently assigned interface attributes to control the stability + * ratings of the probes. + *

+ * Here is an example of how to declare a provider, specifying additional DTrace + * data: +

+    @ProviderName("my_app_provider")
+    @ModuleName("app.jar")
+    @ProviderAttributes(@Attributes={
+        name=StabilityLevel.STABLE,data=StabilityLevel.STABLE,
+        dependency=DependencyClass.COMMON})
+    @ProbeAttributes(@Attributes={
+        name=StabilityLevel.STABLE,data=StabilityLevel.STABLE,
+        dependency=DependencyClass.COMMON})
+    @ModuleAttributes(@Attributes={name=StabilityLevel.UNSTABLE})
+    public class MyProvider {
+        @FunctionName("main") void startProbe();
+    }
+
+ *

+ * @see Solaris Dynamic Tracing Guide, Chapter 34: Statically Defined Tracing for User Applications + * @see Solaris Dynamic Tracing Guide, Chapter 39: Stability + */ + +package com.sun.tracing.dtrace; diff --git a/src/share/classes/com/sun/tracing/package-info.java b/src/share/classes/com/sun/tracing/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..56a75f099b093e54fe71a52587043f48cd56a93d --- /dev/null +++ b/src/share/classes/com/sun/tracing/package-info.java @@ -0,0 +1,163 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/** + * This package provides a mechanism for defining and + * inserting tracepoints into Java-technology based applications, which + * can then be monitored by the tracing tools available on the system. + *

+ * To add tracepoints to a program, you must first decide where to place the + * tracepoints, what the logical names are for these points, what information + * will be available to the tracing mechanisms at each point, and decide upon + * any logical grouping. + *

+ * You add instrumentation to a program in three steps: + *

    + *
  • First, declare tracepoints by creating interfaces to define + * them, and include these interfaces in the program definition. + * The declared interfaces are standard Java technology-based + * interfaces and are compiled with the program.
  • + *
  • Second, add code in the application to create an instance of the + * interface at some point during the initialization of the application, + * using a factory class provided by the system. The reference to the + * instance can be stored as a global static, or passed as context to all + * the places where it is needed.
  • + *
  • Finally, add the actual tracepoints to the desired locations in the + * application by inserting a call to one of the methods defined in the + * interface, via the factory-created reference.
  • + *
+ *

+ * The method calls representing the tracepoints have no logical + * impact on the program. The side effect of the call is that any + * activated tracing mechanisms will be notified that the tracepoint has + * been hit, and will take whatever actions are appropriate (for example, + * logging the tracepoint, or triggering a DTrace probe, etc.). In most + * cases, the impact on performance of adding tracepoints to the application + * will be minimal. + *

+ * Each logical grouping of tracepoints should be defined in a common + * interface, called a provider. An application can have one or many + * providers. Each provider is independent and can be created whenever + * it is appropriate for that provider, for example, when a subsytem is + * initialized. Providers should be disposed of when they are no longer + * needed, to free up any associated system resources. Each tracepoint + * in a provider is represented by a method in that interface. These methods + * are referred to as probes. The method signature determines the probe + * parameters. A call to the method with the specified parameters triggers + * the probe and makes its parameter values visible to any associated tracing + * mechanism. + *

+ * User-defined interfaces which represent providers must extend the + * {@code Provider} interface. To activate the system-defined + * tracing mechanisms, you must obtain an instance of the + * {@code ProviderFactory} class, and pass the class of the provider to + * the {@code createProvider()} method. The returned instance is then used to + * trigger the probes later in the application. + *

+ * In addition to triggering the probes, the provider instance can be used + * to obtain direct references to the {@code Probe} objects, which can be used + * directly for triggering, or can be queried to determine whether the probe is + * currently being traced. The {@code Provider} interface also defines a + * {@code Provider.dispose()} method which is used to free up any resources + * that might be associated with that provider. + *

+ * When a probe is triggered, any activated tracing system will be given + * the provider name, the probe name, and the values of the probe arguments. + * The tracing system is free to consume this data is whatever way is + * appropriate. + * By default, the provider name is the same as the class name of the interface + * that defines the provider. Similarly, the probe name is + * the name of the method that defines the probe. These default values + * can be over-ridden by annotations. The provider definition can be + * annotated with the {@code @ProviderName} annotation, whose value will + * indicate the provider name that the tracing system will use. Similarly, + * the {@code @ProbeName} annotation annotates a declared method and + * indicates the probe name that should be used in the place of the + * method name. These annotations can be used to define providers and + * probes with the same name, in cases where the semantics of the Java language + * may prevent this. + *

+ * Here is a very small and simple usage example: + *

+ * +

+   import com.sun.tracing.Provider;
+   import com.sun.tracing.ProviderFactory;
+
+   interface MyProvider extends Provider {
+       void startProbe();
+       void finishProbe(int value);
+   }
+
+   public class MyApplication {
+       public static void main(String argv[]) {
+           ProviderFactory factory = ProviderFactory.getDefaultFactory();
+           MyProvider trace = factory.createProvider(MyProvider.class);
+
+           trace.startProbe();
+           int result = foo();
+           trace.finishProbe(result);
+
+           trace.dispose();
+       }
+   }
+
+ *

+ * The Java Development Kit (JDK) currently only includes one system-defined + * tracing framework: DTrace. DTrace is enabled automatically whenever an + * application is run on a system and a JDK release that supports it. When + * DTrace is enabled, probes are made available for listing and matching by + * DTrace scripts as soon as the provider is created. At the tracepoint, an + * associated DTrace script is informed of the creation of the provider, and + * it takes whatever action it is designed to take. Tracepoints in the + * program have the following DTrace probe names:
+ * {@code :::} + * Where: + *

    + *
  • {@code } the provider name as specified by the application
  • + *
  • {@code } the operating system process ID
  • + *
  • {@code } undefined, unless specified by the application
  • + *
  • {@code } undefined, unless specified by the application
  • + *
  • {@code } the probe name as specified by the application
  • + *
+ *

+ * The {@code com.sun.tracing.dtrace} package contains additional + * annotations that can be used to control the names used for the + * module and function fields, as well as annotations + * that can be added to the provider to control probe stability and dependency + * attributes. + *

+ * Integer, float and string probe parameters are made available to DTrace + * using + * the built-in argument variables, {@code arg0 ... arg_n}. Integer-types + * are passed by value (boxed values are unboxed), floating-point types are + * passed as encoded integer + * arguments, and {@code java.lang.String} objects are converted + * to UTF8 strings, so they can be read into the DTrace script using the + * {@code copyinstr()} intrinsic. Non-string and non-boxed primitive + * reference arguments are only + * placeholders and have no value. + *

+ * Using the example above, with a theoretical process ID of 123, these are + * the probes that can be traced from DTrace: +

+    MyProvider123:::startProbe
+    MyProvider123:::finishProbe
+
+ * When {@code finishProbe} executes, {@code arg0} will contain the + * value of {@code result}. + *

+ * The DTrace tracing mechanism is enabled for all providers, apart from in the + * following circumstances: + *

    + *
  • DTrace is not supported on the underlying system.
  • + *
  • The property {@code com.sun.tracing.dtrace} is set to "disable".
  • + *
  • The RuntimePermission {@code com.sun.tracing.dtrace.createProvider} + * is denied to the process.
  • + *
+ *

+ */ + +package com.sun.tracing; diff --git a/src/share/classes/java/awt/Component.java b/src/share/classes/java/awt/Component.java index 38d50d5d09fec933cfcbdb8dc94b5e7c13801cad..b48b8c552fda95007167dc9903b2712c0bcea485 100644 --- a/src/share/classes/java/awt/Component.java +++ b/src/share/classes/java/awt/Component.java @@ -634,6 +634,11 @@ public abstract class Component implements ImageObserver, MenuContainer, */ private PropertyChangeSupport changeSupport; + private transient final Object changeSupportLock = new Object(); + private Object getChangeSupportLock() { + return changeSupportLock; + } + boolean isPacked = false; /** @@ -935,24 +940,26 @@ public abstract class Component implements ImageObserver, MenuContainer, */ public GraphicsConfiguration getGraphicsConfiguration() { synchronized(getTreeLock()) { - GraphicsConfiguration gc = graphicsConfig; - Component parent = getParent(); - while ((gc == null) && (parent != null)) { - gc = parent.getGraphicsConfiguration(); - parent = parent.getParent(); + if (graphicsConfig != null) { + return graphicsConfig; + } else if (getParent() != null) { + return getParent().getGraphicsConfiguration(); + } else { + return null; } - return gc; } } final GraphicsConfiguration getGraphicsConfiguration_NoClientCode() { - GraphicsConfiguration gc = this.graphicsConfig; - Component par = this.parent; - while ((gc == null) && (par != null)) { - gc = par.getGraphicsConfiguration_NoClientCode(); - par = par.parent; + GraphicsConfiguration graphicsConfig = this.graphicsConfig; + Container parent = this.parent; + if (graphicsConfig != null) { + return graphicsConfig; + } else if (parent != null) { + return parent.getGraphicsConfiguration_NoClientCode(); + } else { + return null; } - return gc; } /** @@ -4602,7 +4609,8 @@ public abstract class Component implements ImageObserver, MenuContainer, e.isPopupTrigger(), e.getScrollType(), e.getScrollAmount(), - e.getWheelRotation()); + e.getWheelRotation(), + e.getPreciseWheelRotation()); ((AWTEvent)e).copyPrivateDataInto(newMWE); // When dispatching a wheel event to // ancestor, there is no need trying to find descendant @@ -6484,7 +6492,7 @@ public abstract class Component implements ImageObserver, MenuContainer, // will need some help. Container parent = this.parent; if (parent != null && parent.peer instanceof LightweightPeer) { - nativeInLightFixer = new NativeInLightFixer(); + relocateComponent(); } } invalidate(); @@ -6595,10 +6603,6 @@ public abstract class Component implements ImageObserver, MenuContainer, } } - if (nativeInLightFixer != null) { - nativeInLightFixer.uninstall(); - } - ComponentPeer p = peer; if (p != null) { boolean isLightweight = isLightweight(); @@ -7836,15 +7840,17 @@ public abstract class Component implements ImageObserver, MenuContainer, * @see #getPropertyChangeListeners * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener) */ - public synchronized void addPropertyChangeListener( + public void addPropertyChangeListener( PropertyChangeListener listener) { - if (listener == null) { - return; - } - if (changeSupport == null) { - changeSupport = new PropertyChangeSupport(this); + synchronized (getChangeSupportLock()) { + if (listener == null) { + return; + } + if (changeSupport == null) { + changeSupport = new PropertyChangeSupport(this); + } + changeSupport.addPropertyChangeListener(listener); } - changeSupport.addPropertyChangeListener(listener); } /** @@ -7860,12 +7866,14 @@ public abstract class Component implements ImageObserver, MenuContainer, * @see #getPropertyChangeListeners * @see #removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener) */ - public synchronized void removePropertyChangeListener( + public void removePropertyChangeListener( PropertyChangeListener listener) { - if (listener == null || changeSupport == null) { - return; + synchronized (getChangeSupportLock()) { + if (listener == null || changeSupport == null) { + return; + } + changeSupport.removePropertyChangeListener(listener); } - changeSupport.removePropertyChangeListener(listener); } /** @@ -7882,11 +7890,13 @@ public abstract class Component implements ImageObserver, MenuContainer, * @see java.beans.PropertyChangeSupport#getPropertyChangeListeners * @since 1.4 */ - public synchronized PropertyChangeListener[] getPropertyChangeListeners() { - if (changeSupport == null) { - return new PropertyChangeListener[0]; + public PropertyChangeListener[] getPropertyChangeListeners() { + synchronized (getChangeSupportLock()) { + if (changeSupport == null) { + return new PropertyChangeListener[0]; + } + return changeSupport.getPropertyChangeListeners(); } - return changeSupport.getPropertyChangeListeners(); } /** @@ -7920,16 +7930,18 @@ public abstract class Component implements ImageObserver, MenuContainer, * @see #getPropertyChangeListeners(java.lang.String) * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener) */ - public synchronized void addPropertyChangeListener( + public void addPropertyChangeListener( String propertyName, PropertyChangeListener listener) { - if (listener == null) { - return; - } - if (changeSupport == null) { - changeSupport = new PropertyChangeSupport(this); + synchronized (getChangeSupportLock()) { + if (listener == null) { + return; + } + if (changeSupport == null) { + changeSupport = new PropertyChangeSupport(this); + } + changeSupport.addPropertyChangeListener(propertyName, listener); } - changeSupport.addPropertyChangeListener(propertyName, listener); } /** @@ -7948,13 +7960,15 @@ public abstract class Component implements ImageObserver, MenuContainer, * @see #getPropertyChangeListeners(java.lang.String) * @see #removePropertyChangeListener(java.beans.PropertyChangeListener) */ - public synchronized void removePropertyChangeListener( + public void removePropertyChangeListener( String propertyName, PropertyChangeListener listener) { - if (listener == null || changeSupport == null) { - return; + synchronized (getChangeSupportLock()) { + if (listener == null || changeSupport == null) { + return; + } + changeSupport.removePropertyChangeListener(propertyName, listener); } - changeSupport.removePropertyChangeListener(propertyName, listener); } /** @@ -7971,12 +7985,14 @@ public abstract class Component implements ImageObserver, MenuContainer, * @see #getPropertyChangeListeners * @since 1.4 */ - public synchronized PropertyChangeListener[] getPropertyChangeListeners( + public PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { - if (changeSupport == null) { - return new PropertyChangeListener[0]; + synchronized (getChangeSupportLock()) { + if (changeSupport == null) { + return new PropertyChangeListener[0]; + } + return changeSupport.getPropertyChangeListeners(propertyName); } - return changeSupport.getPropertyChangeListeners(propertyName); } /** @@ -7991,7 +8007,10 @@ public abstract class Component implements ImageObserver, MenuContainer, */ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - PropertyChangeSupport changeSupport = this.changeSupport; + PropertyChangeSupport changeSupport; + synchronized (getChangeSupportLock()) { + changeSupport = this.changeSupport; + } if (changeSupport == null || (oldValue != null && newValue != null && oldValue.equals(newValue))) { return; @@ -8491,8 +8510,6 @@ public abstract class Component implements ImageObserver, MenuContainer, setComponentOrientation(orientation); } - transient NativeInLightFixer nativeInLightFixer; - /** * Checks that this component meets the prerequesites to be focus owner: * - it is enabled, visible, focusable @@ -8518,188 +8535,25 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** - * This odd class is to help out a native component that has been - * embedded in a lightweight component. Moving lightweight - * components around and changing their visibility is not seen - * by the native window system. This is a feature for lightweights, - * but a problem for native components that depend upon the - * lightweights. An instance of this class listens to the lightweight - * parents of an associated native component (the outer class). - * - * @author Timothy Prinzing + * Fix the location of the HW component in a LW container hierarchy. */ - final class NativeInLightFixer implements ComponentListener, ContainerListener { - - NativeInLightFixer() { - lightParents = new Vector(); - install(parent); - } - - void install(Container parent) { - lightParents.clear(); - Container p = parent; - boolean isLwParentsVisible = true; - // stash a reference to the components that are being observed so that - // we can reliably remove ourself as a listener later. - for (; p.peer instanceof LightweightPeer; p = p.parent) { - - // register listeners and stash a reference - p.addComponentListener(this); - p.addContainerListener(this); - lightParents.addElement(p); - isLwParentsVisible &= p.isVisible(); - } - // register with the native host (native parent of associated native) - // to get notified if the top-level lightweight is removed. - nativeHost = p; - p.addContainerListener(this); - - // kick start the fixup. Since the event isn't looked at - // we can simulate movement notification. - componentMoved(null); - if (!isLwParentsVisible) { - synchronized (getTreeLock()) { - if (peer != null) { - peer.hide(); - } - } - } - } - - void uninstall() { - if (nativeHost != null) { - removeReferences(); - } - } - - // --- ComponentListener ------------------------------------------- - - /** - * Invoked when one of the lightweight parents has been resized. - * This doesn't change the position of the native child so it - * is ignored. - */ - public void componentResized(ComponentEvent e) { - } - - /** - * Invoked when one of the lightweight parents has been moved. - * The native peer must be told of the new position which is - * relative to the native container that is hosting the - * lightweight components. - */ - public void componentMoved(ComponentEvent e) { - synchronized (getTreeLock()) { - int nativeX = x; - int nativeY = y; - for(Component c = parent; (c != null) && - (c.peer instanceof LightweightPeer); - c = c.parent) { - - nativeX += c.x; - nativeY += c.y; - } - if (peer != null) { - peer.setBounds(nativeX, nativeY, width, height, - ComponentPeer.SET_LOCATION); - } - } - } - - /** - * Invoked when a lightweight parent component has been - * shown. The associated native component must also be - * shown if it hasn't had an overriding hide done on it. - */ - public void componentShown(ComponentEvent e) { - if (shouldShow()) { - synchronized (getTreeLock()) { - if (peer != null) { - peer.show(); - } - } + final void relocateComponent() { + synchronized (getTreeLock()) { + if (peer == null) { + return; } - } - - /** - * Invoked when one of the lightweight parents become visible. - * Returns true if component and all its lightweight - * parents are visible. - */ - private boolean shouldShow() { - boolean isLwParentsVisible = visible; - for (int i = lightParents.size() - 1; - i >= 0 && isLwParentsVisible; - i--) + int nativeX = x; + int nativeY = y; + for (Component cont = getContainer(); + cont != null && cont.isLightweight(); + cont = cont.getContainer()) { - isLwParentsVisible &= - ((Container) lightParents.elementAt(i)).isVisible(); - } - return isLwParentsVisible; - } - - /** - * Invoked when component has been hidden. - */ - public void componentHidden(ComponentEvent e) { - if (visible) { - synchronized (getTreeLock()) { - if (peer != null) { - peer.hide(); - } - } + nativeX += cont.x; + nativeY += cont.y; } + peer.setBounds(nativeX, nativeY, width, height, + ComponentPeer.SET_LOCATION); } - - // --- ContainerListener ------------------------------------ - - /** - * Invoked when a component has been added to a lightweight - * parent. This doesn't effect the native component. - */ - public void componentAdded(ContainerEvent e) { - } - - /** - * Invoked when a lightweight parent has been removed. - * This means the services of this listener are no longer - * required and it should remove all references (ie - * registered listeners). - */ - public void componentRemoved(ContainerEvent e) { - Component c = e.getChild(); - if (c == Component.this) { - removeReferences(); - } else { - int n = lightParents.size(); - for (int i = 0; i < n; i++) { - Container p = (Container) lightParents.elementAt(i); - if (p == c) { - removeReferences(); - break; - } - } - } - } - - /** - * Removes references to this object so it can be - * garbage collected. - */ - void removeReferences() { - int n = lightParents.size(); - for (int i = 0; i < n; i++) { - Container c = (Container) lightParents.elementAt(i); - c.removeComponentListener(this); - c.removeContainerListener(this); - } - nativeHost.removeContainerListener(this); - lightParents.clear(); - nativeHost = null; - } - - Vector lightParents; - Container nativeHost; } /** @@ -9452,6 +9306,19 @@ public abstract class Component implements ImageObserver, MenuContainer, // ************************** MIXING CODE ******************************* + /** + * Check whether we can trust the current bounds of the component. + * The return value of false indicates that the container of the + * component is invalid, and therefore needs to be layed out, which would + * probably mean changing the bounds of its children. + * Null-layout of the container or absence of the container mean + * the bounds of the component are final and can be trusted. + */ + private boolean areBoundsValid() { + Container cont = getContainer(); + return cont == null || cont.isValid() || cont.getLayout() == null; + } + /** * Applies the shape to the component * @param shape Shape to be applied to the component @@ -9475,7 +9342,7 @@ public abstract class Component implements ImageObserver, MenuContainer, // to modify the object outside of the mixing code. this.compoundShape = shape; - if (isValid()) { + if (areBoundsValid()) { Point compAbsolute = getLocationOnWindow(); if (mixingLog.isLoggable(Level.FINER)) { @@ -9602,7 +9469,7 @@ public abstract class Component implements ImageObserver, MenuContainer, void applyCurrentShape() { checkTreeLock(); - if (!isValid()) { + if (!areBoundsValid()) { return; // Because applyCompoundShape() ignores such components anyway } if (mixingLog.isLoggable(Level.FINE)) { diff --git a/src/share/classes/java/awt/Container.java b/src/share/classes/java/awt/Container.java index 46164c410c6ccb934818b8f30a0dbf50aabe97f5..7eba36a11688fbb69da69205a3cead333813e0e8 100644 --- a/src/share/classes/java/awt/Container.java +++ b/src/share/classes/java/awt/Container.java @@ -832,16 +832,8 @@ public class Container extends Component { } if (!comp.isLightweight() && isLightweight()) { // If component is heavyweight and one of the containers is lightweight - // some NativeInLightFixer activity should be performed - if (!curParent.isLightweight()) { - // Moving from heavyweight container to lightweight container - should create NativeInLightFixer - // since addNotify does this - comp.nativeInLightFixer = new NativeInLightFixer(); - } else { - // Component already has NativeInLightFixer - just reinstall it - // because hierarchy changed and he needs to rebuild list of parents to listen. - comp.nativeInLightFixer.install(this); - } + // the location of the component should be fixed. + comp.relocateComponent(); } } } @@ -2267,53 +2259,56 @@ public class Container extends Component { EventTargetFilter filter, boolean searchHeavyweightChildren, boolean searchHeavyweightDescendants) { - int ncomponents = this.ncomponents; - Component component[] = this.component; + synchronized (getTreeLock()) { + int ncomponents = this.ncomponents; + Component component[] = this.component; - for (int i = 0 ; i < ncomponents ; i++) { - Component comp = component[i]; - if (comp != null && comp.visible && - ((!searchHeavyweightChildren && - comp.peer instanceof LightweightPeer) || - (searchHeavyweightChildren && - !(comp.peer instanceof LightweightPeer))) && - comp.contains(x - comp.x, y - comp.y)) { - - // found a component that intersects the point, see if there is - // a deeper possibility. - if (comp instanceof Container) { - Container child = (Container) comp; - Component deeper = child.getMouseEventTarget(x - child.x, - y - child.y, - includeSelf, - filter, - searchHeavyweightDescendants); - if (deeper != null) { - return deeper; - } - } else { - if (filter.accept(comp)) { - // there isn't a deeper target, but this component is a - // target - return comp; + for (int i = 0 ; i < ncomponents ; i++) { + Component comp = component[i]; + if (comp != null && comp.visible && + ((!searchHeavyweightChildren && + comp.peer instanceof LightweightPeer) || + (searchHeavyweightChildren && + !(comp.peer instanceof LightweightPeer))) && + comp.contains(x - comp.x, y - comp.y)) { + + // found a component that intersects the point, see if there + // is a deeper possibility. + if (comp instanceof Container) { + Container child = (Container) comp; + Component deeper = child.getMouseEventTarget( + x - child.x, + y - child.y, + includeSelf, + filter, + searchHeavyweightDescendants); + if (deeper != null) { + return deeper; + } + } else { + if (filter.accept(comp)) { + // there isn't a deeper target, but this component + // is a target + return comp; + } } } } - } - boolean isPeerOK; - boolean isMouseOverMe; + boolean isPeerOK; + boolean isMouseOverMe; - isPeerOK = (peer instanceof LightweightPeer) || includeSelf; - isMouseOverMe = contains(x,y); + isPeerOK = (peer instanceof LightweightPeer) || includeSelf; + isMouseOverMe = contains(x,y); - // didn't find a child target, return this component if it's a possible - // target - if (isMouseOverMe && isPeerOK && filter.accept(this)) { - return this; + // didn't find a child target, return this component if it's + // a possible target + if (isMouseOverMe && isPeerOK && filter.accept(this)) { + return this; + } + // no possible target + return null; } - // no possible target - return null; } static interface EventTargetFilter { @@ -3950,6 +3945,83 @@ public class Container extends Component { } } + private void recursiveShowHeavyweightChildren() { + if (!hasHeavyweightDescendants() || !isVisible()) { + return; + } + for (int index = 0; index < getComponentCount(); index++) { + Component comp = getComponent(index); + if (comp.isLightweight()) { + if (comp instanceof Container) { + ((Container)comp).recursiveShowHeavyweightChildren(); + } + } else { + if (comp.isVisible()) { + ComponentPeer peer = comp.getPeer(); + if (peer != null) { + peer.show(); + } + } + } + } + } + + private void recursiveHideHeavyweightChildren() { + if (!hasHeavyweightDescendants()) { + return; + } + for (int index = 0; index < getComponentCount(); index++) { + Component comp = getComponent(index); + if (comp.isLightweight()) { + if (comp instanceof Container) { + ((Container)comp).recursiveHideHeavyweightChildren(); + } + } else { + if (comp.isVisible()) { + ComponentPeer peer = comp.getPeer(); + if (peer != null) { + peer.hide(); + } + } + } + } + } + + private void recursiveRelocateHeavyweightChildren(Point origin) { + for (int index = 0; index < getComponentCount(); index++) { + Component comp = getComponent(index); + if (comp.isLightweight()) { + if (comp instanceof Container && + ((Container)comp).hasHeavyweightDescendants()) + { + final Point newOrigin = new Point(origin); + newOrigin.translate(comp.getX(), comp.getY()); + ((Container)comp).recursiveRelocateHeavyweightChildren(newOrigin); + } + } else { + ComponentPeer peer = comp.getPeer(); + if (peer != null) { + peer.setBounds(origin.x + comp.getX(), origin.y + comp.getY(), + comp.getWidth(), comp.getHeight(), + ComponentPeer.SET_LOCATION); + } + } + } + } + + /* + * Consider the heavyweight container hides or shows the HW descendants + * automatically. Therefore we care of LW containers' visibility only. + */ + private boolean isRecursivelyVisibleUpToHeavyweightContainer() { + if (!isLightweight()) { + return true; + } + return isVisible() && (getContainer() == null || + getContainer().isRecursivelyVisibleUpToHeavyweightContainer()); + } + + @Override void mixOnShowing() { synchronized (getTreeLock()) { if (mixingLog.isLoggable(Level.FINE)) { @@ -3958,6 +4030,10 @@ public class Container extends Component { boolean isLightweight = isLightweight(); + if (isLightweight && isRecursivelyVisibleUpToHeavyweightContainer()) { + recursiveShowHeavyweightChildren(); + } + if (!isLightweight || (isLightweight && hasHeavyweightDescendants())) { recursiveApplyCurrentShape(); } @@ -3966,6 +4042,42 @@ public class Container extends Component { } } + @Override + void mixOnHiding(boolean isLightweight) { + synchronized (getTreeLock()) { + if (mixingLog.isLoggable(Level.FINE)) { + mixingLog.fine("this = " + this + + "; isLightweight=" + isLightweight); + } + if (isLightweight) { + recursiveHideHeavyweightChildren(); + } + super.mixOnHiding(isLightweight); + } + } + + @Override + void mixOnReshaping() { + synchronized (getTreeLock()) { + if (mixingLog.isLoggable(Level.FINE)) { + mixingLog.fine("this = " + this); + } + if (isLightweight() && hasHeavyweightDescendants()) { + final Point origin = new Point(getX(), getY()); + for (Container cont = getContainer(); + cont != null && cont.isLightweight(); + cont = cont.getContainer()) + { + origin.translate(cont.getX(), cont.getY()); + } + + recursiveRelocateHeavyweightChildren(origin); + } + super.mixOnReshaping(); + } + } + + @Override void mixOnZOrderChanging(int oldZorder, int newZorder) { synchronized (getTreeLock()) { if (mixingLog.isLoggable(Level.FINE)) { @@ -4431,7 +4543,8 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { e.isPopupTrigger(), ((MouseWheelEvent)e).getScrollType(), ((MouseWheelEvent)e).getScrollAmount(), - ((MouseWheelEvent)e).getWheelRotation()); + ((MouseWheelEvent)e).getWheelRotation(), + ((MouseWheelEvent)e).getPreciseWheelRotation()); } else { retargeted = new MouseEvent(target, diff --git a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java index 2587b7ee670057063dcf6fcefa565d6bb4e2d238..1874d8bb3e386c8b13e821f8435840332c5c3f03 100644 --- a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java +++ b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java @@ -154,7 +154,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { private boolean doRestoreFocus(Component toFocus, Component vetoedComponent, boolean clearOnFailure) { - if (toFocus.isShowing() && toFocus.isFocusable() && + if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.isFocusable() && toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK)) { return true; } else { diff --git a/src/share/classes/java/awt/Window.java b/src/share/classes/java/awt/Window.java index 440a65ddec3f8b2aaa51341631f40aafcbf9873e..3ebeee0063971a045aa1293e61d90704b1eff155 100644 --- a/src/share/classes/java/awt/Window.java +++ b/src/share/classes/java/awt/Window.java @@ -1,5 +1,5 @@ /* - * Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1995-2008 Sun Microsystems, 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 @@ -24,7 +24,6 @@ */ package java.awt; -import java.applet.Applet; import java.awt.event.*; import java.awt.im.InputContext; import java.awt.image.BufferStrategy; @@ -355,18 +354,21 @@ public class Window extends Container implements Accessible { static class WindowDisposerRecord implements sun.java2d.DisposerRecord { final WeakReference owner; final WeakReference weakThis; - final AppContext context; + final WeakReference context; WindowDisposerRecord(AppContext context, Window victim) { owner = new WeakReference(victim.getOwner()); weakThis = victim.weakThis; - this.context = context; + this.context = new WeakReference(context); } public void dispose() { Window parent = owner.get(); if (parent != null) { parent.removeOwnedWindow(weakThis); } - Window.removeFromWindowList(context, weakThis); + AppContext ac = context.get(); + if (null != ac) { + Window.removeFromWindowList(ac, weakThis); + } } } @@ -824,7 +826,10 @@ public class Window extends Container implements Accessible { static private final AtomicBoolean beforeFirstWindowShown = new AtomicBoolean(true); - static final void closeSplashScreen() { + final void closeSplashScreen() { + if (isTrayIconWindow) { + return; + } if (beforeFirstWindowShown.getAndSet(false)) { SunToolkit.closeSplashScreen(); } diff --git a/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java b/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java index c84e838403aa651ad629f2a6ee8ee2cf48e39b3a..77eb2bcec614641c532fde86b048ec84e12ef127 100644 --- a/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java +++ b/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2008 Sun Microsystems, 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 @@ -49,7 +49,6 @@ import java.util.WeakHashMap; import sun.awt.datatransfer.DataTransferer; - /** * The SystemFlavorMap is a configurable map between "natives" (Strings), which * correspond to platform-specific data formats, and "flavors" (DataFlavors), @@ -117,15 +116,50 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { /** * Maps native Strings to Lists of DataFlavors (or base type Strings for * text DataFlavors). + * Do not use the field directly, use getNativeToFlavor() instead. */ private Map nativeToFlavor = new HashMap(); + /** + * Accessor to nativeToFlavor map. Since we use lazy initialization we must + * use this accessor instead of direct access to the field which may not be + * initialized yet. This method will initialize the field if needed. + * + * @return nativeToFlavor + */ + private Map getNativeToFlavor() { + if (!isMapInitialized) { + initSystemFlavorMap(); + } + return nativeToFlavor; + } + /** * Maps DataFlavors (or base type Strings for text DataFlavors) to Lists of * native Strings. + * Do not use the field directly, use getFlavorToNative() instead. */ private Map flavorToNative = new HashMap(); + /** + * Accessor to flavorToNative map. Since we use lazy initialization we must + * use this accessor instead of direct access to the field which may not be + * initialized yet. This method will initialize the field if needed. + * + * @return flavorToNative + */ + private synchronized Map getFlavorToNative() { + if (!isMapInitialized) { + initSystemFlavorMap(); + } + return flavorToNative; + } + + /** + * Shows if the object has been initialized. + */ + private boolean isMapInitialized = false; + /** * Caches the result of getNativesForFlavor(). Maps DataFlavors to * SoftReferences which reference Lists of String natives. @@ -169,15 +203,24 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { return fm; } + private SystemFlavorMap() { + } + /** - * Constructs a SystemFlavorMap by reading flavormap.properties and + * Initializes a SystemFlavorMap by reading flavormap.properties and * AWT.DnD.flavorMapFileURL. + * For thread-safety must be called under lock on this. */ - private SystemFlavorMap() { - BufferedReader flavormapDotProperties = (BufferedReader) + private void initSystemFlavorMap() { + if (isMapInitialized) { + return; + } + + isMapInitialized = true; + BufferedReader flavormapDotProperties = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public BufferedReader run() { String fileName = System.getProperty("java.home") + File.separator + @@ -197,12 +240,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { } }); - BufferedReader flavormapURL = (BufferedReader) + BufferedReader flavormapURL = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - String url = Toolkit.getDefaultToolkit().getProperty - ("AWT.DnD.flavorMapFileURL", null); + new java.security.PrivilegedAction() { + public BufferedReader run() { + String url = Toolkit.getProperty("AWT.DnD.flavorMapFileURL", null); if (url == null) { return null; @@ -237,7 +279,6 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { } } } - /** * Copied code from java.util.Properties. Parsing the data ourselves is the * only way to handle duplicate keys and values. @@ -388,11 +429,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { // For text/* flavors, store mappings in separate maps to // enable dynamic mapping generation at a run-time. if ("text".equals(flavor.getPrimaryType())) { - store(value, key, flavorToNative); - store(key, value, nativeToFlavor); + store(value, key, getFlavorToNative()); + store(key, value, getNativeToFlavor()); } else { - store(flavor, key, flavorToNative); - store(key, flavor, nativeToFlavor); + store(flavor, key, getFlavorToNative()); + store(key, flavor, getNativeToFlavor()); } } } @@ -494,7 +535,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { * only if the specified native is encoded as a Java MIME type. */ private List nativeToFlavorLookup(String nat) { - List flavors = (List)nativeToFlavor.get(nat); + List flavors = (List)getNativeToFlavor().get(nat); if (nat != null && !disabledMappingGenerationKeys.contains(nat)) { DataTransferer transferer = DataTransferer.getInstance(); @@ -530,15 +571,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { if (flavor != null) { flavors = new ArrayList(1); - nativeToFlavor.put(nat, flavors); + getNativeToFlavor().put(nat, flavors); flavors.add(flavor); getFlavorsForNativeCache.remove(nat); getFlavorsForNativeCache.remove(null); - List natives = (List)flavorToNative.get(flavor); + List natives = (List)getFlavorToNative().get(flavor); if (natives == null) { natives = new ArrayList(1); - flavorToNative.put(flavor, natives); + getFlavorToNative().put(flavor, natives); } natives.add(nat); getNativesForFlavorCache.remove(flavor); @@ -559,7 +600,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { */ private List flavorToNativeLookup(final DataFlavor flav, final boolean synthesize) { - List natives = (List)flavorToNative.get(flav); + List natives = (List)getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { DataTransferer transferer = DataTransferer.getInstance(); @@ -584,15 +625,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { if (synthesize) { String encoded = encodeDataFlavor(flav); natives = new ArrayList(1); - flavorToNative.put(flav, natives); + getFlavorToNative().put(flav, natives); natives.add(encoded); getNativesForFlavorCache.remove(flav); getNativesForFlavorCache.remove(null); - List flavors = (List)nativeToFlavor.get(encoded); + List flavors = (List)getNativeToFlavor().get(encoded); if (flavors == null) { flavors = new ArrayList(1); - nativeToFlavor.put(encoded, flavors); + getNativeToFlavor().put(encoded, flavors); } flavors.add(flav); getFlavorsForNativeCache.remove(encoded); @@ -645,7 +686,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { } if (flav == null) { - retval = new ArrayList(nativeToFlavor.keySet()); + retval = new ArrayList(getNativeToFlavor().keySet()); } else if (disabledMappingGenerationKeys.contains(flav)) { // In this case we shouldn't synthesize a native for this flavor, // since its mappings were explicitly specified. @@ -655,7 +696,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { // For text/* flavors, flavor-to-native mappings specified in // flavormap.properties are stored per flavor's base type. if ("text".equals(flav.getPrimaryType())) { - retval = (List)flavorToNative.get(flav.mimeType.getBaseType()); + retval = (List)getFlavorToNative().get(flav.mimeType.getBaseType()); if (retval != null) { // To prevent the List stored in the map from modification. retval = new ArrayList(retval); @@ -663,7 +704,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { } // Also include text/plain natives, but don't duplicate Strings - List textPlainList = (List)flavorToNative.get(TEXT_PLAIN_BASE_TYPE); + List textPlainList = (List)getFlavorToNative().get(TEXT_PLAIN_BASE_TYPE); if (textPlainList != null && !textPlainList.isEmpty()) { // To prevent the List stored in the map from modification. @@ -699,7 +740,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { } } } else if (DataTransferer.isFlavorNoncharsetTextType(flav)) { - retval = (List)flavorToNative.get(flav.mimeType.getBaseType()); + retval = (List)getFlavorToNative().get(flav.mimeType.getBaseType()); if (retval == null || retval.isEmpty()) { retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND); @@ -1025,10 +1066,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { throw new NullPointerException("null arguments not permitted"); } - List natives = (List)flavorToNative.get(flav); + List natives = (List)getFlavorToNative().get(flav); if (natives == null) { natives = new ArrayList(1); - flavorToNative.put(flav, natives); + getFlavorToNative().put(flav, natives); } else if (natives.contains(nat)) { return; } @@ -1071,7 +1112,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { throw new NullPointerException("null arguments not permitted"); } - flavorToNative.remove(flav); + getFlavorToNative().remove(flav); for (int i = 0; i < natives.length; i++) { addUnencodedNativeForFlavor(flav, natives[i]); } @@ -1105,10 +1146,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { throw new NullPointerException("null arguments not permitted"); } - List flavors = (List)nativeToFlavor.get(nat); + List flavors = (List)getNativeToFlavor().get(nat); if (flavors == null) { flavors = new ArrayList(1); - nativeToFlavor.put(nat, flavors); + getNativeToFlavor().put(nat, flavors); } else if (flavors.contains(flav)) { return; } @@ -1150,7 +1191,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { throw new NullPointerException("null arguments not permitted"); } - nativeToFlavor.remove(nat); + getNativeToFlavor().remove(nat); for (int i = 0; i < flavors.length; i++) { addFlavorForUnencodedNative(nat, flavors[i]); } diff --git a/src/share/classes/java/awt/dnd/DropTarget.java b/src/share/classes/java/awt/dnd/DropTarget.java index 5995c885b2f51843cef762fdd50368bdc3efc356..aa75ec71541ca07a1d83f8b4edfa299536138de4 100644 --- a/src/share/classes/java/awt/dnd/DropTarget.java +++ b/src/share/classes/java/awt/dnd/DropTarget.java @@ -1,5 +1,5 @@ /* - * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2008 Sun Microsystems, 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 @@ -110,7 +110,11 @@ public class DropTarget implements DropTargetListener, Serializable { setActive(act); } - if (fm != null) flavorMap = fm; + if (fm != null) { + flavorMap = fm; + } else { + flavorMap = SystemFlavorMap.getDefaultFlavorMap(); + } } /** @@ -850,5 +854,5 @@ public class DropTarget implements DropTargetListener, Serializable { * The FlavorMap */ - private transient FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap(); + private transient FlavorMap flavorMap; } diff --git a/src/share/classes/java/awt/event/MouseWheelEvent.java b/src/share/classes/java/awt/event/MouseWheelEvent.java index 40af56c44396759633e2c23769e4326e1e329d88..a1c5b2ebb9111eb755c8914f9a42672b12ceef87 100644 --- a/src/share/classes/java/awt/event/MouseWheelEvent.java +++ b/src/share/classes/java/awt/event/MouseWheelEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-2007 Sun Microsystems, 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 @@ -74,6 +74,19 @@ import java.awt.Component; * methods for conforming to the underlying platform settings. These * platform settings can be changed at any time by the user. MouseWheelEvents * reflect the most recent settings. + *

+ * The MouseWheelEvent class includes methods for + * getting the number of "clicks" by which the mouse wheel is rotated. + * The {@link #getWheelRotation} method returns the integer number + * of "clicks" corresponding to the number of notches by which the wheel was + * rotated. In addition to this method, the MouseWheelEvent + * class provides the {@link #getPreciseWheelRotation} method which returns + * a double number of "clicks" in case a partial rotation occurred. + * The {@link #getPreciseWheelRotation} method is useful if a mouse supports + * a high-resolution wheel, such as a freely rotating wheel with no + * notches. Applications can benefit by using this method to process + * mouse wheel events more precisely, and thus, making visual perception + * smoother. * * @author Brent Christian * @see MouseWheelListener @@ -131,6 +144,13 @@ public class MouseWheelEvent extends MouseEvent { */ int wheelRotation; + /** + * Indicates how far the mouse wheel was rotated. + * + * @see #getPreciseWheelRotation + */ + double preciseWheelRotation; + /* * serialVersionUID */ @@ -165,8 +185,8 @@ public class MouseWheelEvent extends MouseEvent { * WHEEL_BLOCK_SCROLL * @param scrollAmount for scrollType WHEEL_UNIT_SCROLL, * the number of units to be scrolled - * @param wheelRotation the amount that the mouse wheel was rotated (the - * number of "clicks") + * @param wheelRotation the integer number of "clicks" by which the mouse + * wheel was rotated * * @throws IllegalArgumentException if source is null * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean) @@ -211,8 +231,8 @@ public class MouseWheelEvent extends MouseEvent { * WHEEL_BLOCK_SCROLL * @param scrollAmount for scrollType WHEEL_UNIT_SCROLL, * the number of units to be scrolled - * @param wheelRotation the amount that the mouse wheel was rotated (the - * number of "clicks") + * @param wheelRotation the integer number of "clicks" by which the mouse + * wheel was rotated * * @throws IllegalArgumentException if source is null * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean) @@ -223,12 +243,68 @@ public class MouseWheelEvent extends MouseEvent { int x, int y, int xAbs, int yAbs, int clickCount, boolean popupTrigger, int scrollType, int scrollAmount, int wheelRotation) { + this(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount, popupTrigger, + scrollType, scrollAmount, wheelRotation, wheelRotation); + + } + + + /** + * Constructs a MouseWheelEvent object with the specified + * source component, type, modifiers, coordinates, absolute coordinates, + * scroll type, scroll amount, and wheel rotation. + *

Note that passing in an invalid id parameter results + * in unspecified behavior. This method throws an + * IllegalArgumentException if source equals + * null. + *

Even if inconsistent values for relative and absolute coordinates + * are passed to the constructor, a MouseWheelEvent instance + * is still created and no exception is thrown. + * + * @param source the Component that originated the event + * @param id the integer value that identifies the event + * @param when a long value that gives the time when the event occurred + * @param modifiers the modifier keys down during event + * (shift, ctrl, alt, meta) + * @param x the horizontal x coordinate for the + * mouse location + * @param y the vertical y coordinate for the + * mouse location + * @param xAbs the absolute horizontal x coordinate for + * the mouse location + * @param yAbs the absolute vertical y coordinate for + * the mouse location + * @param clickCount the number of mouse clicks associated with the event + * @param popupTrigger a boolean value, true if this event is a trigger + * for a popup-menu + * @param scrollType the type of scrolling which should take place in + * response to this event; valid values are + * WHEEL_UNIT_SCROLL and + * WHEEL_BLOCK_SCROLL + * @param scrollAmount for scrollType WHEEL_UNIT_SCROLL, + * the number of units to be scrolled + * @param wheelRotation the integer number of "clicks" by which the mouse wheel + * was rotated + * @param preciseWheelRotation the double number of "clicks" by which the mouse wheel + * was rotated + * + * @throws IllegalArgumentException if source is null + * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean) + * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int) + * @since 1.7 + */ + public MouseWheelEvent (Component source, int id, long when, int modifiers, + int x, int y, int xAbs, int yAbs, int clickCount, boolean popupTrigger, + int scrollType, int scrollAmount, int wheelRotation, double preciseWheelRotation) { + super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount, popupTrigger, MouseEvent.NOBUTTON); this.scrollType = scrollType; this.scrollAmount = scrollAmount; this.wheelRotation = wheelRotation; + this.preciseWheelRotation = preciseWheelRotation; + } /** @@ -267,16 +343,34 @@ public class MouseWheelEvent extends MouseEvent { } /** - * Returns the number of "clicks" the mouse wheel was rotated. + * Returns the number of "clicks" the mouse wheel was rotated, as an integer. + * A partial rotation may occur if the mouse supports a high-resolution wheel. + * In this case, the method returns zero until a full "click" has been accumulated. * * @return negative values if the mouse wheel was rotated up/away from * the user, and positive values if the mouse wheel was rotated down/ * towards the user + * @see #getPreciseWheelRotation */ public int getWheelRotation() { return wheelRotation; } + /** + * Returns the number of "clicks" the mouse wheel was rotated, as a double. + * A partial rotation may occur if the mouse supports a high-resolution wheel. + * In this case, the return value will include a fractional "click". + * + * @return negative values if the mouse wheel was rotated up or away from + * the user, and positive values if the mouse wheel was rotated down or + * towards the user + * @see #getWheelRotation + * @since 1.7 + */ + public double getPreciseWheelRotation() { + return preciseWheelRotation; + } + /** * This is a convenience method to aid in the implementation of * the common-case MouseWheelListener - to scroll a ScrollPane or @@ -348,6 +442,6 @@ public class MouseWheelEvent extends MouseEvent { } return super.paramString()+",scrollType="+scrollTypeStr+ ",scrollAmount="+getScrollAmount()+",wheelRotation="+ - getWheelRotation(); + getWheelRotation()+",preciseWheelRotation="+getPreciseWheelRotation(); } } diff --git a/src/share/classes/java/beans/MetaData.java b/src/share/classes/java/beans/MetaData.java index 4771bb7d3c140880d50177ea1afad58730262a1b..7b9f6ced377be2fc97df923bdcab31aad6c0dfc2 100644 --- a/src/share/classes/java/beans/MetaData.java +++ b/src/share/classes/java/beans/MetaData.java @@ -1553,7 +1553,7 @@ class MetaData { private static String[] getConstructorProperties(Class type) { String[] names = null; int length = 0; - for (Constructor constructor : type.getConstructors()) { + for (Constructor constructor : type.getConstructors()) { String[] value = getAnnotationValue(constructor); if ((value != null) && (length < value.length) && isValid(constructor, value)) { names = value; @@ -1563,14 +1563,14 @@ class MetaData { return names; } - private static String[] getAnnotationValue(Constructor constructor) { + private static String[] getAnnotationValue(Constructor constructor) { ConstructorProperties annotation = constructor.getAnnotation(ConstructorProperties.class); return (annotation != null) ? annotation.value() : null; } - private static boolean isValid(Constructor constructor, String[] names) { + private static boolean isValid(Constructor constructor, String[] names) { Class[] parameters = constructor.getParameterTypes(); if (names.length != parameters.length) { return false; diff --git a/src/share/classes/java/io/FileInputStream.java b/src/share/classes/java/io/FileInputStream.java index 8575e6d9397cc497714085daacc4150cb0da297b..a37c69c6239890ad13eea9c92a79dcc115bbc000 100644 --- a/src/share/classes/java/io/FileInputStream.java +++ b/src/share/classes/java/io/FileInputStream.java @@ -48,15 +48,15 @@ public class FileInputStream extends InputStream { /* File Descriptor - handle to the open file */ - private FileDescriptor fd; + private final FileDescriptor fd; private FileChannel channel = null; - private Object closeLock = new Object(); + private final Object closeLock = new Object(); private volatile boolean closed = false; - private static ThreadLocal runningFinalize = - new ThreadLocal(); + private static final ThreadLocal runningFinalize = + new ThreadLocal(); private static boolean isRunningFinalize() { Boolean val; @@ -151,7 +151,7 @@ class FileInputStream extends InputStream * is thrown. *

* This constructor does not throw an exception if fdObj - * is {link java.io.FileDescriptor#valid() invalid}. + * is {@link java.io.FileDescriptor#valid() invalid}. * However, if the methods are invoked on the resulting stream to attempt * I/O on the stream, an IOException is thrown. * @@ -389,7 +389,7 @@ class FileInputStream extends InputStream * @see java.io.FileInputStream#close() */ protected void finalize() throws IOException { - if ((fd != null) && (fd != fd.in)) { + if ((fd != null) && (fd != FileDescriptor.in)) { /* * Finalizer should not release the FileDescriptor if another diff --git a/src/share/classes/java/io/FileOutputStream.java b/src/share/classes/java/io/FileOutputStream.java index 695f43150fe2eaa182074755574209f66d8b29fa..f252237d89f85bb6d6025470fc21e008fec88dba 100644 --- a/src/share/classes/java/io/FileOutputStream.java +++ b/src/share/classes/java/io/FileOutputStream.java @@ -52,20 +52,16 @@ public class FileOutputStream extends OutputStream { /** - * The system dependent file descriptor. The value is - * 1 more than actual file descriptor. This means that - * the default value 0 indicates that the file is not open. + * The system dependent file descriptor. */ - private FileDescriptor fd; + private final FileDescriptor fd; private FileChannel channel= null; - private boolean append = false; - - private Object closeLock = new Object(); + private final Object closeLock = new Object(); private volatile boolean closed = false; - private static ThreadLocal runningFinalize = - new ThreadLocal(); + private static final ThreadLocal runningFinalize = + new ThreadLocal(); private static boolean isRunningFinalize() { Boolean val; @@ -75,7 +71,7 @@ class FileOutputStream extends OutputStream } /** - * Creates an output file stream to write to the file with the + * Creates a file output stream to write to the file with the * specified name. A new FileDescriptor object is * created to represent this file connection. *

@@ -100,8 +96,8 @@ class FileOutputStream extends OutputStream } /** - * Creates an output file stream to write to the file with the specified - * name. If the second argument is true, then + * Creates a file output stream to write to the file with the specified + * name. If the second argument is true, then * bytes will be written to the end of the file rather than the beginning. * A new FileDescriptor object is created to represent this * file connection. @@ -202,16 +198,11 @@ class FileOutputStream extends OutputStream } fd = new FileDescriptor(); fd.incrementAndGetUseCount(); - this.append = append; - if (append) { - openAppend(name); - } else { - open(name); - } + open(name, append); } /** - * Creates an output file stream to write to the specified file + * Creates a file output stream to write to the specified file * descriptor, which represents an existing connection to an actual * file in the file system. *

@@ -223,7 +214,7 @@ class FileOutputStream extends OutputStream * is thrown. *

* This constructor does not throw an exception if fdObj - * is {link java.io.FileDescriptor#valid() invalid}. + * is {@link java.io.FileDescriptor#valid() invalid}. * However, if the methods are invoked on the resulting stream to attempt * I/O on the stream, an IOException is thrown. * @@ -252,16 +243,12 @@ class FileOutputStream extends OutputStream } /** - * Opens a file, with the specified name, for writing. - * @param name name of file to be opened - */ - private native void open(String name) throws FileNotFoundException; - - /** - * Opens a file, with the specified name, for appending. + * Opens a file, with the specified name, for overwriting or appending. * @param name name of file to be opened + * @param append whether the file is to be opened in append mode */ - private native void openAppend(String name) throws FileNotFoundException; + private native void open(String name, boolean append) + throws FileNotFoundException; /** * Writes the specified byte to this file output stream. Implements @@ -385,7 +372,7 @@ class FileOutputStream extends OutputStream public FileChannel getChannel() { synchronized (this) { if (channel == null) { - channel = FileChannelImpl.open(fd, false, true, this, append); + channel = FileChannelImpl.open(fd, false, true, this); /* * Increment fd's use count. Invoking the channel's close() @@ -408,7 +395,7 @@ class FileOutputStream extends OutputStream */ protected void finalize() throws IOException { if (fd != null) { - if (fd == fd.out || fd == fd.err) { + if (fd == FileDescriptor.out || fd == FileDescriptor.err) { flush(); } else { diff --git a/src/share/classes/java/io/ObjectInputStream.java b/src/share/classes/java/io/ObjectInputStream.java index 9acc30cf7c19e1315b84caacbc730baa05f6f5cd..d4dd289a3b3e136e41dcf0e2d11d38125a8d9c6a 100644 --- a/src/share/classes/java/io/ObjectInputStream.java +++ b/src/share/classes/java/io/ObjectInputStream.java @@ -212,7 +212,8 @@ public class ObjectInputStream private static final Object unsharedMarker = new Object(); /** table mapping primitive type names to corresponding class objects */ - private static final HashMap primClasses = new HashMap(8, 1.0F); + private static final HashMap> primClasses + = new HashMap>(8, 1.0F); static { primClasses.put("boolean", boolean.class); primClasses.put("byte", byte.class); @@ -620,7 +621,7 @@ public class ObjectInputStream try { return Class.forName(name, false, latestUserDefinedLoader()); } catch (ClassNotFoundException ex) { - Class cl = (Class) primClasses.get(name); + Class cl = primClasses.get(name); if (cl != null) { return cl; } else { @@ -1254,11 +1255,11 @@ public class ObjectInputStream * override security-sensitive non-final methods. Returns true if subclass * is "safe", false otherwise. */ - private static boolean auditSubclass(final Class subcl) { + private static boolean auditSubclass(final Class subcl) { Boolean result = AccessController.doPrivileged( new PrivilegedAction() { public Boolean run() { - for (Class cl = subcl; + for (Class cl = subcl; cl != ObjectInputStream.class; cl = cl.getSuperclass()) { @@ -2217,9 +2218,9 @@ public class ObjectInputStream try { while (list != null) { AccessController.doPrivileged( - new PrivilegedExceptionAction() + new PrivilegedExceptionAction() { - public Object run() throws InvalidObjectException { + public Void run() throws InvalidObjectException { list.obj.validateObject(); return null; } diff --git a/src/share/classes/java/io/ObjectStreamClass.java b/src/share/classes/java/io/ObjectStreamClass.java index 2a4553b11e96486af7068072d896de134993f5bc..af6da35458b23ff3cccb6173dc6fc612820eba0c 100644 --- a/src/share/classes/java/io/ObjectStreamClass.java +++ b/src/share/classes/java/io/ObjectStreamClass.java @@ -77,7 +77,7 @@ public class ObjectStreamClass implements Serializable { NO_FIELDS; /** reflection factory for obtaining serialization constructors */ - private static final ReflectionFactory reflFactory = (ReflectionFactory) + private static final ReflectionFactory reflFactory = AccessController.doPrivileged( new ReflectionFactory.GetReflectionFactoryAction()); @@ -216,10 +216,10 @@ public class ObjectStreamClass implements Serializable { public long getSerialVersionUID() { // REMIND: synchronize instead of relying on volatile? if (suid == null) { - suid = (Long) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - return Long.valueOf(computeDefaultSUID(cl)); + suid = AccessController.doPrivileged( + new PrivilegedAction() { + public Long run() { + return computeDefaultSUID(cl); } } ); @@ -392,8 +392,8 @@ public class ObjectStreamClass implements Serializable { } if (interrupted) { AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + new PrivilegedAction() { + public Void run() { Thread.currentThread().interrupt(); return null; } @@ -427,8 +427,8 @@ public class ObjectStreamClass implements Serializable { localDesc = this; if (serializable) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { if (isEnum) { suid = Long.valueOf(0); fields = NO_FIELDS; @@ -802,7 +802,7 @@ public class ObjectStreamClass implements Serializable { * non-primitive types, and any other non-null type matches assignable * types only. Returns matching field, or null if no match found. */ - ObjectStreamField getField(String name, Class type) { + ObjectStreamField getField(String name, Class type) { for (int i = 0; i < fields.length; i++) { ObjectStreamField f = fields[i]; if (f.getName().equals(name)) { @@ -811,7 +811,7 @@ public class ObjectStreamClass implements Serializable { { return f; } - Class ftype = f.getType(); + Class ftype = f.getType(); if (ftype != null && type.isAssignableFrom(ftype)) { return f; } @@ -1130,7 +1130,7 @@ public class ObjectStreamClass implements Serializable { private ClassDataSlot[] getClassDataLayout0() throws InvalidClassException { - ArrayList slots = new ArrayList(); + ArrayList slots = new ArrayList(); Class start = cl, end = cl; // locate closest non-serializable superclass @@ -1171,8 +1171,7 @@ public class ObjectStreamClass implements Serializable { // order slots from superclass -> subclass Collections.reverse(slots); - return (ClassDataSlot[]) - slots.toArray(new ClassDataSlot[slots.size()]); + return slots.toArray(new ClassDataSlot[slots.size()]); } /** @@ -1309,9 +1308,9 @@ public class ObjectStreamClass implements Serializable { * Access checks are disabled on the returned constructor (if any), since * the defining class may still be non-public. */ - private static Constructor getExternalizableConstructor(Class cl) { + private static Constructor getExternalizableConstructor(Class cl) { try { - Constructor cons = cl.getDeclaredConstructor((Class[]) null); + Constructor cons = cl.getDeclaredConstructor((Class[]) null); cons.setAccessible(true); return ((cons.getModifiers() & Modifier.PUBLIC) != 0) ? cons : null; @@ -1325,15 +1324,15 @@ public class ObjectStreamClass implements Serializable { * superclass, or null if none found. Access checks are disabled on the * returned constructor (if any). */ - private static Constructor getSerializableConstructor(Class cl) { - Class initCl = cl; + private static Constructor getSerializableConstructor(Class cl) { + Class initCl = cl; while (Serializable.class.isAssignableFrom(initCl)) { if ((initCl = initCl.getSuperclass()) == null) { return null; } } try { - Constructor cons = initCl.getDeclaredConstructor((Class[]) null); + Constructor cons = initCl.getDeclaredConstructor((Class[]) null); int mods = cons.getModifiers(); if ((mods & Modifier.PRIVATE) != 0 || ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 && @@ -1355,12 +1354,12 @@ public class ObjectStreamClass implements Serializable { * null if no match found. Access checks are disabled on the returned * method (if any). */ - private static Method getInheritableMethod(Class cl, String name, + private static Method getInheritableMethod(Class cl, String name, Class[] argTypes, Class returnType) { Method meth = null; - Class defCl = cl; + Class defCl = cl; while (defCl != null) { try { meth = defCl.getDeclaredMethod(name, argTypes); @@ -1391,9 +1390,9 @@ public class ObjectStreamClass implements Serializable { * class, or null if none found. Access checks are disabled on the * returned method (if any). */ - private static Method getPrivateMethod(Class cl, String name, - Class[] argTypes, - Class returnType) + private static Method getPrivateMethod(Class cl, String name, + Class[] argTypes, + Class returnType) { try { Method meth = cl.getDeclaredMethod(name, argTypes); @@ -1567,7 +1566,7 @@ public class ObjectStreamClass implements Serializable { ObjectStreamField[] boundFields = new ObjectStreamField[serialPersistentFields.length]; - Set fieldNames = new HashSet(serialPersistentFields.length); + Set fieldNames = new HashSet(serialPersistentFields.length); for (int i = 0; i < serialPersistentFields.length; i++) { ObjectStreamField spf = serialPersistentFields[i]; @@ -1605,7 +1604,7 @@ public class ObjectStreamClass implements Serializable { */ private static ObjectStreamField[] getDefaultSerialFields(Class cl) { Field[] clFields = cl.getDeclaredFields(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); int mask = Modifier.STATIC | Modifier.TRANSIENT; for (int i = 0; i < clFields.length; i++) { @@ -1615,7 +1614,7 @@ public class ObjectStreamClass implements Serializable { } int size = list.size(); return (size == 0) ? NO_FIELDS : - (ObjectStreamField[]) list.toArray(new ObjectStreamField[size]); + list.toArray(new ObjectStreamField[size]); } /** @@ -1688,11 +1687,9 @@ public class ObjectStreamClass implements Serializable { for (int i = 0; i < fields.length; i++) { fieldSigs[i] = new MemberSignature(fields[i]); } - Arrays.sort(fieldSigs, new Comparator() { - public int compare(Object o1, Object o2) { - String name1 = ((MemberSignature) o1).name; - String name2 = ((MemberSignature) o2).name; - return name1.compareTo(name2); + Arrays.sort(fieldSigs, new Comparator() { + public int compare(MemberSignature ms1, MemberSignature ms2) { + return ms1.name.compareTo(ms2.name); } }); for (int i = 0; i < fieldSigs.length; i++) { @@ -1721,11 +1718,9 @@ public class ObjectStreamClass implements Serializable { for (int i = 0; i < cons.length; i++) { consSigs[i] = new MemberSignature(cons[i]); } - Arrays.sort(consSigs, new Comparator() { - public int compare(Object o1, Object o2) { - String sig1 = ((MemberSignature) o1).signature; - String sig2 = ((MemberSignature) o2).signature; - return sig1.compareTo(sig2); + Arrays.sort(consSigs, new Comparator() { + public int compare(MemberSignature ms1, MemberSignature ms2) { + return ms1.signature.compareTo(ms2.signature); } }); for (int i = 0; i < consSigs.length; i++) { @@ -1746,10 +1741,8 @@ public class ObjectStreamClass implements Serializable { for (int i = 0; i < methods.length; i++) { methSigs[i] = new MemberSignature(methods[i]); } - Arrays.sort(methSigs, new Comparator() { - public int compare(Object o1, Object o2) { - MemberSignature ms1 = (MemberSignature) o1; - MemberSignature ms2 = (MemberSignature) o2; + Arrays.sort(methSigs, new Comparator() { + public int compare(MemberSignature ms1, MemberSignature ms2) { int comp = ms1.name.compareTo(ms2.name); if (comp == 0) { comp = ms1.signature.compareTo(ms2.signature); @@ -1859,7 +1852,7 @@ public class ObjectStreamClass implements Serializable { keys = new long[nfields]; offsets = new int[nfields]; typeCodes = new char[nfields]; - ArrayList typeList = new ArrayList(); + ArrayList> typeList = new ArrayList>(); for (int i = 0; i < nfields; i++) { ObjectStreamField f = fields[i]; @@ -1873,7 +1866,7 @@ public class ObjectStreamClass implements Serializable { } } - types = (Class[]) typeList.toArray(new Class[typeList.size()]); + types = typeList.toArray(new Class[typeList.size()]); numPrimFields = nfields - types.length; } diff --git a/src/share/classes/java/lang/Class.java b/src/share/classes/java/lang/Class.java index 6d878c56e7862e96521b9a7dfa40d005ec50274d..632ddb6ed0e3bb72de10ffe608ad8f3a3e447eca 100644 --- a/src/share/classes/java/lang/Class.java +++ b/src/share/classes/java/lang/Class.java @@ -345,9 +345,9 @@ public final // since we have to do the security check here anyway // (the stack depth is wrong for the Constructor's // security check to work) - java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction() { - public Object run() { + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Void run() { c.setAccessible(true); return null; } @@ -1302,10 +1302,10 @@ public final // out anything other than public members and (2) public member access // has already been ok'd by the SecurityManager. - Class[] result = (Class[]) java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction() { - public Object run() { - java.util.List list = new java.util.ArrayList(); + return java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Class[] run() { + List list = new ArrayList(); Class currentClass = Class.this; while (currentClass != null) { Class[] members = currentClass.getDeclaredClasses(); @@ -1316,12 +1316,9 @@ public final } currentClass = currentClass.getSuperclass(); } - Class[] empty = {}; - return list.toArray(empty); + return list.toArray(new Class[0]); } }); - - return result; } @@ -2215,15 +2212,15 @@ public final // Caches for certain reflective results private static boolean useCaches = true; - private volatile transient SoftReference declaredFields; - private volatile transient SoftReference publicFields; - private volatile transient SoftReference declaredMethods; - private volatile transient SoftReference publicMethods; - private volatile transient SoftReference declaredConstructors; - private volatile transient SoftReference publicConstructors; + private volatile transient SoftReference declaredFields; + private volatile transient SoftReference publicFields; + private volatile transient SoftReference declaredMethods; + private volatile transient SoftReference publicMethods; + private volatile transient SoftReference[]> declaredConstructors; + private volatile transient SoftReference[]> publicConstructors; // Intermediate results for getFields and getMethods - private volatile transient SoftReference declaredPublicFields; - private volatile transient SoftReference declaredPublicMethods; + private volatile transient SoftReference declaredPublicFields; + private volatile transient SoftReference declaredPublicMethods; // Incremented by the VM on each call to JVM TI RedefineClasses() // that redefines this class or a superclass. @@ -2295,11 +2292,11 @@ public final clearCachesOnClassRedefinition(); if (publicOnly) { if (declaredPublicFields != null) { - res = (Field[]) declaredPublicFields.get(); + res = declaredPublicFields.get(); } } else { if (declaredFields != null) { - res = (Field[]) declaredFields.get(); + res = declaredFields.get(); } } if (res != null) return res; @@ -2308,9 +2305,9 @@ public final res = Reflection.filterFields(this, getDeclaredFields0(publicOnly)); if (useCaches) { if (publicOnly) { - declaredPublicFields = new SoftReference(res); + declaredPublicFields = new SoftReference(res); } else { - declaredFields = new SoftReference(res); + declaredFields = new SoftReference(res); } } return res; @@ -2319,22 +2316,22 @@ public final // Returns an array of "root" fields. These Field objects must NOT // be propagated to the outside world, but must instead be copied // via ReflectionFactory.copyField. - private Field[] privateGetPublicFields(Set traversedInterfaces) { + private Field[] privateGetPublicFields(Set> traversedInterfaces) { checkInitted(); Field[] res = null; if (useCaches) { clearCachesOnClassRedefinition(); if (publicFields != null) { - res = (Field[]) publicFields.get(); + res = publicFields.get(); } if (res != null) return res; } // No cached value available; compute value recursively. // Traverse in correct order for getField(). - List fields = new ArrayList(); + List fields = new ArrayList(); if (traversedInterfaces == null) { - traversedInterfaces = new HashSet(); + traversedInterfaces = new HashSet>(); } // Local fields @@ -2342,9 +2339,7 @@ public final addAll(fields, tmp); // Direct superinterfaces, recursively - Class[] interfaces = getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - Class c = interfaces[i]; + for (Class c : getInterfaces()) { if (!traversedInterfaces.contains(c)) { traversedInterfaces.add(c); addAll(fields, c.privateGetPublicFields(traversedInterfaces)); @@ -2353,7 +2348,7 @@ public final // Direct superclass, recursively if (!isInterface()) { - Class c = getSuperclass(); + Class c = getSuperclass(); if (c != null) { addAll(fields, c.privateGetPublicFields(traversedInterfaces)); } @@ -2362,12 +2357,12 @@ public final res = new Field[fields.size()]; fields.toArray(res); if (useCaches) { - publicFields = new SoftReference(res); + publicFields = new SoftReference(res); } return res; } - private static void addAll(Collection c, Field[] o) { + private static void addAll(Collection c, Field[] o) { for (int i = 0; i < o.length; i++) { c.add(o[i]); } @@ -2383,18 +2378,18 @@ public final // Returns an array of "root" constructors. These Constructor // objects must NOT be propagated to the outside world, but must // instead be copied via ReflectionFactory.copyConstructor. - private Constructor[] privateGetDeclaredConstructors(boolean publicOnly) { + private Constructor[] privateGetDeclaredConstructors(boolean publicOnly) { checkInitted(); - Constructor[] res = null; + Constructor[] res = null; if (useCaches) { clearCachesOnClassRedefinition(); if (publicOnly) { if (publicConstructors != null) { - res = (Constructor[]) publicConstructors.get(); + res = publicConstructors.get(); } } else { if (declaredConstructors != null) { - res = (Constructor[]) declaredConstructors.get(); + res = declaredConstructors.get(); } } if (res != null) return res; @@ -2407,9 +2402,9 @@ public final } if (useCaches) { if (publicOnly) { - publicConstructors = new SoftReference(res); + publicConstructors = new SoftReference[]>(res); } else { - declaredConstructors = new SoftReference(res); + declaredConstructors = new SoftReference[]>(res); } } return res; @@ -2431,11 +2426,11 @@ public final clearCachesOnClassRedefinition(); if (publicOnly) { if (declaredPublicMethods != null) { - res = (Method[]) declaredPublicMethods.get(); + res = declaredPublicMethods.get(); } } else { if (declaredMethods != null) { - res = (Method[]) declaredMethods.get(); + res = declaredMethods.get(); } } if (res != null) return res; @@ -2444,9 +2439,9 @@ public final res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly)); if (useCaches) { if (publicOnly) { - declaredPublicMethods = new SoftReference(res); + declaredPublicMethods = new SoftReference(res); } else { - declaredMethods = new SoftReference(res); + declaredMethods = new SoftReference(res); } } return res; @@ -2552,7 +2547,7 @@ public final if (useCaches) { clearCachesOnClassRedefinition(); if (publicMethods != null) { - res = (Method[]) publicMethods.get(); + res = publicMethods.get(); } if (res != null) return res; } @@ -2602,7 +2597,7 @@ public final methods.compactAndTrim(); res = methods.getArray(); if (useCaches) { - publicMethods = new SoftReference(res); + publicMethods = new SoftReference(res); } return res; } @@ -2713,11 +2708,11 @@ public final private Constructor getConstructor0(Class[] parameterTypes, int which) throws NoSuchMethodException { - Constructor[] constructors = privateGetDeclaredConstructors((which == Member.PUBLIC)); - for (int i = 0; i < constructors.length; i++) { + Constructor[] constructors = privateGetDeclaredConstructors((which == Member.PUBLIC)); + for (Constructor constructor : constructors) { if (arrayContentsEq(parameterTypes, - constructors[i].getParameterTypes())) { - return getReflectionFactory().copyConstructor(constructors[i]); + constructor.getParameterTypes())) { + return getReflectionFactory().copyConstructor(constructor); } } throw new NoSuchMethodException(getName() + "." + argumentTypesToString(parameterTypes)); @@ -2767,18 +2762,18 @@ public final return out; } - private static Constructor[] copyConstructors(Constructor[] arg) { - Constructor[] out = new Constructor[arg.length]; + private static Constructor[] copyConstructors(Constructor[] arg) { + Constructor[] out = arg.clone(); ReflectionFactory fact = getReflectionFactory(); - for (int i = 0; i < arg.length; i++) { - out[i] = fact.copyConstructor(arg[i]); + for (int i = 0; i < out.length; i++) { + out[i] = fact.copyConstructor(out[i]); } return out; } private native Field[] getDeclaredFields0(boolean publicOnly); private native Method[] getDeclaredMethods0(boolean publicOnly); - private native Constructor[] getDeclaredConstructors0(boolean publicOnly); + private native Constructor[] getDeclaredConstructors0(boolean publicOnly); private native Class[] getDeclaredClasses0(); private static String argumentTypesToString(Class[] argTypes) { @@ -2883,7 +2878,7 @@ public final // Fetches the factory for reflective objects private static ReflectionFactory getReflectionFactory() { if (reflectionFactory == null) { - reflectionFactory = (ReflectionFactory) + reflectionFactory = java.security.AccessController.doPrivileged (new sun.reflect.ReflectionFactory.GetReflectionFactoryAction()); } @@ -2895,8 +2890,8 @@ public final private static boolean initted = false; private static void checkInitted() { if (initted) return; - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { // Tests to ensure the system properties table is fully // initialized. This is needed because reflection code is // called very early in the initialization process (before @@ -2941,17 +2936,17 @@ public final /** * Returns the elements of this enum class or null if this * Class object does not represent an enum type; - * identical to getEnumConstantsShared except that - * the result is uncloned, cached, and shared by all callers. + * identical to getEnumConstants except that the result is + * uncloned, cached, and shared by all callers. */ T[] getEnumConstantsShared() { if (enumConstants == null) { if (!isEnum()) return null; try { final Method values = getMethod("values"); - java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction() { - public Object run() { + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Void run() { values.setAccessible(true); return null; } diff --git a/src/share/classes/java/lang/ClassLoader.java b/src/share/classes/java/lang/ClassLoader.java index 391354ec38b568655f9f9c7c1a04b6cdbc0b5ee7..1b188e23f7cd0abc09a12e3bc0ab3418d45c760d 100644 --- a/src/share/classes/java/lang/ClassLoader.java +++ b/src/share/classes/java/lang/ClassLoader.java @@ -39,6 +39,7 @@ import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.security.ProtectionDomain; +import java.security.cert.Certificate; import java.util.Enumeration; import java.util.Hashtable; import java.util.HashMap; @@ -172,17 +173,18 @@ public abstract class ClassLoader { private ClassLoader parent; // Hashtable that maps packages to certs - private Hashtable package2certs = new Hashtable(11); + private Hashtable package2certs + = new Hashtable(11); // Shared among all packages with unsigned classes - java.security.cert.Certificate[] nocerts; + Certificate[] nocerts; // The classes loaded by this class loader. The only purpose of this table // is to keep the classes from being GC'ed until the loader is GC'ed. - private Vector classes = new Vector(); + private Vector> classes = new Vector>(); // The initiating protection domains for all classes loaded by this loader - private Set domains = new HashSet(); + private Set domains = new HashSet(); // Invoked by the VM to record every loaded class with this loader. void addClass(Class c) { @@ -191,7 +193,7 @@ public abstract class ClassLoader { // The packages defined in this class loader. Each package name is mapped // to its corresponding Package object. - private HashMap packages = new HashMap(); + private HashMap packages = new HashMap(); /** * Creates a new class loader using the specified parent class loader for @@ -342,8 +344,8 @@ public abstract class ClassLoader { final String name = cls.getName(); final int i = name.lastIndexOf('.'); if (i != -1) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { sm.checkPackageAccess(name.substring(0, i)); return null; } @@ -524,17 +526,20 @@ public abstract class ClassLoader { // Class format error - try to transform the bytecode and // define the class again // - Object[] transformers = ClassFileTransformer.getTransformers(); + ClassFileTransformer[] transformers = ClassFileTransformer.getTransformers(); Class c = null; - for (int i = 0; transformers != null && i < transformers.length; i++) { - try { - // Transform byte code using transformer - byte[] tb = ((ClassFileTransformer) transformers[i]).transform(b, off, len); - c = defineClass1(name, tb, 0, tb.length, protectionDomain, source); - break; - } catch (ClassFormatError cfe2) { - // If ClassFormatError occurs, try next transformer + if (transformers != null) { + for (ClassFileTransformer transformer : transformers) { + try { + // Transform byte code using transformer + byte[] tb = transformer.transform(b, off, len); + c = defineClass1(name, tb, 0, tb.length, + protectionDomain, source); + break; + } catch (ClassFormatError cfe2) { + // If ClassFormatError occurs, try next transformer + } } } @@ -550,7 +555,7 @@ public abstract class ClassLoader { private void postDefineClass(Class c, ProtectionDomain protectionDomain) { if (protectionDomain.getCodeSource() != null) { - java.security.cert.Certificate certs[] = + Certificate certs[] = protectionDomain.getCodeSource().getCertificates(); if (certs != null) setSigners(c, certs); @@ -767,8 +772,7 @@ public abstract class ClassLoader { private synchronized void checkCerts(String name, CodeSource cs) { int i = name.lastIndexOf('.'); String pname = (i == -1) ? "" : name.substring(0, i); - java.security.cert.Certificate[] pcerts = - (java.security.cert.Certificate[]) package2certs.get(pname); + Certificate[] pcerts = package2certs.get(pname); if (pcerts == null) { // first class in this package gets to define which // certificates must be the same for all other classes @@ -778,12 +782,12 @@ public abstract class ClassLoader { } if (pcerts == null) { if (nocerts == null) - nocerts = new java.security.cert.Certificate[0]; + nocerts = new Certificate[0]; pcerts = nocerts; } package2certs.put(pname, pcerts); } else { - java.security.cert.Certificate[] certs = null; + Certificate[] certs = null; if (cs != null) { certs = cs.getCertificates(); } @@ -799,8 +803,8 @@ public abstract class ClassLoader { * check to make sure the certs for the new class (certs) are the same as * the certs for the first class inserted in the package (pcerts) */ - private boolean compareCerts(java.security.cert.Certificate[] pcerts, - java.security.cert.Certificate[] certs) + private boolean compareCerts(Certificate[] pcerts, + Certificate[] certs) { // certs can be null, indicating no certs. if ((certs == null) || (certs.length == 0)) { @@ -1031,7 +1035,7 @@ public abstract class ClassLoader { } tmp[1] = findResources(name); - return new CompoundEnumeration(tmp); + return new CompoundEnumeration(tmp); } /** @@ -1068,7 +1072,7 @@ public abstract class ClassLoader { * @since 1.2 */ protected Enumeration findResources(String name) throws IOException { - return new CompoundEnumeration(new Enumeration[0]); + return java.util.Collections.emptyEnumeration(); } /** @@ -1134,13 +1138,13 @@ public abstract class ClassLoader { /** * Find resources from the VM's built-in classloader. */ - private static Enumeration getBootstrapResources(String name) + private static Enumeration getBootstrapResources(String name) throws IOException { - final Enumeration e = getBootstrapClassPath().getResources(name); - return new Enumeration () { - public Object nextElement() { - return ((Resource)e.nextElement()).getURL(); + final Enumeration e = getBootstrapClassPath().getResources(name); + return new Enumeration () { + public URL nextElement() { + return e.nextElement().getURL(); } public boolean hasMoreElements() { return e.hasMoreElements(); @@ -1323,9 +1327,8 @@ public abstract class ClassLoader { Throwable oops = null; scl = l.getClassLoader(); try { - PrivilegedExceptionAction a; - a = new SystemClassLoaderAction(scl); - scl = (ClassLoader) AccessController.doPrivileged(a); + scl = AccessController.doPrivileged( + new SystemClassLoaderAction(scl)); } catch (PrivilegedActionException pae) { oops = pae.getCause(); if (oops instanceof InvocationTargetException) { @@ -1456,7 +1459,7 @@ public abstract class ClassLoader { */ protected Package getPackage(String name) { synchronized (packages) { - Package pkg = (Package)packages.get(name); + Package pkg = packages.get(name); if (pkg == null) { if (parent != null) { pkg = parent.getPackage(name); @@ -1481,9 +1484,9 @@ public abstract class ClassLoader { * @since 1.2 */ protected Package[] getPackages() { - Map map; + Map map; synchronized (packages) { - map = (Map)packages.clone(); + map = new HashMap(packages); } Package[] pkgs; if (parent != null) { @@ -1499,7 +1502,7 @@ public abstract class ClassLoader { } } } - return (Package[])map.values().toArray(new Package[map.size()]); + return map.values().toArray(new Package[map.size()]); } @@ -1585,8 +1588,7 @@ public abstract class ClassLoader { // Invoked in the VM to determine the context class in // JNI_Load/JNI_Unload static Class getFromClass() { - return ((NativeLibrary) - (ClassLoader.nativeLibraryContext.peek())).fromClass; + return ClassLoader.nativeLibraryContext.peek().fromClass; } } @@ -1597,22 +1599,27 @@ public abstract class ClassLoader { // Returns (and initializes) the default domain. private synchronized ProtectionDomain getDefaultDomain() { if (defaultDomain == null) { - CodeSource cs = - new CodeSource(null, (java.security.cert.Certificate[]) null); + CodeSource cs = new CodeSource(null, (Certificate[]) null); defaultDomain = new ProtectionDomain(cs, null, this, null); } return defaultDomain; } // All native library names we've loaded. - private static Vector loadedLibraryNames = new Vector(); + private static Vector loadedLibraryNames + = new Vector(); + // Native libraries belonging to system classes. - private static Vector systemNativeLibraries = new Vector(); + private static Vector systemNativeLibraries + = new Vector(); + // Native libraries associated with the class loader. - private Vector nativeLibraries = new Vector(); + private Vector nativeLibraries + = new Vector(); // native libraries being loaded/unloaded. - private static Stack nativeLibraryContext = new Stack(); + private static Stack nativeLibraryContext + = new Stack(); // The paths searched for libraries static private String usr_paths[]; @@ -1699,13 +1706,13 @@ public abstract class ClassLoader { } private static boolean loadLibrary0(Class fromClass, final File file) { - Boolean exists = (Boolean) - AccessController.doPrivileged(new PrivilegedAction() { + boolean exists = AccessController.doPrivileged( + new PrivilegedAction() { public Object run() { - return new Boolean(file.exists()); - } - }); - if (!exists.booleanValue()) { + return file.exists() ? Boolean.TRUE : null; + }}) + != null; + if (!exists) { return false; } String name; @@ -1716,12 +1723,12 @@ public abstract class ClassLoader { } ClassLoader loader = (fromClass == null) ? null : fromClass.getClassLoader(); - Vector libs = + Vector libs = loader != null ? loader.nativeLibraries : systemNativeLibraries; synchronized (libs) { int size = libs.size(); for (int i = 0; i < size; i++) { - NativeLibrary lib = (NativeLibrary)libs.elementAt(i); + NativeLibrary lib = libs.elementAt(i); if (name.equals(lib.name)) { return true; } @@ -1748,8 +1755,7 @@ public abstract class ClassLoader { */ int n = nativeLibraryContext.size(); for (int i = 0; i < n; i++) { - NativeLibrary lib = (NativeLibrary) - nativeLibraryContext.elementAt(i); + NativeLibrary lib = nativeLibraryContext.elementAt(i); if (name.equals(lib.name)) { if (loader == lib.fromClass.getClassLoader()) { return true; @@ -1780,12 +1786,12 @@ public abstract class ClassLoader { // Invoked in the VM class linking code. static long findNative(ClassLoader loader, String name) { - Vector libs = + Vector libs = loader != null ? loader.nativeLibraries : systemNativeLibraries; synchronized (libs) { int size = libs.size(); for (int i = 0; i < size; i++) { - NativeLibrary lib = (NativeLibrary)libs.elementAt(i); + NativeLibrary lib = libs.elementAt(i); long entry = lib.find(name); if (entry != 0) return entry; @@ -1805,13 +1811,13 @@ public abstract class ClassLoader { // is null then we are delegating assertion status queries to the VM, i.e., // none of this ClassLoader's assertion status modification methods have // been invoked. - private Map packageAssertionStatus = null; + private Map packageAssertionStatus = null; // Maps String fullyQualifiedClassName to Boolean assertionStatus If this // field is null then we are delegating assertion status queries to the VM, // i.e., none of this ClassLoader's assertion status modification methods // have been invoked. - Map classAssertionStatus = null; + Map classAssertionStatus = null; /** * Sets the default assertion status for this class loader. This setting @@ -1878,7 +1884,7 @@ public abstract class ClassLoader { if (packageAssertionStatus == null) initializeJavaAssertionMaps(); - packageAssertionStatus.put(packageName, Boolean.valueOf(enabled)); + packageAssertionStatus.put(packageName, enabled); } /** @@ -1909,7 +1915,7 @@ public abstract class ClassLoader { if (classAssertionStatus == null) initializeJavaAssertionMaps(); - classAssertionStatus.put(className, Boolean.valueOf(enabled)); + classAssertionStatus.put(className, enabled); } /** @@ -1927,8 +1933,8 @@ public abstract class ClassLoader { * Whether or not "Java assertion maps" are initialized, set * them to empty maps, effectively ignoring any present settings. */ - classAssertionStatus = new HashMap(); - packageAssertionStatus = new HashMap(); + classAssertionStatus = new HashMap(); + packageAssertionStatus = new HashMap(); defaultAssertionStatus = false; } @@ -1962,20 +1968,20 @@ public abstract class ClassLoader { // assert packageAssertionStatus != null; // Check for a class entry - result = (Boolean)classAssertionStatus.get(className); + result = classAssertionStatus.get(className); if (result != null) return result.booleanValue(); // Check for most specific package entry int dotIndex = className.lastIndexOf("."); if (dotIndex < 0) { // default package - result = (Boolean)packageAssertionStatus.get(null); + result = packageAssertionStatus.get(null); if (result != null) return result.booleanValue(); } while(dotIndex > 0) { className = className.substring(0, dotIndex); - result = (Boolean)packageAssertionStatus.get(className); + result = packageAssertionStatus.get(className); if (result != null) return result.booleanValue(); dotIndex = className.lastIndexOf(".", dotIndex-1); @@ -1989,17 +1995,17 @@ public abstract class ClassLoader { private void initializeJavaAssertionMaps() { // assert Thread.holdsLock(this); - classAssertionStatus = new HashMap(); - packageAssertionStatus = new HashMap(); + classAssertionStatus = new HashMap(); + packageAssertionStatus = new HashMap(); AssertionStatusDirectives directives = retrieveDirectives(); for(int i = 0; i < directives.classes.length; i++) classAssertionStatus.put(directives.classes[i], - Boolean.valueOf(directives.classEnabled[i])); + directives.classEnabled[i]); for(int i = 0; i < directives.packages.length; i++) packageAssertionStatus.put(directives.packages[i], - Boolean.valueOf(directives.packageEnabled[i])); + directives.packageEnabled[i]); defaultAssertionStatus = directives.deflt; } @@ -2009,28 +2015,24 @@ public abstract class ClassLoader { } -class SystemClassLoaderAction implements PrivilegedExceptionAction { +class SystemClassLoaderAction + implements PrivilegedExceptionAction { private ClassLoader parent; SystemClassLoaderAction(ClassLoader parent) { this.parent = parent; } - public Object run() throws Exception { - ClassLoader sys; - Constructor ctor; - Class c; - Class cp[] = { ClassLoader.class }; - Object params[] = { parent }; - + public ClassLoader run() throws Exception { String cls = System.getProperty("java.system.class.loader"); if (cls == null) { return parent; } - c = Class.forName(cls, true, parent); - ctor = c.getDeclaredConstructor(cp); - sys = (ClassLoader) ctor.newInstance(params); + Constructor ctor = Class.forName(cls, true, parent) + .getDeclaredConstructor(new Class[] { ClassLoader.class }); + ClassLoader sys = (ClassLoader) ctor.newInstance( + new Object[] { parent }); Thread.currentThread().setContextClassLoader(sys); return sys; } diff --git a/src/share/classes/java/lang/Compiler.java b/src/share/classes/java/lang/Compiler.java index 5c2ab73db28f1c621a23de94053840d5cf2d1f74..85219174d7ff68855dfeb90c4ddd831cd657acaa 100644 --- a/src/share/classes/java/lang/Compiler.java +++ b/src/share/classes/java/lang/Compiler.java @@ -53,9 +53,9 @@ public final class Compiler { static { registerNatives(); - java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction() { - public Object run() { + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Void run() { boolean loaded = false; String jit = System.getProperty("java.compiler"); if ((jit != null) && (!jit.equals("NONE")) && diff --git a/src/share/classes/java/lang/Long.java b/src/share/classes/java/lang/Long.java index 271fd1c02c8d5914717b823d2d144f132986bc99..2f0f172698efce051cc0ecd74dab0321cb358ed0 100644 --- a/src/share/classes/java/lang/Long.java +++ b/src/share/classes/java/lang/Long.java @@ -650,7 +650,7 @@ public final class Long extends Number implements Comparable { try { result = Long.valueOf(nm.substring(index), radix); - result = negative ? new Long((long)-result.longValue()) : result; + result = negative ? new Long(-result.longValue()) : result; } catch (NumberFormatException e) { // If number is Long.MIN_VALUE, we'll end up here. The next line // handles this case, and causes any genuine format error to be diff --git a/src/share/classes/java/lang/Package.java b/src/share/classes/java/lang/Package.java index 80af5d9bc46fe6d85268c2cd6d18f7781ed6bec2..0d8779b61470ebab927e31480a11e0557ffda4c3 100644 --- a/src/share/classes/java/lang/Package.java +++ b/src/share/classes/java/lang/Package.java @@ -507,7 +507,7 @@ public class Package implements java.lang.reflect.AnnotatedElement { */ static Package getSystemPackage(String name) { synchronized (pkgs) { - Package pkg = (Package)pkgs.get(name); + Package pkg = pkgs.get(name); if (pkg == null) { name = name.replace('.', '/').concat("/"); String fn = getSystemPackage0(name); @@ -529,18 +529,18 @@ public class Package implements java.lang.reflect.AnnotatedElement { for (int i = 0; i < names.length; i++) { defineSystemPackage(names[i], getSystemPackage0(names[i])); } - return (Package[])pkgs.values().toArray(new Package[pkgs.size()]); + return pkgs.values().toArray(new Package[pkgs.size()]); } } private static Package defineSystemPackage(final String iname, final String fn) { - return (Package) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged(new PrivilegedAction() { + public Package run() { String name = iname; // Get the cached code source url for the file name - URL url = (URL)urls.get(fn); + URL url = urls.get(fn); if (url == null) { // URL not found, so create one File file = new File(fn); @@ -559,7 +559,7 @@ public class Package implements java.lang.reflect.AnnotatedElement { // Convert to "."-separated package name name = name.substring(0, name.length() - 1).replace('/', '.'); Package pkg; - Manifest man = (Manifest)mans.get(fn); + Manifest man = mans.get(fn); if (man != null) { pkg = new Package(name, man, url, null); } else { @@ -588,13 +588,16 @@ public class Package implements java.lang.reflect.AnnotatedElement { } // The map of loaded system packages - private static Map pkgs = new HashMap(31); + private static Map pkgs + = new HashMap(31); // Maps each directory or zip file name to its corresponding url - private static Map urls = new HashMap(10); + private static Map urls + = new HashMap(10); // Maps each code source url for a jar file to its manifest - private static Map mans = new HashMap(10); + private static Map mans + = new HashMap(10); private static native String getSystemPackage0(String name); private static native String[] getSystemPackages0(); diff --git a/src/share/classes/java/lang/Process.java b/src/share/classes/java/lang/Process.java index fe4045ab25f7020e67559db2524178544aaf74f6..88010fd555ddbb2878f91341903bb9d777b36afa 100644 --- a/src/share/classes/java/lang/Process.java +++ b/src/share/classes/java/lang/Process.java @@ -41,18 +41,24 @@ import java.io.*; *

The methods that create processes may not work well for special * processes on certain native platforms, such as native windowing * processes, daemon processes, Win16/DOS processes on Microsoft - * Windows, or shell scripts. The created subprocess does not have - * its own terminal or console. All its standard I/O (i.e. stdin, - * stdout, stderr) operations will be redirected to the parent process - * through three streams - * ({@link #getOutputStream()}, - * {@link #getInputStream()}, - * {@link #getErrorStream()}). + * Windows, or shell scripts. + * + *

By default, the created subprocess does not have its own terminal + * or console. All its standard I/O (i.e. stdin, stdout, stderr) + * operations will be redirected to the parent process, where they can + * be accessed via the streams obtained using the methods + * {@link #getOutputStream()}, + * {@link #getInputStream()}, and + * {@link #getErrorStream()}. * The parent process uses these streams to feed input to and get output * from the subprocess. Because some native platforms only provide * limited buffer size for standard input and output streams, failure * to promptly write the input stream or read the output stream of - * the subprocess may cause the subprocess to block, and even deadlock. + * the subprocess may cause the subprocess to block, or even deadlock. + * + *

Where desired, + * subprocess I/O can also be redirected + * using methods of the {@link ProcessBuilder} class. * *

The subprocess is not killed when there are no more references to * the {@code Process} object, but rather the subprocess @@ -62,16 +68,22 @@ import java.io.*; * Process} object execute asynchronously or concurrently with respect * to the Java process that owns the {@code Process} object. * - * @author unascribed - * @see ProcessBuilder + *

As of 1.5, {@link ProcessBuilder#start()} is the preferred way + * to create a {@code Process}. + * * @since JDK1.0 */ public abstract class Process { /** * Returns the output stream connected to the normal input of the * subprocess. Output to the stream is piped into the standard - * input stream of the process represented by this {@code Process} - * object. + * input of the process represented by this {@code Process} object. + * + *

If the standard input of the subprocess has been redirected using + * {@link ProcessBuilder#redirectInput(Redirect) + * ProcessBuilder.redirectInput} + * then this method will return a + * null output stream. * *

Implementation note: It is a good idea for the returned * output stream to be buffered. @@ -84,30 +96,47 @@ public abstract class Process { /** * Returns the input stream connected to the normal output of the * subprocess. The stream obtains data piped from the standard - * output stream of the process represented by this {@code - * Process} object. + * output of the process represented by this {@code Process} object. + * + *

If the standard output of the subprocess has been redirected using + * {@link ProcessBuilder#redirectOutput(Redirect) + * ProcessBuilder.redirectOutput} + * then this method will return a + * null input stream. + * + *

Otherwise, if the standard error of the subprocess has been + * redirected using + * {@link ProcessBuilder#redirectErrorStream(boolean) + * ProcessBuilder.redirectErrorStream} + * then the input stream returned by this method will receive the + * merged standard output and the standard error of the subprocess. * *

Implementation note: It is a good idea for the returned * input stream to be buffered. * * @return the input stream connected to the normal output of the * subprocess - * @see ProcessBuilder#redirectErrorStream() */ abstract public InputStream getInputStream(); /** - * Returns the input stream connected to the error output stream of - * the subprocess. The stream obtains data piped from the error - * output stream of the process represented by this {@code Process} - * object. + * Returns the input stream connected to the error output of the + * subprocess. The stream obtains data piped from the error output + * of the process represented by this {@code Process} object. + * + *

If the standard error of the subprocess has been redirected using + * {@link ProcessBuilder#redirectError(Redirect) + * ProcessBuilder.redirectError} or + * {@link ProcessBuilder#redirectErrorStream(boolean) + * ProcessBuilder.redirectErrorStream} + * then this method will return a + * null input stream. * *

Implementation note: It is a good idea for the returned * input stream to be buffered. * - * @return the input stream connected to the error output stream of + * @return the input stream connected to the error output of * the subprocess - * @see ProcessBuilder#redirectErrorStream() */ abstract public InputStream getErrorStream(); diff --git a/src/share/classes/java/lang/ProcessBuilder.java b/src/share/classes/java/lang/ProcessBuilder.java index 32895a5baab3b86dfe99aed0a4b2fa3835c6c7ae..be24e8d8235414a8080d275810425e7f18fa767e 100644 --- a/src/share/classes/java/lang/ProcessBuilder.java +++ b/src/share/classes/java/lang/ProcessBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -27,6 +27,10 @@ package java.lang; import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.FileOutputStream; +import java.util.Arrays; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -34,7 +38,7 @@ import java.util.Map; /** * This class is used to create operating system processes. * - *

Each ProcessBuilder instance manages a collection + *

Each {@code ProcessBuilder} instance manages a collection * of process attributes. The {@link #start()} method creates a new * {@link Process} instance with those attributes. The {@link * #start()} method can be invoked repeatedly from the same instance @@ -59,19 +63,64 @@ import java.util.Map; * *

  • a working directory. The default value is the current * working directory of the current process, usually the directory - * named by the system property user.dir. + * named by the system property {@code user.dir}. + * + *
  • a source of standard input. + * By default, the subprocess reads input from a pipe. Java code + * can access this pipe via the output stream returned by + * {@link Process#getOutputStream()}. However, standard input may + * be redirected to another source using + * {@link #redirectInput(Redirect) redirectInput}. + * In this case, {@link Process#getOutputStream()} will return a + * null output stream, for which: + * + *
      + *
    • the {@link OutputStream#write(int) write} methods always + * throw {@code IOException} + *
    • the {@link OutputStream#close() close} method does nothing + *
    + * + *
  • a destination for standard output + * and standard error. By default, the subprocess writes standard + * output and standard error to pipes. Java code can access these pipes + * via the input streams returned by {@link Process#getInputStream()} and + * {@link Process#getErrorStream()}. However, standard output and + * standard error may be redirected to other destinations using + * {@link #redirectOutput(Redirect) redirectOutput} and + * {@link #redirectError(Redirect) redirectError}. + * In this case, {@link Process#getInputStream()} and/or + * {@link Process#getErrorStream()} will return a null input + * stream, for which: + * + *
      + *
    • the {@link InputStream#read() read} methods always return + * {@code -1} + *
    • the {@link InputStream#available() available} method always returns + * {@code 0} + *
    • the {@link InputStream#close() close} method does nothing + *
    * *
  • a redirectErrorStream property. Initially, this property - * is false, meaning that the standard output and error + * is {@code false}, meaning that the standard output and error * output of a subprocess are sent to two separate streams, which can * be accessed using the {@link Process#getInputStream()} and {@link - * Process#getErrorStream()} methods. If the value is set to - * true, the standard error is merged with the standard - * output. This makes it easier to correlate error messages with the - * corresponding output. In this case, the merged data can be read - * from the stream returned by {@link Process#getInputStream()}, while - * reading from the stream returned by {@link - * Process#getErrorStream()} will get an immediate end of file. + * Process#getErrorStream()} methods. + * + *

    If the value is set to {@code true}, then: + * + *

    * * * @@ -87,34 +136,43 @@ import java.util.Map; * is invoked. * *

    Note that this class is not synchronized. - * If multiple threads access a ProcessBuilder instance + * If multiple threads access a {@code ProcessBuilder} instance * concurrently, and at least one of the threads modifies one of the * attributes structurally, it must be synchronized externally. * *

    Starting a new process which uses the default working directory * and environment is easy: * - *

    + * 
     {@code
      * Process p = new ProcessBuilder("myCommand", "myArg").start();
    - * 
    + * } * *

    Here is an example that starts a process with a modified working - * directory and environment: + * directory and environment, and redirects standard output and error + * to be appended to a log file: * - *

    - * ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
    - * Map<String, String> env = pb.environment();
    + * 
     {@code
    + * ProcessBuilder pb =
    + *   new ProcessBuilder("myCommand", "myArg1", "myArg2");
    + * Map env = pb.environment();
      * env.put("VAR1", "myValue");
      * env.remove("OTHERVAR");
      * env.put("VAR2", env.get("VAR1") + "suffix");
      * pb.directory(new File("myDir"));
    + * File log = new File("log");
    + * pb.redirectErrorStream(true);
    + * pb.redirectOutput(Redirect.appendTo(log));
      * Process p = pb.start();
    - * 
    + * assert pb.redirectInput() == Redirect.PIPE; + * assert pb.redirectOutput().file() == log; + * assert p.getInputStream().read() == -1; + * } * *

    To start a process with an explicit set of environment * variables, first call {@link java.util.Map#clear() Map.clear()} * before adding environment variables. * + * @author Martin Buchholz * @since 1.5 */ @@ -124,20 +182,19 @@ public final class ProcessBuilder private File directory; private Map environment; private boolean redirectErrorStream; + private Redirect[] redirects; /** * Constructs a process builder with the specified operating * system program and arguments. This constructor does not - * make a copy of the command list. Subsequent + * make a copy of the {@code command} list. Subsequent * updates to the list will be reflected in the state of the * process builder. It is not checked whether - * command corresponds to a valid operating system - * command.

    - * - * @param command The list containing the program and its arguments + * {@code command} corresponds to a valid operating system + * command. * - * @throws NullPointerException - * If the argument is null + * @param command the list containing the program and its arguments + * @throws NullPointerException if the argument is null */ public ProcessBuilder(List command) { if (command == null) @@ -149,12 +206,12 @@ public final class ProcessBuilder * Constructs a process builder with the specified operating * system program and arguments. This is a convenience * constructor that sets the process builder's command to a string - * list containing the same strings as the command + * list containing the same strings as the {@code command} * array, in the same order. It is not checked whether - * command corresponds to a valid operating system - * command.

    + * {@code command} corresponds to a valid operating system + * command. * - * @param command A string array containing the program and its arguments + * @param command a string array containing the program and its arguments */ public ProcessBuilder(String... command) { this.command = new ArrayList(command.length); @@ -165,16 +222,15 @@ public final class ProcessBuilder /** * Sets this process builder's operating system program and * arguments. This method does not make a copy of the - * command list. Subsequent updates to the list will + * {@code command} list. Subsequent updates to the list will * be reflected in the state of the process builder. It is not - * checked whether command corresponds to a valid - * operating system command.

    + * checked whether {@code command} corresponds to a valid + * operating system command. * - * @param command The list containing the program and its arguments - * @return This process builder + * @param command the list containing the program and its arguments + * @return this process builder * - * @throws NullPointerException - * If the argument is null + * @throws NullPointerException if the argument is null */ public ProcessBuilder command(List command) { if (command == null) @@ -187,12 +243,12 @@ public final class ProcessBuilder * Sets this process builder's operating system program and * arguments. This is a convenience method that sets the command * to a string list containing the same strings as the - * command array, in the same order. It is not - * checked whether command corresponds to a valid - * operating system command.

    + * {@code command} array, in the same order. It is not + * checked whether {@code command} corresponds to a valid + * operating system command. * - * @param command A string array containing the program and its arguments - * @return This process builder + * @param command a string array containing the program and its arguments + * @return this process builder */ public ProcessBuilder command(String... command) { this.command = new ArrayList(command.length); @@ -205,9 +261,9 @@ public final class ProcessBuilder * Returns this process builder's operating system program and * arguments. The returned list is not a copy. Subsequent * updates to the list will be reflected in the state of this - * process builder.

    + * process builder. * - * @return This process builder's program and its arguments + * @return this process builder's program and its arguments */ public List command() { return command; @@ -225,10 +281,10 @@ public final class ProcessBuilder *

    The returned object may be modified using ordinary {@link * java.util.Map Map} operations. These modifications will be * visible to subprocesses started via the {@link #start()} - * method. Two ProcessBuilder instances always + * method. Two {@code ProcessBuilder} instances always * contain independent process environments, so changes to the * returned map will never be reflected in any other - * ProcessBuilder instance or the values returned by + * {@code ProcessBuilder} instance or the values returned by * {@link System#getenv System.getenv}. * *

    If the system does not support environment variables, an @@ -262,25 +318,24 @@ public final class ProcessBuilder *

    The returned map is typically case-sensitive on all platforms. * *

    If a security manager exists, its - * {@link SecurityManager#checkPermission checkPermission} - * method is called with a - * {@link RuntimePermission}("getenv.*") - * permission. This may result in a {@link SecurityException} being - * thrown. + * {@link SecurityManager#checkPermission checkPermission} method + * is called with a + * {@link RuntimePermission}{@code ("getenv.*")} permission. + * This may result in a {@link SecurityException} being thrown. * *

    When passing information to a Java subprocess, * system properties - * are generally preferred over environment variables.

    + * are generally preferred over environment variables. * - * @return This process builder's environment + * @return this process builder's environment * - * @throws SecurityException - * If a security manager exists and its - * {@link SecurityManager#checkPermission checkPermission} - * method doesn't allow access to the process environment + * @throws SecurityException + * if a security manager exists and its + * {@link SecurityManager#checkPermission checkPermission} + * method doesn't allow access to the process environment * - * @see Runtime#exec(String[],String[],java.io.File) - * @see System#getenv() + * @see Runtime#exec(String[],String[],java.io.File) + * @see System#getenv() */ public Map environment() { SecurityManager security = System.getSecurityManager(); @@ -328,12 +383,12 @@ public final class ProcessBuilder * * Subprocesses subsequently started by this object's {@link * #start()} method will use this as their working directory. - * The returned value may be null -- this means to use + * The returned value may be {@code null} -- this means to use * the working directory of the current Java process, usually the - * directory named by the system property user.dir, - * as the working directory of the child process.

    + * directory named by the system property {@code user.dir}, + * as the working directory of the child process. * - * @return This process builder's working directory + * @return this process builder's working directory */ public File directory() { return directory; @@ -344,50 +399,522 @@ public final class ProcessBuilder * * Subprocesses subsequently started by this object's {@link * #start()} method will use this as their working directory. - * The argument may be null -- this means to use the + * The argument may be {@code null} -- this means to use the * working directory of the current Java process, usually the - * directory named by the system property user.dir, - * as the working directory of the child process.

    + * directory named by the system property {@code user.dir}, + * as the working directory of the child process. * - * @param directory The new working directory - * @return This process builder + * @param directory the new working directory + * @return this process builder */ public ProcessBuilder directory(File directory) { this.directory = directory; return this; } + // ---------------- I/O Redirection ---------------- + + /** + * Implements a null input stream. + */ + static class NullInputStream extends InputStream { + public int read() { return -1; } + public int available() { return 0; } + } + + /** + * Implements a null output stream. + */ + static class NullOutputStream extends OutputStream { + public void write(int b) throws IOException { + throw new IOException("Stream closed"); + } + } + + /** + * Represents a source of subprocess input or a destination of + * subprocess output. + * + * Each {@code Redirect} instance is one of the following: + * + *
      + *
    • the special value {@link #PIPE Redirect.PIPE} + *
    • the special value {@link #INHERIT Redirect.INHERIT} + *
    • a redirection to read from a file, created by an invocation of + * {@link Redirect#from Redirect.from(File)} + *
    • a redirection to write to a file, created by an invocation of + * {@link Redirect#to Redirect.to(File)} + *
    • a redirection to append to a file, created by an invocation of + * {@link Redirect#appendTo Redirect.appendTo(File)} + *
    + * + *

    Each of the above categories has an associated unique + * {@link Type Type}. + * + * @since 1.7 + */ + public static abstract class Redirect { + /** + * The type of a {@link Redirect}. + */ + public enum Type { + /** + * The type of {@link Redirect#PIPE Redirect.PIPE}. + */ + PIPE, + + /** + * The type of {@link Redirect#INHERIT Redirect.INHERIT}. + */ + INHERIT, + + /** + * The type of redirects returned from + * {@link Redirect#from Redirect.from(File)}. + */ + READ, + + /** + * The type of redirects returned from + * {@link Redirect#to Redirect.to(File)}. + */ + WRITE, + + /** + * The type of redirects returned from + * {@link Redirect#appendTo Redirect.appendTo(File)}. + */ + APPEND + }; + + /** + * Returns the type of this {@code Redirect}. + * @return the type of this {@code Redirect} + */ + public abstract Type type(); + + /** + * Indicates that subprocess I/O will be connected to the + * current Java process over a pipe. + * + * This is the default handling of subprocess standard I/O. + * + *

    It will always be true that + *

     {@code
    +         * Redirect.PIPE.file() == null &&
    +         * Redirect.PIPE.type() == Redirect.Type.PIPE
    +         * }
    + */ + public static final Redirect PIPE = new Redirect() { + public Type type() { return Type.PIPE; } + public String toString() { return type().toString(); }}; + + /** + * Indicates that subprocess I/O source or destination will be the + * same as those of the current process. This is the normal + * behavior of most operating system command interpreters (shells). + * + *

    It will always be true that + *

     {@code
    +         * Redirect.INHERIT.file() == null &&
    +         * Redirect.INHERIT.type() == Redirect.Type.INHERIT
    +         * }
    + */ + public static final Redirect INHERIT = new Redirect() { + public Type type() { return Type.INHERIT; } + public String toString() { return type().toString(); }}; + + /** + * Returns the {@link File} source or destination associated + * with this redirect, or {@code null} if there is no such file. + * + * @return the file associated with this redirect, + * or {@code null} if there is no such file + */ + public File file() { return null; } + + FileOutputStream toFileOutputStream() throws IOException { + throw new UnsupportedOperationException(); + } + + /** + * Returns a redirect to read from the specified file. + * + *

    It will always be true that + *

     {@code
    +         * Redirect.from(file).file() == file &&
    +         * Redirect.from(file).type() == Redirect.Type.READ
    +         * }
    + * + * @throws NullPointerException if the specified file is null + * @return a redirect to read from the specified file + */ + public static Redirect from(final File file) { + if (file == null) + throw new NullPointerException(); + return new Redirect() { + public Type type() { return Type.READ; } + public File file() { return file; } + public String toString() { + return "redirect to read from file \"" + file + "\""; + } + }; + } + + /** + * Returns a redirect to write to the specified file. + * If the specified file exists when the subprocess is started, + * its previous contents will be discarded. + * + *

    It will always be true that + *

     {@code
    +         * Redirect.to(file).file() == file &&
    +         * Redirect.to(file).type() == Redirect.Type.WRITE
    +         * }
    + * + * @throws NullPointerException if the specified file is null + * @return a redirect to write to the specified file + */ + public static Redirect to(final File file) { + if (file == null) + throw new NullPointerException(); + return new Redirect() { + public Type type() { return Type.WRITE; } + public File file() { return file; } + public String toString() { + return "redirect to write to file \"" + file + "\""; + } + FileOutputStream toFileOutputStream() throws IOException { + return new FileOutputStream(file, false); + } + }; + } + + /** + * Returns a redirect to append to the specified file. + * Each write operation first advances the position to the + * end of the file and then writes the requested data. + * Whether the advancement of the position and the writing + * of the data are done in a single atomic operation is + * system-dependent and therefore unspecified. + * + *

    It will always be true that + *

     {@code
    +         * Redirect.appendTo(file).file() == file &&
    +         * Redirect.appendTo(file).type() == Redirect.Type.APPEND
    +         * }
    + * + * @throws NullPointerException if the specified file is null + * @return a redirect to append to the specified file + */ + public static Redirect appendTo(final File file) { + if (file == null) + throw new NullPointerException(); + return new Redirect() { + public Type type() { return Type.APPEND; } + public File file() { return file; } + public String toString() { + return "redirect to append to file \"" + file + "\""; + } + FileOutputStream toFileOutputStream() throws IOException { + return new FileOutputStream(file, true); + } + }; + } + + /** + * Compares the specified object with this {@code Redirect} for + * equality. Returns {@code true} if and only if the two + * objects are identical or both objects are {@code Redirect} + * instances of the same type associated with non-null equal + * {@code File} instances. + */ + public boolean equals(Object obj) { + if (obj == this) + return true; + if (! (obj instanceof Redirect)) + return false; + Redirect r = (Redirect) obj; + if (r.type() != this.type()) + return false; + assert this.file() != null; + return this.file().equals(r.file()); + } + + /** + * Returns a hash code value for this {@code Redirect}. + * @return a hash code value for this {@code Redirect} + */ + public int hashCode() { + File file = file(); + if (file == null) + return super.hashCode(); + else + return file.hashCode(); + } + + /** + * No public constructors. Clients must use predefined + * static {@code Redirect} instances or factory methods. + */ + private Redirect() {} + } + + private Redirect[] redirects() { + if (redirects == null) + redirects = new Redirect[] { + Redirect.PIPE, Redirect.PIPE, Redirect.PIPE + }; + return redirects; + } + + /** + * Sets this process builder's standard input source. + * + * Subprocesses subsequently started by this object's {@link #start()} + * method obtain their standard input from this source. + * + *

    If the source is {@link Redirect#PIPE Redirect.PIPE} + * (the initial value), then the standard input of a + * subprocess can be written to using the output stream + * returned by {@link Process#getOutputStream()}. + * If the source is set to any other value, then + * {@link Process#getOutputStream()} will return a + * null output stream. + * + * @param source the new standard input source + * @return this process builder + * @throws IllegalArgumentException + * if the redirect does not correspond to a valid source + * of data, that is, has type + * {@link Redirect.Type#WRITE WRITE} or + * {@link Redirect.Type#APPEND APPEND} + * @since 1.7 + */ + public ProcessBuilder redirectInput(Redirect source) { + if (source.type() == Redirect.Type.WRITE || + source.type() == Redirect.Type.APPEND) + throw new IllegalArgumentException( + "Redirect invalid for reading: " + source); + redirects()[0] = source; + return this; + } + + /** + * Sets this process builder's standard output destination. + * + * Subprocesses subsequently started by this object's {@link #start()} + * method send their standard output to this destination. + * + *

    If the destination is {@link Redirect#PIPE Redirect.PIPE} + * (the initial value), then the standard output of a subprocess + * can be read using the input stream returned by {@link + * Process#getInputStream()}. + * If the destination is set to any other value, then + * {@link Process#getInputStream()} will return a + * null input stream. + * + * @param destination the new standard output destination + * @return this process builder + * @throws IllegalArgumentException + * if the redirect does not correspond to a valid + * destination of data, that is, has type + * {@link Redirect.Type#READ READ} + * @since 1.7 + */ + public ProcessBuilder redirectOutput(Redirect destination) { + if (destination.type() == Redirect.Type.READ) + throw new IllegalArgumentException( + "Redirect invalid for writing: " + destination); + redirects()[1] = destination; + return this; + } + + /** + * Sets this process builder's standard error destination. + * + * Subprocesses subsequently started by this object's {@link #start()} + * method send their standard error to this destination. + * + *

    If the destination is {@link Redirect#PIPE Redirect.PIPE} + * (the initial value), then the error output of a subprocess + * can be read using the input stream returned by {@link + * Process#getErrorStream()}. + * If the destination is set to any other value, then + * {@link Process#getErrorStream()} will return a + * null input stream. + * + *

    If the {@link #redirectErrorStream redirectErrorStream} + * attribute has been set {@code true}, then the redirection set + * by this method has no effect. + * + * @param destination the new standard error destination + * @return this process builder + * @throws IllegalArgumentException + * if the redirect does not correspond to a valid + * destination of data, that is, has type + * {@link Redirect.Type#READ READ} + * @since 1.7 + */ + public ProcessBuilder redirectError(Redirect destination) { + if (destination.type() == Redirect.Type.READ) + throw new IllegalArgumentException( + "Redirect invalid for writing: " + destination); + redirects()[2] = destination; + return this; + } + + /** + * Sets this process builder's standard input source to a file. + * + *

    This is a convenience method. An invocation of the form + * {@code redirectInput(file)} + * behaves in exactly the same way as the invocation + * {@link #redirectInput(Redirect) redirectInput} + * {@code (Redirect.from(file))}. + * + * @param file the new standard input source + * @return this process builder + * @since 1.7 + */ + public ProcessBuilder redirectInput(File file) { + return redirectInput(Redirect.from(file)); + } + + /** + * Sets this process builder's standard output destination to a file. + * + *

    This is a convenience method. An invocation of the form + * {@code redirectOutput(file)} + * behaves in exactly the same way as the invocation + * {@link #redirectOutput(Redirect) redirectOutput} + * {@code (Redirect.to(file))}. + * + * @param file the new standard output destination + * @return this process builder + * @since 1.7 + */ + public ProcessBuilder redirectOutput(File file) { + return redirectOutput(Redirect.to(file)); + } + + /** + * Sets this process builder's standard error destination to a file. + * + *

    This is a convenience method. An invocation of the form + * {@code redirectError(file)} + * behaves in exactly the same way as the invocation + * {@link #redirectError(Redirect) redirectError} + * {@code (Redirect.to(file))}. + * + * @param file the new standard error destination + * @return this process builder + * @since 1.7 + */ + public ProcessBuilder redirectError(File file) { + return redirectError(Redirect.to(file)); + } + + /** + * Returns this process builder's standard input source. + * + * Subprocesses subsequently started by this object's {@link #start()} + * method obtain their standard input from this source. + * The initial value is {@link Redirect#PIPE Redirect.PIPE}. + * + * @return this process builder's standard input source + * @since 1.7 + */ + public Redirect redirectInput() { + return (redirects == null) ? Redirect.PIPE : redirects[0]; + } + + /** + * Returns this process builder's standard output destination. + * + * Subprocesses subsequently started by this object's {@link #start()} + * method redirect their standard output to this destination. + * The initial value is {@link Redirect#PIPE Redirect.PIPE}. + * + * @return this process builder's standard output destination + * @since 1.7 + */ + public Redirect redirectOutput() { + return (redirects == null) ? Redirect.PIPE : redirects[1]; + } + + /** + * Returns this process builder's standard error destination. + * + * Subprocesses subsequently started by this object's {@link #start()} + * method redirect their standard error to this destination. + * The initial value is {@link Redirect#PIPE Redirect.PIPE}. + * + * @return this process builder's standard error destination + * @since 1.7 + */ + public Redirect redirectError() { + return (redirects == null) ? Redirect.PIPE : redirects[2]; + } + + /** + * Sets the source and destination for subprocess standard I/O + * to be the same as those of the current Java process. + * + *

    This is a convenience method. An invocation of the form + *

     {@code
    +     * pb.inheritIO()
    +     * }
    + * behaves in exactly the same way as the invocation + *
     {@code
    +     * pb.redirectInput(Redirect.INHERIT)
    +     *   .redirectOutput(Redirect.INHERIT)
    +     *   .redirectError(Redirect.INHERIT)
    +     * }
    + * + * This gives behavior equivalent to most operating system + * command interpreters, or the standard C library function + * {@code system()}. + * + * @return this process builder + * @since 1.7 + */ + public ProcessBuilder inheritIO() { + Arrays.fill(redirects(), Redirect.INHERIT); + return this; + } + /** * Tells whether this process builder merges standard error and * standard output. * - *

    If this property is true, then any error output + *

    If this property is {@code true}, then any error output * generated by subprocesses subsequently started by this object's * {@link #start()} method will be merged with the standard * output, so that both can be read using the * {@link Process#getInputStream()} method. This makes it easier * to correlate error messages with the corresponding output. - * The initial value is false.

    + * The initial value is {@code false}. * - * @return This process builder's redirectErrorStream property + * @return this process builder's {@code redirectErrorStream} property */ public boolean redirectErrorStream() { return redirectErrorStream; } /** - * Sets this process builder's redirectErrorStream property. + * Sets this process builder's {@code redirectErrorStream} property. * - *

    If this property is true, then any error output + *

    If this property is {@code true}, then any error output * generated by subprocesses subsequently started by this object's * {@link #start()} method will be merged with the standard * output, so that both can be read using the * {@link Process#getInputStream()} method. This makes it easier * to correlate error messages with the corresponding output. - * The initial value is false.

    + * The initial value is {@code false}. * - * @param redirectErrorStream The new property value - * @return This process builder + * @param redirectErrorStream the new property value + * @return this process builder */ public ProcessBuilder redirectErrorStream(boolean redirectErrorStream) { this.redirectErrorStream = redirectErrorStream; @@ -410,7 +937,7 @@ public final class ProcessBuilder *

    If there is a security manager, its * {@link SecurityManager#checkExec checkExec} * method is called with the first component of this object's - * command array as its argument. This may result in + * {@code command} array as its argument. This may result in * a {@link SecurityException} being thrown. * *

    Starting an operating system process is highly system-dependent. @@ -426,26 +953,42 @@ public final class ProcessBuilder * subclass of {@link IOException}. * *

    Subsequent modifications to this process builder will not - * affect the returned {@link Process}.

    + * affect the returned {@link Process}. + * + * @return a new {@link Process} object for managing the subprocess + * + * @throws NullPointerException + * if an element of the command list is null + * + * @throws IndexOutOfBoundsException + * if the command is an empty list (has size {@code 0}) + * + * @throws SecurityException + * if a security manager exists and + *
      * - * @return A new {@link Process} object for managing the subprocess + *
    • its + * {@link SecurityManager#checkExec checkExec} + * method doesn't allow creation of the subprocess, or * - * @throws NullPointerException - * If an element of the command list is null + *
    • the standard input to the subprocess was + * {@linkplain #redirectInput redirected from a file} + * and the security manager's + * {@link SecurityManager#checkRead checkRead} method + * denies read access to the file, or * - * @throws IndexOutOfBoundsException - * If the command is an empty list (has size 0) + *
    • the standard output or standard error of the + * subprocess was + * {@linkplain #redirectOutput redirected to a file} + * and the security manager's + * {@link SecurityManager#checkWrite checkWrite} method + * denies write access to the file * - * @throws SecurityException - * If a security manager exists and its - * {@link SecurityManager#checkExec checkExec} - * method doesn't allow creation of the subprocess + *
    * - * @throws IOException - * If an I/O error occurs + * @throws IOException if an I/O error occurs * - * @see Runtime#exec(String[], String[], java.io.File) - * @see SecurityManager#checkExec(String) + * @see Runtime#exec(String[], String[], java.io.File) */ public Process start() throws IOException { // Must convert to array first -- a malicious user-supplied @@ -467,6 +1010,7 @@ public final class ProcessBuilder return ProcessImpl.start(cmdarray, environment, dir, + redirects, redirectErrorStream); } catch (IOException e) { // It's much easier for us to create a high-quality error diff --git a/src/share/classes/java/lang/StringCoding.java b/src/share/classes/java/lang/StringCoding.java index 7eb302130d19b362f17ba8ba29b78a11f416a4b0..f9d8ef3e66be3f3181d4eb332179258ce343cfaf 100644 --- a/src/share/classes/java/lang/StringCoding.java +++ b/src/share/classes/java/lang/StringCoding.java @@ -53,22 +53,23 @@ class StringCoding { private StringCoding() { } - /* The cached coders for each thread - */ - private static ThreadLocal decoder = new ThreadLocal(); - private static ThreadLocal encoder = new ThreadLocal(); + /** The cached coders for each thread */ + private final static ThreadLocal> decoder = + new ThreadLocal>(); + private final static ThreadLocal> encoder = + new ThreadLocal>(); private static boolean warnUnsupportedCharset = true; - private static Object deref(ThreadLocal tl) { - SoftReference sr = (SoftReference)tl.get(); + private static T deref(ThreadLocal> tl) { + SoftReference sr = tl.get(); if (sr == null) return null; return sr.get(); } - private static void set(ThreadLocal tl, Object ob) { - tl.set(new SoftReference(ob)); + private static void set(ThreadLocal> tl, T ob) { + tl.set(new SoftReference(ob)); } // Trim the given byte array to the given length @@ -174,7 +175,7 @@ class StringCoding { static char[] decode(String charsetName, byte[] ba, int off, int len) throws UnsupportedEncodingException { - StringDecoder sd = (StringDecoder)deref(decoder); + StringDecoder sd = deref(decoder); String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; if ((sd == null) || !(csn.equals(sd.requestedCharsetName()) || csn.equals(sd.charsetName()))) { @@ -193,8 +194,7 @@ class StringCoding { static char[] decode(Charset cs, byte[] ba, int off, int len) { StringDecoder sd = new StringDecoder(cs, cs.name()); - byte[] b = Arrays.copyOf(ba, ba.length); - return sd.decode(b, off, len); + return sd.decode(Arrays.copyOfRange(ba, off, off + len), 0, len); } static char[] decode(byte[] ba, int off, int len) { @@ -273,7 +273,7 @@ class StringCoding { static byte[] encode(String charsetName, char[] ca, int off, int len) throws UnsupportedEncodingException { - StringEncoder se = (StringEncoder)deref(encoder); + StringEncoder se = deref(encoder); String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; if ((se == null) || !(csn.equals(se.requestedCharsetName()) || csn.equals(se.charsetName()))) { @@ -292,8 +292,7 @@ class StringCoding { static byte[] encode(Charset cs, char[] ca, int off, int len) { StringEncoder se = new StringEncoder(cs, cs.name()); - char[] c = Arrays.copyOf(ca, ca.length); - return se.encode(c, off, len); + return se.encode(Arrays.copyOfRange(ca, off, off + len), 0, len); } static byte[] encode(char[] ca, int off, int len) { diff --git a/src/share/classes/java/lang/instrument/Instrumentation.java b/src/share/classes/java/lang/instrument/Instrumentation.java index 7e97b09f1347e073f67724773e514fb8c307fd34..b77baa31897789071bcf111b96f31dbacdc052a3 100644 --- a/src/share/classes/java/lang/instrument/Instrumentation.java +++ b/src/share/classes/java/lang/instrument/Instrumentation.java @@ -636,7 +636,11 @@ public interface Instrumentation { * @param transformer * The ClassFileTransformer which wraps using this prefix. * @param prefix - * The prefix which has been applied to wrapped native methods. + * The prefix to apply to wrapped native methods when + * retrying a failed native method resolution. If prefix + * is either null or the empty string, then + * failed native method resolutions are not retried for + * this transformer. * @throws java.lang.NullPointerException if passed a null transformer. * @throws java.lang.UnsupportedOperationException if the current configuration of * the JVM does not allow setting a native method prefix diff --git a/src/share/classes/java/lang/management/ClassLoadingMXBean.java b/src/share/classes/java/lang/management/ClassLoadingMXBean.java index 62f31e48769baaa94cc75f01b3026d5fd3211c35..762e14cb2f552984699f9187f2ca761fc3f87246 100644 --- a/src/share/classes/java/lang/management/ClassLoadingMXBean.java +++ b/src/share/classes/java/lang/management/ClassLoadingMXBean.java @@ -35,7 +35,7 @@ package java.lang.management; * that can be obtained by calling * the {@link ManagementFactory#getClassLoadingMXBean} method or * from the {@link ManagementFactory#getPlatformMBeanServer - * platform MBeanServer} method. + * platform MBeanServer}. * *

    The ObjectName for uniquely identifying the MXBean for * the class loading system within an MBeanServer is: @@ -44,6 +44,10 @@ package java.lang.management; * java.lang:type=ClassLoading} * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see * JMX Specification. * @see @@ -52,7 +56,7 @@ package java.lang.management; * @author Mandy Chung * @since 1.5 */ -public interface ClassLoadingMXBean { +public interface ClassLoadingMXBean extends PlatformManagedObject { /** * Returns the total number of classes that have been loaded since diff --git a/src/share/classes/java/lang/management/CompilationMXBean.java b/src/share/classes/java/lang/management/CompilationMXBean.java index 94f97bb450746848b9bd50f0747a4b43bdbfd21b..ea93a2b0ccb7376271c7b213b170751826dea56f 100644 --- a/src/share/classes/java/lang/management/CompilationMXBean.java +++ b/src/share/classes/java/lang/management/CompilationMXBean.java @@ -44,6 +44,10 @@ package java.lang.management; * java.lang:type=Compilation} * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see * JMX Specification. * @see @@ -52,7 +56,7 @@ package java.lang.management; * @author Mandy Chung * @since 1.5 */ -public interface CompilationMXBean { +public interface CompilationMXBean extends PlatformManagedObject { /** * Returns the name of the Just-in-time (JIT) compiler. * diff --git a/src/share/classes/java/lang/management/GarbageCollectorMXBean.java b/src/share/classes/java/lang/management/GarbageCollectorMXBean.java index f737a9c2ec50044f66c2b41fb148c7de14d9c127..50ee93d8d79e847f013808e9609a0238c16aff5e 100644 --- a/src/share/classes/java/lang/management/GarbageCollectorMXBean.java +++ b/src/share/classes/java/lang/management/GarbageCollectorMXBean.java @@ -48,9 +48,13 @@ package java.lang.management; * java.lang:type=GarbageCollector},name=collector's name * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * * A platform usually includes additional platform-dependent information * specific to a garbage collection algorithm for monitoring. * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see MemoryMXBean * * @see diff --git a/src/share/classes/java/lang/management/ManagementFactory.java b/src/share/classes/java/lang/management/ManagementFactory.java index dff4f19a4e3b901d7ca80f03007949c8d598e33b..c9e12708ef87374a2e9fc9e00e5573f7a98d3971 100644 --- a/src/share/classes/java/lang/management/ManagementFactory.java +++ b/src/share/classes/java/lang/management/ManagementFactory.java @@ -24,17 +24,31 @@ */ package java.lang.management; +import javax.management.DynamicMBean; import javax.management.MBeanServer; import javax.management.MBeanServerConnection; +import javax.management.MBeanServerFactory; import javax.management.MBeanServerPermission; +import javax.management.NotificationEmitter; +import javax.management.ObjectInstance; import javax.management.ObjectName; +import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.MalformedObjectNameException; +import javax.management.MBeanRegistrationException; +import javax.management.NotCompliantMBeanException; +import javax.management.StandardEmitterMBean; +import javax.management.StandardMBean; +import java.util.Collections; +import java.util.ArrayList; import java.util.List; import java.security.AccessController; import java.security.Permission; import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import javax.management.JMX; +import sun.management.ManagementFactoryHelper; /** * The ManagementFactory class is a factory class for getting @@ -49,13 +63,16 @@ import javax.management.JMX; *

      *
    • Direct access to an MXBean interface *
        - *
      1. Get the MXBean instance through the static factory method + *
      2. Get the MXBean instance through the static factory method, + * or the {@link #getPlatformMXBeans(Class)} method * and access the MXBean locally of the running * virtual machine. *
      3. *
      4. Construct an MXBean proxy instance that forwards the * method calls to a given {@link MBeanServer MBeanServer} by calling - * {@link #newPlatformMXBeanProxy newPlatfromMXBeanProxy}. + * the {@link #newPlatformMXBeanProxy newPlatformMXBeanProxy} method + * or the {@link #getPlatformMXBeans(MBeanServerConnection, Class)} + * method. * A proxy is typically constructed to remotely access * an MXBean of another running virtual machine. *
      5. @@ -83,6 +100,10 @@ import javax.management.JMX; * a set of basic data types described below. * See
        * the specification of MXBeans for details. + * All platform MXBean interfaces extend {@link PlatformManagedObject}s + * and new methods may be added in these interfaces + * in future Java SE releases. + *

        * A JMX management application and the platform MBeanServer * can interoperate without requiring classes for MXBean specific * data types. @@ -191,7 +212,10 @@ import javax.management.JMX; *

        MXBean Names

        * Each platform MXBean for a Java virtual machine has a unique * {@link javax.management.ObjectName ObjectName} for - * registration in the platform MBeanServer. + * registration in the platform MBeanServer that can + * be obtained by calling the {@link PlatformManagedObject#getObjectName} + * method. + * * A Java virtual machine has a single instance of the following management * interfaces: * @@ -275,7 +299,7 @@ import javax.management.JMX; * * * @see - * JMX Specification. + * JMX Specification * @see * Ways to Access Management Metrics * @see java.util.logging.LoggingMXBean @@ -368,7 +392,7 @@ public class ManagementFactory { * the Java virtual machine. */ public static ClassLoadingMXBean getClassLoadingMXBean() { - return sun.management.ManagementFactory.getClassLoadingMXBean(); + return ManagementFactoryHelper.getClassLoadingMXBean(); } /** @@ -378,7 +402,7 @@ public class ManagementFactory { * @return a {@link MemoryMXBean} object for the Java virtual machine. */ public static MemoryMXBean getMemoryMXBean() { - return sun.management.ManagementFactory.getMemoryMXBean(); + return ManagementFactoryHelper.getMemoryMXBean(); } /** @@ -388,7 +412,7 @@ public class ManagementFactory { * @return a {@link ThreadMXBean} object for the Java virtual machine. */ public static ThreadMXBean getThreadMXBean() { - return sun.management.ManagementFactory.getThreadMXBean(); + return ManagementFactoryHelper.getThreadMXBean(); } /** @@ -399,7 +423,7 @@ public class ManagementFactory { */ public static RuntimeMXBean getRuntimeMXBean() { - return sun.management.ManagementFactory.getRuntimeMXBean(); + return ManagementFactoryHelper.getRuntimeMXBean(); } /** @@ -412,7 +436,7 @@ public class ManagementFactory { * no compilation system. */ public static CompilationMXBean getCompilationMXBean() { - return sun.management.ManagementFactory.getCompilationMXBean(); + return ManagementFactoryHelper.getCompilationMXBean(); } /** @@ -423,7 +447,7 @@ public class ManagementFactory { * the Java virtual machine. */ public static OperatingSystemMXBean getOperatingSystemMXBean() { - return sun.management.ManagementFactory.getOperatingSystemMXBean(); + return ManagementFactoryHelper.getOperatingSystemMXBean(); } /** @@ -436,7 +460,7 @@ public class ManagementFactory { * */ public static List getMemoryPoolMXBeans() { - return sun.management.ManagementFactory.getMemoryPoolMXBeans(); + return ManagementFactoryHelper.getMemoryPoolMXBeans(); } /** @@ -449,7 +473,7 @@ public class ManagementFactory { * */ public static List getMemoryManagerMXBeans() { - return sun.management.ManagementFactory.getMemoryManagerMXBeans(); + return ManagementFactoryHelper.getMemoryManagerMXBeans(); } @@ -465,7 +489,7 @@ public class ManagementFactory { * */ public static List getGarbageCollectorMXBeans() { - return sun.management.ManagementFactory.getGarbageCollectorMXBeans(); + return ManagementFactoryHelper.getGarbageCollectorMXBeans(); } private static MBeanServer platformMBeanServer; @@ -518,8 +542,25 @@ public class ManagementFactory { } if (platformMBeanServer == null) { - platformMBeanServer = - sun.management.ManagementFactory.createPlatformMBeanServer(); + platformMBeanServer = MBeanServerFactory.createMBeanServer(); + for (PlatformComponent pc : PlatformComponent.values()) { + List list = + pc.getMXBeans(pc.getMXBeanInterface()); + for (PlatformManagedObject o : list) { + // Each PlatformComponent represents one management + // interface. Some MXBean may extend another one. + // The MXBean instances for one platform component + // (returned by pc.getMXBeans()) might be also + // the MXBean instances for another platform component. + // e.g. com.sun.management.GarbageCollectorMXBean + // + // So need to check if an MXBean instance is registered + // before registering into the platform MBeanServer + if (!platformMBeanServer.isRegistered(o.getObjectName())) { + addMXBean(platformMBeanServer, o); + } + } + } } return platformMBeanServer; } @@ -657,6 +698,136 @@ public class ManagementFactory { } } + /** + * Returns the list of platform MXBeans that implement + * the given {@code mxbeanInterface} in the running Java + * virtual machine. + * The returned list may contain zero, one, or more instances. + * The number of instances in the returned list is defined + * in the specification of the given management interface. + * + * @param mxbeanInterface a management interface for a platform + * MXBean + * + * @return the list of platform MXBeans that implements + * {@code mxbeanInterface}. + * + * @throws IllegalArgumentException if {@code mxbeanInterface} + * is not a management interface for the platform. + * + * @since 1.7 + */ + public static List + getPlatformMXBeans(Class mxbeanInterface) { + String className = mxbeanInterface.getName(); + for (PlatformComponent component: PlatformComponent.values()) { + // comparing the class name first instead of the Class instance + // to avoid causing unnecessary class loading of + // the other MXBean interfaces + if (className.equals(component.getMXBeanInterfaceName())) { + if (component.getMXBeanInterface() == mxbeanInterface) { + return component.getMXBeans(mxbeanInterface); + } + } + } + throw new IllegalArgumentException(mxbeanInterface.getName() + + " is not implemented by any of the platform MXBeans."); + } + + /** + * Returns the list of the platform MXBean proxies for + * forwarding the method calls of the {@code mxbeanInterface} + * through the given {@code MBeanServerConnection}. + * The returned list may contain zero, one, or more instances. + * The number of instances in the returned list is defined + * in the specification of the given management interface. + * + * @param connection the {@code MBeanServerConnection} to forward to. + * @param mxbeanInterface a management interface for a platform + * MXBean + * + * @return the list of platform MXBean proxies for + * forwarding the method calls of the {@code mxbeanInterface} + * through the given {@code MBeanServerConnection}. + * + * @throws IllegalArgumentException if {@code mxbeanInterface} + * is not a management interface for the platform. + * + * @throws java.io.IOException if a communication problem + * occurred when accessing the {@code MBeanServerConnection}. + * + * @since 1.7 + */ + public static + List getPlatformMXBeans(MBeanServerConnection connection, + Class mxbeanInterface) + throws java.io.IOException + { + String className = mxbeanInterface.getName(); + for (PlatformComponent component: PlatformComponent.values()) { + // comparing the class name first instead of the Class instance + // to avoid causing unnecessary class loading of + // the other MXBean interfaces + if (className.equals(component.getMXBeanInterfaceName())) { + if (component.getMXBeanInterface() == mxbeanInterface) { + return component.getMXBeans(connection, + mxbeanInterface); + } + } + } + throw new IllegalArgumentException(mxbeanInterface.getName() + + " is not implemented by any of the platform MXBeans."); + } + + /** + * Returns a list of {@code Class} objects, subinterface of + * {@link PlatformManagedObject}, representing + * all management interfaces for + * monitoring and managing the Java platform. + * + * @return a list of {@code Class} objects, subinterface of + * {@link PlatformManagedObject} representing + * the management interfaces for + * monitoring and managing the Java platform. + * + * @since 1.7 + */ + public static List> getAllPlatformMXBeanInterfaces() { + List> result = + new ArrayList>(); + for (PlatformComponent component: PlatformComponent.values()) { + result.add(component.getMXBeanInterface()); + } + return result; + } + private static final String NOTIF_EMITTER = "javax.management.NotificationEmitter"; + + /** + * Registers an MXBean. + */ + private static void addMXBean(final MBeanServer mbs, final PlatformManagedObject pmo) { + // Make DynamicMBean out of MXBean by wrapping it with a StandardMBean + final DynamicMBean dmbean; + if (pmo instanceof NotificationEmitter) { + dmbean = new StandardEmitterMBean(pmo, null, true, (NotificationEmitter) pmo); + } else { + dmbean = new StandardMBean(pmo, null, true); + } + + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Void run() throws InstanceAlreadyExistsException, + MBeanRegistrationException, + NotCompliantMBeanException { + mbs.registerMBean(dmbean, pmo.getObjectName()); + return null; + } + }); + } catch (PrivilegedActionException e) { + throw new RuntimeException(e.getException()); + } + } + } diff --git a/src/share/classes/java/lang/management/MemoryMXBean.java b/src/share/classes/java/lang/management/MemoryMXBean.java index cd277292f3f343d9322e6d653f6c05cabd81ec58..c789885b69ee5625224ef2279600f663039221e2 100644 --- a/src/share/classes/java/lang/management/MemoryMXBean.java +++ b/src/share/classes/java/lang/management/MemoryMXBean.java @@ -46,6 +46,9 @@ import javax.management.openmbean.CompositeData; * java.lang:type=Memory} * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * *

        Memory

        * The memory system of the Java virtual machine manages * the following kinds of memory: @@ -190,6 +193,7 @@ import javax.management.openmbean.CompositeData; * emitter.addNotificationListener(listener, null, null); * * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see * JMX Specification. * @see @@ -198,7 +202,7 @@ import javax.management.openmbean.CompositeData; * @author Mandy Chung * @since 1.5 */ -public interface MemoryMXBean { +public interface MemoryMXBean extends PlatformManagedObject { /** * Returns the approximate number of objects for which * finalization is pending. diff --git a/src/share/classes/java/lang/management/MemoryManagerMXBean.java b/src/share/classes/java/lang/management/MemoryManagerMXBean.java index 2407acaaea579b6d8f23ca853a7bc873da63a5c7..373520a41ecc3b913b71e6d38aa1dc6716243eef 100644 --- a/src/share/classes/java/lang/management/MemoryManagerMXBean.java +++ b/src/share/classes/java/lang/management/MemoryManagerMXBean.java @@ -45,6 +45,10 @@ package java.lang.management; * java.lang:type=MemoryManager},name=manager's name * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see MemoryMXBean * * @see @@ -55,7 +59,7 @@ package java.lang.management; * @author Mandy Chung * @since 1.5 */ -public interface MemoryManagerMXBean { +public interface MemoryManagerMXBean extends PlatformManagedObject { /** * Returns the name representing this memory manager. * diff --git a/src/share/classes/java/lang/management/MemoryPoolMXBean.java b/src/share/classes/java/lang/management/MemoryPoolMXBean.java index 8de391999648d4eb3fb426ab54475387924d3cc2..dca77b7c8b33dc7255746c33bdcf307826cf6cb2 100644 --- a/src/share/classes/java/lang/management/MemoryPoolMXBean.java +++ b/src/share/classes/java/lang/management/MemoryPoolMXBean.java @@ -46,6 +46,9 @@ package java.lang.management; * java.lang:type=MemoryPool},name=pool's name * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * *

        Memory Type

        *

        The Java virtual machine has a heap for object allocation and also * maintains non-heap memory for the method area and the Java virtual @@ -349,6 +352,7 @@ package java.lang.management; * described above for the usage threshold * in a similar fashion. * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see * JMX Specification. * @see @@ -357,7 +361,7 @@ package java.lang.management; * @author Mandy Chung * @since 1.5 */ -public interface MemoryPoolMXBean { +public interface MemoryPoolMXBean extends PlatformManagedObject { /** * Returns the name representing this memory pool. * diff --git a/src/share/classes/java/lang/management/OperatingSystemMXBean.java b/src/share/classes/java/lang/management/OperatingSystemMXBean.java index e7111201418c16008dce230873959b529532464b..c28769cf652949c64b3743cb0d969f54a2c90de2 100644 --- a/src/share/classes/java/lang/management/OperatingSystemMXBean.java +++ b/src/share/classes/java/lang/management/OperatingSystemMXBean.java @@ -44,10 +44,14 @@ package java.lang.management; * java.lang:type=OperatingSystem} * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * *

        This interface defines several convenient methods for accessing * system properties about the operating system on which the Java * virtual machine is running. * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see * JMX Specification. * @see @@ -56,7 +60,7 @@ package java.lang.management; * @author Mandy Chung * @since 1.5 */ -public interface OperatingSystemMXBean { +public interface OperatingSystemMXBean extends PlatformManagedObject { /** * Returns the operating system name. * This method is equivalent to System.getProperty("os.name"). diff --git a/src/share/classes/java/lang/management/PlatformComponent.java b/src/share/classes/java/lang/management/PlatformComponent.java new file mode 100644 index 0000000000000000000000000000000000000000..3cd5d369da4ec63e2ad3670a4152aee96ae858b6 --- /dev/null +++ b/src/share/classes/java/lang/management/PlatformComponent.java @@ -0,0 +1,382 @@ +/* + * Copyright 2008 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.lang.management; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.LoggingMXBean; +import java.util.logging.LogManager; +import javax.management.MBeanServerConnection; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; + +import com.sun.management.HotSpotDiagnosticMXBean; +import com.sun.management.UnixOperatingSystemMXBean; + +import sun.management.ManagementFactoryHelper; + +/** + * This enum class defines the list of platform components + * that provides monitoring and management support. + * Each enum represents one MXBean interface. A MXBean + * instance could implement one or more MXBean interfaces. + * + * For example, com.sun.management.GarbageCollectorMXBean + * extends java.lang.management.GarbageCollectorMXBean + * and there is one set of garbage collection MXBean instances, + * each of which implements both c.s.m. and j.l.m. interfaces. + * There are two separate enums GARBAGE_COLLECTOR + * and SUN_GARBAGE_COLLECTOR so that ManagementFactory.getPlatformMXBeans(Class) + * will return the list of MXBeans of the specified type. + * + * To add a new MXBean interface for the Java platform, + * add a new enum constant and implement the MXBeanFetcher. + */ +enum PlatformComponent { + + /** + * Class loading system of the Java virtual machine. + */ + CLASS_LOADING( + "java.lang.management.ClassLoadingMXBean", + "java.lang", "ClassLoading", defaultKeyProperties(), + new MXBeanFetcher() { + public List getMXBeans() { + return Collections.singletonList(ManagementFactoryHelper.getClassLoadingMXBean()); + } + }), + + /** + * Compilation system of the Java virtual machine. + */ + COMPILATION( + "java.lang.management.CompilationMXBean", + "java.lang", "Compilation", defaultKeyProperties(), + new MXBeanFetcher() { + public List getMXBeans() { + CompilationMXBean m = ManagementFactoryHelper.getCompilationMXBean(); + if (m == null) { + return Collections.emptyList(); + } else { + return Collections.singletonList(m); + } + } + }), + + /** + * Memory system of the Java virtual machine. + */ + MEMORY( + "java.lang.management.MemoryMXBean", + "java.lang", "Memory", defaultKeyProperties(), + new MXBeanFetcher() { + public List getMXBeans() { + return Collections.singletonList(ManagementFactoryHelper.getMemoryMXBean()); + } + }), + + /** + * Garbage Collector in the Java virtual machine. + */ + GARBAGE_COLLECTOR( + "java.lang.management.GarbageCollectorMXBean", + "java.lang", "GarbageCollector", keyProperties("name"), + new MXBeanFetcher() { + public List getMXBeans() { + return ManagementFactoryHelper. + getGarbageCollectorMXBeans(); + } + }), + + /** + * Memory manager in the Java virtual machine. + */ + MEMORY_MANAGER( + "java.lang.management.MemoryManagerMXBean", + "java.lang", "MemoryManager", keyProperties("name"), + new MXBeanFetcher() { + public List getMXBeans() { + return ManagementFactoryHelper.getMemoryManagerMXBeans(); + } + }, + GARBAGE_COLLECTOR), + + /** + * Memory pool in the Java virtual machine. + */ + MEMORY_POOL( + "java.lang.management.MemoryPoolMXBean", + "java.lang", "MemoryPool", keyProperties("name"), + new MXBeanFetcher() { + public List getMXBeans() { + return ManagementFactoryHelper.getMemoryPoolMXBeans(); + } + }), + + /** + * Operating system on which the Java virtual machine is running + */ + OPERATING_SYSTEM( + "java.lang.management.OperatingSystemMXBean", + "java.lang", "OperatingSystem", defaultKeyProperties(), + new MXBeanFetcher() { + public List getMXBeans() { + return Collections.singletonList(ManagementFactoryHelper.getOperatingSystemMXBean()); + } + }), + + /** + * Runtime system of the Java virtual machine. + */ + RUNTIME( + "java.lang.management.RuntimeMXBean", + "java.lang", "Runtime", defaultKeyProperties(), + new MXBeanFetcher() { + public List getMXBeans() { + return Collections.singletonList(ManagementFactoryHelper.getRuntimeMXBean()); + } + }), + + /** + * Threading system of the Java virtual machine. + */ + THREADING( + "java.lang.management.ThreadMXBean", + "java.lang", "Threading", defaultKeyProperties(), + new MXBeanFetcher() { + public List getMXBeans() { + return Collections.singletonList(ManagementFactoryHelper.getThreadMXBean()); + } + }), + + + /** + * Logging facility. + */ + LOGGING( + "java.util.logging.LoggingMXBean", + "java.util.logging", "Logging", defaultKeyProperties(), + new MXBeanFetcher() { + public List getMXBeans() { + return Collections.singletonList(LogManager.getLoggingMXBean()); + } + }), + + // Sun Platform Extension + + /** + * Sun extension garbage collector that performs collections in cycles. + */ + SUN_GARBAGE_COLLECTOR( + "com.sun.management.GarbageCollectorMXBean", + "java.lang", "GarbageCollector", keyProperties("name"), + new MXBeanFetcher() { + public List getMXBeans() { + return getGcMXBeanList(com.sun.management.GarbageCollectorMXBean.class); + } + }), + + /** + * Sun extension operating system on which the Java virtual machine + * is running. + */ + SUN_OPERATING_SYSTEM( + "com.sun.management.OperatingSystemMXBean", + "java.lang", "OperatingSystem", defaultKeyProperties(), + new MXBeanFetcher() { + public List getMXBeans() { + return getOSMXBeanList(com.sun.management.OperatingSystemMXBean.class); + } + }), + + /** + * Unix operating system. + */ + SUN_UNIX_OPERATING_SYSTEM( + "com.sun.management.UnixOperatingSystemMXBean", + "java.lang", "OperatingSystem", defaultKeyProperties(), + new MXBeanFetcher() { + public List getMXBeans() { + return getOSMXBeanList(com.sun.management.UnixOperatingSystemMXBean.class); + } + }), + + /** + * Diagnostic support for the HotSpot Virtual Machine. + */ + HOTSPOT_DIAGNOSTIC( + "com.sun.management.HotSpotDiagnosticMXBean", + "com.sun.management", "HotSpotDiagnostic", defaultKeyProperties(), + new MXBeanFetcher() { + public List getMXBeans() { + return Collections.singletonList(ManagementFactoryHelper.getDiagnosticMXBean()); + } + }); + + + /** + * A task that returns the MXBeans for a component. + */ + interface MXBeanFetcher { + public List getMXBeans(); + } + + /* + * Returns a list of the GC MXBeans of the given type. + */ + private static + List getGcMXBeanList(Class gcMXBeanIntf) { + List list = + ManagementFactoryHelper.getGarbageCollectorMXBeans(); + List result = new ArrayList(list.size()); + for (GarbageCollectorMXBean m : list) { + if (gcMXBeanIntf.isInstance(m)) { + result.add(gcMXBeanIntf.cast(m)); + } + } + return result; + } + + /* + * Returns the OS mxbean instance of the given type. + */ + private static + List getOSMXBeanList(Class osMXBeanIntf) { + OperatingSystemMXBean m = + ManagementFactoryHelper.getOperatingSystemMXBean(); + if (osMXBeanIntf.isInstance(m)) { + return Collections.singletonList(osMXBeanIntf.cast(m)); + } else { + return Collections.emptyList(); + } + } + + private final String mxbeanInterfaceName; + private final String domain; + private final String type; + private final Set keyProperties; + private final MXBeanFetcher fetcher; + private final PlatformComponent[] subComponents; + + private PlatformComponent(String intfName, + String domain, String type, + Set keyProperties, + MXBeanFetcher fetcher) { + this.mxbeanInterfaceName = intfName; + this.domain = domain; + this.type = type; + this.keyProperties = keyProperties; + this.fetcher = fetcher; + this.subComponents = new PlatformComponent[0]; + } + private PlatformComponent(String intfName, + String domain, String type, + Set keyProperties, + MXBeanFetcher fetcher, + PlatformComponent... subComponents) { + this.mxbeanInterfaceName = intfName; + this.domain = domain; + this.type = type; + this.keyProperties = keyProperties; + this.fetcher = fetcher; + this.subComponents = subComponents; + } + + private static Set defaultKeyProps; + private static Set defaultKeyProperties() { + if (defaultKeyProps == null) { + defaultKeyProps = Collections.singleton("type"); + } + return defaultKeyProps; + } + + private static Set keyProperties(String... keyNames) { + Set set = new HashSet(); + set.add("type"); + for (String s : keyNames) { + set.add(s); + } + return set; + } + + String getMXBeanInterfaceName() { + return mxbeanInterfaceName; + } + + @SuppressWarnings("unchecked") + Class getMXBeanInterface() { + try { + // Lazy loading the MXBean interface only when it is needed + return (Class) + Class.forName(mxbeanInterfaceName, false, null); + } catch (ClassNotFoundException x) { + throw new AssertionError(x); + } + } + + @SuppressWarnings("unchecked") + + List getMXBeans(Class mxbeanInterface) + { + return fetcher.getMXBeans(); + } + + + List getMXBeans(MBeanServerConnection mbs, Class mxbeanInterface) + throws java.io.IOException + { + List result = new ArrayList(); + for (ObjectName on : getObjectNames(mbs)) { + result.add(ManagementFactory. + newPlatformMXBeanProxy(mbs, + on.getCanonicalName(), + mxbeanInterface) + ); + } + return result; + } + + private Set getObjectNames(MBeanServerConnection mbs) + throws java.io.IOException + { + String domainAndType = domain + ":type=" + type; + if (keyProperties.size() > 1) { + // if there are more than 1 key properties (i.e. other than "type") + domainAndType += ",*"; + } + ObjectName on = com.sun.jmx.mbeanserver.Util.newObjectName(domainAndType); + Set set = mbs.queryNames(on, null); + for (PlatformComponent pc : subComponents) { + set.addAll(pc.getObjectNames(mbs)); + } + return set; + } + + private static final long serialVersionUID = 6992337162326171013L; +} diff --git a/src/share/classes/java/lang/management/PlatformManagedObject.java b/src/share/classes/java/lang/management/PlatformManagedObject.java new file mode 100644 index 0000000000000000000000000000000000000000..5f68635d4fe8c57e76d04e7d9f2e7e75fd216c73 --- /dev/null +++ b/src/share/classes/java/lang/management/PlatformManagedObject.java @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.lang.management; + +import javax.management.ObjectName; + +/** + * A platform managed object is a {@linkplain javax.management.MXBean JMX MXBean} + * for monitoring and managing a component in the Java platform. + * Each platform managed object has a unique + * object name + * for the {@linkplain ManagementFactory.getPlatformMBeanServer + * platform MBeanServer} access. + * All platform MXBeans will implement this interface. + * + *

        + * Note: + * The platform MXBean interfaces (i.e. all subinterfaces + * of {@code PlatformManagedObject}) are implemented + * by the Java platform only. New methods may be added in these interfaces + * in future Java SE releases. + * In addition, this {@code PlatformManagedObject} interface is only + * intended for the management interfaces for the platform to extend but + * not for applications. + * + * @see Platform MXBeans + * @since 1.7 + */ +public interface PlatformManagedObject { + /** + * Returns an {@link ObjectName ObjectName} instance representing + * the object name of this platform managed object. + * + * @return an {@link ObjectName ObjectName} instance representing + * the object name of this platform managed object. + */ + public ObjectName getObjectName(); +} diff --git a/src/share/classes/java/lang/management/RuntimeMXBean.java b/src/share/classes/java/lang/management/RuntimeMXBean.java index fcd631499aa75e8589a1a164729ab02a11214b04..ab6101bb2ed65ce1412f94092aff533c284aba53 100644 --- a/src/share/classes/java/lang/management/RuntimeMXBean.java +++ b/src/share/classes/java/lang/management/RuntimeMXBean.java @@ -44,9 +44,13 @@ package java.lang.management; * java.lang:type=Runtime} * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * *

        This interface defines several convenient methods for accessing * system properties about the Java virtual machine. * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see * JMX Specification. * @see @@ -55,7 +59,7 @@ package java.lang.management; * @author Mandy Chung * @since 1.5 */ -public interface RuntimeMXBean { +public interface RuntimeMXBean extends PlatformManagedObject { /** * Returns the name representing the running Java virtual machine. * The returned name string can be any arbitrary string and diff --git a/src/share/classes/java/lang/management/ThreadInfo.java b/src/share/classes/java/lang/management/ThreadInfo.java index ac3466085587f0ad29451d0a9af33b4fb816ecfd..d416e0d7ded4e8037084cfb59d61f90deaff2718 100644 --- a/src/share/classes/java/lang/management/ThreadInfo.java +++ b/src/share/classes/java/lang/management/ThreadInfo.java @@ -26,6 +26,7 @@ package java.lang.management; import javax.management.openmbean.CompositeData; +import sun.management.ManagementFactoryHelper; import sun.management.ThreadInfoCompositeData; import static java.lang.Thread.State.*; @@ -220,12 +221,9 @@ public class ThreadInfo { LockInfo[] lockedSynchronizers) { this.threadId = t.getId(); this.threadName = t.getName(); - this.threadState = - sun.management.ManagementFactory.toThreadState(state); - this.suspended = - sun.management.ManagementFactory.isThreadSuspended(state); - this.inNative = - sun.management.ManagementFactory.isThreadRunningNative(state); + this.threadState = ManagementFactoryHelper.toThreadState(state); + this.suspended = ManagementFactoryHelper.isThreadSuspended(state); + this.inNative = ManagementFactoryHelper.isThreadRunningNative(state); this.blockedCount = blockedCount; this.blockedTime = blockedTime; this.waitedCount = waitedCount; diff --git a/src/share/classes/java/lang/management/ThreadMXBean.java b/src/share/classes/java/lang/management/ThreadMXBean.java index 459fbac5d1d72c274ed1a06daab6f558c8d758fe..7f627ca841c53954517a36973226a8b88bc7d29b 100644 --- a/src/share/classes/java/lang/management/ThreadMXBean.java +++ b/src/share/classes/java/lang/management/ThreadMXBean.java @@ -46,6 +46,9 @@ import java.util.Map; * java.lang:type=Threading} * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * *

        Thread ID

        * Thread ID is a positive long value returned by calling the * {@link java.lang.Thread#getId} method for a thread. @@ -108,6 +111,7 @@ import java.util.Map; * {@link #findDeadlockedThreads} methods to find deadlocks in * the running application. * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see * JMX Specification. * @see @@ -117,7 +121,7 @@ import java.util.Map; * @since 1.5 */ -public interface ThreadMXBean { +public interface ThreadMXBean extends PlatformManagedObject { /** * Returns the current number of live threads including both * daemon and non-daemon threads. diff --git a/src/share/classes/java/lang/ref/Finalizer.java b/src/share/classes/java/lang/ref/Finalizer.java index 76b5bd9454a11a24d62a04a3c35e4e838dc8ecb5..695d71d64a11efbca6bf7f657bf2a870c6e1106d 100644 --- a/src/share/classes/java/lang/ref/Finalizer.java +++ b/src/share/classes/java/lang/ref/Finalizer.java @@ -121,8 +121,9 @@ final class Finalizer extends FinalReference { /* Package-private; must be in invokers of these methods from a stalled or deadlocked finalizer thread. */ private static void forkSecondaryFinalizer(final Runnable proc) { - PrivilegedAction pa = new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged( + new PrivilegedAction() { + public Void run() { ThreadGroup tg = Thread.currentThread().getThreadGroup(); for (ThreadGroup tgn = tg; tgn != null; @@ -135,8 +136,7 @@ final class Finalizer extends FinalReference { /* Package-private; must be in /* Ignore */ } return null; - }}; - AccessController.doPrivileged(pa); + }}); } /* Called by Runtime.runFinalization() */ diff --git a/src/share/classes/java/lang/reflect/AccessibleObject.java b/src/share/classes/java/lang/reflect/AccessibleObject.java index 23f16927ae06416df3c0e0d17fecd3b3f12ded72..29889b08810dcef4e77ccd7b984c13e9ee33705a 100644 --- a/src/share/classes/java/lang/reflect/AccessibleObject.java +++ b/src/share/classes/java/lang/reflect/AccessibleObject.java @@ -165,9 +165,9 @@ public class AccessibleObject implements AnnotatedElement { // Reflection factory used by subclasses for creating field, // method, and constructor accessors. Note that this is called // very early in the bootstrapping process. - static final ReflectionFactory reflectionFactory = (ReflectionFactory) - AccessController.doPrivileged - (new sun.reflect.ReflectionFactory.GetReflectionFactoryAction()); + static final ReflectionFactory reflectionFactory = + AccessController.doPrivileged( + new sun.reflect.ReflectionFactory.GetReflectionFactoryAction()); /** * @throws NullPointerException {@inheritDoc} diff --git a/src/share/classes/java/lang/reflect/Modifier.java b/src/share/classes/java/lang/reflect/Modifier.java index e036927ef088e3a38e5595af015e284a1115d624..952fbe8011ba7be34969ac3fbb97b0a5df6e72ce 100644 --- a/src/share/classes/java/lang/reflect/Modifier.java +++ b/src/share/classes/java/lang/reflect/Modifier.java @@ -58,9 +58,8 @@ class Modifier { */ static { sun.reflect.ReflectionFactory factory = - (sun.reflect.ReflectionFactory) AccessController.doPrivileged( - new ReflectionFactory.GetReflectionFactoryAction() - ); + AccessController.doPrivileged( + new ReflectionFactory.GetReflectionFactoryAction()); factory.setLangReflectAccess(new java.lang.reflect.ReflectAccess()); } diff --git a/src/share/classes/java/lang/reflect/Proxy.java b/src/share/classes/java/lang/reflect/Proxy.java index e9a1d40f95cb4ed226d88e6ffaf0d73a5d9d7c2c..ffa6a6dcaddc864ec581f08e1c4f863a126ed642 100644 --- a/src/share/classes/java/lang/reflect/Proxy.java +++ b/src/share/classes/java/lang/reflect/Proxy.java @@ -33,6 +33,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.List; import java.util.WeakHashMap; import sun.misc.ProxyGenerator; @@ -230,7 +231,8 @@ public class Proxy implements java.io.Serializable { { InvocationHandler.class }; /** maps a class loader to the proxy class cache for that loader */ - private static Map loaderToCache = new WeakHashMap(); + private static Map, Object>> loaderToCache + = new WeakHashMap, Object>>(); /** marks that a particular proxy class is currently being generated */ private static Object pendingGenerationMarker = new Object(); @@ -240,8 +242,8 @@ public class Proxy implements java.io.Serializable { private static Object nextUniqueNumberLock = new Object(); /** set of all generated proxy classes, for isProxyClass implementation */ - private static Map proxyClasses = - Collections.synchronizedMap(new WeakHashMap()); + private static Map, Void> proxyClasses = + Collections.synchronizedMap(new WeakHashMap, Void>()); /** * the invocation handler for this proxy instance. @@ -353,7 +355,8 @@ public class Proxy implements java.io.Serializable { /* collect interface names to use as key for proxy class cache */ String[] interfaceNames = new String[interfaces.length]; - Set interfaceSet = new HashSet(); // for detecting duplicates + // for detecting duplicates + Set> interfaceSet = new HashSet>(); for (int i = 0; i < interfaces.length; i++) { /* @@ -401,16 +404,16 @@ public class Proxy implements java.io.Serializable { * representation of a class makes for an implicit weak * reference to the class. */ - Object key = Arrays.asList(interfaceNames); + List key = Arrays.asList(interfaceNames); /* * Find or create the proxy class cache for the class loader. */ - Map cache; + Map, Object> cache; synchronized (loaderToCache) { - cache = (Map) loaderToCache.get(loader); + cache = loaderToCache.get(loader); if (cache == null) { - cache = new HashMap(); + cache = new HashMap, Object>(); loaderToCache.put(loader, cache); } /* @@ -442,7 +445,7 @@ public class Proxy implements java.io.Serializable { do { Object value = cache.get(key); if (value instanceof Reference) { - proxyClass = (Class) ((Reference) value).get(); + proxyClass = (Class) ((Reference) value).get(); } if (proxyClass != null) { // proxy class already generated: return it @@ -544,7 +547,7 @@ public class Proxy implements java.io.Serializable { */ synchronized (cache) { if (proxyClass != null) { - cache.put(key, new WeakReference(proxyClass)); + cache.put(key, new WeakReference>(proxyClass)); } else { cache.remove(key); } @@ -595,14 +598,14 @@ public class Proxy implements java.io.Serializable { /* * Look up or generate the designated proxy class. */ - Class cl = getProxyClass(loader, interfaces); + Class cl = getProxyClass(loader, interfaces); /* * Invoke its constructor with the designated invocation handler. */ try { Constructor cons = cl.getConstructor(constructorParams); - return (Object) cons.newInstance(new Object[] { h }); + return cons.newInstance(new Object[] { h }); } catch (NoSuchMethodException e) { throw new InternalError(e.toString()); } catch (IllegalAccessException e) { diff --git a/src/share/classes/java/net/AbstractPlainSocketImpl.java b/src/share/classes/java/net/AbstractPlainSocketImpl.java index ffc23824b61f10c4263ae057e2208109290b5c90..41c39f0e15f403693f83ef9fa3ab5fcd690bfc48 100644 --- a/src/share/classes/java/net/AbstractPlainSocketImpl.java +++ b/src/share/classes/java/net/AbstractPlainSocketImpl.java @@ -664,7 +664,6 @@ abstract class AbstractPlainSocketImpl extends SocketImpl abstract void socketSetOption(int cmd, boolean on, Object value) throws SocketException; abstract int socketGetOption(int opt, Object iaContainerObj) throws SocketException; - abstract int socketGetOption1(int opt, Object iaContainerObj, FileDescriptor fd) throws SocketException; abstract void socketSendUrgentData(int data) throws IOException; diff --git a/src/share/classes/java/net/DatagramSocket.java b/src/share/classes/java/net/DatagramSocket.java index 4a09fa3cc571d5139864527ca9b7f80f7635e1a2..6082bcab9f22e8e0a56704e7264cd6d64e580eb2 100644 --- a/src/share/classes/java/net/DatagramSocket.java +++ b/src/share/classes/java/net/DatagramSocket.java @@ -287,8 +287,9 @@ class DatagramSocket implements java.io.Closeable { // DatagramSocketImpl.peekdata() is a protected method, therefore we need to use // getDeclaredMethod, therefore we need permission to access the member try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws NoSuchMethodException { + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws NoSuchMethodException { Class[] cl = new Class[1]; cl[0] = DatagramPacket.class; impl.getClass().getDeclaredMethod("peekData", cl); diff --git a/src/share/classes/java/net/InterfaceAddress.java b/src/share/classes/java/net/InterfaceAddress.java index e352c35f80b6d3dfe18f04f5d1e278570c252f8f..66a65358cbcc5929ab3412b8243a37cd87ef66fc 100644 --- a/src/share/classes/java/net/InterfaceAddress.java +++ b/src/share/classes/java/net/InterfaceAddress.java @@ -103,11 +103,9 @@ public class InterfaceAddress { return false; } InterfaceAddress cmp = (InterfaceAddress) obj; - if ((address != null & cmp.address == null) || - (!address.equals(cmp.address))) + if ( !(address == null ? cmp.address == null : address.equals(cmp.address)) ) return false; - if ((broadcast != null & cmp.broadcast == null) || - (!broadcast.equals(cmp.broadcast))) + if ( !(broadcast == null ? cmp.broadcast == null : broadcast.equals(cmp.broadcast)) ) return false; if (maskLength != cmp.maskLength) return false; diff --git a/src/share/classes/java/net/NetworkInterface.java b/src/share/classes/java/net/NetworkInterface.java index 8b2899c48d950df8cf5bd4602b92a6f47771b694..0ce3a8d580bb934d54c94d03f73202d9dacf08f7 100644 --- a/src/share/classes/java/net/NetworkInterface.java +++ b/src/share/classes/java/net/NetworkInterface.java @@ -425,8 +425,6 @@ public final class NetworkInterface { return virtual; } - private native static long getSubnet0(String name, int ind) throws SocketException; - private native static Inet4Address getBroadcast0(String name, int ind) throws SocketException; private native static boolean isUp0(String name, int ind) throws SocketException; private native static boolean isLoopback0(String name, int ind) throws SocketException; private native static boolean supportsMulticast0(String name, int ind) throws SocketException; diff --git a/src/share/classes/java/net/ServerSocket.java b/src/share/classes/java/net/ServerSocket.java index 8b632f665d68ab7bfec0d72ca85ab3c2c9587a41..2793b2f961e8942be76b6bdaebbdb85f314f4c89 100644 --- a/src/share/classes/java/net/ServerSocket.java +++ b/src/share/classes/java/net/ServerSocket.java @@ -247,8 +247,9 @@ class ServerSocket implements java.io.Closeable { // SocketImpl.connect() is a protected method, therefore we need to use // getDeclaredMethod, therefore we need permission to access the member try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws NoSuchMethodException { + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws NoSuchMethodException { Class[] cl = new Class[2]; cl[0] = SocketAddress.class; cl[1] = Integer.TYPE; diff --git a/src/share/classes/java/net/Socket.java b/src/share/classes/java/net/Socket.java index c02dd4e2855b19db9dbb77a24e34287bfe3c330a..5dd5f7f2e4151567edff467d2055bca5c085792e 100644 --- a/src/share/classes/java/net/Socket.java +++ b/src/share/classes/java/net/Socket.java @@ -731,7 +731,8 @@ class Socket implements java.io.Closeable { * then this method will continue to return the connected address * after the socket is closed. * - * @return a SocketAddress reprensenting the remote endpoint of this + + * @return a SocketAddress representing the remote endpoint of this * socket, or null if it is not connected yet. * @see #getInetAddress() * @see #getPort() @@ -847,9 +848,9 @@ class Socket implements java.io.Closeable { final Socket s = this; InputStream is = null; try { - is = (InputStream) - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws IOException { + is = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public InputStream run() throws IOException { return impl.getInputStream(); } }); @@ -887,9 +888,9 @@ class Socket implements java.io.Closeable { final Socket s = this; OutputStream os = null; try { - os = (OutputStream) - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws IOException { + os = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public OutputStream run() throws IOException { return impl.getOutputStream(); } }); diff --git a/src/share/classes/java/net/SocksSocketImpl.java b/src/share/classes/java/net/SocksSocketImpl.java index df88e645be8f21af9f8b47f185fd4a96626445af..76e11e957f7079a3fc9cc15eae2717bb755266be 100644 --- a/src/share/classes/java/net/SocksSocketImpl.java +++ b/src/share/classes/java/net/SocksSocketImpl.java @@ -78,8 +78,8 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { { try { AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() throws IOException { + new java.security.PrivilegedExceptionAction() { + public Void run() throws IOException { superConnectServer(host, port, timeout); cmdIn = getInputStream(); cmdOut = getOutputStream(); @@ -129,10 +129,10 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { String userName; String password = null; final InetAddress addr = InetAddress.getByName(server); - PasswordAuthentication pw = (PasswordAuthentication) + PasswordAuthentication pw = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public PasswordAuthentication run() { return Authenticator.requestPasswordAuthentication( server, addr, port, "SOCKS5", "SOCKS authentication", null); } @@ -339,10 +339,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { // This is the general case // server is not null only when the socket was created with a // specified proxy in which case it does bypass the ProxySelector - ProxySelector sel = (ProxySelector) - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + ProxySelector sel = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public ProxySelector run() { return ProxySelector.getDefault(); } }); @@ -652,10 +651,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { // This is the general case // server is not null only when the socket was created with a // specified proxy in which case it does bypass the ProxySelector - ProxySelector sel = (ProxySelector) - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + ProxySelector sel = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public ProxySelector run() { return ProxySelector.getDefault(); } }); @@ -701,8 +699,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { // Connects to the SOCKS server try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws Exception { cmdsock = new Socket(new PlainSocketImpl()); cmdsock.connect(new InetSocketAddress(server, port)); cmdIn = cmdsock.getInputStream(); @@ -731,8 +730,9 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { } } else { try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws Exception { cmdsock = new Socket(new PlainSocketImpl()); cmdsock.connect(new InetSocketAddress(server, port)); cmdIn = cmdsock.getInputStream(); diff --git a/src/share/classes/java/net/URLClassLoader.java b/src/share/classes/java/net/URLClassLoader.java index 267a005d1017a4249910116dba396f28842fc073..5a6cfefecb3067064e53aeaa0b3d2651bf29eefc 100644 --- a/src/share/classes/java/net/URLClassLoader.java +++ b/src/share/classes/java/net/URLClassLoader.java @@ -205,9 +205,9 @@ public class URLClassLoader extends SecureClassLoader { throws ClassNotFoundException { try { - return (Class) - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws ClassNotFoundException { + return AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Class run() throws ClassNotFoundException { String path = name.replace('.', '/').concat(".class"); Resource res = ucp.getResource(path, false); if (res != null) { @@ -376,9 +376,9 @@ public class URLClassLoader extends SecureClassLoader { /* * The same restriction to finding classes applies to resources */ - URL url = - (URL) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + URL url = AccessController.doPrivileged( + new PrivilegedAction() { + public URL run() { return ucp.findResource(name, true); } }, acc); @@ -397,7 +397,7 @@ public class URLClassLoader extends SecureClassLoader { public Enumeration findResources(final String name) throws IOException { - final Enumeration e = ucp.findResources(name, true); + final Enumeration e = ucp.findResources(name, true); return new Enumeration() { private URL url = null; @@ -407,9 +407,9 @@ public class URLClassLoader extends SecureClassLoader { return true; } do { - URL u = (URL) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + URL u = AccessController.doPrivileged( + new PrivilegedAction() { + public URL run() { if (!e.hasMoreElements()) return null; return e.nextElement(); @@ -515,8 +515,8 @@ public class URLClassLoader extends SecureClassLoader { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { final Permission fp = p; - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() throws SecurityException { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() throws SecurityException { sm.checkPermission(fp); return null; } @@ -544,9 +544,9 @@ public class URLClassLoader extends SecureClassLoader { // Save the caller's context AccessControlContext acc = AccessController.getContext(); // Need a privileged block to create the class loader - URLClassLoader ucl = - (URLClassLoader) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + URLClassLoader ucl = AccessController.doPrivileged( + new PrivilegedAction() { + public URLClassLoader run() { return new FactoryURLClassLoader(urls, parent); } }); @@ -571,9 +571,9 @@ public class URLClassLoader extends SecureClassLoader { // Save the caller's context AccessControlContext acc = AccessController.getContext(); // Need a privileged block to create the class loader - URLClassLoader ucl = (URLClassLoader) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + URLClassLoader ucl = AccessController.doPrivileged( + new PrivilegedAction() { + public URLClassLoader run() { return new FactoryURLClassLoader(urls); } }); diff --git a/src/share/classes/java/net/URLConnection.java b/src/share/classes/java/net/URLConnection.java index c1236bd3a63df882dc1dc17bf76943bda07437e9..a78032a2fcc91d510a5fa0a5f26a1aa6243b6660 100644 --- a/src/share/classes/java/net/URLConnection.java +++ b/src/share/classes/java/net/URLConnection.java @@ -1072,7 +1072,7 @@ public abstract class URLConnection { * properties to be appended into a single property. * * @param key the keyword by which the request is known - * (e.g., "accept"). + * (e.g., "Accept"). * @param value the value associated with it. * @throws IllegalStateException if already connected * @throws NullPointerException if key is null @@ -1096,7 +1096,7 @@ public abstract class URLConnection { * existing values associated with the same key. * * @param key the keyword by which the request is known - * (e.g., "accept"). + * (e.g., "Accept"). * @param value the value associated with it. * @throws IllegalStateException if already connected * @throws NullPointerException if key is null @@ -1120,7 +1120,7 @@ public abstract class URLConnection { * Returns the value of the named general request property for this * connection. * - * @param key the keyword by which the request is known (e.g., "accept"). + * @param key the keyword by which the request is known (e.g., "Accept"). * @return the value of the named general request property for this * connection. If key is null, then null is returned. * @throws IllegalStateException if already connected @@ -1164,7 +1164,7 @@ public abstract class URLConnection { * these properties. * * @param key the keyword by which the request is known - * (e.g., "accept"). + * (e.g., "Accept"). * @param value the value associated with the key. * * @see java.net.URLConnection#setRequestProperty(java.lang.String,java.lang.String) @@ -1183,7 +1183,7 @@ public abstract class URLConnection { * Returns the value of the default request property. Default request * properties are set for every connection. * - * @param key the keyword by which the request is known (e.g., "accept"). + * @param key the keyword by which the request is known (e.g., "Accept"). * @return the value of the default request property * for the specified key. * diff --git a/src/share/classes/java/nio/StringCharBuffer.java b/src/share/classes/java/nio/StringCharBuffer.java index d5a80f26d1c5adfa89bcfcaf266014c1b547c3db..c6ef51eb0dcd9ffe574e967a247fbb0e3ac709ff 100644 --- a/src/share/classes/java/nio/StringCharBuffer.java +++ b/src/share/classes/java/nio/StringCharBuffer.java @@ -60,16 +60,9 @@ class StringCharBuffer // package-private str = s; } - private StringCharBuffer(CharSequence s, int mark, - int pos, int limit, int cap) - { - super(mark, pos, limit, cap); - str = s; - } - public CharBuffer duplicate() { return new StringCharBuffer(str, markValue(), - position(), limit(), capacity()); + position(), limit(), capacity(), offset); } public CharBuffer asReadOnlyBuffer() { @@ -77,11 +70,11 @@ class StringCharBuffer // package-private } public final char get() { - return str.charAt(nextGetIndex()); + return str.charAt(nextGetIndex() + offset); } public final char get(int index) { - return str.charAt(checkIndex(index)); + return str.charAt(checkIndex(index) + offset); } // ## Override bulk get methods for better performance @@ -103,15 +96,16 @@ class StringCharBuffer // package-private } final String toString(int start, int end) { - return str.toString().substring(start, end); + return str.toString().substring(start + offset, end + offset); } public final CharSequence subSequence(int start, int end) { try { int pos = position(); - return new StringCharBuffer(str, + return new StringCharBuffer(str, -1, pos + checkIndex(start, pos), - pos + checkIndex(end, pos)); + pos + checkIndex(end, pos), + remaining(), offset); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } diff --git a/src/share/classes/java/nio/channels/Channels.java b/src/share/classes/java/nio/channels/Channels.java index a6e8a042d571e93f0de07fb1f308d5a38765b492..a39bb382022d70b81362c4a0d71ef05033db7e17 100644 --- a/src/share/classes/java/nio/channels/Channels.java +++ b/src/share/classes/java/nio/channels/Channels.java @@ -66,7 +66,27 @@ public final class Channels { private Channels() { } // No instantiation - private static int write(WritableByteChannel ch, ByteBuffer bb) + /** + * Write all remaining bytes in buffer to the given channel. + * If the channel is selectable then it must be configured blocking. + */ + private static void writeFullyImpl(WritableByteChannel ch, ByteBuffer bb) + throws IOException + { + while (bb.remaining() > 0) { + int n = ch.write(bb); + if (n <= 0) + throw new RuntimeException("no bytes written"); + } + } + + /** + * Write all remaining bytes in buffer to the given channel. + * + * @throws IllegalBlockingException + * If the channel is selectable and configured non-blocking. + */ + private static void writeFully(WritableByteChannel ch, ByteBuffer bb) throws IOException { if (ch instanceof SelectableChannel) { @@ -74,14 +94,13 @@ public final class Channels { synchronized (sc.blockingLock()) { if (!sc.isBlocking()) throw new IllegalBlockingModeException(); - return ch.write(bb); + writeFullyImpl(ch, bb); } } else { - return ch.write(bb); + writeFullyImpl(ch, bb); } } - // -- Byte streams from channels -- /** @@ -148,7 +167,7 @@ public final class Channels { bb.position(off); this.bb = bb; this.bs = bs; - Channels.write(ch, bb); + Channels.writeFully(ch, bb); } public void close() throws IOException { diff --git a/src/share/classes/java/nio/channels/spi/SelectorProvider.java b/src/share/classes/java/nio/channels/spi/SelectorProvider.java index a227addacf26036509e38455c6dcb7a8194809b0..196359bfd91399f25b779726f5f1478d0a499d7d 100644 --- a/src/share/classes/java/nio/channels/spi/SelectorProvider.java +++ b/src/share/classes/java/nio/channels/spi/SelectorProvider.java @@ -167,9 +167,9 @@ public abstract class SelectorProvider { synchronized (lock) { if (provider != null) return provider; - return (SelectorProvider)AccessController - .doPrivileged(new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged( + new PrivilegedAction() { + public SelectorProvider run() { if (loadProviderFromProperty()) return provider; if (loadProviderAsService()) diff --git a/src/share/classes/java/nio/charset/Charset.java b/src/share/classes/java/nio/charset/Charset.java index 1372343271274fda5f35a1c31209060193ef8dff..4c166d519a2747293f36de1347d401642c3fb134 100644 --- a/src/share/classes/java/nio/charset/Charset.java +++ b/src/share/classes/java/nio/charset/Charset.java @@ -212,36 +212,47 @@ import sun.security.action.GetPropertyAction; * *

        Terminology

        * - *

        The name of this class is taken from the terms used in RFC 2278. In that - * document a charset is defined as the combination of a coded character - * set and a character-encoding scheme. + *

        The name of this class is taken from the terms used in + * RFC 2278. + * In that document a charset is defined as the combination of + * one or more coded character sets and a character-encoding scheme. + * (This definition is confusing; some other software systems define + * charset as a synonym for coded character set.) * *

        A coded character set is a mapping between a set of abstract * characters and a set of integers. US-ASCII, ISO 8859-1, - * JIS X 0201, and full Unicode, which is the same as - * ISO 10646-1, are examples of coded character sets. - * - *

        A character-encoding scheme is a mapping between a coded - * character set and a set of octet (eight-bit byte) sequences. UTF-8, UCS-2, - * UTF-16, ISO 2022, and EUC are examples of character-encoding schemes. - * Encoding schemes are often associated with a particular coded character set; - * UTF-8, for example, is used only to encode Unicode. Some schemes, however, - * are associated with multiple character sets; EUC, for example, can be used - * to encode characters in a variety of Asian character sets. + * JIS X 0201, and Unicode are examples of coded character sets. + * + *

        Some standards have defined a character set to be simply a + * set of abstract characters without an associated assigned numbering. + * An alphabet is an example of such a character set. However, the subtle + * distinction between character set and coded character set + * is rarely used in practice; the former has become a short form for the + * latter, including in the Java API specification. + * + *

        A character-encoding scheme is a mapping between one or more + * coded character sets and a set of octet (eight-bit byte) sequences. + * UTF-8, UTF-16, ISO 2022, and EUC are examples of + * character-encoding schemes. Encoding schemes are often associated with + * a particular coded character set; UTF-8, for example, is used only to + * encode Unicode. Some schemes, however, are associated with multiple + * coded character sets; EUC, for example, can be used to encode + * characters in a variety of Asian coded character sets. * *

        When a coded character set is used exclusively with a single - * character-encoding scheme then the corresponding charset is usually named - * for the character set; otherwise a charset is usually named for the encoding - * scheme and, possibly, the locale of the character sets that it supports. - * Hence US-ASCII is the name of the charset for US-ASCII while + * character-encoding scheme then the corresponding charset is usually + * named for the coded character set; otherwise a charset is usually named + * for the encoding scheme and, possibly, the locale of the coded + * character sets that it supports. Hence US-ASCII is both the + * name of a coded character set and of the charset that encodes it, while * EUC-JP is the name of the charset that encodes the * JIS X 0201, JIS X 0208, and JIS X 0212 - * character sets. + * coded character sets for the Japanese language. * *

        The native character encoding of the Java programming language is - * UTF-16. A charset in the Java platform therefore defines a mapping between - * sequences of sixteen-bit UTF-16 code units and sequences of bytes.

        + * UTF-16. A charset in the Java platform therefore defines a mapping + * between sequences of sixteen-bit UTF-16 code units (that is, sequences + * of chars) and sequences of bytes.

        * * * @author Mark Reinhold diff --git a/src/share/classes/java/rmi/activation/ActivationGroupDesc.java b/src/share/classes/java/rmi/activation/ActivationGroupDesc.java index a36274168513aecd939be0f46a47d88b5ea214c9..41a25db97f2e5721cd6d83fb0e43a8ef708a5b1c 100644 --- a/src/share/classes/java/rmi/activation/ActivationGroupDesc.java +++ b/src/share/classes/java/rmi/activation/ActivationGroupDesc.java @@ -263,7 +263,7 @@ public final class ActivationGroupDesc implements Serializable { * @since 1.2 */ public String[] getCommandOptions() { - return (String[]) options.clone(); + return options.clone(); } /** diff --git a/src/share/classes/java/rmi/dgc/VMID.java b/src/share/classes/java/rmi/dgc/VMID.java index bbfd169c011901a35b1d988e16d2ed3368426ceb..9f7801aabd4d725f650b1d326acc5ade25855b7e 100644 --- a/src/share/classes/java/rmi/dgc/VMID.java +++ b/src/share/classes/java/rmi/dgc/VMID.java @@ -136,9 +136,9 @@ public final class VMID implements java.io.Serializable { /* * Get the local host's IP address. */ - byte[] addr = (byte[]) java.security.AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + byte[] addr = java.security.AccessController.doPrivileged( + new PrivilegedAction() { + public byte[] run() { try { return InetAddress.getLocalHost().getAddress(); } catch (Exception e) { diff --git a/src/share/classes/java/security/AccessControlContext.java b/src/share/classes/java/security/AccessControlContext.java index 601bc40ba56551756d95ae4f369eb5b6f9ba9c2e..0a9cfb85b5e408b8857c577544bde0417e38c364 100644 --- a/src/share/classes/java/security/AccessControlContext.java +++ b/src/share/classes/java/security/AccessControlContext.java @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2008 Sun Microsystems, 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 @@ -322,7 +322,7 @@ public final class AccessControlContext { debug.println("access denied " + perm); } - if (Debug.isOn("failure")) { + if (Debug.isOn("failure") && debug != null) { // Want to make sure this is always displayed for failure, // but do not want to display again if already displayed // above. diff --git a/src/share/classes/java/security/KeyStore.java b/src/share/classes/java/security/KeyStore.java index f19a231bfbdc81a4f1bbaaeb3f5902585ef740db..ced20e274463073bbfe3c859a236b68d617e501b 100644 --- a/src/share/classes/java/security/KeyStore.java +++ b/src/share/classes/java/security/KeyStore.java @@ -789,7 +789,7 @@ public class KeyStore { * @param alias the alias name * * @return the certificate chain (ordered with the user's certificate first - * and the root certificate authority last), or null if the given alias + * followed by zero or more certificate authorities), or null if the given alias * does not exist or does not contain a certificate chain * * @exception KeyStoreException if the keystore has not been initialized diff --git a/src/share/classes/java/security/cert/TrustAnchor.java b/src/share/classes/java/security/cert/TrustAnchor.java index 9fdac7b2c9855a0c6bb176b0fe93f0092dc69d8e..cd4c3de7097ab6f2a623251e80e9ae2304575d14 100644 --- a/src/share/classes/java/security/cert/TrustAnchor.java +++ b/src/share/classes/java/security/cert/TrustAnchor.java @@ -275,7 +275,7 @@ public class TrustAnchor { ncBytes = null; nc = null; } else { - ncBytes = (byte []) bytes.clone(); + ncBytes = bytes.clone(); // validate DER encoding try { nc = new NameConstraintsExtension(Boolean.FALSE, bytes); @@ -309,7 +309,7 @@ public class TrustAnchor { * or null if not set. */ public final byte [] getNameConstraints() { - return (ncBytes == null ? null : (byte []) ncBytes.clone()); + return ncBytes == null ? null : ncBytes.clone(); } /** diff --git a/src/share/classes/java/security/cert/X509CertSelector.java b/src/share/classes/java/security/cert/X509CertSelector.java index dbcdf017e76012acd429451c593f32cb210e3ff2..6ec61c17d60d5d4ab5fe19ac1cac0e2ee2cb14bb 100644 --- a/src/share/classes/java/security/cert/X509CertSelector.java +++ b/src/share/classes/java/security/cert/X509CertSelector.java @@ -381,7 +381,7 @@ public class X509CertSelector implements CertSelector { if (subjectKeyID == null) { this.subjectKeyID = null; } else { - this.subjectKeyID = (byte[])subjectKeyID.clone(); + this.subjectKeyID = subjectKeyID.clone(); } } @@ -442,7 +442,7 @@ public class X509CertSelector implements CertSelector { if (authorityKeyID == null) { this.authorityKeyID = null; } else { - this.authorityKeyID = (byte[])authorityKeyID.clone(); + this.authorityKeyID = authorityKeyID.clone(); } } @@ -566,7 +566,7 @@ public class X509CertSelector implements CertSelector { subjectPublicKey = null; subjectPublicKeyBytes = null; } else { - subjectPublicKeyBytes = (byte[])key.clone(); + subjectPublicKeyBytes = key.clone(); subjectPublicKey = X509Key.parse(new DerValue(subjectPublicKeyBytes)); } } @@ -590,7 +590,7 @@ public class X509CertSelector implements CertSelector { if (keyUsage == null) { this.keyUsage = null; } else { - this.keyUsage = (boolean[])keyUsage.clone(); + this.keyUsage = keyUsage.clone(); } } @@ -1041,7 +1041,7 @@ public class X509CertSelector implements CertSelector { ncBytes = null; nc = null; } else { - ncBytes = (byte[])bytes.clone(); + ncBytes = bytes.clone(); nc = new NameConstraintsExtension(FALSE, bytes); } } @@ -1438,7 +1438,7 @@ public class X509CertSelector implements CertSelector { if (subjectKeyID == null) { return null; } - return (byte[])subjectKeyID.clone(); + return subjectKeyID.clone(); } /** @@ -1457,7 +1457,7 @@ public class X509CertSelector implements CertSelector { if (authorityKeyID == null) { return null; } - return (byte[])authorityKeyID.clone(); + return authorityKeyID.clone(); } /** @@ -1546,7 +1546,7 @@ public class X509CertSelector implements CertSelector { if (keyUsage == null) { return null; } - return (boolean[])keyUsage.clone(); + return keyUsage.clone(); } /** @@ -1736,7 +1736,7 @@ public class X509CertSelector implements CertSelector { if (ncBytes == null) { return null; } else { - return (byte[]) ncBytes.clone(); + return ncBytes.clone(); } } diff --git a/src/share/classes/java/util/ArrayList.java b/src/share/classes/java/util/ArrayList.java index 36c846e3b31d0260ae5214da40620b2c081d792f..f769822ce81ab03636488b5192157ba8b4fd8cc3 100644 --- a/src/share/classes/java/util/ArrayList.java +++ b/src/share/classes/java/util/ArrayList.java @@ -892,7 +892,7 @@ public class ArrayList extends AbstractList private final AbstractList parent; private final int parentOffset; private final int offset; - private int size; + int size; SubList(AbstractList parent, int offset, int fromIndex, int toIndex) { @@ -971,6 +971,7 @@ public class ArrayList extends AbstractList public ListIterator listIterator(final int index) { checkForComodification(); rangeCheckForAdd(index); + final int offset = this.offset; return new ListIterator() { int cursor = index; diff --git a/src/share/classes/java/util/Arrays.java b/src/share/classes/java/util/Arrays.java index 3d103ad51b006b95912968cafc4a1a8745b4b7ce..46744d2c6bea1673f1821ee9ed45c09e0f3f97a7 100644 --- a/src/share/classes/java/util/Arrays.java +++ b/src/share/classes/java/util/Arrays.java @@ -1088,7 +1088,7 @@ public class Arrays { * mutually comparable (for example, strings and integers). */ public static void sort(Object[] a) { - Object[] aux = (Object[])a.clone(); + Object[] aux = a.clone(); mergeSort(aux, a, 0, a.length, 0); } @@ -1216,7 +1216,7 @@ public class Arrays { * not mutually comparable using the specified comparator. */ public static void sort(T[] a, Comparator c) { - T[] aux = (T[])a.clone(); + T[] aux = a.clone(); if (c==null) mergeSort(aux, a, 0, a.length, 0); else @@ -1257,7 +1257,7 @@ public class Arrays { public static void sort(T[] a, int fromIndex, int toIndex, Comparator c) { rangeCheck(a.length, fromIndex, toIndex); - T[] aux = (T[])copyOfRange(a, fromIndex, toIndex); + T[] aux = copyOfRange(a, fromIndex, toIndex); if (c==null) mergeSort(aux, a, fromIndex, toIndex, -fromIndex); else @@ -4128,7 +4128,7 @@ public class Arrays { if (a.length != 0 && bufLen <= 0) bufLen = Integer.MAX_VALUE; StringBuilder buf = new StringBuilder(bufLen); - deepToString(a, buf, new HashSet()); + deepToString(a, buf, new HashSet()); return buf.toString(); } diff --git a/src/share/classes/java/util/EnumMap.java b/src/share/classes/java/util/EnumMap.java index 896e07d2833ddb84660f5b5acbccceea92dfc36b..867ccc7bc560a10379a02349993f2f136b7db114 100644 --- a/src/share/classes/java/util/EnumMap.java +++ b/src/share/classes/java/util/EnumMap.java @@ -140,7 +140,7 @@ public class EnumMap, V> extends AbstractMap public EnumMap(EnumMap m) { keyType = m.keyType; keyUniverse = m.keyUniverse; - vals = (Object[]) m.vals.clone(); + vals = m.vals.clone(); size = m.size; } @@ -161,7 +161,7 @@ public class EnumMap, V> extends AbstractMap EnumMap em = (EnumMap) m; keyType = em.keyType; keyUniverse = em.keyUniverse; - vals = (Object[]) em.vals.clone(); + vals = em.vals.clone(); size = em.size; } else { if (m.isEmpty()) @@ -257,7 +257,7 @@ public class EnumMap, V> extends AbstractMap public V put(K key, V value) { typeCheck(key); - int index = ((Enum)key).ordinal(); + int index = key.ordinal(); Object oldValue = vals[index]; vals[index] = maskNull(value); if (oldValue == null) @@ -662,7 +662,7 @@ public class EnumMap, V> extends AbstractMap } catch(CloneNotSupportedException e) { throw new AssertionError(); } - result.vals = (Object[]) result.vals.clone(); + result.vals = result.vals.clone(); return result; } diff --git a/src/share/classes/java/util/HashMap.java b/src/share/classes/java/util/HashMap.java index fbb7b730a72254fa7f9624e7797936043b990c13..daebd7867fe29f4e683920a7f2f85a6edad313fd 100644 --- a/src/share/classes/java/util/HashMap.java +++ b/src/share/classes/java/util/HashMap.java @@ -173,7 +173,7 @@ public class HashMap * rehash). This field is used to make iterators on Collection-views of * the HashMap fail-fast. (See ConcurrentModificationException). */ - transient volatile int modCount; + transient int modCount; /** * Constructs an empty HashMap with the specified initial diff --git a/src/share/classes/java/util/Hashtable.java b/src/share/classes/java/util/Hashtable.java index 46ff36b40965250a03b8b0712c664b5f36ddfaac..c19a6ad249a4f7b35e53a658c1b778e1f223671a 100644 --- a/src/share/classes/java/util/Hashtable.java +++ b/src/share/classes/java/util/Hashtable.java @@ -27,7 +27,7 @@ package java.util; import java.io.*; /** - * This class implements a hashtable, which maps keys to values. Any + * This class implements a hash table, which maps keys to values. Any * non-null object can be used as a key or as a value.

        * * To successfully store and retrieve objects from a hashtable, the @@ -100,9 +100,15 @@ import java.io.*; * *

        As of the Java 2 platform v1.2, this class was retrofitted to * implement the {@link Map} interface, making it a member of the - * Java - * Collections Framework. Unlike the new collection - * implementations, {@code Hashtable} is synchronized. + * + * + * Java Collections Framework. Unlike the new collection + * implementations, {@code Hashtable} is synchronized. If a + * thread-safe implementation is not needed, it is recommended to use + * {@link HashMap} in place of {@code Hashtable}. If a thread-safe + * highly-concurrent implementation is desired, then it is recommended + * to use {@link java.util.concurrent.ConcurrentHashMap} in place of + * {@code Hashtable}. * * @author Arthur van Hoff * @author Josh Bloch diff --git a/src/share/classes/java/util/IdentityHashMap.java b/src/share/classes/java/util/IdentityHashMap.java index 1898ccad515eef0fda6ad31c70d85604782dfd49..7e27bd76e8dc94cde2e24bf4d74cedb81304c43b 100644 --- a/src/share/classes/java/util/IdentityHashMap.java +++ b/src/share/classes/java/util/IdentityHashMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-2008 Sun Microsystems, 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 @@ -173,7 +173,7 @@ public class IdentityHashMap /** * The number of modifications, to support fast-fail iterators */ - private transient volatile int modCount; + private transient int modCount; /** * The next size value at which to resize (capacity * load factor). @@ -701,7 +701,7 @@ public class IdentityHashMap try { IdentityHashMap m = (IdentityHashMap) super.clone(); m.entrySet = null; - m.table = (Object[])table.clone(); + m.table = table.clone(); return m; } catch (CloneNotSupportedException e) { throw new InternalError(); @@ -749,7 +749,6 @@ public class IdentityHashMap expectedModCount = ++modCount; int deletedSlot = lastReturnedIndex; lastReturnedIndex = -1; - size--; // back up index to revisit new contents after deletion index = deletedSlot; indexValid = false; @@ -782,6 +781,8 @@ public class IdentityHashMap return; } + size--; + Object item; for (int i = nextKeyIndex(d, len); (item = tab[i]) != null; i = nextKeyIndex(i, len)) { @@ -975,7 +976,7 @@ public class IdentityHashMap */ public boolean removeAll(Collection c) { boolean modified = false; - for (Iterator i = iterator(); i.hasNext(); ) { + for (Iterator i = iterator(); i.hasNext(); ) { if (c.contains(i.next())) { i.remove(); modified = true; @@ -1033,7 +1034,7 @@ public class IdentityHashMap return containsValue(o); } public boolean remove(Object o) { - for (Iterator i = iterator(); i.hasNext(); ) { + for (Iterator i = iterator(); i.hasNext(); ) { if (i.next() == o) { i.remove(); return true; @@ -1121,7 +1122,7 @@ public class IdentityHashMap */ public boolean removeAll(Collection c) { boolean modified = false; - for (Iterator i = iterator(); i.hasNext(); ) { + for (Iterator> i = iterator(); i.hasNext(); ) { if (c.contains(i.next())) { i.remove(); modified = true; diff --git a/src/share/classes/java/util/JumboEnumSet.java b/src/share/classes/java/util/JumboEnumSet.java index 6512e2cd5c91eef066739c97adb6521e8897c713..de72c5fc5f99e8888dfd2bcff39f888eea233de4 100644 --- a/src/share/classes/java/util/JumboEnumSet.java +++ b/src/share/classes/java/util/JumboEnumSet.java @@ -364,7 +364,7 @@ class JumboEnumSet> extends EnumSet { public EnumSet clone() { JumboEnumSet result = (JumboEnumSet) super.clone(); - result.elements = (long[]) result.elements.clone(); + result.elements = result.elements.clone(); return result; } } diff --git a/src/share/classes/java/util/Random.java b/src/share/classes/java/util/Random.java index b16b48532b2eb59a7c3b8629a72885929393999a..f30feb934fe45a221d5142aa706733f7bef0cc82 100644 --- a/src/share/classes/java/util/Random.java +++ b/src/share/classes/java/util/Random.java @@ -504,7 +504,7 @@ class Random implements java.io.Serializable { // The seed is read in as {@code long} for // historical reasons, but it is converted to an AtomicLong. - long seedVal = (long) fields.get("seed", -1L); + long seedVal = fields.get("seed", -1L); if (seedVal < 0) throw new java.io.StreamCorruptedException( "Random: invalid seed"); diff --git a/src/share/classes/java/util/TreeSet.java b/src/share/classes/java/util/TreeSet.java index 81b02e3663a54d1f4e6090ef2ef8b5b6d9e392cd..c4d538e95932608808068675db4902d82db5e756 100644 --- a/src/share/classes/java/util/TreeSet.java +++ b/src/share/classes/java/util/TreeSet.java @@ -195,7 +195,7 @@ public class TreeSet extends AbstractSet * @since 1.6 */ public NavigableSet descendingSet() { - return new TreeSet(m.descendingMap()); + return new TreeSet(m.descendingMap()); } /** @@ -505,8 +505,8 @@ public class TreeSet extends AbstractSet s.writeInt(m.size()); // Write out all elements in the proper order. - for (Iterator i=m.keySet().iterator(); i.hasNext(); ) - s.writeObject(i.next()); + for (E e : m.keySet()) + s.writeObject(e); } /** diff --git a/src/share/classes/java/util/Vector.java b/src/share/classes/java/util/Vector.java index 209371c538dc42d84887d40aefbe0f3c9abb3190..ce5a2982fc210a13ce085973b8b68dca4078c4d9 100644 --- a/src/share/classes/java/util/Vector.java +++ b/src/share/classes/java/util/Vector.java @@ -64,15 +64,15 @@ package java.util; * *

        As of the Java 2 platform v1.2, this class was retrofitted to * implement the {@link List} interface, making it a member of the - * Java - * Collections Framework. Unlike the new collection - * implementations, {@code Vector} is synchronized. + * + * Java Collections Framework. Unlike the new collection + * implementations, {@code Vector} is synchronized. If a thread-safe + * implementation is not needed, it is recommended to use {@link + * ArrayList} in place of {@code Vector}. * * @author Lee Boynton * @author Jonathan Payne * @see Collection - * @see List - * @see ArrayList * @see LinkedList * @since JDK1.0 */ diff --git a/src/share/classes/java/util/WeakHashMap.java b/src/share/classes/java/util/WeakHashMap.java index 861faa9c297c5d658bd0f17347fac3696c482d2f..bdf52c579996125aaa14a4fd129ec19bc8c28ad1 100644 --- a/src/share/classes/java/util/WeakHashMap.java +++ b/src/share/classes/java/util/WeakHashMap.java @@ -29,7 +29,8 @@ import java.lang.ref.ReferenceQueue; /** - * A hashtable-based Map implementation with weak keys. + * Hash table based implementation of the Map interface, with + * weak keys. * An entry in a WeakHashMap will automatically be removed when * its key is no longer in ordinary use. More precisely, the presence of a * mapping for a given key will not prevent the key from being discarded by the @@ -181,7 +182,7 @@ public class WeakHashMap * * @see ConcurrentModificationException */ - volatile int modCount; + int modCount; @SuppressWarnings("unchecked") private Entry[] newTable(int n) { diff --git a/src/share/classes/java/util/concurrent/DelayQueue.java b/src/share/classes/java/util/concurrent/DelayQueue.java index 57350dd1c3cd788d929b2df5039fdd92c92f953c..a815bbc9bbb0127c2e7c3d4895cf4716bec4cdcf 100644 --- a/src/share/classes/java/util/concurrent/DelayQueue.java +++ b/src/share/classes/java/util/concurrent/DelayQueue.java @@ -69,9 +69,33 @@ public class DelayQueue extends AbstractQueue implements BlockingQueue { private transient final ReentrantLock lock = new ReentrantLock(); - private transient final Condition available = lock.newCondition(); private final PriorityQueue q = new PriorityQueue(); + /** + * Thread designated to wait for the element at the head of + * the queue. This variant of the Leader-Follower pattern + * (http://www.cs.wustl.edu/~schmidt/POSA/POSA2/) serves to + * minimize unnecessary timed waiting. When a thread becomes + * the leader, it waits only for the next delay to elapse, but + * other threads await indefinitely. The leader thread must + * signal some other thread before returning from take() or + * poll(...), unless some other thread becomes leader in the + * interim. Whenever the head of the queue is replaced with + * an element with an earlier expiration time, the leader + * field is invalidated by being reset to null, and some + * waiting thread, but not necessarily the current leader, is + * signalled. So waiting threads must be prepared to acquire + * and lose leadership while waiting. + */ + private Thread leader = null; + + /** + * Condition signalled when a newer element becomes available + * at the head of the queue or a new thread may need to + * become leader. + */ + private final Condition available = lock.newCondition(); + /** * Creates a new DelayQueue that is initially empty. */ @@ -111,10 +135,11 @@ public class DelayQueue extends AbstractQueue final ReentrantLock lock = this.lock; lock.lock(); try { - E first = q.peek(); q.offer(e); - if (first == null || e.compareTo(first) < 0) - available.signalAll(); + if (q.peek() == e) { + leader = null; + available.signal(); + } return true; } finally { lock.unlock(); @@ -160,13 +185,8 @@ public class DelayQueue extends AbstractQueue E first = q.peek(); if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) return null; - else { - E x = q.poll(); - assert x != null; - if (q.size() != 0) - available.signalAll(); - return x; - } + else + return q.poll(); } finally { lock.unlock(); } @@ -185,23 +205,29 @@ public class DelayQueue extends AbstractQueue try { for (;;) { E first = q.peek(); - if (first == null) { + if (first == null) available.await(); - } else { - long delay = first.getDelay(TimeUnit.NANOSECONDS); - if (delay > 0) { - long tl = available.awaitNanos(delay); - } else { - E x = q.poll(); - assert x != null; - if (q.size() != 0) - available.signalAll(); // wake up other takers - return x; - + else { + long delay = first.getDelay(TimeUnit.NANOSECONDS); + if (delay <= 0) + return q.poll(); + else if (leader != null) + available.await(); + else { + Thread thisThread = Thread.currentThread(); + leader = thisThread; + try { + available.awaitNanos(delay); + } finally { + if (leader == thisThread) + leader = null; + } } } } } finally { + if (leader == null && q.peek() != null) + available.signal(); lock.unlock(); } } @@ -230,23 +256,28 @@ public class DelayQueue extends AbstractQueue nanos = available.awaitNanos(nanos); } else { long delay = first.getDelay(TimeUnit.NANOSECONDS); - if (delay > 0) { - if (nanos <= 0) - return null; - if (delay > nanos) - delay = nanos; - long timeLeft = available.awaitNanos(delay); - nanos -= delay - timeLeft; - } else { - E x = q.poll(); - assert x != null; - if (q.size() != 0) - available.signalAll(); - return x; + if (delay <= 0) + return q.poll(); + if (nanos <= 0) + return null; + if (nanos < delay || leader != null) + nanos = available.awaitNanos(nanos); + else { + Thread thisThread = Thread.currentThread(); + leader = thisThread; + try { + long timeLeft = available.awaitNanos(delay); + nanos -= delay - timeLeft; + } finally { + if (leader == thisThread) + leader = null; + } } } } } finally { + if (leader == null && q.peek() != null) + available.signal(); lock.unlock(); } } @@ -303,8 +334,6 @@ public class DelayQueue extends AbstractQueue c.add(q.poll()); ++n; } - if (n > 0) - available.signalAll(); return n; } finally { lock.unlock(); @@ -335,8 +364,6 @@ public class DelayQueue extends AbstractQueue c.add(q.poll()); ++n; } - if (n > 0) - available.signalAll(); return n; } finally { lock.unlock(); @@ -485,6 +512,7 @@ public class DelayQueue extends AbstractQueue return cursor < array.length; } + @SuppressWarnings("unchecked") public E next() { if (cursor >= array.length) throw new NoSuchElementException(); diff --git a/src/share/classes/java/util/concurrent/ExecutorService.java b/src/share/classes/java/util/concurrent/ExecutorService.java index 36b035c33dc524e7f58a7c5ddb2392213e23dc85..6f1f5fa85519643cd16ceef9c8b8eaea37f0972d 100644 --- a/src/share/classes/java/util/concurrent/ExecutorService.java +++ b/src/share/classes/java/util/concurrent/ExecutorService.java @@ -145,6 +145,10 @@ public interface ExecutorService extends Executor { * tasks are executed, but no new tasks will be accepted. * Invocation has no additional effect if already shut down. * + *

        This method does not wait for previously submitted tasks to + * complete execution. Use {@link #awaitTermination awaitTermination} + * to do that. + * * @throws SecurityException if a security manager exists and * shutting down this ExecutorService may manipulate * threads that the caller is not permitted to modify @@ -157,8 +161,12 @@ public interface ExecutorService extends Executor { /** * Attempts to stop all actively executing tasks, halts the - * processing of waiting tasks, and returns a list of the tasks that were - * awaiting execution. + * processing of waiting tasks, and returns a list of the tasks + * that were awaiting execution. + * + *

        This method does not wait for actively executing tasks to + * terminate. Use {@link #awaitTermination awaitTermination} to + * do that. * *

        There are no guarantees beyond best-effort attempts to stop * processing actively executing tasks. For example, typical diff --git a/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java b/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java index f0b1f42f2b174ef3ceeffa8668f22b12d853f81e..dc7fe113f2aa7a59adb6a5114da5d8ac4c86e22c 100644 --- a/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java +++ b/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java @@ -35,6 +35,7 @@ package java.util.concurrent; import java.util.concurrent.atomic.*; +import java.util.concurrent.locks.*; import java.util.*; /** @@ -45,12 +46,21 @@ import java.util.*; * flexibility or capabilities of {@link ThreadPoolExecutor} (which * this class extends) are required. * - *

        Delayed tasks execute no sooner than they are enabled, but + *

        Delayed tasks execute no sooner than they are enabled, but * without any real-time guarantees about when, after they are * enabled, they will commence. Tasks scheduled for exactly the same * execution time are enabled in first-in-first-out (FIFO) order of * submission. * + *

        When a submitted task is cancelled before it is run, execution + * is suppressed. By default, such a cancelled task is not + * automatically removed from the work queue until its delay + * elapses. While this enables further inspection and monitoring, it + * may also cause unbounded retention of cancelled tasks. To avoid + * this, set {@link #setRemoveOnCancelPolicy} to {@code true}, which + * causes tasks to be immediately removed from the work queue at + * time of cancellation. + * *

        While this class inherits from {@link ThreadPoolExecutor}, a few * of the inherited tuning methods are not useful for it. In * particular, because it acts as a fixed-sized pool using @@ -111,21 +121,11 @@ public class ScheduledThreadPoolExecutor * ScheduledExecutorService methods) which are treated as * delayed tasks with a delay of zero. * - * 2. Using a custom queue (DelayedWorkQueue) based on an + * 2. Using a custom queue (DelayedWorkQueue), a variant of * unbounded DelayQueue. The lack of capacity constraint and * the fact that corePoolSize and maximumPoolSize are * effectively identical simplifies some execution mechanics - * (see delayedExecute) compared to ThreadPoolExecutor - * version. - * - * The DelayedWorkQueue class is defined below for the sake of - * ensuring that all elements are instances of - * RunnableScheduledFuture. Since DelayQueue otherwise - * requires type be Delayed, but not necessarily Runnable, and - * the workQueue requires the opposite, we need to explicitly - * define a class that requires both to ensure that users don't - * add objects that aren't RunnableScheduledFutures via - * getQueue().add() etc. + * (see delayedExecute) compared to ThreadPoolExecutor. * * 3. Supporting optional run-after-shutdown parameters, which * leads to overrides of shutdown methods to remove and cancel @@ -149,6 +149,11 @@ public class ScheduledThreadPoolExecutor */ private volatile boolean executeExistingDelayedTasksAfterShutdown = true; + /** + * True if ScheduledFutureTask.cancel should remove from queue + */ + private volatile boolean removeOnCancel = false; + /** * Sequence number to break scheduling ties, and in turn to * guarantee FIFO order among tied entries. @@ -167,8 +172,10 @@ public class ScheduledThreadPoolExecutor /** Sequence number to break ties FIFO */ private final long sequenceNumber; + /** The time the task is enabled to execute in nanoTime units */ private long time; + /** * Period in nanoseconds for repeating tasks. A positive * value indicates fixed-rate execution. A negative value @@ -180,6 +187,11 @@ public class ScheduledThreadPoolExecutor /** The actual task to be re-enqueued by reExecutePeriodic */ RunnableScheduledFuture outerTask = this; + /** + * Index into delay queue, to support faster cancellation. + */ + int heapIndex; + /** * Creates a one-shot action with given nanoTime-based trigger time. */ @@ -255,6 +267,13 @@ public class ScheduledThreadPoolExecutor time = now() - p; } + public boolean cancel(boolean mayInterruptIfRunning) { + boolean cancelled = super.cancel(mayInterruptIfRunning); + if (cancelled && removeOnCancel && heapIndex >= 0) + remove(this); + return cancelled; + } + /** * Overrides FutureTask version so as to reset/requeue if periodic. */ @@ -654,15 +673,48 @@ public class ScheduledThreadPoolExecutor return executeExistingDelayedTasksAfterShutdown; } + /** + * Sets the policy on whether cancelled tasks should be immediately + * removed from the work queue at time of cancellation. This value is + * by default {@code false}. + * + * @param value if {@code true}, remove on cancellation, else don't + * @see #getRemoveOnCancelPolicy + * @since 1.7 + */ + public void setRemoveOnCancelPolicy(boolean value) { + removeOnCancel = value; + } + + /** + * Gets the policy on whether cancelled tasks should be immediately + * removed from the work queue at time of cancellation. This value is + * by default {@code false}. + * + * @return {@code true} if cancelled tasks are immediately removed + * from the queue + * @see #setRemoveOnCancelPolicy + * @since 1.7 + */ + public boolean getRemoveOnCancelPolicy() { + return removeOnCancel; + } + /** * Initiates an orderly shutdown in which previously submitted - * tasks are executed, but no new tasks will be accepted. If the - * {@code ExecuteExistingDelayedTasksAfterShutdownPolicy} has - * been set {@code false}, existing delayed tasks whose delays - * have not yet elapsed are cancelled. And unless the - * {@code ContinueExistingPeriodicTasksAfterShutdownPolicy} has - * been set {@code true}, future executions of existing periodic - * tasks will be cancelled. + * tasks are executed, but no new tasks will be accepted. + * Invocation has no additional effect if already shut down. + * + *

        This method does not wait for previously submitted tasks to + * complete execution. Use {@link #awaitTermination awaitTermination} + * to do that. + * + *

        If the {@code ExecuteExistingDelayedTasksAfterShutdownPolicy} + * has been set {@code false}, existing delayed tasks whose delays + * have not yet elapsed are cancelled. And unless the {@code + * ContinueExistingPeriodicTasksAfterShutdownPolicy} has been set + * {@code true}, future executions of existing periodic tasks will + * be cancelled. * * @throws SecurityException {@inheritDoc} */ @@ -675,6 +727,10 @@ public class ScheduledThreadPoolExecutor * processing of waiting tasks, and returns a list of the tasks * that were awaiting execution. * + *

        This method does not wait for actively executing tasks to + * terminate. Use {@link #awaitTermination awaitTermination} to + * do that. + * *

        There are no guarantees beyond best-effort attempts to stop * processing actively executing tasks. This implementation * cancels tasks via {@link Thread#interrupt}, so any task that @@ -707,56 +763,478 @@ public class ScheduledThreadPoolExecutor } /** - * An annoying wrapper class to convince javac to use a - * DelayQueue as a BlockingQueue + * Specialized delay queue. To mesh with TPE declarations, this + * class must be declared as a BlockingQueue even though + * it can only hold RunnableScheduledFutures. */ - private static class DelayedWorkQueue - extends AbstractCollection + static class DelayedWorkQueue extends AbstractQueue implements BlockingQueue { - private final DelayQueue dq = new DelayQueue(); - public Runnable poll() { return dq.poll(); } - public Runnable peek() { return dq.peek(); } - public Runnable take() throws InterruptedException { return dq.take(); } - public Runnable poll(long timeout, TimeUnit unit) throws InterruptedException { - return dq.poll(timeout, unit); + /* + * A DelayedWorkQueue is based on a heap-based data structure + * like those in DelayQueue and PriorityQueue, except that + * every ScheduledFutureTask also records its index into the + * heap array. This eliminates the need to find a task upon + * cancellation, greatly speeding up removal (down from O(n) + * to O(log n)), and reducing garbage retention that would + * otherwise occur by waiting for the element to rise to top + * before clearing. But because the queue may also hold + * RunnableScheduledFutures that are not ScheduledFutureTasks, + * we are not guaranteed to have such indices available, in + * which case we fall back to linear search. (We expect that + * most tasks will not be decorated, and that the faster cases + * will be much more common.) + * + * All heap operations must record index changes -- mainly + * within siftUp and siftDown. Upon removal, a task's + * heapIndex is set to -1. Note that ScheduledFutureTasks can + * appear at most once in the queue (this need not be true for + * other kinds of tasks or work queues), so are uniquely + * identified by heapIndex. + */ + + private static final int INITIAL_CAPACITY = 16; + private RunnableScheduledFuture[] queue = + new RunnableScheduledFuture[INITIAL_CAPACITY]; + private final ReentrantLock lock = new ReentrantLock(); + private int size = 0; + + /** + * Thread designated to wait for the task at the head of the + * queue. This variant of the Leader-Follower pattern + * (http://www.cs.wustl.edu/~schmidt/POSA/POSA2/) serves to + * minimize unnecessary timed waiting. When a thread becomes + * the leader, it waits only for the next delay to elapse, but + * other threads await indefinitely. The leader thread must + * signal some other thread before returning from take() or + * poll(...), unless some other thread becomes leader in the + * interim. Whenever the head of the queue is replaced with a + * task with an earlier expiration time, the leader field is + * invalidated by being reset to null, and some waiting + * thread, but not necessarily the current leader, is + * signalled. So waiting threads must be prepared to acquire + * and lose leadership while waiting. + */ + private Thread leader = null; + + /** + * Condition signalled when a newer task becomes available at the + * head of the queue or a new thread may need to become leader. + */ + private final Condition available = lock.newCondition(); + + /** + * Set f's heapIndex if it is a ScheduledFutureTask. + */ + private void setIndex(RunnableScheduledFuture f, int idx) { + if (f instanceof ScheduledFutureTask) + ((ScheduledFutureTask)f).heapIndex = idx; } - public boolean add(Runnable x) { - return dq.add((RunnableScheduledFuture)x); + /** + * Sift element added at bottom up to its heap-ordered spot. + * Call only when holding lock. + */ + private void siftUp(int k, RunnableScheduledFuture key) { + while (k > 0) { + int parent = (k - 1) >>> 1; + RunnableScheduledFuture e = queue[parent]; + if (key.compareTo(e) >= 0) + break; + queue[k] = e; + setIndex(e, k); + k = parent; + } + queue[k] = key; + setIndex(key, k); } + + /** + * Sift element added at top down to its heap-ordered spot. + * Call only when holding lock. + */ + private void siftDown(int k, RunnableScheduledFuture key) { + int half = size >>> 1; + while (k < half) { + int child = (k << 1) + 1; + RunnableScheduledFuture c = queue[child]; + int right = child + 1; + if (right < size && c.compareTo(queue[right]) > 0) + c = queue[child = right]; + if (key.compareTo(c) <= 0) + break; + queue[k] = c; + setIndex(c, k); + k = child; + } + queue[k] = key; + setIndex(key, k); + } + + /** + * Resize the heap array. Call only when holding lock. + */ + private void grow() { + int oldCapacity = queue.length; + int newCapacity = oldCapacity + (oldCapacity >> 1); // grow 50% + if (newCapacity < 0) // overflow + newCapacity = Integer.MAX_VALUE; + queue = Arrays.copyOf(queue, newCapacity); + } + + /** + * Find index of given object, or -1 if absent + */ + private int indexOf(Object x) { + if (x != null) { + if (x instanceof ScheduledFutureTask) { + int i = ((ScheduledFutureTask) x).heapIndex; + // Sanity check; x could conceivably be a + // ScheduledFutureTask from some other pool. + if (i >= 0 && i < size && queue[i] == x) + return i; + } else { + for (int i = 0; i < size; i++) + if (x.equals(queue[i])) + return i; + } + } + return -1; + } + + public boolean contains(Object x) { + final ReentrantLock lock = this.lock; + lock.lock(); + try { + return indexOf(x) != -1; + } finally { + lock.unlock(); + } + } + + public boolean remove(Object x) { + final ReentrantLock lock = this.lock; + lock.lock(); + try { + int i = indexOf(x); + if (i < 0) + return false; + + setIndex(queue[i], -1); + int s = --size; + RunnableScheduledFuture replacement = queue[s]; + queue[s] = null; + if (s != i) { + siftDown(i, replacement); + if (queue[i] == replacement) + siftUp(i, replacement); + } + return true; + } finally { + lock.unlock(); + } + } + + public int size() { + final ReentrantLock lock = this.lock; + lock.lock(); + try { + return size; + } finally { + lock.unlock(); + } + } + + public boolean isEmpty() { + return size() == 0; + } + + public int remainingCapacity() { + return Integer.MAX_VALUE; + } + + public RunnableScheduledFuture peek() { + final ReentrantLock lock = this.lock; + lock.lock(); + try { + return queue[0]; + } finally { + lock.unlock(); + } + } + public boolean offer(Runnable x) { - return dq.offer((RunnableScheduledFuture)x); + if (x == null) + throw new NullPointerException(); + RunnableScheduledFuture e = (RunnableScheduledFuture)x; + final ReentrantLock lock = this.lock; + lock.lock(); + try { + int i = size; + if (i >= queue.length) + grow(); + size = i + 1; + if (i == 0) { + queue[0] = e; + setIndex(e, 0); + } else { + siftUp(i, e); + } + if (queue[0] == e) { + leader = null; + available.signal(); + } + } finally { + lock.unlock(); + } + return true; + } + + public void put(Runnable e) { + offer(e); + } + + public boolean add(Runnable e) { + return offer(e); + } + + public boolean offer(Runnable e, long timeout, TimeUnit unit) { + return offer(e); + } + + /** + * Performs common bookkeeping for poll and take: Replaces + * first element with last and sifts it down. Call only when + * holding lock. + * @param f the task to remove and return + */ + private RunnableScheduledFuture finishPoll(RunnableScheduledFuture f) { + int s = --size; + RunnableScheduledFuture x = queue[s]; + queue[s] = null; + if (s != 0) + siftDown(0, x); + setIndex(f, -1); + return f; + } + + public RunnableScheduledFuture poll() { + final ReentrantLock lock = this.lock; + lock.lock(); + try { + RunnableScheduledFuture first = queue[0]; + if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) + return null; + else + return finishPoll(first); + } finally { + lock.unlock(); + } + } + + public RunnableScheduledFuture take() throws InterruptedException { + final ReentrantLock lock = this.lock; + lock.lockInterruptibly(); + try { + for (;;) { + RunnableScheduledFuture first = queue[0]; + if (first == null) + available.await(); + else { + long delay = first.getDelay(TimeUnit.NANOSECONDS); + if (delay <= 0) + return finishPoll(first); + else if (leader != null) + available.await(); + else { + Thread thisThread = Thread.currentThread(); + leader = thisThread; + try { + available.awaitNanos(delay); + } finally { + if (leader == thisThread) + leader = null; + } + } + } + } + } finally { + if (leader == null && queue[0] != null) + available.signal(); + lock.unlock(); + } + } + + public RunnableScheduledFuture poll(long timeout, TimeUnit unit) + throws InterruptedException { + long nanos = unit.toNanos(timeout); + final ReentrantLock lock = this.lock; + lock.lockInterruptibly(); + try { + for (;;) { + RunnableScheduledFuture first = queue[0]; + if (first == null) { + if (nanos <= 0) + return null; + else + nanos = available.awaitNanos(nanos); + } else { + long delay = first.getDelay(TimeUnit.NANOSECONDS); + if (delay <= 0) + return finishPoll(first); + if (nanos <= 0) + return null; + if (nanos < delay || leader != null) + nanos = available.awaitNanos(nanos); + else { + Thread thisThread = Thread.currentThread(); + leader = thisThread; + try { + long timeLeft = available.awaitNanos(delay); + nanos -= delay - timeLeft; + } finally { + if (leader == thisThread) + leader = null; + } + } + } + } + } finally { + if (leader == null && queue[0] != null) + available.signal(); + lock.unlock(); + } } - public void put(Runnable x) { - dq.put((RunnableScheduledFuture)x); + + public void clear() { + final ReentrantLock lock = this.lock; + lock.lock(); + try { + for (int i = 0; i < size; i++) { + RunnableScheduledFuture t = queue[i]; + if (t != null) { + queue[i] = null; + setIndex(t, -1); + } + } + size = 0; + } finally { + lock.unlock(); + } } - public boolean offer(Runnable x, long timeout, TimeUnit unit) { - return dq.offer((RunnableScheduledFuture)x, timeout, unit); + + /** + * Return and remove first element only if it is expired. + * Used only by drainTo. Call only when holding lock. + */ + private RunnableScheduledFuture pollExpired() { + RunnableScheduledFuture first = queue[0]; + if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) + return null; + return finishPoll(first); + } + + public int drainTo(Collection c) { + if (c == null) + throw new NullPointerException(); + if (c == this) + throw new IllegalArgumentException(); + final ReentrantLock lock = this.lock; + lock.lock(); + try { + RunnableScheduledFuture first; + int n = 0; + while ((first = pollExpired()) != null) { + c.add(first); + ++n; + } + return n; + } finally { + lock.unlock(); + } } - public Runnable remove() { return dq.remove(); } - public Runnable element() { return dq.element(); } - public void clear() { dq.clear(); } - public int drainTo(Collection c) { return dq.drainTo(c); } public int drainTo(Collection c, int maxElements) { - return dq.drainTo(c, maxElements); + if (c == null) + throw new NullPointerException(); + if (c == this) + throw new IllegalArgumentException(); + if (maxElements <= 0) + return 0; + final ReentrantLock lock = this.lock; + lock.lock(); + try { + RunnableScheduledFuture first; + int n = 0; + while (n < maxElements && (first = pollExpired()) != null) { + c.add(first); + ++n; + } + return n; + } finally { + lock.unlock(); + } + } + + public Object[] toArray() { + final ReentrantLock lock = this.lock; + lock.lock(); + try { + return Arrays.copyOf(queue, size, Object[].class); + } finally { + lock.unlock(); + } + } + + @SuppressWarnings("unchecked") + public T[] toArray(T[] a) { + final ReentrantLock lock = this.lock; + lock.lock(); + try { + if (a.length < size) + return (T[]) Arrays.copyOf(queue, size, a.getClass()); + System.arraycopy(queue, 0, a, 0, size); + if (a.length > size) + a[size] = null; + return a; + } finally { + lock.unlock(); + } } - public int remainingCapacity() { return dq.remainingCapacity(); } - public boolean remove(Object x) { return dq.remove(x); } - public boolean contains(Object x) { return dq.contains(x); } - public int size() { return dq.size(); } - public boolean isEmpty() { return dq.isEmpty(); } - public Object[] toArray() { return dq.toArray(); } - public T[] toArray(T[] array) { return dq.toArray(array); } public Iterator iterator() { - return new Iterator() { - private Iterator it = dq.iterator(); - public boolean hasNext() { return it.hasNext(); } - public Runnable next() { return it.next(); } - public void remove() { it.remove(); } - }; + return new Itr(Arrays.copyOf(queue, size)); + } + + /** + * Snapshot iterator that works off copy of underlying q array. + */ + private class Itr implements Iterator { + final RunnableScheduledFuture[] array; + int cursor = 0; // index of next element to return + int lastRet = -1; // index of last element, or -1 if no such + + Itr(RunnableScheduledFuture[] array) { + this.array = array; + } + + public boolean hasNext() { + return cursor < array.length; + } + + public Runnable next() { + if (cursor >= array.length) + throw new NoSuchElementException(); + lastRet = cursor; + return array[cursor++]; + } + + public void remove() { + if (lastRet < 0) + throw new IllegalStateException(); + DelayedWorkQueue.this.remove(array[lastRet]); + lastRet = -1; + } } } } diff --git a/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java b/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java index 150ceca17477a7c36373809a7bb602ed10dc4ae7..7ea1d5ab4ba690715a596beda331f41db4fdc953 100644 --- a/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java +++ b/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java @@ -1342,6 +1342,10 @@ public class ThreadPoolExecutor extends AbstractExecutorService { * tasks are executed, but no new tasks will be accepted. * Invocation has no additional effect if already shut down. * + *

        This method does not wait for previously submitted tasks to + * complete execution. Use {@link #awaitTermination awaitTermination} + * to do that. + * * @throws SecurityException {@inheritDoc} */ public void shutdown() { @@ -1364,6 +1368,10 @@ public class ThreadPoolExecutor extends AbstractExecutorService { * that were awaiting execution. These tasks are drained (removed) * from the task queue upon return from this method. * + *

        This method does not wait for actively executing tasks to + * terminate. Use {@link #awaitTermination awaitTermination} to + * do that. + * *

        There are no guarantees beyond best-effort attempts to stop * processing actively executing tasks. This implementation * cancels tasks via {@link Thread#interrupt}, so any task that diff --git a/src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java b/src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java index c9280c851270c7b2a5d5603788376fed81c7b7e6..8888efb2477a57994432cdb724ba0969333a567f 100644 --- a/src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java +++ b/src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java @@ -222,7 +222,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab /** Inner class providing writelock */ private final ReentrantReadWriteLock.WriteLock writerLock; /** Performs all synchronization mechanics */ - private final Sync sync; + final Sync sync; /** * Creates a new {@code ReentrantReadWriteLock} with @@ -239,7 +239,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab * @param fair {@code true} if this lock should use a fair ordering policy */ public ReentrantReadWriteLock(boolean fair) { - sync = (fair)? new FairSync() : new NonfairSync(); + sync = fair ? new FairSync() : new NonfairSync(); readerLock = new ReadLock(this); writerLock = new WriteLock(this); } @@ -256,8 +256,8 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab /* * Read vs write count extraction constants and functions. - * Lock state is logically divided into two shorts: The lower - * one representing the exclusive (writer) lock hold count, + * Lock state is logically divided into two unsigned shorts: + * The lower one representing the exclusive (writer) lock hold count, * and the upper the shared (reader) hold count. */ @@ -279,13 +279,6 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab int count; // Use id, not reference, to avoid garbage retention final long tid = Thread.currentThread().getId(); - /** Decrement if positive; return previous value */ - int tryDecrement() { - int c = count; - if (c > 0) - count = c - 1; - return c; - } } /** @@ -303,7 +296,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab * The number of read locks held by current thread. * Initialized only in constructor and readObject. */ - transient ThreadLocalHoldCounter readHolds; + private transient ThreadLocalHoldCounter readHolds; /** * The hold count of the last thread to successfully acquire @@ -312,7 +305,17 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab * acquire. This is non-volatile since it is just used * as a heuristic, and would be great for threads to cache. */ - transient HoldCounter cachedHoldCounter; + private transient HoldCounter cachedHoldCounter; + + /** + * firstReader is the first thread to have acquired the read lock. + * firstReaderHoldCount is firstReader's hold count. + * This allows tracking of read holds for uncontended read + * locks to be very cheap. + */ + private final static long INVALID_THREAD_ID = -1; + private transient long firstReader = INVALID_THREAD_ID; + private transient int firstReaderHoldCount; Sync() { readHolds = new ThreadLocalHoldCounter(); @@ -390,12 +393,25 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab } protected final boolean tryReleaseShared(int unused) { - HoldCounter rh = cachedHoldCounter; - Thread current = Thread.currentThread(); - if (rh == null || rh.tid != current.getId()) - rh = readHolds.get(); - if (rh.tryDecrement() <= 0) - throw new IllegalMonitorStateException(); + long tid = Thread.currentThread().getId(); + if (firstReader == tid) { + // assert firstReaderHoldCount > 0; + if (firstReaderHoldCount == 1) + firstReader = INVALID_THREAD_ID; + else + firstReaderHoldCount--; + } else { + HoldCounter rh = cachedHoldCounter; + if (rh == null || rh.tid != tid) + rh = readHolds.get(); + int count = rh.count; + if (count <= 1) { + readHolds.remove(); + if (count <= 0) + throw unmatchedUnlockException(); + } + --rh.count; + } for (;;) { int c = getState(); int nextc = c - SHARED_UNIT; @@ -404,12 +420,16 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab } } + private IllegalMonitorStateException unmatchedUnlockException() { + return new IllegalMonitorStateException( + "attempt to unlock read lock, not locked by current thread"); + } + protected final int tryAcquireShared(int unused) { /* * Walkthrough: * 1. If write lock held by another thread, fail. - * 2. If count saturated, throw error. - * 3. Otherwise, this thread is eligible for + * 2. Otherwise, this thread is eligible for * lock wrt state, so ask if it should block * because of queue policy. If not, try * to grant by CASing state and updating count. @@ -417,23 +437,33 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab * acquires, which is postponed to full version * to avoid having to check hold count in * the more typical non-reentrant case. - * 4. If step 3 fails either because thread - * apparently not eligible or CAS fails, - * chain to version with full retry loop. + * 3. If step 2 fails either because thread + * apparently not eligible or CAS fails or count + * saturated, chain to version with full retry loop. */ Thread current = Thread.currentThread(); int c = getState(); if (exclusiveCount(c) != 0 && getExclusiveOwnerThread() != current) return -1; - if (sharedCount(c) == MAX_COUNT) - throw new Error("Maximum lock count exceeded"); + int r = sharedCount(c); if (!readerShouldBlock() && + r < MAX_COUNT && compareAndSetState(c, c + SHARED_UNIT)) { - HoldCounter rh = cachedHoldCounter; - if (rh == null || rh.tid != current.getId()) - cachedHoldCounter = rh = readHolds.get(); - rh.count++; + long tid = current.getId(); + if (r == 0) { + firstReader = tid; + firstReaderHoldCount = 1; + } else if (firstReader == tid) { + firstReaderHoldCount++; + } else { + HoldCounter rh = cachedHoldCounter; + if (rh == null || rh.tid != tid) + cachedHoldCounter = rh = readHolds.get(); + else if (rh.count == 0) + readHolds.set(rh); + rh.count++; + } return 1; } return fullTryAcquireShared(current); @@ -450,20 +480,56 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab * complicating tryAcquireShared with interactions between * retries and lazily reading hold counts. */ - HoldCounter rh = cachedHoldCounter; - if (rh == null || rh.tid != current.getId()) - rh = readHolds.get(); + HoldCounter rh = null; for (;;) { int c = getState(); - int w = exclusiveCount(c); - if ((w != 0 && getExclusiveOwnerThread() != current) || - ((rh.count | w) == 0 && readerShouldBlock())) - return -1; + if (exclusiveCount(c) != 0) { + if (getExclusiveOwnerThread() != current) + //if (removeNeeded) readHolds.remove(); + return -1; + // else we hold the exclusive lock; blocking here + // would cause deadlock. + } else if (readerShouldBlock()) { + // Make sure we're not acquiring read lock reentrantly + long tid = current.getId(); + if (firstReader == tid) { + // assert firstReaderHoldCount > 0; + } else { + if (rh == null) { + rh = cachedHoldCounter; + if (rh == null || rh.tid != tid) { + rh = readHolds.get(); + if (rh.count == 0) + readHolds.remove(); + } + } + if (rh.count == 0) + return -1; + } + } if (sharedCount(c) == MAX_COUNT) throw new Error("Maximum lock count exceeded"); if (compareAndSetState(c, c + SHARED_UNIT)) { - cachedHoldCounter = rh; // cache for release - rh.count++; + long tid = current.getId(); + if (sharedCount(c) == 0) { + firstReader = tid; + firstReaderHoldCount = 1; + } else if (firstReader == tid) { + firstReaderHoldCount++; + } else { + if (rh == null) { + rh = cachedHoldCounter; + if (rh != null && rh.tid == tid) { + if (rh.count == 0) + readHolds.set(rh); + } else { + rh = readHolds.get(); + } + } else if (rh.count == 0) + readHolds.set(rh); + cachedHoldCounter = rh; // cache for release + rh.count++; + } return 1; } } @@ -472,14 +538,14 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab /** * Performs tryLock for write, enabling barging in both modes. * This is identical in effect to tryAcquire except for lack - * of calls to writerShouldBlock + * of calls to writerShouldBlock. */ final boolean tryWriteLock() { Thread current = Thread.currentThread(); int c = getState(); if (c != 0) { int w = exclusiveCount(c); - if (w == 0 ||current != getExclusiveOwnerThread()) + if (w == 0 || current != getExclusiveOwnerThread()) return false; if (w == MAX_COUNT) throw new Error("Maximum lock count exceeded"); @@ -493,7 +559,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab /** * Performs tryLock for read, enabling barging in both modes. * This is identical in effect to tryAcquireShared except for - * lack of calls to readerShouldBlock + * lack of calls to readerShouldBlock. */ final boolean tryReadLock() { Thread current = Thread.currentThread(); @@ -502,13 +568,24 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab if (exclusiveCount(c) != 0 && getExclusiveOwnerThread() != current) return false; - if (sharedCount(c) == MAX_COUNT) + int r = sharedCount(c); + if (r == MAX_COUNT) throw new Error("Maximum lock count exceeded"); if (compareAndSetState(c, c + SHARED_UNIT)) { - HoldCounter rh = cachedHoldCounter; - if (rh == null || rh.tid != current.getId()) - cachedHoldCounter = rh = readHolds.get(); - rh.count++; + long tid = current.getId(); + if (r == 0) { + firstReader = tid; + firstReaderHoldCount = 1; + } else if (firstReader == tid) { + firstReaderHoldCount++; + } else { + HoldCounter rh = cachedHoldCounter; + if (rh == null || rh.tid != tid) + cachedHoldCounter = rh = readHolds.get(); + else if (rh.count == 0) + readHolds.set(rh); + rh.count++; + } return true; } } @@ -546,7 +623,20 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab } final int getReadHoldCount() { - return getReadLockCount() == 0? 0 : readHolds.get().count; + if (getReadLockCount() == 0) + return 0; + + long tid = Thread.currentThread().getId(); + if (firstReader == tid) + return firstReaderHoldCount; + + HoldCounter rh = cachedHoldCounter; + if (rh != null && rh.tid == tid) + return rh.count; + + int count = readHolds.get().count; + if (count == 0) readHolds.remove(); + return count; } /** @@ -557,6 +647,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); readHolds = new ThreadLocalHoldCounter(); + firstReader = INVALID_THREAD_ID; setState(0); // reset to unlocked state } diff --git a/src/share/classes/java/util/logging/Logging.java b/src/share/classes/java/util/logging/Logging.java index 8ff810fbd95537eb65dfa1deb603db4737d7a559..559bc6b4d0b04535a7d2a8389921435fd4487e97 100644 --- a/src/share/classes/java/util/logging/Logging.java +++ b/src/share/classes/java/util/logging/Logging.java @@ -29,6 +29,8 @@ import java.util.Enumeration; import java.util.List; import java.util.ArrayList; +import javax.management.ObjectName; + /** * Logging is the implementation class of LoggingMXBean. * @@ -115,4 +117,7 @@ class Logging implements LoggingMXBean { } } + public ObjectName getObjectName() { + return com.sun.jmx.mbeanserver.Util.newObjectName(LogManager.LOGGING_MXBEAN_NAME); + } } diff --git a/src/share/classes/java/util/logging/LoggingMXBean.java b/src/share/classes/java/util/logging/LoggingMXBean.java index 771849c70b96eaa26a0d3b8f6872d684b3cf385e..c9917bea4ae1b990df92a15c4c1850d351ec3bf3 100644 --- a/src/share/classes/java/util/logging/LoggingMXBean.java +++ b/src/share/classes/java/util/logging/LoggingMXBean.java @@ -25,6 +25,8 @@ package java.util.logging; +import java.lang.management.PlatformManagedObject; + /** * The management interface for the logging facility. * @@ -43,14 +45,17 @@ package java.util.logging; * java.util.logging:type=Logging} * * - * @see java.lang.management.ManagementFactory + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * + * @see java.lang.management.ManagementFactory#getPlatformMXBeans(Class) * * @author Ron Mann * @author Mandy Chung * @since 1.5 * */ -public interface LoggingMXBean { +public interface LoggingMXBean extends PlatformManagedObject { /** * Returns the list of currently registered loggers. This method diff --git a/src/share/classes/java/util/prefs/AbstractPreferences.java b/src/share/classes/java/util/prefs/AbstractPreferences.java index 029133714ea0acfc12d1f091b9665965406da317..ebf975ccfd89e6ae88ebcf21d8f8b2c58106e7d4 100644 --- a/src/share/classes/java/util/prefs/AbstractPreferences.java +++ b/src/share/classes/java/util/prefs/AbstractPreferences.java @@ -155,7 +155,8 @@ public abstract class AbstractPreferences extends Preferences { * All known unremoved children of this node. (This "cache" is consulted * prior to calling childSpi() or getChild(). */ - private Map kidCache = new HashMap(); + private Map kidCache + = new HashMap(); /** * This field is used to keep track of whether or not this node has @@ -712,11 +713,10 @@ public abstract class AbstractPreferences extends Preferences { if (removed) throw new IllegalStateException("Node has been removed."); - Set s = new TreeSet(kidCache.keySet()); - String[] kids = childrenNamesSpi(); - for(int i=0; i s = new TreeSet(kidCache.keySet()); + for (String kid : childrenNamesSpi()) + s.add(kid); + return s.toArray(EMPTY_STRING_ARRAY); } } @@ -728,8 +728,7 @@ public abstract class AbstractPreferences extends Preferences { * @return all known unremoved children of this node. */ protected final AbstractPreferences[] cachedChildren() { - return (AbstractPreferences[]) kidCache.values(). - toArray(EMPTY_ABSTRACT_PREFS_ARRAY); + return kidCache.values().toArray(EMPTY_ABSTRACT_PREFS_ARRAY); } private static final AbstractPreferences[] EMPTY_ABSTRACT_PREFS_ARRAY @@ -825,7 +824,7 @@ public abstract class AbstractPreferences extends Preferences { if (token.equals("/")) // Check for consecutive slashes throw new IllegalArgumentException("Consecutive slashes in path"); synchronized(lock) { - AbstractPreferences child=(AbstractPreferences)kidCache.get(token); + AbstractPreferences child = kidCache.get(token); if (child == null) { if (token.length() > MAX_NAME_LENGTH) throw new IllegalArgumentException( @@ -893,7 +892,7 @@ public abstract class AbstractPreferences extends Preferences { if (token.equals("/")) // Check for consecutive slashes throw new IllegalArgumentException("Consecutive slashes in path"); synchronized(lock) { - AbstractPreferences child=(AbstractPreferences)kidCache.get(token); + AbstractPreferences child = kidCache.get(token); if (child == null) child = getChild(token); if (child==null) @@ -964,9 +963,10 @@ public abstract class AbstractPreferences extends Preferences { kidCache.put(kidNames[i], childSpi(kidNames[i])); // Recursively remove all cached children - for (Iterator i = kidCache.values().iterator(); i.hasNext();) { + for (Iterator i = kidCache.values().iterator(); + i.hasNext();) { try { - ((AbstractPreferences)i.next()).removeNode2(); + i.next().removeNode2(); i.remove(); } catch (BackingStoreException x) { } } @@ -1020,13 +1020,12 @@ public abstract class AbstractPreferences extends Preferences { * preference tree. */ public boolean isUserNode() { - Boolean result = (Boolean) - AccessController.doPrivileged( new PrivilegedAction() { - public Object run() { - return Boolean.valueOf(root == Preferences.userRoot()); + return AccessController.doPrivileged( + new PrivilegedAction() { + public Boolean run() { + return root == Preferences.userRoot(); } - }); - return result.booleanValue(); + }).booleanValue(); } public void addPreferenceChangeListener(PreferenceChangeListener pcl) { @@ -1443,7 +1442,8 @@ public abstract class AbstractPreferences extends Preferences { * event delivery from preference activity, greatly simplifying * locking and reducing opportunity for deadlock. */ - private static final List eventQueue = new LinkedList(); + private static final List eventQueue + = new LinkedList(); /** * These two classes are used to distinguish NodeChangeEvents on @@ -1476,7 +1476,7 @@ public abstract class AbstractPreferences extends Preferences { try { while (eventQueue.isEmpty()) eventQueue.wait(); - event = (EventObject) eventQueue.remove(0); + event = eventQueue.remove(0); } catch (InterruptedException e) { // XXX Log "Event dispatch thread interrupted. Exiting" return; diff --git a/src/share/classes/java/util/prefs/Preferences.java b/src/share/classes/java/util/prefs/Preferences.java index 1c25cfdbc13273b3bd21870b2f09fd924100c5f6..1aad5d9f0ef9fb529960b72bf9723035e507aa06 100644 --- a/src/share/classes/java/util/prefs/Preferences.java +++ b/src/share/classes/java/util/prefs/Preferences.java @@ -32,9 +32,8 @@ import java.security.AccessController; import java.security.Permission; import java.security.PrivilegedAction; import java.util.Iterator; -import sun.misc.Service; -import sun.misc.ServiceConfigurationError; - +import java.util.ServiceLoader; +import java.util.ServiceConfigurationError; // These imports needed only as a workaround for a JavaDoc bug import java.lang.RuntimePermission; @@ -274,12 +273,14 @@ public abstract class Preferences { private static PreferencesFactory factory1() { // 2. Try service provider interface - Iterator i = Service.providers(PreferencesFactory.class, - ClassLoader.getSystemClassLoader()); + Iterator itr = ServiceLoader + .load(PreferencesFactory.class, ClassLoader.getSystemClassLoader()) + .iterator(); + // choose first provider instance - while (i.hasNext()) { + while (itr.hasNext()) { try { - return (PreferencesFactory) i.next(); + return itr.next(); } catch (ServiceConfigurationError sce) { if (sce.getCause() instanceof SecurityException) { // Ignore the security exception, try the next provider diff --git a/src/share/classes/java/util/regex/Matcher.java b/src/share/classes/java/util/regex/Matcher.java index 5dc6caa19d2f2c422e0edf7dfe6cfe2c84bc1c0f..60dabaa279aa13fe49400f90d9dd78a570884e2f 100644 --- a/src/share/classes/java/util/regex/Matcher.java +++ b/src/share/classes/java/util/regex/Matcher.java @@ -249,7 +249,7 @@ public final class Matcher implements MatchResult { Matcher result = new Matcher(this.parentPattern, text.toString()); result.first = this.first; result.last = this.last; - result.groups = (int[])(this.groups.clone()); + result.groups = this.groups.clone(); return result; } diff --git a/src/share/classes/java/util/regex/Pattern.java b/src/share/classes/java/util/regex/Pattern.java index 91ee38eb7a027d0afccb2ef650f8be866e99b1c7..2b60313673a7254785651b97ce2ce318c07cdae0 100644 --- a/src/share/classes/java/util/regex/Pattern.java +++ b/src/share/classes/java/util/regex/Pattern.java @@ -2844,7 +2844,15 @@ loop: for(int x=0, offset=0; xAttributeValueExp may be used anywhere a ValueExp is required. + *

        Represents attributes used as arguments to relational constraints. + * Instances of this class are usually obtained using {@link Query#attr(String) + * Query.attr}.

        + * + *

        An AttributeValueExp may be used anywhere a + * ValueExp is required. * * @since 1.5 */ @@ -46,6 +51,8 @@ public class AttributeValueExp implements ValueExp { */ private String attr; + private transient int dotIndex; + /** * An AttributeValueExp with a null attribute. * @deprecated An instance created with this constructor cannot be @@ -64,6 +71,18 @@ public class AttributeValueExp implements ValueExp { */ public AttributeValueExp(String attr) { this.attr = attr; + setDotIndex(); + } + + private void setDotIndex() { + if (attr != null) + dotIndex = attr.indexOf('.'); + } + + private void readObject(ObjectInputStream in) + throws ClassNotFoundException, IOException { + in.defaultReadObject(); + setDotIndex(); } /** @@ -76,7 +95,13 @@ public class AttributeValueExp implements ValueExp { } /** - * Applies the AttributeValueExp on an MBean. + *

        Applies the AttributeValueExp on an MBean. + * This method calls {@link #getAttribute getAttribute(name)} and wraps + * the result as a {@code ValueExp}. The value returned by + * {@code getAttribute} must be a {@code Number}, {@code String}, + * or {@code Boolean}; otherwise this method throws a + * {@code BadAttributeValueExpException}, which will cause + * the containing query to be false for this {@code name}.

        * * @param name The name of the MBean on which the AttributeValueExp will be applied. * @@ -88,6 +113,7 @@ public class AttributeValueExp implements ValueExp { * @exception BadBinaryOpValueExpException * */ + @Override public ValueExp apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException { Object result = getAttribute(name); @@ -106,8 +132,9 @@ public class AttributeValueExp implements ValueExp { /** * Returns the string representing its value. */ + @Override public String toString() { - return attr; + return QueryParser.quoteId(attr); } @@ -115,18 +142,38 @@ public class AttributeValueExp implements ValueExp { * Sets the MBean server on which the query is to be performed. * * @param s The MBean server on which the query is to be performed. + * + * @deprecated This method has no effect. The MBean Server used to + * obtain an attribute value is {@link QueryEval#getMBeanServer()}. */ /* There is no need for this method, because if a query is being evaluted an AttributeValueExp can only appear inside a QueryExp, and that QueryExp will itself have done setMBeanServer. */ + @Deprecated + @Override public void setMBeanServer(MBeanServer s) { } /** - * Return the value of the given attribute in the named MBean. + *

        Return the value of the given attribute in the named MBean. * If the attempt to access the attribute generates an exception, - * return null. + * return null.

        + * + *

        Let n be the {@linkplain #getAttributeName attribute + * name}. Then this method proceeds as follows. First it calls + * {@link MBeanServer#getAttribute getAttribute(name, n)}. If that + * generates an {@link AttributeNotFoundException}, and if n + * contains at least one dot ({@code .}), then the method calls {@code + * getAttribute(name, }n{@code .substring(0, }n{@code + * .indexOf('.')))}; in other words it calls {@code getAttribute} + * with the substring of n before the first dot. Then it + * extracts a component from the retrieved value, as described in the documentation for the {@code + * monitor} package.

        + * + *

        The MBean Server used is the one returned by {@link + * QueryEval#getMBeanServer()}.

        * * @param name the name of the MBean whose attribute is to be returned. * @@ -139,10 +186,34 @@ public class AttributeValueExp implements ValueExp { MBeanServer server = QueryEval.getMBeanServer(); + try { return server.getAttribute(name, attr); + } catch (AttributeNotFoundException e) { + if (dotIndex < 0) + throw e; + } + + String toGet = attr.substring(0, dotIndex); + + Object value = server.getAttribute(name, toGet); + + return extractElement(value, attr.substring(dotIndex + 1)); } catch (Exception re) { return null; } } + private Object extractElement(Object value, String elementWithDots) + throws AttributeNotFoundException { + while (true) { + int dot = elementWithDots.indexOf('.'); + String element = (dot < 0) ? + elementWithDots : elementWithDots.substring(0, dot); + value = Introspector.elementFromComplex(value, element); + if (dot < 0) + return value; + elementWithDots = elementWithDots.substring(dot + 1); + } + } + } diff --git a/src/share/classes/javax/management/BetweenQueryExp.java b/src/share/classes/javax/management/BetweenQueryExp.java index 247c6b4bab7b6821444c2ad5a167e5a4d9daa246..4079f6379618141f2cbaf81073803babdd8c717c 100644 --- a/src/share/classes/javax/management/BetweenQueryExp.java +++ b/src/share/classes/javax/management/BetweenQueryExp.java @@ -109,34 +109,25 @@ class BetweenQueryExp extends QueryEval implements QueryExp { ValueExp val1 = exp1.apply(name); ValueExp val2 = exp2.apply(name); ValueExp val3 = exp3.apply(name); - String sval1; - String sval2; - String sval3; - double dval1; - double dval2; - double dval3; - long lval1; - long lval2; - long lval3; boolean numeric = val1 instanceof NumericValueExp; if (numeric) { if (((NumericValueExp)val1).isLong()) { - lval1 = ((NumericValueExp)val1).longValue(); - lval2 = ((NumericValueExp)val2).longValue(); - lval3 = ((NumericValueExp)val3).longValue(); + long lval1 = ((NumericValueExp)val1).longValue(); + long lval2 = ((NumericValueExp)val2).longValue(); + long lval3 = ((NumericValueExp)val3).longValue(); return lval2 <= lval1 && lval1 <= lval3; } else { - dval1 = ((NumericValueExp)val1).doubleValue(); - dval2 = ((NumericValueExp)val2).doubleValue(); - dval3 = ((NumericValueExp)val3).doubleValue(); + double dval1 = ((NumericValueExp)val1).doubleValue(); + double dval2 = ((NumericValueExp)val2).doubleValue(); + double dval3 = ((NumericValueExp)val3).doubleValue(); return dval2 <= dval1 && dval1 <= dval3; } } else { - sval1 = ((StringValueExp)val1).toString(); - sval2 = ((StringValueExp)val2).toString(); - sval3 = ((StringValueExp)val3).toString(); + String sval1 = ((StringValueExp)val1).getValue(); + String sval2 = ((StringValueExp)val2).getValue(); + String sval3 = ((StringValueExp)val3).getValue(); return sval2.compareTo(sval1) <= 0 && sval1.compareTo(sval3) <= 0; } } @@ -148,4 +139,8 @@ class BetweenQueryExp extends QueryEval implements QueryExp { return "(" + exp1 + ") between (" + exp2 + ") and (" + exp3 + ")"; } - } + @Override + String toQueryString() { + return exp1 + " between " + exp2 + " and " + exp3; + } +} diff --git a/src/share/classes/javax/management/BinaryOpValueExp.java b/src/share/classes/javax/management/BinaryOpValueExp.java index 536f1f615661cfb2c09fd66ac7204d71e2607979..138258b9d2a1b42003f583a57ae2a1101b25d06b 100644 --- a/src/share/classes/javax/management/BinaryOpValueExp.java +++ b/src/share/classes/javax/management/BinaryOpValueExp.java @@ -167,12 +167,74 @@ class BinaryOpValueExp extends QueryEval implements ValueExp { */ public String toString() { try { - return exp1 + " " + opString() + " " + exp2; + return parens(exp1, true) + " " + opString() + " " + parens(exp2, false); } catch (BadBinaryOpValueExpException ex) { return "invalid expression"; } } + /* + * Add parentheses to the given subexpression if necessary to + * preserve meaning. Suppose this BinaryOpValueExp is + * Query.times(Query.plus(Query.attr("A"), Query.attr("B")), Query.attr("C")). + * Then the original toString() logic would return A + B * C. + * We check precedences in order to return (A + B) * C, which is the + * meaning of the ValueExp. + * + * We need to add parentheses if the unparenthesized expression would + * be parsed as a different ValueExp from the original. + * We cannot omit parentheses even when mathematically + * the result would be equivalent, because we do not know whether the + * numeric values will be integer or floating-point. Addition and + * multiplication are associative for integers but not always for + * floating-point. + * + * So the rule is that we omit parentheses if the ValueExp + * is (A op1 B) op2 C and the precedence of op1 is greater than or + * equal to that of op2; or if the ValueExp is A op1 (B op2 C) and + * the precedence of op2 is greater than that of op1. (There are two + * precedences: that of * and / is greater than that of + and -.) + * The case of (A op1 B) op2 (C op3 D) applies each rule in turn. + * + * The following examples show the rules in action. On the left, + * the original ValueExp. On the right, the string representation. + * + * (A + B) + C A + B + C + * (A * B) + C A * B + C + * (A + B) * C (A + B) * C + * (A * B) * C A * B * C + * A + (B + C) A + (B + C) + * A + (B * C) A + B * C + * A * (B + C) A * (B + C) + * A * (B * C) A * (B * C) + */ + private String parens(ValueExp subexp, boolean left) + throws BadBinaryOpValueExpException { + boolean omit; + if (subexp instanceof BinaryOpValueExp) { + int subop = ((BinaryOpValueExp) subexp).op; + if (left) + omit = (precedence(subop) >= precedence(op)); + else + omit = (precedence(subop) > precedence(op)); + } else + omit = true; + + if (omit) + return subexp.toString(); + else + return "(" + subexp + ")"; + } + + private int precedence(int xop) throws BadBinaryOpValueExpException { + switch (xop) { + case Query.PLUS: case Query.MINUS: return 0; + case Query.TIMES: case Query.DIV: return 1; + default: + throw new BadBinaryOpValueExpException(this); + } + } + private String opString() throws BadBinaryOpValueExpException { switch (op) { case Query.PLUS: @@ -188,4 +250,10 @@ class BinaryOpValueExp extends QueryEval implements ValueExp { throw new BadBinaryOpValueExpException(this); } + @Deprecated + public void setMBeanServer(MBeanServer s) { + super.setMBeanServer(s); + } + + } diff --git a/src/share/classes/javax/management/BinaryRelQueryExp.java b/src/share/classes/javax/management/BinaryRelQueryExp.java index 47809f35d9de1d5ae0e043f391ad440fa7be10b4..2e740aee2bde49a132ef53ae270d7765573a6452 100644 --- a/src/share/classes/javax/management/BinaryRelQueryExp.java +++ b/src/share/classes/javax/management/BinaryRelQueryExp.java @@ -108,20 +108,12 @@ class BinaryRelQueryExp extends QueryEval implements QueryExp { BadAttributeValueExpException, InvalidApplicationException { Object val1 = exp1.apply(name); Object val2 = exp2.apply(name); - String sval1; - String sval2; - double dval1; - double dval2; - long lval1; - long lval2; - boolean bval1; - boolean bval2; boolean numeric = val1 instanceof NumericValueExp; boolean bool = val1 instanceof BooleanValueExp; if (numeric) { if (((NumericValueExp)val1).isLong()) { - lval1 = ((NumericValueExp)val1).longValue(); - lval2 = ((NumericValueExp)val2).longValue(); + long lval1 = ((NumericValueExp)val1).longValue(); + long lval2 = ((NumericValueExp)val2).longValue(); switch (relOp) { case Query.GT: @@ -136,8 +128,8 @@ class BinaryRelQueryExp extends QueryEval implements QueryExp { return lval1 == lval2; } } else { - dval1 = ((NumericValueExp)val1).doubleValue(); - dval2 = ((NumericValueExp)val2).doubleValue(); + double dval1 = ((NumericValueExp)val1).doubleValue(); + double dval2 = ((NumericValueExp)val2).doubleValue(); switch (relOp) { case Query.GT: @@ -155,8 +147,8 @@ class BinaryRelQueryExp extends QueryEval implements QueryExp { } else if (bool) { - bval1 = ((BooleanValueExp)val1).getValue().booleanValue(); - bval2 = ((BooleanValueExp)val2).getValue().booleanValue(); + boolean bval1 = ((BooleanValueExp)val1).getValue().booleanValue(); + boolean bval2 = ((BooleanValueExp)val2).getValue().booleanValue(); switch (relOp) { case Query.GT: @@ -172,8 +164,8 @@ class BinaryRelQueryExp extends QueryEval implements QueryExp { } } else { - sval1 = ((StringValueExp)val1).getValue(); - sval2 = ((StringValueExp)val2).getValue(); + String sval1 = ((StringValueExp)val1).getValue(); + String sval2 = ((StringValueExp)val2).getValue(); switch (relOp) { case Query.GT: @@ -199,6 +191,11 @@ class BinaryRelQueryExp extends QueryEval implements QueryExp { return "(" + exp1 + ") " + relOpString() + " (" + exp2 + ")"; } + @Override + String toQueryString() { + return exp1 + " " + relOpString() + " " + exp2; + } + private String relOpString() { switch (relOp) { case Query.GT: diff --git a/src/share/classes/javax/management/BooleanValueExp.java b/src/share/classes/javax/management/BooleanValueExp.java index 6dc569744cf0324745bdb7728fdb252ac95d3340..7a5348fd0ab8c56cb4e824bda1811b9bad396608 100644 --- a/src/share/classes/javax/management/BooleanValueExp.java +++ b/src/share/classes/javax/management/BooleanValueExp.java @@ -84,4 +84,10 @@ class BooleanValueExp extends QueryEval implements ValueExp { return this; } + @Deprecated + public void setMBeanServer(MBeanServer s) { + super.setMBeanServer(s); + } + + } diff --git a/src/share/classes/javax/management/InQueryExp.java b/src/share/classes/javax/management/InQueryExp.java index 01f2c503a1b8d4800c135e951eb0fbea375a8ef1..103ba3b8633b37c873eaf084682b827a7ee2ec08 100644 --- a/src/share/classes/javax/management/InQueryExp.java +++ b/src/share/classes/javax/management/InQueryExp.java @@ -91,21 +91,23 @@ class InQueryExp extends QueryEval implements QueryExp { * @exception BadAttributeValueExpException * @exception InvalidApplicationException */ - public boolean apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, + public boolean apply(ObjectName name) + throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException { if (valueList != null) { ValueExp v = val.apply(name); boolean numeric = v instanceof NumericValueExp; - for (int i = 0; i < valueList.length; i++) { + for (ValueExp element : valueList) { + element = element.apply(name); if (numeric) { - if (((NumericValueExp)valueList[i]).doubleValue() == - ((NumericValueExp)v).doubleValue()) { + if (((NumericValueExp) element).doubleValue() == + ((NumericValueExp) v).doubleValue()) { return true; } } else { - if (((StringValueExp)valueList[i]).getValue().equals( - ((StringValueExp)v).getValue())) { + if (((StringValueExp) element).getValue().equals( + ((StringValueExp) v).getValue())) { return true; } } diff --git a/src/share/classes/javax/management/MBeanServer.java b/src/share/classes/javax/management/MBeanServer.java index 607f234c8b054b5810febe5596cdef06dc90f7ce..728f71340ba7f12b3076778f4961fc7d9053a3a9 100644 --- a/src/share/classes/javax/management/MBeanServer.java +++ b/src/share/classes/javax/management/MBeanServer.java @@ -50,7 +50,7 @@ import javax.management.loading.ClassLoaderRepository; * server. A Java object cannot be registered in the MBean server * unless it is a JMX compliant MBean.

        * - *

        When an MBean is registered or unregistered in the MBean server + *

        When an MBean is registered or unregistered in the MBean server * a {@link javax.management.MBeanServerNotification * MBeanServerNotification} Notification is emitted. To register an * object as listener to MBeanServerNotifications you should call the @@ -258,27 +258,43 @@ import javax.management.loading.ClassLoaderRepository; */ public interface MBeanServer extends MBeanServerConnection { - // doc comment inherited from MBeanServerConnection + /** + * {@inheritDoc} + *

        If this method successfully creates an MBean, a notification + * is sent as described above.

        + */ public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException; - // doc comment inherited from MBeanServerConnection + /** + * {@inheritDoc} + *

        If this method successfully creates an MBean, a notification + * is sent as described above.

        + */ public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException; - // doc comment inherited from MBeanServerConnection + /** + * {@inheritDoc} + *

        If this method successfully creates an MBean, a notification + * is sent as described above.

        + */ public ObjectInstance createMBean(String className, ObjectName name, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException; - // doc comment inherited from MBeanServerConnection + /** + * {@inheritDoc} + *

        If this method successfully creates an MBean, a notification + * is sent as described above.

        + */ public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object params[], String signature[]) @@ -287,12 +303,15 @@ public interface MBeanServer extends MBeanServerConnection { NotCompliantMBeanException, InstanceNotFoundException; /** - * Registers a pre-existing object as an MBean with the MBean + *

        Registers a pre-existing object as an MBean with the MBean * server. If the object name given is null, the MBean must * provide its own name by implementing the {@link * javax.management.MBeanRegistration MBeanRegistration} interface * and returning the name from the {@link - * MBeanRegistration#preRegister preRegister} method. + * MBeanRegistration#preRegister preRegister} method.

        + * + *

        If this method successfully registers an MBean, a notification + * is sent as described above.

        * * @param object The MBean to be registered as an MBean. * @param name The object name of the MBean. May be null. @@ -319,7 +338,12 @@ public interface MBeanServer extends MBeanServerConnection { throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException; - // doc comment inherited from MBeanServerConnection + /** + * {@inheritDoc} + * + *

        If this method successfully unregisters an MBean, a notification + * is sent as described above.

        + */ public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException; diff --git a/src/share/classes/javax/management/MatchQueryExp.java b/src/share/classes/javax/management/MatchQueryExp.java index 12e42769ffdf0973c026939ef83b3643c4958c75..779fac1989ff2605b4fc28a3299f16844670c951 100644 --- a/src/share/classes/javax/management/MatchQueryExp.java +++ b/src/share/classes/javax/management/MatchQueryExp.java @@ -113,7 +113,32 @@ class MatchQueryExp extends QueryEval implements QueryExp { } private static String likeTranslate(String s) { - return s.replace('?', '_').replace('*', '%'); + StringBuilder sb = new StringBuilder(); + int c; + for (int i = 0; i < s.length(); i += Character.charCount(c)) { + c = s.codePointAt(i); + switch (c) { + case '\\': + i += Character.charCount(c); + sb.append('\\'); + if (i < s.length()) { + c = s.codePointAt(i); + sb.appendCodePoint(c); + } + break; + case '*': + sb.append('%'); break; + case '?': + sb.append('_'); break; + case '%': + sb.append("\\%"); break; + case '_': + sb.append("\\_"); break; + default: + sb.appendCodePoint(c); break; + } + } + return sb.toString(); } /* diff --git a/src/share/classes/javax/management/NotQueryExp.java b/src/share/classes/javax/management/NotQueryExp.java index a099152012a9eae87aa064c595c87e28d99ca99d..ef2dc57b797e41deb45b576ee3f76008faa8dcf3 100644 --- a/src/share/classes/javax/management/NotQueryExp.java +++ b/src/share/classes/javax/management/NotQueryExp.java @@ -86,8 +86,14 @@ class NotQueryExp extends QueryEval implements QueryExp { /** * Returns the string representing the object. */ + @Override public String toString() { return "not (" + exp + ")"; } + @Override + String toQueryString() { + return "not (" + Query.toString(exp) + ")"; + } + } diff --git a/src/share/classes/javax/management/NumericValueExp.java b/src/share/classes/javax/management/NumericValueExp.java index bd8da33eaabc7a00d315792278fc32ca1823a984..c823a93deb4fc22d846dee50b963bce899983b37 100644 --- a/src/share/classes/javax/management/NumericValueExp.java +++ b/src/share/classes/javax/management/NumericValueExp.java @@ -151,11 +151,18 @@ class NumericValueExp extends QueryEval implements ValueExp { * Returns the string representing the object */ public String toString() { + if (val == null) + return "null"; if (val instanceof Long || val instanceof Integer) { - return String.valueOf(val.longValue()); + return Long.toString(val.longValue()); } - return String.valueOf(val.doubleValue()); + double d = val.doubleValue(); + if (Double.isInfinite(d)) + return (d > 0) ? "(1.0 / 0.0)" : "(-1.0 / 0.0)"; + if (Double.isNaN(d)) + return "(0.0 / 0.0)"; + return Double.toString(d); } /** @@ -244,4 +251,10 @@ class NumericValueExp extends QueryEval implements ValueExp { out.defaultWriteObject(); } } + + @Deprecated + public void setMBeanServer(MBeanServer s) { + super.setMBeanServer(s); + } + } diff --git a/src/share/classes/javax/management/ObjectName.java b/src/share/classes/javax/management/ObjectName.java index 8721bb62d18a9fdac85397a1cf6a49fec357f53c..ff11962b666e8a9bfeb7d67342a0e67606be626d 100644 --- a/src/share/classes/javax/management/ObjectName.java +++ b/src/share/classes/javax/management/ObjectName.java @@ -26,6 +26,7 @@ package javax.management; import com.sun.jmx.mbeanserver.GetPropertyAction; +import com.sun.jmx.mbeanserver.Util; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectInputStream; @@ -222,7 +223,8 @@ import javax.management.QueryExp; * @since 1.5 */ @SuppressWarnings("serial") // don't complain serialVersionUID not constant -public class ObjectName implements Comparable, QueryExp { +public class ObjectName extends ToQueryString + implements Comparable, QueryExp { /** * A structure recording property structure and @@ -1385,12 +1387,7 @@ public class ObjectName implements Comparable, QueryExp { throws NullPointerException { if (name.getClass().equals(ObjectName.class)) return name; - try { - return new ObjectName(name.getSerializedNameString()); - } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Unexpected: " + e); - // can't happen - } + return Util.newObjectName(name.getSerializedNameString()); } /** @@ -1779,10 +1776,16 @@ public class ObjectName implements Comparable, QueryExp { * * @return a string representation of this object name. */ + @Override public String toString() { return getSerializedNameString(); } + @Override + String toQueryString() { + return "LIKE " + Query.value(toString()); + } + /** * Compares the current object name with another object name. Two * ObjectName instances are equal if and only if their canonical @@ -1943,14 +1946,7 @@ public class ObjectName implements Comparable, QueryExp { * * @since 1.6 */ - public static final ObjectName WILDCARD; - static { - try { - WILDCARD = new ObjectName("*:*"); - } catch (MalformedObjectNameException e) { - throw new Error("Can't initialize wildcard name", e); - } - } + public static final ObjectName WILDCARD = Util.newObjectName("*:*"); // Category : Utilities <=================================== diff --git a/src/share/classes/javax/management/OrQueryExp.java b/src/share/classes/javax/management/OrQueryExp.java index 772a32385aeb8b18bb6f780f38fd148013976e3f..e1ca5122f2890de1836e870c81483aa60f44684f 100644 --- a/src/share/classes/javax/management/OrQueryExp.java +++ b/src/share/classes/javax/management/OrQueryExp.java @@ -98,9 +98,29 @@ class OrQueryExp extends QueryEval implements QueryExp { } /** - * Returns a string representation of this AndQueryExp + * Returns a string representation of this OrQueryExp */ public String toString() { return "(" + exp1 + ") or (" + exp2 + ")"; } + + @Override + String toQueryString() { + return parens(exp1) + " or " + parens(exp2); + } + + // Add parentheses to avoid possible confusion. If we have an expression + // such as Query.or(Query.and(a, b), c), then we return + // (a and b) or c + // rather than just + // a and b or c + // In fact the precedence rules are such that the parentheses are not + // strictly necessary, but omitting them would be confusing. + private static String parens(QueryExp exp) { + String s = Query.toString(exp); + if (exp instanceof AndQueryExp) + return "(" + s + ")"; + else + return s; + } } diff --git a/src/share/classes/javax/management/QualifiedAttributeValueExp.java b/src/share/classes/javax/management/QualifiedAttributeValueExp.java index fe7ce41a012920785772ae87652b3708ba572218..3934d27084f8a105e66711b26ea638c6aa149ef8 100644 --- a/src/share/classes/javax/management/QualifiedAttributeValueExp.java +++ b/src/share/classes/javax/management/QualifiedAttributeValueExp.java @@ -27,9 +27,11 @@ package javax.management; /** - * This class represents indexed attributes used as arguments to relational - * constraints. An QualifiedAttributeValueExp may be used anywhere a - * ValueExp is required. + *

        Represents attributes used as arguments to relational constraints, + * where the attribute must be in an MBean of a specified {@linkplain + * MBeanInfo#getClassName() class}. A QualifiedAttributeValueExp may be used + * anywhere a ValueExp is required. + * * @serial include * * @since 1.5 @@ -48,7 +50,9 @@ class QualifiedAttributeValueExp extends AttributeValueExp { /** * Basic Constructor. + * @deprecated see {@link AttributeValueExp#AttributeValueExp()} */ + @Deprecated public QualifiedAttributeValueExp() { } @@ -81,6 +85,7 @@ class QualifiedAttributeValueExp extends AttributeValueExp { * @exception BadAttributeValueExpException * @exception InvalidApplicationException */ + @Override public ValueExp apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException { try { @@ -105,9 +110,11 @@ class QualifiedAttributeValueExp extends AttributeValueExp { /** * Returns the string representing its value */ + @Override public String toString() { if (className != null) { - return className + "." + super.toString(); + return QueryParser.quoteId(className) + "#" + + QueryParser.quoteId(super.toString()); } else { return super.toString(); } diff --git a/src/share/classes/javax/management/Query.java b/src/share/classes/javax/management/Query.java index 84a71da510b0570b20bf056ad9e3dbacbc4c1b2e..d3b461da75d593087d070063a654faac9e90c4a8 100644 --- a/src/share/classes/javax/management/Query.java +++ b/src/share/classes/javax/management/Query.java @@ -27,19 +27,346 @@ package javax.management; /** - *

        Constructs query object constraints. The static methods provided - * return query expressions that may be used in listing and - * enumerating MBeans. Individual constraint construction methods - * allow only appropriate types as arguments. Composition of calls can - * construct arbitrary nestings of constraints, as the following - * example illustrates:

        + *

        Constructs query object constraints.

        + * + *

        The MBean Server can be queried for MBeans that meet a particular + * condition, using its {@link MBeanServer#queryNames queryNames} or + * {@link MBeanServer#queryMBeans queryMBeans} method. The {@link QueryExp} + * parameter to the method can be any implementation of the interface + * {@code QueryExp}, but it is usually best to obtain the {@code QueryExp} + * value by calling the static methods in this class. This is particularly + * true when querying a remote MBean Server: a custom implementation of the + * {@code QueryExp} interface might not be present in the remote MBean Server, + * but the methods in this class return only standard classes that are + * part of the JMX implementation.

        + * + *

        There are two ways to create {@code QueryExp} objects using the methods + * in this class. The first is to build them by chaining together calls to + * the various methods. The second is to use the Query Language described + * below and produce the {@code QueryExp} by calling + * {@link #fromString Query.fromString}. The two ways are equivalent: + * every {@code QueryExp} returned by {@code fromString} can also be + * constructed by chaining method calls.

        + * + *

        As an example, suppose you wanted to find all MBeans where the {@code + * Enabled} attribute is {@code true} and the {@code Owner} attribute is {@code + * "Duke"}. Here is how you could construct the appropriate {@code QueryExp} by + * chaining together method calls:

        + * + *
        + * QueryExp query =
        + *     Query.and(Query.eq(Query.attr("Enabled"), Query.value(true)),
        + *               Query.eq(Query.attr("Owner"), Query.value("Duke")));
        + * 
        + * + *

        Here is how you could construct the same {@code QueryExp} using the + * Query Language:

        * *
        - * QueryExp exp = Query.and(Query.gt(Query.attr("age"),Query.value(5)),
        - *                          Query.match(Query.attr("name"),
        - *                                      Query.value("Smith")));
        + * QueryExp query = Query.fromString("Enabled = true and Owner = 'Duke'");
          * 
        * + *

        The principal advantage of the method-chaining approach is that the + * compiler will check that the query makes sense. The principal advantage + * of the Query Language approach is that it is easier to write and especially + * read.

        + * + * + *

        Query Language

        + * + *

        The query language is closely modeled on the WHERE clause of + * SQL SELECT statements. The formal specification of the language + * appears below, but it is probably easier to + * understand it with examples such as the following.

        + * + *
        + *
        {@code Message = 'OK'} + *
        Selects MBeans that have a {@code Message} attribute whose value + * is the string {@code OK}. + * + *
        {@code FreeSpacePercent < 10} + *
        Selects MBeans that have a {@code FreeSpacePercent} attribute whose + * value is a number less than 10. + * + *
        {@code FreeSpacePercent < 10 and WarningSent = false} + *
        Selects the same MBeans as the previous example, but they must + * also have a boolean attribute {@code WarningSent} whose value + * is false. + * + *
        {@code SpaceUsed > TotalSpace * (2.0 / 3.0)} + *
        Selects MBeans that have {@code SpaceUsed} and {@code TotalSpace} + * attributes where the first is more than two-thirds the second. + * + *
        {@code not (FreeSpacePercent between 10 and 90)} + *
        Selects MBeans that have a {@code FreeSpacePercent} attribute whose + * value is not between 10 and 90, inclusive. + * + *
        {@code FreeSpacePercent not between 10 and 90} + *
        Another way of writing the previous query. + * + *
        {@code Status in ('STOPPED', 'STARTING', 'STARTED')} + *
        Selects MBeans that have a {@code Status} attribute whose value + * is one of those three strings. + * + *
        {@code Message like 'OK: %'} + *
        Selects MBeans that have a {@code Message} attribute whose value + * is a string beginning with {@code "OK: "}. Notice that the + * wildcard characters are SQL's ones. In the query language, + * {@code %} means "any sequence of characters" and {@code _} + * means "any single character". In the rest of the JMX API, these + * correspond to {@code *} and {@code %} respectively. + * + *
        {@code instanceof 'javax.management.NotificationBroadcaster'} + *
        Selects MBeans that are instances of + * {@link javax.management.NotificationBroadcaster}, as reported by + * {@link javax.management.MBeanServer#isInstanceOf MBeanServer.isInstanceOf}. + * + *
        {@code like 'mydomain:*'} + *
        Selects MBeans whose {@link ObjectName}s have the domain {@code mydomain}. + * + *
        + * + *

        The last two examples do not correspond to valid SQL syntax, but all + * the others do.

        + * + *

        The remainder of this description is a formal specification of the + * query language.

        + * + * + *

        Lexical elements

        + * + *

        Keywords such as and, like, and between are not + * case sensitive. You can write between, BETWEEN, or + * BeTwEeN with the same effect.

        + * + *

        On the other hand, attribute names are case sensitive. The + * attribute {@code Name} is not the same as the attribute {@code name}.

        + * + *

        To access an attribute whose name, ignoring case, is the same as one of + * the keywords {@code not}, {@code instanceof}, {@code like}, {@code true}, + * or {@code false}, you can use double quotes, for example {@code "not"}. + * Double quotes can also be used to include non-identifier characters in + * the name of an attribute, for example {@code "attribute-name-with-hyphens"}. + * To include the double quote character in the attribute name, write it + * twice. {@code "foo""bar""baz"} represents the attribute called + * {@code foo"bar"baz}. + * + *

        String constants are written with single quotes like {@code 'this'}. A + * single quote within a string constant must be doubled, for example + * {@code 'can''t'}.

        + * + *

        Integer constants are written as a sequence of decimal digits, + * optionally preceded by a plus or minus sign. An integer constant must be + * a valid input to {@link Long#valueOf(String)}.

        + * + *

        Floating-point constants are written using the Java syntax. A + * floating-point constant must be a valid input to + * {@link Double#valueOf(String)}.

        + * + *

        A boolean constant is either {@code true} or {@code false}, ignoring + * case.

        + * + *

        Spaces cannot appear inside identifiers (unless written with double + * quotes) or keywords or multi-character tokens such as {@code <=}. Spaces can + * appear anywhere else, but are not required except to separate tokens. For + * example, the query {@code a < b and 5 = c} could also be written {@code a + * + * + *

        Grammar

        + * + *
        + *
        query: + *
        andquery [OR query] + * + *
        andquery: + *
        predicate [AND andquery] + * + *
        predicate: + *
        ( query ) |
        + * NOT predicate |
        + * INSTANCEOF stringvalue |
        + * LIKE objectnamepattern |
        + * value predrhs + * + *
        predrhs: + *
        compare value |
        + * [NOT] BETWEEN value AND + * value |
        + * [NOT] IN ( value + * commavalues ) |
        + * [NOT] LIKE stringvalue + * + *
        commavalues: + *
        [ , value commavalues ] + * + *
        compare: + *
        = | < | > | + * <= | >= | <> | != + * + *
        value: + *
        factor [plusorminus + * value] + * + *
        plusorminus: + *
        + | - + * + *
        factor: + *
        term [timesordivide + * factor] + * + *
        timesordivide: + *
        * | / + * + *
        term: + *
        attr | literal | + * ( value ) + * + *
        attr: + *
        name [# name] + * + *
        name: + *
        identifier [.name] + * + *
        identifier: + *
        Java-identifier | double-quoted-identifier + * + *
        literal: + *
        booleanlit | longlit | + * doublelit | stringlit + * + *
        booleanlit: + *
        FALSE | TRUE + * + *
        stringvalue: + *
        stringlit + * + *
        objectnamepattern: + *
        stringlit + * + *
        + * + * + *

        Semantics

        + * + *

        The meaning of the grammar is described in the table below. + * This defines a function q that maps a string to a Java object + * such as a {@link QueryExp} or a {@link ValueExp}.

        + * + * + * + * + *
        String sq(s)
        query1 OR query2 + * {@link Query#or Query.or}(q(query1), q(query2)) + * + *
        query1 AND query2 + * {@link Query#and Query.and}(q(query1), q(query2)) + * + *
        ( queryOrValue ) + * q(queryOrValue) + * + *
        NOT query + * {@link Query#not Query.not}(q(query)) + * + *
        INSTANCEOF stringLiteral + * {@link Query#isInstanceOf Query.isInstanceOf}({@link Query#value(String) Query.value}(q(stringLiteral))) + * + *
        LIKE stringLiteral + * {@link ObjectName#ObjectName(String) new ObjectName}(q(stringLiteral)) + * + *
        value1 = value2 + * {@link Query#eq Query.eq}(q(value1), q(value2)) + * + *
        value1 < value2 + * {@link Query#lt Query.lt}(q(value1), q(value2)) + * + *
        value1 > value2 + * {@link Query#gt Query.gt}(q(value1), q(value2)) + * + *
        value1 <= value2 + * {@link Query#leq Query.leq}(q(value1), q(value2)) + * + *
        value1 >= value2 + * {@link Query#geq Query.geq}(q(value1), q(value2)) + * + *
        value1 <> value2 + * {@link Query#not Query.not}({@link Query#eq Query.eq}(q(value1), q(value2))) + * + *
        value1 != value2 + * {@link Query#not Query.not}({@link Query#eq Query.eq}(q(value1), q(value2))) + * + *
        value1 BETWEEN value2 AND value3 + * {@link Query#between Query.between}(q(value1), + * q(value2), q(value3)) + * + *
        value1 NOT BETWEEN value2 AND value3 + * {@link Query#not Query.not}({@link Query#between Query.between}(q(value1), q(value2), q(value3))) + * + *
        value1 IN ( value2, value3 ) + * {@link Query#in Query.in}(q(value1), + * new ValueExp[] { + * q(value2), q(value3)}) + * + *
        value1 NOT IN ( value2, value3 ) + * {@link Query#not Query.not}({@link Query#in Query.in}(q(value1), + * new ValueExp[] { + * q(value2), q(value3)})) + * + *
        value LIKE stringLiteral + * {@link Query#match Query.match}(q(value), + * translateWildcards(q(stringLiteral))) + * + *
        value NOT LIKE stringLiteral + * {@link Query#not Query.not}({@link Query#match Query.match}(q(value), + * translateWildcards(q(stringLiteral)))) + * + *
        value1 + value2 + * {@link Query#plus Query.plus}(q(value1), q(value2)) + * + *
        value1 - value2 + * {@link Query#minus Query.minus}(q(value1), q(value2)) + * + *
        value1 * value2 + * {@link Query#times Query.times}(q(value1), q(value2)) + * + *
        value1 / value2 + * {@link Query#div Query.div}(q(value1), q(value2)) + * + *
        name + * {@link Query#attr(String) Query.attr}(q(name)) + * + *
        name1#name2 + * {@link Query#attr(String,String) Query.attr}(q(name1), + * q(name2)) + * + *
        FALSE + * {@link Query#value(boolean) Query.value}(false) + * + *
        TRUE + * {@link Query#value(boolean) Query.value}(true) + * + *
        decimalLiteral + * {@link Query#value(long) Query.value}({@link Long#valueOf(String) Long.valueOf}(decimalLiteral)) + * + *
        floatingPointLiteral + * {@link Query#value(double) Query.value}({@link Double#valueOf(String) Double.valueOf}(floatingPointLiteral)) + *
        + * + *

        Here, translateWildcards is a function + * that translates from the SQL notation for wildcards, using {@code %} and + * {@code _}, to the JMX API notation, using {@code *} and {@code ?}. If the + * LIKE string already contains {@code *} or {@code ?}, these characters + * have their literal meanings, and will be quoted in the call to + * {@link Query#match Query.match}.

        + * * @since 1.5 */ public class Query extends Object { @@ -277,16 +604,12 @@ package javax.management; } /** - *

        Returns a new attribute expression.

        - * - *

        Evaluating this expression for a given - * objectName includes performing {@link - * MBeanServer#getAttribute MBeanServer.getAttribute(objectName, - * name)}.

        + *

        Returns a new attribute expression. See {@link AttributeValueExp} + * for a detailed description of the semantics of the expression.

        * * @param name The name of the attribute. * - * @return An attribute expression for the attribute named name. + * @return An attribute expression for the attribute named {@code name}. */ public static AttributeValueExp attr(String name) { return new AttributeValueExp(name); @@ -627,6 +950,63 @@ package javax.management; return new InstanceOfQueryExp(classNameValue); } + /** + *

        Return a string representation of the given query. The string + * returned by this method can be converted back into an equivalent + * query using {@link #fromString fromString}.

        + * + *

        (Two queries are equivalent if they produce the same result in + * all cases. Equivalent queries are not necessarily identical: + * for example the queries {@code Query.lt(Query.attr("A"), Query.attr("B"))} + * and {@code Query.not(Query.ge(Query.attr("A"), Query.attr("B")))} are + * equivalent but not identical.)

        + * + *

        The string returned by this method is only guaranteed to be converted + * back into an equivalent query if {@code query} was constructed, or + * could have been constructed, using the methods of this class. + * If you make a custom query {@code myQuery} by implementing + * {@link QueryExp} yourself then the result of + * {@code Query.toString(myQuery)} is unspecified.

        + * + * @param query the query to convert. If it is null, the result will + * also be null. + * @return the string representation of the query, or null if the + * query is null. + * + * @since 1.7 + */ + public static String toString(QueryExp query) { + if (query == null) + return null; + + if (query instanceof ToQueryString) + return ((ToQueryString) query).toQueryString(); + + return query.toString(); + } + + /** + *

        Produce a query from the given string. The query returned + * by this method can be converted back into a string using + * {@link #toString(QueryExp) toString}. The resultant string will + * not necessarily be equal to {@code s}.

        + * + * @param s the string to convert. + * + * @return a {@code QueryExp} derived by parsing the string, or + * null if the string is null. + * + * @throws IllegalArgumentException if the string is not a valid + * query string. + * + * @since 1.7 + */ + public static QueryExp fromString(String s) { + if (s == null) + return null; + return new QueryParser(s).parseQuery(); + } + /** * Utility method to escape strings used with * Query.{initial|any|final}SubString() methods. diff --git a/src/share/classes/javax/management/QueryEval.java b/src/share/classes/javax/management/QueryEval.java index 05c4e38b4beca33c09a8ddb43941336cdd7ef7f9..02c651c3c4c34e138774e85264fade860a5ec88b 100644 --- a/src/share/classes/javax/management/QueryEval.java +++ b/src/share/classes/javax/management/QueryEval.java @@ -38,7 +38,7 @@ import javax.management.MBeanServer; * * @since 1.5 */ -public abstract class QueryEval implements Serializable { +public abstract class QueryEval extends ToQueryString implements Serializable { /* Serial version */ private static final long serialVersionUID = 2675899265640874796L; diff --git a/src/share/classes/javax/management/QueryExp.java b/src/share/classes/javax/management/QueryExp.java index 6ac9ef6854f5d893fca198272b0cc9296636a865..217db104249a83ba01df21b097791d6fa9851db1 100644 --- a/src/share/classes/javax/management/QueryExp.java +++ b/src/share/classes/javax/management/QueryExp.java @@ -30,9 +30,9 @@ import java.io.Serializable; /** - *

        Represents relational constraints that can be used in database - * query "where clauses". Instances of QueryExp are returned by the - * static methods of the {@link Query} class.

        + *

        Represents relational constraints similar to database query "where + * clauses". Instances of QueryExp are returned by the static methods of the + * {@link Query} class.

        * *

        It is possible, but not * recommended, to create custom queries by implementing this @@ -40,6 +40,7 @@ import java.io.Serializable; * QueryEval} class than to implement the interface directly, so that * the {@link #setMBeanServer} method works correctly. * + * @see MBeanServer#queryNames MBeanServer.queryNames * @since 1.5 */ public interface QueryExp extends Serializable { diff --git a/src/share/classes/javax/management/QueryNotificationFilter.java b/src/share/classes/javax/management/QueryNotificationFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..c6c10393902949b1656d3a804650e7ebaa42bdf6 --- /dev/null +++ b/src/share/classes/javax/management/QueryNotificationFilter.java @@ -0,0 +1,417 @@ +/* + * Copyright 2007 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.management; + +import com.sun.jmx.mbeanserver.NotificationMBeanSupport; +import com.sun.jmx.mbeanserver.Util; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Collections; +import java.util.Set; + +/** + *

        General-purpose notification filter. This filter can be used to + * filter notifications from a possibly-remote MBean. Most filtering + * decisions can be coded using this filter, which avoids having to + * write a custom implementation of the {@link NotificationFilter} + * class. Writing a custom implementation requires you to deploy it + * on both the client and the server in the remote case, so using this class + * instead is recommended where possible.

        + * + * + * + *

        This class uses the {@linkplain Query Query API} to specify the + * filtering logic. For example, to select only notifications where the + * {@linkplain Notification#getType() type} is {@code "com.example.mytype"}, + * you could use

        + * + *
        + * NotificationFilter filter =
        + *     new QueryNotificationFilter("Type = 'com.example.mytype'");
        + * 
        + * + *

        or equivalently

        + * + *
        + * NotificationFilter filter =
        + *     new QueryNotificationFilter(
        + *             Query.eq(Query.attr("Type"), Query.value("com.example.mytype")));
        + * 
        + * + *

        (This particular example could also use + * {@link NotificationFilterSupport}.)

        + * + *

        Here are some other examples of filters you can specify with this class.

        + * + *
        + * + *
        {@code QueryNotificationFilter("Type = 'com.example.type1' or + * Type = 'com.example.type2'")} + *
        Notifications where the type is either of the given strings. + * + *
        {@code QueryNotificationFilter("Type in ('com.example.type1', + * 'com.example.type2')")} + *
        Another way to write the previous example. + * + *
        {@code QueryNotificationFilter("SequenceNumber > 1000")} + *
        Notifications where the {@linkplain Notification#getSequenceNumber() + * sequence number} is greater than 1000. + * + *
        {@code QueryNotificationFilter(AttributeChangeNotification.class, null)} + *
        Notifications where the notification class is + * {@link AttributeChangeNotification} or a subclass of it. + * + *
        {@code QueryNotificationFilter(AttributeChangeNotification.class, + * "AttributeName = 'Size'")} + *
        Notifications where the notification class is + * {@link AttributeChangeNotification} or a subclass, and where the + * {@linkplain AttributeChangeNotification#getAttributeName() name of the + * changed attribute} is {@code Size}. + * + *
        {@code QueryNotificationFilter(AttributeChangeNotification.class, + * "AttributeName = 'Size' and NewValue - OldValue > 100")} + *
        As above, but the difference between the + * {@linkplain AttributeChangeNotification#getNewValue() new value} and the + * {@linkplain AttributeChangeNotification#getOldValue() old value} must be + * greater than 100. + * + *
        {@code QueryNotificationFilter("like 'com.example.mydomain:*'")} + *
        Notifications where the {@linkplain Notification#getSource() source} + * is an ObjectName that matches the pattern. + * + *
        {@code QueryNotificationFilter("Source.canonicalName like + * 'com.example.mydomain:%'")} + *
        Another way to write the previous example. + * + *
        {@code QueryNotificationFilter(MBeanServerNotification.class, + * "Type = 'JMX.mbean.registered' and MBeanName.canonicalName like + * 'com.example.mydomain:%'")} + *
        Notifications of class {@link MBeanServerNotification} representing + * an object registered in the domain {@code com.example.mydomain}. + * + *
        + * + *

        How it works

        + * + *

        Although the examples above are clear, looking closely at the + * Query API reveals a subtlety. A {@link QueryExp} is evaluated on + * an {@link ObjectName}, not a {@code Notification}.

        + * + *

        Every time a {@code Notification} is to be filtered by a + * {@code QueryNotificationFilter}, a special {@link MBeanServer} is created. + * This {@code MBeanServer} contains exactly one MBean, which represents the + * {@code Notification}. If the {@linkplain Notification#getSource() + * source} of the notification is an {@code ObjectName}, which is + * recommended practice, then the name of the MBean representing the + * {@code Notification} will be this {@code ObjectName}. Otherwise the + * name is unspecified.

        + * + *

        The query specified in the {@code QueryNotificationFilter} constructor + * is evaluated against this {@code MBeanServer} and {@code ObjectName}, + * and the filter returns true if and only if the query does. If the + * query throws an exception, then the filter will return false.

        + * + *

        The MBean representing the {@code Notification} has one attribute for + * every property of the {@code Notification}. Specifically, for every public + * method {@code T getX()} in the {@code NotificationClass}, the MBean will + * have an attribute called {@code X} of type {@code T}. For example, if the + * {@code Notification} is an {@code AttributeChangeNotification}, then the + * MBean will have an attribute called {@code AttributeName} of type + * {@code "java.lang.String"}, corresponding to the method {@link + * AttributeChangeNotification#getAttributeName}.

        + * + *

        Query evaluation usually involves calls to the methods of {@code + * MBeanServer}. The methods have the following behavior:

        + * + *
          + *
        • The {@link MBeanServer#getAttribute getAttribute} method returns the + * value of the corresponding property. + *
        • The {@link MBeanServer#getObjectInstance getObjectInstance} + * method returns an {@link ObjectInstance} where the {@link + * ObjectInstance#getObjectName ObjectName} is the name of the MBean and the + * {@link ObjectInstance#getClassName ClassName} is the class name of the + * {@code Notification}. + *
        • The {@link MBeanServer#isInstanceOf isInstanceOf} method returns true + * if and only if the {@code Notification}'s {@code ClassLoader} can load the + * named class, and the {@code Notification} is an {@linkplain Class#isInstance + * instance} of that class. + *
        + * + *

        These are the only {@code MBeanServer} methods that are needed to + * evaluate standard queries. The behavior of the other {@code MBeanServer} + * methods is unspecified.

        + * + * @since 1.7 + */ +public class QueryNotificationFilter implements NotificationFilter { + private static final long serialVersionUID = -8408613922660635231L; + + private static final ObjectName DEFAULT_NAME = + Util.newObjectName(":type=Notification"); + private static final QueryExp trueQuery; + static { + ValueExp zero = Query.value(0); + trueQuery = Query.eq(zero, zero); + } + + private final QueryExp query; + + /** + * Construct a {@code QueryNotificationFilter} that evaluates the given + * {@code QueryExp} to determine whether to accept a notification. + * + * @param query the {@code QueryExp} to evaluate. Can be null, + * in which case all notifications are accepted. + */ + public QueryNotificationFilter(QueryExp query) { + if (query == null) + this.query = trueQuery; + else + this.query = query; + } + + /** + * Construct a {@code QueryNotificationFilter} that evaluates the query + * in the given string to determine whether to accept a notification. + * The string is converted into a {@code QueryExp} using + * {@link Query#fromString Query.fromString}. + * + * @param query the string specifying the query to evaluate. Can be null, + * in which case all notifications are accepted. + * + * @throws IllegalArgumentException if the string is not a valid + * query string. + */ + public QueryNotificationFilter(String query) { + this(Query.fromString(query)); + } + + /** + *

        Construct a {@code QueryNotificationFilter} that evaluates the query + * in the given string to determine whether to accept a notification, + * and where the notification must also be an instance of the given class. + * The string is converted into a {@code QueryExp} using + * {@link Query#fromString Query.fromString}.

        + * + * @param notifClass the class that the notification must be an instance of. + * Cannot be null. + * + * @param query the string specifying the query to evaluate. Can be null, + * in which case all notifications are accepted. + * + * @throws IllegalArgumentException if the string is not a valid + * query string, or if {@code notifClass} is null. + */ + public QueryNotificationFilter( + Class notifClass, String query) { + this(Query.and(Query.isInstanceOf(Query.value(notNull(notifClass).getName())), + Query.fromString(query))); + } + + private static T notNull(T x) { + if (x == null) + throw new IllegalArgumentException("Null argument"); + return x; + } + + /** + * Retrieve the query that this notification filter will evaluate for + * each notification. + * + * @return the query. + */ + public QueryExp getQuery() { + return query; + } + + public boolean isNotificationEnabled(Notification notification) { + ObjectName name; + + Object source = notification.getSource(); + if (source instanceof ObjectName) + name = (ObjectName) source; + else + name = DEFAULT_NAME; + + MBS mbsImpl = new MBS(notification, name); + MBeanServer mbs = (MBeanServer) Proxy.newProxyInstance( + MBeanServer.class.getClassLoader(), + new Class[] {MBeanServer.class}, + new ForwardIH(mbsImpl)); + return evalQuery(query, mbs, name); + } + + private static boolean evalQuery( + QueryExp query, MBeanServer mbs, ObjectName name) { + MBeanServer oldMBS = QueryEval.getMBeanServer(); + try { + if (mbs != null) + query.setMBeanServer(mbs); + return query.apply(name); + } catch (Exception e) { + return false; + } finally { + query.setMBeanServer(oldMBS); + } + } + + private static class ForwardIH implements InvocationHandler { + private final MBS mbs; + + ForwardIH(MBS mbs) { + this.mbs = mbs; + } + + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable { + Method forward; + try { + forward = MBS.class.getMethod( + method.getName(), method.getParameterTypes()); + } catch (NoSuchMethodException e) { + throw new UnsupportedOperationException(method.getName()); + } + try { + return forward.invoke(mbs, args); + } catch (InvocationTargetException e) { + throw e.getCause(); + } + } + } + + private static class MBS { + private final Notification notification; + private final ObjectName objectName; + private final ObjectInstance objectInstance; + private volatile DynamicMBean mbean; + + MBS(Notification n, ObjectName name) { + this.notification = n; + this.objectName = name; + this.objectInstance = new ObjectInstance(name, n.getClass().getName()); + } + + private void checkName(ObjectName name) throws InstanceNotFoundException { + if (!objectName.equals(name)) + throw new InstanceNotFoundException(String.valueOf(name)); + } + + private DynamicMBean mbean(ObjectName name) + throws InstanceNotFoundException, ReflectionException { + if (mbean == null) { + try { + mbean = new NotificationMBeanSupport(notification); + } catch (NotCompliantMBeanException e) { + throw new ReflectionException(e); + } + } + return mbean; + } + + public ObjectInstance getObjectInstance(ObjectName name) + throws InstanceNotFoundException { + checkName(name); + return objectInstance; + } + + public Set queryMBeans(ObjectName name, QueryExp query) { + Set names = queryNames(name, query); + switch (names.size()) { + case 0: + return Collections.emptySet(); + case 1: + return Collections.singleton(objectInstance); + default: + throw new UnsupportedOperationException("Internal error"); + } + } + + public Set queryNames(ObjectName name, QueryExp query) { + if ((name != null && !name.apply(objectName)) || + (query != null && !evalQuery(query, null, name))) + return Collections.emptySet(); + return Collections.singleton(objectName); + } + + public boolean isRegistered(ObjectName name) { + return objectName.equals(name); + } + + public Integer getMBeanCount() { + return 1; + } + + public Object getAttribute(ObjectName name, String attribute) + throws MBeanException, AttributeNotFoundException, + InstanceNotFoundException, ReflectionException { + return mbean(name).getAttribute(attribute); + } + + public AttributeList getAttributes(ObjectName name, String[] attributes) + throws InstanceNotFoundException, ReflectionException { + return mbean(name).getAttributes(attributes); + } + + public String getDefaultDomain() { + return objectName.getDomain(); + } + + public String[] getDomains() { + return new String[] {objectName.getDomain()}; + } + + public MBeanInfo getMBeanInfo(ObjectName name) + throws InstanceNotFoundException, ReflectionException { + return mbean(name).getMBeanInfo(); + } + + public boolean isInstanceOf(ObjectName name, String className) + throws InstanceNotFoundException { + try { + mbean(name); + ClassLoader loader = notification.getClass().getClassLoader(); + Class c = Class.forName(className, false, loader); + return c.isInstance(notification); + } catch (ReflectionException e) { + return false; + } catch (ClassNotFoundException e) { + return false; + } + } + + public ClassLoader getClassLoaderFor(ObjectName mbeanName) + throws InstanceNotFoundException { + checkName(mbeanName); + return notification.getClass().getClassLoader(); + } + } +} diff --git a/src/share/classes/javax/management/QueryParser.java b/src/share/classes/javax/management/QueryParser.java new file mode 100644 index 0000000000000000000000000000000000000000..5e24e3bfbd3d7dc0e7096dab5f518cc9ee73d680 --- /dev/null +++ b/src/share/classes/javax/management/QueryParser.java @@ -0,0 +1,663 @@ +/* + * Copyright 2008 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.management; + +import java.util.ArrayList; +import java.util.Formatter; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +/** + *

        Parser for JMX queries represented in an SQL-like language.

        + */ +/* + * Note that if a query starts with ( then we don't know whether it is + * a predicate or just a value that is parenthesized. So, inefficiently, + * we try to parse a predicate and if that doesn't work we try to parse + * a value. + */ +class QueryParser { + // LEXER STARTS HERE + + private static class Token { + final String string; + Token(String s) { + this.string = s; + } + + @Override + public String toString() { + return string; + } + } + + private static final Token + END = new Token(""), + LPAR = new Token("("), RPAR = new Token(")"), + COMMA = new Token(","), DOT = new Token("."), SHARP = new Token("#"), + PLUS = new Token("+"), MINUS = new Token("-"), + TIMES = new Token("*"), DIVIDE = new Token("/"), + LT = new Token("<"), GT = new Token(">"), + LE = new Token("<="), GE = new Token(">="), + NE = new Token("<>"), EQ = new Token("="), + NOT = new Id("NOT"), INSTANCEOF = new Id("INSTANCEOF"), + FALSE = new Id("FALSE"), TRUE = new Id("TRUE"), + BETWEEN = new Id("BETWEEN"), AND = new Id("AND"), + OR = new Id("OR"), IN = new Id("IN"), + LIKE = new Id("LIKE"), CLASS = new Id("CLASS"); + + // Keywords that can appear where an identifier can appear. + // If an attribute is one of these, then it must be quoted when + // converting a query into a string. + // We use a TreeSet so we can look up case-insensitively. + private static final Set idKeywords = + new TreeSet(String.CASE_INSENSITIVE_ORDER); + static { + for (Token t : new Token[] {NOT, INSTANCEOF, FALSE, TRUE, LIKE, CLASS}) + idKeywords.add(t.string); + }; + + public static String quoteId(String id) { + if (id.contains("\"") || idKeywords.contains(id)) + return '"' + id.replace("\"", "\"\"") + '"'; + else + return id; + } + + private static class Id extends Token { + Id(String id) { + super(id); + } + + // All other tokens use object identity, which means e.g. that one + // occurrence of the string constant 'x' is not the same as another. + // For identifiers, we ignore case when testing for equality so that + // for a keyword such as AND you can also spell it as "And" or "and". + // But we keep the original case of the identifier, so if it's not + // a keyword we will distinguish between the attribute Foo and the + // attribute FOO. + @Override + public boolean equals(Object o) { + return (o instanceof Id && (((Id) o).toString().equalsIgnoreCase(toString()))); + } + } + + private static class QuotedId extends Token { + QuotedId(String id) { + super(id); + } + + @Override + public String toString() { + return '"' + string.replace("\"", "\"\"") + '"'; + } + } + + private static class StringLit extends Token { + StringLit(String s) { + super(s); + } + + @Override + public String toString() { + return '\'' + string.replace("'", "''") + '\''; + } + } + + private static class LongLit extends Token { + long number; + + LongLit(long number) { + super(Long.toString(number)); + this.number = number; + } + } + + private static class DoubleLit extends Token { + double number; + + DoubleLit(double number) { + super(Double.toString(number)); + this.number = number; + } + } + + private static class Tokenizer { + private final String s; + private final int len; + private int i = 0; + + Tokenizer(String s) { + this.s = s; + this.len = s.length(); + } + + private int thisChar() { + if (i == len) + return -1; + return s.codePointAt(i); + } + + private void advance() { + i += Character.charCount(thisChar()); + } + + private int thisCharAdvance() { + int c = thisChar(); + advance(); + return c; + } + + Token nextToken() { + // In this method, c is the character we're looking at, and + // thisChar() is the character after that. Everything must + // preserve these invariants. When we return we then have + // thisChar() being the start of the following token, so + // the next call to nextToken() will begin from there. + int c; + + // Skip space + do { + if (i == len) + return null; + c = thisCharAdvance(); + } while (Character.isWhitespace(c)); + + // Now c is the first character of the token, and tokenI points + // to the character after that. + switch (c) { + case '(': return LPAR; + case ')': return RPAR; + case ',': return COMMA; + case '.': return DOT; + case '#': return SHARP; + case '*': return TIMES; + case '/': return DIVIDE; + case '=': return EQ; + case '-': return MINUS; + case '+': return PLUS; + + case '>': + if (thisChar() == '=') { + advance(); + return GE; + } else + return GT; + + case '<': + c = thisChar(); + switch (c) { + case '=': advance(); return LE; + case '>': advance(); return NE; + default: return LT; + } + + case '!': + if (thisCharAdvance() != '=') + throw new IllegalArgumentException("'!' must be followed by '='"); + return NE; + + case '"': + case '\'': { + int quote = c; + StringBuilder sb = new StringBuilder(); + while (true) { + while ((c = thisChar()) != quote) { + if (c < 0) { + throw new IllegalArgumentException( + "Unterminated string constant"); + } + sb.appendCodePoint(thisCharAdvance()); + } + advance(); + if (thisChar() == quote) { + sb.appendCodePoint(quote); + advance(); + } else + break; + } + if (quote == '\'') + return new StringLit(sb.toString()); + else + return new QuotedId(sb.toString()); + } + } + + // Is it a numeric constant? + if (Character.isDigit(c) || c == '.') { + StringBuilder sb = new StringBuilder(); + int lastc = -1; + while (true) { + sb.appendCodePoint(c); + c = Character.toLowerCase(thisChar()); + if (c == '+' || c == '-') { + if (lastc != 'e') + break; + } else if (!Character.isDigit(c) && c != '.' && c != 'e') + break; + lastc = c; + advance(); + } + String s = sb.toString(); + if (s.indexOf('.') >= 0 || s.indexOf('e') >= 0) { + double d = parseDoubleCheckOverflow(s); + return new DoubleLit(d); + } else { + // Like the Java language, we allow the numeric constant + // x where -x = Long.MIN_VALUE, even though x is not + // representable as a long (it is Long.MAX_VALUE + 1). + // Code in the parser will reject this value if it is + // not the operand of unary minus. + long l = -Long.parseLong("-" + s); + return new LongLit(l); + } + } + + // It must be an identifier. + if (!Character.isJavaIdentifierStart(c)) { + StringBuilder sb = new StringBuilder(); + Formatter f = new Formatter(sb); + f.format("Bad character: %c (%04x)", c, c); + throw new IllegalArgumentException(sb.toString()); + } + + StringBuilder id = new StringBuilder(); + while (true) { // identifier + id.appendCodePoint(c); + c = thisChar(); + if (!Character.isJavaIdentifierPart(c)) + break; + advance(); + } + + return new Id(id.toString()); + } + } + + /* Parse a double as a Java compiler would do it, throwing an exception + * if the input does not fit in a double. We assume that the input + * string is not "Infinity" and does not have a leading sign. + */ + private static double parseDoubleCheckOverflow(String s) { + double d = Double.parseDouble(s); + if (Double.isInfinite(d)) + throw new NumberFormatException("Overflow: " + s); + if (d == 0.0) { // Underflow checking is hard! CR 6604864 + String ss = s; + int e = s.indexOf('e'); // we already forced E to lowercase + if (e > 0) + ss = s.substring(0, e); + ss = ss.replace("0", "").replace(".", ""); + if (!ss.isEmpty()) + throw new NumberFormatException("Underflow: " + s); + } + return d; + } + + // PARSER STARTS HERE + + private final List tokens; + private int tokenI; + // The current token is always tokens[tokenI]. + + QueryParser(String s) { + // Construct the complete list of tokens immediately and append + // a sentinel (END). + tokens = new ArrayList(); + Tokenizer tokenizer = new Tokenizer(s); + Token t; + while ((t = tokenizer.nextToken()) != null) + tokens.add(t); + tokens.add(END); + } + + private Token current() { + return tokens.get(tokenI); + } + + // If the current token is t, then skip it and return true. + // Otherwise, return false. + private boolean skip(Token t) { + if (t.equals(current())) { + tokenI++; + return true; + } + return false; + } + + // If the current token is one of the ones in 'tokens', then skip it + // and return its index in 'tokens'. Otherwise, return -1. + private int skipOne(Token... tokens) { + for (int i = 0; i < tokens.length; i++) { + if (skip(tokens[i])) + return i; + } + return -1; + } + + // If the current token is t, then skip it and return. + // Otherwise throw an exception. + private void expect(Token t) { + if (!skip(t)) + throw new IllegalArgumentException("Expected " + t + ", found " + current()); + } + + private void next() { + tokenI++; + } + + QueryExp parseQuery() { + QueryExp qe = query(); + if (current() != END) + throw new IllegalArgumentException("Junk at end of query: " + current()); + return qe; + } + + // The remainder of this class is a classical recursive-descent parser. + // We only need to violate the recursive-descent scheme in one place, + // where parentheses make the grammar not LL(1). + + private QueryExp query() { + QueryExp lhs = andquery(); + while (skip(OR)) + lhs = Query.or(lhs, andquery()); + return lhs; + } + + private QueryExp andquery() { + QueryExp lhs = predicate(); + while (skip(AND)) + lhs = Query.and(lhs, predicate()); + return lhs; + } + + private QueryExp predicate() { + // Grammar hack. If we see a paren, it might be (query) or + // it might be (value). We try to parse (query), and if that + // fails, we parse (value). For example, if the string is + // "(2+3)*4 < 5" then we will try to parse the query + // "2+3)*4 < 5", which will fail at the ), so we'll back up to + // the paren and let value() handle it. + if (skip(LPAR)) { + int parenIndex = tokenI - 1; + try { + QueryExp qe = query(); + expect(RPAR); + return qe; + } catch (IllegalArgumentException e) { + // OK: try parsing a value + } + tokenI = parenIndex; + } + + if (skip(NOT)) + return Query.not(predicate()); + + if (skip(INSTANCEOF)) + return Query.isInstanceOf(stringvalue()); + + if (skip(LIKE)) { + StringValueExp sve = stringvalue(); + String s = sve.getValue(); + try { + return new ObjectName(s); + } catch (MalformedObjectNameException e) { + throw new IllegalArgumentException( + "Bad ObjectName pattern after LIKE: '" + s + "'", e); + } + } + + ValueExp lhs = value(); + + return predrhs(lhs); + } + + // The order of elements in the following arrays is important. The code + // in predrhs depends on integer indexes. Change with caution. + private static final Token[] relations = { + EQ, LT, GT, LE, GE, NE, + // 0, 1, 2, 3, 4, 5, + }; + private static final Token[] betweenLikeIn = { + BETWEEN, LIKE, IN + // 0, 1, 2, + }; + + private QueryExp predrhs(ValueExp lhs) { + Token start = current(); // for errors + + // Look for < > = etc + int i = skipOne(relations); + if (i >= 0) { + ValueExp rhs = value(); + switch (i) { + case 0: return Query.eq(lhs, rhs); + case 1: return Query.lt(lhs, rhs); + case 2: return Query.gt(lhs, rhs); + case 3: return Query.leq(lhs, rhs); + case 4: return Query.geq(lhs, rhs); + case 5: return Query.not(Query.eq(lhs, rhs)); + // There is no Query.ne so <> is shorthand for the above. + default: + throw new AssertionError(); + } + } + + // Must be BETWEEN LIKE or IN, optionally preceded by NOT + boolean not = skip(NOT); + i = skipOne(betweenLikeIn); + if (i < 0) + throw new IllegalArgumentException("Expected relation at " + start); + + QueryExp q; + switch (i) { + case 0: { // BETWEEN + ValueExp lower = value(); + expect(AND); + ValueExp upper = value(); + q = Query.between(lhs, lower, upper); + break; + } + + case 1: { // LIKE + if (!(lhs instanceof AttributeValueExp)) { + throw new IllegalArgumentException( + "Left-hand side of LIKE must be an attribute"); + } + AttributeValueExp alhs = (AttributeValueExp) lhs; + StringValueExp sve = stringvalue(); + String s = sve.getValue(); + q = Query.match(alhs, patternValueExp(s)); + break; + } + + case 2: { // IN + expect(LPAR); + List values = new ArrayList(); + values.add(value()); + while (skip(COMMA)) + values.add(value()); + expect(RPAR); + q = Query.in(lhs, values.toArray(new ValueExp[values.size()])); + break; + } + + default: + throw new AssertionError(); + } + + if (not) + q = Query.not(q); + + return q; + } + + private ValueExp value() { + ValueExp lhs = factor(); + int i; + while ((i = skipOne(PLUS, MINUS)) >= 0) { + ValueExp rhs = factor(); + if (i == 0) + lhs = Query.plus(lhs, rhs); + else + lhs = Query.minus(lhs, rhs); + } + return lhs; + } + + private ValueExp factor() { + ValueExp lhs = term(); + int i; + while ((i = skipOne(TIMES, DIVIDE)) >= 0) { + ValueExp rhs = term(); + if (i == 0) + lhs = Query.times(lhs, rhs); + else + lhs = Query.div(lhs, rhs); + } + return lhs; + } + + private ValueExp term() { + boolean signed = false; + int sign = +1; + if (skip(PLUS)) + signed = true; + else if (skip(MINUS)) { + signed = true; sign = -1; + } + + Token t = current(); + next(); + + if (t instanceof DoubleLit) + return Query.value(sign * ((DoubleLit) t).number); + if (t instanceof LongLit) { + long n = ((LongLit) t).number; + if (n == Long.MIN_VALUE && sign != -1) + throw new IllegalArgumentException("Illegal positive integer: " + n); + return Query.value(sign * n); + } + if (signed) + throw new IllegalArgumentException("Expected number after + or -"); + + if (t == LPAR) { + ValueExp v = value(); + expect(RPAR); + return v; + } + if (t.equals(FALSE) || t.equals(TRUE)) { + return Query.value(t.equals(TRUE)); + } + if (t.equals(CLASS)) + return Query.classattr(); + + if (t instanceof StringLit) + return Query.value(t.string); // Not toString(), which would requote ' + + // At this point, all that remains is something that will call Query.attr + + if (!(t instanceof Id) && !(t instanceof QuotedId)) + throw new IllegalArgumentException("Unexpected token " + t); + + String name1 = name(t); + + if (skip(SHARP)) { + Token t2 = current(); + next(); + String name2 = name(t2); + return Query.attr(name1, name2); + } + return Query.attr(name1); + } + + // Initially, t is the first token of a supposed name and current() + // is the second. + private String name(Token t) { + StringBuilder sb = new StringBuilder(); + while (true) { + if (!(t instanceof Id) && !(t instanceof QuotedId)) + throw new IllegalArgumentException("Unexpected token " + t); + sb.append(t.string); + if (current() != DOT) + break; + sb.append('.'); + next(); + t = current(); + next(); + } + return sb.toString(); + } + + private StringValueExp stringvalue() { + // Currently the only way to get a StringValueExp when constructing + // a QueryExp is via Query.value(String), so we only recognize + // string literals here. But if we expand queries in the future + // that might no longer be true. + Token t = current(); + next(); + if (!(t instanceof StringLit)) + throw new IllegalArgumentException("Expected string: " + t); + return Query.value(t.string); + } + + // Convert the SQL pattern syntax, using % and _, to the Query.match + // syntax, using * and ?. The tricky part is recognizing \% and + // \_ as literal values, and also not replacing them inside []. + // But Query.match does not recognize \ inside [], which makes our + // job a tad easier. + private StringValueExp patternValueExp(String s) { + int c; + for (int i = 0; i < s.length(); i += Character.charCount(c)) { + c = s.codePointAt(i); + switch (c) { + case '\\': + i++; // i += Character.charCount(c), but we know it's 1! + if (i >= s.length()) + throw new IllegalArgumentException("\\ at end of pattern"); + break; + case '[': + i = s.indexOf(']', i); + if (i < 0) + throw new IllegalArgumentException("[ without ]"); + break; + case '%': + s = s.substring(0, i) + "*" + s.substring(i + 1); + break; + case '_': + s = s.substring(0, i) + "?" + s.substring(i + 1); + break; + case '*': + case '?': + s = s.substring(0, i) + '\\' + (char) c + s.substring(i + 1); + i++; + break; + } + } + return Query.value(s); + } +} diff --git a/src/share/classes/javax/management/StringValueExp.java b/src/share/classes/javax/management/StringValueExp.java index 5e5202349f5d5eeb6f0d875a9c404fd7a3902219..40a9b2364d8bf8af7ddda578370e250fd618b018 100644 --- a/src/share/classes/javax/management/StringValueExp.java +++ b/src/share/classes/javax/management/StringValueExp.java @@ -73,7 +73,7 @@ public class StringValueExp implements ValueExp { * Returns the string representing the object. */ public String toString() { - return "'" + val + "'"; + return "'" + val.replace("'", "''") + "'"; } diff --git a/src/share/classes/javax/management/ToQueryString.java b/src/share/classes/javax/management/ToQueryString.java new file mode 100644 index 0000000000000000000000000000000000000000..be73bc5f3777c3a18ca9ecdc2a875826b75be8f1 --- /dev/null +++ b/src/share/classes/javax/management/ToQueryString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2008 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.management; + +/* QueryExp classes can extend this to get non-default treatment for + * Query.toString(q). We're reluctant to change the public toString() + * methods of the classes because people might be parsing them, even + * though that's rather fragile. But Query.toString(q) has no such + * constraint so it can use the new toQueryString() method defined here. + */ +class ToQueryString { + String toQueryString() { + return toString(); + } +} diff --git a/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java b/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java index 0b9072a5e4127fcc0229802fba6b77f2f8091b62..a0d68356a0b9a5d352b345179d9e39b519a3d2c2 100644 --- a/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java +++ b/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java @@ -48,6 +48,7 @@ import java.util.logging.Level; import java.util.Map; import java.util.Set; +import java.util.Vector; import javax.management.Attribute; import javax.management.AttributeChangeNotification; import javax.management.AttributeChangeNotificationFilter; @@ -132,8 +133,6 @@ public class RequiredModelMBean * and operations will be executed */ private Object managedResource = null; - private static final String currClass = "RequiredModelMBean"; - /* records the registering in MBeanServer */ private boolean registered = false; private transient MBeanServer server = null; @@ -2488,10 +2487,13 @@ public class RequiredModelMBean } if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { + Vector enabledAttrs = currFilter.getEnabledAttributes(); + String s = (enabledAttrs.size() > 1) ? + "[" + enabledAttrs.firstElement() + ", ...]" : + enabledAttrs.toString(); MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), mth, - "Set attribute change filter to " + - currFilter.getEnabledAttributes().firstElement()); + "Set attribute change filter to " + s); } attributeBroadcaster.addNotificationListener(inlistener,currFilter, diff --git a/src/share/classes/javax/management/monitor/Monitor.java b/src/share/classes/javax/management/monitor/Monitor.java index 528e8c7fd1a2e266a23cf96e0a16bce495d499f7..5df59a7a20e5a1afa1cb36c1ec7c155ebfebbf66 100644 --- a/src/share/classes/javax/management/monitor/Monitor.java +++ b/src/share/classes/javax/management/monitor/Monitor.java @@ -27,13 +27,8 @@ package javax.management.monitor; import static com.sun.jmx.defaults.JmxProperties.MONITOR_LOGGER; import com.sun.jmx.mbeanserver.GetPropertyAction; -import com.sun.jmx.remote.util.EnvHelp; -import java.beans.BeanInfo; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; +import com.sun.jmx.mbeanserver.Introspector; import java.io.IOException; -import java.lang.reflect.Array; -import java.lang.reflect.InvocationTargetException; import java.security.AccessControlContext; import java.security.AccessController; import java.security.PrivilegedAction; @@ -64,7 +59,6 @@ import javax.management.NotificationBroadcasterSupport; import javax.management.ObjectName; import javax.management.ReflectionException; import static javax.management.monitor.MonitorNotification.*; -import javax.management.openmbean.CompositeData; /** * Defines the part common to all monitor MBeans. @@ -876,44 +870,13 @@ public abstract class Monitor if (isComplexTypeAttribute) { Object v = value; for (String attr : remainingAttributes) - v = introspect(object, attr, v); + v = Introspector.elementFromComplex(v, attr); return (Comparable) v; } else { return (Comparable) value; } } - Object introspect(ObjectName object, - String attribute, - Object value) - throws AttributeNotFoundException { - try { - if (value.getClass().isArray() && attribute.equals("length")) { - return Array.getLength(value); - } else if (value instanceof CompositeData) { - return ((CompositeData) value).get(attribute); - } else { - // Java Beans introspection - // - BeanInfo bi = Introspector.getBeanInfo(value.getClass()); - PropertyDescriptor[] pds = bi.getPropertyDescriptors(); - for (PropertyDescriptor pd : pds) - if (pd.getName().equals(attribute)) - return pd.getReadMethod().invoke(value); - throw new AttributeNotFoundException( - "Could not find the getter method for the property " + - attribute + " using the Java Beans introspector"); - } - } catch (InvocationTargetException e) { - throw new IllegalArgumentException(e); - } catch (AttributeNotFoundException e) { - throw e; - } catch (Exception e) { - throw EnvHelp.initCause( - new AttributeNotFoundException(e.getMessage()), e); - } - } - boolean isComparableTypeValid(ObjectName object, String attribute, Comparable value) { diff --git a/src/share/classes/javax/management/remote/JMXServiceURL.java b/src/share/classes/javax/management/remote/JMXServiceURL.java index 5d5c799774e5b7f4298d2133df8f6b396a9620c0..3211c902b473f164afb5fb1dcd12cea90494cf59 100644 --- a/src/share/classes/javax/management/remote/JMXServiceURL.java +++ b/src/share/classes/javax/management/remote/JMXServiceURL.java @@ -30,6 +30,7 @@ package javax.management.remote; import com.sun.jmx.remote.util.ClassLogger; import com.sun.jmx.remote.util.EnvHelp; +import java.beans.ConstructorProperties; import java.io.Serializable; import java.net.InetAddress; import java.net.MalformedURLException; @@ -274,6 +275,7 @@ public class JMXServiceURL implements Serializable { * is not possible to find the local host name, or if * port is negative. */ + @ConstructorProperties({"protocol", "host", "port", "URLPath"}) public JMXServiceURL(String protocol, String host, int port, String urlPath) throws MalformedURLException { diff --git a/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java b/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java index cf569ef5bdeb4386195e409c3bb4ece8a5770d83..9d266fac8612e0d41d0bdab2d83f410edd50cc90 100644 --- a/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java +++ b/src/share/classes/javax/rmi/ssl/SslRMIClientSocketFactory.java @@ -121,7 +121,7 @@ public class SslRMIClientSocketFactory sslSocketFactory.createSocket(host, port); // Set the SSLSocket Enabled Cipher Suites // - final String enabledCipherSuites = (String) + final String enabledCipherSuites = System.getProperty("javax.rmi.ssl.client.enabledCipherSuites"); if (enabledCipherSuites != null) { StringTokenizer st = new StringTokenizer(enabledCipherSuites, ","); @@ -139,7 +139,7 @@ public class SslRMIClientSocketFactory } // Set the SSLSocket Enabled Protocols // - final String enabledProtocols = (String) + final String enabledProtocols = System.getProperty("javax.rmi.ssl.client.enabledProtocols"); if (enabledProtocols != null) { StringTokenizer st = new StringTokenizer(enabledProtocols, ","); diff --git a/src/share/classes/javax/rmi/ssl/SslRMIServerSocketFactory.java b/src/share/classes/javax/rmi/ssl/SslRMIServerSocketFactory.java index 27e8b2f2af9197744858c218d90891fe66386ec2..802e1668b8631007f531d98a503bf6c9cb345597 100644 --- a/src/share/classes/javax/rmi/ssl/SslRMIServerSocketFactory.java +++ b/src/share/classes/javax/rmi/ssl/SslRMIServerSocketFactory.java @@ -165,9 +165,9 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { // Initialize the configuration parameters. // this.enabledCipherSuites = enabledCipherSuites == null ? - null : (String[]) enabledCipherSuites.clone(); + null : enabledCipherSuites.clone(); this.enabledProtocols = enabledProtocols == null ? - null : (String[]) enabledProtocols.clone(); + null : enabledProtocols.clone(); this.needClientAuth = needClientAuth; // Force the initialization of the default at construction time, @@ -196,13 +196,11 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { // if (this.enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(this.enabledCipherSuites); - enabledCipherSuitesList = - Arrays.asList((String[]) this.enabledCipherSuites); + enabledCipherSuitesList = Arrays.asList(this.enabledCipherSuites); } if (this.enabledProtocols != null) { sslSocket.setEnabledProtocols(this.enabledProtocols); - enabledProtocolsList = - Arrays.asList((String[]) this.enabledProtocols); + enabledProtocolsList = Arrays.asList(this.enabledProtocols); } } @@ -218,7 +216,7 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { */ public final String[] getEnabledCipherSuites() { return enabledCipherSuites == null ? - null : (String[]) enabledCipherSuites.clone(); + null : enabledCipherSuites.clone(); } /** @@ -234,7 +232,7 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { */ public final String[] getEnabledProtocols() { return enabledProtocols == null ? - null : (String[]) enabledProtocols.clone(); + null : enabledProtocols.clone(); } /** @@ -315,8 +313,8 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { (enabledCipherSuites != null && that.enabledCipherSuites == null)) return false; if (enabledCipherSuites != null && that.enabledCipherSuites != null) { - List thatEnabledCipherSuitesList = - Arrays.asList((String[]) that.enabledCipherSuites); + List thatEnabledCipherSuitesList = + Arrays.asList(that.enabledCipherSuites); if (!enabledCipherSuitesList.equals(thatEnabledCipherSuitesList)) return false; } @@ -327,8 +325,8 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { (enabledProtocols != null && that.enabledProtocols == null)) return false; if (enabledProtocols != null && that.enabledProtocols != null) { - List thatEnabledProtocolsList = - Arrays.asList((String[]) that.enabledProtocols); + List thatEnabledProtocolsList = + Arrays.asList(that.enabledProtocols); if (!enabledProtocolsList.equals(thatEnabledProtocolsList)) return false; } @@ -374,7 +372,7 @@ public class SslRMIServerSocketFactory implements RMIServerSocketFactory { private final String[] enabledCipherSuites; private final String[] enabledProtocols; private final boolean needClientAuth; - private List enabledCipherSuitesList; - private List enabledProtocolsList; + private List enabledCipherSuitesList; + private List enabledProtocolsList; private SSLContext context; } diff --git a/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java b/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java index 1879e5c4bf230b3e7e18b28b7c79f44d3346e212..394634249843c6f97a01080fc867126ab44a54c4 100644 --- a/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java +++ b/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java @@ -276,7 +276,7 @@ public class KerberosTicket implements Destroyable, Refreshable, if (flags != null) { if (flags.length >= NUM_FLAGS) - this.flags = (boolean[]) flags.clone(); + this.flags = flags.clone(); else { this.flags = new boolean[NUM_FLAGS]; // Fill in whatever we have @@ -304,7 +304,7 @@ public class KerberosTicket implements Destroyable, Refreshable, this.endTime = endTime; if (clientAddresses != null) - this.clientAddresses = (InetAddress[]) clientAddresses.clone(); + this.clientAddresses = clientAddresses.clone(); } /** @@ -430,7 +430,7 @@ public class KerberosTicket implements Destroyable, Refreshable, * @return the flags associated with this ticket. */ public final boolean[] getFlags() { - return (flags == null? null: (boolean[]) flags.clone()); + return (flags == null? null: flags.clone()); } /** @@ -479,8 +479,7 @@ public class KerberosTicket implements Destroyable, Refreshable, * provided. */ public final java.net.InetAddress[] getClientAddresses() { - return (clientAddresses == null? - null: (InetAddress[]) clientAddresses.clone()); + return (clientAddresses == null) ? null: clientAddresses.clone(); } /** @@ -491,7 +490,7 @@ public class KerberosTicket implements Destroyable, Refreshable, public final byte[] getEncoded() { if (destroyed) throw new IllegalStateException("This ticket is no longer valid"); - return (byte[]) asn1Encoding.clone(); + return asn1Encoding.clone(); } /** Determines if this ticket is still current. */ diff --git a/src/share/classes/javax/security/auth/kerberos/KeyImpl.java b/src/share/classes/javax/security/auth/kerberos/KeyImpl.java index 5937fd53cacbcd5cbd85e2dfd5bd0167983c0536..6fcffbdeecc6bdc4b6fb950e91348eabcf1efca4 100644 --- a/src/share/classes/javax/security/auth/kerberos/KeyImpl.java +++ b/src/share/classes/javax/security/auth/kerberos/KeyImpl.java @@ -66,7 +66,7 @@ class KeyImpl implements SecretKey, Destroyable, Serializable { */ public KeyImpl(byte[] keyBytes, int keyType) { - this.keyBytes = (byte[]) keyBytes.clone(); + this.keyBytes = keyBytes.clone(); this.keyType = keyType; } @@ -151,7 +151,7 @@ class KeyImpl implements SecretKey, Destroyable, Serializable { public final byte[] getEncoded() { if (destroyed) throw new IllegalStateException("This key is no longer valid"); - return (byte[])keyBytes.clone(); + return keyBytes.clone(); } public void destroy() throws DestroyFailedException { diff --git a/src/share/classes/javax/security/cert/X509Certificate.java b/src/share/classes/javax/security/cert/X509Certificate.java index e5849e5c5206ab53d732abf959c9a5a1f4318d13..14ccaffaffd2ee42ad97af29b89204ca3ea3c8f5 100644 --- a/src/share/classes/javax/security/cert/X509Certificate.java +++ b/src/share/classes/javax/security/cert/X509Certificate.java @@ -363,7 +363,7 @@ public abstract class X509Certificate extends Certificate { * subject Name * * - *

        See getIssuerDN for Name + *

        See {@link #getIssuerDN() getIssuerDN} for Name * and other relevant definitions. * * @return a Principal whose name is the subject name. @@ -393,7 +393,7 @@ public abstract class X509Certificate extends Certificate { /** * Gets the notAfter date from the validity period of - * the certificate. See getNotBefore + * the certificate. See {@link #getNotBefore() getNotBefore} * for relevant ASN.1 definitions. * * @return the end date of the validity period. @@ -429,7 +429,7 @@ public abstract class X509Certificate extends Certificate { * For example, the string "1.2.840.10040.4.3" identifies the SHA-1 * with DSA signature algorithm, as per the PKIX part I. * - *

        See getSigAlgName for + *

        See {@link #getSigAlgName() getSigAlgName} for * relevant ASN.1 definitions. * * @return the signature algorithm OID string. @@ -442,7 +442,7 @@ public abstract class X509Certificate extends Certificate { * algorithm parameters are null; the parameters are usually * supplied with the certificate's public key. * - *

        See getSigAlgName for + *

        See {@link #getSigAlgName() getSigAlgName} for * relevant ASN.1 definitions. * * @return the DER-encoded signature algorithm parameters, or diff --git a/src/share/classes/javax/swing/plaf/synth/doc-files/synth.dtd b/src/share/classes/javax/swing/plaf/synth/doc-files/synth.dtd index 5ac5a61f100e0dc2f6929c0df69b83549ebc1c9d..9188d43e2d4e6bc4e9ba7d86663e987883b33715 100644 --- a/src/share/classes/javax/swing/plaf/synth/doc-files/synth.dtd +++ b/src/share/classes/javax/swing/plaf/synth/doc-files/synth.dtd @@ -73,7 +73,7 @@ type (idref|boolean|dimension|insets|integer|string) "idref" value CDATA #REQUIRED > - + - - + + + - - -

        - Synth is a skinnable look and feel in which all painting is - delegated. Synth does not provide a default look. In - order to use Synth you need to specify a - file, or - provide a {@link - javax.swing.plaf.synth.SynthStyleFactory}. Both - configuration options require an - understanding of the synth architecture, which is described - below, as well as an understanding of Swing's architecture. -

        -

        - Unless otherwise specified null is not a legal value to any of - the methods defined in the synth package and if passed in will - result in a NullPointerException. - - -

        Synth

        -

        - Each {@link javax.swing.plaf.ComponentUI} implementation in Synth associates - itself with one {@link - javax.swing.plaf.synth.SynthStyle} per {@link - javax.swing.plaf.synth.Region}, most - Components only have one Region and - therefor only one SynthStyle. - SynthStyle - is used to access all style related properties: fonts, colors - and other Component properties. In addition - SynthStyles are used to obtain - {@link javax.swing.plaf.synth.SynthPainter}s for painting the background, border, - focus and other portions of a Component. The ComponentUIs obtain - SynthStyles from a - {@link javax.swing.plaf.synth.SynthStyleFactory}. - A SynthStyleFactory - can be provided directly by way of - {@link javax.swing.plaf.synth.SynthLookAndFeel#setStyleFactory(javax.swing.plaf.synth.SynthStyleFactory)}, - or indirectly by way of - {@link javax.swing.plaf.synth.SynthLookAndFeel#load}. The - following example uses the SynthLookAndFeel.load() - method to configure a SynthLookAndFeel and sets it - as the current look and feel: -

        -
        -
        -  SynthLookAndFeel laf = new SynthLookAndFeel();
        +
        +
        +    

        + Synth is a skinnable look and feel in which all painting is + delegated. Synth does not provide a default look. In + order to use Synth you need to specify a + file, or + provide a {@link + javax.swing.plaf.synth.SynthStyleFactory}. Both + configuration options require an + understanding of the synth architecture, which is described + below, as well as an understanding of Swing's architecture. +

        +

        + Unless otherwise specified null is not a legal value to any of + the methods defined in the synth package and if passed in will + result in a NullPointerException. + + +

        Synth

        +

        + Each {@link javax.swing.plaf.ComponentUI} implementation in Synth associates + itself with one {@link + javax.swing.plaf.synth.SynthStyle} per {@link + javax.swing.plaf.synth.Region}, most + Components only have one Region and + therefor only one SynthStyle. + SynthStyle + is used to access all style related properties: fonts, colors + and other Component properties. In addition + SynthStyles are used to obtain + {@link javax.swing.plaf.synth.SynthPainter}s for painting the background, border, + focus and other portions of a Component. The ComponentUIs obtain + SynthStyles from a + {@link javax.swing.plaf.synth.SynthStyleFactory}. + A SynthStyleFactory + can be provided directly by way of + {@link javax.swing.plaf.synth.SynthLookAndFeel#setStyleFactory(javax.swing.plaf.synth.SynthStyleFactory)}, + or indirectly by way of + {@link javax.swing.plaf.synth.SynthLookAndFeel#load}. The + following example uses the SynthLookAndFeel.load() + method to configure a SynthLookAndFeel and sets it + as the current look and feel: +

        +
        +
        +  SynthLookAndFeel laf = new SynthLookAndFeel();
           laf.load(MyClass.class.getResourceAsStream("laf.xml"), MyClass.class);
        -  UIManager.setLookAndFeel(laf);
        -      
        -
        -

        - Many JComponents are broken down into smaller - pieces and identified by the type safe enumeration in - {@link javax.swing.plaf.synth.Region}. For example, a JTabbedPane - consists of a Region for the - JTabbedPane ({@link - javax.swing.plaf.synth.Region#TABBED_PANE}), the content - area ({@link - javax.swing.plaf.synth.Region#TABBED_PANE_CONTENT}), the - area behind the tabs ({@link - javax.swing.plaf.synth.Region#TABBED_PANE_TAB_AREA}), and the - tabs ({@link - javax.swing.plaf.synth.Region#TABBED_PANE_TAB}). Each - Region of each - JComponent will have a - SynthStyle. This allows - you to customize individual pieces of each region of each - JComponent. -

        - Many of the Synth methods take a {@link javax.swing.plaf.synth.SynthContext}. This - is used to provide information about the current - Component and includes: the - {@link javax.swing.plaf.synth.SynthStyle} associated with the current - {@link javax.swing.plaf.synth.Region}, the state of the Component - as a bitmask (refer to {@link - javax.swing.plaf.synth.SynthConstants} for the valid - states), and a {@link javax.swing.plaf.synth.Region} identifying the portion of - the Component being painted. -

        - All text rendering by non-JTextComponents is - delegated to a {@link - javax.swing.plaf.synth.SynthGraphicsUtils}, which is - obtained using the {@link javax.swing.plaf.synth.SynthStyle} method - {@link javax.swing.plaf.synth.SynthStyle#getGraphicsUtils}. You can - customize text rendering - by supplying your own {@link javax.swing.plaf.synth.SynthGraphicsUtils}. - -

        - -

        Notes on specific components

        - -

        JTree

        -

        - Synth provides a region for the cells of a tree: - Region.TREE_CELL. To specify the colors of the - renderer you'll want to provide a style for the - TREE_CELL region. The following illustrates this: -

        -  <style id="treeCellStyle">
        -    <opaque value="TRUE"/>
        -    <state>
        -      <color value="WHITE" type="TEXT_FOREGROUND"/>
        -      <color value="RED" type="TEXT_BACKGROUND"/>
        -    </state>
        -    <state value="SELECTED">
        -      <color value="RED" type="TEXT_FOREGROUND"/>
        -      <color value="WHITE" type="BACKGROUND"/>
        -    </state>
        -  </style>
        -  <bind style="treeCellStyle" type="region" key="TreeCell"/>
        -
        -

        - This specifies a color combination of red on white, when - selected, and white on red when not selected. To see the - background you need to specify that labels are not opaque. The - following XML fragment does that: -

        -  <style id="labelStyle">
        -    <opaque value="FALSE"/>
        -  </style>
        -  <bind style="labelStyle" type="region" key="Label"/>
        -
        - -

        JList and JTable

        -

        - The colors that the renderers for JList and JTable use are - specified by way of the list and table Regions. The following - XML fragment illustrates how to specify red on white, when - selected, and white on red when not selected: -

        -  <style id="style">
        -    <opaque value="TRUE"/>
        -    <state>
        -      <color value="WHITE" type="TEXT_FOREGROUND"/>
        -      <color value="RED" type="TEXT_BACKGROUND"/>
        -      <color value="RED" type="BACKGROUND"/>
        -    </state>
        -    <state value="SELECTED">
        -      <color value="RED" type="TEXT_FOREGROUND"/>
        -      <color value="WHITE" type="TEXT_BACKGROUND"/>
        -    </state>
        -  </style>
        -  <bind style="style" type="region" key="Table"/>
        -  <bind style="style" type="region" key="List"/>
        -
        - - + UIManager.setLookAndFeel(laf); +
        +
        +

        + Many JComponents are broken down into smaller + pieces and identified by the type safe enumeration in + {@link javax.swing.plaf.synth.Region}. For example, a JTabbedPane + consists of a Region for the + JTabbedPane ({@link + javax.swing.plaf.synth.Region#TABBED_PANE}), the content + area ({@link + javax.swing.plaf.synth.Region#TABBED_PANE_CONTENT}), the + area behind the tabs ({@link + javax.swing.plaf.synth.Region#TABBED_PANE_TAB_AREA}), and the + tabs ({@link + javax.swing.plaf.synth.Region#TABBED_PANE_TAB}). Each + Region of each + JComponent will have a + SynthStyle. This allows + you to customize individual pieces of each region of each + JComponent. +

        + Many of the Synth methods take a {@link javax.swing.plaf.synth.SynthContext}. This + is used to provide information about the current + Component and includes: the + {@link javax.swing.plaf.synth.SynthStyle} associated with the current + {@link javax.swing.plaf.synth.Region}, the state of the Component + as a bitmask (refer to {@link + javax.swing.plaf.synth.SynthConstants} for the valid + states), and a {@link javax.swing.plaf.synth.Region} identifying the portion of + the Component being painted. +

        + All text rendering by non-JTextComponents is + delegated to a {@link + javax.swing.plaf.synth.SynthGraphicsUtils}, which is + obtained using the {@link javax.swing.plaf.synth.SynthStyle} method + {@link javax.swing.plaf.synth.SynthStyle#getGraphicsUtils}. You can + customize text rendering + by supplying your own {@link javax.swing.plaf.synth.SynthGraphicsUtils}. + +

        + +

        Notes on specific components

        + +

        JTree

        +

        + Synth provides a region for the cells of a tree: + Region.TREE_CELL. To specify the colors of the + renderer you'll want to provide a style for the + TREE_CELL region. The following illustrates this: +

        +  <style id="treeCellStyle">
        +    <opaque value="TRUE"/>
        +    <state>
        +      <color value="WHITE" type="TEXT_FOREGROUND"/>
        +      <color value="RED" type="TEXT_BACKGROUND"/>
        +    </state>
        +    <state value="SELECTED">
        +      <color value="RED" type="TEXT_FOREGROUND"/>
        +      <color value="WHITE" type="BACKGROUND"/>
        +    </state>
        +  </style>
        +  <bind style="treeCellStyle" type="region" key="TreeCell"/>
        +
        +

        + This specifies a color combination of red on white, when + selected, and white on red when not selected. To see the + background you need to specify that labels are not opaque. The + following XML fragment does that: +

        +  <style id="labelStyle">
        +    <opaque value="FALSE"/>
        +  </style>
        +  <bind style="labelStyle" type="region" key="Label"/>
        +
        + +

        JList and JTable

        +

        + The colors that the renderers for JList and JTable use are + specified by way of the list and table Regions. The following + XML fragment illustrates how to specify red on white, when + selected, and white on red when not selected: +

        +  <style id="style">
        +    <opaque value="TRUE"/>
        +    <state>
        +      <color value="WHITE" type="TEXT_FOREGROUND"/>
        +      <color value="RED" type="TEXT_BACKGROUND"/>
        +      <color value="RED" type="BACKGROUND"/>
        +    </state>
        +    <state value="SELECTED">
        +      <color value="RED" type="TEXT_FOREGROUND"/>
        +      <color value="WHITE" type="TEXT_BACKGROUND"/>
        +    </state>
        +  </style>
        +  <bind style="style" type="region" key="Table"/>
        +  <bind style="style" type="region" key="List"/>
        +
        + + diff --git a/src/share/classes/sun/awt/AppContext.java b/src/share/classes/sun/awt/AppContext.java index 038f5936aa534152911b942e49701cdcb3e1bfc9..4bdc337970bb822b519eaac21fb74dac4930a624 100644 --- a/src/share/classes/sun/awt/AppContext.java +++ b/src/share/classes/sun/awt/AppContext.java @@ -1,5 +1,5 @@ /* - * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1998-2008 Sun Microsystems, 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 @@ -40,6 +40,8 @@ import java.util.IdentityHashMap; import java.util.Map; import java.util.Set; import java.util.HashSet; +import java.util.logging.Level; +import java.util.logging.Logger; import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeListener; @@ -126,6 +128,7 @@ import java.beans.PropertyChangeListener; * @author Fred Ecks */ public final class AppContext { + private static final Logger log = Logger.getLogger("sun.awt.AppContext"); /* Since the contents of an AppContext are unique to each Java * session, this class should never be serialized. */ @@ -143,13 +146,15 @@ public final class AppContext { * Returns a set containing all AppContexts. */ public static Set getAppContexts() { - return new HashSet(threadGroup2appContext.values()); + synchronized (threadGroup2appContext) { + return new HashSet(threadGroup2appContext.values()); + } } /* The main "system" AppContext, used by everything not otherwise contained in another AppContext. */ - private static AppContext mainAppContext = null; + private static volatile AppContext mainAppContext = null; /* * The hash map associated with this AppContext. A private delegate @@ -174,31 +179,30 @@ public final class AppContext { public static final String DISPOSED_PROPERTY_NAME = "disposed"; public static final String GUI_DISPOSED = "guidisposed"; - private boolean isDisposed = false; // true if AppContext is disposed + private volatile boolean isDisposed = false; // true if AppContext is disposed public boolean isDisposed() { return isDisposed; } - static { // On the main Thread, we get the ThreadGroup, make a corresponding // AppContext, and instantiate the Java EventQueue. This way, legacy // code is unaffected by the move to multiple AppContext ability. AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - ThreadGroup currentThreadGroup = - Thread.currentThread().getThreadGroup(); - ThreadGroup parentThreadGroup = currentThreadGroup.getParent(); - while (parentThreadGroup != null) { - // Find the root ThreadGroup to construct our main AppContext - currentThreadGroup = parentThreadGroup; - parentThreadGroup = currentThreadGroup.getParent(); + public Object run() { + ThreadGroup currentThreadGroup = + Thread.currentThread().getThreadGroup(); + ThreadGroup parentThreadGroup = currentThreadGroup.getParent(); + while (parentThreadGroup != null) { + // Find the root ThreadGroup to construct our main AppContext + currentThreadGroup = parentThreadGroup; + parentThreadGroup = currentThreadGroup.getParent(); + } + mainAppContext = new AppContext(currentThreadGroup); + numAppContexts = 1; + return mainAppContext; } - mainAppContext = new AppContext(currentThreadGroup); - numAppContexts = 1; - return mainAppContext; - } }); } @@ -209,7 +213,7 @@ public final class AppContext { * number is 1. If so, it returns the sole AppContext without * checking Thread.currentThread(). */ - private static int numAppContexts; + private static volatile int numAppContexts; /* * The context ClassLoader that was used to create this AppContext. @@ -236,14 +240,15 @@ public final class AppContext { threadGroup2appContext.put(threadGroup, this); this.contextClassLoader = - (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public ClassLoader run() { return Thread.currentThread().getContextClassLoader(); } }); } - private static MostRecentThreadAppContext mostRecentThreadAppContext = null; + private static final ThreadLocal threadAppContext = + new ThreadLocal(); /** * Returns the appropriate AppContext for the caller, @@ -260,59 +265,46 @@ public final class AppContext { if (numAppContexts == 1) // If there's only one system-wide, return mainAppContext; // return the main system AppContext. - final Thread currentThread = Thread.currentThread(); - - AppContext appContext = null; - - // Note: this most recent Thread/AppContext caching is thread-hot. - // A simple test using SwingSet found that 96.8% of lookups - // were matched using the most recent Thread/AppContext. By - // instantiating a simple MostRecentThreadAppContext object on - // cache misses, the cache hits can be processed without - // synchronization. + AppContext appContext = threadAppContext.get(); + + if (null == appContext) { + appContext = AccessController.doPrivileged(new PrivilegedAction() + { + public AppContext run() { + // Get the current ThreadGroup, and look for it and its + // parents in the hash from ThreadGroup to AppContext -- + // it should be found, because we use createNewContext() + // when new AppContext objects are created. + ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup(); + ThreadGroup threadGroup = currentThreadGroup; + AppContext context = threadGroup2appContext.get(threadGroup); + while (context == null) { + threadGroup = threadGroup.getParent(); + if (threadGroup == null) { + // If we get here, we're running under a ThreadGroup that + // has no AppContext associated with it. This should never + // happen, because createNewContext() should be used by the + // toolkit to create the ThreadGroup that everything runs + // under. + throw new RuntimeException("Invalid ThreadGroup"); + } + context = threadGroup2appContext.get(threadGroup); + } + // In case we did anything in the above while loop, we add + // all the intermediate ThreadGroups to threadGroup2appContext + // so we won't spin again. + for (ThreadGroup tg = currentThreadGroup; tg != threadGroup; tg = tg.getParent()) { + threadGroup2appContext.put(tg, context); + } + // Now we're done, so we cache the latest key/value pair. + // (we do this before checking with any AWTSecurityManager, so if + // this Thread equates with the main AppContext in the cache, it + // still will) + threadAppContext.set(context); - MostRecentThreadAppContext recent = mostRecentThreadAppContext; - if ((recent != null) && (recent.thread == currentThread)) { - appContext = recent.appContext; // Cache hit - } else { - appContext = (AppContext)AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - // Get the current ThreadGroup, and look for it and its - // parents in the hash from ThreadGroup to AppContext -- - // it should be found, because we use createNewContext() - // when new AppContext objects are created. - ThreadGroup currentThreadGroup = currentThread.getThreadGroup(); - ThreadGroup threadGroup = currentThreadGroup; - AppContext context = threadGroup2appContext.get(threadGroup); - while (context == null) { - threadGroup = threadGroup.getParent(); - if (threadGroup == null) { - // If we get here, we're running under a ThreadGroup that - // has no AppContext associated with it. This should never - // happen, because createNewContext() should be used by the - // toolkit to create the ThreadGroup that everything runs - // under. - throw new RuntimeException("Invalid ThreadGroup"); + return context; } - context = threadGroup2appContext.get(threadGroup); - } - // In case we did anything in the above while loop, we add - // all the intermediate ThreadGroups to threadGroup2appContext - // so we won't spin again. - for (ThreadGroup tg = currentThreadGroup; tg != threadGroup; tg = tg.getParent()) { - threadGroup2appContext.put(tg, context); - } - // Now we're done, so we cache the latest key/value pair. - // (we do this before checking with any AWTSecurityManager, so if - // this Thread equates with the main AppContext in the cache, it - // still will) - mostRecentThreadAppContext = - new MostRecentThreadAppContext(currentThread, context); - - return context; - } - }); + }); } if (appContext == mainAppContext) { @@ -321,9 +313,9 @@ public final class AppContext { // allow it to choose the AppContext to return. SecurityManager securityManager = System.getSecurityManager(); if ((securityManager != null) && - (securityManager instanceof AWTSecurityManager)) { - AWTSecurityManager awtSecMgr = - (AWTSecurityManager)securityManager; + (securityManager instanceof AWTSecurityManager)) + { + AWTSecurityManager awtSecMgr = (AWTSecurityManager)securityManager; AppContext secAppContext = awtSecMgr.getAppContext(); if (secAppContext != null) { appContext = secAppContext; // Return what we're told @@ -385,7 +377,13 @@ public final class AppContext { public void run() { Window[] windowsToDispose = Window.getOwnerlessWindows(); for (Window w : windowsToDispose) { - w.dispose(); + try { + w.dispose(); + } catch (Throwable t) { + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "exception occured while disposing app context", t); + } + } } AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -444,7 +442,7 @@ public final class AppContext { // Threads in the ThreadGroup to exit. long startTime = System.currentTimeMillis(); - long endTime = startTime + (long)THREAD_INTERRUPT_TIMEOUT; + long endTime = startTime + THREAD_INTERRUPT_TIMEOUT; while ((this.threadGroup.activeCount() > 0) && (System.currentTimeMillis() < endTime)) { try { @@ -459,7 +457,7 @@ public final class AppContext { // Threads in the ThreadGroup to die. startTime = System.currentTimeMillis(); - endTime = startTime + (long)THREAD_INTERRUPT_TIMEOUT; + endTime = startTime + THREAD_INTERRUPT_TIMEOUT; while ((this.threadGroup.activeCount() > 0) && (System.currentTimeMillis() < endTime)) { try { @@ -478,10 +476,7 @@ public final class AppContext { } threadGroup2appContext.remove(this.threadGroup); - MostRecentThreadAppContext recent = mostRecentThreadAppContext; - if ((recent != null) && (recent.appContext == this)) - mostRecentThreadAppContext = null; - // If the "most recent" points to this, clear it for GC + threadAppContext.set(null); // Finally, we destroy the ThreadGroup entirely. try { @@ -664,6 +659,7 @@ public final class AppContext { * Returns a string representation of this AppContext. * @since 1.2 */ + @Override public String toString() { return getClass().getName() + "[threadGroup=" + threadGroup.getName() + "]"; } @@ -769,15 +765,6 @@ public final class AppContext { } } -final class MostRecentThreadAppContext { - final Thread thread; - final AppContext appContext; - MostRecentThreadAppContext(Thread key, AppContext value) { - thread = key; - appContext = value; - } -} - final class MostRecentKeyValue { Object key; Object value; diff --git a/src/share/classes/sun/awt/datatransfer/DataTransferer.java b/src/share/classes/sun/awt/datatransfer/DataTransferer.java index 5dd12441081fb423244e530fb064e3ea880e6e8a..d96008309fb66cbdbe2083605fc844ddd81273f7 100644 --- a/src/share/classes/sun/awt/datatransfer/DataTransferer.java +++ b/src/share/classes/sun/awt/datatransfer/DataTransferer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-2008 Sun Microsystems, 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 @@ -270,62 +270,58 @@ public abstract class DataTransferer { * instead, null will be returned. */ public static DataTransferer getInstance() { - if (transferer == null) { - synchronized (DataTransferer.class) { - if (transferer == null) { - final String name = SunToolkit. - getDataTransfererClassName(); - if (name != null) { - PrivilegedAction action = new PrivilegedAction() { - public Object run() { - Class cls = null; - Method method = null; - Object ret = null; - - try { - cls = Class.forName(name); - } catch (ClassNotFoundException e) { - ClassLoader cl = ClassLoader. - getSystemClassLoader(); - if (cl != null) { - try { - cls = cl.loadClass(name); - } catch (ClassNotFoundException ee) { - ee.printStackTrace(); - throw new AWTError("DataTransferer not found: " + name); - } - } - } - if (cls != null) { + synchronized (DataTransferer.class) { + if (transferer == null) { + final String name = SunToolkit.getDataTransfererClassName(); + if (name != null) { + PrivilegedAction action = new PrivilegedAction() + { + public DataTransferer run() { + Class cls = null; + Method method = null; + DataTransferer ret = null; + + try { + cls = Class.forName(name); + } catch (ClassNotFoundException e) { + ClassLoader cl = ClassLoader. + getSystemClassLoader(); + if (cl != null) { try { - method = cls.getDeclaredMethod - ("getInstanceImpl"); - method.setAccessible(true); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new AWTError("Cannot instantiate DataTransferer: " + name); - } catch (SecurityException e) { - e.printStackTrace(); - throw new AWTError("Access is denied for DataTransferer: " + name); + cls = cl.loadClass(name); + } catch (ClassNotFoundException ee) { + ee.printStackTrace(); + throw new AWTError("DataTransferer not found: " + name); } } - if (method != null) { - try { - ret = method.invoke(null); - } catch (InvocationTargetException e) { - e.printStackTrace(); - throw new AWTError("Cannot instantiate DataTransferer: " + name); - } catch (IllegalAccessException e) { - e.printStackTrace(); - throw new AWTError("Cannot access DataTransferer: " + name); - } + } + if (cls != null) { + try { + method = cls.getDeclaredMethod("getInstanceImpl"); + method.setAccessible(true); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new AWTError("Cannot instantiate DataTransferer: " + name); + } catch (SecurityException e) { + e.printStackTrace(); + throw new AWTError("Access is denied for DataTransferer: " + name); } - return ret; } - }; - transferer = (DataTransferer) - AccessController.doPrivileged(action); - } + if (method != null) { + try { + ret = (DataTransferer) method.invoke(null); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new AWTError("Cannot instantiate DataTransferer: " + name); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new AWTError("Cannot access DataTransferer: " + name); + } + } + return ret; + } + }; + transferer = AccessController.doPrivileged(action); } } } diff --git a/src/share/classes/sun/instrument/InstrumentationImpl.java b/src/share/classes/sun/instrument/InstrumentationImpl.java index cdafaa4b8f2f2406e9f785bf08a14fb116c5b6f4..203f1563518481a2842d966a82b3f4271b65943a 100644 --- a/src/share/classes/sun/instrument/InstrumentationImpl.java +++ b/src/share/classes/sun/instrument/InstrumentationImpl.java @@ -303,39 +303,78 @@ public class InstrumentationImpl implements Instrumentation { NoSuchMethodException firstExc = null; boolean twoArgAgent = false; - // The agent class has a premain or agentmain method that has 1 or 2 - // arguments. We first check for a signature of (String, Instrumentation), - // and if not found we check for (String). If neither is found then we - // throw the NoSuchMethodException from the first attempt so that the - // exception text indicates the lookup failed for the 2-arg method - // (same as JDK5.0). + // The agent class must have a premain or agentmain method that + // has 1 or 2 arguments. We check in the following order: + // + // 1) declared with a signature of (String, Instrumentation) + // 2) declared with a signature of (String) + // 3) inherited with a signature of (String, Instrumentation) + // 4) inherited with a signature of (String) + // + // So the declared version of either 1-arg or 2-arg always takes + // primary precedence over an inherited version. After that, the + // 2-arg version takes precedence over the 1-arg version. + // + // If no method is found then we throw the NoSuchMethodException + // from the first attempt so that the exception text indicates + // the lookup failed for the 2-arg method (same as JDK5.0). try { - m = javaAgentClass.getMethod( methodname, - new Class[] { - String.class, - java.lang.instrument.Instrumentation.class - } - ); + m = javaAgentClass.getDeclaredMethod( methodname, + new Class[] { + String.class, + java.lang.instrument.Instrumentation.class + } + ); twoArgAgent = true; } catch (NoSuchMethodException x) { // remember the NoSuchMethodException firstExc = x; } - // check for the 1-arg method if (m == null) { + // now try the declared 1-arg method try { - m = javaAgentClass.getMethod(methodname, new Class[] { String.class }); + m = javaAgentClass.getDeclaredMethod(methodname, + new Class[] { String.class }); } catch (NoSuchMethodException x) { - // Neither method exists so we throw the first NoSuchMethodException - // as per 5.0 + // ignore this exception because we'll try + // two arg inheritance next + } + } + + if (m == null) { + // now try the inherited 2-arg method + try { + m = javaAgentClass.getMethod( methodname, + new Class[] { + String.class, + java.lang.instrument.Instrumentation.class + } + ); + twoArgAgent = true; + } catch (NoSuchMethodException x) { + // ignore this exception because we'll try + // one arg inheritance next + } + } + + if (m == null) { + // finally try the inherited 1-arg method + try { + m = javaAgentClass.getMethod(methodname, + new Class[] { String.class }); + } catch (NoSuchMethodException x) { + // none of the methods exists so we throw the + // first NoSuchMethodException as per 5.0 throw firstExc; } } // the premain method should not be required to be public, // make it accessible so we can call it + // Note: The spec says the following: + // The agent class must implement a public static premain method... setAccessible(m, true); // invoke the 1 or 2-arg method diff --git a/src/share/classes/sun/management/ClassLoadingImpl.java b/src/share/classes/sun/management/ClassLoadingImpl.java index 080921f7f37466ba4671599ce028f4130615feaa..c851f71dfb07f77d650af6fde59fb4c31dbbb537 100644 --- a/src/share/classes/sun/management/ClassLoadingImpl.java +++ b/src/share/classes/sun/management/ClassLoadingImpl.java @@ -26,6 +26,8 @@ package sun.management; import java.lang.management.ClassLoadingMXBean; +import java.lang.management.ManagementFactory; +import javax.management.ObjectName; /** * Implementation class for the class loading subsystem. @@ -62,9 +64,13 @@ class ClassLoadingImpl implements ClassLoadingMXBean { } public void setVerbose(boolean value) { - ManagementFactory.checkControlAccess(); + Util.checkControlAccess(); setVerboseClass(value); } native static void setVerboseClass(boolean value); + + public ObjectName getObjectName() { + return Util.newObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME); + } } diff --git a/src/share/classes/sun/management/CompilationImpl.java b/src/share/classes/sun/management/CompilationImpl.java index 5757642d61868e80f27d2191bb78cbae9145f277..ce5a8204436e61a3d9921afd6d1394a372b1ac93 100644 --- a/src/share/classes/sun/management/CompilationImpl.java +++ b/src/share/classes/sun/management/CompilationImpl.java @@ -26,6 +26,8 @@ package sun.management; import java.lang.management.CompilationMXBean; +import java.lang.management.ManagementFactory; +import javax.management.ObjectName; /** * Implementation class for the compilation subsystem. @@ -46,7 +48,7 @@ class CompilationImpl implements CompilationMXBean { this.jvm = vm; this.name = jvm.getCompilerName(); if (name == null) { - throw new InternalError("Null compiler name"); + throw new AssertionError("Null compiler name"); } } @@ -67,4 +69,9 @@ class CompilationImpl implements CompilationMXBean { return jvm.getTotalCompileTime(); } + public ObjectName getObjectName() { + return Util.newObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME); + } + + } diff --git a/src/share/classes/sun/management/ConnectorAddressLink.java b/src/share/classes/sun/management/ConnectorAddressLink.java index 58b1b3f5a70c8f8b626fc60b8b54f25b2fc51159..093746c3164770db825e7a06feff105aff8a996a 100644 --- a/src/share/classes/sun/management/ConnectorAddressLink.java +++ b/src/share/classes/sun/management/ConnectorAddressLink.java @@ -1,5 +1,5 @@ /* - * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2004-2008 Sun Microsystems, 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 @@ -25,12 +25,13 @@ package sun.management; +import java.io.IOException; import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; import java.util.Iterator; -import java.util.Set; -import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import sun.misc.Perf; import sun.management.counter.Units; @@ -46,36 +47,67 @@ import sun.management.counter.perf.PerfInstrumentation; public class ConnectorAddressLink { private static final String CONNECTOR_ADDRESS_COUNTER = - "sun.management.JMXConnectorServer.address"; + "sun.management.JMXConnectorServer.address"; + + /* + * The format of the jvmstat counters representing the properties of + * a given out-of-the-box JMX remote connector will be as follows: + * + * sun.management.JMXConnectorServer..= + * + * where: + * + * counter = index computed by this class which uniquely identifies + * an out-of-the-box JMX remote connector running in this + * Java virtual machine. + * key/value = a given key/value pair in the map supplied to the + * exportRemote() method. + * + * For example, + * + * sun.management.JMXConnectorServer.0.remoteAddress=service:jmx:rmi:///jndi/rmi://myhost:5000/jmxrmi + * sun.management.JMXConnectorServer.0.authenticate=false + * sun.management.JMXConnectorServer.0.ssl=false + * sun.management.JMXConnectorServer.0.sslRegistry=false + * sun.management.JMXConnectorServer.0.sslNeedClientAuth=false + */ + private static final String REMOTE_CONNECTOR_COUNTER_PREFIX = + "sun.management.JMXConnectorServer."; + + /* + * JMX remote connector counter (it will be incremented every + * time a new out-of-the-box JMX remote connector is created). + */ + private static AtomicInteger counter = new AtomicInteger(); /** * Exports the specified connector address to the instrumentation buffer * so that it can be read by this or other Java virtual machines running * on the same system. * - * @param address The connector address. + * @param address The connector address. */ public static void export(String address) { if (address == null || address.length() == 0) { throw new IllegalArgumentException("address not specified"); } Perf perf = Perf.getPerf(); - perf.createString(CONNECTOR_ADDRESS_COUNTER, 1, Units.STRING.intValue(), address); + perf.createString( + CONNECTOR_ADDRESS_COUNTER, 1, Units.STRING.intValue(), address); } /** * Imports the connector address from the instrument buffer * of the specified Java virtual machine. * - * @param vmid an identifier that uniquely identifies a local - * Java virtual machine, or 0 to indicate - * the current Java virtual machine. + * @param vmid an identifier that uniquely identifies a local Java virtual + * machine, or 0 to indicate the current Java virtual machine. * - * @return the value of the connector address, or null - * if the target VM has not exported a connector address. + * @return the value of the connector address, or null if the + * target VM has not exported a connector address. * - * @throws IOException An I/O error occurred while trying to acquire - * the instrumentation buffer. + * @throws IOException An I/O error occurred while trying to acquire the + * instrumentation buffer. */ public static String importFrom(int vmid) throws IOException { Perf perf = Perf.getPerf(); @@ -85,14 +117,65 @@ public class ConnectorAddressLink { } catch (IllegalArgumentException iae) { throw new IOException(iae.getMessage()); } - List counters = (new PerfInstrumentation(bb)).findByPattern(CONNECTOR_ADDRESS_COUNTER); + List counters = + new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER); Iterator i = counters.iterator(); if (i.hasNext()) { - Counter c = (Counter)i.next(); - return (String)c.getValue(); + Counter c = (Counter) i.next(); + return (String) c.getValue(); } else { return null; } } + /** + * Exports the specified remote connector address and associated + * configuration properties to the instrumentation buffer so that + * it can be read by this or other Java virtual machines running + * on the same system. + * + * @param properties The remote connector address properties. + */ + public static void exportRemote(Map properties) { + final int index = counter.getAndIncrement(); + Perf perf = Perf.getPerf(); + for (Map.Entry entry : properties.entrySet()) { + perf.createString(REMOTE_CONNECTOR_COUNTER_PREFIX + index + "." + + entry.getKey(), 1, Units.STRING.intValue(), entry.getValue()); + } + } + + /** + * Imports the remote connector address and associated + * configuration properties from the instrument buffer + * of the specified Java virtual machine. + * + * @param vmid an identifier that uniquely identifies a local Java virtual + * machine, or 0 to indicate the current Java virtual machine. + * + * @return a map containing the remote connector's properties, or an empty + * map if the target VM has not exported the remote connector's properties. + * + * @throws IOException An I/O error occurred while trying to acquire the + * instrumentation buffer. + */ + public static Map importRemoteFrom(int vmid) throws IOException { + Perf perf = Perf.getPerf(); + ByteBuffer bb; + try { + bb = perf.attach(vmid, "r"); + } catch (IllegalArgumentException iae) { + throw new IOException(iae.getMessage()); + } + List counters = new PerfInstrumentation(bb).getAllCounters(); + Map properties = new HashMap(); + for (Object c : counters) { + String name = ((Counter) c).getName(); + if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) && + !name.equals(CONNECTOR_ADDRESS_COUNTER)) { + properties.put(name, ((Counter) c).getValue().toString()); + } + } + return properties; + } } diff --git a/src/share/classes/sun/management/Flag.java b/src/share/classes/sun/management/Flag.java index 510edadd6682026d9ec5fab5c234e0e5d58b5a2c..d89761cb1f7878ba2e9360055badf3387a1c6635 100644 --- a/src/share/classes/sun/management/Flag.java +++ b/src/share/classes/sun/management/Flag.java @@ -64,7 +64,8 @@ class Flag { } VMOption getVMOption() { - return new VMOption(name, value.toString(), writeable, origin); + String val = value == null ? "" : value.toString(); + return new VMOption(name, val, writeable, origin); } static Flag getFlag(String name) { diff --git a/src/share/classes/sun/management/GarbageCollectorImpl.java b/src/share/classes/sun/management/GarbageCollectorImpl.java index b5ac9a987ccde6c3186599cf3c64b30adaaba822..17d8fcda4968017119236ae2afa8d42fb55674f9 100644 --- a/src/share/classes/sun/management/GarbageCollectorImpl.java +++ b/src/share/classes/sun/management/GarbageCollectorImpl.java @@ -34,6 +34,7 @@ import com.sun.management.GcInfo; import javax.management.openmbean.CompositeData; import javax.management.MBeanInfo; import javax.management.MBeanAttributeInfo; +import javax.management.ObjectName; import java.util.List; import java.util.ListIterator; @@ -88,4 +89,8 @@ class GarbageCollectorImpl extends MemoryManagerImpl return info; } + public ObjectName getObjectName() { + return Util.newObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE, getName()); + } + } diff --git a/src/share/classes/sun/management/GcInfoBuilder.java b/src/share/classes/sun/management/GcInfoBuilder.java index 2e892a55ac0608dac14ad141eaf01824ece9f963..dcacc1b53566cf4455b898e720c0cea9b5d26a20 100644 --- a/src/share/classes/sun/management/GcInfoBuilder.java +++ b/src/share/classes/sun/management/GcInfoBuilder.java @@ -145,7 +145,7 @@ public class GcInfoBuilder { allItemTypes[i] = SimpleType.DOUBLE; break; default: - throw new InternalError( + throw new AssertionError( "Unsupported type [" + gcExtItemTypes[i] + "]"); } } diff --git a/src/share/classes/sun/management/GcInfoCompositeData.java b/src/share/classes/sun/management/GcInfoCompositeData.java index 9face5bded95533024d9dd5536a6d6dc19bde617..ab4d1c557ba493e29b586cf8dce54dfcbb488586 100644 --- a/src/share/classes/sun/management/GcInfoCompositeData.java +++ b/src/share/classes/sun/management/GcInfoCompositeData.java @@ -80,19 +80,19 @@ public class GcInfoCompositeData extends LazyCompositeData { }; } catch (OpenDataException e) { // Should never reach here - throw Util.newAssertionError(e); + throw new AssertionError(e); } // Get the item values for the extension attributes final int gcExtItemCount = builder.getGcExtItemCount(); if (gcExtItemCount == 0 && gcExtItemValues != null && gcExtItemValues.length != 0) { - throw new InternalError("Unexpected Gc Extension Item Values"); + throw new AssertionError("Unexpected Gc Extension Item Values"); } if (gcExtItemCount > 0 && (gcExtItemValues == null || gcExtItemCount != gcExtItemValues.length)) { - throw new InternalError("Unmatched Gc Extension Item Values"); + throw new AssertionError("Unmatched Gc Extension Item Values"); } Object[] values = new Object[baseGcInfoItemValues.length + @@ -111,7 +111,7 @@ public class GcInfoCompositeData extends LazyCompositeData { values); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } @@ -141,10 +141,10 @@ public class GcInfoCompositeData extends LazyCompositeData { MappedMXBeanType.getMappedType(m.getGenericReturnType()); } catch (NoSuchMethodException e) { // Should never reach here - throw Util.newAssertionError(e); + throw new AssertionError(e); } catch (OpenDataException e) { // Should never reach here - throw Util.newAssertionError(e); + throw new AssertionError(e); } } @@ -186,10 +186,10 @@ public class GcInfoCompositeData extends LazyCompositeData { return cast(memoryUsageMapType.toJavaTypeData(td)); } catch (InvalidObjectException e) { // Should never reach here - throw Util.newAssertionError(e); + throw new AssertionError(e); } catch (OpenDataException e) { // Should never reach here - throw Util.newAssertionError(e); + throw new AssertionError(e); } } @@ -205,10 +205,10 @@ public class GcInfoCompositeData extends LazyCompositeData { return cast(memoryUsageMapType.toJavaTypeData(td)); } catch (InvalidObjectException e) { // Should never reach here - throw Util.newAssertionError(e); + throw new AssertionError(e); } catch (OpenDataException e) { // Should never reach here - throw Util.newAssertionError(e); + throw new AssertionError(e); } } diff --git a/src/share/classes/sun/management/HotSpotDiagnostic.java b/src/share/classes/sun/management/HotSpotDiagnostic.java index 174e4a054393526f9f931b4da4263ea76e396f29..060c4573a92f6e956318a62e6de159d26429f3b8 100644 --- a/src/share/classes/sun/management/HotSpotDiagnostic.java +++ b/src/share/classes/sun/management/HotSpotDiagnostic.java @@ -28,6 +28,8 @@ package sun.management; import java.util.*; import java.io.IOException; import java.lang.reflect.Method; +import javax.management.ObjectName; + import com.sun.management.HotSpotDiagnosticMXBean; import com.sun.management.VMOption; @@ -72,7 +74,7 @@ public class HotSpotDiagnostic implements HotSpotDiagnosticMXBean { throw new NullPointerException("value cannot be null"); } - ManagementFactory.checkControlAccess(); + Util.checkControlAccess(); Flag flag = Flag.getFlag(name); if (flag == null) { throw new IllegalArgumentException("VM option \"" + @@ -113,4 +115,8 @@ public class HotSpotDiagnostic implements HotSpotDiagnosticMXBean { v.getClass().getName()); } } + + public ObjectName getObjectName() { + return Util.newObjectName("com.sun.management:type=HotSpotDiagnostic"); + } } diff --git a/src/share/classes/sun/management/HotspotCompilation.java b/src/share/classes/sun/management/HotspotCompilation.java index 9b0deb9963577caeacf7c3646afee7049aaa2776..50348cedffcaed3a4fce0a4f2c82a430190901fb 100644 --- a/src/share/classes/sun/management/HotspotCompilation.java +++ b/src/share/classes/sun/management/HotspotCompilation.java @@ -131,7 +131,7 @@ class HotspotCompilation } // FIXME: should tolerate if counter doesn't exist - throw new InternalError("Counter " + name + " does not exist"); + throw new AssertionError("Counter " + name + " does not exist"); } private void initCompilerCounters() { diff --git a/src/share/classes/sun/management/HotspotInternal.java b/src/share/classes/sun/management/HotspotInternal.java index ed452d6d3cb70367a6daa0df4ac77ce746e0b21c..45c4a9afd2f80df965cae1213bfa631d57f7ea5b 100644 --- a/src/share/classes/sun/management/HotspotInternal.java +++ b/src/share/classes/sun/management/HotspotInternal.java @@ -39,6 +39,9 @@ import javax.management.ObjectName; public class HotspotInternal implements HotspotInternalMBean, MBeanRegistration { + private final static String HOTSPOT_INTERNAL_MBEAN_NAME = + "sun.management:type=HotspotInternal"; + private static ObjectName objName = Util.newObjectName(HOTSPOT_INTERNAL_MBEAN_NAME); private MBeanServer server = null; /** @@ -52,16 +55,16 @@ public class HotspotInternal ObjectName name) throws java.lang.Exception { // register all internal MBeans when this MBean is instantiated // and to be registered in a MBeanServer. - ManagementFactory.registerInternalMBeans(server); + ManagementFactoryHelper.registerInternalMBeans(server); this.server = server; - return ManagementFactory.getHotspotInternalObjectName(); + return objName; } public void postRegister(Boolean registrationDone) {}; public void preDeregister() throws java.lang.Exception { // unregister all internal MBeans when this MBean is unregistered. - ManagementFactory.unregisterInternalMBeans(server); + ManagementFactoryHelper.unregisterInternalMBeans(server); } public void postDeregister() {}; diff --git a/src/share/classes/sun/management/LockDataConverter.java b/src/share/classes/sun/management/LockDataConverter.java index e72c6b9387174e26537fec4900fd7ce4a6da81a8..4b557ad2cd753d328f7154460ed0e264ae1d26bd 100644 --- a/src/share/classes/sun/management/LockDataConverter.java +++ b/src/share/classes/sun/management/LockDataConverter.java @@ -73,7 +73,7 @@ class LockDataConverter extends StandardMBean try { return (CompositeData) getAttribute("LockInfo"); } catch (Exception e) { - throw Util.newInternalError(e); + throw new AssertionError(e); } } @@ -81,7 +81,7 @@ class LockDataConverter extends StandardMBean try { return (CompositeData[]) getAttribute("LockedSynchronizers"); } catch (Exception e) { - throw Util.newInternalError(e); + throw new AssertionError(e); } } @@ -89,7 +89,7 @@ class LockDataConverter extends StandardMBean try { setAttribute(new Attribute("LockInfo", cd)); } catch (Exception e) { - throw Util.newInternalError(e); + throw new AssertionError(e); } return getLockInfo(); } @@ -98,7 +98,7 @@ class LockDataConverter extends StandardMBean try { setAttribute(new Attribute("LockedSynchronizers", cd)); } catch (Exception e) { - throw Util.newInternalError(e); + throw new AssertionError(e); } return getLockedSynchronizers(); } diff --git a/src/share/classes/sun/management/ManagementFactory.java b/src/share/classes/sun/management/ManagementFactory.java index 24a6bc1cff1cdcc779754a38203361e3c1c52664..12891a6d20af73aab013420be461b24c3105a16c 100644 --- a/src/share/classes/sun/management/ManagementFactory.java +++ b/src/share/classes/sun/management/ManagementFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008 Sun Microsystems, 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 @@ -25,445 +25,17 @@ package sun.management; -import java.lang.management.*; -import java.util.logging.LogManager; - -import javax.management.DynamicMBean; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; -import javax.management.MBeanInfo; -import javax.management.NotificationEmitter; -import javax.management.ObjectName; -import javax.management.ObjectInstance; -import javax.management.InstanceAlreadyExistsException; -import javax.management.InstanceNotFoundException; -import javax.management.MBeanRegistrationException; -import javax.management.NotCompliantMBeanException; -import javax.management.MalformedObjectNameException; -import javax.management.RuntimeOperationsException; -import javax.management.StandardEmitterMBean; -import javax.management.StandardMBean; -import java.security.AccessController; -import java.security.Permission; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import sun.security.action.LoadLibraryAction; - -import java.util.ArrayList; -import java.util.List; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.Iterator; -import java.util.ListIterator; -import com.sun.management.OSMBeanFactory; -import com.sun.management.HotSpotDiagnosticMXBean; - -import static java.lang.management.ManagementFactory.*; +import java.lang.management.MemoryManagerMXBean; +import java.lang.management.MemoryPoolMXBean; +import java.lang.management.GarbageCollectorMXBean; /** - * ManagementFactory provides static factory methods to create - * instances of the management interface. + * ManagementFactory class provides the methods that the HotSpot VM + * will invoke. So the class and method names cannot be renamed. */ -public class ManagementFactory { +class ManagementFactory { private ManagementFactory() {}; - private static VMManagement jvm; - - private static boolean mbeansCreated = false; - private static ClassLoadingImpl classMBean = null; - private static MemoryImpl memoryMBean = null; - private static ThreadImpl threadMBean = null; - private static RuntimeImpl runtimeMBean = null; - private static CompilationImpl compileMBean = null; - private static OperatingSystemImpl osMBean = null; - - public static synchronized ClassLoadingMXBean getClassLoadingMXBean() { - if (classMBean == null) { - classMBean = new ClassLoadingImpl(jvm); - } - return classMBean; - } - - public static synchronized MemoryMXBean getMemoryMXBean() { - if (memoryMBean == null) { - memoryMBean = new MemoryImpl(jvm); - } - return memoryMBean; - } - - public static synchronized ThreadMXBean getThreadMXBean() { - if (threadMBean == null) { - threadMBean = new ThreadImpl(jvm); - } - return threadMBean; - } - - public static synchronized RuntimeMXBean getRuntimeMXBean() { - if (runtimeMBean == null) { - runtimeMBean = new RuntimeImpl(jvm); - } - return runtimeMBean; - } - - public static synchronized CompilationMXBean getCompilationMXBean() { - if (compileMBean == null && jvm.getCompilerName() != null) { - compileMBean = new CompilationImpl(jvm); - } - return compileMBean; - } - - public static synchronized OperatingSystemMXBean getOperatingSystemMXBean() { - if (osMBean == null) { - osMBean = (OperatingSystemImpl) - OSMBeanFactory.getOperatingSystemMXBean(jvm); - } - return osMBean; - } - - public static List getMemoryPoolMXBeans() { - MemoryPoolMXBean[] pools = MemoryImpl.getMemoryPools(); - List list = new ArrayList(pools.length); - for (int i = 0; i < pools.length; i++) { - MemoryPoolMXBean p = pools[i]; - list.add(p); - } - return list; - } - - public static List getMemoryManagerMXBeans() { - MemoryManagerMXBean[] mgrs = MemoryImpl.getMemoryManagers(); - List result = new ArrayList(mgrs.length); - for (int i = 0; i < mgrs.length; i++) { - MemoryManagerMXBean m = mgrs[i]; - result.add(m); - } - return result; - } - - public static List getGarbageCollectorMXBeans() { - MemoryManagerMXBean[] mgrs = MemoryImpl.getMemoryManagers(); - List result = new ArrayList(mgrs.length); - for (int i = 0; i < mgrs.length; i++) { - if (mgrs[i] instanceof GarbageCollectorMXBean) { - GarbageCollectorMXBean gc = (GarbageCollectorMXBean) mgrs[i]; - result.add(gc); - } - } - return result; - } - - private static HotSpotDiagnostic hsDiagMBean = null; - private static HotspotRuntime hsRuntimeMBean = null; - private static HotspotClassLoading hsClassMBean = null; - private static HotspotThread hsThreadMBean = null; - private static HotspotCompilation hsCompileMBean = null; - private static HotspotMemory hsMemoryMBean = null; - - public static synchronized HotSpotDiagnosticMXBean getDiagnosticMXBean() { - if (hsDiagMBean == null) { - hsDiagMBean = new HotSpotDiagnostic(); - } - return hsDiagMBean; - } - - /** - - /** - * This method is for testing only. - */ - public static synchronized HotspotRuntimeMBean getHotspotRuntimeMBean() { - if (hsRuntimeMBean == null) { - hsRuntimeMBean = new HotspotRuntime(jvm); - } - return hsRuntimeMBean; - } - - /** - * This method is for testing only. - */ - public static synchronized HotspotClassLoadingMBean getHotspotClassLoadingMBean() { - if (hsClassMBean == null) { - hsClassMBean = new HotspotClassLoading(jvm); - } - return hsClassMBean; - } - - /** - * This method is for testing only. - */ - public static synchronized HotspotThreadMBean getHotspotThreadMBean() { - if (hsThreadMBean == null) { - hsThreadMBean = new HotspotThread(jvm); - } - return hsThreadMBean; - } - - /** - * This method is for testing only. - */ - public static synchronized HotspotMemoryMBean getHotspotMemoryMBean() { - if (hsMemoryMBean == null) { - hsMemoryMBean = new HotspotMemory(jvm); - } - return hsMemoryMBean; - } - - /** - * This method is for testing only. - */ - public static synchronized HotspotCompilationMBean getHotspotCompilationMBean() { - if (hsCompileMBean == null) { - hsCompileMBean = new HotspotCompilation(jvm); - } - return hsCompileMBean; - } - - private static Permission monitorPermission = - new ManagementPermission("monitor"); - private static Permission controlPermission = - new ManagementPermission("control"); - - /** - * Check that the current context is trusted to perform monitoring - * or management. - *

        - * If the check fails we throw a SecurityException, otherwise - * we return normally. - * - * @exception SecurityException if a security manager exists and if - * the caller does not have ManagementPermission("control"). - */ - static void checkAccess(Permission p) - throws SecurityException { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(p); - } - } - - static void checkMonitorAccess() throws SecurityException { - checkAccess(monitorPermission); - } - static void checkControlAccess() throws SecurityException { - checkAccess(controlPermission); - } - - /** - * Registers an MXBean and throws exception if an instance with the same - * name exists. - * - * This method makes a DynamicMBean out of an MXBean by wrapping it with a - * StandardMBean (StandardEmitterMBean if the supplied emitter is not null), - * so it can be registered in an MBeanServer which does not have support for - * MXBeans. - */ - private static void addMXBean(MBeanServer mbs, Object mbean, - String mbeanName, NotificationEmitter emitter) { - // Make DynamicMBean out of MXBean by wrapping it with a StandardMBean - // - final DynamicMBean dmbean; - if (emitter == null) { - dmbean = new StandardMBean(mbean, null, true); - } else { - dmbean = new StandardEmitterMBean(mbean, null, true, emitter); - } - addMBean(mbs, dmbean, mbeanName, false); - } - - /** - * Registers a Standard MBean or a Dynamic MBean and throws - * exception if an instance with the same name exists. - */ - private static void addMBean(MBeanServer mbs, Object mbean, String mbeanName) { - addMBean(mbs, mbean, mbeanName, false); - } - - private static void addMBean(MBeanServer mbs, Object mbean, - String mbeanName, boolean ignoreConflicts) { - try { - final ObjectName objName = new ObjectName(mbeanName); - - // inner class requires these fields to be final - final MBeanServer mbs0 = mbs; - final Object mbean0 = mbean; - final boolean ignore = ignoreConflicts; - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws InstanceAlreadyExistsException, - MBeanRegistrationException, - NotCompliantMBeanException { - try { - ObjectInstance o = mbs0.registerMBean(mbean0, - objName); - return null; - } catch (InstanceAlreadyExistsException e) { - // if an instance with the object name exists in - // the MBeanServer ignore the exception - // if ignoreConflicts is true; - // otherwise, throws exception. - if (!ignore) { - throw e; - } - } - return null; - } - }); - } catch (PrivilegedActionException e) { - throw Util.newException(e.getException()); - } catch (MalformedObjectNameException e) { - // should not reach here - throw Util.newException(e); - } - } - - public static MBeanServer createPlatformMBeanServer() { - MBeanServer mbs = MBeanServerFactory.createMBeanServer(); - // Register all the platform MBeans to this MBeanServer - addMXBean(mbs, getClassLoadingMXBean(), - CLASS_LOADING_MXBEAN_NAME, null); - addMXBean(mbs, getMemoryMXBean(), - MEMORY_MXBEAN_NAME, (NotificationEmitter) getMemoryMXBean()); - addMXBean(mbs, getOperatingSystemMXBean(), - OPERATING_SYSTEM_MXBEAN_NAME, null); - addMXBean(mbs, getRuntimeMXBean(), - RUNTIME_MXBEAN_NAME, null); - addMXBean(mbs, getThreadMXBean(), - THREAD_MXBEAN_NAME, null); - addMXBean(mbs, getDiagnosticMXBean(), - HOTSPOT_DIAGNOSTIC_MXBEAN_NAME, null); - - // CompilationMBean may not exist - if (getCompilationMXBean() != null) { - addMXBean(mbs, getCompilationMXBean(), - COMPILATION_MXBEAN_NAME, null); - } - - // Register MBeans for memory pools and memory managers - addMemoryManagers(mbs); - addMemoryPools(mbs); - - // Register platform extension - addMXBean(mbs, LogManager.getLoggingMXBean(), - LogManager.LOGGING_MXBEAN_NAME, null); - - return mbs; - } - - private final static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME = - "com.sun.management:type=HotSpotDiagnostic"; - - private final static String HOTSPOT_CLASS_LOADING_MBEAN_NAME = - "sun.management:type=HotspotClassLoading"; - - private final static String HOTSPOT_COMPILATION_MBEAN_NAME = - "sun.management:type=HotspotCompilation"; - - private final static String HOTSPOT_MEMORY_MBEAN_NAME = - "sun.management:type=HotspotMemory"; - - private static final String HOTSPOT_RUNTIME_MBEAN_NAME = - "sun.management:type=HotspotRuntime"; - - private final static String HOTSPOT_THREAD_MBEAN_NAME = - "sun.management:type=HotspotThreading"; - - private final static String HOTSPOT_INTERNAL_MBEAN_NAME = - "sun.management:type=HotspotInternal"; - - private static ObjectName hsInternalObjName = null; - static synchronized ObjectName getHotspotInternalObjectName() { - if (hsInternalObjName == null) { - try { - hsInternalObjName = new ObjectName(HOTSPOT_INTERNAL_MBEAN_NAME); - } catch (MalformedObjectNameException e) { - // should not reach here - throw Util.newException(e); - } - } - return hsInternalObjName; - } - - static void registerInternalMBeans(MBeanServer mbs) { - // register all internal MBeans if not registered - // No exception is thrown if a MBean with that object name - // already registered (i.e. ignore if name conflicts). - addMBean(mbs, getHotspotClassLoadingMBean(), - HOTSPOT_CLASS_LOADING_MBEAN_NAME, true); - addMBean(mbs, getHotspotMemoryMBean(), - HOTSPOT_MEMORY_MBEAN_NAME, true); - addMBean(mbs, getHotspotRuntimeMBean(), - HOTSPOT_RUNTIME_MBEAN_NAME, true); - addMBean(mbs, getHotspotThreadMBean(), - HOTSPOT_THREAD_MBEAN_NAME, true); - - // CompilationMBean may not exist - if (getCompilationMXBean() != null) { - addMBean(mbs, getHotspotCompilationMBean(), - HOTSPOT_COMPILATION_MBEAN_NAME, true); - } - } - - private static void unregisterMBean(MBeanServer mbs, String mbeanName) { - try { - final ObjectName objName = new ObjectName(mbeanName); - - // inner class requires these fields to be final - final MBeanServer mbs0 = mbs; - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws MBeanRegistrationException, - RuntimeOperationsException { - try { - mbs0.unregisterMBean(objName); - } catch (InstanceNotFoundException e) { - // ignore exception if not found - } - return null; - } - }); - } catch (PrivilegedActionException e) { - throw Util.newException(e.getException()); - } catch (MalformedObjectNameException e) { - // should not reach here - throw Util.newException(e); - } - } - - static void unregisterInternalMBeans(MBeanServer mbs) { - // unregister all internal MBeans - unregisterMBean(mbs, HOTSPOT_CLASS_LOADING_MBEAN_NAME); - unregisterMBean(mbs, HOTSPOT_MEMORY_MBEAN_NAME); - unregisterMBean(mbs, HOTSPOT_RUNTIME_MBEAN_NAME); - unregisterMBean(mbs, HOTSPOT_THREAD_MBEAN_NAME); - - // CompilationMBean may not exist - if (getCompilationMXBean() != null) { - unregisterMBean(mbs, HOTSPOT_COMPILATION_MBEAN_NAME); - } - } - - private static synchronized void addMemoryPools(MBeanServer mbs) { - - // Get a list of memory pools - MemoryPoolMXBean[] newPools = MemoryImpl.getMemoryPools(); - - for (int i = 0; i < newPools.length; i++) { - String poolObjNameString = Util.getMBeanObjectName(newPools[i]); - addMXBean(mbs, newPools[i], poolObjNameString, null); - } - } - - // Register all memory managers with the MBeanServer; - private static synchronized void addMemoryManagers(MBeanServer mbs) { - - // Get a list of memory managers - MemoryManagerMXBean[] newMgrs = MemoryImpl.getMemoryManagers(); - - for (int i = 0; i < newMgrs.length; i++) { - String mgrObjNameString = Util.getMBeanObjectName(newMgrs[i]); - addMXBean(mbs, newMgrs[i], mgrObjNameString, null); - } - } - // Invoked by the VM private static MemoryPoolMXBean createMemoryPool (String name, boolean isHeap, long uThreshold, long gcThreshold) { @@ -480,29 +52,4 @@ public class ManagementFactory { // ignore type parameter which is for future extension return new GarbageCollectorImpl(name); } - - static { - AccessController.doPrivileged(new LoadLibraryAction("management")); - jvm = new VMManagementImpl(); - } - - public static boolean isThreadSuspended(int state) { - return ((state & JMM_THREAD_STATE_FLAG_SUSPENDED) != 0); - } - - public static boolean isThreadRunningNative(int state) { - return ((state & JMM_THREAD_STATE_FLAG_NATIVE) != 0); - } - - public static Thread.State toThreadState(int state) { - // suspended and native bits may be set in state - int threadStatus = state & ~JMM_THREAD_STATE_FLAG_MASK; - return sun.misc.VM.toThreadState(threadStatus); - } - - // These values are defined in jmm.h - private static final int JMM_THREAD_STATE_FLAG_MASK = 0xFFF00000; - private static final int JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000; - private static final int JMM_THREAD_STATE_FLAG_NATIVE = 0x00400000; - } diff --git a/src/share/classes/sun/management/ManagementFactoryHelper.java b/src/share/classes/sun/management/ManagementFactoryHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..0ba44a81289f291c4db7c437a8a038a11c6c51c5 --- /dev/null +++ b/src/share/classes/sun/management/ManagementFactoryHelper.java @@ -0,0 +1,340 @@ +/* + * Copyright 2003-2006 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package sun.management; + +import java.lang.management.*; +import java.util.logging.LogManager; + +import javax.management.DynamicMBean; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.management.MBeanInfo; +import javax.management.NotificationEmitter; +import javax.management.ObjectName; +import javax.management.ObjectInstance; +import javax.management.InstanceAlreadyExistsException; +import javax.management.InstanceNotFoundException; +import javax.management.MBeanRegistrationException; +import javax.management.NotCompliantMBeanException; +import javax.management.RuntimeOperationsException; +import javax.management.StandardEmitterMBean; +import javax.management.StandardMBean; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import sun.security.action.LoadLibraryAction; + +import java.util.ArrayList; +import java.util.List; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.Iterator; +import java.util.ListIterator; +import com.sun.management.OSMBeanFactory; +import com.sun.management.HotSpotDiagnosticMXBean; + +import static java.lang.management.ManagementFactory.*; + +/** + * ManagementFactoryHelper provides static factory methods to create + * instances of the management interface. + */ +public class ManagementFactoryHelper { + private ManagementFactoryHelper() {}; + + private static VMManagement jvm; + + private static boolean mbeansCreated = false; + private static ClassLoadingImpl classMBean = null; + private static MemoryImpl memoryMBean = null; + private static ThreadImpl threadMBean = null; + private static RuntimeImpl runtimeMBean = null; + private static CompilationImpl compileMBean = null; + private static OperatingSystemImpl osMBean = null; + + public static synchronized ClassLoadingMXBean getClassLoadingMXBean() { + if (classMBean == null) { + classMBean = new ClassLoadingImpl(jvm); + } + return classMBean; + } + + public static synchronized MemoryMXBean getMemoryMXBean() { + if (memoryMBean == null) { + memoryMBean = new MemoryImpl(jvm); + } + return memoryMBean; + } + + public static synchronized ThreadMXBean getThreadMXBean() { + if (threadMBean == null) { + threadMBean = new ThreadImpl(jvm); + } + return threadMBean; + } + + public static synchronized RuntimeMXBean getRuntimeMXBean() { + if (runtimeMBean == null) { + runtimeMBean = new RuntimeImpl(jvm); + } + return runtimeMBean; + } + + public static synchronized CompilationMXBean getCompilationMXBean() { + if (compileMBean == null && jvm.getCompilerName() != null) { + compileMBean = new CompilationImpl(jvm); + } + return compileMBean; + } + + public static synchronized OperatingSystemMXBean getOperatingSystemMXBean() { + if (osMBean == null) { + osMBean = (OperatingSystemImpl) + OSMBeanFactory.getOperatingSystemMXBean(jvm); + } + return osMBean; + } + + public static List getMemoryPoolMXBeans() { + MemoryPoolMXBean[] pools = MemoryImpl.getMemoryPools(); + List list = new ArrayList(pools.length); + for (MemoryPoolMXBean p : pools) { + list.add(p); + } + return list; + } + + public static List getMemoryManagerMXBeans() { + MemoryManagerMXBean[] mgrs = MemoryImpl.getMemoryManagers(); + List result = new ArrayList(mgrs.length); + for (MemoryManagerMXBean m : mgrs) { + result.add(m); + } + return result; + } + + public static List getGarbageCollectorMXBeans() { + MemoryManagerMXBean[] mgrs = MemoryImpl.getMemoryManagers(); + List result = new ArrayList(mgrs.length); + for (MemoryManagerMXBean m : mgrs) { + if (GarbageCollectorMXBean.class.isInstance(m)) { + result.add(GarbageCollectorMXBean.class.cast(m)); + } + } + return result; + } + + private static HotSpotDiagnostic hsDiagMBean = null; + private static HotspotRuntime hsRuntimeMBean = null; + private static HotspotClassLoading hsClassMBean = null; + private static HotspotThread hsThreadMBean = null; + private static HotspotCompilation hsCompileMBean = null; + private static HotspotMemory hsMemoryMBean = null; + + public static synchronized HotSpotDiagnosticMXBean getDiagnosticMXBean() { + if (hsDiagMBean == null) { + hsDiagMBean = new HotSpotDiagnostic(); + } + return hsDiagMBean; + } + + /** + + /** + * This method is for testing only. + */ + public static synchronized HotspotRuntimeMBean getHotspotRuntimeMBean() { + if (hsRuntimeMBean == null) { + hsRuntimeMBean = new HotspotRuntime(jvm); + } + return hsRuntimeMBean; + } + + /** + * This method is for testing only. + */ + public static synchronized HotspotClassLoadingMBean getHotspotClassLoadingMBean() { + if (hsClassMBean == null) { + hsClassMBean = new HotspotClassLoading(jvm); + } + return hsClassMBean; + } + + /** + * This method is for testing only. + */ + public static synchronized HotspotThreadMBean getHotspotThreadMBean() { + if (hsThreadMBean == null) { + hsThreadMBean = new HotspotThread(jvm); + } + return hsThreadMBean; + } + + /** + * This method is for testing only. + */ + public static synchronized HotspotMemoryMBean getHotspotMemoryMBean() { + if (hsMemoryMBean == null) { + hsMemoryMBean = new HotspotMemory(jvm); + } + return hsMemoryMBean; + } + + /** + * This method is for testing only. + */ + public static synchronized HotspotCompilationMBean getHotspotCompilationMBean() { + if (hsCompileMBean == null) { + hsCompileMBean = new HotspotCompilation(jvm); + } + return hsCompileMBean; + } + + /** + * Registers a given MBean if not registered in the MBeanServer; + * otherwise, just return. + */ + private static void addMBean(MBeanServer mbs, Object mbean, String mbeanName) { + try { + final ObjectName objName = Util.newObjectName(mbeanName); + + // inner class requires these fields to be final + final MBeanServer mbs0 = mbs; + final Object mbean0 = mbean; + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Void run() throws MBeanRegistrationException, + NotCompliantMBeanException { + try { + mbs0.registerMBean(mbean0, objName); + return null; + } catch (InstanceAlreadyExistsException e) { + // if an instance with the object name exists in + // the MBeanServer ignore the exception + } + return null; + } + }); + } catch (PrivilegedActionException e) { + throw Util.newException(e.getException()); + } + } + + private final static String HOTSPOT_CLASS_LOADING_MBEAN_NAME = + "sun.management:type=HotspotClassLoading"; + + private final static String HOTSPOT_COMPILATION_MBEAN_NAME = + "sun.management:type=HotspotCompilation"; + + private final static String HOTSPOT_MEMORY_MBEAN_NAME = + "sun.management:type=HotspotMemory"; + + private static final String HOTSPOT_RUNTIME_MBEAN_NAME = + "sun.management:type=HotspotRuntime"; + + private final static String HOTSPOT_THREAD_MBEAN_NAME = + "sun.management:type=HotspotThreading"; + + static void registerInternalMBeans(MBeanServer mbs) { + // register all internal MBeans if not registered + // No exception is thrown if a MBean with that object name + // already registered + addMBean(mbs, getHotspotClassLoadingMBean(), + HOTSPOT_CLASS_LOADING_MBEAN_NAME); + addMBean(mbs, getHotspotMemoryMBean(), + HOTSPOT_MEMORY_MBEAN_NAME); + addMBean(mbs, getHotspotRuntimeMBean(), + HOTSPOT_RUNTIME_MBEAN_NAME); + addMBean(mbs, getHotspotThreadMBean(), + HOTSPOT_THREAD_MBEAN_NAME); + + // CompilationMBean may not exist + if (getCompilationMXBean() != null) { + addMBean(mbs, getHotspotCompilationMBean(), + HOTSPOT_COMPILATION_MBEAN_NAME); + } + } + + private static void unregisterMBean(MBeanServer mbs, String mbeanName) { + try { + final ObjectName objName = Util.newObjectName(mbeanName); + + // inner class requires these fields to be final + final MBeanServer mbs0 = mbs; + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Void run() throws MBeanRegistrationException, + RuntimeOperationsException { + try { + mbs0.unregisterMBean(objName); + } catch (InstanceNotFoundException e) { + // ignore exception if not found + } + return null; + } + }); + } catch (PrivilegedActionException e) { + throw Util.newException(e.getException()); + } + } + + static void unregisterInternalMBeans(MBeanServer mbs) { + // unregister all internal MBeans + unregisterMBean(mbs, HOTSPOT_CLASS_LOADING_MBEAN_NAME); + unregisterMBean(mbs, HOTSPOT_MEMORY_MBEAN_NAME); + unregisterMBean(mbs, HOTSPOT_RUNTIME_MBEAN_NAME); + unregisterMBean(mbs, HOTSPOT_THREAD_MBEAN_NAME); + + // CompilationMBean may not exist + if (getCompilationMXBean() != null) { + unregisterMBean(mbs, HOTSPOT_COMPILATION_MBEAN_NAME); + } + } + + static { + AccessController.doPrivileged(new LoadLibraryAction("management")); + jvm = new VMManagementImpl(); + } + + public static boolean isThreadSuspended(int state) { + return ((state & JMM_THREAD_STATE_FLAG_SUSPENDED) != 0); + } + + public static boolean isThreadRunningNative(int state) { + return ((state & JMM_THREAD_STATE_FLAG_NATIVE) != 0); + } + + public static Thread.State toThreadState(int state) { + // suspended and native bits may be set in state + int threadStatus = state & ~JMM_THREAD_STATE_FLAG_MASK; + return sun.misc.VM.toThreadState(threadStatus); + } + + // These values are defined in jmm.h + private static final int JMM_THREAD_STATE_FLAG_MASK = 0xFFF00000; + private static final int JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000; + private static final int JMM_THREAD_STATE_FLAG_NATIVE = 0x00400000; + +} diff --git a/src/share/classes/sun/management/MappedMXBeanType.java b/src/share/classes/sun/management/MappedMXBeanType.java index 1d606fbb458cd698e20c4bb1fbf346bb1c7fa05b..84b13b8f3b021bd3e566270d93554238e4f2f4a4 100644 --- a/src/share/classes/sun/management/MappedMXBeanType.java +++ b/src/share/classes/sun/management/MappedMXBeanType.java @@ -735,14 +735,14 @@ public abstract class MappedMXBeanType { throws OpenDataException, InvalidObjectException { if (fromMethod == null) { - throw new InternalError("Does not support data conversion"); + throw new AssertionError("Does not support data conversion"); } try { return fromMethod.invoke(null, data); } catch (IllegalAccessException e) { // should never reach here - throw Util.newAssertionError(e); + throw new AssertionError(e); } catch (InvocationTargetException e) { final OpenDataException ode = new OpenDataException("Failed to invoke " + @@ -785,7 +785,7 @@ public abstract class MappedMXBeanType { t = new InProgress(); } catch (OpenDataException e) { // Should not reach here - throw Util.newAssertionError(e); + throw new AssertionError(e); } inProgress = t; } @@ -807,9 +807,9 @@ public abstract class MappedMXBeanType { } catch (ClassNotFoundException e) { // the classes that these predefined types declare // must exist! - throw Util.newAssertionError(e); + throw new AssertionError(e); } catch (OpenDataException e) { - throw Util.newAssertionError(e); + throw new AssertionError(e); } if (c.getName().startsWith("java.lang.")) { @@ -821,12 +821,12 @@ public abstract class MappedMXBeanType { // OK: must not be a primitive wrapper } catch (IllegalAccessException e) { // Should not reach here - throw Util.newAssertionError(e); + throw new AssertionError(e); } } } } catch (OpenDataException e) { - throw Util.newAssertionError(e); + throw new AssertionError(e); } } diff --git a/src/share/classes/sun/management/MemoryImpl.java b/src/share/classes/sun/management/MemoryImpl.java index 2e8fcf25944343b1819115d006d3068ab8f51c79..2d9f1d281ee5734c49a0b0fbcc0d58cc59a80a9d 100644 --- a/src/share/classes/sun/management/MemoryImpl.java +++ b/src/share/classes/sun/management/MemoryImpl.java @@ -25,13 +25,13 @@ package sun.management; +import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.MemoryUsage; import java.lang.management.MemoryNotificationInfo; import java.lang.management.MemoryManagerMXBean; import java.lang.management.MemoryPoolMXBean; import javax.management.ObjectName; -import javax.management.MalformedObjectNameException; import javax.management.MBeanNotificationInfo; import javax.management.Notification; import javax.management.NotificationEmitter; @@ -88,7 +88,7 @@ class MemoryImpl extends NotificationEmitterSupport } public void setVerbose(boolean value) { - ManagementFactory.checkControlAccess(); + Util.checkControlAccess(); setVerboseGC(value); } @@ -150,19 +150,6 @@ class MemoryImpl extends NotificationEmitterSupport return ++seqNumber; } - private static ObjectName objname = null; - private static synchronized ObjectName getObjectName() { - if (objname != null) return objname; - - try { - objname = new ObjectName(java.lang.management.ManagementFactory.MEMORY_MXBEAN_NAME); - } catch (MalformedObjectNameException e) { - // should never reach here - throw Util.newInternalError(e); - } - return objname; - } - static void createNotification(String notifType, String poolName, MemoryUsage usage, @@ -175,7 +162,7 @@ class MemoryImpl extends NotificationEmitterSupport long timestamp = System.currentTimeMillis(); String msg = getNotifMsg(notifType); Notification notif = new Notification(notifType, - getObjectName(), + mbean.getObjectName(), getNextSeqNumber(), timestamp, msg); @@ -189,4 +176,8 @@ class MemoryImpl extends NotificationEmitterSupport mbean.sendNotification(notif); } + public ObjectName getObjectName() { + return Util.newObjectName(ManagementFactory.MEMORY_MXBEAN_NAME); + } + } diff --git a/src/share/classes/sun/management/MemoryManagerImpl.java b/src/share/classes/sun/management/MemoryManagerImpl.java index a9dd0da80a8dbce34ece672af05afe2004a5318c..bcf713829d1ee745069ee64c743bc1958089431d 100644 --- a/src/share/classes/sun/management/MemoryManagerImpl.java +++ b/src/share/classes/sun/management/MemoryManagerImpl.java @@ -25,9 +25,12 @@ package sun.management; +import java.lang.management.ManagementFactory; import java.lang.management.MemoryManagerMXBean; import java.lang.management.MemoryPoolMXBean; +import javax.management.ObjectName; + /** * Implementation class for a memory manager. * Standard and committed hotspot-specific metrics if any. @@ -73,4 +76,8 @@ class MemoryManagerImpl implements MemoryManagerMXBean { } private native MemoryPoolMXBean[] getMemoryPools0(); + public ObjectName getObjectName() { + return Util.newObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE, getName()); + } + } diff --git a/src/share/classes/sun/management/MemoryNotifInfoCompositeData.java b/src/share/classes/sun/management/MemoryNotifInfoCompositeData.java index 4714a14fce305b1703a6c62a9ebe94e5c115e515..00d58fcded8d475147be08296b67ff76e6eef553 100644 --- a/src/share/classes/sun/management/MemoryNotifInfoCompositeData.java +++ b/src/share/classes/sun/management/MemoryNotifInfoCompositeData.java @@ -69,7 +69,7 @@ public class MemoryNotifInfoCompositeData extends LazyCompositeData { memoryNotifInfoItemValues); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } @@ -80,7 +80,7 @@ public class MemoryNotifInfoCompositeData extends LazyCompositeData { MappedMXBeanType.toOpenType(MemoryNotificationInfo.class); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } diff --git a/src/share/classes/sun/management/MemoryPoolImpl.java b/src/share/classes/sun/management/MemoryPoolImpl.java index 152b31d96c67612afbd7d2a543ec13a1745758f2..84abe93826e16e996aa528dd5ee4e09f3ea7f197 100644 --- a/src/share/classes/sun/management/MemoryPoolImpl.java +++ b/src/share/classes/sun/management/MemoryPoolImpl.java @@ -25,12 +25,13 @@ package sun.management; +import java.lang.management.ManagementFactory; import java.lang.management.MemoryPoolMXBean; - import java.lang.management.MemoryUsage; import java.lang.management.MemoryType; import java.lang.management.MemoryManagerMXBean; import javax.management.openmbean.CompositeData; +import javax.management.ObjectName; import static java.lang.management.MemoryNotificationInfo.*; @@ -114,7 +115,7 @@ class MemoryPoolImpl implements MemoryPoolMXBean { "Usage threshold is not supported"); } - ManagementFactory.checkControlAccess(); + Util.checkControlAccess(); MemoryUsage usage = getUsage0(); if (newThreshold < 0) { @@ -159,7 +160,7 @@ class MemoryPoolImpl implements MemoryPoolMXBean { } public void resetPeakUsage() { - ManagementFactory.checkControlAccess(); + Util.checkControlAccess(); synchronized (this) { // synchronized since getPeakUsage may be called concurrently @@ -211,7 +212,7 @@ class MemoryPoolImpl implements MemoryPoolMXBean { "CollectionUsage threshold is not supported"); } - ManagementFactory.checkControlAccess(); + Util.checkControlAccess(); MemoryUsage usage = getUsage0(); if (newThreshold < 0) { @@ -304,7 +305,7 @@ class MemoryPoolImpl implements MemoryPoolMXBean { } void triggerAction() { // Should not reach here - throw new InternalError(); + throw new AssertionError("Should not reach here"); } void clearAction() { // do nothing @@ -332,10 +333,15 @@ class MemoryPoolImpl implements MemoryPoolMXBean { } void triggerAction() { // Should not reach here - throw new InternalError(); + throw new AssertionError("Should not reach here"); } void clearAction() { // do nothing } } + + public ObjectName getObjectName() { + return Util.newObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE, getName()); + } + } diff --git a/src/share/classes/sun/management/MemoryUsageCompositeData.java b/src/share/classes/sun/management/MemoryUsageCompositeData.java index e827ccb79bcec4d0b6e11dfde767899f5c8e4464..aa6e281d46871288e8876674b8416fb0fdd9b4fa 100644 --- a/src/share/classes/sun/management/MemoryUsageCompositeData.java +++ b/src/share/classes/sun/management/MemoryUsageCompositeData.java @@ -68,7 +68,7 @@ public class MemoryUsageCompositeData extends LazyCompositeData { memoryUsageItemValues); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } @@ -79,7 +79,7 @@ public class MemoryUsageCompositeData extends LazyCompositeData { MappedMXBeanType.toOpenType(MemoryUsage.class); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } diff --git a/src/share/classes/sun/management/MonitorInfoCompositeData.java b/src/share/classes/sun/management/MonitorInfoCompositeData.java index 6c1fb1d771780747043ebe76de3543a51ef78cdd..cf82e29ec61568ce34c3a07fa259c999b1e231b1 100644 --- a/src/share/classes/sun/management/MonitorInfoCompositeData.java +++ b/src/share/classes/sun/management/MonitorInfoCompositeData.java @@ -81,7 +81,7 @@ public class MonitorInfoCompositeData extends LazyCompositeData { values); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } @@ -95,7 +95,7 @@ public class MonitorInfoCompositeData extends LazyCompositeData { monitorInfoItemNames = (String[]) s.toArray(new String[0]); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } diff --git a/src/share/classes/sun/management/NotificationEmitterSupport.java b/src/share/classes/sun/management/NotificationEmitterSupport.java index ee0d1a2a63075f6bfb9b35f34921b0531986d3ae..a48c3ef9e68b2cf7859c57c884c048929af9a131 100644 --- a/src/share/classes/sun/management/NotificationEmitterSupport.java +++ b/src/share/classes/sun/management/NotificationEmitterSupport.java @@ -156,7 +156,7 @@ abstract class NotificationEmitterSupport implements NotificationEmitter { li.listener.handleNotification(notification, li.handback); } catch (Exception e) { e.printStackTrace(); - throw new InternalError("Error in invoking listener"); + throw new AssertionError("Error in invoking listener"); } } } diff --git a/src/share/classes/sun/management/OperatingSystemImpl.java b/src/share/classes/sun/management/OperatingSystemImpl.java index 9a815f7206b144a912c0c8fe4826bc03717d88fa..3f1cc10f45617b034127601341d94eba656845c4 100644 --- a/src/share/classes/sun/management/OperatingSystemImpl.java +++ b/src/share/classes/sun/management/OperatingSystemImpl.java @@ -26,6 +26,8 @@ package sun.management; import java.lang.management.OperatingSystemMXBean; +import java.lang.management.ManagementFactory; +import javax.management.ObjectName; import sun.misc.Unsafe; /** @@ -71,4 +73,9 @@ public class OperatingSystemImpl implements OperatingSystemMXBean { return -1.0; } } + public ObjectName getObjectName() { + return Util.newObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME); + } + } + diff --git a/src/share/classes/sun/management/RuntimeImpl.java b/src/share/classes/sun/management/RuntimeImpl.java index fbf4e2afa970ff9a571d94fcda2bb360b000377f..6791069f38cd495f327725c41e77e4c9f433968a 100644 --- a/src/share/classes/sun/management/RuntimeImpl.java +++ b/src/share/classes/sun/management/RuntimeImpl.java @@ -26,6 +26,7 @@ package sun.management; import java.lang.management.RuntimeMXBean; +import java.lang.management.ManagementFactory; import java.util.List; import java.util.HashMap; @@ -38,6 +39,7 @@ import javax.management.openmbean.CompositeType; import javax.management.openmbean.OpenType; import javax.management.openmbean.SimpleType; import javax.management.openmbean.OpenDataException; +import javax.management.ObjectName; /** * Implementation class for the runtime subsystem. @@ -104,12 +106,12 @@ class RuntimeImpl implements RuntimeMXBean { throw new UnsupportedOperationException( "Boot class path mechanism is not supported"); } - ManagementFactory.checkMonitorAccess(); + Util.checkMonitorAccess(); return jvm.getBootClassPath(); } public List getInputArguments() { - ManagementFactory.checkMonitorAccess(); + Util.checkMonitorAccess(); return jvm.getVmArguments(); } @@ -145,4 +147,9 @@ class RuntimeImpl implements RuntimeMXBean { return map; } + + public ObjectName getObjectName() { + return Util.newObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME); + } + } diff --git a/src/share/classes/sun/management/StackTraceElementCompositeData.java b/src/share/classes/sun/management/StackTraceElementCompositeData.java index 30eab89e253d713052098734718736bcc18ecc90..13c3547eff9aa26d4e4a3c5b154953dec30fb346 100644 --- a/src/share/classes/sun/management/StackTraceElementCompositeData.java +++ b/src/share/classes/sun/management/StackTraceElementCompositeData.java @@ -76,7 +76,7 @@ public class StackTraceElementCompositeData extends LazyCompositeData { stackTraceElementItemValues); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } @@ -87,7 +87,7 @@ public class StackTraceElementCompositeData extends LazyCompositeData { MappedMXBeanType.toOpenType(StackTraceElement.class); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } diff --git a/src/share/classes/sun/management/ThreadImpl.java b/src/share/classes/sun/management/ThreadImpl.java index a62fe80a5f8529ed2ccb4649f64882a075be5baf..0e0057706746fa022c1326382477692c7cff5805 100644 --- a/src/share/classes/sun/management/ThreadImpl.java +++ b/src/share/classes/sun/management/ThreadImpl.java @@ -26,6 +26,7 @@ package sun.management; import java.lang.management.ThreadMXBean; +import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.lang.management.LockInfo; @@ -33,6 +34,8 @@ import java.lang.management.MonitorInfo; import java.util.Map; import java.util.HashMap; +import javax.management.ObjectName; + /** * Implementation class for the thread subsystem. * Standard and committed hotspot-specific metrics if any. @@ -102,7 +105,7 @@ class ThreadImpl implements ThreadMXBean { } public long[] getAllThreadIds() { - ManagementFactory.checkMonitorAccess(); + Util.checkMonitorAccess(); Thread[] threads = getThreads(); int length = threads.length; @@ -156,7 +159,7 @@ class ThreadImpl implements ThreadMXBean { "Invalid maxDepth parameter: " + maxDepth); } - ManagementFactory.checkMonitorAccess(); + Util.checkMonitorAccess(); ThreadInfo[] infos = new ThreadInfo[ids.length]; if (maxDepth == Integer.MAX_VALUE) { @@ -175,7 +178,7 @@ class ThreadImpl implements ThreadMXBean { "Thread contention monitoring is not supported"); } - ManagementFactory.checkControlAccess(); + Util.checkControlAccess(); synchronized (this) { if (contentionMonitoringEnabled != enable) { @@ -297,7 +300,7 @@ class ThreadImpl implements ThreadMXBean { "Thread CPU time measurement is not supported"); } - ManagementFactory.checkControlAccess(); + Util.checkControlAccess(); synchronized (this) { if (cpuTimeEnabled != enable) { // update VM of the state change @@ -308,7 +311,7 @@ class ThreadImpl implements ThreadMXBean { } public long[] findMonitorDeadlockedThreads() { - ManagementFactory.checkMonitorAccess(); + Util.checkMonitorAccess(); Thread[] threads = findMonitorDeadlockedThreads0(); if (threads == null) { @@ -329,7 +332,7 @@ class ThreadImpl implements ThreadMXBean { "Monitoring of Synchronizer Usage is not supported."); } - ManagementFactory.checkMonitorAccess(); + Util.checkMonitorAccess(); Thread[] threads = findDeadlockedThreads0(); if (threads == null) { @@ -345,7 +348,7 @@ class ThreadImpl implements ThreadMXBean { } public void resetPeakThreadCount() { - ManagementFactory.checkControlAccess(); + Util.checkControlAccess(); resetPeakThreadCount0(); } @@ -373,7 +376,7 @@ class ThreadImpl implements ThreadMXBean { "Monitoring of Synchronizer Usage is not supported."); } - ManagementFactory.checkMonitorAccess(); + Util.checkMonitorAccess(); return dumpThreads0(ids, lockedMonitors, lockedSynchronizers); } @@ -388,7 +391,7 @@ class ThreadImpl implements ThreadMXBean { "Monitoring of Synchronizer Usage is not supported."); } - ManagementFactory.checkMonitorAccess(); + Util.checkMonitorAccess(); return dumpThreads0(null, lockedMonitors, lockedSynchronizers); } @@ -410,4 +413,10 @@ class ThreadImpl implements ThreadMXBean { // tid == 0 to reset contention times for all threads private static native void resetContentionTimes0(long tid); + + public ObjectName getObjectName() { + return Util.newObjectName(ManagementFactory.THREAD_MXBEAN_NAME); + } + } + diff --git a/src/share/classes/sun/management/ThreadInfoCompositeData.java b/src/share/classes/sun/management/ThreadInfoCompositeData.java index 86b662245a843eede514472a8be9b6103b17c8df..ede8eabb585228a16b0a0a942f2e39100fe156cd 100644 --- a/src/share/classes/sun/management/ThreadInfoCompositeData.java +++ b/src/share/classes/sun/management/ThreadInfoCompositeData.java @@ -126,7 +126,7 @@ public class ThreadInfoCompositeData extends LazyCompositeData { threadInfoItemValues); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } @@ -209,7 +209,7 @@ public class ThreadInfoCompositeData extends LazyCompositeData { v5ItemTypes); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } // Each CompositeData object has its CompositeType associated diff --git a/src/share/classes/sun/management/Util.java b/src/share/classes/sun/management/Util.java index 43518df91fd062e00ca08b5dd3fd1fc2276e4fd6..80eea62953e14c6335fccdcc37a6ac85e805fa5d 100644 --- a/src/share/classes/sun/management/Util.java +++ b/src/share/classes/sun/management/Util.java @@ -26,48 +26,58 @@ package sun.management; import java.lang.management.*; -import static java.lang.management.ManagementFactory.*; import java.util.List; +import java.security.Permission; +import javax.management.ObjectName; +import javax.management.MalformedObjectNameException; + +import static java.lang.management.ManagementFactory.*; class Util { - static String getMBeanObjectName(MemoryPoolMXBean pool) { - return MEMORY_POOL_MXBEAN_DOMAIN_TYPE + - ",name=" + pool.getName(); + static RuntimeException newException(Exception e) { + throw new RuntimeException(e); } - static String getMBeanObjectName(MemoryManagerMXBean mgr) { - if (mgr instanceof GarbageCollectorMXBean) { - return getMBeanObjectName((GarbageCollectorMXBean) mgr); - } else { - return MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE + - ",name=" + mgr.getName(); - } + private static final String[] EMPTY_STRING_ARRAY = new String[0]; + static String[] toStringArray(List list) { + return (String[]) list.toArray(EMPTY_STRING_ARRAY); } - static String getMBeanObjectName(GarbageCollectorMXBean gc) { - return GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + - ",name=" + gc.getName(); + static ObjectName newObjectName(String name) { + return com.sun.jmx.mbeanserver.Util.newObjectName(name); } - static RuntimeException newException(Exception e) { - RuntimeException e1 = new RuntimeException(e.getMessage()); - e1.initCause(e); - return e1; + public static ObjectName newObjectName(String domainAndType, String name) { + return newObjectName(domainAndType + ",name=" + name); } - static InternalError newInternalError(Exception e) { - InternalError e1 = new InternalError(e.getMessage()); - e1.initCause(e); - return e1; - } - static AssertionError newAssertionError(Exception e) { - AssertionError e1 = new AssertionError(e.getMessage()); - e1.initCause(e); - return e1; + private static ManagementPermission monitorPermission = + new ManagementPermission("monitor"); + private static ManagementPermission controlPermission = + new ManagementPermission("control"); + + /** + * Check that the current context is trusted to perform monitoring + * or management. + *

        + * If the check fails we throw a SecurityException, otherwise + * we return normally. + * + * @exception SecurityException if a security manager exists and if + * the caller does not have ManagementPermission("control"). + */ + static void checkAccess(ManagementPermission p) + throws SecurityException { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(p); + } } - private static String[] EMPTY_STRING_ARRAY = new String[0]; - static String[] toStringArray(List list) { - return (String[]) list.toArray(EMPTY_STRING_ARRAY); + static void checkMonitorAccess() throws SecurityException { + checkAccess(monitorPermission); + } + static void checkControlAccess() throws SecurityException { + checkAccess(controlPermission); } } diff --git a/src/share/classes/sun/management/VMManagementImpl.java b/src/share/classes/sun/management/VMManagementImpl.java index ce2ab534b07af0e6150f0480f7ba79371ee370af..74ba9e2202c4feb7977bcec2bf76e919ea6574f5 100644 --- a/src/share/classes/sun/management/VMManagementImpl.java +++ b/src/share/classes/sun/management/VMManagementImpl.java @@ -59,7 +59,7 @@ class VMManagementImpl implements VMManagement { static { version = getVersion0(); if (version == null) { - throw new InternalError("Invalid Management Version"); + throw new AssertionError("Invalid Management Version"); } initOptionalSupportFields(); } @@ -244,7 +244,7 @@ class VMManagementImpl implements VMManagement { // was set noPerfData = true; } catch (IOException e) { - throw new InternalError(e.getMessage()); + throw new AssertionError(e); } return perfInstr; } diff --git a/src/share/classes/sun/management/VMOptionCompositeData.java b/src/share/classes/sun/management/VMOptionCompositeData.java index 15921a888bc573fa505d93d04bbfbde84e42e1ee..2639060d569fa24eccf1e605bdf5ef47786ae497 100644 --- a/src/share/classes/sun/management/VMOptionCompositeData.java +++ b/src/share/classes/sun/management/VMOptionCompositeData.java @@ -69,7 +69,7 @@ public class VMOptionCompositeData extends LazyCompositeData { vmOptionItemValues); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } @@ -80,7 +80,7 @@ public class VMOptionCompositeData extends LazyCompositeData { MappedMXBeanType.toOpenType(VMOption.class); } catch (OpenDataException e) { // Should never reach here - throw Util.newInternalError(e); + throw new AssertionError(e); } } diff --git a/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java b/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java index 0463db83f89002edeb7369ab1d8e2f9dda00ad5c..43cae9144e9b1077995a854f6c2bc45c67613ec7 100644 --- a/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java +++ b/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -39,6 +39,7 @@ import java.rmi.NoSuchObjectException; import java.rmi.Remote; import java.rmi.RemoteException; import java.rmi.registry.Registry; +import java.rmi.server.RemoteObject; import java.rmi.server.RMIClientSocketFactory; import java.rmi.server.RMIServerSocketFactory; import java.rmi.server.UnicastRemoteObject; @@ -70,12 +71,14 @@ import javax.rmi.ssl.SslRMIServerSocketFactory; import javax.security.auth.Subject; +import sun.rmi.server.UnicastRef; import sun.rmi.server.UnicastServerRef; import sun.rmi.server.UnicastServerRef2; import sun.management.Agent; import sun.management.AgentConfigurationError; import static sun.management.AgentConfigurationError.*; +import sun.management.ConnectorAddressLink; import sun.management.FileSystem; import sun.management.snmp.util.MibLogger; @@ -92,20 +95,22 @@ public final class ConnectorBootstrap { * Default values for JMX configuration properties. **/ public static interface DefaultValues { - public static final String PORT="0"; - public static final String CONFIG_FILE_NAME="management.properties"; - public static final String USE_SSL="true"; - public static final String USE_REGISTRY_SSL="false"; - public static final String USE_AUTHENTICATION="true"; - public static final String PASSWORD_FILE_NAME="jmxremote.password"; - public static final String ACCESS_FILE_NAME="jmxremote.access"; - public static final String SSL_NEED_CLIENT_AUTH="false"; + + public static final String PORT = "0"; + public static final String CONFIG_FILE_NAME = "management.properties"; + public static final String USE_SSL = "true"; + public static final String USE_REGISTRY_SSL = "false"; + public static final String USE_AUTHENTICATION = "true"; + public static final String PASSWORD_FILE_NAME = "jmxremote.password"; + public static final String ACCESS_FILE_NAME = "jmxremote.access"; + public static final String SSL_NEED_CLIENT_AUTH = "false"; } /** * Names of JMX configuration properties. **/ public static interface PropertyNames { + public static final String PORT = "com.sun.management.jmxremote.port"; public static final String CONFIG_FILE_NAME = @@ -132,6 +137,21 @@ public final class ConnectorBootstrap { "com.sun.management.jmxremote.ssl.config.file"; } + /** + * JMXConnectorServer associated data. + */ + private static class JMXConnectorServerData { + + public JMXConnectorServerData( + JMXConnectorServer jmxConnectorServer, + JMXServiceURL jmxRemoteURL) { + this.jmxConnectorServer = jmxConnectorServer; + this.jmxRemoteURL = jmxRemoteURL; + } + JMXConnectorServer jmxConnectorServer; + JMXServiceURL jmxRemoteURL; + } + /** *

        Prevents our RMI server objects from keeping the JVM alive.

        * @@ -151,6 +171,7 @@ public final class ConnectorBootstrap { * works). Hence the somewhat misleading name of this class.

        */ private static class PermanentExporter implements RMIExporter { + public Remote exportObject(Remote obj, int port, RMIClientSocketFactory csf, @@ -158,24 +179,25 @@ public final class ConnectorBootstrap { throws RemoteException { synchronized (this) { - if (firstExported == null) + if (firstExported == null) { firstExported = obj; + } } final UnicastServerRef ref; - if (csf == null && ssf == null) + if (csf == null && ssf == null) { ref = new UnicastServerRef(port); - else + } else { ref = new UnicastServerRef2(port, csf, ssf); + } return ref.exportObject(obj, null, true); } // Nothing special to be done for this case public boolean unexportObject(Remote obj, boolean force) - throws NoSuchObjectException { + throws NoSuchObjectException { return UnicastRemoteObject.unexportObject(obj, force); } - Remote firstExported; } @@ -202,19 +224,21 @@ public final class ConnectorBootstrap { } private void checkAccessFileEntries(Subject subject) { - if (subject == null) + if (subject == null) { throw new SecurityException( "Access denied! No matching entries found in " + "the access file [" + accessFile + "] as the " + "authenticated Subject is null"); + } final Set principals = subject.getPrincipals(); - for (Iterator i = principals.iterator(); i.hasNext(); ) { + for (Iterator i = principals.iterator(); i.hasNext();) { final Principal p = (Principal) i.next(); - if (properties.containsKey(p.getName())) + if (properties.containsKey(p.getName())) { return; + } } final Set principalsStr = new HashSet(); - for (Iterator i = principals.iterator(); i.hasNext(); ) { + for (Iterator i = principals.iterator(); i.hasNext();) { final Principal p = (Principal) i.next(); principalsStr.add(p.getName()); } @@ -225,16 +249,16 @@ public final class ConnectorBootstrap { } private static Properties propertiesFromFile(String fname) - throws IOException { + throws IOException { Properties p = new Properties(); - if (fname == null) + if (fname == null) { return p; + } FileInputStream fin = new FileInputStream(fname); p.load(fin); fin.close(); return p; } - private final Map environment; private final Properties properties; private final String accessFile; @@ -251,22 +275,23 @@ public final class ConnectorBootstrap { // Load a new management properties final Properties props = Agent.loadManagementProperties(); - if (props == null) return null; + if (props == null) { + return null; + } final String portStr = props.getProperty(PropertyNames.PORT); // System.out.println("initializing: {port=" + portStr + ", // properties="+props+"}"); - return initialize(portStr,props); + return initialize(portStr, props); } /** * Initializes and starts a JMX Connector Server for remote * monitoring and management. **/ - public static synchronized - JMXConnectorServer initialize(String portStr, Properties props) { + public static synchronized JMXConnectorServer initialize(String portStr, Properties props) { // Get port number final int port; @@ -280,21 +305,21 @@ public final class ConnectorBootstrap { } // Do we use authentication? - final String useAuthenticationStr = + final String useAuthenticationStr = props.getProperty(PropertyNames.USE_AUTHENTICATION, DefaultValues.USE_AUTHENTICATION); final boolean useAuthentication = Boolean.valueOf(useAuthenticationStr).booleanValue(); // Do we use SSL? - final String useSslStr = + final String useSslStr = props.getProperty(PropertyNames.USE_SSL, DefaultValues.USE_SSL); final boolean useSsl = Boolean.valueOf(useSslStr).booleanValue(); // Do we use RMI Registry SSL? - final String useRegistrySslStr = + final String useRegistrySslStr = props.getProperty(PropertyNames.USE_REGISTRY_SSL, DefaultValues.USE_REGISTRY_SSL); final boolean useRegistrySsl = @@ -307,7 +332,7 @@ public final class ConnectorBootstrap { StringTokenizer st = new StringTokenizer(enabledCipherSuites, ","); int tokens = st.countTokens(); enabledCipherSuitesList = new String[tokens]; - for (int i = 0 ; i < tokens; i++) { + for (int i = 0; i < tokens; i++) { enabledCipherSuitesList[i] = st.nextToken(); } } @@ -319,12 +344,12 @@ public final class ConnectorBootstrap { StringTokenizer st = new StringTokenizer(enabledProtocols, ","); int tokens = st.countTokens(); enabledProtocolsList = new String[tokens]; - for (int i = 0 ; i < tokens; i++) { + for (int i = 0; i < tokens; i++) { enabledProtocolsList[i] = st.nextToken(); } } - final String sslNeedClientAuthStr = + final String sslNeedClientAuthStr = props.getProperty(PropertyNames.SSL_NEED_CLIENT_AUTH, DefaultValues.SSL_NEED_CLIENT_AUTH); final boolean sslNeedClientAuth = @@ -374,39 +399,49 @@ public final class ConnectorBootstrap { sslNeedClientAuth + "\n\t" + PropertyNames.USE_AUTHENTICATION + "=" + useAuthentication + - (useAuthentication ? - (loginConfigName == null ? - ("\n\t" + PropertyNames.PASSWORD_FILE_NAME + "=" + - passwordFileName) : - ("\n\t" + PropertyNames.LOGIN_CONFIG_NAME + "=" + + (useAuthentication ? (loginConfigName == null ? ("\n\t" + PropertyNames.PASSWORD_FILE_NAME + "=" + + passwordFileName) : ("\n\t" + PropertyNames.LOGIN_CONFIG_NAME + "=" + loginConfigName)) : "\n\t" + Agent.getText("jmxremote.ConnectorBootstrap.initialize.noAuthentication")) + - (useAuthentication ? - ("\n\t" + PropertyNames.ACCESS_FILE_NAME + "=" + + (useAuthentication ? ("\n\t" + PropertyNames.ACCESS_FILE_NAME + "=" + accessFileName) : "") + ""); } final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); JMXConnectorServer cs = null; + JMXServiceURL url = null; try { - cs = exportMBeanServer(mbs, port, useSsl, useRegistrySsl, + final JMXConnectorServerData data = exportMBeanServer( + mbs, port, useSsl, useRegistrySsl, sslConfigFileName, enabledCipherSuitesList, enabledProtocolsList, sslNeedClientAuth, useAuthentication, loginConfigName, passwordFileName, accessFileName); - - final JMXServiceURL url = cs.getAddress(); + cs = data.jmxConnectorServer; + url = data.jmxRemoteURL; log.config("initialize", Agent.getText("jmxremote.ConnectorBootstrap.initialize.ready", - new JMXServiceURL(url.getProtocol(), - url.getHost(), - url.getPort(), - "/jndi/rmi://"+url.getHost()+":"+port+"/"+ - "jmxrmi").toString())); + url.toString())); } catch (Exception e) { throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString()); } + try { + // Export remote connector address and associated configuration + // properties to the instrumentation buffer. + Map properties = new HashMap(); + properties.put("remoteAddress", url.toString()); + properties.put("authenticate", useAuthenticationStr); + properties.put("ssl", useSslStr); + properties.put("sslRegistry", useRegistrySslStr); + properties.put("sslNeedClientAuth", sslNeedClientAuthStr); + ConnectorAddressLink.exportRemote(properties); + } catch (Exception e) { + // Remote connector server started but unable to export remote + // connector address and associated configuration properties to + // the instrumentation buffer - non-fatal error. + log.debug("initialize", e); + } return cs; } @@ -452,7 +487,7 @@ public final class ConnectorBootstrap { } private static void checkPasswordFile(String passwordFileName) { - if (passwordFileName == null || passwordFileName.length()==0) { + if (passwordFileName == null || passwordFileName.length() == 0) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_SET); } File file = new File(passwordFileName); @@ -468,9 +503,9 @@ public final class ConnectorBootstrap { try { if (fs.supportsFileSecurity(file)) { if (!fs.isAccessUserOnly(file)) { - final String msg=Agent.getText("jmxremote.ConnectorBootstrap.initialize.password.readonly", + final String msg = Agent.getText("jmxremote.ConnectorBootstrap.initialize.password.readonly", passwordFileName); - log.config("initialize",msg); + log.config("initialize", msg); throw new AgentConfigurationError(PASSWORD_FILE_ACCESS_NOT_RESTRICTED, passwordFileName); } @@ -482,7 +517,7 @@ public final class ConnectorBootstrap { } private static void checkAccessFile(String accessFileName) { - if (accessFileName == null || accessFileName.length()==0) { + if (accessFileName == null || accessFileName.length() == 0) { throw new AgentConfigurationError(ACCESS_FILE_NOT_SET); } File file = new File(accessFileName); @@ -619,7 +654,7 @@ public final class ConnectorBootstrap { } } - private static JMXConnectorServer exportMBeanServer( + private static JMXConnectorServerData exportMBeanServer( MBeanServer mbs, int port, boolean useSsl, @@ -697,24 +732,30 @@ public final class ConnectorBootstrap { } final Registry registry; - if (useRegistrySsl) + if (useRegistrySsl) { registry = new SingleEntryRegistry(port, csf, ssf, "jmxrmi", exporter.firstExported); - else + } else { registry = new SingleEntryRegistry(port, "jmxrmi", exporter.firstExported); + } + + JMXServiceURL remoteURL = new JMXServiceURL( + "service:jmx:rmi:///jndi/rmi://" + url.getHost() + ":" + + ((UnicastRef) ((RemoteObject) registry).getRef()).getLiveRef().getPort() + + "/jmxrmi"); /* Our exporter remembers the first object it was asked to - export, which will be an RMIServerImpl appropriate for - publication in our special registry. We could - alternatively have constructed the RMIServerImpl explicitly - and then constructed an RMIConnectorServer passing it as a - parameter, but that's quite a bit more verbose and pulls in - lots of knowledge of the RMI connector. */ - - return connServer; + export, which will be an RMIServerImpl appropriate for + publication in our special registry. We could + alternatively have constructed the RMIServerImpl explicitly + and then constructed an RMIConnectorServer passing it as a + parameter, but that's quite a bit more verbose and pulls in + lots of knowledge of the RMI connector. */ + + return new JMXConnectorServerData(connServer, remoteURL); } /** @@ -726,5 +767,4 @@ public final class ConnectorBootstrap { // XXX Revisit: should probably clone this MibLogger.... private static final MibLogger log = new MibLogger(ConnectorBootstrap.class); - } diff --git a/src/share/classes/sun/management/snmp/jvminstr/JvmMemPoolEntryImpl.java b/src/share/classes/sun/management/snmp/jvminstr/JvmMemPoolEntryImpl.java index 156813969f9a06ad1f910cd19505c5973dba4f37..0863148f916086ed63a7bed939509313b9b50c68 100644 --- a/src/share/classes/sun/management/snmp/jvminstr/JvmMemPoolEntryImpl.java +++ b/src/share/classes/sun/management/snmp/jvminstr/JvmMemPoolEntryImpl.java @@ -26,7 +26,6 @@ package sun.management.snmp.jvminstr; // java imports // -import java.io.Serializable; import java.util.Map; // jmx imports @@ -36,9 +35,7 @@ import com.sun.jmx.snmp.SnmpDefinitions; // jdmk imports // -import com.sun.jmx.snmp.agent.SnmpMib; -import java.lang.management.ManagementFactory; import java.lang.management.MemoryUsage; import java.lang.management.MemoryType; import java.lang.management.MemoryPoolMXBean; @@ -73,7 +70,9 @@ public class JvmMemPoolEntryImpl implements JvmMemPoolEntryMBean { "jvmMemPoolEntry.getCollectionUsage"; final static MemoryUsage ZEROS = new MemoryUsage(0,0,0,0); - + final String entryMemoryTag; + final String entryPeakMemoryTag; + final String entryCollectMemoryTag; MemoryUsage getMemoryUsage() { try { @@ -81,17 +80,17 @@ public class JvmMemPoolEntryImpl implements JvmMemPoolEntryMBean { if (m != null) { final MemoryUsage cached = (MemoryUsage) - m.get(memoryTag); + m.get(entryMemoryTag); if (cached != null) { - log.debug("getMemoryUsage", - "jvmMemPoolEntry.getUsage found in cache."); + log.debug("getMemoryUsage",entryMemoryTag+ + " found in cache."); return cached; } MemoryUsage u = pool.getUsage(); if (u == null) u = ZEROS; - m.put(memoryTag,u); + m.put(entryMemoryTag,u); return u; } // Should never come here. @@ -113,18 +112,18 @@ public class JvmMemPoolEntryImpl implements JvmMemPoolEntryMBean { if (m != null) { final MemoryUsage cached = (MemoryUsage) - m.get(peakMemoryTag); + m.get(entryPeakMemoryTag); if (cached != null) { if (log.isDebugOn()) log.debug("getPeakMemoryUsage", - peakMemoryTag + " found in cache."); + entryPeakMemoryTag + " found in cache."); return cached; } MemoryUsage u = pool.getPeakUsage(); if (u == null) u = ZEROS; - m.put(peakMemoryTag,u); + m.put(entryPeakMemoryTag,u); return u; } // Should never come here. @@ -146,18 +145,18 @@ public class JvmMemPoolEntryImpl implements JvmMemPoolEntryMBean { if (m != null) { final MemoryUsage cached = (MemoryUsage) - m.get(collectMemoryTag); + m.get(entryCollectMemoryTag); if (cached != null) { if (log.isDebugOn()) log.debug("getCollectMemoryUsage", - collectMemoryTag + " found in cache."); + entryCollectMemoryTag + " found in cache."); return cached; } MemoryUsage u = pool.getCollectionUsage(); if (u == null) u = ZEROS; - m.put(collectMemoryTag,u); + m.put(entryCollectMemoryTag,u); return u; } // Should never come here. @@ -179,9 +178,12 @@ public class JvmMemPoolEntryImpl implements JvmMemPoolEntryMBean { /** * Constructor for the "JvmMemPoolEntry" group. */ - public JvmMemPoolEntryImpl(MemoryPoolMXBean mp, int index) { + public JvmMemPoolEntryImpl(MemoryPoolMXBean mp, final int index) { this.pool=mp; this.jvmMemPoolIndex = index; + this.entryMemoryTag = memoryTag + "." + index; + this.entryPeakMemoryTag = peakMemoryTag + "." + index; + this.entryCollectMemoryTag = collectMemoryTag + "." + index; } /** diff --git a/src/share/classes/sun/misc/ClassFileTransformer.java b/src/share/classes/sun/misc/ClassFileTransformer.java index a0d2c84ed6f3d17af6c6facaa3ee60580c69d0f0..1d05f71cc8a649113d32af1f6432b8e184aee532 100644 --- a/src/share/classes/sun/misc/ClassFileTransformer.java +++ b/src/share/classes/sun/misc/ClassFileTransformer.java @@ -46,8 +46,10 @@ public abstract class ClassFileTransformer { // Singleton of ClassFileTransformer // - private static ArrayList transformerList = new ArrayList(); - private static Object[] transformers = new Object[0]; + private static ArrayList transformerList + = new ArrayList(); + private static ClassFileTransformer[] transformers + = new ClassFileTransformer[0]; /** * Add the class file transformer object. @@ -59,7 +61,7 @@ public abstract class ClassFileTransformer synchronized(transformerList) { transformerList.add(t); - transformers = transformerList.toArray(); + transformers = transformerList.toArray(new ClassFileTransformer[0]); } } @@ -68,7 +70,7 @@ public abstract class ClassFileTransformer * * @return ClassFileTransformer object array */ - public static Object[] getTransformers() + public static ClassFileTransformer[] getTransformers() { // transformers is not intended to be changed frequently, // so it is okay to not put synchronized block here diff --git a/src/share/classes/sun/misc/Cleaner.java b/src/share/classes/sun/misc/Cleaner.java index c6cd63697b41c866a9f1911aaa1b7262a464ee00..036b6c94cd0d4d24d7eafc902838edbd1eeacfef 100644 --- a/src/share/classes/sun/misc/Cleaner.java +++ b/src/share/classes/sun/misc/Cleaner.java @@ -141,8 +141,8 @@ public class Cleaner try { thunk.run(); } catch (final Throwable x) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { if (System.err != null) new Error("Cleaner terminated abnormally", x) .printStackTrace(); diff --git a/src/share/classes/sun/misc/ExtensionDependency.java b/src/share/classes/sun/misc/ExtensionDependency.java index ce2df19f3eabc17b30c8b96eaad7e3977d6cf3da..67012641e6278f542bf377112bcebe30e5fc2cab 100644 --- a/src/share/classes/sun/misc/ExtensionDependency.java +++ b/src/share/classes/sun/misc/ExtensionDependency.java @@ -284,10 +284,9 @@ public class ExtensionDependency { // Load the jar file ... Manifest man; try { - man = (Manifest) AccessController.doPrivileged - ( - new PrivilegedExceptionAction() { - public Object run() + man = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Manifest run() throws IOException, FileNotFoundException { if (!file.exists()) throw new FileNotFoundException(file.getName()); @@ -391,9 +390,9 @@ public class ExtensionDependency { final String extName = extensionName; final String[] fileExt = {".jar", ".zip"}; - return (File) AccessController.doPrivileged - (new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged( + new PrivilegedAction() { + public File run() { try { File fExtension; File[] dirs = getExtDirs(); @@ -460,7 +459,7 @@ public class ExtensionDependency { * @return the list of files installed in all the directories */ private static File[] getExtFiles(File[] dirs) throws IOException { - Vector urls = new Vector(); + Vector urls = new Vector(); for (int i = 0; i < dirs.length; i++) { String[] files = dirs[i].list(new JarFilter()); if (files != null) { @@ -484,16 +483,15 @@ public class ExtensionDependency { *

        */ private File[] getInstalledExtensions() throws IOException { - return (File[]) AccessController.doPrivileged - ( - new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged( + new PrivilegedAction() { + public File[] run() { try { return getExtFiles(getExtDirs()); } catch(IOException e) { debug("Cannot get list of installed extensions"); debugException(e); - return new URL[0]; + return new File[0]; } } }); diff --git a/src/share/classes/sun/misc/GC.java b/src/share/classes/sun/misc/GC.java index b3fd3f97712b4f466a8e7a478de2a66f5e2818a6..477b5ffad915c45c2d478b6a21da3a0bc881d1b7 100644 --- a/src/share/classes/sun/misc/GC.java +++ b/src/share/classes/sun/misc/GC.java @@ -128,8 +128,8 @@ public class GC { /* Create a new daemon thread in the root thread group */ public static void create() { - PrivilegedAction pa = new PrivilegedAction() { - public Object run() { + PrivilegedAction pa = new PrivilegedAction() { + public Void run() { ThreadGroup tg = Thread.currentThread().getThreadGroup(); for (ThreadGroup tgn = tg; tgn != null; @@ -170,13 +170,14 @@ public class GC { * method. Given a request, the only interesting operation is that of * cancellation. */ - public static class LatencyRequest implements Comparable { + public static class LatencyRequest + implements Comparable { /* Instance counter, used to generate unique identifers */ private static long counter = 0; /* Sorted set of active latency requests */ - private static SortedSet requests = null; + private static SortedSet requests = null; /* Examine the request set and reset the latency target if necessary. * Must be invoked while holding the lock. @@ -187,7 +188,7 @@ public class GC { setLatencyTarget(NO_TARGET); } } else { - LatencyRequest r = (LatencyRequest)requests.first(); + LatencyRequest r = requests.first(); if (r.latency != latencyTarget) { setLatencyTarget(r.latency); } @@ -211,7 +212,7 @@ public class GC { synchronized (lock) { this.id = ++counter; if (requests == null) { - requests = new TreeSet(); + requests = new TreeSet(); } requests.add(this); adjustLatencyIfNeeded(); @@ -240,8 +241,7 @@ public class GC { } } - public int compareTo(Object o) { - LatencyRequest r = (LatencyRequest)o; + public int compareTo(LatencyRequest r) { long d = this.latency - r.latency; if (d == 0) d = this.id - r.id; return (d < 0) ? -1 : ((d > 0) ? +1 : 0); diff --git a/src/share/classes/sun/misc/JavaIOFileDescriptorAccess.java b/src/share/classes/sun/misc/JavaIOFileDescriptorAccess.java index 874145c629019e32099f476b7b9f49f30fe67cdb..42f3ea1ae6627cbd815f99242bdedadfd76202e7 100644 --- a/src/share/classes/sun/misc/JavaIOFileDescriptorAccess.java +++ b/src/share/classes/sun/misc/JavaIOFileDescriptorAccess.java @@ -33,4 +33,8 @@ import java.io.FileDescriptor; public interface JavaIOFileDescriptorAccess { public void set(FileDescriptor obj, int fd); public int get(FileDescriptor fd); + + // Only valid on Windows + public void setHandle(FileDescriptor obj, long handle); + public long getHandle(FileDescriptor obj); } diff --git a/src/share/classes/sun/misc/Launcher.java b/src/share/classes/sun/misc/Launcher.java index fca6609043372757bd2648bf77cdc53bfbb6c9f3..26f84d6281973d1a4790217e7847f72127cb2b81 100644 --- a/src/share/classes/sun/misc/Launcher.java +++ b/src/share/classes/sun/misc/Launcher.java @@ -135,9 +135,9 @@ public class Launcher { // aa synthesized ACC via a call to the private method // ExtClassLoader.getContext(). - return (ExtClassLoader) AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Object run() throws IOException { + return AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public ExtClassLoader run() throws IOException { int len = dirs.length; for (int i = 0; i < len; i++) { MetaIndex.registerDirectory(dirs[i]); @@ -180,7 +180,7 @@ public class Launcher { } private static URL[] getExtURLs(File[] dirs) throws IOException { - Vector urls = new Vector(); + Vector urls = new Vector(); for (int i = 0; i < dirs.length; i++) { String[] files = dirs[i].list(); if (files != null) { @@ -261,9 +261,9 @@ public class Launcher { // when loading classes. Specifically it prevent // accessClassInPackage.sun.* grants from being honored. // - return (AppClassLoader) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged( + new PrivilegedAction() { + public AppClassLoader run() { URL[] urls = (s == null) ? new URL[0] : pathToURLs(path); return new AppClassLoader(urls, extcl); @@ -348,12 +348,12 @@ public class Launcher { URL[] urls; if (prop != null) { final String path = prop; - urls = (URL[])AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + urls = AccessController.doPrivileged( + new PrivilegedAction() { + public URL[] run() { File[] classPath = getClassPath(path); int len = classPath.length; - Set seenDirs = new HashSet(); + Set seenDirs = new HashSet(); for (int i = 0; i < len; i++) { File curEntry = classPath[i]; // Negative test used to properly handle @@ -509,8 +509,8 @@ class PathPermissions extends PermissionCollection { perms.add(new java.util.PropertyPermission("java.*", SecurityConstants.PROPERTY_READ_ACTION)); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { for (int i=0; i < path.length; i++) { File f = path[i]; String path; @@ -553,7 +553,7 @@ class PathPermissions extends PermissionCollection { return perms.implies(permission); } - public java.util.Enumeration elements() { + public java.util.Enumeration elements() { if (perms == null) init(); synchronized (perms) { diff --git a/src/share/classes/sun/misc/PerformanceLogger.java b/src/share/classes/sun/misc/PerformanceLogger.java index 5f1218453885312f9ededf8c13147f16f7e3fb53..e23a0f1abb40a30268a4f7c05cde4eaa77718610 100644 --- a/src/share/classes/sun/misc/PerformanceLogger.java +++ b/src/share/classes/sun/misc/PerformanceLogger.java @@ -78,7 +78,7 @@ public class PerformanceLogger { private static boolean perfLoggingOn = false; private static boolean useNanoTime = false; - private static Vector times; + private static Vector times; private static String logFileName = null; private static Writer logWriter = null; @@ -104,8 +104,8 @@ public class PerformanceLogger { if (logFileName != null) { if (logWriter == null) { java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { try { File logFile = new File(logFileName); logFile.createNewFile(); @@ -124,7 +124,7 @@ public class PerformanceLogger { logWriter = new OutputStreamWriter(System.out); } } - times = new Vector(10); + times = new Vector(10); // Reserve predefined slots for (int i = 0; i <= LAST_RESERVED; ++i) { times.add(new TimeData("Time " + i + " not set", 0)); @@ -207,7 +207,7 @@ public class PerformanceLogger { */ public static long getStartTime() { if (loggingEnabled()) { - return ((TimeData)times.get(START_INDEX)).getTime(); + return times.get(START_INDEX).getTime(); } else { return 0; } @@ -253,7 +253,7 @@ public class PerformanceLogger { */ public static long getTimeAtIndex(int index) { if (loggingEnabled()) { - return ((TimeData)times.get(index)).getTime(); + return times.get(index).getTime(); } else { return 0; } @@ -264,7 +264,7 @@ public class PerformanceLogger { */ public static String getMessageAtIndex(int index) { if (loggingEnabled()) { - return ((TimeData)times.get(index)).getMessage(); + return times.get(index).getMessage(); } else { return null; } @@ -278,7 +278,7 @@ public class PerformanceLogger { try { synchronized(times) { for (int i = 0; i < times.size(); ++i) { - TimeData td = (TimeData)times.get(i); + TimeData td = times.get(i); if (td != null) { writer.write(i + " " + td.getMessage() + ": " + td.getTime() + "\n"); diff --git a/src/share/classes/sun/misc/ProxyGenerator.java b/src/share/classes/sun/misc/ProxyGenerator.java index 42350461eca7eba8383a243a7a6bb4c90304af7a..d25a87c1b4a33dc4210def1bd3a8740cfaae872d 100644 --- a/src/share/classes/sun/misc/ProxyGenerator.java +++ b/src/share/classes/sun/misc/ProxyGenerator.java @@ -324,8 +324,8 @@ public class ProxyGenerator { if (saveGeneratedFiles) { java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { try { FileOutputStream file = new FileOutputStream(dotToSlash(name) + ".class"); @@ -576,7 +576,7 @@ public class ProxyGenerator { * compatibly with the throws clauses of both * overridden methods. */ - List legalExceptions = new ArrayList(); + List> legalExceptions = new ArrayList>(); collectCompatibleTypes( exceptionTypes, pm.exceptionTypes, legalExceptions); collectCompatibleTypes( @@ -618,11 +618,11 @@ public class ProxyGenerator { * List of return types that are not yet known to be * assignable from ("covered" by) any of the others. */ - LinkedList uncoveredReturnTypes = new LinkedList(); + LinkedList> uncoveredReturnTypes = new LinkedList>(); nextNewReturnType: for (ProxyMethod pm : methods) { - Class newReturnType = pm.returnType; + Class newReturnType = pm.returnType; if (newReturnType.isPrimitive()) { throw new IllegalArgumentException( "methods with same signature " + @@ -637,9 +637,9 @@ public class ProxyGenerator { * Compare the new return type to the existing uncovered * return types. */ - ListIterator liter = uncoveredReturnTypes.listIterator(); + ListIterator> liter = uncoveredReturnTypes.listIterator(); while (liter.hasNext()) { - Class uncoveredReturnType = liter.next(); + Class uncoveredReturnType = liter.next(); /* * If an existing uncovered return type is assignable @@ -944,10 +944,10 @@ public class ProxyGenerator { tryEnd = pc = (short) minfo.code.size(); - List catchList = computeUniqueCatchList(exceptionTypes); + List> catchList = computeUniqueCatchList(exceptionTypes); if (catchList.size() > 0) { - for (Class ex : catchList) { + for (Class ex : catchList) { minfo.exceptionTable.add(new ExceptionTableEntry( tryBegin, tryEnd, pc, cp.getClass(dotToSlash(ex.getName())))); @@ -1521,8 +1521,9 @@ public class ProxyGenerator { * declared exceptions from duplicate methods inherited from * different interfaces. */ - private static void collectCompatibleTypes(Class[] from, Class[] with, - List list) + private static void collectCompatibleTypes(Class[] from, + Class[] with, + List> list) { for (int i = 0; i < from.length; i++) { if (!list.contains(from[i])) { @@ -1557,8 +1558,8 @@ public class ProxyGenerator { * given list of declared exceptions, indicating that no exceptions * need to be caught. */ - private static List computeUniqueCatchList(Class[] exceptions) { - List uniqueList = new ArrayList(); + private static List> computeUniqueCatchList(Class[] exceptions) { + List> uniqueList = new ArrayList>(); // unique exceptions to catch uniqueList.add(Error.class); // always catch/rethrow these @@ -1566,7 +1567,7 @@ public class ProxyGenerator { nextException: for (int i = 0; i < exceptions.length; i++) { - Class ex = exceptions[i]; + Class ex = exceptions[i]; if (ex.isAssignableFrom(Throwable.class)) { /* * If Throwable is declared to be thrown by the proxy method, @@ -1586,7 +1587,7 @@ public class ProxyGenerator { * exceptions that need to be caught: */ for (int j = 0; j < uniqueList.size();) { - Class ex2 = uniqueList.get(j); + Class ex2 = uniqueList.get(j); if (ex2.isAssignableFrom(ex)) { /* * if a superclass of this exception is already on diff --git a/src/share/classes/sun/misc/URLClassPath.java b/src/share/classes/sun/misc/URLClassPath.java index 3aefe401db8577d82584d462f269167d902f1d82..b3bd6d38a9e9736218a63e0a9bcbf200688f6ea3 100644 --- a/src/share/classes/sun/misc/URLClassPath.java +++ b/src/share/classes/sun/misc/URLClassPath.java @@ -86,16 +86,16 @@ public class URLClassPath { } /* The original search path of URLs. */ - private ArrayList path = new ArrayList(); + private ArrayList path = new ArrayList(); /* The stack of unopened URLs */ - Stack urls = new Stack(); + Stack urls = new Stack(); /* The resulting search path of Loaders */ - ArrayList loaders = new ArrayList(); + ArrayList loaders = new ArrayList(); /* Map of each URL opened to its corresponding Loader */ - HashMap lmap = new HashMap(); + HashMap lmap = new HashMap(); /* The jar protocol handler to use when creating new URLs */ private URLStreamHandler jarHandler; @@ -146,7 +146,7 @@ public class URLClassPath { */ public URL[] getURLs() { synchronized (urls) { - return (URL[])path.toArray(new URL[path.size()]); + return path.toArray(new URL[path.size()]); } } @@ -200,9 +200,9 @@ public class URLClassPath { * @param name the resource name * @return an Enumeration of all the urls having the specified name */ - public Enumeration findResources(final String name, + public Enumeration findResources(final String name, final boolean check) { - return new Enumeration() { + return new Enumeration() { private int index = 0; private URL url = null; @@ -225,7 +225,7 @@ public class URLClassPath { return next(); } - public Object nextElement() { + public URL nextElement() { if (!next()) { throw new NoSuchElementException(); } @@ -247,9 +247,9 @@ public class URLClassPath { * @param name the resource name * @return an Enumeration of all the resources having the specified name */ - public Enumeration getResources(final String name, + public Enumeration getResources(final String name, final boolean check) { - return new Enumeration() { + return new Enumeration() { private int index = 0; private Resource res = null; @@ -272,7 +272,7 @@ public class URLClassPath { return next(); } - public Object nextElement() { + public Resource nextElement() { if (!next()) { throw new NoSuchElementException(); } @@ -283,7 +283,7 @@ public class URLClassPath { }; } - public Enumeration getResources(final String name) { + public Enumeration getResources(final String name) { return getResources(name, true); } @@ -302,7 +302,7 @@ public class URLClassPath { if (urls.empty()) { return null; } else { - url = (URL)urls.pop(); + url = urls.pop(); } } // Skip this URL if it already has a Loader. (Loader @@ -329,7 +329,7 @@ public class URLClassPath { loaders.add(loader); lmap.put(url, loader); } - return (Loader)loaders.get(index); + return loaders.get(index); } /* @@ -337,9 +337,9 @@ public class URLClassPath { */ private Loader getLoader(final URL url) throws IOException { try { - return (Loader)java.security.AccessController.doPrivileged - (new java.security.PrivilegedExceptionAction() { - public Object run() throws IOException { + return java.security.AccessController.doPrivileged( + new java.security.PrivilegedExceptionAction() { + public Loader run() throws IOException { String file = url.getFile(); if (file != null && file.endsWith("/")) { if ("file".equals(url.getProtocol())) { @@ -561,13 +561,14 @@ public class URLClassPath { private JarIndex index; private MetaIndex metaIndex; private URLStreamHandler handler; - private HashMap lmap; + private HashMap lmap; /* * Creates a new JarLoader for the specified URL referring to * a JAR file. */ - JarLoader(URL url, URLStreamHandler jarHandler, HashMap loaderMap) + JarLoader(URL url, URLStreamHandler jarHandler, + HashMap loaderMap) throws IOException { super(new URL("jar", "", -1, url + "!/", jarHandler)); @@ -615,8 +616,8 @@ public class URLClassPath { if (jar == null) { try { java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() throws IOException { + new java.security.PrivilegedExceptionAction() { + public Void run() throws IOException { if (DEBUG) { System.err.println("Opening " + csu); Thread.dumpStack(); @@ -732,9 +733,9 @@ public class URLClassPath { String entryName; ZipEntry entry; - Enumeration enum_ = jar.entries(); + Enumeration enum_ = jar.entries(); while (enum_.hasMoreElements()) { - entry = (ZipEntry)enum_.nextElement(); + entry = enum_.nextElement(); entryName = entry.getName(); if((pos = entryName.lastIndexOf("/")) != -1) entryName = entryName.substring(0, pos); @@ -778,7 +779,7 @@ public class URLClassPath { if (index == null) return null; - HashSet visited = new HashSet(); + HashSet visited = new HashSet(); return getResource(name, check, visited); } @@ -790,7 +791,7 @@ public class URLClassPath { * non-existent resource */ Resource getResource(final String name, boolean check, - Set visited) { + Set visited) { Resource res; Object[] jarFiles; @@ -819,10 +820,9 @@ public class URLClassPath { /* no loader has been set up for this jar file * before */ - newLoader = (JarLoader) - AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Object run() throws IOException { + newLoader = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public JarLoader run() throws IOException { return new JarLoader(url, handler, lmap); } diff --git a/src/share/classes/sun/net/NetProperties.java b/src/share/classes/sun/net/NetProperties.java index c2c7eb54e2a83ee8a2212a4781624631fee61209..a94f20c2ae3fb2aeaae3d841b5c623f59694196b 100644 --- a/src/share/classes/sun/net/NetProperties.java +++ b/src/share/classes/sun/net/NetProperties.java @@ -42,8 +42,8 @@ public class NetProperties { static private Properties props = new Properties(); static { AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + new PrivilegedAction() { + public Void run() { loadDefaultProperties(); return null; }}); diff --git a/src/share/classes/sun/net/NetworkClient.java b/src/share/classes/sun/net/NetworkClient.java index 6e49e4c30fdc3d1308f89b465e4ed65d49ae0449..321b71bf6504aeca934c7440ee3fc4fb5e8d7fbf 100644 --- a/src/share/classes/sun/net/NetworkClient.java +++ b/src/share/classes/sun/net/NetworkClient.java @@ -64,8 +64,8 @@ public class NetworkClient { final String encs[] = { null }; AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + new PrivilegedAction() { + public Void run() { vals[0] = Integer.getInteger("sun.net.client.defaultReadTimeout", 0).intValue(); vals[1] = Integer.getInteger("sun.net.client.defaultConnectTimeout", 0).intValue(); encs[0] = System.getProperty("file.encoding", "ISO8859_1"); @@ -152,9 +152,9 @@ public class NetworkClient { Socket s; if (proxy != null) { if (proxy.type() == Proxy.Type.SOCKS) { - s = (Socket) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + s = AccessController.doPrivileged( + new PrivilegedAction() { + public Socket run() { return new Socket(proxy); }}); } else diff --git a/src/share/classes/sun/net/ftp/FtpClient.java b/src/share/classes/sun/net/ftp/FtpClient.java index 52458a68870adf85c58dfcf3701bea9ca52ff3c5..9a7c99d517d7f1a9749b40a04d32d58070e10210 100644 --- a/src/share/classes/sun/net/ftp/FtpClient.java +++ b/src/share/classes/sun/net/ftp/FtpClient.java @@ -117,8 +117,8 @@ public class FtpClient extends TransferProtocolClient { public static int getFtpProxyPort() { final int result[] = {80}; java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { String tmp = System.getProperty("ftp.proxyPort"); if (tmp == null) { @@ -343,9 +343,9 @@ public class FtpClient extends TransferProtocolClient { Socket s; if (proxy != null) { if (proxy.type() == Proxy.Type.SOCKS) { - s = (Socket) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + s = AccessController.doPrivileged( + new PrivilegedAction() { + public Socket run() { return new Socket(proxy); }}); } else diff --git a/src/share/classes/sun/net/spi/DefaultProxySelector.java b/src/share/classes/sun/net/spi/DefaultProxySelector.java index 425c884fef63ba14c8856ad05312b28cb67a5d09..6d69c49bfb6c8685d057088e2d74f4314b99c6b1 100644 --- a/src/share/classes/sun/net/spi/DefaultProxySelector.java +++ b/src/share/classes/sun/net/spi/DefaultProxySelector.java @@ -82,9 +82,9 @@ public class DefaultProxySelector extends ProxySelector { static { final String key = "java.net.useSystemProxies"; - Boolean b = (Boolean) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + Boolean b = AccessController.doPrivileged( + new PrivilegedAction() { + public Boolean run() { return NetProperties.getBoolean(key); }}); if (b != null && b.booleanValue()) { @@ -197,9 +197,9 @@ public class DefaultProxySelector extends ProxySelector { * System properties it does help having only 1 call to doPrivileged. * Be mindful what you do in here though! */ - Proxy p = (Proxy) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + Proxy p = AccessController.doPrivileged( + new PrivilegedAction() { + public Proxy run() { int i, j; String phost = null; int pport = 0; diff --git a/src/share/classes/sun/net/www/MessageHeader.java b/src/share/classes/sun/net/www/MessageHeader.java index 02fb42cd4b5cb582227e75a1b5f1de442e851821..c02374d589eee4bd432aed4b4d14eb705a0fd7e5 100644 --- a/src/share/classes/sun/net/www/MessageHeader.java +++ b/src/share/classes/sun/net/www/MessageHeader.java @@ -138,7 +138,7 @@ class MessageHeader { return null; } - class HeaderIterator implements Iterator { + class HeaderIterator implements Iterator { int index = 0; int next = -1; String key; @@ -165,7 +165,7 @@ class MessageHeader { return false; } } - public Object next() { + public String next() { synchronized (lock) { if (haveNext) { haveNext = false; @@ -187,17 +187,17 @@ class MessageHeader { * return an Iterator that returns all values of a particular * key in sequence */ - public Iterator multiValueIterator (String k) { + public Iterator multiValueIterator (String k) { return new HeaderIterator (k, this); } - public synchronized Map getHeaders() { + public synchronized Map> getHeaders() { return getHeaders(null); } - public synchronized Map getHeaders(String[] excludeList) { + public synchronized Map> getHeaders(String[] excludeList) { boolean skipIt = false; - Map m = new HashMap(); + Map> m = new HashMap>(); for (int i = nkeys; --i >= 0;) { if (excludeList != null) { // check if the key is in the excludeList. @@ -211,9 +211,9 @@ class MessageHeader { } } if (!skipIt) { - List l = (List)m.get(keys[i]); + List l = m.get(keys[i]); if (l == null) { - l = new ArrayList(); + l = new ArrayList(); m.put(keys[i], l); } l.add(values[i]); @@ -223,11 +223,8 @@ class MessageHeader { } } - Set keySet = m.keySet(); - for (Iterator i = keySet.iterator(); i.hasNext();) { - Object key = i.next(); - List l = (List)m.get(key); - m.put(key, Collections.unmodifiableList(l)); + for (String key : m.keySet()) { + m.put(key, Collections.unmodifiableList(m.get(key))); } return Collections.unmodifiableMap(m); diff --git a/src/share/classes/sun/net/www/MimeTable.java b/src/share/classes/sun/net/www/MimeTable.java index 291cf0586eb37dc9d0708c789ca50bf09efcd048..6018fbf464147051c228f652c7dbb531d747f5ac 100644 --- a/src/share/classes/sun/net/www/MimeTable.java +++ b/src/share/classes/sun/net/www/MimeTable.java @@ -37,18 +37,20 @@ import java.util.StringTokenizer; public class MimeTable implements FileNameMap { /** Keyed by content type, returns MimeEntries */ - private Hashtable entries = new Hashtable(); + private Hashtable entries + = new Hashtable(); /** Keyed by file extension (with the .), returns MimeEntries */ - private Hashtable extensionMap = new Hashtable(); + private Hashtable extensionMap + = new Hashtable(); // Will be reset if in the platform-specific data file private static String tempFileTemplate; static { java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { tempFileTemplate = System.getProperty("content.types.temp.file.template", "/tmp/%s"); @@ -60,7 +62,8 @@ public class MimeTable implements FileNameMap { "/usr/etc/mailcap", "/usr/local/etc/mailcap", System.getProperty("hotjava.home", - "/usr/local/hotjava") + "/lib/mailcap", + "/usr/local/hotjava") + + "/lib/mailcap", }; return null; } @@ -83,8 +86,8 @@ public class MimeTable implements FileNameMap { public static MimeTable getDefaultTable() { if (defaultInstance == null) { java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { defaultInstance = new MimeTable(); URLConnection.setFileNameMap(defaultInstance); return null; @@ -130,7 +133,7 @@ public class MimeTable implements FileNameMap { } public synchronized MimeEntry remove(String type) { - MimeEntry entry = (MimeEntry)entries.get(type); + MimeEntry entry = entries.get(type); return remove(entry); } @@ -142,16 +145,16 @@ public class MimeTable implements FileNameMap { } } - return (MimeEntry)entries.remove(entry.getType()); + return entries.remove(entry.getType()); } public synchronized MimeEntry find(String type) { - MimeEntry entry = (MimeEntry)entries.get(type); + MimeEntry entry = entries.get(type); if (entry == null) { // try a wildcard lookup - Enumeration e = entries.elements(); + Enumeration e = entries.elements(); while (e.hasMoreElements()) { - MimeEntry wild = (MimeEntry)e.nextElement(); + MimeEntry wild = e.nextElement(); if (wild.matches(type)) { return wild; } @@ -191,13 +194,13 @@ public class MimeTable implements FileNameMap { * with it. */ public synchronized MimeEntry findByExt(String fileExtension) { - return (MimeEntry)extensionMap.get(fileExtension); + return extensionMap.get(fileExtension); } public synchronized MimeEntry findByDescription(String description) { - Enumeration e = elements(); + Enumeration e = elements(); while (e.hasMoreElements()) { - MimeEntry entry = (MimeEntry)e.nextElement(); + MimeEntry entry = e.nextElement(); if (description.equals(entry.getDescription())) { return entry; } @@ -211,7 +214,7 @@ public class MimeTable implements FileNameMap { return tempFileTemplate; } - public synchronized Enumeration elements() { + public synchronized Enumeration elements() { return entries.elements(); } @@ -269,7 +272,7 @@ public class MimeTable implements FileNameMap { } // now, parse the mime-type spec's - Enumeration types = entries.propertyNames(); + Enumeration types = entries.propertyNames(); while (types.hasMoreElements()) { String type = (String)types.nextElement(); String attrs = entries.getProperty(type); @@ -392,9 +395,9 @@ public class MimeTable implements FileNameMap { public Properties getAsProperties() { Properties properties = new Properties(); - Enumeration e = elements(); + Enumeration e = elements(); while (e.hasMoreElements()) { - MimeEntry entry = (MimeEntry)e.nextElement(); + MimeEntry entry = e.nextElement(); properties.put(entry.getType(), entry.toProperty()); } diff --git a/src/share/classes/sun/net/www/http/ChunkedOutputStream.java b/src/share/classes/sun/net/www/http/ChunkedOutputStream.java index a06b5afe22867fc2f7c7f883a667014ec3b489e7..5f4a7902f622b51fa7747cfac62bac70318a6d6c 100644 --- a/src/share/classes/sun/net/www/http/ChunkedOutputStream.java +++ b/src/share/classes/sun/net/www/http/ChunkedOutputStream.java @@ -177,14 +177,23 @@ public class ChunkedOutputStream extends PrintStream { return; } - if (len > MAX_BUF_SIZE) { + int l = preferredChunkSize - count; + + if ((len > MAX_BUF_SIZE) && (len > l)) { + /* current chunk is empty just write the data */ + if (count == 0) { + count = len; + flush (b, false, off); + return; + } + /* first finish the current chunk */ - int l = preferredChunkSize - count; if (l > 0) { System.arraycopy(b, off, buf, count, l); count = preferredChunkSize; flush(buf, false); } + count = len - l; /* Now write the rest of the data */ flush (b, false, l+off); diff --git a/src/share/classes/sun/net/www/http/HttpClient.java b/src/share/classes/sun/net/www/http/HttpClient.java index 674a88336e460200110c26272d760a85f959b91f..7f0cf0d427329213bed55c796557aa09735b3add 100644 --- a/src/share/classes/sun/net/www/http/HttpClient.java +++ b/src/share/classes/sun/net/www/http/HttpClient.java @@ -230,9 +230,9 @@ public class HttpClient extends NetworkClient { setConnectTimeout(to); // get the cookieHandler if there is any - cookieHandler = (CookieHandler)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + cookieHandler = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public CookieHandler run() { return CookieHandler.getDefault(); } }); @@ -297,7 +297,7 @@ public class HttpClient extends NetworkClient { HttpClient ret = null; /* see if one's already around */ if (useCache) { - ret = (HttpClient) kac.get(url, null); + ret = kac.get(url, null); if (ret != null) { if ((ret.proxy != null && ret.proxy.equals(p)) || (ret.proxy == null && p == null)) { @@ -389,7 +389,7 @@ public class HttpClient extends NetworkClient { * cache). */ public void closeIdleConnection() { - HttpClient http = (HttpClient) kac.get(url, null); + HttpClient http = kac.get(url, null); if (http != null) { http.closeServer(); } @@ -447,8 +447,8 @@ public class HttpClient extends NetworkClient { { try { java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() throws IOException { + new java.security.PrivilegedExceptionAction() { + public Void run() throws IOException { openServer(server.getHostString(), server.getPort()); return null; } @@ -477,9 +477,8 @@ public class HttpClient extends NetworkClient { { try { java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() throws IOException - { + new java.security.PrivilegedExceptionAction() { + public Void run() throws IOException { superOpenServer(proxyHost, proxyPort); return null; } @@ -686,7 +685,7 @@ public class HttpClient extends NetworkClient { // So we do put the cast in as a workaround until // it is resolved. if (uri != null) - cookieHandler.put(uri, (Map>)responses.getHeaders()); + cookieHandler.put(uri, responses.getHeaders()); } /* decide if we're keeping alive: diff --git a/src/share/classes/sun/net/www/http/KeepAliveCache.java b/src/share/classes/sun/net/www/http/KeepAliveCache.java index 1226b2510136de22b047a576fa985ed25fa3e171..93882397a112ad4619ef141758bef4470cf4a5d8 100644 --- a/src/share/classes/sun/net/www/http/KeepAliveCache.java +++ b/src/share/classes/sun/net/www/http/KeepAliveCache.java @@ -38,7 +38,9 @@ import java.util.concurrent.ConcurrentHashMap; * @author Stephen R. Pietrowicz (NCSA) * @author Dave Brown */ -public class KeepAliveCache extends ConcurrentHashMap implements Runnable { +public class KeepAliveCache + extends ConcurrentHashMap + implements Runnable { private static final long serialVersionUID = -2937172892064557949L; /* maximum # keep-alive connections to maintain at once @@ -88,12 +90,12 @@ public class KeepAliveCache extends ConcurrentHashMap implements Runnable { * back from the server. If I'm connected through a Netscape proxy * to a server that sent me a keep-alive * time of 15 sec, the proxy unilaterally terminates my connection - * The robustness to to get around this is in HttpClient.parseHTTP() + * The robustness to get around this is in HttpClient.parseHTTP() */ final KeepAliveCache cache = this; java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { // We want to create the Keep-Alive-Timer in the // system threadgroup ThreadGroup grp = Thread.currentThread().getThreadGroup(); @@ -112,7 +114,7 @@ public class KeepAliveCache extends ConcurrentHashMap implements Runnable { } KeepAliveKey key = new KeepAliveKey(url, obj); - ClientVector v = (ClientVector)super.get(key); + ClientVector v = super.get(key); if (v == null) { int keepAliveTimeout = http.getKeepAliveTimeout(); @@ -125,10 +127,10 @@ public class KeepAliveCache extends ConcurrentHashMap implements Runnable { } } - /* remove an obsolete HttpClient from it's VectorCache */ + /* remove an obsolete HttpClient from its VectorCache */ public synchronized void remove (HttpClient h, Object obj) { KeepAliveKey key = new KeepAliveKey(h.url, obj); - ClientVector v = (ClientVector)super.get(key); + ClientVector v = super.get(key); if (v != null) { v.remove(h); if (v.empty()) { @@ -137,7 +139,7 @@ public class KeepAliveCache extends ConcurrentHashMap implements Runnable { } } - /* called by a clientVector thread when all it's connections have timed out + /* called by a clientVector thread when all its connections have timed out * and that vector of connections should be removed. */ synchronized void removeVector(KeepAliveKey k) { @@ -147,10 +149,10 @@ public class KeepAliveCache extends ConcurrentHashMap implements Runnable { /** * Check to see if this URL has a cached HttpClient */ - public synchronized Object get(URL url, Object obj) { + public synchronized HttpClient get(URL url, Object obj) { KeepAliveKey key = new KeepAliveKey(url, obj); - ClientVector v = (ClientVector)super.get(key); + ClientVector v = super.get(key); if (v == null) { // nothing in cache yet return null; } @@ -180,17 +182,16 @@ public class KeepAliveCache extends ConcurrentHashMap implements Runnable { long currentTime = System.currentTimeMillis(); - Iterator itr = keySet().iterator(); - ArrayList keysToRemove = new ArrayList(); + ArrayList keysToRemove + = new ArrayList(); - while (itr.hasNext()) { - KeepAliveKey key = (KeepAliveKey)itr.next(); - ClientVector v = (ClientVector)get(key); + for (KeepAliveKey key : keySet()) { + ClientVector v = get(key); synchronized (v) { int i; for (i = 0; i < v.size(); i++) { - KeepAliveEntry e = (KeepAliveEntry)v.elementAt(i); + KeepAliveEntry e = v.elementAt(i); if ((currentTime - e.idleStartTime) > v.nap) { HttpClient h = e.hc; h.closeServer(); @@ -205,9 +206,9 @@ public class KeepAliveCache extends ConcurrentHashMap implements Runnable { } } } - itr = keysToRemove.iterator(); - while (itr.hasNext()) { - removeVector((KeepAliveKey)itr.next()); + + for (KeepAliveKey key : keysToRemove) { + removeVector(key); } } } while (size() > 0); @@ -234,7 +235,7 @@ public class KeepAliveCache extends ConcurrentHashMap implements Runnable { */ -class ClientVector extends java.util.Stack { +class ClientVector extends java.util.Stack { private static final long serialVersionUID = -8680532108106489459L; // sleep time in milliseconds, before cache clear @@ -254,7 +255,7 @@ class ClientVector extends java.util.Stack { HttpClient hc = null; long currentTime = System.currentTimeMillis(); do { - KeepAliveEntry e = (KeepAliveEntry)pop(); + KeepAliveEntry e = pop(); if ((currentTime - e.idleStartTime) > nap) { e.hc.closeServer(); } else { diff --git a/src/share/classes/sun/net/www/http/KeepAliveStream.java b/src/share/classes/sun/net/www/http/KeepAliveStream.java index 779afb5ad7ba988d2163077e02e08e878ec67453..08fc3b03b17f210cfc23852ee1596a8d6ab24181 100644 --- a/src/share/classes/sun/net/www/http/KeepAliveStream.java +++ b/src/share/classes/sun/net/www/http/KeepAliveStream.java @@ -174,8 +174,8 @@ class KeepAliveStream extends MeteredStream implements Hurryable { if (startCleanupThread) { java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { // We want to create the Keep-Alive-SocketCleaner in the // system threadgroup ThreadGroup grp = Thread.currentThread().getThreadGroup(); diff --git a/src/share/classes/sun/net/www/http/KeepAliveStreamCleaner.java b/src/share/classes/sun/net/www/http/KeepAliveStreamCleaner.java index 779e38ac9ea94cc00522c822ab35606edf278104..3ae7cff0fdf97d36b9b6bc1ef69e35ef8d753ca9 100644 --- a/src/share/classes/sun/net/www/http/KeepAliveStreamCleaner.java +++ b/src/share/classes/sun/net/www/http/KeepAliveStreamCleaner.java @@ -59,19 +59,19 @@ public class KeepAliveStreamCleaner extends LinkedBlockingQueue() { + public Integer run() { + return NetProperties.getInteger(maxDataKey, MAX_DATA_REMAINING); + }}).intValue() * 1024; MAX_DATA_REMAINING = maxData; final String maxCapacityKey = "http.KeepAlive.queuedConnections"; - int maxCapacity = ((Integer) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - return new Integer(NetProperties.getInteger(maxCapacityKey, MAX_CAPACITY)); - }})).intValue(); + int maxCapacity = AccessController.doPrivileged( + new PrivilegedAction() { + public Integer run() { + return NetProperties.getInteger(maxCapacityKey, MAX_CAPACITY); + }}).intValue(); MAX_CAPACITY = maxCapacity; } diff --git a/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java b/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java index 44473d421d829ee580fe1d3ada25a99493be81b4..3661090f806dce4ed926f9f5da7ee125f8c96376 100644 --- a/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java +++ b/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java @@ -215,12 +215,11 @@ public class FtpURLConnection extends URLConnection { Proxy p = null; if (instProxy == null) { // no per connection proxy specified /** - * Do we have to use a proxie? + * Do we have to use a proxy? */ - ProxySelector sel = (ProxySelector) - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + ProxySelector sel = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public ProxySelector run() { return ProxySelector.getDefault(); } }); diff --git a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index fb1f3b05ed14a9adf96fd7039fb60ad60d2351b2..ef439005318a8152e9a447124dda5c8d2ad23811 100644 --- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -64,11 +64,6 @@ import java.text.SimpleDateFormat; import java.util.TimeZone; import java.net.MalformedURLException; import java.nio.ByteBuffer; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; -import java.nio.channels.Selector; -import java.nio.channels.SelectionKey; -import java.nio.channels.SelectableChannel; import java.lang.reflect.*; /** @@ -144,8 +139,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection { static { maxRedirects = java.security.AccessController.doPrivileged( - new sun.security.action.GetIntegerAction("http.maxRedirects", - defaultmaxRedirects)).intValue(); + new sun.security.action.GetIntegerAction( + "http.maxRedirects", defaultmaxRedirects)).intValue(); version = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("java.version")); String agent = java.security.AccessController.doPrivileged( @@ -291,10 +286,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection { final String scheme, final URL url, final RequestorType authType) { - return (PasswordAuthentication) - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + return java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public PasswordAuthentication run() { return Authenticator.requestPasswordAuthentication( host, addr, port, protocol, prompt, scheme, url, authType); @@ -559,15 +553,15 @@ public class HttpURLConnection extends java.net.HttpURLConnection { responses = new MessageHeader(); this.handler = handler; instProxy = p; - cookieHandler = (CookieHandler)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + cookieHandler = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public CookieHandler run() { return CookieHandler.getDefault(); } }); - cacheHandler = (ResponseCache)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + cacheHandler = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public ResponseCache run() { return ResponseCache.getDefault(); } }); @@ -650,8 +644,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection { final boolean result[] = {false}; java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { try { InetAddress a1 = InetAddress.getByName(h1); InetAddress a2 = InetAddress.getByName(h2); @@ -729,10 +723,10 @@ public class HttpURLConnection extends java.net.HttpURLConnection { /** * Do we have to use a proxy? */ - ProxySelector sel = (ProxySelector) + ProxySelector sel = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public ProxySelector run() { return ProxySelector.getDefault(); } }); @@ -824,6 +818,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * - get input, [read input,] get output, [write output] */ + @Override public synchronized OutputStream getOutputStream() throws IOException { try { @@ -908,30 +903,28 @@ public class HttpURLConnection extends java.net.HttpURLConnection { URI uri = ParseUtil.toURI(url); if (uri != null) { - Map cookies = cookieHandler.get(uri, requests.getHeaders(EXCLUDE_HEADERS)); + Map> cookies + = cookieHandler.get( + uri, requests.getHeaders(EXCLUDE_HEADERS)); if (!cookies.isEmpty()) { - Set s = cookies.entrySet(); - Iterator k_itr = s.iterator(); - while (k_itr.hasNext()) { - Map.Entry entry = (Map.Entry)k_itr.next(); - String key = (String)entry.getKey(); + for (Map.Entry> entry : + cookies.entrySet()) { + String key = entry.getKey(); // ignore all entries that don't have "Cookie" // or "Cookie2" as keys if (!"Cookie".equalsIgnoreCase(key) && !"Cookie2".equalsIgnoreCase(key)) { continue; } - List l = (List)entry.getValue(); + List l = entry.getValue(); if (l != null && !l.isEmpty()) { - Iterator v_itr = l.iterator(); StringBuilder cookieValue = new StringBuilder(); - while (v_itr.hasNext()) { - String value = (String)v_itr.next(); - cookieValue.append(value).append(';'); + for (String value : l) { + cookieValue.append(value).append("; "); } - // strip off the ending ;-sign + // strip off the trailing '; ' try { - requests.add(key, cookieValue.substring(0, cookieValue.length() - 1)); + requests.add(key, cookieValue.substring(0, cookieValue.length() - 2)); } catch (StringIndexOutOfBoundsException ignored) { // no-op } @@ -950,6 +943,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection { } // end of getting cookies } + @Override + @SuppressWarnings("empty-statement") public synchronized InputStream getInputStream() throws IOException { if (!doInput) { @@ -1363,29 +1358,27 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * original exception and with the same message. Right now, * there is no convenient APIs for doing so. */ - private IOException getChainedException(IOException rememberedException) { + private IOException getChainedException(final IOException rememberedException) { try { - final IOException originalException = rememberedException; - final Class[] cls = new Class[1]; - cls[0] = String.class; - final String[] args = new String[1]; - args[0] = originalException.getMessage(); - IOException chainedException = (IOException) - java.security.AccessController.doPrivileged - (new java.security.PrivilegedExceptionAction() { - public Object run() - throws Exception { - Constructor ctr = originalException.getClass().getConstructor(cls); - return (IOException)ctr.newInstance((Object[])args); + final Object[] args = { rememberedException.getMessage() }; + IOException chainedException = + java.security.AccessController.doPrivileged( + new java.security.PrivilegedExceptionAction() { + public IOException run() throws Exception { + return (IOException) + rememberedException.getClass() + .getConstructor(new Class[] { String.class }) + .newInstance(args); } }); - chainedException.initCause(originalException); + chainedException.initCause(rememberedException); return chainedException; } catch (Exception ignored) { return rememberedException; } } + @Override public InputStream getErrorStream() { if (connected && responseCode >= 400) { // Client Error 4xx and Server Error 5xx @@ -1629,10 +1622,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection { InetAddress addr = null; try { final String finalHost = host; - addr = (InetAddress) - java.security.AccessController.doPrivileged - (new java.security.PrivilegedExceptionAction() { - public Object run() + addr = java.security.AccessController.doPrivileged( + new java.security.PrivilegedExceptionAction() { + public InetAddress run() throws java.net.UnknownHostException { return InetAddress.getByName(finalHost); } @@ -2054,6 +2046,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { */ private void disconnectInternal() { responseCode = -1; + inputStream = null; if (pi != null) { pi.finishTracking(); pi = null; @@ -2152,6 +2145,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * Gets a header field by name. Returns null if not known. * @param name the name of the header field */ + @Override public String getHeaderField(String name) { try { getInputStream(); @@ -2174,7 +2168,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * @return a Map of header fields * @since 1.4 */ - public Map getHeaderFields() { + @Override + public Map> getHeaderFields() { try { getInputStream(); } catch (IOException e) {} @@ -2190,6 +2185,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * Gets a header field by index. Returns null if not known. * @param n the index of the header field */ + @Override public String getHeaderField(int n) { try { getInputStream(); @@ -2205,6 +2201,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * Gets a header field by index. Returns null if not known. * @param n the index of the header field */ + @Override public String getHeaderFieldKey(int n) { try { getInputStream(); @@ -2222,6 +2219,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * exists, overwrite its value with the new value. * @param value the value to be set */ + @Override public void setRequestProperty(String key, String value) { if (connected) throw new IllegalStateException("Already connected"); @@ -2243,6 +2241,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * @see #getRequestProperties(java.lang.String) * @since 1.4 */ + @Override public void addRequestProperty(String key, String value) { if (connected) throw new IllegalStateException("Already connected"); @@ -2262,6 +2261,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { requests.set(key, value); } + @Override public String getRequestProperty (String key) { // don't return headers containing security sensitive information if (key != null) { @@ -2286,7 +2286,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * @throws IllegalStateException if already connected * @since 1.4 */ - public Map getRequestProperties() { + @Override + public Map> getRequestProperties() { if (connected) throw new IllegalStateException("Already connected"); @@ -2294,6 +2295,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { return requests.getHeaders(EXCLUDE_HEADERS); } + @Override public void setConnectTimeout(int timeout) { if (timeout < 0) throw new IllegalArgumentException("timeouts can't be negative"); @@ -2313,6 +2315,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * @see java.net.URLConnection#connect() * @since 1.5 */ + @Override public int getConnectTimeout() { return (connectTimeout < 0 ? 0 : connectTimeout); } @@ -2337,6 +2340,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * @see java.io.InputStream#read() * @since 1.5 */ + @Override public void setReadTimeout(int timeout) { if (timeout < 0) throw new IllegalArgumentException("timeouts can't be negative"); @@ -2354,10 +2358,12 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * @see java.io.InputStream#read() * @since 1.5 */ + @Override public int getReadTimeout() { return readTimeout < 0 ? 0 : readTimeout; } + @Override protected void finalize() { // this should do nothing. The stream finalizer will close // the fd @@ -2367,20 +2373,15 @@ public class HttpURLConnection extends java.net.HttpURLConnection { return method; } - private MessageHeader mapToMessageHeader(Map map) { + private MessageHeader mapToMessageHeader(Map> map) { MessageHeader headers = new MessageHeader(); if (map == null || map.isEmpty()) { return headers; } - Set entries = map.entrySet(); - Iterator itr1 = entries.iterator(); - while (itr1.hasNext()) { - Map.Entry entry = (Map.Entry)itr1.next(); - String key = (String)entry.getKey(); - List values = (List)entry.getValue(); - Iterator itr2 = values.iterator(); - while (itr2.hasNext()) { - String value = (String)itr2.next(); + for (Map.Entry> entry : map.entrySet()) { + String key = entry.getKey(); + List values = entry.getValue(); + for (String value : values) { if (key == null) { headers.prepend(key, value); } else { @@ -2437,6 +2438,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * @see java.io.FilterInputStream#in * @see java.io.FilterInputStream#reset() */ + @Override public synchronized void mark(int readlimit) { super.mark(readlimit); if (cacheRequest != null) { @@ -2466,6 +2468,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * @see java.io.FilterInputStream#in * @see java.io.FilterInputStream#mark(int) */ + @Override public synchronized void reset() throws IOException { super.reset(); if (cacheRequest != null) { @@ -2474,6 +2477,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { } } + @Override public int read() throws IOException { try { byte[] b = new byte[1]; @@ -2487,10 +2491,12 @@ public class HttpURLConnection extends java.net.HttpURLConnection { } } + @Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); } + @Override public int read(byte[] b, int off, int len) throws IOException { try { int newLen = super.read(b, off, len); @@ -2521,6 +2527,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { } } + @Override public void close () throws IOException { try { if (outputStream != null) { @@ -2565,6 +2572,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { error = false; } + @Override public void write (int b) throws IOException { checkError(); written ++; @@ -2574,10 +2582,12 @@ public class HttpURLConnection extends java.net.HttpURLConnection { out.write (b); } + @Override public void write (byte[] b) throws IOException { write (b, 0, b.length); } + @Override public void write (byte[] b, int off, int len) throws IOException { checkError(); written += len; @@ -2608,6 +2618,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { return closed && ! error; } + @Override public void close () throws IOException { if (closed) { return; @@ -2726,6 +2737,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { } } + @Override public int available() throws IOException { if (is == null) { return buffer.remaining(); @@ -2740,10 +2752,12 @@ public class HttpURLConnection extends java.net.HttpURLConnection { return (ret == -1? ret : (b[0] & 0x00FF)); } + @Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); } + @Override public int read(byte[] b, int off, int len) throws IOException { int rem = buffer.remaining(); if (rem > 0) { @@ -2759,6 +2773,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { } } + @Override public void close() throws IOException { buffer = null; if (is != null) { @@ -2775,6 +2790,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { class EmptyInputStream extends InputStream { + @Override public int available() { return 0; } diff --git a/src/share/classes/sun/net/www/protocol/http/NegotiatorImpl.java b/src/share/classes/sun/net/www/protocol/http/NegotiatorImpl.java index 1ecf6a28c2997d7ae319ab9d0761c6afce9fa57e..3dc7bb6952efd52fda58d07b739c2d3753f633ef 100644 --- a/src/share/classes/sun/net/www/protocol/http/NegotiatorImpl.java +++ b/src/share/classes/sun/net/www/protocol/http/NegotiatorImpl.java @@ -91,9 +91,10 @@ public class NegotiatorImpl extends Negotiator { GSSManagerImpl manager = new GSSManagerImpl( GSSUtil.CALLER_HTTP_NEGOTIATE); - String peerName = "HTTP/" + hostname; + String peerName = "HTTP@" + hostname; - GSSName serverName = manager.createName(peerName, null); + GSSName serverName = manager.createName(peerName, + GSSName.NT_HOSTBASED_SERVICE); context = manager.createContext(serverName, oid, null, 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 7f82e993161999189b40b1f600d236e351086494..d21425680c810a14b4b210b6cc46212fcf3401b6 100644 --- a/src/share/classes/sun/net/www/protocol/https/HttpsClient.java +++ b/src/share/classes/sun/net/www/protocol/https/HttpsClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2001-2008 Sun Microsystems, 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 @@ -518,6 +518,16 @@ final class HttpsClient extends HttpClient kac.put(url, sslSocketFactory, this); } + /* + * Close an idle connection to this URL (if it exists in the cache). + */ + public void closeIdleConnection() { + HttpClient http = (HttpClient) kac.get(url, sslSocketFactory); + if (http != null) { + http.closeServer(); + } + } + /** * Returns the cipher suite in use on this connection. */ diff --git a/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java b/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java index 4388f79d8910685921e8a0ddea9b9e11cf2d3512..80b9f0f763f567c9261afc84d0abb521fdff9c6d 100644 --- a/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java +++ b/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java @@ -55,7 +55,7 @@ public class URLJarFile extends JarFile { private Manifest superMan; private Attributes superAttr; - private Map superEntries; + private Map superEntries; static JarFile getJarFile(URL url) throws IOException { return getJarFile(url, null); @@ -146,12 +146,10 @@ public class URLJarFile extends JarFile { // now deep copy the manifest entries if (superEntries != null) { - Map entries = man.getEntries(); - Iterator it = superEntries.keySet().iterator(); - while (it.hasNext()) { - Object key = it.next(); - Attributes at = (Attributes)superEntries.get(key); - entries.put(key, at.clone()); + Map entries = man.getEntries(); + for (String key : superEntries.keySet()) { + Attributes at = superEntries.get(key); + entries.put(key, (Attributes) at.clone()); } } @@ -213,9 +211,9 @@ public class URLJarFile extends JarFile { final InputStream in = url.openConnection().getInputStream(); try { - result = (JarFile) - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws IOException { + result = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public JarFile run() throws IOException { OutputStream out = null; File tmpFile = null; try { @@ -273,9 +271,9 @@ public class URLJarFile extends JarFile { public Attributes getAttributes() throws IOException { if (URLJarFile.this.isSuperMan()) { - Map e = URLJarFile.this.superEntries; + Map e = URLJarFile.this.superEntries; if (e != null) { - Attributes a = (Attributes)e.get(getName()); + Attributes a = e.get(getName()); if (a != null) return (Attributes)a.clone(); } diff --git a/src/share/classes/sun/net/www/protocol/mailto/MailToURLConnection.java b/src/share/classes/sun/net/www/protocol/mailto/MailToURLConnection.java index d939ce5515b9425f8cc05fb2ab1c31cbf360d592..53367aead964b056baebb18560f63c88e14ac3f5 100644 --- a/src/share/classes/sun/net/www/protocol/mailto/MailToURLConnection.java +++ b/src/share/classes/sun/net/www/protocol/mailto/MailToURLConnection.java @@ -29,9 +29,6 @@ import java.net.URL; import java.net.InetAddress; import java.net.SocketPermission; import java.io.*; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.StringTokenizer; import java.security.Permission; import sun.net.www.*; import sun.net.smtp.SmtpClient; @@ -86,11 +83,11 @@ public class MailToURLConnection extends URLConnection { } public void connect() throws IOException { - System.err.println("connect. Timeout = " + connectTimeout); client = new SmtpClient(connectTimeout); client.setReadTimeout(readTimeout); } + @Override public synchronized OutputStream getOutputStream() throws IOException { if (os != null) { return os; @@ -107,6 +104,7 @@ public class MailToURLConnection extends URLConnection { return os; } + @Override public Permission getPermission() throws IOException { if (permission == null) { connect(); @@ -116,22 +114,26 @@ public class MailToURLConnection extends URLConnection { return permission; } + @Override public void setConnectTimeout(int timeout) { if (timeout < 0) throw new IllegalArgumentException("timeouts can't be negative"); connectTimeout = timeout; } + @Override public int getConnectTimeout() { return (connectTimeout < 0 ? 0 : connectTimeout); } + @Override public void setReadTimeout(int timeout) { if (timeout < 0) throw new IllegalArgumentException("timeouts can't be negative"); readTimeout = timeout; } + @Override public int getReadTimeout() { return readTimeout < 0 ? 0 : readTimeout; } diff --git a/src/share/classes/sun/nio/ch/FileChannelImpl.java b/src/share/classes/sun/nio/ch/FileChannelImpl.java index 4aa21dbd18ad9f28955bd6079f88d9a2703fceb7..aae23b7664b476481366a27e17dc3f6a7ea66d93 100644 --- a/src/share/classes/sun/nio/ch/FileChannelImpl.java +++ b/src/share/classes/sun/nio/ch/FileChannelImpl.java @@ -52,39 +52,37 @@ public class FileChannelImpl { // Used to make native read and write calls - private static NativeDispatcher nd; + private static final NativeDispatcher nd; // Memory allocation size for mapping buffers - private static long allocationGranularity; + private static final long allocationGranularity; // Cached field for MappedByteBuffer.isAMappedBuffer - private static Field isAMappedBufferField; + private static final Field isAMappedBufferField; // File descriptor - private FileDescriptor fd; + private final FileDescriptor fd; // File access mode (immutable) - private boolean writable; - private boolean readable; - private boolean appending; + private final boolean writable; + private final boolean readable; // Required to prevent finalization of creating stream (immutable) - private Object parent; + private final Object parent; // Thread-safe set of IDs of native threads, for signalling - private NativeThreadSet threads = new NativeThreadSet(2); + private final NativeThreadSet threads = new NativeThreadSet(2); // Lock for operations involving position and size - private Object positionLock = new Object(); + private final Object positionLock = new Object(); private FileChannelImpl(FileDescriptor fd, boolean readable, - boolean writable, Object parent, boolean append) + boolean writable, Object parent) { this.fd = fd; this.readable = readable; this.writable = writable; this.parent = parent; - this.appending = append; } // Invoked by getChannel() methods @@ -94,14 +92,7 @@ public class FileChannelImpl boolean readable, boolean writable, Object parent) { - return new FileChannelImpl(fd, readable, writable, parent, false); - } - - public static FileChannel open(FileDescriptor fd, - boolean readable, boolean writable, - Object parent, boolean append) - { - return new FileChannelImpl(fd, readable, writable, parent, append); + return new FileChannelImpl(fd, readable, writable, parent); } private void ensureOpen() throws IOException { @@ -134,15 +125,7 @@ public class FileChannelImpl // superclass AbstractInterruptibleChannel, but the isOpen logic in // that method will prevent this method from being reinvoked. // - if (parent instanceof FileInputStream) - ((FileInputStream)parent).close(); - else if (parent instanceof FileOutputStream) - ((FileOutputStream)parent).close(); - else if (parent instanceof RandomAccessFile) - ((RandomAccessFile)parent).close(); - else - assert false; - + ((java.io.Closeable)parent).close(); } else { nd.close(fd); } @@ -218,8 +201,6 @@ public class FileChannelImpl if (!isOpen()) return 0; ti = threads.add(); - if (appending) - position(size()); do { n = IOUtil.write(fd, src, -1, nd, positionLock); } while ((n == IOStatus.INTERRUPTED) && isOpen()); @@ -244,8 +225,6 @@ public class FileChannelImpl if (!isOpen()) return 0; ti = threads.add(); - if (appending) - position(size()); do { n = IOUtil.write(fd, srcs, nd); } while ((n == IOStatus.INTERRUPTED) && isOpen()); @@ -1051,7 +1030,7 @@ public class FileChannelImpl private FileKey fileKey; FileLockReference(FileLock referent, - ReferenceQueue queue, + ReferenceQueue queue, FileKey key) { super(referent, queue); this.fileKey = key; @@ -1073,7 +1052,7 @@ public class FileChannelImpl new ConcurrentHashMap>(); // reference queue for cleared refs - private static ReferenceQueue queue = new ReferenceQueue(); + private static ReferenceQueue queue = new ReferenceQueue(); // the enclosing file channel private FileChannelImpl fci; diff --git a/src/share/classes/sun/nio/ch/Reflect.java b/src/share/classes/sun/nio/ch/Reflect.java index b50c600e3145152f972ec4f02c2b523f7350465f..cd98bf8dfad5fb1197326cc01458b293ef164ac7 100644 --- a/src/share/classes/sun/nio/ch/Reflect.java +++ b/src/share/classes/sun/nio/ch/Reflect.java @@ -43,8 +43,8 @@ class Reflect { // package-private } private static void setAccessible(final AccessibleObject ao) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { ao.setAccessible(true); return null; }}); @@ -54,7 +54,7 @@ class Reflect { // package-private Class[] paramTypes) { try { - Class cl = Class.forName(className); + Class cl = Class.forName(className); Constructor c = cl.getDeclaredConstructor(paramTypes); setAccessible(c); return c; @@ -82,7 +82,7 @@ class Reflect { // package-private Class[] paramTypes) { try { - Class cl = Class.forName(className); + Class cl = Class.forName(className); Method m = cl.getDeclaredMethod(methodName, paramTypes); setAccessible(m); return m; diff --git a/src/share/classes/sun/nio/ch/SocketAdaptor.java b/src/share/classes/sun/nio/ch/SocketAdaptor.java index e852204d803381f658bac8e352c885845fdfed38..d8c26a2d13bb41a1336210f442bab22ba918aac9 100644 --- a/src/share/classes/sun/nio/ch/SocketAdaptor.java +++ b/src/share/classes/sun/nio/ch/SocketAdaptor.java @@ -242,9 +242,9 @@ public class SocketAdaptor throw new SocketException("Socket input is shutdown"); if (socketInputStream == null) { try { - socketInputStream = (InputStream)AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Object run() throws IOException { + socketInputStream = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public InputStream run() throws IOException { return new SocketInputStream(); } }); @@ -264,9 +264,9 @@ public class SocketAdaptor throw new SocketException("Socket output is shutdown"); OutputStream os = null; try { - os = (OutputStream) - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws IOException { + os = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public OutputStream run() throws IOException { return Channels.newOutputStream(sc); } }); diff --git a/src/share/classes/sun/nio/ch/Util.java b/src/share/classes/sun/nio/ch/Util.java index bacaa59f85f9e29aaff9aa066faceb4d6fa48178..73b66e072962775da72610b95a2f134c51c79055 100644 --- a/src/share/classes/sun/nio/ch/Util.java +++ b/src/share/classes/sun/nio/ch/Util.java @@ -49,20 +49,21 @@ class Util { private static final int TEMP_BUF_POOL_SIZE = 3; // Per-thread soft cache of the last temporary direct buffer - private static ThreadLocal[] bufferPool; + private static ThreadLocal>[] bufferPool; static { - bufferPool = new ThreadLocal[TEMP_BUF_POOL_SIZE]; + bufferPool = (ThreadLocal>[]) + new ThreadLocal[TEMP_BUF_POOL_SIZE]; for (int i=0; i>(); } static ByteBuffer getTemporaryDirectBuffer(int size) { ByteBuffer buf = null; // Grab a buffer if available for (int i=0; i ref = bufferPool[i].get(); + if ((ref != null) && ((buf = ref.get()) != null) && (buf.capacity() >= size)) { buf.rewind(); buf.limit(size); @@ -80,18 +81,18 @@ class Util { return; // Put it in an empty slot if such exists for (int i=0; i ref = bufferPool[i].get(); if ((ref == null) || (ref.get() == null)) { - bufferPool[i].set(new SoftReference(buf)); + bufferPool[i].set(new SoftReference(buf)); return; } } // Otherwise replace a smaller one in the cache if such exists for (int i=0; i ref = bufferPool[i].get(); + ByteBuffer inCacheBuf = ref.get(); if ((inCacheBuf == null) || (buf.capacity() > inCacheBuf.capacity())) { - bufferPool[i].set(new SoftReference(buf)); + bufferPool[i].set(new SoftReference(buf)); return; } } @@ -120,10 +121,12 @@ class Util { } // Per-thread cached selector - private static ThreadLocal localSelector = new ThreadLocal(); + private static ThreadLocal> localSelector + = new ThreadLocal>(); // Hold a reference to the selWrapper object to prevent it from // being cleaned when the temporary selector wrapped is on lease. - private static ThreadLocal localSelectorWrapper = new ThreadLocal(); + private static ThreadLocal localSelectorWrapper + = new ThreadLocal(); // When finished, invoker must ensure that selector is empty // by cancelling any related keys and explicitly releasing @@ -131,15 +134,16 @@ class Util { static Selector getTemporarySelector(SelectableChannel sc) throws IOException { - SoftReference ref = (SoftReference)localSelector.get(); + SoftReference ref = localSelector.get(); SelectorWrapper selWrapper = null; Selector sel = null; if (ref == null - || ((selWrapper = (SelectorWrapper) ref.get()) == null) + || ((selWrapper = ref.get()) == null) || ((sel = selWrapper.get()) == null) || (sel.provider() != sc.provider())) { sel = sc.provider().openSelector(); - localSelector.set(new SoftReference(new SelectorWrapper(sel))); + localSelector.set(new SoftReference( + new SelectorWrapper(sel))); } else { localSelectorWrapper.set(selWrapper); } @@ -235,10 +239,10 @@ class Util { private static volatile Constructor directByteBufferConstructor = null; private static void initDBBConstructor() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { try { - Class cl = Class.forName("java.nio.DirectByteBuffer"); + Class cl = Class.forName("java.nio.DirectByteBuffer"); Constructor ctor = cl.getDeclaredConstructor( new Class[] { int.class, long.class, @@ -282,10 +286,10 @@ class Util { private static volatile Constructor directByteBufferRConstructor = null; private static void initDBBRConstructor() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { try { - Class cl = Class.forName("java.nio.DirectByteBufferR"); + Class cl = Class.forName("java.nio.DirectByteBufferR"); Constructor ctor = cl.getDeclaredConstructor( new Class[] { int.class, long.class, diff --git a/src/share/classes/sun/nio/cs/CharsetMapping.java b/src/share/classes/sun/nio/cs/CharsetMapping.java new file mode 100644 index 0000000000000000000000000000000000000000..c2449f0605de0b2cc39f64d584f642e3a6cc91ae --- /dev/null +++ b/src/share/classes/sun/nio/cs/CharsetMapping.java @@ -0,0 +1,351 @@ +/* + * Copyright 2008 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package sun.nio.cs; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.*; +import java.security.*; + +public class CharsetMapping { + public final static char UNMAPPABLE_DECODING = '\uFFFD'; + public final static int UNMAPPABLE_ENCODING = -1; + + char[] b2cSB; //singlebyte b->c + char[] b2cDB1; //dobulebyte b->c /db1 + char[] b2cDB2; //dobulebyte b->c /db2 + + int b2Min, b2Max; //min/max(start/end) value of 2nd byte + int b1MinDB1, b1MaxDB1; //min/Max(start/end) value of 1st byte/db1 + int b1MinDB2, b1MaxDB2; //min/Max(start/end) value of 1st byte/db2 + int dbSegSize; + + char[] c2b; + char[] c2bIndex; + + // Supplementary + char[] b2cSupp; + char[] c2bSupp; + + // Composite + Entry[] b2cComp; + Entry[] c2bComp; + + public char decodeSingle(int b) { + return b2cSB[b]; + } + + public char decodeDouble(int b1, int b2) { + if (b2 >= b2Min && b2 < b2Max) { + b2 -= b2Min; + if (b1 >= b1MinDB1 && b1 <= b1MaxDB1) { + b1 -= b1MinDB1; + return b2cDB1[b1 * dbSegSize + b2]; + } + if (b1 >= b1MinDB2 && b1 <= b1MaxDB2) { + b1 -= b1MinDB2; + return b2cDB2[b1 * dbSegSize + b2]; + } + } + return UNMAPPABLE_DECODING; + } + + // for jis0213 all supplementary characters are in 0x2xxxx range, + // so only the xxxx part is now stored, should actually store the + // codepoint value instead. + public char[] decodeSurrogate(int db, char[] cc) { + int end = b2cSupp.length / 2; + int i = Arrays.binarySearch(b2cSupp, 0, end, (char)db); + if (i >= 0) { + Character.toChars(b2cSupp[end + i] + 0x20000, cc, 0); + return cc; + } + return null; + } + + public char[] decodeComposite(Entry comp, char[] cc) { + int i = findBytes(b2cComp, comp); + if (i >= 0) { + cc[0] = (char)b2cComp[i].cp; + cc[1] = (char)b2cComp[i].cp2; + return cc; + } + return null; + } + + public int encodeChar(char ch) { + int index = c2bIndex[ch >> 8]; + if (index == 0xffff) + return UNMAPPABLE_ENCODING; + return c2b[index + (ch & 0xff)]; + } + + public int encodeSurrogate(char hi, char lo) { + char c = (char)Character.toCodePoint(hi, lo); + int end = c2bSupp.length / 2; + int i = Arrays.binarySearch(c2bSupp, 0, end, c); + if (i >= 0) + return c2bSupp[end + i]; + return UNMAPPABLE_ENCODING; + } + + public boolean isCompositeBase(Entry comp) { + if (comp.cp <= 0x31f7 && comp.cp >= 0xe6) { + return (findCP(c2bComp, comp) >= 0); + } + return false; + } + + public int encodeComposite(Entry comp) { + int i = findComp(c2bComp, comp); + if (i >= 0) + return c2bComp[i].bs; + return UNMAPPABLE_ENCODING; + } + + // init the CharsetMapping object from the .dat binary file + public static CharsetMapping get(final InputStream is) { + return AccessController.doPrivileged(new PrivilegedAction() { + public CharsetMapping run() { + return new CharsetMapping().load(is); + } + }); + } + + public static class Entry { + public int bs; //byte sequence reps + public int cp; //Unicode codepoint + public int cp2; //CC of composite + } + + static Comparator comparatorBytes = + new Comparator() { + public int compare(Entry m1, Entry m2) { + return m1.bs - m2.bs; + } + public boolean equals(Object obj) { + return this == obj; + } + }; + + static Comparator comparatorCP = + new Comparator() { + public int compare(Entry m1, Entry m2) { + return m1.cp - m2.cp; + } + public boolean equals(Object obj) { + return this == obj; + } + }; + + static Comparator comparatorComp = + new Comparator() { + public int compare(Entry m1, Entry m2) { + int v = m1.cp - m2.cp; + if (v == 0) + v = m1.cp2 - m2.cp2; + return v; + } + public boolean equals(Object obj) { + return this == obj; + } + }; + + static int findBytes(Entry[] a, Entry k) { + return Arrays.binarySearch(a, 0, a.length, k, comparatorBytes); + } + + static int findCP(Entry[] a, Entry k) { + return Arrays.binarySearch(a, 0, a.length, k, comparatorCP); + } + + static int findComp(Entry[] a, Entry k) { + return Arrays.binarySearch(a, 0, a.length, k, comparatorComp); + } + + /*****************************************************************************/ + // tags of different charset mapping tables + private final static int MAP_SINGLEBYTE = 0x1; // 0..256 : c + private final static int MAP_DOUBLEBYTE1 = 0x2; // min..max: c + private final static int MAP_DOUBLEBYTE2 = 0x3; // min..max: c [DB2] + private final static int MAP_SUPPLEMENT = 0x5; // db,c + private final static int MAP_SUPPLEMENT_C2B = 0x6; // c,db + private final static int MAP_COMPOSITE = 0x7; // db,base,cc + private final static int MAP_INDEXC2B = 0x8; // index table of c->bb + + private static final boolean readNBytes(InputStream in, byte[] bb, int N) + throws IOException + { + int off = 0; + while (N > 0) { + int n = in.read(bb, off, N); + if (n == -1) + return false; + N = N - n; + off += n; + } + return true; + } + + int off = 0; + byte[] bb; + private char[] readCharArray() { + // first 2 bytes are the number of "chars" stored in this table + int size = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff); + char [] cc = new char[size]; + for (int i = 0; i < size; i++) { + cc[i] = (char)(((bb[off++]&0xff)<<8) | (bb[off++]&0xff)); + } + return cc; + } + + void readSINGLEBYTE() { + char[] map = readCharArray(); + for (int i = 0; i < map.length; i++) { + char c = map[i]; + if (c != UNMAPPABLE_DECODING) { + c2b[c2bIndex[c >> 8] + (c&0xff)] = (char)i; + } + } + b2cSB = map; + } + + void readINDEXC2B() { + char[] map = readCharArray(); + for (int i = map.length - 1; i >= 0; i--) { + if (c2b == null && map[i] != -1) { + c2b = new char[map[i] + 256]; + Arrays.fill(c2b, (char)UNMAPPABLE_ENCODING); + break; + } + } + c2bIndex = map; + } + + char[] readDB(int b1Min, int b2Min, int segSize) { + char[] map = readCharArray(); + for (int i = 0; i < map.length; i++) { + char c = map[i]; + if (c != UNMAPPABLE_DECODING) { + int b1 = i / segSize; + int b2 = i % segSize; + int b = (b1 + b1Min)* 256 + (b2 + b2Min); + //System.out.printf(" DB %x\t%x%n", b, c & 0xffff); + c2b[c2bIndex[c >> 8] + (c&0xff)] = (char)(b); + } + } + return map; + } + + void readDOUBLEBYTE1() { + b1MinDB1 = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff); + b1MaxDB1 = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff); + b2Min = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff); + b2Max = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff); + dbSegSize = b2Max - b2Min + 1; + b2cDB1 = readDB(b1MinDB1, b2Min, dbSegSize); + } + + void readDOUBLEBYTE2() { + b1MinDB2 = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff); + b1MaxDB2 = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff); + b2Min = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff); + b2Max = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff); + dbSegSize = b2Max - b2Min + 1; + b2cDB2 = readDB(b1MinDB2, b2Min, dbSegSize); + } + + void readCOMPOSITE() { + char[] map = readCharArray(); + int mLen = map.length/3; + b2cComp = new Entry[mLen]; + c2bComp = new Entry[mLen]; + for (int i = 0, j= 0; i < mLen; i++) { + Entry m = new Entry(); + m.bs = map[j++]; + m.cp = map[j++]; + m.cp2 = map[j++]; + b2cComp[i] = m; + c2bComp[i] = m; + } + Arrays.sort(c2bComp, 0, c2bComp.length, comparatorComp); + } + + CharsetMapping load(InputStream in) { + try { + // The first 4 bytes are the size of the total data followed in + // this .dat file. + int len = ((in.read()&0xff) << 24) | ((in.read()&0xff) << 16) | + ((in.read()&0xff) << 8) | (in.read()&0xff); + bb = new byte[len]; + off = 0; + //System.out.printf("In : Total=%d%n", len); + // Read in all bytes + if (!readNBytes(in, bb, len)) + throw new RuntimeException("Corrupted data file"); + in.close(); + + while (off < len) { + int type = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff); + switch(type) { + case MAP_INDEXC2B: + readINDEXC2B(); + break; + case MAP_SINGLEBYTE: + readSINGLEBYTE(); + break; + case MAP_DOUBLEBYTE1: + readDOUBLEBYTE1(); + break; + case MAP_DOUBLEBYTE2: + readDOUBLEBYTE2(); + break; + case MAP_SUPPLEMENT: + b2cSupp = readCharArray(); + break; + case MAP_SUPPLEMENT_C2B: + c2bSupp = readCharArray(); + break; + case MAP_COMPOSITE: + readCOMPOSITE(); + break; + default: + throw new RuntimeException("Corrupted data file"); + } + } + bb = null; + return this; + } catch (IOException x) { + x.printStackTrace(); + return null; + } + } +} diff --git a/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java b/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java index fbd1967df4d076e2915a83d91cb1cb6de7bd70c6..885424ad489628d97ac99bae9a586ac167cb484c 100644 --- a/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java +++ b/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java @@ -23,9 +23,6 @@ * have any questions. */ -/* - */ - package sun.nio.cs.ext; import java.lang.ref.SoftReference; @@ -183,6 +180,25 @@ public class ExtendedCharsets "csISO159JISX02121990" }); + charset("x-SJIS_0213", "SJIS_0213", + new String[] { + "sjis-0213", + "sjis_0213", + "sjis:2004", + "sjis_0213:2004", + "shift_jis_0213:2004", + "shift_jis:2004" + }); + + charset("x-MS932_0213", "MS932_0213", + new String[] { + "MS932-0213", + "MS932_0213", + "MS932:2004", + "windows-932-0213", + "windows-932:2004" + }); + charset("EUC-JP", "EUC_JP", new String[] { "euc_jp", // JDK historical diff --git a/src/share/classes/sun/nio/cs/ext/MS932_0213.java b/src/share/classes/sun/nio/cs/ext/MS932_0213.java new file mode 100644 index 0000000000000000000000000000000000000000..4c9d0b353fb00fe6efcc6f1438454615bcff5223 --- /dev/null +++ b/src/share/classes/sun/nio/cs/ext/MS932_0213.java @@ -0,0 +1,80 @@ +/* + * Copyright 2008 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package sun.nio.cs.ext; + +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.CharsetDecoder; + +public class MS932_0213 extends Charset { + public MS932_0213() { + super("x-MS932_0213", ExtendedCharsets.aliasesFor("MS932_0213")); + } + + public boolean contains(Charset cs) { + return ((cs.name().equals("US-ASCII")) + || (cs instanceof MS932) + || (cs instanceof MS932_0213)); + } + + public CharsetDecoder newDecoder() { + return new Decoder(this); + } + + public CharsetEncoder newEncoder() { + return new Encoder(this); + } + + protected static class Decoder extends SJIS_0213.Decoder { + MS932DB.Decoder decMS932; + protected Decoder(Charset cs) { + super(cs); + decMS932 = new MS932DB.Decoder(cs); + } + + protected char decodeDouble(int b1, int b2) { + char c = decMS932.decodeDouble(b1, b2); + if (c == DoubleByteDecoder.REPLACE_CHAR) + return super.decodeDouble(b1, b2); + return c; + } + } + + protected static class Encoder extends SJIS_0213.Encoder { + MS932DB.Encoder encMS932; + protected Encoder(Charset cs) { + super(cs); + encMS932 = new MS932DB.Encoder(cs); + } + + protected int encodeChar(char ch) { + int db = encMS932.encodeDouble(ch); + if (db == 0) + return super.encodeChar(ch); + return db; + } + } +} diff --git a/src/share/classes/sun/nio/cs/ext/SJIS_0213.java b/src/share/classes/sun/nio/cs/ext/SJIS_0213.java new file mode 100644 index 0000000000000000000000000000000000000000..e1f1f50ccee3138b9054a4c95770ddcc1f51ed13 --- /dev/null +++ b/src/share/classes/sun/nio/cs/ext/SJIS_0213.java @@ -0,0 +1,398 @@ +/* + * Copyright 2008 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package sun.nio.cs.ext; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CoderResult; +import java.util.Arrays; +import sun.nio.cs.CharsetMapping; + +/* + * 5 types of entry in SJIS_X_0213/Unicode mapping table + * + * (1)Single-Byte + * JIS_X_0213 does not define single-byte character itself, the + * JIS_X_0201 entries are added in for sjis implementation. + * + * (2)Double-Byte SJIS <-> BMP Unicode + * ex: 0x8140 U+3000 # IDEOGRAPHIC SPACE + * + * (3)Double-Byte SJIS <-> Supplementary + * ex: 0xFCF0 U+2A61A # [2000] [Unicode3.1] + * + * (4)Double-Byte SJIS <-> Composite + * ex: 0x83F6 U+31F7+309A # [2000] + * + * (5)"Windows-only" special mapping entries + * are handled by MS932_0213. + */ + +public class SJIS_0213 extends Charset { + public SJIS_0213() { + super("x-SJIS_0213", ExtendedCharsets.aliasesFor("SJIS_0213")); + } + + public boolean contains(Charset cs) { + return ((cs.name().equals("US-ASCII")) + || (cs instanceof SJIS) + || (cs instanceof SJIS_0213)); + } + + public CharsetDecoder newDecoder() { + return new Decoder(this); + } + + public CharsetEncoder newEncoder() { + return new Encoder(this); + } + + static CharsetMapping mapping = + CharsetMapping.get(SJIS_0213.class.getResourceAsStream("sjis0213.dat")); + + protected static class Decoder extends CharsetDecoder { + protected static final char UNMAPPABLE = CharsetMapping.UNMAPPABLE_DECODING; + + protected Decoder(Charset cs) { + super(cs, 0.5f, 1.0f); + } + + private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) { + byte[] sa = src.array(); + int sp = src.arrayOffset() + src.position(); + int sl = src.arrayOffset() + src.limit(); + + char[] da = dst.array(); + int dp = dst.arrayOffset() + dst.position(); + int dl = dst.arrayOffset() + dst.limit(); + + try { + while (sp < sl) { + int b1 = sa[sp] & 0xff; + char c = decodeSingle(b1); + int inSize = 1, outSize = 1; + char[] cc = null; + if (c == UNMAPPABLE) { + if (sl - sp < 2) + return CoderResult.UNDERFLOW; + int b2 = sa[sp + 1] & 0xff; + c = decodeDouble(b1, b2); + inSize++; + if (c == UNMAPPABLE) { + cc = decodeDoubleEx(b1, b2); + if (cc == null) { + if (decodeSingle(b2) == UNMAPPABLE) + return CoderResult.unmappableForLength(2); + else + return CoderResult.unmappableForLength(1); + } + outSize++; + } + } + if (dl - dp < outSize) + return CoderResult.OVERFLOW; + if (outSize == 2) { + da[dp++] = cc[0]; + da[dp++] = cc[1]; + } else { + da[dp++] = c; + } + sp += inSize; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(sp - src.arrayOffset()); + dst.position(dp - dst.arrayOffset()); + } + } + + private CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) { + int mark = src.position(); + try { + while (src.hasRemaining()) { + char[] cc = null; + int b1 = src.get() & 0xff; + char c = decodeSingle(b1); + int inSize = 1, outSize = 1; + if (c == UNMAPPABLE) { + if (src.remaining() < 1) + return CoderResult.UNDERFLOW; + int b2 = src.get() & 0xff; + inSize++; + c = decodeDouble(b1, b2); + if (c == UNMAPPABLE) { + cc = decodeDoubleEx(b1, b2); + if (cc == null) { + if (decodeSingle(b2) == UNMAPPABLE) + return CoderResult.unmappableForLength(2); + else + return CoderResult.unmappableForLength(1); + } + outSize++; + } + } + if (dst.remaining() < outSize) + return CoderResult.OVERFLOW; + if (outSize == 2) { + dst.put(cc[0]); + dst.put(cc[1]); + } else { + dst.put(c); + } + mark += inSize; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(mark); + } + } + + protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { + if (src.hasArray() && dst.hasArray()) + return decodeArrayLoop(src, dst); + else + return decodeBufferLoop(src, dst); + } + + protected char decodeSingle(int b) { + return mapping.decodeSingle(b); + } + + protected char decodeDouble(int b1, int b2) { + return mapping.decodeDouble(b1, b2); + } + + private char[] cc = new char[2]; + private CharsetMapping.Entry comp = new CharsetMapping.Entry(); + protected char[] decodeDoubleEx(int b1, int b2) { + int db = (b1 << 8) | b2; + if (mapping.decodeSurrogate(db, cc) != null) + return cc; + comp.bs = db; + if (mapping.decodeComposite(comp, cc) != null) + return cc; + return null; + } + } + + protected static class Encoder extends CharsetEncoder { + protected static final int UNMAPPABLE = CharsetMapping.UNMAPPABLE_ENCODING; + protected static final int MAX_SINGLEBYTE = 0xff; + + protected Encoder(Charset cs) { + super(cs, 2.0f, 2.0f); + } + + public boolean canEncode(char c) { + return (encodeChar(c) != UNMAPPABLE); + } + + protected int encodeChar(char ch) { + return mapping.encodeChar(ch); + } + + protected int encodeSurrogate(char hi, char lo) { + return mapping.encodeSurrogate(hi, lo); + } + + private CharsetMapping.Entry comp = new CharsetMapping.Entry(); + protected int encodeComposite(char base, char cc) { + comp.cp = base; + comp.cp2 = cc; + return mapping.encodeComposite(comp); + } + + protected boolean isCompositeBase(char ch) { + comp.cp = ch; + return mapping.isCompositeBase(comp); + } + + // Unlike surrogate pair, the base character of a base+cc composite + // itself is a legal codepoint in 0213, if we simply return UNDERFLOW + // when a base candidate is the last input char in the CharBuffer, like + // what we do for the surrogte pair, encoding will fail if this base + // character is indeed the last character of the input char sequence. + // Keep this base candidate in "leftoverBase" so we can flush it out + // at the end of the encoding circle. + char leftoverBase = 0; + protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { + char[] sa = src.array(); + int sp = src.arrayOffset() + src.position(); + int sl = src.arrayOffset() + src.limit(); + byte[] da = dst.array(); + int dp = dst.arrayOffset() + dst.position(); + int dl = dst.arrayOffset() + dst.limit(); + + try { + while (sp < sl) { + int db; + char c = sa[sp]; + if (leftoverBase != 0) { + boolean isComp = false; + db = encodeComposite(leftoverBase, c); + if (db == UNMAPPABLE) + db = encodeChar(leftoverBase); + else + isComp = true; + if (dl - dp < 2) + return CoderResult.OVERFLOW; + da[dp++] = (byte)(db >> 8); + da[dp++] = (byte)db; + leftoverBase = 0; + if (isComp) { + sp++; + continue; + } + } + if (isCompositeBase(c)) { + leftoverBase = c; + } else { + db = encodeChar(c); + if (db > MAX_SINGLEBYTE) { // DoubleByte + if (dl - dp < 2) + return CoderResult.OVERFLOW; + da[dp++] = (byte)(db >> 8); + da[dp++] = (byte)db; + } else if (db != UNMAPPABLE) { // SingleByte + if (dl <= dp) + return CoderResult.OVERFLOW; + da[dp++] = (byte)db; + } else if (Character.isHighSurrogate(c)) { + if ((sp + 1) == sl) + return CoderResult.UNDERFLOW; + char c2 = sa[sp + 1]; + if (!Character.isLowSurrogate(c2)) + return CoderResult.malformedForLength(1); + db = encodeSurrogate(c, c2); + if (db == UNMAPPABLE) + return CoderResult.unmappableForLength(2); + if (dl - dp < 2) + return CoderResult.OVERFLOW; + da[dp++] = (byte)(db >> 8); + da[dp++] = (byte)db; + sp++; + } else { + return CoderResult.unmappableForLength(1); + } + } + sp++; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(sp - src.arrayOffset()); + dst.position(dp - dst.arrayOffset()); + } + } + + protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) { + int mark = src.position(); + try { + while (src.hasRemaining()) { + int db; + char c = src.get(); + if (leftoverBase != 0) { + boolean isComp = false; + db = encodeComposite(leftoverBase, c); + if (db == UNMAPPABLE) + db = encodeChar(leftoverBase); + else + isComp = true; + if (dst.remaining() < 2) + return CoderResult.OVERFLOW; + dst.put((byte)(db >> 8)); + dst.put((byte)(db)); + leftoverBase = 0; + if (isComp) { + mark++; + continue; + } + } + if (isCompositeBase(c)) { + leftoverBase = c; + } else { + db = encodeChar(c); + if (db > MAX_SINGLEBYTE) { // DoubleByte + if (dst.remaining() < 2) + return CoderResult.OVERFLOW; + dst.put((byte)(db >> 8)); + dst.put((byte)(db)); + } else if (db != UNMAPPABLE) { // Single-byte + if (dst.remaining() < 1) + return CoderResult.OVERFLOW; + dst.put((byte)db); + } else if (Character.isHighSurrogate(c)) { + if (!src.hasRemaining()) // Surrogates + return CoderResult.UNDERFLOW; + char c2 = src.get(); + if (!Character.isLowSurrogate(c2)) + return CoderResult.malformedForLength(1); + db = encodeSurrogate(c, c2); + if (db == UNMAPPABLE) + return CoderResult.unmappableForLength(2); + if (dst.remaining() < 2) + return CoderResult.OVERFLOW; + dst.put((byte)(db >> 8)); + dst.put((byte)(db)); + mark++; + } else { + return CoderResult.unmappableForLength(1); + } + } + mark++; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(mark); + } + } + + protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) { + if (src.hasArray() && dst.hasArray()) + return encodeArrayLoop(src, dst); + else + return encodeBufferLoop(src, dst); + } + + protected CoderResult implFlush(ByteBuffer dst) { + if (leftoverBase > 0) { + if (dst.remaining() < 2) + return CoderResult.OVERFLOW; + int db = encodeChar(leftoverBase); + dst.put((byte)(db >> 8)); + dst.put((byte)(db)); + leftoverBase = 0; + } + return CoderResult.UNDERFLOW; + } + + protected void implReset() { + leftoverBase = 0; + } + } +} diff --git a/src/share/classes/sun/reflect/ClassDefiner.java b/src/share/classes/sun/reflect/ClassDefiner.java index 63a4e2af44d77830851d6af6c337152722353cc2..91efcfffedff9ba0bfcb7536d8d2b46ff241a523 100644 --- a/src/share/classes/sun/reflect/ClassDefiner.java +++ b/src/share/classes/sun/reflect/ClassDefiner.java @@ -54,9 +54,9 @@ class ClassDefiner { static Class defineClass(String name, byte[] bytes, int off, int len, final ClassLoader parentClassLoader) { - ClassLoader newLoader = (ClassLoader) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + ClassLoader newLoader = AccessController.doPrivileged( + new PrivilegedAction() { + public ClassLoader run() { return new DelegatingClassLoader(parentClassLoader); } }); diff --git a/src/share/classes/sun/reflect/MethodAccessorGenerator.java b/src/share/classes/sun/reflect/MethodAccessorGenerator.java index 3b62e2df8190ba5a4f30d81dd5d1afbca207c756..fd72a6e1c87cc900b988b031cc0b80dc016a339a 100644 --- a/src/share/classes/sun/reflect/MethodAccessorGenerator.java +++ b/src/share/classes/sun/reflect/MethodAccessorGenerator.java @@ -392,11 +392,12 @@ class MethodAccessorGenerator extends AccessorGenerator { // same namespace as the target class. Since the generated code // is privileged anyway, the protection domain probably doesn't // matter. - return (MagicAccessorImpl) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged( + new PrivilegedAction() { + public MagicAccessorImpl run() { try { - return ClassDefiner.defineClass + return (MagicAccessorImpl) + ClassDefiner.defineClass (generatedName, bytes, 0, diff --git a/src/share/classes/sun/reflect/ReflectionFactory.java b/src/share/classes/sun/reflect/ReflectionFactory.java index 30a1ac47c20c6a944843476ff796d0c1a443a21b..54dc717f62f3ffa8fdcbcccfb1c8cd7439fad5b1 100644 --- a/src/share/classes/sun/reflect/ReflectionFactory.java +++ b/src/share/classes/sun/reflect/ReflectionFactory.java @@ -84,8 +84,8 @@ public class ReflectionFactory { * AccessController.doPrivileged. */ public static final class GetReflectionFactoryAction - implements PrivilegedAction { - public Object run() { + implements PrivilegedAction { + public ReflectionFactory run() { return getReflectionFactory(); } } @@ -164,7 +164,7 @@ public class ReflectionFactory { public ConstructorAccessor newConstructorAccessor(Constructor c) { checkInitted(); - Class declaringClass = c.getDeclaringClass(); + Class declaringClass = c.getDeclaringClass(); if (Modifier.isAbstract(declaringClass.getModifiers())) { return new InstantiationExceptionConstructorAccessorImpl(null); } @@ -204,9 +204,9 @@ public class ReflectionFactory { /** Creates a new java.lang.reflect.Field. Access checks as per java.lang.reflect.AccessibleObject are not overridden. */ - public Field newField(Class declaringClass, + public Field newField(Class declaringClass, String name, - Class type, + Class type, int modifiers, int slot, String signature, @@ -223,11 +223,11 @@ public class ReflectionFactory { /** Creates a new java.lang.reflect.Method. Access checks as per java.lang.reflect.AccessibleObject are not overridden. */ - public Method newMethod(Class declaringClass, + public Method newMethod(Class declaringClass, String name, - Class[] parameterTypes, - Class returnType, - Class[] checkedExceptions, + Class[] parameterTypes, + Class returnType, + Class[] checkedExceptions, int modifiers, int slot, String signature, @@ -250,9 +250,9 @@ public class ReflectionFactory { /** Creates a new java.lang.reflect.Constructor. Access checks as per java.lang.reflect.AccessibleObject are not overridden. */ - public Constructor newConstructor(Class declaringClass, - Class[] parameterTypes, - Class[] checkedExceptions, + public Constructor newConstructor(Class declaringClass, + Class[] parameterTypes, + Class[] checkedExceptions, int modifiers, int slot, String signature, @@ -310,7 +310,7 @@ public class ReflectionFactory { /** Makes a copy of the passed constructor. The returned constructor is a "child" of the passed one; see the comments in Constructor.java for details. */ - public Constructor copyConstructor(Constructor arg) { + public Constructor copyConstructor(Constructor arg) { return langReflectAccess().copyConstructor(arg); } @@ -321,7 +321,7 @@ public class ReflectionFactory { // public Constructor newConstructorForSerialization - (Class classToInstantiate, Constructor constructorToCall) + (Class classToInstantiate, Constructor constructorToCall) { // Fast path if (constructorToCall.getDeclaringClass() == classToInstantiate) { @@ -366,8 +366,9 @@ public class ReflectionFactory { run, before the system properties are set up. */ private static void checkInitted() { if (initted) return; - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged( + new PrivilegedAction() { + public Void run() { // Tests to ensure the system properties table is fully // initialized. This is needed because reflection code is // called very early in the initialization process (before diff --git a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java index 45147dc51cf42828046107aa48f7501e6d1a1f07..56f1bad4b04479c23f27f8a0b70affb0c56af468 100644 --- a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java +++ b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java @@ -273,8 +273,8 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable { private Method[] getMemberMethods() { if (memberMethods == null) { final Method[] mm = type.getDeclaredMethods(); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { AccessibleObject.setAccessible(mm, true); return null; } diff --git a/src/share/classes/sun/reflect/misc/MethodUtil.java b/src/share/classes/sun/reflect/misc/MethodUtil.java index b36993337bb2460c89d6d43d61d9ca17dec2718c..9c1bfbea41fceaab140489762ca53d85a23f5b4b 100644 --- a/src/share/classes/sun/reflect/misc/MethodUtil.java +++ b/src/share/classes/sun/reflect/misc/MethodUtil.java @@ -67,7 +67,7 @@ public final class MethodUtil extends SecureClassLoader { super(); } - public static Method getMethod(Class cls, String name, Class[] args) + public static Method getMethod(Class cls, String name, Class[] args) throws NoSuchMethodException { ReflectUtil.checkPackageAccess(cls); return cls.getMethod(name, args); @@ -89,7 +89,7 @@ public final class MethodUtil extends SecureClassLoader { if (System.getSecurityManager() == null) { return cls.getMethods(); } - Map sigs = new HashMap(); + Map sigs = new HashMap(); while (cls != null) { boolean done = getInternalPublicMethods(cls, sigs); if (done) { @@ -98,14 +98,14 @@ public final class MethodUtil extends SecureClassLoader { getInterfaceMethods(cls, sigs); cls = cls.getSuperclass(); } - Collection c = sigs.values(); - return (Method[]) c.toArray(new Method[c.size()]); + return sigs.values().toArray(new Method[sigs.size()]); } /* * Process the immediate interfaces of this class or interface. */ - private static void getInterfaceMethods(Class cls, Map sigs) { + private static void getInterfaceMethods(Class cls, + Map sigs) { Class[] intfs = cls.getInterfaces(); for (int i=0; i < intfs.length; i++) { Class intf = intfs[i]; @@ -120,7 +120,8 @@ public final class MethodUtil extends SecureClassLoader { * * Process the methods in this class or interface */ - private static boolean getInternalPublicMethods(Class cls, Map sigs) { + private static boolean getInternalPublicMethods(Class cls, + Map sigs) { Method[] methods = null; try { /* @@ -178,7 +179,7 @@ public final class MethodUtil extends SecureClassLoader { return done; } - private static void addMethod(Map sigs, Method method) { + private static void addMethod(Map sigs, Method method) { Signature signature = new Signature(method); if (!sigs.containsKey(signature)) { sigs.put(signature, method); @@ -186,7 +187,7 @@ public final class MethodUtil extends SecureClassLoader { /* * Superclasses beat interfaces. */ - Method old = (Method)sigs.get(signature); + Method old = sigs.get(signature); if (old.getDeclaringClass().isInterface()) { sigs.put(signature, method); } @@ -280,17 +281,15 @@ public final class MethodUtil extends SecureClassLoader { } private static Method getTrampoline() { - Method tramp = null; - try { - tramp = (Method) AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - Class[] types; - Class t = getTrampolineClass(); - Method b; - - types = new Class[] {Method.class, Object.class, Object[].class}; - b = t.getDeclaredMethod("invoke", types); + return AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Method run() throws Exception { + Class t = getTrampolineClass(); + Class[] types = { + Method.class, Object.class, Object[].class + }; + Method b = t.getDeclaredMethod("invoke", types); ((AccessibleObject)b).setAccessible(true); return b; } @@ -298,7 +297,6 @@ public final class MethodUtil extends SecureClassLoader { } catch (Exception e) { throw new InternalError("bouncer cannot be found"); } - return tramp; } diff --git a/src/share/classes/sun/rmi/log/ReliableLog.java b/src/share/classes/sun/rmi/log/ReliableLog.java index 7ac2858196a315e12624d59c0820a171ff432527..542c6d27a15a169b7a687e2232294c6fe0b969e8 100644 --- a/src/share/classes/sun/rmi/log/ReliableLog.java +++ b/src/share/classes/sun/rmi/log/ReliableLog.java @@ -140,8 +140,8 @@ public class ReliableLog { throws IOException { super(); - this.Debug = ((Boolean) AccessController.doPrivileged( - new GetBooleanAction("sun.rmi.log.debug"))).booleanValue(); + this.Debug = AccessController.doPrivileged( + new GetBooleanAction("sun.rmi.log.debug")).booleanValue(); dir = new File(dirPath); if (!(dir.exists() && dir.isDirectory())) { // create directory @@ -333,8 +333,8 @@ public class ReliableLog { private static Constructor getLogClassConstructor() { - String logClassName = ((String) AccessController.doPrivileged( - new GetPropertyAction("sun.rmi.log.class"))); + String logClassName = AccessController.doPrivileged( + new GetPropertyAction("sun.rmi.log.class")); if (logClassName != null) { try { ClassLoader loader = diff --git a/src/share/classes/sun/rmi/registry/RegistryImpl.java b/src/share/classes/sun/rmi/registry/RegistryImpl.java index 2f29cd57033517b8d277aed65ce3a481ed1c1250..7a99a014ee52666b141f5447ab1b796c0a90316b 100644 --- a/src/share/classes/sun/rmi/registry/RegistryImpl.java +++ b/src/share/classes/sun/rmi/registry/RegistryImpl.java @@ -66,8 +66,10 @@ public class RegistryImpl extends java.rmi.server.RemoteServer /* indicate compatibility with JDK 1.1.x version of class */ private static final long serialVersionUID = 4666870661827494597L; - private Hashtable bindings = new Hashtable(101); - private static Hashtable allowedAccessCache = new Hashtable(3); + private Hashtable bindings + = new Hashtable(101); + private static Hashtable allowedAccessCache + = new Hashtable(3); private static RegistryImpl registry; private static ObjID id = new ObjID(ObjID.REGISTRY_ID); @@ -119,7 +121,7 @@ public class RegistryImpl extends java.rmi.server.RemoteServer throws RemoteException, NotBoundException { synchronized (bindings) { - Remote obj = (Remote)bindings.get(name); + Remote obj = bindings.get(name); if (obj == null) throw new NotBoundException(name); return obj; @@ -136,7 +138,7 @@ public class RegistryImpl extends java.rmi.server.RemoteServer { checkAccess("Registry.bind"); synchronized (bindings) { - Remote curr = (Remote)bindings.get(name); + Remote curr = bindings.get(name); if (curr != null) throw new AlreadyBoundException(name); bindings.put(name, obj); @@ -153,7 +155,7 @@ public class RegistryImpl extends java.rmi.server.RemoteServer { checkAccess("Registry.unbind"); synchronized (bindings) { - Remote obj = (Remote)bindings.get(name); + Remote obj = bindings.get(name); if (obj == null) throw new NotBoundException(name); bindings.remove(name); @@ -203,10 +205,9 @@ public class RegistryImpl extends java.rmi.server.RemoteServer InetAddress clientHost; try { - clientHost = (InetAddress) - java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() + clientHost = java.security.AccessController.doPrivileged( + new java.security.PrivilegedExceptionAction() { + public InetAddress run() throws java.net.UnknownHostException { return InetAddress.getByName(clientHostName); @@ -228,8 +229,8 @@ public class RegistryImpl extends java.rmi.server.RemoteServer final InetAddress finalClientHost = clientHost; java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() throws java.io.IOException { + new java.security.PrivilegedExceptionAction() { + public Void run() throws java.io.IOException { /* * if a ServerSocket can be bound to the client's * address then that address must be local diff --git a/src/share/classes/sun/rmi/rmic/RemoteClass.java b/src/share/classes/sun/rmi/rmic/RemoteClass.java index 0caa07fe0677abd2c7a0a30d1eb5c82db2c473ea..7d41be36974f2a517d804e6eb95484bc78fc475b 100644 --- a/src/share/classes/sun/rmi/rmic/RemoteClass.java +++ b/src/share/classes/sun/rmi/rmic/RemoteClass.java @@ -103,7 +103,7 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { * in the array). */ public ClassDefinition[] getRemoteInterfaces() { - return (ClassDefinition[]) remoteInterfaces.clone(); + return remoteInterfaces.clone(); } /** @@ -118,7 +118,7 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { * stub/skeleton protocol. */ public Method[] getRemoteMethods() { - return (Method[]) remoteMethods.clone(); + return remoteMethods.clone(); } /** @@ -204,8 +204,8 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { * chain, add each directly-implemented interface that * somehow extends Remote to a list. */ - Vector remotesImplemented = // list of remote interfaces found - new Vector(); + Vector remotesImplemented = // list of remote interfaces found + new Vector(); for (ClassDefinition classDef = implClassDef; classDef != null;) { @@ -307,13 +307,13 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { * Now we collect the methods from all of the remote interfaces * into a hashtable. */ - Hashtable methods = new Hashtable(); + Hashtable methods = new Hashtable(); boolean errors = false; - for (Enumeration enumeration = remotesImplemented.elements(); + for (Enumeration enumeration + = remotesImplemented.elements(); enumeration.hasMoreElements();) { - ClassDefinition interfaceDef = - (ClassDefinition) enumeration.nextElement(); + ClassDefinition interfaceDef = enumeration.nextElement(); if (!collectRemoteMethods(interfaceDef, methods)) errors = true; } @@ -336,10 +336,10 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { */ String[] orderedKeys = new String[methods.size()]; int count = 0; - for (Enumeration enumeration = methods.elements(); + for (Enumeration enumeration = methods.elements(); enumeration.hasMoreElements();) { - Method m = (Method) enumeration.nextElement(); + Method m = enumeration.nextElement(); String key = m.getNameAndDescriptor(); int i; for (i = count; i > 0; --i) { @@ -353,7 +353,7 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { } remoteMethods = new Method[methods.size()]; for (int i = 0; i < remoteMethods.length; i++) { - remoteMethods[i] = (Method) methods.get(orderedKeys[i]); + remoteMethods[i] = methods.get(orderedKeys[i]); /***** */ if (env.verbose()) { System.out.print("[found remote method <" + i + ">: " + @@ -388,7 +388,7 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { * or false if an error occurred. */ private boolean collectRemoteMethods(ClassDefinition interfaceDef, - Hashtable table) + Hashtable table) { if (!interfaceDef.isInterface()) { throw new Error( @@ -529,7 +529,7 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { * the new method (see bugid 4070653). */ String key = newMethod.getNameAndDescriptor(); - Method oldMethod = (Method) table.get(key); + Method oldMethod = table.get(key); if (oldMethod != null) { newMethod = newMethod.mergeWith(oldMethod); if (newMethod == null) { @@ -684,7 +684,7 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { * methods that can be legally thrown in each of them. */ public ClassDeclaration[] getExceptions() { - return (ClassDeclaration[]) exceptions.clone(); + return exceptions.clone(); } /** @@ -789,7 +789,8 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { getNameAndDescriptor()); } - Vector legalExceptions = new Vector(); + Vector legalExceptions + = new Vector(); try { collectCompatibleExceptions( other.exceptions, exceptions, legalExceptions); @@ -814,7 +815,7 @@ public class RemoteClass implements sun.rmi.rmic.RMIConstants { */ private void collectCompatibleExceptions(ClassDeclaration[] from, ClassDeclaration[] with, - Vector list) + Vector list) throws ClassNotFound { for (int i = 0; i < from.length; i++) { diff --git a/src/share/classes/sun/rmi/rmic/newrmic/jrmp/RemoteClass.java b/src/share/classes/sun/rmi/rmic/newrmic/jrmp/RemoteClass.java index f22a652dfdb5c7390b6dc9bd23efd66cd2191767..064d2d0cc7a2c1825f3e52dd10b9c75dedc0e0ae 100644 --- a/src/share/classes/sun/rmi/rmic/newrmic/jrmp/RemoteClass.java +++ b/src/share/classes/sun/rmi/rmic/newrmic/jrmp/RemoteClass.java @@ -121,7 +121,7 @@ final class RemoteClass { * in the array). **/ ClassDoc[] remoteInterfaces() { - return (ClassDoc[]) remoteInterfaces.clone(); + return remoteInterfaces.clone(); } /** @@ -136,7 +136,7 @@ final class RemoteClass { * stub/skeleton protocol. **/ Method[] remoteMethods() { - return (Method[]) remoteMethods.clone(); + return remoteMethods.clone(); } /** @@ -559,7 +559,7 @@ final class RemoteClass { * methods that can be legally thrown by all of them. **/ ClassDoc[] exceptionTypes() { - return (ClassDoc[]) exceptionTypes.clone(); + return exceptionTypes.clone(); } /** diff --git a/src/share/classes/sun/rmi/runtime/Log.java b/src/share/classes/sun/rmi/runtime/Log.java index 3eb8ce9cf9f72d92971936bba509302ab61ed9a9..8017ee0a10f08855aec561a9d4e1a6b31d5be460 100644 --- a/src/share/classes/sun/rmi/runtime/Log.java +++ b/src/share/classes/sun/rmi/runtime/Log.java @@ -71,7 +71,7 @@ public abstract class Log { private static final LogFactory logFactory; static { boolean useOld = - Boolean.valueOf((String) java.security.AccessController. + Boolean.valueOf(java.security.AccessController. doPrivileged(new sun.security.action.GetPropertyAction( "sun.rmi.log.useOld"))).booleanValue(); @@ -179,17 +179,16 @@ public abstract class Log { private static class LoggerLog extends Log { /* alternate console handler for RMI loggers */ - private static final Handler alternateConsole = (Handler) + private static final Handler alternateConsole = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Handler run() { InternalStreamHandler alternate = new InternalStreamHandler(System.err); alternate.setLevel(Level.ALL); return alternate; } - } - ); + }); /** handler to which messages are copied */ private InternalStreamHandler copyHandler = null; @@ -206,8 +205,8 @@ public abstract class Log { if (level != null){ java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { if (!logger.isLoggable(level)) { logger.setLevel(level); } diff --git a/src/share/classes/sun/rmi/server/LoaderHandler.java b/src/share/classes/sun/rmi/server/LoaderHandler.java index d4a9183e4a368bd8002b3a86bee9058dde58fdb3..dcdecb0cc43c74f804529dad7722ab1d2a301aa5 100644 --- a/src/share/classes/sun/rmi/server/LoaderHandler.java +++ b/src/share/classes/sun/rmi/server/LoaderHandler.java @@ -70,7 +70,7 @@ public final class LoaderHandler { /** RMI class loader log level */ static final int logLevel = LogStream.parseLevel( - (String) java.security.AccessController.doPrivileged( + java.security.AccessController.doPrivileged( new GetPropertyAction("sun.rmi.loader.logLevel"))); /* loader system log */ @@ -83,7 +83,7 @@ public final class LoaderHandler { */ private static String codebaseProperty = null; static { - String prop = (String) java.security.AccessController.doPrivileged( + String prop = java.security.AccessController.doPrivileged( new GetPropertyAction("java.rmi.server.codebase")); if (prop != null && prop.trim().length() > 0) { codebaseProperty = prop; @@ -94,8 +94,8 @@ public final class LoaderHandler { private static URL[] codebaseURLs = null; /** table of class loaders that use codebase property for annotation */ - private static final Map codebaseLoaders = - Collections.synchronizedMap(new IdentityHashMap(5)); + private static final Map codebaseLoaders = + Collections.synchronizedMap(new IdentityHashMap(5)); static { for (ClassLoader codebaseLoader = ClassLoader.getSystemClassLoader(); codebaseLoader != null; @@ -111,10 +111,12 @@ public final class LoaderHandler { * references, so this table does not prevent loaders from being * garbage collected. */ - private static final HashMap loaderTable = new HashMap(5); + private static final HashMap loaderTable + = new HashMap(5); /** reference queue for cleared class loader entries */ - private static final ReferenceQueue refQueue = new ReferenceQueue(); + private static final ReferenceQueue refQueue + = new ReferenceQueue(); /* * Disallow anyone from creating one of these. @@ -757,7 +759,7 @@ public final class LoaderHandler { throws MalformedURLException { synchronized (pathToURLsCache) { - Object[] v = (Object[]) pathToURLsCache.get(path); + Object[] v = pathToURLsCache.get(path); if (v != null) { return ((URL[])v[0]); } @@ -769,13 +771,14 @@ public final class LoaderHandler { } synchronized (pathToURLsCache) { pathToURLsCache.put(path, - new Object[] {urls, new SoftReference(path)}); + new Object[] {urls, new SoftReference(path)}); } return urls; } /** map from weak(key=string) to [URL[], soft(key)] */ - private static final Map pathToURLsCache = new WeakHashMap(5); + private static final Map pathToURLsCache + = new WeakHashMap(5); /** * Convert an array of URL objects into a corresponding string @@ -853,9 +856,9 @@ public final class LoaderHandler { * in the table of RMI class loaders. */ LoaderKey key = new LoaderKey(urls, parent); - entry = (LoaderEntry) loaderTable.get(key); + entry = loaderTable.get(key); - if (entry == null || (loader = (Loader) entry.get()) == null) { + if (entry == null || (loader = entry.get()) == null) { /* * If entry was in table but it's weak reference was cleared, * remove it from the table and mark it as explicitly cleared, @@ -876,9 +879,9 @@ public final class LoaderHandler { * necessary to load classes from its codebase URL path. */ AccessControlContext acc = getLoaderAccessControlContext(urls); - loader = (Loader) java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + loader = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Loader run() { return new Loader(urls, parent); } }, acc); @@ -954,7 +957,7 @@ public final class LoaderHandler { * loader key for the loader so that the mapping can be removed from * the table efficiently when the weak reference is cleared. */ - private static class LoaderEntry extends WeakReference { + private static class LoaderEntry extends WeakReference { public LoaderKey key; @@ -983,10 +986,10 @@ public final class LoaderHandler { * getAccessControlContext() in the sun.applet.AppletPanel class. */ // begin with permissions granted to all code in current policy - PermissionCollection perms = (PermissionCollection) + PermissionCollection perms = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public PermissionCollection run() { CodeSource codesource = new CodeSource(null, (java.security.cert.Certificate[]) null); Policy p = java.security.Policy.getPolicy(); diff --git a/src/share/classes/sun/rmi/server/MarshalInputStream.java b/src/share/classes/sun/rmi/server/MarshalInputStream.java index a75b8051a5cece710332e519dc5035637138aa66..cf4e345d786c4b5c1d0a69603545036765a25a45 100644 --- a/src/share/classes/sun/rmi/server/MarshalInputStream.java +++ b/src/share/classes/sun/rmi/server/MarshalInputStream.java @@ -59,18 +59,20 @@ public class MarshalInputStream extends ObjectInputStream { * as cached at class initialization time. */ private static final boolean useCodebaseOnlyProperty = - ((Boolean) java.security.AccessController.doPrivileged( + java.security.AccessController.doPrivileged( new sun.security.action.GetBooleanAction( - "java.rmi.server.useCodebaseOnly"))).booleanValue(); + "java.rmi.server.useCodebaseOnly")).booleanValue(); /** table to hold sun classes to which access is explicitly permitted */ - protected static Map permittedSunClasses = new HashMap(3); + protected static Map> permittedSunClasses + = new HashMap>(3); /** if true, don't try superclass first in resolveClass() */ private boolean skipDefaultResolveClass = false; /** callbacks to make when done() called: maps Object to Runnable */ - private final Map doneCallbacks = new HashMap(3); + private final Map doneCallbacks + = new HashMap(3); /** * if true, load classes (if not available locally) only from the @@ -130,7 +132,7 @@ public class MarshalInputStream extends ObjectInputStream { * with that key. */ public Runnable getDoneCallback(Object key) { - return (Runnable) doneCallbacks.get(key); // not thread-safe + return doneCallbacks.get(key); // not thread-safe } /** @@ -153,9 +155,9 @@ public class MarshalInputStream extends ObjectInputStream { * the superclass's close method. */ public void done() { - Iterator iter = doneCallbacks.values().iterator(); + Iterator iter = doneCallbacks.values().iterator(); while (iter.hasNext()) { // not thread-safe - Runnable callback = (Runnable) iter.next(); + Runnable callback = iter.next(); callback.run(); } doneCallbacks.clear(); @@ -276,8 +278,7 @@ public class MarshalInputStream extends ObjectInputStream { name = perm.getName(); } - Class resolvedClass = - (Class) permittedSunClasses.get(className); + Class resolvedClass = permittedSunClasses.get(className); // if class not permitted, throw the SecurityException if ((name == null) || diff --git a/src/share/classes/sun/rmi/server/MarshalOutputStream.java b/src/share/classes/sun/rmi/server/MarshalOutputStream.java index 63aed2bee5324eb5057d958b2062701e22492d81..067a5f2ec702ce0e215e0ea60ca2608145d0d37f 100644 --- a/src/share/classes/sun/rmi/server/MarshalOutputStream.java +++ b/src/share/classes/sun/rmi/server/MarshalOutputStream.java @@ -64,8 +64,8 @@ public class MarshalOutputStream extends ObjectOutputStream super(out); this.useProtocolVersion(protocolVersion); java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { enableReplaceObject(true); return null; } diff --git a/src/share/classes/sun/rmi/server/Util.java b/src/share/classes/sun/rmi/server/Util.java index f103319ce89cc244542670d0d9288736aa1ec908..f757874416bba4afe927e910f964a001fefcfb6e 100644 --- a/src/share/classes/sun/rmi/server/Util.java +++ b/src/share/classes/sun/rmi/server/Util.java @@ -67,7 +67,7 @@ public final class Util { /** "server" package log level */ static final int logLevel = LogStream.parseLevel( - (String) AccessController.doPrivileged( + AccessController.doPrivileged( new GetPropertyAction("sun.rmi.server.logLevel"))); /** server reference log */ @@ -76,13 +76,13 @@ public final class Util { /** cached value of property java.rmi.server.ignoreStubClasses */ private static final boolean ignoreStubClasses = - ((Boolean) AccessController.doPrivileged( - new GetBooleanAction("java.rmi.server.ignoreStubClasses"))). + AccessController.doPrivileged( + new GetBooleanAction("java.rmi.server.ignoreStubClasses")). booleanValue(); /** cache of impl classes that have no corresponding stub class */ - private static final Map withoutStubs = - Collections.synchronizedMap(new WeakHashMap(11)); + private static final Map, Void> withoutStubs = + Collections.synchronizedMap(new WeakHashMap, Void>(11)); /** parameter types for stub constructor */ private static final Class[] stubConsParamTypes = { RemoteRef.class }; @@ -207,9 +207,9 @@ public final class Util { * @throws NullPointerException if remoteClass is null */ private static Class[] getRemoteInterfaces(Class remoteClass) { - ArrayList list = new ArrayList(); + ArrayList> list = new ArrayList>(); getRemoteInterfaces(list, remoteClass); - return (Class []) list.toArray(new Class[list.size()]); + return list.toArray(new Class[list.size()]); } /** @@ -220,7 +220,7 @@ public final class Util { * any illegal remote interfaces * @throws NullPointerException if the specified class or list is null */ - private static void getRemoteInterfaces(ArrayList list, Class cl) { + private static void getRemoteInterfaces(ArrayList> list, Class cl) { Class superclass = cl.getSuperclass(); if (superclass != null) { getRemoteInterfaces(list, superclass); @@ -254,7 +254,7 @@ public final class Util { * @throws IllegalArgumentException if m is an illegal remote method */ private static void checkMethod(Method m) { - Class[] ex = m.getExceptionTypes(); + Class[] ex = m.getExceptionTypes(); for (int i = 0; i < ex.length; i++) { if (ex[i].isAssignableFrom(RemoteException.class)) return; @@ -283,7 +283,7 @@ public final class Util { * pickle methods */ try { - Class stubcl = + Class stubcl = Class.forName(stubname, false, remoteClass.getClassLoader()); Constructor cons = stubcl.getConstructor(stubConsParamTypes); return (RemoteStub) cons.newInstance(new Object[] { ref }); diff --git a/src/share/classes/sun/rmi/server/WeakClassHashMap.java b/src/share/classes/sun/rmi/server/WeakClassHashMap.java index e822c26551b734eb95707f447c4d51decb46c327..331930c368034b0d7aaebe38af14f433920a962c 100644 --- a/src/share/classes/sun/rmi/server/WeakClassHashMap.java +++ b/src/share/classes/sun/rmi/server/WeakClassHashMap.java @@ -69,7 +69,7 @@ public abstract class WeakClassHashMap { synchronized (valueCell) { V value = null; if (valueCell.ref != null) { - value = (V) valueCell.ref.get(); + value = valueCell.ref.get(); } if (value == null) { value = computeValue(remoteClass); diff --git a/src/share/classes/sun/rmi/transport/DGCClient.java b/src/share/classes/sun/rmi/transport/DGCClient.java index 31784b3574a7c7e596564ea056e9bd4afb33b105..585901bbce7c5ac61e1fbf862eb53c4abe93f564 100644 --- a/src/share/classes/sun/rmi/transport/DGCClient.java +++ b/src/share/classes/sun/rmi/transport/DGCClient.java @@ -85,21 +85,21 @@ final class DGCClient { /** lease duration to request (usually ignored by server) */ private static final long leaseValue = // default 10 minutes - ((Long) AccessController.doPrivileged( + AccessController.doPrivileged( new GetLongAction("java.rmi.dgc.leaseValue", - 600000))).longValue(); + 600000)).longValue(); /** maximum interval between retries of failed clean calls */ private static final long cleanInterval = // default 3 minutes - ((Long) AccessController.doPrivileged( + AccessController.doPrivileged( new GetLongAction("sun.rmi.dgc.cleanInterval", - 180000))).longValue(); + 180000)).longValue(); /** maximum interval between complete garbage collections of local heap */ private static final long gcInterval = // default 1 hour - ((Long) AccessController.doPrivileged( + AccessController.doPrivileged( new GetLongAction("sun.rmi.dgc.client.gcInterval", - 3600000))).longValue(); + 3600000)).longValue(); /** minimum retry count for dirty calls that fail */ private static final int dirtyFailureRetries = 5; @@ -243,7 +243,7 @@ final class DGCClient { } catch (RemoteException e) { throw new Error("internal error creating DGC stub"); } - renewCleanThread = (Thread) AccessController.doPrivileged( + renewCleanThread = AccessController.doPrivileged( new NewThreadAction(new RenewCleanThread(), "RenewClean-" + endpoint, true)); renewCleanThread.start(); @@ -473,8 +473,9 @@ final class DGCClient { if (newRenewTime < renewTime) { renewTime = newRenewTime; if (interruptible) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged( + new PrivilegedAction() { + public Void run() { renewCleanThread.interrupt(); return null; } diff --git a/src/share/classes/sun/rmi/transport/Target.java b/src/share/classes/sun/rmi/transport/Target.java index 01df43800938e4c877ec4860cfbdbefb2b75adbe..6abf092d725d0a65623edc92ff5df42a3a24695d 100644 --- a/src/share/classes/sun/rmi/transport/Target.java +++ b/src/share/classes/sun/rmi/transport/Target.java @@ -321,7 +321,7 @@ public final class Target { Remote obj = getImpl(); if (obj instanceof Unreferenced) { final Unreferenced unrefObj = (Unreferenced) obj; - final Thread t = (Thread) + final Thread t = java.security.AccessController.doPrivileged( new NewThreadAction(new Runnable() { public void run() { @@ -334,8 +334,8 @@ public final class Target { * for threads that may invoke user code (see bugid 4171278). */ java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { t.setContextClassLoader(ccl); return null; } diff --git a/src/share/classes/sun/rmi/transport/Transport.java b/src/share/classes/sun/rmi/transport/Transport.java index 572a55b2bea1551303b6a9aff2b16a936ded0f5b..67e6058d95a91191c3036efd12830e8e05260125 100644 --- a/src/share/classes/sun/rmi/transport/Transport.java +++ b/src/share/classes/sun/rmi/transport/Transport.java @@ -53,7 +53,7 @@ public abstract class Transport { static final int logLevel = LogStream.parseLevel(getLogLevel()); private static String getLogLevel() { - return (String) java.security.AccessController.doPrivileged( + return java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("sun.rmi.transport.logLevel")); } @@ -171,8 +171,8 @@ public abstract class Transport { currentTransport.set(this); try { java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() throws IOException { + new java.security.PrivilegedExceptionAction() { + public Void run() throws IOException { checkAcceptPermission(acc); disp.dispatch(impl, call); return null; diff --git a/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java b/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java index 3d91ab0d179a4bbe90a3cc015612eadd34fc3c56..cb4a88e562c6677fca20a068538c80fb81b95ef6 100644 --- a/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java +++ b/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java @@ -89,8 +89,8 @@ public final class CGIHandler { static { java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public Void run() { ContentLength = Integer.getInteger("CONTENT_LENGTH", 0).intValue(); QueryString = System.getProperty("QUERY_STRING", ""); diff --git a/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java b/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java index 7498c9bfd8b03449d44a52b00ce48513eea195cb..2c972d8760f6c6116b0d802b8cff101d4fd59094 100644 --- a/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java +++ b/src/share/classes/sun/rmi/transport/proxy/HttpSendSocket.java @@ -78,7 +78,7 @@ class HttpSendSocket extends Socket implements RMISocketInfo { * property at the moment that the socket was created. */ private String lineSeparator = - (String) java.security.AccessController.doPrivileged( + java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("line.separator")); /** diff --git a/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java b/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java index 16735959e2f594dd5ed80b4b01c77974097f29b0..92d0dd77cb3a955f66a29745c836feb38ac88eb8 100644 --- a/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java +++ b/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java @@ -50,7 +50,7 @@ public class RMIMasterSocketFactory extends RMISocketFactory { static int logLevel = LogStream.parseLevel(getLogLevel()); private static String getLogLevel() { - return (String) java.security.AccessController.doPrivileged( + return java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("sun.rmi.transport.proxy.logLevel")); } @@ -63,15 +63,15 @@ public class RMIMasterSocketFactory extends RMISocketFactory { private static long connectTimeout = getConnectTimeout(); private static long getConnectTimeout() { - return ((Long) java.security.AccessController.doPrivileged( + return java.security.AccessController.doPrivileged( new GetLongAction("sun.rmi.transport.proxy.connectTimeout", - 15000))).longValue(); // default: 15 seconds + 15000)).longValue(); // default: 15 seconds } /** whether to fallback to HTTP on general connect failures */ - private static final boolean eagerHttpFallback = ((Boolean) + private static final boolean eagerHttpFallback = java.security.AccessController.doPrivileged(new GetBooleanAction( - "sun.rmi.transport.proxy.eagerHttpFallback"))).booleanValue(); + "sun.rmi.transport.proxy.eagerHttpFallback")).booleanValue(); /** table of hosts successfully connected to and the factory used */ private Hashtable successTable = new Hashtable(); @@ -100,14 +100,14 @@ public class RMIMasterSocketFactory extends RMISocketFactory { try { String proxyHost; - proxyHost = (String) java.security.AccessController.doPrivileged( + proxyHost = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("http.proxyHost")); if (proxyHost == null) - proxyHost=(String)java.security.AccessController.doPrivileged( + proxyHost = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("proxyHost")); - Boolean tmp = (Boolean)java.security.AccessController.doPrivileged( + Boolean tmp = java.security.AccessController.doPrivileged( new sun.security.action.GetBooleanAction("java.rmi.server.disableHttp")); if (!tmp.booleanValue() && @@ -178,10 +178,8 @@ public class RMIMasterSocketFactory extends RMISocketFactory { try { synchronized (connector) { - Thread t = (Thread) - java.security.AccessController.doPrivileged( - new NewThreadAction(connector, "AsyncConnector", - true)); + Thread t = java.security.AccessController.doPrivileged( + new NewThreadAction(connector, "AsyncConnector", true)); t.start(); try { diff --git a/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java b/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java index f756cd34f74fa4759df1be8e08389613b482bc4e..ac26ac6d832a759457bc00aad073d6f4e4546b95 100644 --- a/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java +++ b/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java @@ -49,7 +49,7 @@ final class ConnectionMultiplexer { static int logLevel = LogStream.parseLevel(getLogLevel()); private static String getLogLevel() { - return (String) java.security.AccessController.doPrivileged( + return java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("sun.rmi.transport.tcp.multiplex.logLevel")); } diff --git a/src/share/classes/sun/security/jgss/GSSManagerImpl.java b/src/share/classes/sun/security/jgss/GSSManagerImpl.java index 7bf0f9be2302edb2974fd99f482345a488820416..7aa401b03800a8ecd669427edb74f022d4dfe8bd 100644 --- a/src/share/classes/sun/security/jgss/GSSManagerImpl.java +++ b/src/share/classes/sun/security/jgss/GSSManagerImpl.java @@ -83,7 +83,7 @@ public class GSSManagerImpl extends GSSManager { public Oid[] getNamesForMech(Oid mech) throws GSSException { MechanismFactory factory = list.getMechFactory(mech); - return (Oid[])factory.getNameTypes().clone(); + return factory.getNameTypes().clone(); } public Oid[] getMechsForName(Oid nameType){ diff --git a/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java b/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java index 0fcbe12ff25e74b78a8edba1ddcb15b9b2a54a8a..838f6f8df1e373da5e5f8fbe18594e8166a86dc3 100644 --- a/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java +++ b/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java @@ -103,8 +103,7 @@ class InitSecContextToken extends InitialToken { apReq = new KrbApReq(apReqBytes, keys, addr); //debug("\nReceived AP-REQ and authenticated it.\n"); - EncryptionKey sessionKey - = (EncryptionKey) apReq.getCreds().getSessionKey(); + EncryptionKey sessionKey = apReq.getCreds().getSessionKey(); /* System.out.println("\n\nSession key from service ticket is: " + diff --git a/src/share/classes/sun/security/krb5/Config.java b/src/share/classes/sun/security/krb5/Config.java index 013fd1da1365c4f092e54417ac4fe367f1e607ab..a65ec8687497622681cbd304d55db431274812e6 100644 --- a/src/share/classes/sun/security/krb5/Config.java +++ b/src/share/classes/sun/security/krb5/Config.java @@ -1040,11 +1040,12 @@ public class Config { * Check if need to use DNS to locate Kerberos services */ public boolean useDNS(String name) { - boolean value = getDefaultBooleanValue(name, "libdefaults"); - if (value == false) { - value = getDefaultBooleanValue("dns_fallback", "libdefaults"); + String value = getDefault(name, "libdefaults"); + if (value == null) { + return getDefaultBooleanValue("dns_fallback", "libdefaults"); + } else { + return value.equalsIgnoreCase("true"); } - return value; } /** diff --git a/src/share/classes/sun/security/krb5/KrbTgsReq.java b/src/share/classes/sun/security/krb5/KrbTgsReq.java index 328e255e0d64ec25d566b86583bc722c25d13136..0cc54e17c454ffdc77ba4ab7f9ba2ae1639fb24c 100644 --- a/src/share/classes/sun/security/krb5/KrbTgsReq.java +++ b/src/share/classes/sun/security/krb5/KrbTgsReq.java @@ -75,108 +75,108 @@ public class KrbTgsReq extends KrbKdcReq { null); // EncryptionKey subSessionKey } - // Called by Credentials, KrbCred - KrbTgsReq( - KDCOptions options, - Credentials asCreds, - PrincipalName sname, - KerberosTime from, - KerberosTime till, - KerberosTime rtime, - int[] eTypes, - HostAddresses addresses, - AuthorizationData authorizationData, - Ticket[] additionalTickets, - EncryptionKey subKey) throws KrbException, IOException { - - princName = asCreds.client; - servName = sname; - ctime = new KerberosTime(KerberosTime.NOW); - - - // check if they are valid arguments. The optional fields - // should be consistent with settings in KDCOptions. - if (options.get(KDCOptions.FORWARDABLE) && - (!(asCreds.flags.get(Krb5.TKT_OPTS_FORWARDABLE)))) { - throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); - } - if (options.get(KDCOptions.FORWARDED)) { - if (!(asCreds.flags.get(KDCOptions.FORWARDABLE))) - throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); - } - if (options.get(KDCOptions.PROXIABLE) && - (!(asCreds.flags.get(Krb5.TKT_OPTS_PROXIABLE)))) { - throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); - } - if (options.get(KDCOptions.PROXY)) { - if (!(asCreds.flags.get(KDCOptions.PROXIABLE))) - throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); - } - if (options.get(KDCOptions.ALLOW_POSTDATE) && - (!(asCreds.flags.get(Krb5.TKT_OPTS_MAY_POSTDATE)))) { - throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); - } - if (options.get(KDCOptions.RENEWABLE) && - (!(asCreds.flags.get(Krb5.TKT_OPTS_RENEWABLE)))) { - throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); - } - - if (options.get(KDCOptions.POSTDATED)) { - if (!(asCreds.flags.get(KDCOptions.POSTDATED))) - throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); - } else { - if (from != null) from = null; - } - if (options.get(KDCOptions.RENEWABLE)) { - if (!(asCreds.flags.get(KDCOptions.RENEWABLE))) - throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); - } else { - if (rtime != null) rtime = null; - } - if (options.get(KDCOptions.ENC_TKT_IN_SKEY)) { - if (additionalTickets == null) - throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); - // in TGS_REQ there could be more than one additional - // tickets, but in file-based credential cache, - // there is only one additional ticket field. - secondTicket = additionalTickets[0]; - } else { - if (additionalTickets != null) - additionalTickets = null; - } - - tgsReqMessg = createRequest( - options, - asCreds.ticket, - asCreds.key, - ctime, - princName, - princName.getRealm(), - servName, - from, - till, - rtime, - eTypes, - addresses, - authorizationData, - additionalTickets, - subKey); - obuf = tgsReqMessg.asn1Encode(); - - // XXX We need to revisit this to see if can't move it - // up such that FORWARDED flag set in the options - // is included in the marshaled request. - /* - * If this is based on a forwarded ticket, record that in the - * options, because the returned TgsRep will contain the - * FORWARDED flag set. - */ - if (asCreds.flags.get(KDCOptions.FORWARDED)) - options.set(KDCOptions.FORWARDED, true); - + // Called by Credentials, KrbCred + KrbTgsReq( + KDCOptions options, + Credentials asCreds, + PrincipalName sname, + KerberosTime from, + KerberosTime till, + KerberosTime rtime, + int[] eTypes, + HostAddresses addresses, + AuthorizationData authorizationData, + Ticket[] additionalTickets, + EncryptionKey subKey) throws KrbException, IOException { + + princName = asCreds.client; + servName = sname; + ctime = new KerberosTime(KerberosTime.NOW); + + + // check if they are valid arguments. The optional fields + // should be consistent with settings in KDCOptions. + if (options.get(KDCOptions.FORWARDABLE) && + (!(asCreds.flags.get(Krb5.TKT_OPTS_FORWARDABLE)))) { + throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); + } + if (options.get(KDCOptions.FORWARDED)) { + if (!(asCreds.flags.get(KDCOptions.FORWARDABLE))) + throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); + } + if (options.get(KDCOptions.PROXIABLE) && + (!(asCreds.flags.get(Krb5.TKT_OPTS_PROXIABLE)))) { + throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); + } + if (options.get(KDCOptions.PROXY)) { + if (!(asCreds.flags.get(KDCOptions.PROXIABLE))) + throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); + } + if (options.get(KDCOptions.ALLOW_POSTDATE) && + (!(asCreds.flags.get(Krb5.TKT_OPTS_MAY_POSTDATE)))) { + throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); + } + if (options.get(KDCOptions.RENEWABLE) && + (!(asCreds.flags.get(Krb5.TKT_OPTS_RENEWABLE)))) { + throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); + } + if (options.get(KDCOptions.POSTDATED)) { + if (!(asCreds.flags.get(KDCOptions.POSTDATED))) + throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); + } else { + if (from != null) from = null; + } + if (options.get(KDCOptions.RENEWABLE)) { + if (!(asCreds.flags.get(KDCOptions.RENEWABLE))) + throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); + } else { + if (rtime != null) rtime = null; + } + if (options.get(KDCOptions.ENC_TKT_IN_SKEY)) { + if (additionalTickets == null) + throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); + // in TGS_REQ there could be more than one additional + // tickets, but in file-based credential cache, + // there is only one additional ticket field. + secondTicket = additionalTickets[0]; + } else { + if (additionalTickets != null) + additionalTickets = null; } + tgsReqMessg = createRequest( + options, + asCreds.ticket, + asCreds.key, + ctime, + princName, + princName.getRealm(), + servName, + from, + till, + rtime, + eTypes, + addresses, + authorizationData, + additionalTickets, + subKey); + obuf = tgsReqMessg.asn1Encode(); + + // XXX We need to revisit this to see if can't move it + // up such that FORWARDED flag set in the options + // is included in the marshaled request. + /* + * If this is based on a forwarded ticket, record that in the + * options, because the returned TgsRep will contain the + * FORWARDED flag set. + */ + if (asCreds.flags.get(KDCOptions.FORWARDED)) + options.set(KDCOptions.FORWARDED, true); + + + } + /** * Sends a TGS request to the realm of the target. * @throws KrbException diff --git a/src/share/classes/sun/security/krb5/internal/APRep.java b/src/share/classes/sun/security/krb5/internal/APRep.java index 17aeb89797c9ff57636bc6c6b7f26ec1c19bd890..53c3b58eaac2c419d7a45dc5b11b1914d39f1f48 100644 --- a/src/share/classes/sun/security/krb5/internal/APRep.java +++ b/src/share/classes/sun/security/krb5/internal/APRep.java @@ -54,81 +54,88 @@ import java.math.BigInteger; * http://www.ietf.org/rfc/rfc4120.txt. */ public class APRep { - public int pvno; - public int msgType; - public EncryptedData encPart; - public APRep(EncryptedData new_encPart) { - pvno = Krb5.PVNO; - msgType = Krb5.KRB_AP_REP; - encPart = new_encPart; - } + public int pvno; + public int msgType; + public EncryptedData encPart; - public APRep(byte[] data) throws Asn1Exception, - KrbApErrException, IOException { - init(new DerValue(data)); - } + public APRep(EncryptedData new_encPart) { + pvno = Krb5.PVNO; + msgType = Krb5.KRB_AP_REP; + encPart = new_encPart; + } + + public APRep(byte[] data) throws Asn1Exception, + KrbApErrException, IOException { + init(new DerValue(data)); + } public APRep(DerValue encoding) throws Asn1Exception, - KrbApErrException, IOException { - init(encoding); - } + KrbApErrException, IOException { + init(encoding); + } - /** - * Initializes an APRep object. - * @param encoding a single DER-encoded value. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * @exception KrbApErrException if the value read from the DER-encoded data - * stream does not match the pre-defined value. - */ + /** + * Initializes an APRep object. + * @param encoding a single DER-encoded value. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * @exception KrbApErrException if the value read from the DER-encoded data + * stream does not match the pre-defined value. + */ private void init(DerValue encoding) throws Asn1Exception, - KrbApErrException, IOException { + KrbApErrException, IOException { - if (((encoding.getTag() & (byte)(0x1F)) != Krb5.KRB_AP_REP) - || (encoding.isApplication() != true) - || (encoding.isConstructed() != true)) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - DerValue der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) + if (((encoding.getTag() & (byte) (0x1F)) != Krb5.KRB_AP_REP) + || (encoding.isApplication() != true) + || (encoding.isConstructed() != true)) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); - DerValue subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) != (byte)0x00) + } + DerValue der = encoding.getData().getDerValue(); + if (der.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + DerValue subDer = der.getData().getDerValue(); + if ((subDer.getTag() & (byte) 0x1F) != (byte) 0x00) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } pvno = subDer.getData().getBigInteger().intValue(); - if (pvno != Krb5.PVNO) - throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) != (byte)0x01) + if (pvno != Krb5.PVNO) { + throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & (byte) 0x1F) != (byte) 0x01) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); - msgType = subDer.getData().getBigInteger().intValue(); - if (msgType != Krb5.KRB_AP_REP) - throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE); - encPart = EncryptedData.parse(der.getData(), (byte)0x02, false); - if (der.getData().available() > 0) + } + msgType = subDer.getData().getBigInteger().intValue(); + if (msgType != Krb5.KRB_AP_REP) { + throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE); + } + encPart = EncryptedData.parse(der.getData(), (byte) 0x02, false); + if (der.getData().available() > 0) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); } + } - /** - * Encodes an APRep object. - * @return byte array of encoded APRep object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - public byte[] asn1Encode() throws Asn1Exception, IOException { + /** + * Encodes an APRep object. + * @return byte array of encoded APRep object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { DerOutputStream bytes = new DerOutputStream(); - DerOutputStream temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(pvno)); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp); - temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(msgType)); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), encPart.asn1Encode()); - temp = new DerOutputStream(); - temp.write(DerValue.tag_Sequence, bytes); - DerOutputStream aprep = new DerOutputStream(); - aprep.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte)0x0F), temp); - return aprep.toByteArray(); - } - + DerOutputStream temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(pvno)); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), temp); + temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(msgType)); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x01), temp); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x02), encPart.asn1Encode()); + temp = new DerOutputStream(); + temp.write(DerValue.tag_Sequence, bytes); + DerOutputStream aprep = new DerOutputStream(); + aprep.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte) 0x0F), temp); + return aprep.toByteArray(); + } } diff --git a/src/share/classes/sun/security/krb5/internal/APReq.java b/src/share/classes/sun/security/krb5/internal/APReq.java index 328f833df6291b390ce57e427712494b2b565b21..3a1dc7c2222eeb9a69d9e2bbc7576fe63a2cee11 100644 --- a/src/share/classes/sun/security/krb5/internal/APReq.java +++ b/src/share/classes/sun/security/krb5/internal/APReq.java @@ -54,94 +54,98 @@ import java.math.BigInteger; * * http://www.ietf.org/rfc/rfc4120.txt. */ - public class APReq { - public int pvno; - public int msgType; - public APOptions apOptions; - public Ticket ticket; - public EncryptedData authenticator; - public APReq( - APOptions new_apOptions, - Ticket new_ticket, - EncryptedData new_authenticator - ) { - pvno = Krb5.PVNO; - msgType = Krb5.KRB_AP_REQ; - apOptions = new_apOptions; - ticket = new_ticket; - authenticator = new_authenticator; - } + public int pvno; + public int msgType; + public APOptions apOptions; + public Ticket ticket; + public EncryptedData authenticator; + + public APReq( + APOptions new_apOptions, + Ticket new_ticket, + EncryptedData new_authenticator) { + pvno = Krb5.PVNO; + msgType = Krb5.KRB_AP_REQ; + apOptions = new_apOptions; + ticket = new_ticket; + authenticator = new_authenticator; + } - public APReq(byte[] data) throws Asn1Exception,IOException, KrbApErrException, RealmException { + public APReq(byte[] data) throws Asn1Exception, IOException, KrbApErrException, RealmException { init(new DerValue(data)); - } + } public APReq(DerValue encoding) throws Asn1Exception, IOException, KrbApErrException, RealmException { - init(encoding); - } + init(encoding); + } - /** - * Initializes an APReq object. - * @param encoding a single DER-encoded value. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * @exception KrbApErrException if the value read from the DER-encoded data stream does not match the pre-defined value. - * @exception RealmException if an error occurs while parsing a Realm object. - */ - private void init(DerValue encoding) throws Asn1Exception, - IOException, KrbApErrException, RealmException { - DerValue der, subDer; - if (((encoding.getTag() & (byte)0x1F) != Krb5.KRB_AP_REQ) - || (encoding.isApplication() != true) - || (encoding.isConstructed() != true)) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) != (byte)0x00) + /** + * Initializes an APReq object. + * @param encoding a single DER-encoded value. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * @exception KrbApErrException if the value read from the DER-encoded data stream does not match the pre-defined value. + * @exception RealmException if an error occurs while parsing a Realm object. + */ + private void init(DerValue encoding) throws Asn1Exception, + IOException, KrbApErrException, RealmException { + DerValue der, subDer; + if (((encoding.getTag() & (byte) 0x1F) != Krb5.KRB_AP_REQ) + || (encoding.isApplication() != true) + || (encoding.isConstructed() != true)) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + der = encoding.getData().getDerValue(); + if (der.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & (byte) 0x1F) != (byte) 0x00) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } pvno = subDer.getData().getBigInteger().intValue(); - if (pvno != Krb5.PVNO) - throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) != (byte)0x01) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - msgType = subDer.getData().getBigInteger().intValue(); - if (msgType != Krb5.KRB_AP_REQ) - throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE); - apOptions = APOptions.parse(der.getData(), (byte)0x02, false); - ticket = Ticket.parse(der.getData(), (byte)0x03, false); - authenticator = EncryptedData.parse(der.getData(), (byte)0x04, false); - if (der.getData().available() > 0) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + if (pvno != Krb5.PVNO) { + throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION); } - - /** - * Encodes an APReq object. - * @return byte array of encoded APReq object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - public byte[] asn1Encode() throws Asn1Exception, IOException { - DerOutputStream bytes = new DerOutputStream(); - DerOutputStream temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(pvno)); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp); - temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(msgType)); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), apOptions.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), ticket.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), authenticator.asn1Encode()); - temp = new DerOutputStream(); - temp.write(DerValue.tag_Sequence, bytes); - DerOutputStream apreq = new DerOutputStream(); - apreq.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte)0x0E), temp); - return apreq.toByteArray(); - + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & (byte) 0x1F) != (byte) 0x01) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); } + msgType = subDer.getData().getBigInteger().intValue(); + if (msgType != Krb5.KRB_AP_REQ) { + throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE); + } + apOptions = APOptions.parse(der.getData(), (byte) 0x02, false); + ticket = Ticket.parse(der.getData(), (byte) 0x03, false); + authenticator = EncryptedData.parse(der.getData(), (byte) 0x04, false); + if (der.getData().available() > 0) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + } + /** + * Encodes an APReq object. + * @return byte array of encoded APReq object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { + DerOutputStream bytes = new DerOutputStream(); + DerOutputStream temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(pvno)); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), temp); + temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(msgType)); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x01), temp); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x02), apOptions.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x03), ticket.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x04), authenticator.asn1Encode()); + temp = new DerOutputStream(); + temp.write(DerValue.tag_Sequence, bytes); + DerOutputStream apreq = new DerOutputStream(); + apreq.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte) 0x0E), temp); + return apreq.toByteArray(); + } } diff --git a/src/share/classes/sun/security/krb5/internal/ASRep.java b/src/share/classes/sun/security/krb5/internal/ASRep.java index df0ebac655062ee4828eeae58880de2a7bb0fa92..a59811d97f9a88467fe736bc4ae03758ca77805a 100644 --- a/src/share/classes/sun/security/krb5/internal/ASRep.java +++ b/src/share/classes/sun/security/krb5/internal/ASRep.java @@ -40,30 +40,28 @@ import java.io.IOException; public class ASRep extends KDCRep { - public ASRep( - PAData[] new_pAData, - Realm new_crealm, - PrincipalName new_cname, - Ticket new_ticket, - EncryptedData new_encPart - ) throws IOException { - super(new_pAData, new_crealm, new_cname, new_ticket, - new_encPart, Krb5.KRB_AS_REP); - } + public ASRep( + PAData[] new_pAData, + Realm new_crealm, + PrincipalName new_cname, + Ticket new_ticket, + EncryptedData new_encPart) throws IOException { + super(new_pAData, new_crealm, new_cname, new_ticket, + new_encPart, Krb5.KRB_AS_REP); + } - public ASRep(byte[] data) throws Asn1Exception, - RealmException, KrbApErrException, IOException { - init(new DerValue(data)); - } + public ASRep(byte[] data) throws Asn1Exception, + RealmException, KrbApErrException, IOException { + init(new DerValue(data)); + } - public ASRep(DerValue encoding) throws Asn1Exception, - RealmException, KrbApErrException, IOException { - init(encoding); - } - - private void init(DerValue encoding) throws Asn1Exception, - RealmException, KrbApErrException, IOException { - init(encoding, Krb5.KRB_AS_REP); - } + public ASRep(DerValue encoding) throws Asn1Exception, + RealmException, KrbApErrException, IOException { + init(encoding); + } + private void init(DerValue encoding) throws Asn1Exception, + RealmException, KrbApErrException, IOException { + init(encoding, Krb5.KRB_AS_REP); + } } diff --git a/src/share/classes/sun/security/krb5/internal/ASReq.java b/src/share/classes/sun/security/krb5/internal/ASReq.java index 743316c6c0c9109d794165952944a0b69bb028d6..b5907398bf71a2e6804ac998ca8a6cb96080bbe5 100644 --- a/src/share/classes/sun/security/krb5/internal/ASReq.java +++ b/src/share/classes/sun/security/krb5/internal/ASReq.java @@ -36,20 +36,19 @@ import java.io.IOException; public class ASReq extends KDCReq { - public ASReq(PAData[] new_pAData, KDCReqBody new_reqBody) throws IOException { - super(new_pAData, new_reqBody, Krb5.KRB_AS_REQ); - } + public ASReq(PAData[] new_pAData, KDCReqBody new_reqBody) throws IOException { + super(new_pAData, new_reqBody, Krb5.KRB_AS_REQ); + } - public ASReq(byte[] data) throws Asn1Exception, KrbException, IOException { - init(new DerValue(data)); - } + public ASReq(byte[] data) throws Asn1Exception, KrbException, IOException { + init(new DerValue(data)); + } public ASReq(DerValue encoding) throws Asn1Exception, KrbException, IOException { - init(encoding); - } - - private void init(DerValue encoding) throws Asn1Exception, IOException, KrbException { - super.init(encoding, Krb5.KRB_AS_REQ); - } + init(encoding); + } + private void init(DerValue encoding) throws Asn1Exception, IOException, KrbException { + super.init(encoding, Krb5.KRB_AS_REQ); + } } diff --git a/src/share/classes/sun/security/krb5/internal/Authenticator.java b/src/share/classes/sun/security/krb5/internal/Authenticator.java index 57b6156c0e5e2342d09eee273dcc6baa94c7ed3e..49cf1709ee2c3bca33acc9c7a81d0c63a9a1236d 100644 --- a/src/share/classes/sun/security/krb5/internal/Authenticator.java +++ b/src/share/classes/sun/security/krb5/internal/Authenticator.java @@ -34,6 +34,7 @@ import sun.security.util.*; import java.util.Vector; import java.io.IOException; import java.math.BigInteger; + /** * Implements the ASN.1 Authenticator type. * @@ -58,6 +59,7 @@ import java.math.BigInteger; * http://www.ietf.org/rfc/rfc4120.txt. */ public class Authenticator { + public int authenticator_vno; public Realm crealm; public PrincipalName cname; @@ -68,137 +70,145 @@ public class Authenticator { Integer seqNumber; //optional public AuthorizationData authorizationData; //optional - public Authenticator ( - Realm new_crealm, - PrincipalName new_cname, - Checksum new_cksum, - int new_cusec, - KerberosTime new_ctime, - EncryptionKey new_subKey, - Integer new_seqNumber, - AuthorizationData new_authorizationData - ) { - authenticator_vno = Krb5.AUTHNETICATOR_VNO; - crealm = new_crealm; - cname = new_cname; - cksum = new_cksum; - cusec = new_cusec; - ctime = new_ctime; - subKey = new_subKey; - seqNumber = new_seqNumber; - authorizationData = new_authorizationData; - } + public Authenticator( + Realm new_crealm, + PrincipalName new_cname, + Checksum new_cksum, + int new_cusec, + KerberosTime new_ctime, + EncryptionKey new_subKey, + Integer new_seqNumber, + AuthorizationData new_authorizationData) { + authenticator_vno = Krb5.AUTHNETICATOR_VNO; + crealm = new_crealm; + cname = new_cname; + cksum = new_cksum; + cusec = new_cusec; + ctime = new_ctime; + subKey = new_subKey; + seqNumber = new_seqNumber; + authorizationData = new_authorizationData; + } - public Authenticator(byte[] data) - throws Asn1Exception, IOException, KrbApErrException, RealmException { - init(new DerValue(data)); - } + public Authenticator(byte[] data) + throws Asn1Exception, IOException, KrbApErrException, RealmException { + init(new DerValue(data)); + } - public Authenticator(DerValue encoding) - throws Asn1Exception,IOException, KrbApErrException, RealmException { - init(encoding); - } + public Authenticator(DerValue encoding) + throws Asn1Exception, IOException, KrbApErrException, RealmException { + init(encoding); + } - /** - * Initializes an Authenticator object. - * @param encoding a single DER-encoded value. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * @exception KrbApErrException if the value read from the DER-encoded data - * stream does not match the pre-defined value. - * @exception RealmException if an error occurs while parsing a Realm object. - */ - private void init(DerValue encoding) - throws Asn1Exception, IOException, KrbApErrException, RealmException { - DerValue der, subDer; - //may not be the correct error code for a tag - //mismatch on an encrypted structure - if (((encoding.getTag() & (byte)0x1F) != (byte)0x02) - || (encoding.isApplication() != true) - || (encoding.isConstructed() != true)) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) + /** + * Initializes an Authenticator object. + * @param encoding a single DER-encoded value. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * @exception KrbApErrException if the value read from the DER-encoded data + * stream does not match the pre-defined value. + * @exception RealmException if an error occurs while parsing a Realm object. + */ + private void init(DerValue encoding) + throws Asn1Exception, IOException, KrbApErrException, RealmException { + DerValue der, subDer; + //may not be the correct error code for a tag + //mismatch on an encrypted structure + if (((encoding.getTag() & (byte) 0x1F) != (byte) 0x02) + || (encoding.isApplication() != true) + || (encoding.isConstructed() != true)) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) != (byte)0x00) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + der = encoding.getData().getDerValue(); + if (der.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & (byte) 0x1F) != (byte) 0x00) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } authenticator_vno = subDer.getData().getBigInteger().intValue(); - if (authenticator_vno != 5) + if (authenticator_vno != 5) { throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION); - crealm = Realm.parse(der.getData(), (byte)0x01, false); - cname = PrincipalName.parse(der.getData(), (byte)0x02, false); - cksum = Checksum.parse(der.getData(), (byte)0x03, true); + } + crealm = Realm.parse(der.getData(), (byte) 0x01, false); + cname = PrincipalName.parse(der.getData(), (byte) 0x02, false); + cksum = Checksum.parse(der.getData(), (byte) 0x03, true); + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & (byte) 0x1F) == 0x04) { + cusec = subDer.getData().getBigInteger().intValue(); + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + ctime = KerberosTime.parse(der.getData(), (byte) 0x05, false); + if (der.getData().available() > 0) { + subKey = EncryptionKey.parse(der.getData(), (byte) 0x06, true); + } else { + subKey = null; + seqNumber = null; + authorizationData = null; + } + if (der.getData().available() > 0) { + if ((der.getData().peekByte() & 0x1F) == 0x07) { subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) == 0x04) { - cusec = subDer.getData().getBigInteger().intValue(); - } - else throw new Asn1Exception(Krb5.ASN1_BAD_ID); - ctime = KerberosTime.parse(der.getData(), (byte)0x05, false); - if (der.getData().available() > 0) { - subKey = EncryptionKey.parse(der.getData(), (byte)0x06, true); - } - else { - subKey = null; - seqNumber = null; - authorizationData = null; - } - if (der.getData().available() > 0) { - if ((der.getData().peekByte() & 0x1F) == 0x07) { - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) == (byte)0x07) - seqNumber = new Integer(subDer.getData().getBigInteger().intValue()); - } + if ((subDer.getTag() & (byte) 0x1F) == (byte) 0x07) { + seqNumber = new Integer(subDer.getData().getBigInteger().intValue()); } - else { - seqNumber = null; - authorizationData = null; - } - if (der.getData().available() > 0) { - authorizationData = AuthorizationData.parse(der.getData(), (byte)0x08, true); - } - else authorizationData = null; - if (der.getData().available() > 0) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + } else { + seqNumber = null; + authorizationData = null; + } + if (der.getData().available() > 0) { + authorizationData = AuthorizationData.parse(der.getData(), (byte) 0x08, true); + } else { + authorizationData = null; + } + if (der.getData().available() > 0) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); } + } - /** - * Encodes an Authenticator object. - * @return byte array of encoded Authenticator object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - public byte[] asn1Encode() throws Asn1Exception, IOException { - Vector v = new Vector (); - DerOutputStream temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(authenticator_vno)); - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp.toByteArray())); - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), crealm.asn1Encode())); - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), cname.asn1Encode())); - if (cksum != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), cksum.asn1Encode())); - temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(cusec)); - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), temp.toByteArray())); - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), ctime.asn1Encode())); - if (subKey != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x06), subKey.asn1Encode())); - if (seqNumber != null) { - temp = new DerOutputStream(); - // encode as an unsigned integer (UInt32) - temp.putInteger(BigInteger.valueOf(seqNumber.longValue())); - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x07), temp.toByteArray())); - } - if (authorizationData != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x08), authorizationData.asn1Encode())); - DerValue der[] = new DerValue[v.size()]; - v.copyInto(der); - temp = new DerOutputStream(); - temp.putSequence(der); - DerOutputStream out = new DerOutputStream(); - out.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte)0x02), temp); - return out.toByteArray(); + /** + * Encodes an Authenticator object. + * @return byte array of encoded Authenticator object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { + Vector v = new Vector(); + DerOutputStream temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(authenticator_vno)); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), temp.toByteArray())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x01), crealm.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x02), cname.asn1Encode())); + if (cksum != null) { + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x03), cksum.asn1Encode())); + } + temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(cusec)); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x04), temp.toByteArray())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x05), ctime.asn1Encode())); + if (subKey != null) { + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x06), subKey.asn1Encode())); } + if (seqNumber != null) { + temp = new DerOutputStream(); + // encode as an unsigned integer (UInt32) + temp.putInteger(BigInteger.valueOf(seqNumber.longValue())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x07), temp.toByteArray())); + } + if (authorizationData != null) { + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x08), authorizationData.asn1Encode())); + } + DerValue der[] = new DerValue[v.size()]; + v.copyInto(der); + temp = new DerOutputStream(); + temp.putSequence(der); + DerOutputStream out = new DerOutputStream(); + out.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte) 0x02), temp); + return out.toByteArray(); + } public final Checksum getChecksum() { return cksum; @@ -211,5 +221,4 @@ public class Authenticator { public final EncryptionKey getSubKey() { return subKey; } - } diff --git a/src/share/classes/sun/security/krb5/internal/AuthorizationData.java b/src/share/classes/sun/security/krb5/internal/AuthorizationData.java index d6f04d748b521c1a3e0ca14cd5fb7830721eec28..269edec71a1500d9843a2f3186253227fd404312 100644 --- a/src/share/classes/sun/security/krb5/internal/AuthorizationData.java +++ b/src/share/classes/sun/security/krb5/internal/AuthorizationData.java @@ -53,82 +53,81 @@ import sun.security.krb5.internal.ccache.CCacheOutputStream; * } */ public class AuthorizationData implements Cloneable { - private AuthorizationDataEntry[] entry = null; - private AuthorizationData() { - } + private AuthorizationDataEntry[] entry = null; + + private AuthorizationData() { + } - public AuthorizationData( - AuthorizationDataEntry[] new_entries - ) throws IOException { - if (new_entries != null) { - entry = new AuthorizationDataEntry[new_entries.length]; - for (int i = 0; i < new_entries.length; i++) { - if (new_entries[i] == null) { - throw new IOException("Cannot create an AuthorizationData"); - } else { - entry[i] = (AuthorizationDataEntry)new_entries[i].clone(); - } - } + public AuthorizationData(AuthorizationDataEntry[] new_entries) + throws IOException { + if (new_entries != null) { + entry = new AuthorizationDataEntry[new_entries.length]; + for (int i = 0; i < new_entries.length; i++) { + if (new_entries[i] == null) { + throw new IOException("Cannot create an AuthorizationData"); + } else { + entry[i] = (AuthorizationDataEntry) new_entries[i].clone(); } + } } + } - public AuthorizationData( - AuthorizationDataEntry new_entry - ) { - entry = new AuthorizationDataEntry[1]; - entry[0] = new_entry; - } + public AuthorizationData(AuthorizationDataEntry new_entry) { + entry = new AuthorizationDataEntry[1]; + entry[0] = new_entry; + } - public Object clone() { - AuthorizationData new_authorizationData = - new AuthorizationData(); - if (entry != null) { - new_authorizationData.entry = - new AuthorizationDataEntry[entry.length]; - for (int i = 0; i < entry.length; i++) - new_authorizationData.entry[i] = - (AuthorizationDataEntry)entry[i].clone(); - } - return new_authorizationData; + public Object clone() { + AuthorizationData new_authorizationData = + new AuthorizationData(); + if (entry != null) { + new_authorizationData.entry = + new AuthorizationDataEntry[entry.length]; + for (int i = 0; i < entry.length; i++) { + new_authorizationData.entry[i] = + (AuthorizationDataEntry) entry[i].clone(); + } } + return new_authorizationData; + } - /** - * Constructs a new AuthorizationData, instance. - * @param der a single DER-encoded value. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - public AuthorizationData(DerValue der) throws Asn1Exception, IOException { - Vector v = - new Vector (); - if (der.getTag() != DerValue.tag_Sequence) { - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - } - while (der.getData().available() > 0) { - v.addElement(new AuthorizationDataEntry(der.getData().getDerValue())); - } - if (v.size() > 0) { - entry = new AuthorizationDataEntry[v.size()]; - v.copyInto(entry); - } + /** + * Constructs a new AuthorizationData, instance. + * @param der a single DER-encoded value. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public AuthorizationData(DerValue der) throws Asn1Exception, IOException { + Vector v = + new Vector(); + if (der.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + while (der.getData().available() > 0) { + v.addElement(new AuthorizationDataEntry(der.getData().getDerValue())); } + if (v.size() > 0) { + entry = new AuthorizationDataEntry[v.size()]; + v.copyInto(entry); + } + } - /** - * Encodes an AuthorizationData object. - * @return byte array of encoded AuthorizationData object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - public byte[] asn1Encode() throws Asn1Exception, IOException { - DerOutputStream bytes = new DerOutputStream(); - DerValue der[] = new DerValue[entry.length]; - for (int i = 0; i < entry.length; i++) { - der[i] = new DerValue(entry[i].asn1Encode()); - } - bytes.putSequence(der); - return bytes.toByteArray(); + /** + * Encodes an AuthorizationData object. + * @return byte array of encoded AuthorizationData object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { + DerOutputStream bytes = new DerOutputStream(); + DerValue der[] = new DerValue[entry.length]; + for (int i = 0; i < entry.length; i++) { + der[i] = new DerValue(entry[i].asn1Encode()); } + bytes.putSequence(der); + return bytes.toByteArray(); + } /** * Parse (unmarshal) an AuthorizationData object from a DER input stream. @@ -143,31 +142,30 @@ public class AuthorizationData implements Cloneable { * @return an instance of AuthorizationData. * */ - public static AuthorizationData parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException{ - if ((optional) && (((byte)data.peekByte() & (byte)0x1F) != explicitTag)) { - return null; - } - DerValue der = data.getDerValue(); - if (explicitTag != (der.getTag() & (byte)0x1F)) { - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - } - else { - DerValue subDer = der.getData().getDerValue(); - return new AuthorizationData(subDer); - } + public static AuthorizationData parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException { + if ((optional) && (((byte) data.peekByte() & (byte) 0x1F) != explicitTag)) { + return null; + } + DerValue der = data.getDerValue(); + if (explicitTag != (der.getTag() & (byte) 0x1F)) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } else { + DerValue subDer = der.getData().getDerValue(); + return new AuthorizationData(subDer); } + } - /** - * Writes AuthorizationData data fields to a output stream. - * - * @param cos a CCacheOutputStream to be written to. - * @exception IOException if an I/O exception occurs. - */ - public void writeAuth(CCacheOutputStream cos) throws IOException { - for (int i = 0; i < entry.length; i++) { - entry[i].writeEntry(cos); - } + /** + * Writes AuthorizationData data fields to a output stream. + * + * @param cos a CCacheOutputStream to be written to. + * @exception IOException if an I/O exception occurs. + */ + public void writeAuth(CCacheOutputStream cos) throws IOException { + for (int i = 0; i < entry.length; i++) { + entry[i].writeEntry(cos); } + } public String toString() { String retVal = "AuthorizationData:\n"; diff --git a/src/share/classes/sun/security/krb5/internal/AuthorizationDataEntry.java b/src/share/classes/sun/security/krb5/internal/AuthorizationDataEntry.java index 3ad64576175750ed08dbb0ca8f6b94bbdd6e4465..e159c85fc00947bec63608e1b5aaaa3bcccf6a30 100644 --- a/src/share/classes/sun/security/krb5/internal/AuthorizationDataEntry.java +++ b/src/share/classes/sun/security/krb5/internal/AuthorizationDataEntry.java @@ -35,90 +35,90 @@ import sun.security.krb5.Asn1Exception; import sun.security.krb5.internal.ccache.CCacheOutputStream; public class AuthorizationDataEntry implements Cloneable { - public int adType; - public byte[] adData; - private AuthorizationDataEntry() { - } + public int adType; + public byte[] adData; - public AuthorizationDataEntry( - int new_adType, - byte[] new_adData - ) { - adType = new_adType; - adData = new_adData; - } + private AuthorizationDataEntry() { + } + + public AuthorizationDataEntry( + int new_adType, + byte[] new_adData) { + adType = new_adType; + adData = new_adData; + } - public Object clone() { - AuthorizationDataEntry new_authorizationDataEntry = - new AuthorizationDataEntry(); - new_authorizationDataEntry.adType = adType; - if (adData != null) { - new_authorizationDataEntry.adData = new byte[adData.length]; - System.arraycopy(adData, 0, - new_authorizationDataEntry.adData, 0, adData.length); - } - return new_authorizationDataEntry; + public Object clone() { + AuthorizationDataEntry new_authorizationDataEntry = + new AuthorizationDataEntry(); + new_authorizationDataEntry.adType = adType; + if (adData != null) { + new_authorizationDataEntry.adData = new byte[adData.length]; + System.arraycopy(adData, 0, + new_authorizationDataEntry.adData, 0, adData.length); } + return new_authorizationDataEntry; + } - /** - * Constructs an instance of AuthorizationDataEntry. - * @param encoding a single DER-encoded value. - */ - public AuthorizationDataEntry(DerValue encoding) throws Asn1Exception, IOException { - DerValue der; + /** + * Constructs an instance of AuthorizationDataEntry. + * @param encoding a single DER-encoded value. + */ + public AuthorizationDataEntry(DerValue encoding) throws Asn1Exception, IOException { + DerValue der; if (encoding.getTag() != DerValue.tag_Sequence) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); - } - der = encoding.getData().getDerValue(); - if ((der.getTag() & (byte)0x1F) == (byte)0x00) { - adType = der.getData().getBigInteger().intValue(); - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } der = encoding.getData().getDerValue(); - if ((der.getTag() & (byte)0x1F) == (byte)0x01) { - adData = der.getData().getOctetString(); - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - if (encoding.getData().available() > 0) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + if ((der.getTag() & (byte) 0x1F) == (byte) 0x00) { + adType = der.getData().getBigInteger().intValue(); + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); } + der = encoding.getData().getDerValue(); + if ((der.getTag() & (byte) 0x1F) == (byte) 0x01) { + adData = der.getData().getOctetString(); + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + if (encoding.getData().available() > 0) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + } - /** - * Encodes an AuthorizationDataEntry object. - * @return byte array of encoded AuthorizationDataEntry object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - public byte[] asn1Encode() throws Asn1Exception, IOException { + /** + * Encodes an AuthorizationDataEntry object. + * @return byte array of encoded AuthorizationDataEntry object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { DerOutputStream bytes = new DerOutputStream(); - DerOutputStream temp = new DerOutputStream(); - temp.putInteger(adType); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp); - temp = new DerOutputStream(); - temp.putOctetString(adData); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp); - temp = new DerOutputStream(); - temp.write(DerValue.tag_Sequence, bytes); - return temp.toByteArray(); - } + DerOutputStream temp = new DerOutputStream(); + temp.putInteger(adType); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), temp); + temp = new DerOutputStream(); + temp.putOctetString(adData); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x01), temp); + temp = new DerOutputStream(); + temp.write(DerValue.tag_Sequence, bytes); + return temp.toByteArray(); + } - /** - * Writes the entry's data fields in FCC format to an output stream. - * - * @param cos a CCacheOutputStream. - * @exception IOException if an I/O exception occurs. - */ - public void writeEntry(CCacheOutputStream cos) throws IOException { - cos.write16(adType); - cos.write32(adData.length); - cos.write(adData, 0, adData.length); - } + /** + * Writes the entry's data fields in FCC format to an output stream. + * + * @param cos a CCacheOutputStream. + * @exception IOException if an I/O exception occurs. + */ + public void writeEntry(CCacheOutputStream cos) throws IOException { + cos.write16(adType); + cos.write32(adData.length); + cos.write(adData, 0, adData.length); + } public String toString() { return ("adType=" + adType + " adData.length=" + adData.length); } - } diff --git a/src/share/classes/sun/security/krb5/internal/ETypeInfo2.java b/src/share/classes/sun/security/krb5/internal/ETypeInfo2.java index 110e38b080667545709f475ec453f6a331eb6d8d..30bf4dfb3c9ee49a9853408a555e64e301944280 100644 --- a/src/share/classes/sun/security/krb5/internal/ETypeInfo2.java +++ b/src/share/classes/sun/security/krb5/internal/ETypeInfo2.java @@ -100,16 +100,16 @@ public class ETypeInfo2 { // salt if (encoding.getData().available() > 0) { - der = encoding.getData().getDerValue(); - if ((der.getTag() & 0x1F) == 0x01) { + if ((encoding.getData().peekByte() & 0x1F) == 0x01) { + der = encoding.getData().getDerValue(); this.saltStr = der.getData().getGeneralString(); } } // s2kparams if (encoding.getData().available() > 0) { - der = encoding.getData().getDerValue(); - if ((der.getTag() & 0x1F) == 0x02) { + if ((encoding.getData().peekByte() & 0x1F) == 0x02) { + der = encoding.getData().getDerValue(); this.s2kparams = der.getData().getOctetString(); } } diff --git a/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java b/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java index 1d3381797e04bbaf89fe93690ceb182dc5463e77..b3dcf144159854736fa264c9aad8036f46c45758 100644 --- a/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java @@ -55,102 +55,111 @@ import java.math.BigInteger; * http://www.ietf.org/rfc/rfc4120.txt. */ public class EncAPRepPart { - public KerberosTime ctime; - public int cusec; + + public KerberosTime ctime; + public int cusec; EncryptionKey subKey; //optional Integer seqNumber; //optional - public EncAPRepPart( - KerberosTime new_ctime, - int new_cusec, - EncryptionKey new_subKey, - Integer new_seqNumber - ) { - ctime = new_ctime; - cusec = new_cusec; - subKey = new_subKey; - seqNumber = new_seqNumber; - } + public EncAPRepPart( + KerberosTime new_ctime, + int new_cusec, + EncryptionKey new_subKey, + Integer new_seqNumber) { + ctime = new_ctime; + cusec = new_cusec; + subKey = new_subKey; + seqNumber = new_seqNumber; + } - public EncAPRepPart(byte[] data) - throws Asn1Exception, IOException { - init(new DerValue(data)); - } + public EncAPRepPart(byte[] data) + throws Asn1Exception, IOException { + init(new DerValue(data)); + } - public EncAPRepPart(DerValue encoding) - throws Asn1Exception, IOException { - init(encoding); - } + public EncAPRepPart(DerValue encoding) + throws Asn1Exception, IOException { + init(encoding); + } - /** - * Initializes an EncaPRepPart object. - * @param encoding a single DER-encoded value. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - private void init(DerValue encoding) throws Asn1Exception, IOException { - DerValue der, subDer; - if (((encoding.getTag() & (byte)0x1F) != (byte)0x1B) - || (encoding.isApplication() != true) - || (encoding.isConstructed() != true)) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + /** + * Initializes an EncaPRepPart object. + * @param encoding a single DER-encoded value. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + private void init(DerValue encoding) throws Asn1Exception, IOException { + DerValue der, subDer; + if (((encoding.getTag() & (byte) 0x1F) != (byte) 0x1B) + || (encoding.isApplication() != true) + || (encoding.isConstructed() != true)) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) + if (der.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + ctime = KerberosTime.parse(der.getData(), (byte) 0x00, true); + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & (byte) 0x1F) == (byte) 0x01) { + cusec = subDer.getData().getBigInteger().intValue(); + } else { throw new Asn1Exception(Krb5.ASN1_BAD_ID); - ctime = KerberosTime.parse(der.getData(), (byte)0x00, true); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) == (byte)0x01) { - cusec = subDer.getData().getBigInteger().intValue(); - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - if (der.getData().available() > 0) { - subKey = EncryptionKey.parse(der.getData(), (byte)0x02, true); - } - else { - subKey = null; - seqNumber = null; - } - if (der.getData().available() > 0) { - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & 0x1F) != 0x03) { - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - } - seqNumber = new Integer(subDer.getData().getBigInteger().intValue()); - } - else seqNumber = null; - if (der.getData().available() > 0) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); } + if (der.getData().available() > 0) { + subKey = EncryptionKey.parse(der.getData(), (byte) 0x02, true); + } else { + subKey = null; + seqNumber = null; + } + if (der.getData().available() > 0) { + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & 0x1F) != 0x03) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + seqNumber = new Integer(subDer.getData().getBigInteger().intValue()); + } else { + seqNumber = null; + } + if (der.getData().available() > 0) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + } - /** - * Encodes an EncAPRepPart object. - * @return byte array of encoded EncAPRepPart object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - public byte[] asn1Encode() throws Asn1Exception, IOException{ - Vector v = new Vector (); + /** + * Encodes an EncAPRepPart object. + * @return byte array of encoded EncAPRepPart object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { + Vector v = new Vector(); DerOutputStream temp = new DerOutputStream(); - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), ctime.asn1Encode())); - temp.putInteger(BigInteger.valueOf(cusec)); - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp.toByteArray())); - if (subKey != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), subKey.asn1Encode())); - if (seqNumber != null) { - temp = new DerOutputStream(); - // encode as an unsigned integer (UInt32) - temp.putInteger(BigInteger.valueOf(seqNumber.longValue())); - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), temp.toByteArray())); - } - DerValue der[] = new DerValue[v.size()]; - v.copyInto(der); - temp = new DerOutputStream(); - temp.putSequence(der); - DerOutputStream out = new DerOutputStream(); - out.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte)0x1B), temp); - return out.toByteArray(); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x00), ctime.asn1Encode())); + temp.putInteger(BigInteger.valueOf(cusec)); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x01), temp.toByteArray())); + if (subKey != null) { + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x02), subKey.asn1Encode())); + } + if (seqNumber != null) { + temp = new DerOutputStream(); + // encode as an unsigned integer (UInt32) + temp.putInteger(BigInteger.valueOf(seqNumber.longValue())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x03), temp.toByteArray())); } + DerValue der[] = new DerValue[v.size()]; + v.copyInto(der); + temp = new DerOutputStream(); + temp.putSequence(der); + DerOutputStream out = new DerOutputStream(); + out.write(DerValue.createTag(DerValue.TAG_APPLICATION, + true, (byte) 0x1B), temp); + return out.toByteArray(); + } public final EncryptionKey getSubKey() { return subKey; @@ -159,5 +168,4 @@ public class EncAPRepPart { public final Integer getSeqNumber() { return seqNumber; } - } diff --git a/src/share/classes/sun/security/krb5/internal/EncASRepPart.java b/src/share/classes/sun/security/krb5/internal/EncASRepPart.java index b5526e8014d5260c55c8a4ca69626cd9b919b25e..b71238fef5110bd30e5a19eb328a3f4cf23aa042 100644 --- a/src/share/classes/sun/security/krb5/internal/EncASRepPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncASRepPart.java @@ -36,57 +36,55 @@ import java.io.IOException; public class EncASRepPart extends EncKDCRepPart { - public EncASRepPart( - EncryptionKey new_key, - LastReq new_lastReq, - int new_nonce, - KerberosTime new_keyExpiration, - TicketFlags new_flags, - KerberosTime new_authtime, - KerberosTime new_starttime, - KerberosTime new_endtime, - KerberosTime new_renewTill, - Realm new_srealm, - PrincipalName new_sname, - HostAddresses new_caddr - ) { - super( - new_key, - new_lastReq, - new_nonce, - new_keyExpiration, - new_flags, - new_authtime, - new_starttime, - new_endtime, - new_renewTill, - new_srealm, - new_sname, - new_caddr, - Krb5.KRB_ENC_AS_REP_PART - //may need to use Krb5.KRB_ENC_TGS_REP_PART to mimic - //behavior of other implementaions, instead of above + public EncASRepPart( + EncryptionKey new_key, + LastReq new_lastReq, + int new_nonce, + KerberosTime new_keyExpiration, + TicketFlags new_flags, + KerberosTime new_authtime, + KerberosTime new_starttime, + KerberosTime new_endtime, + KerberosTime new_renewTill, + Realm new_srealm, + PrincipalName new_sname, + HostAddresses new_caddr) { + super( + new_key, + new_lastReq, + new_nonce, + new_keyExpiration, + new_flags, + new_authtime, + new_starttime, + new_endtime, + new_renewTill, + new_srealm, + new_sname, + new_caddr, + Krb5.KRB_ENC_AS_REP_PART ); - } + //may need to use Krb5.KRB_ENC_TGS_REP_PART to mimic + //behavior of other implementaions, instead of above + } - public EncASRepPart(byte[] data) throws Asn1Exception, - IOException, KrbException { - init(new DerValue(data)); - } + public EncASRepPart(byte[] data) throws Asn1Exception, + IOException, KrbException { + init(new DerValue(data)); + } - public EncASRepPart(DerValue encoding) throws Asn1Exception, - IOException, KrbException { - init(encoding); - } + public EncASRepPart(DerValue encoding) throws Asn1Exception, + IOException, KrbException { + init(encoding); + } - private void init(DerValue encoding) throws Asn1Exception, - IOException, KrbException { - init(encoding, Krb5.KRB_ENC_AS_REP_PART); - } - - public byte[] asn1Encode() throws Asn1Exception, - IOException { - return asn1Encode(Krb5.KRB_ENC_AS_REP_PART); - } + private void init(DerValue encoding) throws Asn1Exception, + IOException, KrbException { + init(encoding, Krb5.KRB_ENC_AS_REP_PART); + } + public byte[] asn1Encode() throws Asn1Exception, + IOException { + return asn1Encode(Krb5.KRB_ENC_AS_REP_PART); + } } diff --git a/src/share/classes/sun/security/krb5/internal/EncKDCRepPart.java b/src/share/classes/sun/security/krb5/internal/EncKDCRepPart.java index 35081a0051cd8459bffec558fdf9a8922001b359..e7723a41c4236dce939871a8b41ab5a0bdae739e 100644 --- a/src/share/classes/sun/security/krb5/internal/EncKDCRepPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncKDCRepPart.java @@ -36,6 +36,7 @@ import sun.security.util.*; import java.util.Vector; import java.io.IOException; import java.math.BigInteger; + /** * Implements the ASN.1 EncKDCRepPart type. * @@ -63,143 +64,163 @@ import java.math.BigInteger; * http://www.ietf.org/rfc/rfc4120.txt. */ public class EncKDCRepPart { - public EncryptionKey key; - public LastReq lastReq; - public int nonce; - public KerberosTime keyExpiration; //optional - public TicketFlags flags; - public KerberosTime authtime; - public KerberosTime starttime; //optional - public KerberosTime endtime; - public KerberosTime renewTill; //optional - public Realm srealm; - public PrincipalName sname; - public HostAddresses caddr; //optional - public int msgType; //not included in sequence - public EncKDCRepPart( - EncryptionKey new_key, - LastReq new_lastReq, - int new_nonce, - KerberosTime new_keyExpiration, - TicketFlags new_flags, - KerberosTime new_authtime, - KerberosTime new_starttime, - KerberosTime new_endtime, - KerberosTime new_renewTill, - Realm new_srealm, - PrincipalName new_sname, - HostAddresses new_caddr, - int new_msgType - ) { - key = new_key; - lastReq = new_lastReq; - nonce = new_nonce; - keyExpiration = new_keyExpiration; - flags = new_flags; - authtime = new_authtime; - starttime = new_starttime; - endtime = new_endtime; - renewTill = new_renewTill; - srealm = new_srealm; - sname = new_sname; - caddr = new_caddr; - msgType = new_msgType; - } + public EncryptionKey key; + public LastReq lastReq; + public int nonce; + public KerberosTime keyExpiration; //optional + public TicketFlags flags; + public KerberosTime authtime; + public KerberosTime starttime; //optional + public KerberosTime endtime; + public KerberosTime renewTill; //optional + public Realm srealm; + public PrincipalName sname; + public HostAddresses caddr; //optional + public int msgType; //not included in sequence - public EncKDCRepPart() { - } + public EncKDCRepPart( + EncryptionKey new_key, + LastReq new_lastReq, + int new_nonce, + KerberosTime new_keyExpiration, + TicketFlags new_flags, + KerberosTime new_authtime, + KerberosTime new_starttime, + KerberosTime new_endtime, + KerberosTime new_renewTill, + Realm new_srealm, + PrincipalName new_sname, + HostAddresses new_caddr, + int new_msgType) { + key = new_key; + lastReq = new_lastReq; + nonce = new_nonce; + keyExpiration = new_keyExpiration; + flags = new_flags; + authtime = new_authtime; + starttime = new_starttime; + endtime = new_endtime; + renewTill = new_renewTill; + srealm = new_srealm; + sname = new_sname; + caddr = new_caddr; + msgType = new_msgType; + } - public EncKDCRepPart(byte[] data, int rep_type) - throws Asn1Exception, IOException, RealmException{ - init(new DerValue(data), rep_type); - } + public EncKDCRepPart() { + } - public EncKDCRepPart(DerValue encoding, int rep_type) - throws Asn1Exception, IOException, RealmException - { - init(encoding, rep_type); - } + public EncKDCRepPart(byte[] data, int rep_type) + throws Asn1Exception, IOException, RealmException { + init(new DerValue(data), rep_type); + } + + public EncKDCRepPart(DerValue encoding, int rep_type) + throws Asn1Exception, IOException, RealmException { + init(encoding, rep_type); + } - /** - * Initializes an EncKDCRepPart object. - * - * @param encoding a single DER-encoded value. - * @param rep_type type of the encrypted reply message. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * @exception RealmException if an error occurs while decoding an Realm object. - */ - protected void init(DerValue encoding, int rep_type) - throws Asn1Exception, IOException, RealmException - { - DerValue der, subDer; - //implementations return the incorrect tag value, so - //we don't use the above line; instead we use the following - msgType = (encoding.getTag() & (byte)0x1F); + /** + * Initializes an EncKDCRepPart object. + * + * @param encoding a single DER-encoded value. + * @param rep_type type of the encrypted reply message. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * @exception RealmException if an error occurs while decoding an Realm object. + */ + protected void init(DerValue encoding, int rep_type) + throws Asn1Exception, IOException, RealmException { + DerValue der, subDer; + //implementations return the incorrect tag value, so + //we don't use the above line; instead we use the following + msgType = (encoding.getTag() & (byte) 0x1F); if (msgType != Krb5.KRB_ENC_AS_REP_PART && - msgType != Krb5.KRB_ENC_TGS_REP_PART) + msgType != Krb5.KRB_ENC_TGS_REP_PART) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + der = encoding.getData().getDerValue(); + if (der.getTag() != DerValue.tag_Sequence) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); - der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) + } + key = EncryptionKey.parse(der.getData(), (byte) 0x00, false); + lastReq = LastReq.parse(der.getData(), (byte) 0x01, false); + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & (byte) 0x1F) == (byte) 0x02) { + nonce = subDer.getData().getBigInteger().intValue(); + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + keyExpiration = KerberosTime.parse(der.getData(), (byte) 0x03, true); + flags = TicketFlags.parse(der.getData(), (byte) 0x04, false); + authtime = KerberosTime.parse(der.getData(), (byte) 0x05, false); + starttime = KerberosTime.parse(der.getData(), (byte) 0x06, true); + endtime = KerberosTime.parse(der.getData(), (byte) 0x07, false); + renewTill = KerberosTime.parse(der.getData(), (byte) 0x08, true); + srealm = Realm.parse(der.getData(), (byte) 0x09, false); + sname = PrincipalName.parse(der.getData(), (byte) 0x0A, false); + if (der.getData().available() > 0) { + caddr = HostAddresses.parse(der.getData(), (byte) 0x0B, true); + } + if (der.getData().available() > 0) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); - key = EncryptionKey.parse(der.getData(), (byte)0x00, false); - lastReq = LastReq.parse(der.getData(), (byte)0x01, false); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) == (byte)0x02) - nonce = subDer.getData().getBigInteger().intValue(); - else throw new Asn1Exception(Krb5.ASN1_BAD_ID); - keyExpiration = KerberosTime.parse(der.getData(), (byte)0x03, true); - flags = TicketFlags.parse(der.getData(), (byte)0x04, false); - authtime = KerberosTime.parse(der.getData(), (byte)0x05, false); - starttime = KerberosTime.parse(der.getData(), (byte)0x06, true); - endtime = KerberosTime.parse(der.getData(), (byte)0x07, false); - renewTill = KerberosTime.parse(der.getData(), (byte)0x08, true); - srealm = Realm.parse(der.getData(), (byte)0x09, false); - sname = PrincipalName.parse(der.getData(), (byte)0x0A, false); - if (der.getData().available() > 0) - caddr = HostAddresses.parse(der.getData(), (byte)0x0B, true); - if (der.getData().available() > 0) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); } + } - /** - * Encodes an EncKDCRepPart object. - * @param rep_type type of encrypted reply message. - * @return byte array of encoded EncKDCRepPart object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - public byte[] asn1Encode(int rep_type) throws Asn1Exception, - IOException { + /** + * Encodes an EncKDCRepPart object. + * @param rep_type type of encrypted reply message. + * @return byte array of encoded EncKDCRepPart object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public byte[] asn1Encode(int rep_type) throws Asn1Exception, + IOException { DerOutputStream temp = new DerOutputStream(); DerOutputStream bytes = new DerOutputStream(); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), key.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), lastReq.asn1Encode()); - temp.putInteger(BigInteger.valueOf(nonce)); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), temp); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x00), key.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x01), lastReq.asn1Encode()); + temp.putInteger(BigInteger.valueOf(nonce)); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x02), temp); - if (keyExpiration != null) - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), keyExpiration.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), flags.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), authtime.asn1Encode()); - if (starttime != null) - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x06), starttime.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x07), endtime.asn1Encode()); - if (renewTill != null) - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x08), renewTill.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x09), srealm.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x0A), sname.asn1Encode()); - if (caddr != null) - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x0B), caddr.asn1Encode()); - //should use the rep_type to build the encoding - //but other implementations do not; it is ignored and - //the cached msgType is used instead - temp = new DerOutputStream(); - temp.write(DerValue.tag_Sequence, bytes); - bytes = new DerOutputStream(); - bytes.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte)msgType), temp); - return bytes.toByteArray(); + if (keyExpiration != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x03), keyExpiration.asn1Encode()); } - + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x04), flags.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x05), authtime.asn1Encode()); + if (starttime != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x06), starttime.asn1Encode()); + } + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x07), endtime.asn1Encode()); + if (renewTill != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x08), renewTill.asn1Encode()); + } + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x09), srealm.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x0A), sname.asn1Encode()); + if (caddr != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x0B), caddr.asn1Encode()); + } + //should use the rep_type to build the encoding + //but other implementations do not; it is ignored and + //the cached msgType is used instead + temp = new DerOutputStream(); + temp.write(DerValue.tag_Sequence, bytes); + bytes = new DerOutputStream(); + bytes.write(DerValue.createTag(DerValue.TAG_APPLICATION, + true, (byte) msgType), temp); + return bytes.toByteArray(); + } } diff --git a/src/share/classes/sun/security/krb5/internal/EncKrbCredPart.java b/src/share/classes/sun/security/krb5/internal/EncKrbCredPart.java index f37f252bbaa1d3ac8556b484ebb67795a8a3a3bd..c5acf6d2b1c8ef02c538a1b39301521f37745efe 100644 --- a/src/share/classes/sun/security/krb5/internal/EncKrbCredPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncKrbCredPart.java @@ -36,6 +36,7 @@ import sun.security.krb5.RealmException; import java.util.Vector; import java.io.IOException; import java.math.BigInteger; + /** * Implements the ASN.1 EncKrbCredPart type. * @@ -57,148 +58,158 @@ import java.math.BigInteger; * http://www.ietf.org/rfc/rfc4120.txt. */ public class EncKrbCredPart { - public KrbCredInfo[] ticketInfo = null; - public KerberosTime timeStamp; //optional - private Integer nonce; //optional - private Integer usec; //optional - private HostAddress sAddress; //optional - private HostAddresses rAddress; //optional + public KrbCredInfo[] ticketInfo = null; + public KerberosTime timeStamp; //optional + private Integer nonce; //optional + private Integer usec; //optional + private HostAddress sAddress; //optional + private HostAddresses rAddress; //optional - public EncKrbCredPart( - KrbCredInfo[] new_ticketInfo, - KerberosTime new_timeStamp, - Integer new_usec, - Integer new_nonce, - HostAddress new_sAddress, - HostAddresses new_rAddress - ) throws IOException { - if (new_ticketInfo != null) { - ticketInfo = new KrbCredInfo[new_ticketInfo.length]; - for (int i = 0; i < new_ticketInfo.length; i++) { - if (new_ticketInfo[i] == null) { - throw new IOException("Cannot create a EncKrbCredPart"); - } else { - ticketInfo[i] = (KrbCredInfo)new_ticketInfo[i].clone(); - } - } + public EncKrbCredPart( + KrbCredInfo[] new_ticketInfo, + KerberosTime new_timeStamp, + Integer new_usec, + Integer new_nonce, + HostAddress new_sAddress, + HostAddresses new_rAddress) throws IOException { + if (new_ticketInfo != null) { + ticketInfo = new KrbCredInfo[new_ticketInfo.length]; + for (int i = 0; i < new_ticketInfo.length; i++) { + if (new_ticketInfo[i] == null) { + throw new IOException("Cannot create a EncKrbCredPart"); + } else { + ticketInfo[i] = (KrbCredInfo) new_ticketInfo[i].clone(); } - timeStamp = new_timeStamp; - usec = new_usec; - nonce = new_nonce; - sAddress = new_sAddress; - rAddress = new_rAddress; + } } + timeStamp = new_timeStamp; + usec = new_usec; + nonce = new_nonce; + sAddress = new_sAddress; + rAddress = new_rAddress; + } - public EncKrbCredPart(byte[] data) throws Asn1Exception, - IOException, RealmException { - init(new DerValue(data)); - } + public EncKrbCredPart(byte[] data) throws Asn1Exception, + IOException, RealmException { + init(new DerValue(data)); + } - public EncKrbCredPart(DerValue encoding) throws Asn1Exception, - IOException, RealmException { - init(encoding); - } + public EncKrbCredPart(DerValue encoding) throws Asn1Exception, + IOException, RealmException { + init(encoding); + } - /** - * Initializes an EncKrbCredPart object. - * @param encoding a single DER-encoded value. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * @exception RealmException if an error occurs while parsing a Realm object. - */ - private void init(DerValue encoding) throws Asn1Exception, - IOException, RealmException { - DerValue der, subDer; - //may not be the correct error code for a tag - //mismatch on an encrypted structure - nonce = null; - timeStamp = null; - usec= null; + /** + * Initializes an EncKrbCredPart object. + * @param encoding a single DER-encoded value. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * @exception RealmException if an error occurs while parsing a Realm object. + */ + private void init(DerValue encoding) throws Asn1Exception, + IOException, RealmException { + DerValue der, subDer; + //may not be the correct error code for a tag + //mismatch on an encrypted structure + nonce = null; + timeStamp = null; + usec = null; sAddress = null; rAddress = null; - if (((encoding.getTag() & (byte)0x1F) != (byte)0x1D) - || (encoding.isApplication() != true) - || (encoding.isConstructed() != true)) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + if (((encoding.getTag() & (byte) 0x1F) != (byte) 0x1D) + || (encoding.isApplication() != true) + || (encoding.isConstructed() != true)) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) + if (der.getTag() != DerValue.tag_Sequence) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & (byte) 0x1F) == (byte) 0x00) { + DerValue derValues[] = subDer.getData().getSequence(1); + ticketInfo = new KrbCredInfo[derValues.length]; + for (int i = 0; i < derValues.length; i++) { + ticketInfo[i] = new KrbCredInfo(derValues[i]); + } + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + if (der.getData().available() > 0) { + if (((byte) (der.getData().peekByte()) & (byte) 0x1F) == (byte) 0x01) { subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) == (byte)0x00) { - DerValue derValues[] = subDer.getData().getSequence(1); - ticketInfo = new KrbCredInfo[derValues.length]; - for (int i = 0; i < derValues.length; i++) { - ticketInfo[i] = new KrbCredInfo(derValues[i]); - } - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - if (der.getData().available() > 0) { - if (((byte)(der.getData().peekByte()) & (byte)0x1F) == (byte)0x01) { - subDer = der.getData().getDerValue(); - nonce = new Integer(subDer.getData().getBigInteger().intValue()); - } - } - if (der.getData().available() >0) { - timeStamp = KerberosTime.parse(der.getData(), (byte)0x02, true); - } - if (der.getData().available() >0) { - if (((byte)(der.getData().peekByte()) & (byte)0x1F) == (byte)0x03) { - subDer = der.getData().getDerValue(); - usec = new Integer(subDer.getData().getBigInteger().intValue()); - } - } - if (der.getData().available() >0) { - sAddress = HostAddress.parse(der.getData(), (byte)0x04, true); - } - if (der.getData().available() >0) { - rAddress = HostAddresses.parse(der.getData(), (byte)0x05, true); - } - if (der.getData().available() >0) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + nonce = new Integer(subDer.getData().getBigInteger().intValue()); + } + } + if (der.getData().available() > 0) { + timeStamp = KerberosTime.parse(der.getData(), (byte) 0x02, true); + } + if (der.getData().available() > 0) { + if (((byte) (der.getData().peekByte()) & (byte) 0x1F) == (byte) 0x03) { + subDer = der.getData().getDerValue(); + usec = new Integer(subDer.getData().getBigInteger().intValue()); + } + } + if (der.getData().available() > 0) { + sAddress = HostAddress.parse(der.getData(), (byte) 0x04, true); + } + if (der.getData().available() > 0) { + rAddress = HostAddresses.parse(der.getData(), (byte) 0x05, true); + } + if (der.getData().available() > 0) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); } + } - /** - * Encodes an EncKrbCredPart object. - * @return byte array of encoded EncKrbCredPart object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * - */ - public byte[] asn1Encode() throws Asn1Exception, IOException{ + /** + * Encodes an EncKrbCredPart object. + * @return byte array of encoded EncKrbCredPart object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { DerOutputStream bytes = new DerOutputStream(); - DerOutputStream temp = new DerOutputStream(); - DerValue[] tickets = new DerValue[ticketInfo.length]; - for (int i = 0; i < ticketInfo.length; i++) - tickets[i] = new DerValue(ticketInfo[i].asn1Encode()); - temp.putSequence(tickets); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp); + DerOutputStream temp = new DerOutputStream(); + DerValue[] tickets = new DerValue[ticketInfo.length]; + for (int i = 0; i < ticketInfo.length; i++) { + tickets[i] = new DerValue(ticketInfo[i].asn1Encode()); + } + temp.putSequence(tickets); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x00), temp); - if (nonce != null) { + if (nonce != null) { temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(nonce.intValue())); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp); - } + temp.putInteger(BigInteger.valueOf(nonce.intValue())); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x01), temp); + } if (timeStamp != null) { - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), timeStamp.asn1Encode()); - } - if (usec != null) { - temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(usec.intValue())); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), temp); - } - if (sAddress != null) { - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), sAddress.asn1Encode()); - } - if (rAddress != null) { - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), rAddress.asn1Encode()); - } - temp = new DerOutputStream(); - temp.write(DerValue.tag_Sequence, bytes); - bytes = new DerOutputStream(); - bytes.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte)0x1D), temp); - return bytes.toByteArray(); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x02), timeStamp.asn1Encode()); + } + if (usec != null) { + temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(usec.intValue())); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x03), temp); + } + if (sAddress != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x04), sAddress.asn1Encode()); + } + if (rAddress != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x05), rAddress.asn1Encode()); } + temp = new DerOutputStream(); + temp.write(DerValue.tag_Sequence, bytes); + bytes = new DerOutputStream(); + bytes.write(DerValue.createTag(DerValue.TAG_APPLICATION, + true, (byte) 0x1D), temp); + return bytes.toByteArray(); + } } diff --git a/src/share/classes/sun/security/krb5/internal/EncKrbPrivPart.java b/src/share/classes/sun/security/krb5/internal/EncKrbPrivPart.java index e4ed50b4ba1cf382d960f2f64f06c173ea098a0f..292dd58be3b442acbf177c5192365cf42adb254c 100644 --- a/src/share/classes/sun/security/krb5/internal/EncKrbPrivPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncKrbPrivPart.java @@ -55,114 +55,119 @@ import java.math.BigInteger; * * http://www.ietf.org/rfc/rfc4120.txt. */ - public class EncKrbPrivPart { - public byte[] userData = null; - public KerberosTime timestamp; //optional - public Integer usec; //optional - public Integer seqNumber; //optional - public HostAddress sAddress; //optional - public HostAddress rAddress; //optional - public EncKrbPrivPart( - byte[] new_userData, - KerberosTime new_timestamp, - Integer new_usec, - Integer new_seqNumber, - HostAddress new_sAddress, - HostAddress new_rAddress - ) { - if (new_userData != null) { - userData = new_userData.clone(); - } - timestamp = new_timestamp; - usec = new_usec; - seqNumber = new_seqNumber; - sAddress = new_sAddress; - rAddress = new_rAddress; - } + public byte[] userData = null; + public KerberosTime timestamp; //optional + public Integer usec; //optional + public Integer seqNumber; //optional + public HostAddress sAddress; //optional + public HostAddress rAddress; //optional - public EncKrbPrivPart(byte[] data) throws Asn1Exception, IOException { - init(new DerValue(data)); + public EncKrbPrivPart( + byte[] new_userData, + KerberosTime new_timestamp, + Integer new_usec, + Integer new_seqNumber, + HostAddress new_sAddress, + HostAddress new_rAddress) { + if (new_userData != null) { + userData = new_userData.clone(); } + timestamp = new_timestamp; + usec = new_usec; + seqNumber = new_seqNumber; + sAddress = new_sAddress; + rAddress = new_rAddress; + } - public EncKrbPrivPart(DerValue encoding) throws Asn1Exception, IOException { - init(encoding); - } + public EncKrbPrivPart(byte[] data) throws Asn1Exception, IOException { + init(new DerValue(data)); + } + + public EncKrbPrivPart(DerValue encoding) throws Asn1Exception, IOException { + init(encoding); + } - /** - * Initializes an EncKrbPrivPart object. - * @param encoding a single DER-encoded value. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - private void init(DerValue encoding) throws Asn1Exception, IOException { + /** + * Initializes an EncKrbPrivPart object. + * @param encoding a single DER-encoded value. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + private void init(DerValue encoding) throws Asn1Exception, IOException { DerValue der, subDer; - if (((encoding.getTag() & (byte)0x1F) != (byte)0x1C) - || (encoding.isApplication() != true) - || (encoding.isConstructed() != true)) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) + if (((encoding.getTag() & (byte) 0x1F) != (byte) 0x1C) + || (encoding.isApplication() != true) + || (encoding.isConstructed() != true)) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + der = encoding.getData().getDerValue(); + if (der.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & (byte) 0x1F) == (byte) 0x00) { + userData = subDer.getData().getOctetString(); + } else { throw new Asn1Exception(Krb5.ASN1_BAD_ID); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & (byte)0x1F) == (byte)0x00) { - userData = subDer.getData().getOctetString(); - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - timestamp = KerberosTime.parse(der.getData(), (byte)0x01, true); - if ((der.getData().peekByte() & 0x1F) == 0x02) { - subDer = der.getData().getDerValue(); - usec = new Integer(subDer.getData().getBigInteger().intValue()); - } - else usec = null; - if ((der.getData().peekByte() & 0x1F) == 0x03 ) { - subDer = der.getData().getDerValue(); - seqNumber = new Integer(subDer.getData().getBigInteger().intValue()); - } - else seqNumber = null; - sAddress = HostAddress.parse(der.getData(), (byte)0x04, false); - if (der.getData().available() > 0) { - rAddress = HostAddress.parse(der.getData(), (byte)0x05, true); - } - if (der.getData().available() > 0) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); } + timestamp = KerberosTime.parse(der.getData(), (byte) 0x01, true); + if ((der.getData().peekByte() & 0x1F) == 0x02) { + subDer = der.getData().getDerValue(); + usec = new Integer(subDer.getData().getBigInteger().intValue()); + } else { + usec = null; + } + if ((der.getData().peekByte() & 0x1F) == 0x03) { + subDer = der.getData().getDerValue(); + seqNumber = new Integer(subDer.getData().getBigInteger().intValue()); + } else { + seqNumber = null; + } + sAddress = HostAddress.parse(der.getData(), (byte) 0x04, false); + if (der.getData().available() > 0) { + rAddress = HostAddress.parse(der.getData(), (byte) 0x05, true); + } + if (der.getData().available() > 0) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + } - /** - * Encodes an EncKrbPrivPart object. - * @return byte array of encoded EncKrbPrivPart object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - public byte[] asn1Encode() throws Asn1Exception, IOException { + /** + * Encodes an EncKrbPrivPart object. + * @return byte array of encoded EncKrbPrivPart object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { DerOutputStream temp = new DerOutputStream(); DerOutputStream bytes = new DerOutputStream(); - temp.putOctetString(userData); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp); - if (timestamp != null) - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), timestamp.asn1Encode()); - if (usec != null) { - temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(usec.intValue())); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), temp); - } - if (seqNumber != null) { - temp = new DerOutputStream(); - // encode as an unsigned integer (UInt32) - temp.putInteger(BigInteger.valueOf(seqNumber.longValue())); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), temp); - } - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), sAddress.asn1Encode()); - if (rAddress != null) { - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), rAddress.asn1Encode()); - } - temp = new DerOutputStream(); - temp.write(DerValue.tag_Sequence, bytes); - bytes = new DerOutputStream(); - bytes.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte)0x1C), temp); - return bytes.toByteArray(); + temp.putOctetString(userData); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), temp); + if (timestamp != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x01), timestamp.asn1Encode()); + } + if (usec != null) { + temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(usec.intValue())); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x02), temp); + } + if (seqNumber != null) { + temp = new DerOutputStream(); + // encode as an unsigned integer (UInt32) + temp.putInteger(BigInteger.valueOf(seqNumber.longValue())); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x03), temp); + } + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x04), sAddress.asn1Encode()); + if (rAddress != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x05), rAddress.asn1Encode()); } + temp = new DerOutputStream(); + temp.write(DerValue.tag_Sequence, bytes); + bytes = new DerOutputStream(); + bytes.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte) 0x1C), temp); + return bytes.toByteArray(); + } } diff --git a/src/share/classes/sun/security/krb5/internal/EncTGSRepPart.java b/src/share/classes/sun/security/krb5/internal/EncTGSRepPart.java index 95c100a020aca76197012d16966dc295e7b8172d..864115e52e98fc51cb06bc2a2f15d12e8155550d 100644 --- a/src/share/classes/sun/security/krb5/internal/EncTGSRepPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncTGSRepPart.java @@ -35,55 +35,52 @@ import java.io.IOException; public class EncTGSRepPart extends EncKDCRepPart { - public EncTGSRepPart( - EncryptionKey new_key, - LastReq new_lastReq, - int new_nonce, - KerberosTime new_keyExpiration, - TicketFlags new_flags, - KerberosTime new_authtime, - KerberosTime new_starttime, - KerberosTime new_endtime, - KerberosTime new_renewTill, - Realm new_srealm, - PrincipalName new_sname, - HostAddresses new_caddr - ) { - super( - new_key, - new_lastReq, - new_nonce, - new_keyExpiration, - new_flags, - new_authtime, - new_starttime, - new_endtime, - new_renewTill, - new_srealm, - new_sname, - new_caddr, - Krb5.KRB_ENC_TGS_REP_PART - ); - } + public EncTGSRepPart( + EncryptionKey new_key, + LastReq new_lastReq, + int new_nonce, + KerberosTime new_keyExpiration, + TicketFlags new_flags, + KerberosTime new_authtime, + KerberosTime new_starttime, + KerberosTime new_endtime, + KerberosTime new_renewTill, + Realm new_srealm, + PrincipalName new_sname, + HostAddresses new_caddr) { + super( + new_key, + new_lastReq, + new_nonce, + new_keyExpiration, + new_flags, + new_authtime, + new_starttime, + new_endtime, + new_renewTill, + new_srealm, + new_sname, + new_caddr, + Krb5.KRB_ENC_TGS_REP_PART); + } - public EncTGSRepPart(byte[] data) throws Asn1Exception, - IOException, KrbException { - init(new DerValue(data)); - } + public EncTGSRepPart(byte[] data) throws Asn1Exception, + IOException, KrbException { + init(new DerValue(data)); + } - public EncTGSRepPart(DerValue encoding) throws Asn1Exception, - IOException, KrbException { - init(encoding); - } + public EncTGSRepPart(DerValue encoding) throws Asn1Exception, + IOException, KrbException { + init(encoding); + } - private void init(DerValue encoding) throws Asn1Exception, - IOException, KrbException { - init(encoding, Krb5.KRB_ENC_TGS_REP_PART); - } - - public byte[] asn1Encode() throws Asn1Exception, - IOException { - return asn1Encode(Krb5.KRB_ENC_TGS_REP_PART); - } + private void init(DerValue encoding) throws Asn1Exception, + IOException, KrbException { + init(encoding, Krb5.KRB_ENC_TGS_REP_PART); + } + public byte[] asn1Encode() throws Asn1Exception, + IOException { + return asn1Encode(Krb5.KRB_ENC_TGS_REP_PART); + } } diff --git a/src/share/classes/sun/security/krb5/internal/EncTicketPart.java b/src/share/classes/sun/security/krb5/internal/EncTicketPart.java index 5f315095825832d0759518f877403558e3556ed1..73eb814445baff9933da195a84aa99aab0225ab7 100644 --- a/src/share/classes/sun/security/krb5/internal/EncTicketPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncTicketPart.java @@ -62,69 +62,68 @@ import java.io.*; * http://www.ietf.org/rfc/rfc4120.txt. */ public class EncTicketPart { - public TicketFlags flags; - public EncryptionKey key; - public Realm crealm; - public PrincipalName cname; - public TransitedEncoding transited; - public KerberosTime authtime; - public KerberosTime starttime; //optional - public KerberosTime endtime; - public KerberosTime renewTill; //optional - public HostAddresses caddr; //optional - public AuthorizationData authorizationData; //optional - - public EncTicketPart( - TicketFlags new_flags, - EncryptionKey new_key, - Realm new_crealm, - PrincipalName new_cname, - TransitedEncoding new_transited, - KerberosTime new_authtime, - KerberosTime new_starttime, - KerberosTime new_endtime, - KerberosTime new_renewTill, - HostAddresses new_caddr, - AuthorizationData new_authorizationData - ) { - flags = new_flags; - key = new_key; - crealm = new_crealm; - cname = new_cname; - transited = new_transited; - authtime = new_authtime; - starttime = new_starttime; - endtime = new_endtime; - renewTill = new_renewTill; - caddr = new_caddr; - authorizationData = new_authorizationData; - } - public EncTicketPart(byte[] data) - throws Asn1Exception, KrbException, IOException { - init(new DerValue(data)); - } + public TicketFlags flags; + public EncryptionKey key; + public Realm crealm; + public PrincipalName cname; + public TransitedEncoding transited; + public KerberosTime authtime; + public KerberosTime starttime; //optional + public KerberosTime endtime; + public KerberosTime renewTill; //optional + public HostAddresses caddr; //optional + public AuthorizationData authorizationData; //optional + + public EncTicketPart( + TicketFlags new_flags, + EncryptionKey new_key, + Realm new_crealm, + PrincipalName new_cname, + TransitedEncoding new_transited, + KerberosTime new_authtime, + KerberosTime new_starttime, + KerberosTime new_endtime, + KerberosTime new_renewTill, + HostAddresses new_caddr, + AuthorizationData new_authorizationData) { + flags = new_flags; + key = new_key; + crealm = new_crealm; + cname = new_cname; + transited = new_transited; + authtime = new_authtime; + starttime = new_starttime; + endtime = new_endtime; + renewTill = new_renewTill; + caddr = new_caddr; + authorizationData = new_authorizationData; + } - public EncTicketPart(DerValue encoding) - throws Asn1Exception, KrbException, IOException { - init(encoding); - } + public EncTicketPart(byte[] data) + throws Asn1Exception, KrbException, IOException { + init(new DerValue(data)); + } - /** - * Initializes an EncTicketPart object. - * @param encoding a single DER-encoded value. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * @exception RealmException if an error occurs while parsing a Realm object. - */ + public EncTicketPart(DerValue encoding) + throws Asn1Exception, KrbException, IOException { + init(encoding); + } + /** + * Initializes an EncTicketPart object. + * @param encoding a single DER-encoded value. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * @exception RealmException if an error occurs while parsing a Realm object. + */ private static String getHexBytes(byte[] bytes, int len) - throws IOException { + throws IOException { StringBuffer sb = new StringBuffer(); for (int i = 0; i < len; i++) { - int b1 = (bytes[i]>>4) & 0x0f; + int b1 = (bytes[i] >> 4) & 0x0f; int b2 = bytes[i] & 0x0f; sb.append(Integer.toHexString(b1)); @@ -134,73 +133,91 @@ public class EncTicketPart { return sb.toString(); } - private void init(DerValue encoding) - throws Asn1Exception, IOException, RealmException { - DerValue der, subDer; + private void init(DerValue encoding) + throws Asn1Exception, IOException, RealmException { + DerValue der, subDer; - renewTill = null; - caddr = null; - authorizationData = null; - if (((encoding.getTag() & (byte)0x1F) != (byte)0x03) + renewTill = null; + caddr = null; + authorizationData = null; + if (((encoding.getTag() & (byte) 0x1F) != (byte) 0x03) || (encoding.isApplication() != true) - || (encoding.isConstructed() != true)) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - flags = TicketFlags.parse(der.getData(), (byte)0x00, false); - key = EncryptionKey.parse(der.getData(), (byte)0x01, false); - crealm = Realm.parse(der.getData(), (byte)0x02, false); - cname = PrincipalName.parse(der.getData(), (byte)0x03, false); - transited = TransitedEncoding.parse(der.getData(), (byte)0x04, false); - authtime = KerberosTime.parse(der.getData(), (byte)0x05, false); - starttime = KerberosTime.parse(der.getData(), (byte)0x06, true); - endtime = KerberosTime.parse(der.getData(), (byte)0x07, false); - if (der.getData().available() > 0) { - renewTill = KerberosTime.parse(der.getData(), (byte)0x08, true); - } - if (der.getData().available() > 0) { - caddr = HostAddresses.parse(der.getData(), (byte)0x09, true); - } - if (der.getData().available() > 0) { - authorizationData = AuthorizationData.parse(der.getData(), (byte)0x0A, true); - } - if (der.getData().available() > 0) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - + || (encoding.isConstructed() != true)) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + der = encoding.getData().getDerValue(); + if (der.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + flags = TicketFlags.parse(der.getData(), (byte) 0x00, false); + key = EncryptionKey.parse(der.getData(), (byte) 0x01, false); + crealm = Realm.parse(der.getData(), (byte) 0x02, false); + cname = PrincipalName.parse(der.getData(), (byte) 0x03, false); + transited = TransitedEncoding.parse(der.getData(), (byte) 0x04, false); + authtime = KerberosTime.parse(der.getData(), (byte) 0x05, false); + starttime = KerberosTime.parse(der.getData(), (byte) 0x06, true); + endtime = KerberosTime.parse(der.getData(), (byte) 0x07, false); + if (der.getData().available() > 0) { + renewTill = KerberosTime.parse(der.getData(), (byte) 0x08, true); + } + if (der.getData().available() > 0) { + caddr = HostAddresses.parse(der.getData(), (byte) 0x09, true); + } + if (der.getData().available() > 0) { + authorizationData = AuthorizationData.parse(der.getData(), (byte) 0x0A, true); + } + if (der.getData().available() > 0) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); } - /** - * Encodes an EncTicketPart object. - * @return byte array of encoded EncTicketPart object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ + } - public byte[] asn1Encode() throws Asn1Exception, IOException { + /** + * Encodes an EncTicketPart object. + * @return byte array of encoded EncTicketPart object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { DerOutputStream bytes = new DerOutputStream(); - DerOutputStream temp = new DerOutputStream(); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), flags.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), key.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), crealm.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), cname.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), transited.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), authtime.asn1Encode()); - if (starttime != null) - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x06), starttime.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x07), endtime.asn1Encode()); - - if (renewTill != null) - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x08), renewTill.asn1Encode()); - - if (caddr != null) - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x09), caddr.asn1Encode()); - - if (authorizationData != null) - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x0A), authorizationData.asn1Encode()); - temp.write(DerValue.tag_Sequence, bytes); - bytes = new DerOutputStream(); - bytes.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte)0x03), temp); - return bytes.toByteArray(); + DerOutputStream temp = new DerOutputStream(); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x00), flags.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x01), key.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x02), crealm.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x03), cname.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x04), transited.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x05), authtime.asn1Encode()); + if (starttime != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x06), starttime.asn1Encode()); + } + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x07), endtime.asn1Encode()); + + if (renewTill != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x08), renewTill.asn1Encode()); } + + if (caddr != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x09), caddr.asn1Encode()); + } + + if (authorizationData != null) { + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x0A), authorizationData.asn1Encode()); + } + temp.write(DerValue.tag_Sequence, bytes); + bytes = new DerOutputStream(); + bytes.write(DerValue.createTag(DerValue.TAG_APPLICATION, + true, (byte) 0x03), temp); + return bytes.toByteArray(); + } } diff --git a/src/share/classes/sun/security/krb5/internal/KDCRep.java b/src/share/classes/sun/security/krb5/internal/KDCRep.java index ca1d777ed231ee9c84f128dd03bb236ab8f89f7f..f7cc7180082be06e1d78b249b0cfbcc4e6d4b74d 100644 --- a/src/share/classes/sun/security/krb5/internal/KDCRep.java +++ b/src/share/classes/sun/security/krb5/internal/KDCRep.java @@ -35,6 +35,7 @@ import sun.security.util.*; import java.util.Vector; import java.io.IOException; import java.math.BigInteger; + /** * Implements the ASN.1 KDC-REP type. * @@ -59,163 +60,168 @@ import java.math.BigInteger; * * http://www.ietf.org/rfc/rfc4120.txt. */ - public class KDCRep { - public Realm crealm; - public PrincipalName cname; - public Ticket ticket; - public EncryptedData encPart; - public EncKDCRepPart encKDCRepPart; //not part of ASN.1 encoding - private int pvno; - private int msgType; - private PAData[] pAData = null; //optional - private boolean DEBUG = Krb5.DEBUG; + public Realm crealm; + public PrincipalName cname; + public Ticket ticket; + public EncryptedData encPart; + public EncKDCRepPart encKDCRepPart; //not part of ASN.1 encoding + private int pvno; + private int msgType; + private PAData[] pAData = null; //optional + private boolean DEBUG = Krb5.DEBUG; - public KDCRep( - PAData[] new_pAData, - Realm new_crealm, - PrincipalName new_cname, - Ticket new_ticket, - EncryptedData new_encPart, - int req_type - ) throws IOException { - pvno = Krb5.PVNO; - msgType = req_type; - if (new_pAData != null) { - pAData = new PAData[new_pAData.length]; - for (int i = 0; i < new_pAData.length; i++) { - if (new_pAData[i] == null) { - throw new IOException("Cannot create a KDCRep"); - } else { - pAData[i] = (PAData)new_pAData[i].clone(); - } - } + public KDCRep( + PAData[] new_pAData, + Realm new_crealm, + PrincipalName new_cname, + Ticket new_ticket, + EncryptedData new_encPart, + int req_type) throws IOException { + pvno = Krb5.PVNO; + msgType = req_type; + if (new_pAData != null) { + pAData = new PAData[new_pAData.length]; + for (int i = 0; i < new_pAData.length; i++) { + if (new_pAData[i] == null) { + throw new IOException("Cannot create a KDCRep"); + } else { + pAData[i] = (PAData) new_pAData[i].clone(); } - crealm = new_crealm; - cname = new_cname; - ticket = new_ticket; - encPart = new_encPart; + } } + crealm = new_crealm; + cname = new_cname; + ticket = new_ticket; + encPart = new_encPart; + } - public KDCRep() { - } + public KDCRep() { + } - public KDCRep(byte[] data, int req_type) throws Asn1Exception, KrbApErrException, RealmException, IOException { - init(new DerValue(data), req_type); - } + public KDCRep(byte[] data, int req_type) throws Asn1Exception, + KrbApErrException, RealmException, IOException { + init(new DerValue(data), req_type); + } - public KDCRep(DerValue encoding, int req_type) throws Asn1Exception, - RealmException, KrbApErrException, IOException { - init(encoding, req_type); - } + public KDCRep(DerValue encoding, int req_type) throws Asn1Exception, + RealmException, KrbApErrException, IOException { + init(encoding, req_type); + } /* // Not used? Don't know what keyusage to use here %%% - - public void decrypt(EncryptionKey key) throws Asn1Exception, - IOException, KrbException, RealmException { - encKDCRepPart = new EncKDCRepPart(encPart.decrypt(key), - msgType); - } -*/ - - /** - * Initializes an KDCRep object. - * - * @param encoding a single DER-encoded value. - * @param req_type reply message type. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * @exception RealmException if an error occurs while constructing a Realm object from DER-encoded data. - * @exception KrbApErrException if the value read from the DER-encoded data stream does not match the pre-defined value. - * - */ - protected void init(DerValue encoding, int req_type) + public void decrypt(EncryptionKey key) throws Asn1Exception, + IOException, KrbException, RealmException { + encKDCRepPart = new EncKDCRepPart(encPart.decrypt(key), msgType); + } + */ + /** + * Initializes an KDCRep object. + * + * @param encoding a single DER-encoded value. + * @param req_type reply message type. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * @exception RealmException if an error occurs while constructing + * a Realm object from DER-encoded data. + * @exception KrbApErrException if the value read from the DER-encoded + * data stream does not match the pre-defined value. + * + */ + protected void init(DerValue encoding, int req_type) throws Asn1Exception, RealmException, IOException, - KrbApErrException { - DerValue der, subDer; - if ((encoding.getTag() & 0x1F) != req_type) { - if (DEBUG) { - System.out.println(">>> KDCRep: init() " + - "encoding tag is " + - encoding.getTag() + - " req type is " + req_type); - } - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + KrbApErrException { + DerValue der, subDer; + if ((encoding.getTag() & 0x1F) != req_type) { + if (DEBUG) { + System.out.println(">>> KDCRep: init() " + + "encoding tag is " + + encoding.getTag() + + " req type is " + req_type); } - der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) { - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + der = encoding.getData().getDerValue(); + if (der.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & 0x1F) == 0x00) { + pvno = subDer.getData().getBigInteger().intValue(); + if (pvno != Krb5.PVNO) { + throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION); } - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & 0x1F) == 0x00) { - pvno = subDer.getData().getBigInteger().intValue(); - if (pvno != Krb5.PVNO) - throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION); - } else { - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & 0x1F) == 0x01) { + msgType = subDer.getData().getBigInteger().intValue(); + if (msgType != req_type) { + throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE); } + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + if ((der.getData().peekByte() & 0x1F) == 0x02) { subDer = der.getData().getDerValue(); - if ((subDer.getTag() & 0x1F) == 0x01) { - msgType = subDer.getData().getBigInteger().intValue(); - if (msgType != req_type) { - throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE); - } - } else { - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - } - if ((der.getData().peekByte() & 0x1F) == 0x02) { - subDer = der.getData().getDerValue(); - DerValue[] padata = subDer.getData().getSequence(1); - pAData = new PAData[padata.length]; - for (int i = 0; i < padata.length; i++) { - pAData[i] = new PAData(padata[i]); - } - } else { - pAData = null; - } - crealm = Realm.parse(der.getData(), (byte)0x03, false); - cname = PrincipalName.parse(der.getData(), (byte)0x04, false); - ticket = Ticket.parse(der.getData(), (byte)0x05, false); - encPart = EncryptedData.parse(der.getData(), (byte)0x06, false); - if (der.getData().available() > 0) { - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + DerValue[] padata = subDer.getData().getSequence(1); + pAData = new PAData[padata.length]; + for (int i = 0; i < padata.length; i++) { + pAData[i] = new PAData(padata[i]); } + } else { + pAData = null; } + crealm = Realm.parse(der.getData(), (byte) 0x03, false); + cname = PrincipalName.parse(der.getData(), (byte) 0x04, false); + ticket = Ticket.parse(der.getData(), (byte) 0x05, false); + encPart = EncryptedData.parse(der.getData(), (byte) 0x06, false); + if (der.getData().available() > 0) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + } + /** + * Encodes this object to a byte array. + * @return byte array of encoded APReq object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { - /** - * Encodes this object to a byte array. - * @return byte array of encoded APReq object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * - */ - public byte[] asn1Encode() throws Asn1Exception, IOException { - - DerOutputStream bytes = new DerOutputStream(); - DerOutputStream temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(pvno)); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp); - temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(msgType)); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp); - if (pAData != null && pAData.length > 0) { - DerOutputStream padata_stream = new DerOutputStream(); - for (int i = 0; i < pAData.length; i++) { - padata_stream.write(pAData[i].asn1Encode()); - } - temp = new DerOutputStream(); - temp.write(DerValue.tag_SequenceOf, padata_stream); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), temp); + DerOutputStream bytes = new DerOutputStream(); + DerOutputStream temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(pvno)); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x00), temp); + temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(msgType)); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x01), temp); + if (pAData != null && pAData.length > 0) { + DerOutputStream padata_stream = new DerOutputStream(); + for (int i = 0; i < pAData.length; i++) { + padata_stream.write(pAData[i].asn1Encode()); } - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), crealm.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), cname.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), ticket.asn1Encode()); - bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x06), encPart.asn1Encode()); temp = new DerOutputStream(); - temp.write(DerValue.tag_Sequence, bytes); - return temp.toByteArray(); + temp.write(DerValue.tag_SequenceOf, padata_stream); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x02), temp); } + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x03), crealm.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x04), cname.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x05), ticket.asn1Encode()); + bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x06), encPart.asn1Encode()); + temp = new DerOutputStream(); + temp.write(DerValue.tag_Sequence, bytes); + return temp.toByteArray(); + } } diff --git a/src/share/classes/sun/security/krb5/internal/KDCReq.java b/src/share/classes/sun/security/krb5/internal/KDCReq.java index 2f0498956958977aab6d1dbf1788b84a83469657..a46f6436cd82d450df53c573e37c4f69f4bda321 100644 --- a/src/share/classes/sun/security/krb5/internal/KDCReq.java +++ b/src/share/classes/sun/security/krb5/internal/KDCReq.java @@ -56,155 +56,160 @@ import java.math.BigInteger; * * http://www.ietf.org/rfc/rfc4120.txt. */ - public class KDCReq { - public KDCReqBody reqBody; - private int pvno; - private int msgType; - private PAData[] pAData = null; //optional + public KDCReqBody reqBody; + private int pvno; + private int msgType; + private PAData[] pAData = null; //optional - public KDCReq(PAData[] new_pAData, KDCReqBody new_reqBody, - int req_type) throws IOException { - pvno = Krb5.PVNO; - msgType = req_type; - if (new_pAData != null) { - pAData = new PAData[new_pAData.length]; - for (int i = 0; i < new_pAData.length; i++) { - if (new_pAData[i] == null) { - throw new IOException("Cannot create a KDCRep"); - } else { - pAData[i] = (PAData)new_pAData[i].clone(); - } - } + public KDCReq(PAData[] new_pAData, KDCReqBody new_reqBody, + int req_type) throws IOException { + pvno = Krb5.PVNO; + msgType = req_type; + if (new_pAData != null) { + pAData = new PAData[new_pAData.length]; + for (int i = 0; i < new_pAData.length; i++) { + if (new_pAData[i] == null) { + throw new IOException("Cannot create a KDCRep"); + } else { + pAData[i] = (PAData) new_pAData[i].clone(); } - reqBody = new_reqBody; + } } + reqBody = new_reqBody; + } - public KDCReq() { - } + public KDCReq() { + } - public KDCReq(byte[] data, int req_type) throws Asn1Exception, - IOException, KrbException { + public KDCReq(byte[] data, int req_type) throws Asn1Exception, + IOException, KrbException { init(new DerValue(data), req_type); - } + } /** - * Creates an KDCReq object from a DerValue object and asn1 type. - * - * @param der a DER value of an KDCReq object. - * @param req_type a encoded asn1 type value. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * @exceptoin KrbErrException - */ + * Creates an KDCReq object from a DerValue object and asn1 type. + * + * @param der a DER value of an KDCReq object. + * @param req_type a encoded asn1 type value. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * @exceptoin KrbErrException + */ public KDCReq(DerValue der, int req_type) throws Asn1Exception, - IOException, KrbException { - init(der, req_type); - } + IOException, KrbException { + init(der, req_type); + } - /** - * Initializes a KDCReq object from a DerValue. The DER encoding - * must be in the format specified by the KRB_KDC_REQ ASN.1 notation. - * - * @param encoding a DER-encoded KDCReq object. - * @param req_type an int indicating whether it's KRB_AS_REQ or KRB_TGS_REQ type - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * @exception KrbException if an error occurs while constructing a Realm object, - * or a Krb object from DER-encoded data. - */ + /** + * Initializes a KDCReq object from a DerValue. The DER encoding + * must be in the format specified by the KRB_KDC_REQ ASN.1 notation. + * + * @param encoding a DER-encoded KDCReq object. + * @param req_type an int indicating whether it's KRB_AS_REQ or KRB_TGS_REQ type + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * @exception KrbException if an error occurs while constructing a Realm object, + * or a Krb object from DER-encoded data. + */ protected void init(DerValue encoding, int req_type) throws Asn1Exception, - IOException, KrbException { - DerValue der, subDer; - BigInteger bint; - if ((encoding.getTag() & 0x1F) != req_type) { - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - } - der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) { + IOException, KrbException { + DerValue der, subDer; + BigInteger bint; + if ((encoding.getTag() & 0x1F) != req_type) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); - } - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & 0x01F) == 0x01) { - bint = subDer.getData().getBigInteger(); - this.pvno = bint.intValue(); - if (this.pvno != Krb5.PVNO) - throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION); - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & 0x01F) == 0x02) { - bint = subDer.getData().getBigInteger(); - this.msgType = bint.intValue(); - if (this.msgType != req_type) - throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE); - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & 0x01F) == 0x03) { - DerValue subsubDer = subDer.getData().getDerValue(); - if (subsubDer.getTag() != DerValue.tag_SequenceOf) { - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - } - Vector v = new Vector (); - while (subsubDer.getData().available() > 0) { - v.addElement(new PAData(subsubDer.getData().getDerValue())); - } - if (v.size() > 0) { - pAData = new PAData[v.size()]; - v.copyInto(pAData); - } - } - else pAData = null; - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & 0x01F) == 0x04) { - DerValue subsubDer = subDer.getData().getDerValue(); - reqBody = new KDCReqBody(subsubDer, msgType); - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); } + der = encoding.getData().getDerValue(); + if (der.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & 0x01F) == 0x01) { + bint = subDer.getData().getBigInteger(); + this.pvno = bint.intValue(); + if (this.pvno != Krb5.PVNO) { + throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION); + } + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & 0x01F) == 0x02) { + bint = subDer.getData().getBigInteger(); + this.msgType = bint.intValue(); + if (this.msgType != req_type) { + throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE); + } + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + if ((der.getData().peekByte() & 0x1F) == 0x03) { + subDer = der.getData().getDerValue(); + DerValue subsubDer = subDer.getData().getDerValue(); + if (subsubDer.getTag() != DerValue.tag_SequenceOf) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + Vector v = new Vector(); + while (subsubDer.getData().available() > 0) { + v.addElement(new PAData(subsubDer.getData().getDerValue())); + } + if (v.size() > 0) { + pAData = new PAData[v.size()]; + v.copyInto(pAData); + } + } else { + pAData = null; + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & 0x01F) == 0x04) { + DerValue subsubDer = subDer.getData().getDerValue(); + reqBody = new KDCReqBody(subsubDer, msgType); + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + } - /** - * Encodes this object to a byte array. - * - * @return an byte array of encoded data. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * - */ + /** + * Encodes this object to a byte array. + * + * @return an byte array of encoded data. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * + */ public byte[] asn1Encode() throws Asn1Exception, IOException { - DerOutputStream temp, bytes, out; - temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(pvno)); - out = new DerOutputStream(); - out.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp); - temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(msgType)); - out.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), temp); + DerOutputStream temp, bytes, out; + temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(pvno)); + out = new DerOutputStream(); + out.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x01), temp); + temp = new DerOutputStream(); + temp.putInteger(BigInteger.valueOf(msgType)); + out.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x02), temp); if (pAData != null && pAData.length > 0) { - temp = new DerOutputStream(); - for (int i = 0; i < pAData.length; i++) { - temp.write(pAData[i].asn1Encode()); - } - bytes = new DerOutputStream(); - bytes.write(DerValue.tag_SequenceOf, temp); - out.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), bytes); - } - out.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), reqBody.asn1Encode(msgType)); - bytes = new DerOutputStream(); - bytes.write(DerValue.tag_Sequence, out); - out = new DerOutputStream(); - out.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte)msgType), bytes); - return out.toByteArray(); - } - - public byte[] asn1EncodeReqBody() throws Asn1Exception, IOException - { - return reqBody.asn1Encode(msgType); + temp = new DerOutputStream(); + for (int i = 0; i < pAData.length; i++) { + temp.write(pAData[i].asn1Encode()); + } + bytes = new DerOutputStream(); + bytes.write(DerValue.tag_SequenceOf, temp); + out.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x03), bytes); } + out.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x04), reqBody.asn1Encode(msgType)); + bytes = new DerOutputStream(); + bytes.write(DerValue.tag_Sequence, out); + out = new DerOutputStream(); + out.write(DerValue.createTag(DerValue.TAG_APPLICATION, + true, (byte) msgType), bytes); + return out.toByteArray(); + } + public byte[] asn1EncodeReqBody() throws Asn1Exception, IOException { + return reqBody.asn1Encode(msgType); + } } diff --git a/src/share/classes/sun/security/krb5/internal/KRBCred.java b/src/share/classes/sun/security/krb5/internal/KRBCred.java index 2c364e834b01ba5ac268fe9b672783885bf7c9f7..a30ca6d2929379acb29b8c1fced208eb0b7095fc 100644 --- a/src/share/classes/sun/security/krb5/internal/KRBCred.java +++ b/src/share/classes/sun/security/krb5/internal/KRBCred.java @@ -56,128 +56,134 @@ import java.math.BigInteger; * * http://www.ietf.org/rfc/rfc4120.txt. */ - public class KRBCred { - public Ticket[] tickets = null; - public EncryptedData encPart; - private int pvno; - private int msgType; + public Ticket[] tickets = null; + public EncryptedData encPart; + private int pvno; + private int msgType; - public KRBCred(Ticket[] new_tickets, EncryptedData new_encPart) throws IOException { - pvno = Krb5.PVNO; - msgType = Krb5.KRB_CRED; - if (new_tickets != null) { - tickets = new Ticket[new_tickets.length]; - for (int i = 0; i < new_tickets.length; i++) { - if (new_tickets[i] == null) { - throw new IOException("Cannot create a KRBCred"); - } else { - tickets[i] = (Ticket)new_tickets[i].clone(); - } - } + public KRBCred(Ticket[] new_tickets, EncryptedData new_encPart) throws IOException { + pvno = Krb5.PVNO; + msgType = Krb5.KRB_CRED; + if (new_tickets != null) { + tickets = new Ticket[new_tickets.length]; + for (int i = 0; i < new_tickets.length; i++) { + if (new_tickets[i] == null) { + throw new IOException("Cannot create a KRBCred"); + } else { + tickets[i] = (Ticket) new_tickets[i].clone(); } - encPart = new_encPart; + } } + encPart = new_encPart; + } - public KRBCred(byte[] data) throws Asn1Exception, - RealmException, KrbApErrException, IOException { - init(new DerValue(data)); - } + public KRBCred(byte[] data) throws Asn1Exception, + RealmException, KrbApErrException, IOException { + init(new DerValue(data)); + } - public KRBCred(DerValue encoding) throws Asn1Exception, - RealmException, KrbApErrException, IOException { - init(encoding); - } + public KRBCred(DerValue encoding) throws Asn1Exception, + RealmException, KrbApErrException, IOException { + init(encoding); + } - /** - * Initializes an KRBCred object. - * @param encoding a single DER-encoded value. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - * @exception KrbApErrException if the value read from the DER-encoded data - * stream does not match the pre-defined value. - * @exception RealmException if an error occurs while parsing a Realm object. - */ - private void init(DerValue encoding) throws Asn1Exception, - RealmException, KrbApErrException, IOException { - if (((encoding.getTag() & (byte)0x1F) != (byte)0x16) - || (encoding.isApplication() != true) - || (encoding.isConstructed() != true)) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + /** + * Initializes an KRBCred object. + * @param encoding a single DER-encoded value. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + * @exception KrbApErrException if the value read from the DER-encoded data + * stream does not match the pre-defined value. + * @exception RealmException if an error occurs while parsing a Realm object. + */ + private void init(DerValue encoding) throws Asn1Exception, + RealmException, KrbApErrException, IOException { + if (((encoding.getTag() & (byte) 0x1F) != (byte) 0x16) + || (encoding.isApplication() != true) + || (encoding.isConstructed() != true)) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } DerValue der, subDer; - der = encoding.getData().getDerValue(); - if (der.getTag() != DerValue.tag_Sequence) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & 0x1F) == 0x00) { - pvno = subDer.getData().getBigInteger().intValue(); - if (pvno != Krb5.PVNO) { + der = encoding.getData().getDerValue(); + if (der.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & 0x1F) == 0x00) { + pvno = subDer.getData().getBigInteger().intValue(); + if (pvno != Krb5.PVNO) { throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION); - } - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - subDer = der.getData().getDerValue(); - if ((subDer.getTag() & 0x1F) == 0x01) { - msgType = subDer.getData().getBigInteger().intValue(); - if (msgType != Krb5.KRB_CRED) + } + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + subDer = der.getData().getDerValue(); + if ((subDer.getTag() & 0x1F) == 0x01) { + msgType = subDer.getData().getBigInteger().intValue(); + if (msgType != Krb5.KRB_CRED) { throw new KrbApErrException(Krb5.KRB_AP_ERR_MSG_TYPE); - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } subDer = der.getData().getDerValue(); - if ((subDer.getTag() & 0x1F) == 0x02) { - DerValue subsubDer = subDer.getData().getDerValue(); + if ((subDer.getTag() & 0x1F) == 0x02) { + DerValue subsubDer = subDer.getData().getDerValue(); if (subsubDer.getTag() != DerValue.tag_SequenceOf) { - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - } - Vector v = new Vector (); + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + Vector v = new Vector(); while (subsubDer.getData().available() > 0) { - v.addElement(new Ticket(subsubDer.getData().getDerValue())); - } + v.addElement(new Ticket(subsubDer.getData().getDerValue())); + } if (v.size() > 0) { - tickets = new Ticket[v.size()]; - v.copyInto(tickets); - } - } - else - throw new Asn1Exception(Krb5.ASN1_BAD_ID); - encPart = EncryptedData.parse(der.getData(), (byte)0x03, false); - - if (der.getData().available() > 0) - throw new Asn1Exception(Krb5.ASN1_BAD_ID); + tickets = new Ticket[v.size()]; + v.copyInto(tickets); + } + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); } + encPart = EncryptedData.parse(der.getData(), (byte) 0x03, false); + if (der.getData().available() > 0) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + } - /** - * Encodes an KRBCred object. - * @return the data of encoded EncAPRepPart object. - * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. - * @exception IOException if an I/O error occurs while reading encoded data. - */ - public byte[] asn1Encode() throws Asn1Exception, IOException { + /** + * Encodes an KRBCred object. + * @return the data of encoded EncAPRepPart object. + * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. + * @exception IOException if an I/O error occurs while reading encoded data. + */ + public byte[] asn1Encode() throws Asn1Exception, IOException { DerOutputStream temp, bytes, out; temp = new DerOutputStream(); temp.putInteger(BigInteger.valueOf(pvno)); out = new DerOutputStream(); - out.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp); - temp = new DerOutputStream(); - temp.putInteger(BigInteger.valueOf(msgType)); - out.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp); + out.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x00), temp); temp = new DerOutputStream(); - for (int i = 0; i < tickets.length; i++) { - temp.write(tickets[i].asn1Encode()); - } + temp.putInteger(BigInteger.valueOf(msgType)); + out.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x01), temp); + temp = new DerOutputStream(); + for (int i = 0; i < tickets.length; i++) { + temp.write(tickets[i].asn1Encode()); + } bytes = new DerOutputStream(); bytes.write(DerValue.tag_SequenceOf, temp); - out.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), bytes); - out.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), encPart.asn1Encode()); + out.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x02), bytes); + out.write(DerValue.createTag(DerValue.TAG_CONTEXT, + true, (byte) 0x03), encPart.asn1Encode()); bytes = new DerOutputStream(); bytes.write(DerValue.tag_Sequence, out); - out = new DerOutputStream(); - out.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte)0x16), bytes); - return out.toByteArray(); - } - + out = new DerOutputStream(); + out.write(DerValue.createTag(DerValue.TAG_APPLICATION, + true, (byte) 0x16), bytes); + return out.toByteArray(); + } } diff --git a/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java b/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java index 3853ab579cce0d195743b2fe3a5d9a872956b7cc..08a21b6658993d19ed6a7d700e5ed43c53ffe954 100644 --- a/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java +++ b/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java @@ -111,7 +111,7 @@ public class KrbCredInfo { * @exception RealmException if an error occurs while parsing a Realm object. */ public KrbCredInfo(DerValue encoding) - throws Asn1Exception, IOException, RealmException{ + throws Asn1Exception, IOException, RealmException{ if (encoding.getTag() != DerValue.tag_Sequence) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); } @@ -160,25 +160,25 @@ public class KrbCredInfo { Vector v = new Vector (); v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), key.asn1Encode())); if (prealm != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), prealm.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), prealm.asn1Encode())); if (pname != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), pname.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), pname.asn1Encode())); if (flags != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), flags.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), flags.asn1Encode())); if (authtime != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), authtime.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), authtime.asn1Encode())); if (starttime != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), starttime.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), starttime.asn1Encode())); if (endtime != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x06), endtime.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x06), endtime.asn1Encode())); if (renewTill != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x07), renewTill.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x07), renewTill.asn1Encode())); if (srealm != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x08), srealm.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x08), srealm.asn1Encode())); if (sname != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x09), sname.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x09), sname.asn1Encode())); if (caddr != null) - v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x0A), caddr.asn1Encode())); + v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x0A), caddr.asn1Encode())); DerValue der[] = new DerValue[v.size()]; v.copyInto(der); DerOutputStream out = new DerOutputStream(); diff --git a/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java b/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java index 5a62d6d2508fed4cf281066e0f6d72d965398735..64c3f8cd85bae7029baa796ea58a3d1462a1db86 100644 --- a/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java +++ b/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java @@ -215,7 +215,9 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC addrType = read(2); addrLength = read(4); if (!(addrLength == 4 || addrLength == 16)) { - System.out.println("Incorrect address format."); + if (DEBUG) { + System.out.println("Incorrect address format."); + } return null; } byte[] result = new byte[addrLength]; @@ -338,15 +340,19 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC System.out.println(">>>DEBUG key type: " + key.getEType()); long times[] = readTimes(); KerberosTime authtime = new KerberosTime(times[0]); - KerberosTime starttime = new KerberosTime(times[1]); + KerberosTime starttime = + (times[1]==0) ? null : new KerberosTime(times[1]); KerberosTime endtime = new KerberosTime(times[2]); - KerberosTime renewTill = new KerberosTime(times[3]); + KerberosTime renewTill = + (times[3]==0) ? null : new KerberosTime(times[3]); if (DEBUG) { System.out.println(">>>DEBUG auth time: " + authtime.toDate().toString()); - System.out.println(">>>DEBUG start time: " + starttime.toDate().toString()); + System.out.println(">>>DEBUG start time: " + + ((starttime==null)?"null":starttime.toDate().toString())); System.out.println(">>>DEBUG end time: " + endtime.toDate().toString()); - System.out.println(">>>DEBUG renew_till time: " + renewTill.toDate().toString()); + System.out.println(">>>DEBUG renew_till time: " + + ((renewTill==null)?"null":renewTill.toDate().toString())); } boolean skey = readskey(); boolean flags[] = readFlags(); diff --git a/src/share/classes/sun/security/krb5/internal/ccache/Credentials.java b/src/share/classes/sun/security/krb5/internal/ccache/Credentials.java index 4665d9f63dcc32ca5efa413e7336dec123975d9b..ff45cb73d37de7cbcce98169677440ca95185743 100644 --- a/src/share/classes/sun/security/krb5/internal/ccache/Credentials.java +++ b/src/share/classes/sun/security/krb5/internal/ccache/Credentials.java @@ -34,169 +34,185 @@ import sun.security.krb5.*; import sun.security.krb5.internal.*; public class Credentials { - PrincipalName cname; - Realm crealm; + + PrincipalName cname; + Realm crealm; PrincipalName sname; - Realm srealm; - EncryptionKey key; - KerberosTime authtime; - KerberosTime starttime;//optional - KerberosTime endtime; - KerberosTime renewTill; //optional - HostAddresses caddr; //optional; for proxied tickets only + Realm srealm; + EncryptionKey key; + KerberosTime authtime; + KerberosTime starttime;//optional + KerberosTime endtime; + KerberosTime renewTill; //optional + HostAddresses caddr; //optional; for proxied tickets only AuthorizationData authorizationData; //optional, not being actually used public boolean isEncInSKey; // true if ticket is encrypted in another ticket's skey - TicketFlags flags; + TicketFlags flags; Ticket ticket; - Ticket secondTicket; //optional - private boolean DEBUG = Krb5.DEBUG; - - public Credentials( - PrincipalName new_cname, - PrincipalName new_sname, - EncryptionKey new_key, - KerberosTime new_authtime, - KerberosTime new_starttime, - KerberosTime new_endtime, - KerberosTime new_renewTill, - boolean new_isEncInSKey, - TicketFlags new_flags, - HostAddresses new_caddr, - AuthorizationData new_authData, - Ticket new_ticket, - Ticket new_secondTicket) { - cname = (PrincipalName)new_cname.clone(); - if (new_cname.getRealm() != null) - crealm = (Realm)new_cname.getRealm().clone(); - - sname = (PrincipalName)new_sname.clone(); - if (new_sname.getRealm() != null) - srealm = (Realm)new_sname.getRealm().clone(); - - key = (EncryptionKey)new_key.clone(); - - authtime = (KerberosTime)new_authtime.clone(); - starttime = (KerberosTime)new_starttime.clone(); - endtime = (KerberosTime)new_endtime.clone(); - renewTill = (KerberosTime)new_renewTill.clone(); - if (new_caddr != null) - caddr = (HostAddresses)new_caddr.clone(); - if (new_authData != null) { - authorizationData - = (AuthorizationData)new_authData.clone(); - } - - isEncInSKey = new_isEncInSKey; - flags = (TicketFlags)new_flags.clone(); - ticket = (Ticket)(new_ticket.clone()); - if (new_secondTicket != null) - secondTicket = (Ticket)new_secondTicket.clone(); - } - - - - public Credentials( - KDCRep kdcRep, - Ticket new_secondTicket, - AuthorizationData new_authorizationData, - boolean new_isEncInSKey - ) { - if (kdcRep.encKDCRepPart == null) //can't store while encrypted - return; - crealm = (Realm)kdcRep.crealm.clone(); - cname = (PrincipalName)kdcRep.cname.clone(); - ticket = (Ticket)kdcRep.ticket.clone(); - key = (EncryptionKey)kdcRep.encKDCRepPart.key.clone(); - flags = (TicketFlags)kdcRep.encKDCRepPart.flags.clone(); - authtime = (KerberosTime)kdcRep.encKDCRepPart.authtime.clone(); - starttime = (KerberosTime)kdcRep.encKDCRepPart.starttime.clone(); - endtime = (KerberosTime)kdcRep.encKDCRepPart.endtime.clone(); - renewTill = (KerberosTime)kdcRep.encKDCRepPart.renewTill.clone(); - srealm = (Realm)kdcRep.encKDCRepPart.srealm.clone(); - sname = (PrincipalName)kdcRep.encKDCRepPart.sname.clone(); - caddr = (HostAddresses)kdcRep.encKDCRepPart.caddr.clone(); - secondTicket = (Ticket)new_secondTicket.clone(); - authorizationData = - (AuthorizationData)new_authorizationData.clone(); - isEncInSKey = new_isEncInSKey; - } - - public Credentials(KDCRep kdcRep) { - this(kdcRep, null); - } - - public Credentials(KDCRep kdcRep, Ticket new_ticket) { - sname = (PrincipalName)kdcRep.encKDCRepPart.sname.clone(); - srealm = (Realm)kdcRep.encKDCRepPart.srealm.clone(); - try { - sname.setRealm(srealm); - } - catch (RealmException e) { - } - cname = (PrincipalName)kdcRep.cname.clone(); - crealm = (Realm)kdcRep.crealm.clone(); - try { - cname.setRealm(crealm); - } - catch (RealmException e) { - } - key = (EncryptionKey)kdcRep.encKDCRepPart.key.clone(); - authtime = (KerberosTime)kdcRep.encKDCRepPart.authtime.clone(); - if (kdcRep.encKDCRepPart.starttime != null) { - starttime = (KerberosTime)kdcRep.encKDCRepPart.starttime.clone(); - } - else starttime = null; - endtime = (KerberosTime)kdcRep.encKDCRepPart.endtime.clone(); - if (kdcRep.encKDCRepPart.renewTill != null) { - renewTill = (KerberosTime)kdcRep.encKDCRepPart.renewTill.clone(); - } - else renewTill = null; - // if (kdcRep.msgType == Krb5.KRB_AS_REP) { - // isEncInSKey = false; - // secondTicket = null; - // } - flags = kdcRep.encKDCRepPart.flags; - if (kdcRep.encKDCRepPart.caddr != null) - caddr = (HostAddresses)kdcRep.encKDCRepPart.caddr.clone(); - else caddr = null; - ticket = (Ticket)kdcRep.ticket.clone(); - if (new_ticket != null) { - secondTicket = (Ticket)new_ticket.clone(); - isEncInSKey = true; - } else { - secondTicket = null; - isEncInSKey = false; - } - } - - /** - * Checks if this credential is expired - */ - public boolean isValid() { - boolean valid = true; - if (endtime.getTime() < System.currentTimeMillis()) { - valid = false; - } - else if ((starttime.getTime() > System.currentTimeMillis()) - || ((starttime == null) && (authtime.getTime() > System.currentTimeMillis()))) - { - valid = false; - } - return valid; - } - - public PrincipalName getServicePrincipal() throws RealmException{ - if (sname.getRealm() == null) { - sname.setRealm(srealm); - } - return sname; - } - - public sun.security.krb5.Credentials setKrbCreds() { - return new sun.security.krb5.Credentials(ticket, - cname, sname, key, flags, authtime, starttime, endtime, renewTill, caddr); + Ticket secondTicket; //optional + private boolean DEBUG = Krb5.DEBUG; + + public Credentials( + PrincipalName new_cname, + PrincipalName new_sname, + EncryptionKey new_key, + KerberosTime new_authtime, + KerberosTime new_starttime, + KerberosTime new_endtime, + KerberosTime new_renewTill, + boolean new_isEncInSKey, + TicketFlags new_flags, + HostAddresses new_caddr, + AuthorizationData new_authData, + Ticket new_ticket, + Ticket new_secondTicket) { + cname = (PrincipalName) new_cname.clone(); + if (new_cname.getRealm() != null) { + crealm = (Realm) new_cname.getRealm().clone(); + } + + sname = (PrincipalName) new_sname.clone(); + if (new_sname.getRealm() != null) { + srealm = (Realm) new_sname.getRealm().clone(); + } + + key = (EncryptionKey) new_key.clone(); + + authtime = (KerberosTime) new_authtime.clone(); + if (new_starttime != null) { + starttime = (KerberosTime) new_starttime.clone(); + } + endtime = (KerberosTime) new_endtime.clone(); + if (new_renewTill != null) { + renewTill = (KerberosTime) new_renewTill.clone(); + } + if (new_caddr != null) { + caddr = (HostAddresses) new_caddr.clone(); + } + if (new_authData != null) { + authorizationData = (AuthorizationData) new_authData.clone(); } + isEncInSKey = new_isEncInSKey; + flags = (TicketFlags) new_flags.clone(); + ticket = (Ticket) (new_ticket.clone()); + if (new_secondTicket != null) { + secondTicket = (Ticket) new_secondTicket.clone(); + } + } + + public Credentials( + KDCRep kdcRep, + Ticket new_secondTicket, + AuthorizationData new_authorizationData, + boolean new_isEncInSKey) { + if (kdcRep.encKDCRepPart == null) //can't store while encrypted + { + return; + } + crealm = (Realm) kdcRep.crealm.clone(); + cname = (PrincipalName) kdcRep.cname.clone(); + ticket = (Ticket) kdcRep.ticket.clone(); + key = (EncryptionKey) kdcRep.encKDCRepPart.key.clone(); + flags = (TicketFlags) kdcRep.encKDCRepPart.flags.clone(); + authtime = (KerberosTime) kdcRep.encKDCRepPart.authtime.clone(); + if (kdcRep.encKDCRepPart.starttime != null) { + starttime = (KerberosTime) kdcRep.encKDCRepPart.starttime.clone(); + } + endtime = (KerberosTime) kdcRep.encKDCRepPart.endtime.clone(); + if (kdcRep.encKDCRepPart.renewTill != null) { + renewTill = (KerberosTime) kdcRep.encKDCRepPart.renewTill.clone(); + } + srealm = (Realm) kdcRep.encKDCRepPart.srealm.clone(); + sname = (PrincipalName) kdcRep.encKDCRepPart.sname.clone(); + caddr = (HostAddresses) kdcRep.encKDCRepPart.caddr.clone(); + secondTicket = (Ticket) new_secondTicket.clone(); + authorizationData = + (AuthorizationData) new_authorizationData.clone(); + isEncInSKey = new_isEncInSKey; + } + + public Credentials(KDCRep kdcRep) { + this(kdcRep, null); + } + + public Credentials(KDCRep kdcRep, Ticket new_ticket) { + sname = (PrincipalName) kdcRep.encKDCRepPart.sname.clone(); + srealm = (Realm) kdcRep.encKDCRepPart.srealm.clone(); + try { + sname.setRealm(srealm); + } catch (RealmException e) { + } + cname = (PrincipalName) kdcRep.cname.clone(); + crealm = (Realm) kdcRep.crealm.clone(); + try { + cname.setRealm(crealm); + } catch (RealmException e) { + } + key = (EncryptionKey) kdcRep.encKDCRepPart.key.clone(); + authtime = (KerberosTime) kdcRep.encKDCRepPart.authtime.clone(); + if (kdcRep.encKDCRepPart.starttime != null) { + starttime = (KerberosTime) kdcRep.encKDCRepPart.starttime.clone(); + } else { + starttime = null; + } + endtime = (KerberosTime) kdcRep.encKDCRepPart.endtime.clone(); + if (kdcRep.encKDCRepPart.renewTill != null) { + renewTill = (KerberosTime) kdcRep.encKDCRepPart.renewTill.clone(); + } else { + renewTill = null; + } + // if (kdcRep.msgType == Krb5.KRB_AS_REP) { + // isEncInSKey = false; + // secondTicket = null; + // } + flags = kdcRep.encKDCRepPart.flags; + if (kdcRep.encKDCRepPart.caddr != null) { + caddr = (HostAddresses) kdcRep.encKDCRepPart.caddr.clone(); + } else { + caddr = null; + } + ticket = (Ticket) kdcRep.ticket.clone(); + if (new_ticket != null) { + secondTicket = (Ticket) new_ticket.clone(); + isEncInSKey = true; + } else { + secondTicket = null; + isEncInSKey = false; + } + } + + /** + * Checks if this credential is expired + */ + public boolean isValid() { + boolean valid = true; + if (endtime.getTime() < System.currentTimeMillis()) { + valid = false; + } else if (starttime != null) { + if (starttime.getTime() > System.currentTimeMillis()) { + valid = false; + } + } else { + if (authtime.getTime() > System.currentTimeMillis()) { + valid = false; + } + } + return valid; + } + + public PrincipalName getServicePrincipal() throws RealmException { + if (sname.getRealm() == null) { + sname.setRealm(srealm); + } + return sname; + } + + public sun.security.krb5.Credentials setKrbCreds() { + return new sun.security.krb5.Credentials(ticket, + cname, sname, key, flags, authtime, starttime, endtime, renewTill, caddr); + } + public KerberosTime getAuthTime() { return authtime; } diff --git a/src/share/classes/sun/security/krb5/internal/crypto/dk/AesDkCrypto.java b/src/share/classes/sun/security/krb5/internal/crypto/dk/AesDkCrypto.java index 31919fc51f5b6e83d2181fd41b942ba6ce95b169..ea6e2d3eb241722543106fc7c155eecd0922b07d 100644 --- a/src/share/classes/sun/security/krb5/internal/crypto/dk/AesDkCrypto.java +++ b/src/share/classes/sun/security/krb5/internal/crypto/dk/AesDkCrypto.java @@ -440,7 +440,9 @@ public class AesDkCrypto extends DkCrypto { for (int i = 0; i < hashSize; i++) { if (calculatedHmac[i] != ciphertext[hmacOffset+i]) { cksumFailed = true; - System.err.println("Checksum failed !"); + if (debug) { + System.err.println("Checksum failed !"); + } break; } } diff --git a/src/share/classes/sun/security/krb5/internal/crypto/dk/ArcFourCrypto.java b/src/share/classes/sun/security/krb5/internal/crypto/dk/ArcFourCrypto.java index 57a0c091721199eb5718eeb0fc8050442b2eed2c..8d4c89d60b3e956c6cf7a6bd08a18743c863ae54 100644 --- a/src/share/classes/sun/security/krb5/internal/crypto/dk/ArcFourCrypto.java +++ b/src/share/classes/sun/security/krb5/internal/crypto/dk/ArcFourCrypto.java @@ -397,7 +397,9 @@ public class ArcFourCrypto extends DkCrypto { for (int i = 0; i < hashSize; i++) { if (calculatedHmac[i] != ciphertext[i]) { cksumFailed = true; - System.err.println("Checksum failed !"); + if (debug) { + System.err.println("Checksum failed !"); + } break; } } diff --git a/src/share/classes/sun/security/pkcs11/P11Cipher.java b/src/share/classes/sun/security/pkcs11/P11Cipher.java index 4fca6f880a81f4d7b040bec7ecf09e35e2f3c1f0..f5da56bec64c7daa087680229263dd877b66b037 100644 --- a/src/share/classes/sun/security/pkcs11/P11Cipher.java +++ b/src/share/classes/sun/security/pkcs11/P11Cipher.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -22,10 +22,10 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ - package sun.security.pkcs11; import java.nio.ByteBuffer; +import java.util.Arrays; import java.security.*; import java.security.spec.*; @@ -34,7 +34,6 @@ import javax.crypto.*; import javax.crypto.spec.*; import sun.nio.ch.DirectBuffer; - import sun.security.pkcs11.wrapper.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*; @@ -43,8 +42,8 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*; * DES, DESede, AES, ARCFOUR, and Blowfish. * * This class is designed to support ECB and CBC with NoPadding and - * PKCS5Padding for both. However, currently only CBC/NoPadding (and - * ECB/NoPadding for stream ciphers) is functional. + * PKCS5Padding for both. It will use its own padding impl if the + * native mechanism does not support padding. * * Note that PKCS#11 current only supports ECB and CBC. There are no * provisions for other modes such as CFB, OFB, PCBC, or CTR mode. @@ -62,10 +61,59 @@ final class P11Cipher extends CipherSpi { private final static int MODE_CBC = 4; // padding constant for NoPadding - private final static int PAD_NONE = 5; + private final static int PAD_NONE = 5; // padding constant for PKCS5Padding private final static int PAD_PKCS5 = 6; + private static interface Padding { + // ENC: format the specified buffer with padding bytes and return the + // actual padding length + int setPaddingBytes(byte[] paddingBuffer, int padLen); + + // DEC: return the length of trailing padding bytes given the specified + // padded data + int unpad(byte[] paddedData, int len) + throws BadPaddingException; + } + + private static class PKCS5Padding implements Padding { + + private final int blockSize; + + PKCS5Padding(int blockSize) + throws NoSuchPaddingException { + if (blockSize == 0) { + throw new NoSuchPaddingException + ("PKCS#5 padding not supported with stream ciphers"); + } + this.blockSize = blockSize; + } + + public int setPaddingBytes(byte[] paddingBuffer, int padLen) { + Arrays.fill(paddingBuffer, 0, padLen, (byte) (padLen & 0x007f)); + return padLen; + } + + public int unpad(byte[] paddedData, int len) + throws BadPaddingException { + if (len < 1 || len > paddedData.length) { + throw new BadPaddingException("Invalid pad array length!"); + } + byte padValue = paddedData[len - 1]; + if (padValue < 1 || padValue > blockSize) { + throw new BadPaddingException("Invalid pad value!"); + } + // sanity check padding bytes + int padStartIndex = len - padValue; + for (int i = padStartIndex; i < len; i++) { + if (paddedData[i] != padValue) { + throw new BadPaddingException("Invalid pad bytes!"); + } + } + return padValue; + } + } + // token instance private final Token token; @@ -99,65 +147,93 @@ final class P11Cipher extends CipherSpi { // padding type, on of PAD_* above (PAD_NONE for stream ciphers) private int paddingType; + // when the padding is requested but unsupported by the native mechanism, + // we use the following to do padding and necessary data buffering. + // padding object which generate padding and unpad the decrypted data + private Padding paddingObj; + // buffer for holding back the block which contains padding bytes + private byte[] padBuffer; + private int padBufferLen; + // original IV, if in MODE_CBC private byte[] iv; - // total number of bytes processed - private int bytesProcessed; + // number of bytes buffered internally by the native mechanism and padBuffer + // if we do the padding + private int bytesBuffered; P11Cipher(Token token, String algorithm, long mechanism) - throws PKCS11Exception { + throws PKCS11Exception, NoSuchAlgorithmException { super(); this.token = token; this.algorithm = algorithm; this.mechanism = mechanism; - keyAlgorithm = algorithm.split("/")[0]; + + String algoParts[] = algorithm.split("/"); + keyAlgorithm = algoParts[0]; + if (keyAlgorithm.equals("AES")) { blockSize = 16; - blockMode = MODE_CBC; - // XXX change default to PKCS5Padding - paddingType = PAD_NONE; - } else if (keyAlgorithm.equals("RC4") || keyAlgorithm.equals("ARCFOUR")) { + } else if (keyAlgorithm.equals("RC4") || + keyAlgorithm.equals("ARCFOUR")) { blockSize = 0; - blockMode = MODE_ECB; - paddingType = PAD_NONE; } else { // DES, DESede, Blowfish blockSize = 8; - blockMode = MODE_CBC; - // XXX change default to PKCS5Padding - paddingType = PAD_NONE; + } + this.blockMode = + (algoParts.length > 1 ? parseMode(algoParts[1]) : MODE_ECB); + + String defPadding = (blockSize == 0 ? "NoPadding" : "PKCS5Padding"); + String paddingStr = + (algoParts.length > 2 ? algoParts[2] : defPadding); + try { + engineSetPadding(paddingStr); + } catch (NoSuchPaddingException nspe) { + // should not happen + throw new ProviderException(nspe); } session = token.getOpSession(); } protected void engineSetMode(String mode) throws NoSuchAlgorithmException { + // Disallow change of mode for now since currently it's explicitly + // defined in transformation strings + throw new NoSuchAlgorithmException("Unsupported mode " + mode); + } + + private int parseMode(String mode) throws NoSuchAlgorithmException { mode = mode.toUpperCase(); + int result; if (mode.equals("ECB")) { - this.blockMode = MODE_ECB; + result = MODE_ECB; } else if (mode.equals("CBC")) { if (blockSize == 0) { throw new NoSuchAlgorithmException ("CBC mode not supported with stream ciphers"); } - this.blockMode = MODE_CBC; + result = MODE_CBC; } else { throw new NoSuchAlgorithmException("Unsupported mode " + mode); } + return result; } // see JCE spec protected void engineSetPadding(String padding) throws NoSuchPaddingException { - if (padding.equalsIgnoreCase("NoPadding")) { + paddingObj = null; + padBuffer = null; + padding = padding.toUpperCase(); + if (padding.equals("NOPADDING")) { paddingType = PAD_NONE; - } else if (padding.equalsIgnoreCase("PKCS5Padding")) { - if (blockSize == 0) { - throw new NoSuchPaddingException - ("PKCS#5 padding not supported with stream ciphers"); - } + } else if (padding.equals("PKCS5PADDING")) { paddingType = PAD_PKCS5; - // XXX PKCS#5 not yet implemented - throw new NoSuchPaddingException("pkcs5"); + if (mechanism != CKM_DES_CBC_PAD && mechanism != CKM_DES3_CBC_PAD && + mechanism != CKM_AES_CBC_PAD) { + // no native padding support; use our own padding impl + paddingObj = new PKCS5Padding(blockSize); + padBuffer = new byte[blockSize]; + } } else { throw new NoSuchPaddingException("Unsupported padding " + padding); } @@ -175,7 +251,7 @@ final class P11Cipher extends CipherSpi { // see JCE spec protected byte[] engineGetIV() { - return (iv == null) ? null : (byte[])iv.clone(); + return (iv == null) ? null : (byte[]) iv.clone(); } // see JCE spec @@ -185,8 +261,9 @@ final class P11Cipher extends CipherSpi { } IvParameterSpec ivSpec = new IvParameterSpec(iv); try { - AlgorithmParameters params = AlgorithmParameters.getInstance - (keyAlgorithm, P11Util.getSunJceProvider()); + AlgorithmParameters params = + AlgorithmParameters.getInstance(keyAlgorithm, + P11Util.getSunJceProvider()); params.init(ivSpec); return params; } catch (GeneralSecurityException e) { @@ -210,38 +287,38 @@ final class P11Cipher extends CipherSpi { protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException { - byte[] iv; + byte[] ivValue; if (params != null) { if (params instanceof IvParameterSpec == false) { throw new InvalidAlgorithmParameterException ("Only IvParameterSpec supported"); } - IvParameterSpec ivSpec = (IvParameterSpec)params; - iv = ivSpec.getIV(); + IvParameterSpec ivSpec = (IvParameterSpec) params; + ivValue = ivSpec.getIV(); } else { - iv = null; + ivValue = null; } - implInit(opmode, key, iv, random); + implInit(opmode, key, ivValue, random); } // see JCE spec protected void engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException { - byte[] iv; + byte[] ivValue; if (params != null) { try { IvParameterSpec ivSpec = (IvParameterSpec) params.getParameterSpec(IvParameterSpec.class); - iv = ivSpec.getIV(); + ivValue = ivSpec.getIV(); } catch (InvalidParameterSpecException e) { throw new InvalidAlgorithmParameterException ("Could not decode IV", e); } } else { - iv = null; + ivValue = null; } - implInit(opmode, key, iv, random); + implInit(opmode, key, ivValue, random); } // actual init() implementation @@ -250,31 +327,31 @@ final class P11Cipher extends CipherSpi { throws InvalidKeyException, InvalidAlgorithmParameterException { cancelOperation(); switch (opmode) { - case Cipher.ENCRYPT_MODE: - encrypt = true; - break; - case Cipher.DECRYPT_MODE: - encrypt = false; - break; - default: - throw new InvalidAlgorithmParameterException - ("Unsupported mode: " + opmode); + case Cipher.ENCRYPT_MODE: + encrypt = true; + break; + case Cipher.DECRYPT_MODE: + encrypt = false; + break; + default: + throw new InvalidAlgorithmParameterException + ("Unsupported mode: " + opmode); } if (blockMode == MODE_ECB) { // ECB or stream cipher if (iv != null) { if (blockSize == 0) { throw new InvalidAlgorithmParameterException - ("IV not used with stream ciphers"); + ("IV not used with stream ciphers"); } else { throw new InvalidAlgorithmParameterException - ("IV not used in ECB mode"); + ("IV not used in ECB mode"); } } } else { // MODE_CBC if (iv == null) { if (encrypt == false) { throw new InvalidAlgorithmParameterException - ("IV must be specified for decryption in CBC mode"); + ("IV must be specified for decryption in CBC mode"); } // generate random IV if (random == null) { @@ -285,7 +362,7 @@ final class P11Cipher extends CipherSpi { } else { if (iv.length != blockSize) { throw new InvalidAlgorithmParameterException - ("IV length must match block size"); + ("IV length must match block size"); } } } @@ -331,63 +408,43 @@ final class P11Cipher extends CipherSpi { session = token.getOpSession(); } if (encrypt) { - token.p11.C_EncryptInit - (session.id(), new CK_MECHANISM(mechanism, iv), p11Key.keyID); + token.p11.C_EncryptInit(session.id(), + new CK_MECHANISM(mechanism, iv), p11Key.keyID); } else { - token.p11.C_DecryptInit - (session.id(), new CK_MECHANISM(mechanism, iv), p11Key.keyID); + token.p11.C_DecryptInit(session.id(), + new CK_MECHANISM(mechanism, iv), p11Key.keyID); } - bytesProcessed = 0; + bytesBuffered = 0; + padBufferLen = 0; initialized = true; } - // XXX the calculations below assume the PKCS#11 implementation is smart. - // conceivably, not all implementations are and we may need to estimate - // more conservatively - - private int bytesBuffered(int totalLen) { - if (paddingType == PAD_NONE) { - // with NoPadding, buffer only the current unfinished block - return totalLen & (blockSize - 1); - } else { // PKCS5 - // with PKCS5Padding in decrypt mode, the buffer must never - // be empty. Buffer a full block instead of nothing. - int buffered = totalLen & (blockSize - 1); - if ((buffered == 0) && (encrypt == false)) { - buffered = blockSize; - } - return buffered; - } - } - // if update(inLen) is called, how big does the output buffer have to be? private int updateLength(int inLen) { if (inLen <= 0) { return 0; } - if (blockSize == 0) { - return inLen; - } else { - // bytes that need to be buffered now - int buffered = bytesBuffered(bytesProcessed); - // bytes that need to be buffered after this update - int newBuffered = bytesBuffered(bytesProcessed + inLen); - return inLen + buffered - newBuffered; + + int result = inLen + bytesBuffered; + if (blockSize != 0) { + // minus the number of bytes in the last incomplete block. + result -= (result & (blockSize - 1)); } + return result; } // if doFinal(inLen) is called, how big does the output buffer have to be? private int doFinalLength(int inLen) { - if (paddingType == PAD_NONE) { - return updateLength(inLen); - } if (inLen < 0) { return 0; } - int buffered = bytesBuffered(bytesProcessed); - int newProcessed = bytesProcessed + inLen; - int paddedProcessed = (newProcessed + blockSize) & ~(blockSize - 1); - return paddedProcessed - bytesProcessed + buffered; + + int result = inLen + bytesBuffered; + if (blockSize != 0 && encrypt && paddingType != PAD_NONE) { + // add the number of bytes to make the last block complete. + result += (blockSize - (result & (blockSize - 1))); + } + return result; } // see JCE spec @@ -397,6 +454,7 @@ final class P11Cipher extends CipherSpi { int n = engineUpdate(in, inOfs, inLen, out, 0); return P11Util.convert(out, 0, n); } catch (ShortBufferException e) { + // convert since the output length is calculated by updateLength() throw new ProviderException(e); } } @@ -409,6 +467,7 @@ final class P11Cipher extends CipherSpi { } // see JCE spec + @Override protected int engineUpdate(ByteBuffer inBuffer, ByteBuffer outBuffer) throws ShortBufferException { return implUpdate(inBuffer, outBuffer); @@ -422,14 +481,15 @@ final class P11Cipher extends CipherSpi { int n = engineDoFinal(in, inOfs, inLen, out, 0); return P11Util.convert(out, 0, n); } catch (ShortBufferException e) { + // convert since the output length is calculated by doFinalLength() throw new ProviderException(e); } } // see JCE spec protected int engineDoFinal(byte[] in, int inOfs, int inLen, byte[] out, - int outOfs) throws ShortBufferException, IllegalBlockSizeException { - // BadPaddingException { + int outOfs) throws ShortBufferException, IllegalBlockSizeException, + BadPaddingException { int n = 0; if ((inLen != 0) && (in != null)) { n = engineUpdate(in, inOfs, inLen, out, outOfs); @@ -440,8 +500,10 @@ final class P11Cipher extends CipherSpi { } // see JCE spec + @Override protected int engineDoFinal(ByteBuffer inBuffer, ByteBuffer outBuffer) - throws ShortBufferException, IllegalBlockSizeException, BadPaddingException { + throws ShortBufferException, IllegalBlockSizeException, + BadPaddingException { int n = engineUpdate(inBuffer, outBuffer); n += implDoFinal(outBuffer); return n; @@ -454,18 +516,55 @@ final class P11Cipher extends CipherSpi { } try { ensureInitialized(); - int k; + int k = 0; if (encrypt) { - k = token.p11.C_EncryptUpdate - (session.id(), 0, in, inOfs, inLen, 0, out, outOfs, outLen); + k = token.p11.C_EncryptUpdate(session.id(), 0, in, inOfs, inLen, + 0, out, outOfs, outLen); } else { - k = token.p11.C_DecryptUpdate - (session.id(), 0, in, inOfs, inLen, 0, out, outOfs, outLen); + int newPadBufferLen = 0; + if (paddingObj != null) { + if (padBufferLen != 0) { + // NSS throws up when called with data not in multiple + // of blocks. Try to work around this by holding the + // extra data in padBuffer. + if (padBufferLen != padBuffer.length) { + int bufCapacity = padBuffer.length - padBufferLen; + if (inLen > bufCapacity) { + bufferInputBytes(in, inOfs, bufCapacity); + inOfs += bufCapacity; + inLen -= bufCapacity; + } else { + bufferInputBytes(in, inOfs, inLen); + return 0; + } + } + k = token.p11.C_DecryptUpdate(session.id(), + 0, padBuffer, 0, padBufferLen, + 0, out, outOfs, outLen); + padBufferLen = 0; + } + newPadBufferLen = inLen & (blockSize - 1); + if (newPadBufferLen == 0) { + newPadBufferLen = padBuffer.length; + } + inLen -= newPadBufferLen; + } + if (inLen > 0) { + k += token.p11.C_DecryptUpdate(session.id(), 0, in, inOfs, + inLen, 0, out, (outOfs + k), (outLen - k)); + } + // update 'padBuffer' if using our own padding impl. + if (paddingObj != null) { + bufferInputBytes(in, inOfs + inLen, newPadBufferLen); + } } - bytesProcessed += inLen; + bytesBuffered += (inLen - k); return k; } catch (PKCS11Exception e) { - // XXX throw correct exception + if (e.getErrorCode() == CKR_BUFFER_TOO_SMALL) { + throw (ShortBufferException) + (new ShortBufferException().initCause(e)); + } throw new ProviderException("update() failed", e); } } @@ -481,101 +580,167 @@ final class P11Cipher extends CipherSpi { if (outLen < updateLength(inLen)) { throw new ShortBufferException(); } - boolean inPosChanged = false; + int origPos = inBuffer.position(); try { ensureInitialized(); long inAddr = 0; - int inOfs = inBuffer.position(); + int inOfs = 0; byte[] inArray = null; + if (inBuffer instanceof DirectBuffer) { - inAddr = ((DirectBuffer)inBuffer).address(); - } else { - if (inBuffer.hasArray()) { - inArray = inBuffer.array(); - inOfs += inBuffer.arrayOffset(); - } else { - inArray = new byte[inLen]; - inBuffer.get(inArray); - inOfs = 0; - inPosChanged = true; - } + inAddr = ((DirectBuffer) inBuffer).address(); + inOfs = origPos; + } else if (inBuffer.hasArray()) { + inArray = inBuffer.array(); + inOfs = (origPos + inBuffer.arrayOffset()); } long outAddr = 0; - int outOfs = outBuffer.position(); + int outOfs = 0; byte[] outArray = null; if (outBuffer instanceof DirectBuffer) { - outAddr = ((DirectBuffer)outBuffer).address(); + outAddr = ((DirectBuffer) outBuffer).address(); + outOfs = outBuffer.position(); } else { if (outBuffer.hasArray()) { outArray = outBuffer.array(); - outOfs += outBuffer.arrayOffset(); + outOfs = (outBuffer.position() + outBuffer.arrayOffset()); } else { outArray = new byte[outLen]; - outOfs = 0; } } - int k; + int k = 0; if (encrypt) { - k = token.p11.C_EncryptUpdate - (session.id(), inAddr, inArray, inOfs, inLen, - outAddr, outArray, outOfs, outLen); + if (inAddr == 0 && inArray == null) { + inArray = new byte[inLen]; + inBuffer.get(inArray); + } else { + inBuffer.position(origPos + inLen); + } + k = token.p11.C_EncryptUpdate(session.id(), + inAddr, inArray, inOfs, inLen, + outAddr, outArray, outOfs, outLen); } else { - k = token.p11.C_DecryptUpdate - (session.id(), inAddr, inArray, inOfs, inLen, - outAddr, outArray, outOfs, outLen); - } - bytesProcessed += inLen; - if (!inPosChanged) { - inBuffer.position(inBuffer.position() + inLen); + int newPadBufferLen = 0; + if (paddingObj != null) { + if (padBufferLen != 0) { + // NSS throws up when called with data not in multiple + // of blocks. Try to work around this by holding the + // extra data in padBuffer. + if (padBufferLen != padBuffer.length) { + int bufCapacity = padBuffer.length - padBufferLen; + if (inLen > bufCapacity) { + bufferInputBytes(inBuffer, bufCapacity); + inOfs += bufCapacity; + inLen -= bufCapacity; + } else { + bufferInputBytes(inBuffer, inLen); + return 0; + } + } + k = token.p11.C_DecryptUpdate(session.id(), 0, + padBuffer, 0, padBufferLen, outAddr, outArray, + outOfs, outLen); + padBufferLen = 0; + } + newPadBufferLen = inLen & (blockSize - 1); + if (newPadBufferLen == 0) { + newPadBufferLen = padBuffer.length; + } + inLen -= newPadBufferLen; + } + if (inLen > 0) { + if (inAddr == 0 && inArray == null) { + inArray = new byte[inLen]; + inBuffer.get(inArray); + } else { + inBuffer.position(inBuffer.position() + inLen); + } + k += token.p11.C_DecryptUpdate(session.id(), inAddr, + inArray, inOfs, inLen, outAddr, outArray, + (outOfs + k), (outLen - k)); + } + // update 'padBuffer' if using our own padding impl. + if (paddingObj != null && newPadBufferLen != 0) { + bufferInputBytes(inBuffer, newPadBufferLen); + } } + bytesBuffered += (inLen - k); if (!(outBuffer instanceof DirectBuffer) && - !outBuffer.hasArray()) { + !outBuffer.hasArray()) { outBuffer.put(outArray, outOfs, k); } else { outBuffer.position(outBuffer.position() + k); } return k; } catch (PKCS11Exception e) { - // Un-read the bytes back to input buffer - if (inPosChanged) { - inBuffer.position(inBuffer.position() - inLen); + // Reset input buffer to its original position for + inBuffer.position(origPos); + if (e.getErrorCode() == CKR_BUFFER_TOO_SMALL) { + throw (ShortBufferException) + (new ShortBufferException().initCause(e)); } - // XXX throw correct exception throw new ProviderException("update() failed", e); } } private int implDoFinal(byte[] out, int outOfs, int outLen) - throws ShortBufferException, IllegalBlockSizeException { - if (outLen < doFinalLength(0)) { + throws ShortBufferException, IllegalBlockSizeException, + BadPaddingException { + int requiredOutLen = doFinalLength(0); + if (outLen < requiredOutLen) { throw new ShortBufferException(); } try { ensureInitialized(); + int k = 0; if (encrypt) { - return token.p11.C_EncryptFinal - (session.id(), 0, out, outOfs, outLen); + if (paddingObj != null) { + int actualPadLen = paddingObj.setPaddingBytes(padBuffer, + requiredOutLen - bytesBuffered); + k = token.p11.C_EncryptUpdate(session.id(), + 0, padBuffer, 0, actualPadLen, + 0, out, outOfs, outLen); + } + k += token.p11.C_EncryptFinal(session.id(), + 0, out, (outOfs + k), (outLen - k)); } else { - return token.p11.C_DecryptFinal - (session.id(), 0, out, outOfs, outLen); + if (paddingObj != null) { + if (padBufferLen != 0) { + k = token.p11.C_DecryptUpdate(session.id(), 0, + padBuffer, 0, padBufferLen, 0, padBuffer, 0, + padBuffer.length); + } + k += token.p11.C_DecryptFinal(session.id(), 0, padBuffer, k, + padBuffer.length - k); + int actualPadLen = paddingObj.unpad(padBuffer, k); + k -= actualPadLen; + System.arraycopy(padBuffer, 0, out, outOfs, k); + } else { + k = token.p11.C_DecryptFinal(session.id(), 0, out, outOfs, + outLen); + } } + return k; } catch (PKCS11Exception e) { handleException(e); throw new ProviderException("doFinal() failed", e); } finally { initialized = false; - bytesProcessed = 0; + bytesBuffered = 0; + padBufferLen = 0; session = token.releaseSession(session); } } private int implDoFinal(ByteBuffer outBuffer) - throws ShortBufferException, IllegalBlockSizeException { + throws ShortBufferException, IllegalBlockSizeException, + BadPaddingException { int outLen = outBuffer.remaining(); - if (outLen < doFinalLength(0)) { + int requiredOutLen = doFinalLength(0); + if (outLen < requiredOutLen) { throw new ShortBufferException(); } @@ -583,30 +748,54 @@ final class P11Cipher extends CipherSpi { ensureInitialized(); long outAddr = 0; - int outOfs = outBuffer.position(); byte[] outArray = null; + int outOfs = 0; if (outBuffer instanceof DirectBuffer) { - outAddr = ((DirectBuffer)outBuffer).address(); + outAddr = ((DirectBuffer) outBuffer).address(); + outOfs = outBuffer.position(); } else { if (outBuffer.hasArray()) { outArray = outBuffer.array(); - outOfs += outBuffer.arrayOffset(); + outOfs = outBuffer.position() + outBuffer.arrayOffset(); } else { outArray = new byte[outLen]; - outOfs = 0; } } - int k; + int k = 0; + if (encrypt) { - k = token.p11.C_EncryptFinal - (session.id(), outAddr, outArray, outOfs, outLen); + if (paddingObj != null) { + int actualPadLen = paddingObj.setPaddingBytes(padBuffer, + requiredOutLen - bytesBuffered); + k = token.p11.C_EncryptUpdate(session.id(), + 0, padBuffer, 0, actualPadLen, + outAddr, outArray, outOfs, outLen); + } + k += token.p11.C_EncryptFinal(session.id(), + outAddr, outArray, (outOfs + k), (outLen - k)); } else { - k = token.p11.C_DecryptFinal - (session.id(), outAddr, outArray, outOfs, outLen); + if (paddingObj != null) { + if (padBufferLen != 0) { + k = token.p11.C_DecryptUpdate(session.id(), + 0, padBuffer, 0, padBufferLen, + 0, padBuffer, 0, padBuffer.length); + padBufferLen = 0; + } + k += token.p11.C_DecryptFinal(session.id(), + 0, padBuffer, k, padBuffer.length - k); + int actualPadLen = paddingObj.unpad(padBuffer, k); + k -= actualPadLen; + outArray = padBuffer; + outOfs = 0; + } else { + k = token.p11.C_DecryptFinal(session.id(), + outAddr, outArray, outOfs, outLen); + } } - if (!(outBuffer instanceof DirectBuffer) && - !outBuffer.hasArray()) { + if ((!encrypt && paddingObj != null) || + (!(outBuffer instanceof DirectBuffer) && + !outBuffer.hasArray())) { outBuffer.put(outArray, outOfs, k); } else { outBuffer.position(outBuffer.position() + k); @@ -617,20 +806,22 @@ final class P11Cipher extends CipherSpi { throw new ProviderException("doFinal() failed", e); } finally { initialized = false; - bytesProcessed = 0; + bytesBuffered = 0; session = token.releaseSession(session); } } private void handleException(PKCS11Exception e) - throws IllegalBlockSizeException { + throws ShortBufferException, IllegalBlockSizeException { long errorCode = e.getErrorCode(); - // XXX better check - if (errorCode == CKR_DATA_LEN_RANGE) { - throw (IllegalBlockSizeException)new - IllegalBlockSizeException(e.toString()).initCause(e); + if (errorCode == CKR_BUFFER_TOO_SMALL) { + throw (ShortBufferException) + (new ShortBufferException().initCause(e)); + } else if (errorCode == CKR_DATA_LEN_RANGE || + errorCode == CKR_ENCRYPTED_DATA_LEN_RANGE) { + throw (IllegalBlockSizeException) + (new IllegalBlockSizeException(e.toString()).initCause(e)); } - } // see JCE spec @@ -649,12 +840,14 @@ final class P11Cipher extends CipherSpi { } // see JCE spec + @Override protected int engineGetKeySize(Key key) throws InvalidKeyException { int n = P11SecretKeyFactory.convertKey - (token, key, keyAlgorithm).keyLength(); + (token, key, keyAlgorithm).keyLength(); return n; } + @Override protected void finalize() throws Throwable { try { if ((session != null) && token.isValid()) { @@ -666,4 +859,15 @@ final class P11Cipher extends CipherSpi { } } + private final void bufferInputBytes(byte[] in, int inOfs, int len) { + System.arraycopy(in, inOfs, padBuffer, padBufferLen, len); + padBufferLen += len; + bytesBuffered += len; + } + + private final void bufferInputBytes(ByteBuffer inBuffer, int len) { + inBuffer.get(padBuffer, padBufferLen, len); + padBufferLen += len; + bytesBuffered += len; + } } diff --git a/src/share/classes/sun/security/pkcs11/P11KeyGenerator.java b/src/share/classes/sun/security/pkcs11/P11KeyGenerator.java index b49cbeac050015468b8d15403bc5740db34997f1..c08c12a26c486d201d28eb8d51e4b54d47d74e76 100644 --- a/src/share/classes/sun/security/pkcs11/P11KeyGenerator.java +++ b/src/share/classes/sun/security/pkcs11/P11KeyGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -65,10 +65,86 @@ final class P11KeyGenerator extends KeyGeneratorSpi { // are supported. private boolean supportBothKeySizes; - // min and max key sizes (in bits) for variable-key-length - // algorithms, e.g. RC4 and Blowfish - private int minKeySize; - private int maxKeySize; + /** + * Utility method for checking if the specified key size is valid + * and within the supported range. Return the significant key size + * upon successful validation. + * @param keyGenMech the PKCS#11 key generation mechanism. + * @param keySize the to-be-checked key size for this mechanism. + * @param token token which provides this mechanism. + * @return the significant key size (in bits) corresponding to the + * specified key size. + * @throws InvalidParameterException if the specified key size is invalid. + * @throws ProviderException if this mechanism isn't supported by SunPKCS11 + * or underlying native impl. + */ + static int checkKeySize(long keyGenMech, int keySize, Token token) + throws InvalidAlgorithmParameterException, ProviderException { + int sigKeySize; + switch ((int)keyGenMech) { + case (int)CKM_DES_KEY_GEN: + if ((keySize != 64) && (keySize != 56)) { + throw new InvalidAlgorithmParameterException + ("DES key length must be 56 bits"); + } + sigKeySize = 56; + break; + case (int)CKM_DES2_KEY_GEN: + case (int)CKM_DES3_KEY_GEN: + if ((keySize == 112) || (keySize == 128)) { + sigKeySize = 112; + } else if ((keySize == 168) || (keySize == 192)) { + sigKeySize = 168; + } else { + throw new InvalidAlgorithmParameterException + ("DESede key length must be 112, or 168 bits"); + } + break; + default: + // Handle all variable-key-length algorithms here + CK_MECHANISM_INFO info = null; + try { + info = token.getMechanismInfo(keyGenMech); + } catch (PKCS11Exception p11e) { + // Should never happen + throw new ProviderException + ("Cannot retrieve mechanism info", p11e); + } + if (info == null) { + // XXX Unable to retrieve the supported key length from + // the underlying native impl. Skip the checking for now. + return keySize; + } + // PKCS#11 defines these to be in number of bytes except for + // RC4 which is in bits. However, some PKCS#11 impls still use + // bytes for all mechs, e.g. NSS. We try to detect this + // inconsistency if the minKeySize seems unreasonably small. + int minKeySize = (int)info.ulMinKeySize; + int maxKeySize = (int)info.ulMaxKeySize; + if (keyGenMech != CKM_RC4_KEY_GEN || minKeySize < 8) { + minKeySize = (int)info.ulMinKeySize << 3; + maxKeySize = (int)info.ulMaxKeySize << 3; + } + // Explicitly disallow keys shorter than 40-bits for security + if (minKeySize < 40) minKeySize = 40; + if (keySize < minKeySize || keySize > maxKeySize) { + throw new InvalidAlgorithmParameterException + ("Key length must be between " + minKeySize + + " and " + maxKeySize + " bits"); + } + if (keyGenMech == CKM_AES_KEY_GEN) { + if ((keySize != 128) && (keySize != 192) && + (keySize != 256)) { + throw new InvalidAlgorithmParameterException + ("AES key length must be " + minKeySize + + (maxKeySize >= 192? ", 192":"") + + (maxKeySize >= 256? ", or 256":"") + " bits"); + } + } + sigKeySize = keySize; + } + return sigKeySize; + } P11KeyGenerator(Token token, String algorithm, long mechanism) throws PKCS11Exception { @@ -85,72 +161,44 @@ final class P11KeyGenerator extends KeyGeneratorSpi { supportBothKeySizes = (token.provider.config.isEnabled(CKM_DES2_KEY_GEN) && (token.getMechanismInfo(CKM_DES2_KEY_GEN) != null)); - } else if (this.mechanism == CKM_RC4_KEY_GEN) { - CK_MECHANISM_INFO info = token.getMechanismInfo(mechanism); - // Although PKCS#11 spec documented that these are in bits, - // NSS, for one, uses bytes. Multiple by 8 if the number seems - // unreasonably small. - if (info.ulMinKeySize < 8) { - minKeySize = (int)info.ulMinKeySize << 3; - maxKeySize = (int)info.ulMaxKeySize << 3; - } else { - minKeySize = (int)info.ulMinKeySize; - maxKeySize = (int)info.ulMaxKeySize; - } - // Explicitly disallow keys shorter than 40-bits for security - if (minKeySize < 40) minKeySize = 40; - } else if (this.mechanism == CKM_BLOWFISH_KEY_GEN) { - CK_MECHANISM_INFO info = token.getMechanismInfo(mechanism); - maxKeySize = (int)info.ulMaxKeySize << 3; - minKeySize = (int)info.ulMinKeySize << 3; - // Explicitly disallow keys shorter than 40-bits for security - if (minKeySize < 40) minKeySize = 40; } - setDefaultKeySize(); } // set default keysize and also initialize keyType private void setDefaultKeySize() { - // whether to check default key size against the min and max value - boolean validateKeySize = false; switch ((int)mechanism) { case (int)CKM_DES_KEY_GEN: keySize = 64; - significantKeySize = 56; keyType = CKK_DES; break; case (int)CKM_DES2_KEY_GEN: keySize = 128; - significantKeySize = 112; keyType = CKK_DES2; break; case (int)CKM_DES3_KEY_GEN: keySize = 192; - significantKeySize = 168; keyType = CKK_DES3; break; case (int)CKM_AES_KEY_GEN: - keyType = CKK_AES; keySize = 128; - significantKeySize = 128; + keyType = CKK_AES; break; case (int)CKM_RC4_KEY_GEN: - keyType = CKK_RC4; keySize = 128; - validateKeySize = true; + keyType = CKK_RC4; break; case (int)CKM_BLOWFISH_KEY_GEN: - keyType = CKK_BLOWFISH; keySize = 128; - validateKeySize = true; + keyType = CKK_BLOWFISH; break; default: throw new ProviderException("Unknown mechanism " + mechanism); } - if (validateKeySize && - ((keySize > maxKeySize) || (keySize < minKeySize))) { - throw new ProviderException("Unsupported key size"); + try { + significantKeySize = checkKeySize(mechanism, keySize, token); + } catch (InvalidAlgorithmParameterException iape) { + throw new ProviderException("Unsupported default key size", iape); } } @@ -170,57 +218,32 @@ final class P11KeyGenerator extends KeyGeneratorSpi { // see JCE spec protected void engineInit(int keySize, SecureRandom random) { token.ensureValid(); - switch ((int)mechanism) { - case (int)CKM_DES_KEY_GEN: - if ((keySize != this.keySize) && - (keySize != this.significantKeySize)) { - throw new InvalidParameterException - ("DES key length must be 56 bits"); - } - break; - case (int)CKM_DES2_KEY_GEN: - case (int)CKM_DES3_KEY_GEN: - long newMechanism; - if ((keySize == 112) || (keySize == 128)) { - newMechanism = CKM_DES2_KEY_GEN; - } else if ((keySize == 168) || (keySize == 192)) { - newMechanism = CKM_DES3_KEY_GEN; - } else { - throw new InvalidParameterException - ("DESede key length must be 112, or 168 bits"); - } + int newSignificantKeySize; + try { + newSignificantKeySize = checkKeySize(mechanism, keySize, token); + } catch (InvalidAlgorithmParameterException iape) { + throw (InvalidParameterException) + (new InvalidParameterException().initCause(iape)); + } + if ((mechanism == CKM_DES2_KEY_GEN) || + (mechanism == CKM_DES3_KEY_GEN)) { + long newMechanism = (newSignificantKeySize == 112 ? + CKM_DES2_KEY_GEN : CKM_DES3_KEY_GEN); if (mechanism != newMechanism) { if (supportBothKeySizes) { mechanism = newMechanism; - setDefaultKeySize(); + // Adjust keyType to reflect the mechanism change + keyType = (mechanism == CKM_DES2_KEY_GEN ? + CKK_DES2 : CKK_DES3); } else { throw new InvalidParameterException - ("Only " + significantKeySize + - "-bit DESede key length is supported"); + ("Only " + significantKeySize + + "-bit DESede is supported"); } } - break; - case (int)CKM_AES_KEY_GEN: - if ((keySize != 128) && (keySize != 192) && (keySize != 256)) { - throw new InvalidParameterException - ("AES key length must be 128, 192, or 256 bits"); - } - this.keySize = keySize; - significantKeySize = keySize; - break; - case (int)CKM_RC4_KEY_GEN: - case (int)CKM_BLOWFISH_KEY_GEN: - if ((keySize < minKeySize) || (keySize > maxKeySize)) { - throw new InvalidParameterException - (algorithm + " key length must be between " + - minKeySize + " and " + maxKeySize + " bits"); - } - this.keySize = keySize; - this.significantKeySize = keySize; - break; - default: - throw new ProviderException("Unknown mechanism " + mechanism); } + this.keySize = keySize; + this.significantKeySize = newSignificantKeySize; } // see JCE spec diff --git a/src/share/classes/sun/security/pkcs11/P11KeyStore.java b/src/share/classes/sun/security/pkcs11/P11KeyStore.java index 26382d71b6dfbb6bd685e2e565921b605df68910..839a2f3ba64bcc02ca5411012843e78cf15e290a 100644 --- a/src/share/classes/sun/security/pkcs11/P11KeyStore.java +++ b/src/share/classes/sun/security/pkcs11/P11KeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -156,10 +156,10 @@ final class P11KeyStore extends KeyStoreSpi { // CKA_CLASS - entry type private CK_ATTRIBUTE type = null; - // CKA_LABEL of cert + // CKA_LABEL of cert and secret key private String label = null; - // CKA_ID - of private key/cert + // CKA_ID of the private key/cert pair private byte[] id = null; // CKA_TRUSTED - true if cert is trusted @@ -871,10 +871,8 @@ final class P11KeyStore extends KeyStoreSpi { if ((token.tokenInfo.flags & CKF_PROTECTED_AUTHENTICATION_PATH) == 0) { token.provider.login(null, handler); } else { - // token supports protected authentication path // (external pin-pad, for example) - if (handler != null && !token.config.getKeyStoreCompatibilityMode()) { throw new LoginException("can not specify password if token " + @@ -1130,19 +1128,14 @@ final class P11KeyStore extends KeyStoreSpi { SecretKey skey = ske.getSecretKey(); try { - // first see if the key already exists. - // if so, update the CKA_LABEL - if (!updateSkey(alias)) { - - // key entry does not exist. - // delete existing entry for alias and - // create new secret key entry - // (new entry might be a secret key - // session object converted into a token object) + // first check if the key already exists + AliasInfo aliasInfo = aliasMap.get(alias); + if (aliasInfo != null) { engineDeleteEntry(alias); - storeSkey(alias, ske); } + storeSkey(alias, ske); + } catch (PKCS11Exception pe) { throw new KeyStoreException(pe); } @@ -1396,41 +1389,6 @@ final class P11KeyStore extends KeyStoreSpi { } } - /** - * return true if update occurred - */ - private boolean updateSkey(String alias) - throws KeyStoreException, PKCS11Exception { - - Session session = null; - try { - session = token.getOpSession(); - - // first update existing secret key CKA_LABEL - - THandle h = getTokenObject(session, ATTR_CLASS_SKEY, null, alias); - if (h.type != ATTR_CLASS_SKEY) { - if (debug != null) { - debug.println("did not find secret key " + - "with CKA_LABEL [" + alias + "]"); - } - return false; - } - CK_ATTRIBUTE[] attrs = new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_LABEL, alias) }; - token.p11.C_SetAttributeValue(session.id(), h.handle, attrs); - - if (debug != null) { - debug.println("updateSkey set new alias [" + - alias + - "] for secret key entry"); - } - - return true; - } finally { - token.releaseSession(session); - } - } /** * XXX On ibutton, when you C_SetAttribute(CKA_ID) for a private key @@ -1532,30 +1490,6 @@ final class P11KeyStore extends KeyStoreSpi { } } - private void updateP11Skey(String alias, P11Key key) - throws PKCS11Exception { - - Session session = null; - try { - session = token.getOpSession(); - - // session key - convert to token key and set CKA_LABEL - - CK_ATTRIBUTE[] attrs = new CK_ATTRIBUTE[] { - ATTR_TOKEN_TRUE, - new CK_ATTRIBUTE(CKA_LABEL, alias) }; - token.p11.C_CopyObject(session.id(), key.keyID, attrs); - if (debug != null) { - debug.println("updateP11Skey copied secret session key " + - "for [" + - alias + - "] to token entry"); - } - } finally { - token.releaseSession(session); - } - } - private void updateP11Pkey(String alias, CK_ATTRIBUTE attribute, P11Key key) throws PKCS11Exception { @@ -1689,48 +1623,26 @@ final class P11KeyStore extends KeyStoreSpi { throws PKCS11Exception, KeyStoreException { SecretKey skey = ske.getSecretKey(); - long keyType = CKK_GENERIC_SECRET; - - if (skey instanceof P11Key && this.token == ((P11Key)skey).token) { - updateP11Skey(alias, (P11Key)skey); - return; - } - - if ("AES".equalsIgnoreCase(skey.getAlgorithm())) { - keyType = CKK_AES; - } else if ("Blowfish".equalsIgnoreCase(skey.getAlgorithm())) { - keyType = CKK_BLOWFISH; - } else if ("DES".equalsIgnoreCase(skey.getAlgorithm())) { - keyType = CKK_DES; - } else if ("DESede".equalsIgnoreCase(skey.getAlgorithm())) { - keyType = CKK_DES3; - } else if ("RC4".equalsIgnoreCase(skey.getAlgorithm()) || - "ARCFOUR".equalsIgnoreCase(skey.getAlgorithm())) { - keyType = CKK_RC4; + // No need to specify CKA_CLASS, CKA_KEY_TYPE, CKA_VALUE since + // they are handled in P11SecretKeyFactory.createKey() method. + CK_ATTRIBUTE[] attrs = new CK_ATTRIBUTE[] { + ATTR_SKEY_TOKEN_TRUE, + ATTR_PRIVATE_TRUE, + new CK_ATTRIBUTE(CKA_LABEL, alias), + }; + try { + P11SecretKeyFactory.convertKey(token, skey, null, attrs); + } catch (InvalidKeyException ike) { + // re-throw KeyStoreException to match javadoc + throw new KeyStoreException("Cannot convert to PKCS11 keys", ike); } - CK_ATTRIBUTE[] attrs = new CK_ATTRIBUTE[] { - ATTR_SKEY_TOKEN_TRUE, - ATTR_CLASS_SKEY, - ATTR_PRIVATE_TRUE, - new CK_ATTRIBUTE(CKA_KEY_TYPE, keyType), - new CK_ATTRIBUTE(CKA_LABEL, alias), - new CK_ATTRIBUTE(CKA_VALUE, skey.getEncoded()) }; - attrs = token.getAttributes - (TemplateManager.O_IMPORT, CKO_SECRET_KEY, keyType, attrs); + // update global alias map + aliasMap.put(alias, new AliasInfo(alias)); - // create the new entry - Session session = null; - try { - session = token.getOpSession(); - token.p11.C_CreateObject(session.id(), attrs); - if (debug != null) { - debug.println("storeSkey created token secret key for [" + - alias + - "]"); - } - } finally { - token.releaseSession(session); + if (debug != null) { + debug.println("storeSkey created token secret key for [" + + alias + "]"); } } @@ -2492,7 +2404,8 @@ final class P11KeyStore extends KeyStoreSpi { // if there are duplicates (either between secret keys, // or between a secret key and another object), // throw an exception - HashSet sKeySet = new HashSet(); + HashMap sKeyMap = + new HashMap(); attrs = new CK_ATTRIBUTE[] { ATTR_SKEY_TOKEN_TRUE, @@ -2507,8 +2420,8 @@ final class P11KeyStore extends KeyStoreSpi { // there is a CKA_LABEL String cka_label = new String(attrs[0].getCharArray()); - if (!sKeySet.contains(cka_label)) { - sKeySet.add(cka_label); + if (sKeyMap.get(cka_label) == null) { + sKeyMap.put(cka_label, new AliasInfo(cka_label)); } else { throw new KeyStoreException("invalid KeyStore state: " + "found multiple secret keys sharing same " + @@ -2523,7 +2436,7 @@ final class P11KeyStore extends KeyStoreSpi { ArrayList matchedCerts = mapPrivateKeys(pkeyIDs, certMap); boolean sharedLabel = mapCerts(matchedCerts, certMap); - mapSecretKeys(sKeySet); + mapSecretKeys(sKeyMap); return sharedLabel; @@ -2547,7 +2460,7 @@ final class P11KeyStore extends KeyStoreSpi { HashMap> certMap) throws PKCS11Exception, CertificateException { - // global alias map + // reset global alias map aliasMap = new HashMap(); // list of matched certs that we will return @@ -2722,18 +2635,17 @@ final class P11KeyStore extends KeyStoreSpi { * If the secret key shares a CKA_LABEL with another entry, * throw an exception */ - private void mapSecretKeys(HashSet sKeySet) + private void mapSecretKeys(HashMap sKeyMap) throws KeyStoreException { - for (String label : sKeySet) { - if (!aliasMap.containsKey(label)) { - aliasMap.put(label, new AliasInfo(label)); - } else { + for (String label : sKeyMap.keySet()) { + if (aliasMap.containsKey(label)) { throw new KeyStoreException("invalid KeyStore state: " + "found secret key sharing CKA_LABEL [" + label + "] with another token object"); } } + aliasMap.putAll(sKeyMap); } private void dumpTokenMap() { diff --git a/src/share/classes/sun/security/pkcs11/P11RSACipher.java b/src/share/classes/sun/security/pkcs11/P11RSACipher.java index e2060c739fa75836fc2a7e68143aa15c17293ee8..3b8244cc413a2ee8d3da6e0a415eab5d690e0b2d 100644 --- a/src/share/classes/sun/security/pkcs11/P11RSACipher.java +++ b/src/share/classes/sun/security/pkcs11/P11RSACipher.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -98,7 +98,6 @@ final class P11RSACipher extends CipherSpi { this.token = token; this.algorithm = "RSA"; this.mechanism = mechanism; - session = token.getOpSession(); } // modes do not make sense for RSA, but allow ECB @@ -184,7 +183,8 @@ final class P11RSACipher extends CipherSpi { throw new InvalidKeyException ("Wrap has to be used with public keys"); } - // No further setup needed for C_Wrap(). We remain uninitialized. + // No further setup needed for C_Wrap(). We'll initialize later if + // we can't use C_Wrap(). return; } else if (opmode == Cipher.UNWRAP_MODE) { if (p11Key.isPrivate() == false) { @@ -383,7 +383,8 @@ final class P11RSACipher extends CipherSpi { return implDoFinal(out, outOfs, out.length - outOfs); } - private byte[] doFinal() throws BadPaddingException, IllegalBlockSizeException { + private byte[] doFinal() throws BadPaddingException, + IllegalBlockSizeException { byte[] t = new byte[2048]; int n = implDoFinal(t, 0, t.length); byte[] out = new byte[n]; @@ -394,20 +395,37 @@ final class P11RSACipher extends CipherSpi { // see JCE spec protected byte[] engineWrap(Key key) throws InvalidKeyException, IllegalBlockSizeException { - // XXX Note that if we cannot convert key to a key on this token, - // we will fail. For example, trying a wrap an AES key on a token that - // does not support AES. - // We could implement a fallback that just encrypts the encoding - // (assuming the key is not sensitive). For now, we are operating under - // the assumption that this is not necessary. String keyAlg = key.getAlgorithm(); - P11Key secretKey = P11SecretKeyFactory.convertKey(token, key, keyAlg); + P11Key sKey = null; + try { + // The conversion may fail, e.g. trying to wrap an AES key on + // a token that does not support AES, or when the key size is + // not within the range supported by the token. + sKey = P11SecretKeyFactory.convertKey(token, key, keyAlg); + } catch (InvalidKeyException ike) { + byte[] toBeWrappedKey = key.getEncoded(); + if (toBeWrappedKey == null) { + throw new InvalidKeyException + ("wrap() failed, no encoding available", ike); + } + // Directly encrypt the key encoding when key conversion failed + implInit(Cipher.ENCRYPT_MODE, p11Key); + implUpdate(toBeWrappedKey, 0, toBeWrappedKey.length); + try { + return doFinal(); + } catch (BadPaddingException bpe) { + // should not occur + throw new InvalidKeyException("wrap() failed", bpe); + } finally { + // Restore original mode + implInit(Cipher.WRAP_MODE, p11Key); + } + } Session s = null; try { s = token.getOpSession(); - byte[] b = token.p11.C_WrapKey(s.id(), new CK_MECHANISM(mechanism), - p11Key.keyID, secretKey.keyID); - return b; + return token.p11.C_WrapKey(s.id(), new CK_MECHANISM(mechanism), + p11Key.keyID, sKey.keyID); } catch (PKCS11Exception e) { throw new InvalidKeyException("wrap() failed", e); } finally { @@ -431,11 +449,13 @@ final class P11RSACipher extends CipherSpi { }; attributes = token.getAttributes (O_IMPORT, CKO_SECRET_KEY, keyType, attributes); - long keyID = token.p11.C_UnwrapKey(s.id(), new CK_MECHANISM(mechanism), - p11Key.keyID, wrappedKey, attributes); - return P11Key.secretKey(session, keyID, algorithm, 48 << 3, attributes); + long keyID = token.p11.C_UnwrapKey(s.id(), + new CK_MECHANISM(mechanism), p11Key.keyID, wrappedKey, + attributes); + return P11Key.secretKey(session, keyID, algorithm, 48 << 3, + attributes); } catch (PKCS11Exception e) { - throw new InvalidKeyException("wrap() failed", e); + throw new InvalidKeyException("unwrap() failed", e); } finally { token.releaseSession(s); } diff --git a/src/share/classes/sun/security/pkcs11/P11SecretKeyFactory.java b/src/share/classes/sun/security/pkcs11/P11SecretKeyFactory.java index bd09447c189133a389c607f7135ed5b02b4b0a3e..59b59237a6ffaa72adcce7ed3b0d1578b5236908 100644 --- a/src/share/classes/sun/security/pkcs11/P11SecretKeyFactory.java +++ b/src/share/classes/sun/security/pkcs11/P11SecretKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -104,9 +104,20 @@ final class P11SecretKeyFactory extends SecretKeyFactorySpi { /** * Convert an arbitrary key of algorithm into a P11Key of provider. - * Used engineTranslateKey(), P11Cipher.init(), and P11Mac.init(). + * Used in engineTranslateKey(), P11Cipher.init(), and P11Mac.init(). */ - static P11Key convertKey(Token token, Key key, String algorithm) + static P11Key convertKey(Token token, Key key, String algo) + throws InvalidKeyException { + return convertKey(token, key, algo, null); + } + + /** + * Convert an arbitrary key of algorithm w/ custom attributes into a + * P11Key of provider. + * Used in P11KeyStore.storeSkey. + */ + static P11Key convertKey(Token token, Key key, String algo, + CK_ATTRIBUTE[] extraAttrs) throws InvalidKeyException { token.ensureValid(); if (key == null) { @@ -115,25 +126,41 @@ final class P11SecretKeyFactory extends SecretKeyFactorySpi { if (key instanceof SecretKey == false) { throw new InvalidKeyException("Key must be a SecretKey"); } - long algorithmType; - if (algorithm == null) { - algorithm = key.getAlgorithm(); - algorithmType = getKeyType(algorithm); + long algoType; + if (algo == null) { + algo = key.getAlgorithm(); + algoType = getKeyType(algo); } else { - algorithmType = getKeyType(algorithm); + algoType = getKeyType(algo); long keyAlgorithmType = getKeyType(key.getAlgorithm()); - if (algorithmType != keyAlgorithmType) { - if ((algorithmType == PCKK_HMAC) || (algorithmType == PCKK_SSLMAC)) { + if (algoType != keyAlgorithmType) { + if ((algoType == PCKK_HMAC) || (algoType == PCKK_SSLMAC)) { // ignore key algorithm for MACs } else { throw new InvalidKeyException - ("Key algorithm must be " + algorithm); + ("Key algorithm must be " + algo); } } } if (key instanceof P11Key) { P11Key p11Key = (P11Key)key; if (p11Key.token == token) { + if (extraAttrs != null) { + Session session = null; + try { + session = token.getObjSession(); + long newKeyID = token.p11.C_CopyObject(session.id(), + p11Key.keyID, extraAttrs); + p11Key = (P11Key) (P11Key.secretKey(p11Key.session, + newKeyID, p11Key.algorithm, p11Key.keyLength, + extraAttrs)); + } catch (PKCS11Exception p11e) { + throw new InvalidKeyException + ("Cannot duplicate the PKCS11 key", p11e); + } finally { + token.releaseSession(session); + } + } return p11Key; } } @@ -141,11 +168,11 @@ final class P11SecretKeyFactory extends SecretKeyFactorySpi { if (p11Key != null) { return p11Key; } - if ("RAW".equals(key.getFormat()) == false) { + if ("RAW".equalsIgnoreCase(key.getFormat()) == false) { throw new InvalidKeyException("Encoded format must be RAW"); } byte[] encoded = key.getEncoded(); - p11Key = createKey(token, encoded, algorithm, algorithmType); + p11Key = createKey(token, encoded, algo, algoType, extraAttrs); token.secretCache.put(key, p11Key); return p11Key; } @@ -159,79 +186,79 @@ final class P11SecretKeyFactory extends SecretKeyFactorySpi { } private static P11Key createKey(Token token, byte[] encoded, - String algorithm, long keyType) throws InvalidKeyException { - int n = encoded.length; - int keyLength; - switch ((int)keyType) { - case (int)CKK_RC4: - if ((n < 5) || (n > 128)) { - throw new InvalidKeyException - ("ARCFOUR key length must be between 5 and 128 bytes"); - } - keyLength = n << 3; - break; - case (int)CKK_DES: - if (n != 8) { - throw new InvalidKeyException - ("DES key length must be 8 bytes"); - } - keyLength = 56; - fixDESParity(encoded, 0); - break; - case (int)CKK_DES3: - if (n == 16) { - keyType = CKK_DES2; - } else if (n == 24) { - keyType = CKK_DES3; - fixDESParity(encoded, 16); - } else { - throw new InvalidKeyException - ("DESede key length must be 16 or 24 bytes"); - } - fixDESParity(encoded, 0); - fixDESParity(encoded, 8); - keyLength = n * 7; - break; - case (int)CKK_AES: - if ((n != 16) && (n != 24) && (n != 32)) { - throw new InvalidKeyException - ("AES key length must be 16, 24, or 32 bytes"); - } - keyLength = n << 3; - break; - case (int)CKK_BLOWFISH: - if ((n < 5) || (n > 56)) { - throw new InvalidKeyException - ("Blowfish key length must be between 5 and 56 bytes"); - } - keyLength = n << 3; - break; - case (int)CKK_GENERIC_SECRET: - case (int)PCKK_TLSPREMASTER: - case (int)PCKK_TLSRSAPREMASTER: - case (int)PCKK_TLSMASTER: - keyType = CKK_GENERIC_SECRET; - keyLength = n << 3; - break; - case (int)PCKK_SSLMAC: - case (int)PCKK_HMAC: - if (n == 0) { - throw new InvalidKeyException - ("MAC keys must not be empty"); + String algorithm, long keyType, CK_ATTRIBUTE[] extraAttrs) + throws InvalidKeyException { + int n = encoded.length << 3; + int keyLength = n; + try { + switch ((int)keyType) { + case (int)CKK_DES: + keyLength = + P11KeyGenerator.checkKeySize(CKM_DES_KEY_GEN, n, token); + fixDESParity(encoded, 0); + break; + case (int)CKK_DES3: + keyLength = + P11KeyGenerator.checkKeySize(CKM_DES3_KEY_GEN, n, token); + fixDESParity(encoded, 0); + fixDESParity(encoded, 8); + if (keyLength == 112) { + keyType = CKK_DES2; + } else { + keyType = CKK_DES3; + fixDESParity(encoded, 16); + } + break; + case (int)CKK_AES: + keyLength = + P11KeyGenerator.checkKeySize(CKM_AES_KEY_GEN, n, token); + break; + case (int)CKK_RC4: + keyLength = + P11KeyGenerator.checkKeySize(CKM_RC4_KEY_GEN, n, token); + break; + case (int)CKK_BLOWFISH: + keyLength = + P11KeyGenerator.checkKeySize(CKM_BLOWFISH_KEY_GEN, n, + token); + break; + case (int)CKK_GENERIC_SECRET: + case (int)PCKK_TLSPREMASTER: + case (int)PCKK_TLSRSAPREMASTER: + case (int)PCKK_TLSMASTER: + keyType = CKK_GENERIC_SECRET; + break; + case (int)PCKK_SSLMAC: + case (int)PCKK_HMAC: + if (n == 0) { + throw new InvalidKeyException + ("MAC keys must not be empty"); + } + keyType = CKK_GENERIC_SECRET; + break; + default: + throw new InvalidKeyException("Unknown algorithm " + + algorithm); } - keyType = CKK_GENERIC_SECRET; - keyLength = n << 3; - break; - default: - throw new InvalidKeyException("Unknown algorithm " + algorithm); + } catch (InvalidAlgorithmParameterException iape) { + throw new InvalidKeyException("Invalid key for " + algorithm, + iape); + } catch (ProviderException pe) { + throw new InvalidKeyException("Could not create key", pe); } Session session = null; try { - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_CLASS, CKO_SECRET_KEY), - new CK_ATTRIBUTE(CKA_KEY_TYPE, keyType), - new CK_ATTRIBUTE(CKA_VALUE, encoded), - }; + CK_ATTRIBUTE[] attributes; + if (extraAttrs != null) { + attributes = new CK_ATTRIBUTE[3 + extraAttrs.length]; + System.arraycopy(extraAttrs, 0, attributes, 3, + extraAttrs.length); + } else { + attributes = new CK_ATTRIBUTE[3]; + } + attributes[0] = new CK_ATTRIBUTE(CKA_CLASS, CKO_SECRET_KEY); + attributes[1] = new CK_ATTRIBUTE(CKA_KEY_TYPE, keyType); + attributes[2] = new CK_ATTRIBUTE(CKA_VALUE, encoded); attributes = token.getAttributes (O_IMPORT, CKO_SECRET_KEY, keyType, attributes); session = token.getObjSession(); @@ -280,7 +307,7 @@ final class P11SecretKeyFactory extends SecretKeyFactorySpi { private byte[] getKeyBytes(SecretKey key) throws InvalidKeySpecException { try { key = engineTranslateKey(key); - if ("RAW".equals(key.getFormat()) == false) { + if ("RAW".equalsIgnoreCase(key.getFormat()) == false) { throw new InvalidKeySpecException ("Could not obtain key bytes"); } diff --git a/src/share/classes/sun/security/pkcs11/SunPKCS11.java b/src/share/classes/sun/security/pkcs11/SunPKCS11.java index c98bbdbb4a738d5559bf4ec6b806c2476447f354..88d8d4b73939b6e2fb76887e49e16d08d74f495e 100644 --- a/src/share/classes/sun/security/pkcs11/SunPKCS11.java +++ b/src/share/classes/sun/security/pkcs11/SunPKCS11.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -601,14 +601,26 @@ public final class SunPKCS11 extends AuthProvider { // XXX attributes for Ciphers (supported modes, padding) d(CIP, "ARCFOUR", P11Cipher, s("RC4"), m(CKM_RC4)); - // XXX only CBC/NoPadding for block ciphers d(CIP, "DES/CBC/NoPadding", P11Cipher, m(CKM_DES_CBC)); + d(CIP, "DES/CBC/PKCS5Padding", P11Cipher, + m(CKM_DES_CBC_PAD, CKM_DES_CBC)); + d(CIP, "DES/ECB", P11Cipher, s("DES"), + m(CKM_DES_ECB)); + d(CIP, "DESede/CBC/NoPadding", P11Cipher, m(CKM_DES3_CBC)); + d(CIP, "DESede/CBC/PKCS5Padding", P11Cipher, + m(CKM_DES3_CBC_PAD, CKM_DES3_CBC)); + d(CIP, "DESede/ECB", P11Cipher, s("DESede"), + m(CKM_DES3_ECB)); d(CIP, "AES/CBC/NoPadding", P11Cipher, m(CKM_AES_CBC)); - d(CIP, "Blowfish/CBC/NoPadding", P11Cipher, + d(CIP, "AES/CBC/PKCS5Padding", P11Cipher, + m(CKM_AES_CBC_PAD, CKM_AES_CBC)); + d(CIP, "AES/ECB", P11Cipher, s("AES"), + m(CKM_AES_ECB)); + d(CIP, "Blowfish/CBC", P11Cipher, m(CKM_BLOWFISH_CBC)); // XXX RSA_X_509, RSA_OAEP not yet supported diff --git a/src/share/classes/sun/security/ssl/CipherSuite.java b/src/share/classes/sun/security/ssl/CipherSuite.java index 794f7179f2061f5a073335b4bd00ffc76c6ab98b..81a3696f7afcddb875c5dea7f9377bdb8812c392 100644 --- a/src/share/classes/sun/security/ssl/CipherSuite.java +++ b/src/share/classes/sun/security/ssl/CipherSuite.java @@ -191,7 +191,7 @@ final class CipherSuite implements Comparable { if (s == null) { throw new IllegalArgumentException("Name must not be null"); } - CipherSuite c = (CipherSuite)nameMap.get(s); + CipherSuite c = nameMap.get(s); if ((c == null) || (c.allowed == false)) { throw new IllegalArgumentException("Unsupported ciphersuite " + s); } @@ -395,7 +395,7 @@ final class CipherSuite implements Comparable { } private static synchronized boolean isAvailable(BulkCipher cipher) { - Boolean b = (Boolean)availableCache.get(cipher); + Boolean b = availableCache.get(cipher); if (b == null) { try { SecretKey key = new SecretKeySpec diff --git a/src/share/classes/sun/security/ssl/DHCrypt.java b/src/share/classes/sun/security/ssl/DHCrypt.java index baf784cde2bc3cdb14d18959c1b9e7bd5a7248de..5c9dc14aac207baf989e76c56e05628bc8874d25 100644 --- a/src/share/classes/sun/security/ssl/DHCrypt.java +++ b/src/share/classes/sun/security/ssl/DHCrypt.java @@ -132,8 +132,7 @@ final class DHCrypt { } try { KeyFactory factory = JsseJce.getKeyFactory("DH"); - return (DHPublicKeySpec)factory.getKeySpec - (key, DHPublicKeySpec.class); + return factory.getKeySpec(key, DHPublicKeySpec.class); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/src/share/classes/sun/security/ssl/Handshaker.java b/src/share/classes/sun/security/ssl/Handshaker.java index b8395665d5a3373bb7f16de9f8d08f7533b2b9ac..5b9dae6c59084f5dc9a3ce97cd7cd18f3e34f2f4 100644 --- a/src/share/classes/sun/security/ssl/Handshaker.java +++ b/src/share/classes/sun/security/ssl/Handshaker.java @@ -617,7 +617,8 @@ abstract class Handshaker { r.write(1); // single byte of data if (conn != null) { - synchronized (conn.writeLock) { + conn.writeLock.lock(); + try { conn.writeRecord(r); conn.changeWriteCiphers(); if (debug != null && Debug.isOn("handshake")) { @@ -625,6 +626,8 @@ abstract class Handshaker { } mesg.write(output); output.flush(); + } finally { + conn.writeLock.unlock(); } } else { synchronized (engine.writeLock) { diff --git a/src/share/classes/sun/security/ssl/InputRecord.java b/src/share/classes/sun/security/ssl/InputRecord.java index 56ea2b0483e4fea9c15e0e34fc72aefab7096201..c0e3e4aa526ab29a58eda28573ff5371daa03947 100644 --- a/src/share/classes/sun/security/ssl/InputRecord.java +++ b/src/share/classes/sun/security/ssl/InputRecord.java @@ -426,12 +426,12 @@ class InputRecord extends ByteArrayInputStream implements Record { if (really < 0) { throw new SSLException("SSL peer shut down incorrectly"); } - - // now we've got a complete record. - count = contentLen + headerSize; - exlen = 0; } + // now we've got a complete record. + count = contentLen + headerSize; + exlen = 0; + if (debug != null && Debug.isOn("record")) { if (count < 0 || count > (maxRecordSize - headerSize)) { System.out.println(Thread.currentThread().getName() @@ -502,10 +502,11 @@ class InputRecord extends ByteArrayInputStream implements Record { if (really < 0) { throw new EOFException("SSL peer shut down incorrectly"); } - - // now we've got a complete record. - exlen = 0; } + + // now we've got a complete record. + exlen = 0; + hashInternal(buf, 2, 3); hashInternal(v2Buf, 0, len); V2toV3ClientHello(v2Buf); diff --git a/src/share/classes/sun/security/ssl/JsseJce.java b/src/share/classes/sun/security/ssl/JsseJce.java index 5fb6972874f644d2d981d2894397eff32df9461d..d9a40fb2b8474f068470d3cb9844e18a459d8abc 100644 --- a/src/share/classes/sun/security/ssl/JsseJce.java +++ b/src/share/classes/sun/security/ssl/JsseJce.java @@ -343,8 +343,7 @@ final class JsseJce { } try { KeyFactory factory = JsseJce.getKeyFactory("RSA"); - return (RSAPublicKeySpec)factory.getKeySpec - (key, RSAPublicKeySpec.class); + return factory.getKeySpec(key, RSAPublicKeySpec.class); } catch (Exception e) { throw (RuntimeException)new RuntimeException().initCause(e); } diff --git a/src/share/classes/sun/security/ssl/OutputRecord.java b/src/share/classes/sun/security/ssl/OutputRecord.java index 3153b07f1acced0d51b3d8470ce07dda81897fe3..3d580e5cd5b6cde93b3f73192f2d8e353b52ce51 100644 --- a/src/share/classes/sun/security/ssl/OutputRecord.java +++ b/src/share/classes/sun/security/ssl/OutputRecord.java @@ -174,6 +174,18 @@ class OutputRecord extends ByteArrayOutputStream implements Record { return count == headerSize; } + /* + * Return true if the record is of a given alert. + */ + boolean isAlert(byte description) { + // An alert is defined with a two bytes struct, + // {byte level, byte description}, following after the header bytes. + if (count > (headerSize + 1) && contentType == ct_alert) { + return buf[headerSize + 1] == description; + } + + return false; + } /* * Compute the MAC and append it to this record. In case we diff --git a/src/share/classes/sun/security/ssl/ProtocolList.java b/src/share/classes/sun/security/ssl/ProtocolList.java index 9898d244a2005b05a21c939028796af496ba99ee..197cfa4adbb31a4a674c5707bab5f71391fa794e 100644 --- a/src/share/classes/sun/security/ssl/ProtocolList.java +++ b/src/share/classes/sun/security/ssl/ProtocolList.java @@ -98,7 +98,7 @@ final class ProtocolList { protocolNames[i++] = version.name; } } - return (String[])protocolNames.clone(); + return protocolNames.clone(); } public String toString() { diff --git a/src/share/classes/sun/security/ssl/SSLSessionImpl.java b/src/share/classes/sun/security/ssl/SSLSessionImpl.java index 38d666ac337959c63ec10c1182e8fd967fe6183a..a37954ea22e4153d6915690c3cece837a1664f11 100644 --- a/src/share/classes/sun/security/ssl/SSLSessionImpl.java +++ b/src/share/classes/sun/security/ssl/SSLSessionImpl.java @@ -458,7 +458,7 @@ final class SSLSessionImpl implements SSLSession { + " for Kerberos cipher suites"); } if (peerCerts != null) { - return (X509Certificate [])peerCerts.clone(); + return peerCerts.clone(); } else { throw new SSLPeerUnverifiedException("peer not authenticated"); } @@ -489,7 +489,7 @@ final class SSLSessionImpl implements SSLSession { if (peerCerts == null) { throw new SSLPeerUnverifiedException("peer not authenticated"); } - return ((X500Principal)peerCerts[0].getSubjectX500Principal()); + return peerCerts[0].getSubjectX500Principal(); } /** @@ -508,7 +508,7 @@ final class SSLSessionImpl implements SSLSession { (KerberosPrincipal)localPrincipal); } return (localCerts == null ? null : - (X500Principal)localCerts[0].getSubjectX500Principal()); + localCerts[0].getSubjectX500Principal()); } /** diff --git a/src/share/classes/sun/security/ssl/SSLSocketImpl.java b/src/share/classes/sun/security/ssl/SSLSocketImpl.java index 0b8a16c0958954b0f8df80bc29ff1c30465ce272..66b6e6d112c0b7cf5856457bb37d17a951cbcc37 100644 --- a/src/share/classes/sun/security/ssl/SSLSocketImpl.java +++ b/src/share/classes/sun/security/ssl/SSLSocketImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, 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 @@ -33,6 +33,8 @@ import java.security.AccessController; import java.security.AccessControlContext; import java.security.PrivilegedAction; import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.ReentrantLock; import javax.crypto.BadPaddingException; @@ -274,7 +276,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { * from the peer are handled properly. */ private Object handshakeLock; - Object writeLock; + ReentrantLock writeLock; private Object readLock; private InputRecord inrec; @@ -314,7 +316,6 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { private HashMap handshakeListeners; - /* * Reuse the same internal input/output streams. */ @@ -526,7 +527,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { enabledCipherSuites = CipherSuiteList.getDefault(); enabledProtocols = ProtocolList.getDefault(); handshakeLock = new Object(); - writeLock = new Object(); + writeLock = new ReentrantLock(); readLock = new Object(); inrec = null; @@ -677,16 +678,81 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { // implementations are fragile and don't like to see empty // records, so this also increases robustness. // - synchronized (writeLock) { - if (!r.isEmpty()) { - // r.compress(c); - r.addMAC(writeMAC); - r.encrypt(writeCipher); - r.write(sockOutput); + if (!r.isEmpty()) { + + // If the record is a close notify alert, we need to honor + // socket option SO_LINGER. Note that we will try to send + // the close notify even if the SO_LINGER set to zero. + if (r.isAlert(Alerts.alert_close_notify) && getSoLinger() >= 0) { + + // keep and clear the current thread interruption status. + boolean interrupted = Thread.interrupted(); + try { + if (writeLock.tryLock(getSoLinger(), TimeUnit.SECONDS)) { + try { + writeRecordInternal(r); + } finally { + writeLock.unlock(); + } + } else { + SSLException ssle = new SSLException( + "SO_LINGER timeout," + + " close_notify message cannot be sent."); + + + // For layered, non-autoclose sockets, we are not + // able to bring them into a usable state, so we + // treat it as fatal error. + if (self != this && !autoClose) { + // Note that the alert description is + // specified as -1, so no message will be send + // to peer anymore. + fatal((byte)(-1), ssle); + } else if ((debug != null) && Debug.isOn("ssl")) { + System.out.println(threadName() + + ", received Exception: " + ssle); + } + + // RFC2246 requires that the session becomes + // unresumable if any connection is terminated + // without proper close_notify messages with + // level equal to warning. + // + // RFC4346 no longer requires that a session not be + // resumed if failure to properly close a connection. + // + // We choose to make the session unresumable if + // failed to send the close_notify message. + // + sess.invalidate(); + } + } catch (InterruptedException ie) { + // keep interrupted status + interrupted = true; + } + + // restore the interrupted status + if (interrupted) { + Thread.currentThread().interrupt(); + } + } else { + writeLock.lock(); + try { + writeRecordInternal(r); + } finally { + writeLock.unlock(); + } } } } + private void writeRecordInternal(OutputRecord r) throws IOException { + // r.compress(c); + r.addMAC(writeMAC); + r.encrypt(writeCipher); + r.write(sockOutput); + } + /* * Read an application data record. Alerts and handshake @@ -1533,7 +1599,11 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { if (oldState == cs_HANDSHAKE) { sockInput.skip(sockInput.available()); } - sendAlert(Alerts.alert_fatal, description); + + // If the description equals -1, the alert won't be sent to peer. + if (description != -1) { + sendAlert(Alerts.alert_fatal, description); + } if (cause instanceof SSLException) { // only true if != null closeReason = (SSLException)cause; } else { @@ -1614,7 +1684,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { * Emit alerts. Caller must have synchronized with "this". */ private void sendAlert(byte level, byte description) { - if (connectionState >= cs_CLOSED) { + if (connectionState >= cs_SENT_CLOSE) { return; } diff --git a/src/share/classes/sun/security/ssl/SessionId.java b/src/share/classes/sun/security/ssl/SessionId.java index 557fbff30c842d87e35c9b778f6c5735deab28f1..c9b900f743ad685940167443a319a8d8768886a4 100644 --- a/src/share/classes/sun/security/ssl/SessionId.java +++ b/src/share/classes/sun/security/ssl/SessionId.java @@ -64,7 +64,7 @@ class SessionId /** Returns the bytes in the ID. May be an empty array. */ byte [] getId () { - return (byte []) sessionId.clone (); + return sessionId.clone (); } /** Returns the ID as a string */ diff --git a/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java b/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java index a111f79b42761bacf3a8672da6ef41f50da4da06..2cd825def268f4d6b21dfe502f00111066572a06 100644 --- a/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java +++ b/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java @@ -172,7 +172,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager { if (cred == null) { return null; } else { - return (X509Certificate[])cred.certificates.clone(); + return cred.certificates.clone(); } } @@ -255,7 +255,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager { String[] aliases; if (issuers == null || issuers.length == 0) { - aliases = (String[])serverAliasCache.get(keyType); + aliases = serverAliasCache.get(keyType); if (aliases == null) { aliases = getServerAliases(keyType, issuers); // Cache the result (positive and negative lookups) @@ -388,7 +388,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager { } } - String[] aliasStrings = (String[])aliases.toArray(STRING0); + String[] aliasStrings = aliases.toArray(STRING0); return ((aliasStrings.length == 0) ? null : aliasStrings); } diff --git a/src/share/classes/sun/security/validator/EndEntityChecker.java b/src/share/classes/sun/security/validator/EndEntityChecker.java index f0fb1787fa35909076475c06477919de0f685f82..189db3dd058e57bc0535ee7cc728a580ef57d842 100644 --- a/src/share/classes/sun/security/validator/EndEntityChecker.java +++ b/src/share/classes/sun/security/validator/EndEntityChecker.java @@ -87,6 +87,9 @@ class EndEntityChecker { // the Microsoft Server-Gated-Cryptography EKU extension OID private final static String OID_EKU_MS_SGC = "1.3.6.1.4.1.311.10.3.3"; + // the recognized extension OIDs + private final static String OID_SUBJECT_ALT_NAME = "2.5.29.17"; + private final static String NSCT_SSL_CLIENT = NetscapeCertTypeExtension.SSL_CLIENT; @@ -171,6 +174,13 @@ class EndEntityChecker { throws CertificateException { // basic constraints irrelevant in EE certs exts.remove(SimpleValidator.OID_BASIC_CONSTRAINTS); + + // If the subject field contains an empty sequence, the subjectAltName + // extension MUST be marked critical. + // We do not check the validity of the critical extension, just mark + // it recognizable here. + exts.remove(OID_SUBJECT_ALT_NAME); + if (!exts.isEmpty()) { throw new CertificateException("Certificate contains unsupported " + "critical extensions: " + exts); diff --git a/src/share/classes/sun/security/x509/AVA.java b/src/share/classes/sun/security/x509/AVA.java index 9a6b7a59d1a41c58d958e0e6bf0fc00dd08ff6ae..43d914cba13ea7b58734b7ac25732bc8665972ac 100644 --- a/src/share/classes/sun/security/x509/AVA.java +++ b/src/share/classes/sun/security/x509/AVA.java @@ -780,7 +780,8 @@ public class AVA implements DerEncoder { * Implementations MAY escape other characters. * * NOTE: this implementation also recognizes "=" and "#" as - * characters which need escaping. + * characters which need escaping, and null which is escaped as + * '\00' (see RFC 4514). * * If a character to be escaped is one of the list shown above, then * it is prefixed by a backslash ('\' ASCII 92). @@ -805,6 +806,10 @@ public class AVA implements DerEncoder { // append printable/escaped char sbuffer.append(c); + } else if (c == '\u0000') { + // escape null character + sbuffer.append("\\00"); + } else if (debug != null && Debug.isOn("ava")) { // embed non-printable/non-escaped char diff --git a/src/share/classes/sun/security/x509/CertificatePolicySet.java b/src/share/classes/sun/security/x509/CertificatePolicySet.java index 32e5121c76a3b89cd8a3d0c79b6c7e7164ba7202..514a3576cc47a964a99abf62aa722476f0ca98c6 100644 --- a/src/share/classes/sun/security/x509/CertificatePolicySet.java +++ b/src/share/classes/sun/security/x509/CertificatePolicySet.java @@ -87,7 +87,7 @@ public class CertificatePolicySet { DerOutputStream tmp = new DerOutputStream(); for (int i = 0; i < ids.size(); i++) { - ((CertificatePolicyId)ids.elementAt(i)).encode(tmp); + ids.elementAt(i).encode(tmp); } out.write(DerValue.tag_Sequence,tmp); } diff --git a/src/share/classes/sun/security/x509/X509Cert.java b/src/share/classes/sun/security/x509/X509Cert.java index 6777d4b4a2ff08ef906b6a28a0360f1c519c94ad..af68511129412f6c7ebf94b6aab704146691b316 100644 --- a/src/share/classes/sun/security/x509/X509Cert.java +++ b/src/share/classes/sun/security/x509/X509Cert.java @@ -516,7 +516,7 @@ public class X509Cert implements Certificate, Serializable { * Null is returned in the case of a partially constructed cert. */ public byte [] getSignedCert () - { return (byte[])signedCert.clone(); } + { return signedCert.clone(); } /** diff --git a/src/share/classes/sun/tools/jar/JarVerifierStream.java b/src/share/classes/sun/tools/jar/JarVerifierStream.java index 5485bfaded9969b082171ba8d0c0ec34a6272ed8..c39b35eaa172e3b5e1907c4155f5c3ae5b085e19 100644 --- a/src/share/classes/sun/tools/jar/JarVerifierStream.java +++ b/src/share/classes/sun/tools/jar/JarVerifierStream.java @@ -32,7 +32,6 @@ import java.util.jar.*; import java.security.cert.Certificate; import java.security.AccessController; import java.security.cert.X509Certificate; -import java.security.Identity; import java.security.PublicKey; import java.security.Principal; import sun.security.provider.SystemIdentity; @@ -49,7 +48,8 @@ import sun.security.provider.SystemIdentity; public class JarVerifierStream extends ZipInputStream { private JarEntry current; - private Hashtable verified = new Hashtable(); + private Hashtable> verified + = new Hashtable>(); private JarInputStream jis; private sun.tools.jar.Manifest man = null; @@ -120,7 +120,7 @@ public class JarVerifierStream extends ZipInputStream { if (current != null) { Certificate[] certs = current.getCertificates(); if (certs != null) { - Vector ids = getIds(certs); + Vector ids = getIds(certs); if (ids != null) { verified.put(current.getName(), ids); } @@ -189,7 +189,7 @@ public class JarVerifierStream extends ZipInputStream { static class CertCache { Certificate [] certs; - Vector ids; + Vector ids; boolean equals(Certificate[] certs) { if (this.certs == null) { @@ -229,21 +229,21 @@ public class JarVerifierStream extends ZipInputStream { } } - private ArrayList certCache = null; + private ArrayList certCache = null; /** * Returns the Identity vector for the given array of Certificates */ - protected Vector getIds(Certificate[] certs) { + protected Vector getIds(Certificate[] certs) { if (certs == null) return null; if (certCache == null) - certCache = new ArrayList(); + certCache = new ArrayList(); CertCache cc; for (int i = 0; i < certCache.size(); i++) { - cc = (CertCache) certCache.get(i); + cc = certCache.get(i); if (cc.equals(certs)) { return cc.ids; } @@ -265,8 +265,8 @@ public class JarVerifierStream extends ZipInputStream { new sun.security.x509.X509Cert(encoded); try { AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() + new java.security.PrivilegedExceptionAction() { + public Void run() throws java.security.KeyManagementException { id.addCertificate(oldC); @@ -278,7 +278,7 @@ public class JarVerifierStream extends ZipInputStream { pae.getException(); } if (cc.ids == null) - cc.ids = new Vector(); + cc.ids = new Vector(); cc.ids.addElement(id); } catch (java.security.KeyManagementException kme) { // ignore if we can't create Identity diff --git a/src/share/classes/sun/tools/jconsole/MBeansTab.java b/src/share/classes/sun/tools/jconsole/MBeansTab.java index c2055d0916c9910307bbed85e9caf6feb47787c8..53260144e6353545f258aa0e02551accfb1f8885 100644 --- a/src/share/classes/sun/tools/jconsole/MBeansTab.java +++ b/src/share/classes/sun/tools/jconsole/MBeansTab.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2004-2007 Sun Microsystems, 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 @@ -26,6 +26,7 @@ package sun.tools.jconsole; import java.awt.BorderLayout; +import java.awt.EventQueue; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -42,7 +43,8 @@ import com.sun.tools.jconsole.JConsoleContext; @SuppressWarnings("serial") public class MBeansTab extends Tab implements - NotificationListener, PropertyChangeListener, TreeSelectionListener { + NotificationListener, PropertyChangeListener, + TreeSelectionListener, TreeWillExpandListener { private XTree tree; private XSheet sheet; @@ -70,6 +72,7 @@ public class MBeansTab extends Tab implements return sheet; } + @Override public void dispose() { super.dispose(); sheet.dispose(); @@ -79,61 +82,79 @@ public class MBeansTab extends Tab implements return vmPanel.getUpdateInterval(); } - void synchroniseMBeanServerView() { - // Register listener for MBean registration/unregistration - // - try { - getMBeanServerConnection().addNotificationListener( - MBeanServerDelegate.DELEGATE_NAME, - this, - null, - null); - } catch (InstanceNotFoundException e) { - // Should never happen because the MBeanServerDelegate - // is always present in any standard MBeanServer - // - if (JConsole.isDebug()) { - e.printStackTrace(); - } - } catch (IOException e) { - if (JConsole.isDebug()) { - e.printStackTrace(); + private void buildMBeanServerView() { + new SwingWorker, Void>() { + @Override + public Set doInBackground() { + // Register listener for MBean registration/unregistration + // + try { + getMBeanServerConnection().addNotificationListener( + MBeanServerDelegate.DELEGATE_NAME, + MBeansTab.this, + null, + null); + } catch (InstanceNotFoundException e) { + // Should never happen because the MBeanServerDelegate + // is always present in any standard MBeanServer + // + if (JConsole.isDebug()) { + e.printStackTrace(); + } + } catch (IOException e) { + if (JConsole.isDebug()) { + e.printStackTrace(); + } + vmPanel.getProxyClient().markAsDead(); + return null; + } + // Retrieve MBeans from MBeanServer + // + Set mbeans = null; + try { + mbeans = getMBeanServerConnection().queryNames(null, null); + } catch (IOException e) { + if (JConsole.isDebug()) { + e.printStackTrace(); + } + vmPanel.getProxyClient().markAsDead(); + return null; + } + return mbeans; } - vmPanel.getProxyClient().markAsDead(); - return; - } - // Retrieve MBeans from MBeanServer - // - Set newSet = null; - try { - newSet = getMBeanServerConnection().queryNames(null,null); - } catch (IOException e) { - if (JConsole.isDebug()) { - e.printStackTrace(); + @Override + protected void done() { + try { + // Wait for mbsc.queryNames() result + Set mbeans = get(); + // Do not display anything until the new tree has been built + // + tree.setVisible(false); + // Cleanup current tree + // + tree.removeAll(); + // Add MBeans to tree + // + tree.addMBeansToView(mbeans); + // Display the new tree + // + tree.setVisible(true); + } catch (Exception e) { + Throwable t = Utils.getActualException(e); + if (JConsole.isDebug()) { + System.err.println("Problem at MBean tree construction"); + t.printStackTrace(); + } + } } - vmPanel.getProxyClient().markAsDead(); - return; - } - // Cleanup current tree - // - tree.removeAll(); - // Do not display anything until the new tree has been built - // - tree.setVisible(false); - // Add MBeans to tree - // - for (ObjectName mbean : newSet) { - tree.addMBeanToView(mbean); - } - // Display the new tree - // - tree.setVisible(true); + }.execute(); } public MBeanServerConnection getMBeanServerConnection() { return vmPanel.getProxyClient().getMBeanServerConnection(); } + @Override public void update() { // Ping the connection to see if it is still alive. At // some point the ProxyClient class should centralize @@ -160,6 +181,7 @@ public class MBeansTab extends Tab implements tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION); tree.addTreeSelectionListener(this); + tree.addTreeWillExpandListener(this); tree.addMouseListener(ml); JScrollPane theScrollPane = new JScrollPane( tree, @@ -177,55 +199,55 @@ public class MBeansTab extends Tab implements add(mainSplit); } - /* notification listener */ - public void handleNotification(Notification notification, Object handback) { - if (notification instanceof MBeanServerNotification) { - ObjectName mbean = - ((MBeanServerNotification) notification).getMBeanName(); - if (notification.getType().equals( - MBeanServerNotification.REGISTRATION_NOTIFICATION)) { - tree.addMBeanToView(mbean); - } else if (notification.getType().equals( - MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) { - tree.delMBeanFromView(mbean); + /* notification listener: handleNotification */ + public void handleNotification( + final Notification notification, Object handback) { + EventQueue.invokeLater(new Runnable() { + public void run() { + if (notification instanceof MBeanServerNotification) { + ObjectName mbean = + ((MBeanServerNotification) notification).getMBeanName(); + if (notification.getType().equals( + MBeanServerNotification.REGISTRATION_NOTIFICATION)) { + tree.addMBeanToView(mbean); + } else if (notification.getType().equals( + MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) { + tree.removeMBeanFromView(mbean); + } + } } - } + }); } - /* property change listener */ + /* property change listener: propertyChange */ public void propertyChange(PropertyChangeEvent evt) { - if (evt.getPropertyName() == JConsoleContext.CONNECTION_STATE_PROPERTY) { + if (JConsoleContext.CONNECTION_STATE_PROPERTY.equals(evt.getPropertyName())) { boolean connected = (Boolean) evt.getNewValue(); if (connected) { - workerAdd(new Runnable() { - public void run() { - synchroniseMBeanServerView(); - } - }); + buildMBeanServerView(); } else { sheet.dispose(); } } - } - /* tree selection listener */ + /* tree selection listener: valueChanged */ public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); sheet.displayNode(node); } - - /* tree mouse listener */ + /* tree mouse listener: mousePressed */ private MouseListener ml = new MouseAdapter() { + @Override public void mousePressed(MouseEvent e) { if (e.getClickCount() == 1) { int selRow = tree.getRowForLocation(e.getX(), e.getY()); if (selRow != -1) { TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); - DefaultMutableTreeNode node = (DefaultMutableTreeNode) - selPath.getLastPathComponent(); + DefaultMutableTreeNode node = + (DefaultMutableTreeNode) selPath.getLastPathComponent(); if (sheet.isMBeanNode(node)) { tree.expandPath(selPath); } @@ -233,4 +255,22 @@ public class MBeansTab extends Tab implements } } }; + + /* tree will expand listener: treeWillExpand */ + public void treeWillExpand(TreeExpansionEvent e) + throws ExpandVetoException { + TreePath path = e.getPath(); + if (!tree.hasBeenExpanded(path)) { + DefaultMutableTreeNode node = + (DefaultMutableTreeNode) path.getLastPathComponent(); + if (sheet.isMBeanNode(node) && !tree.hasMetadataNodes(node)) { + tree.addMetadataNodes(node); + } + } + } + + /* tree will expand listener: treeWillCollapse */ + public void treeWillCollapse(TreeExpansionEvent e) + throws ExpandVetoException { + } } diff --git a/src/share/classes/sun/tools/jconsole/MemoryPoolStat.java b/src/share/classes/sun/tools/jconsole/MemoryPoolStat.java index f1d75147b6212a4cfb4ba7d63822e545d5b48d3e..c8c27e91ac44db4bd48d307111c52bab1a2f91b1 100644 --- a/src/share/classes/sun/tools/jconsole/MemoryPoolStat.java +++ b/src/share/classes/sun/tools/jconsole/MemoryPoolStat.java @@ -22,6 +22,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole; import java.lang.management.MemoryUsage; diff --git a/src/share/classes/sun/tools/jconsole/VMPanel.java b/src/share/classes/sun/tools/jconsole/VMPanel.java index e57c91a5e359ebd82eb6673e4893a8e717296b97..8215a7a8ed5a99fe6b08ddce0ebda99878cbcc8f 100644 --- a/src/share/classes/sun/tools/jconsole/VMPanel.java +++ b/src/share/classes/sun/tools/jconsole/VMPanel.java @@ -45,6 +45,7 @@ import static sun.tools.jconsole.ProxyClient.*; @SuppressWarnings("serial") public class VMPanel extends JTabbedPane implements PropertyChangeListener { + private ProxyClient proxyClient; private Timer timer; private int updateInterval; @@ -55,12 +56,9 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { private String password; private String url; private VMInternalFrame vmIF = null; - private static final String windowsLaF = - "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; - + "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; private static ArrayList tabInfos = new ArrayList(); - private boolean wasConnected = false; // The everConnected flag keeps track of whether the window can be @@ -76,7 +74,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { // Each VMPanel has its own instance of the JConsolePlugin // A map of JConsolePlugin to the previous SwingWorker - private Map> plugins = null; + private Map> plugins = null; private boolean pluginTabsAdded = false; // Update these only on the EDT @@ -86,11 +84,11 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { static { tabInfos.add(new TabInfo(OverviewTab.class, OverviewTab.getTabName(), true)); - tabInfos.add(new TabInfo(MemoryTab.class, MemoryTab.getTabName(), true)); - tabInfos.add(new TabInfo(ThreadTab.class, ThreadTab.getTabName(), true)); - tabInfos.add(new TabInfo(ClassTab.class, ClassTab.getTabName(), true)); + tabInfos.add(new TabInfo(MemoryTab.class, MemoryTab.getTabName(), true)); + tabInfos.add(new TabInfo(ThreadTab.class, ThreadTab.getTabName(), true)); + tabInfos.add(new TabInfo(ClassTab.class, ClassTab.getTabName(), true)); tabInfos.add(new TabInfo(SummaryTab.class, SummaryTab.getTabName(), true)); - tabInfos.add(new TabInfo(MBeansTab.class, MBeansTab.getTabName(), true)); + tabInfos.add(new TabInfo(MBeansTab.class, MBeansTab.getTabName(), true)); } public static TabInfo[] getTabInfos() { @@ -101,8 +99,8 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { this.proxyClient = proxyClient; this.updateInterval = updateInterval; this.hostName = proxyClient.getHostName(); - this.port = proxyClient.getPort(); - this.vmid = proxyClient.getVmid(); + this.port = proxyClient.getPort(); + this.vmid = proxyClient.getVmid(); this.userName = proxyClient.getUserName(); this.password = proxyClient.getPassword(); this.url = proxyClient.getUrl(); @@ -113,7 +111,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { } } - plugins = new LinkedHashMap>(); + plugins = new LinkedHashMap>(); for (JConsolePlugin p : JConsole.getPlugins()) { p.setContext(proxyClient); plugins.put(p, null); @@ -128,10 +126,9 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { proxyClient.addPropertyChangeListener(this); addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { - if (connectedIconBounds != null - && (e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0 - && connectedIconBounds.contains(e.getPoint())) { + if (connectedIconBounds != null && (e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0 && connectedIconBounds.contains(e.getPoint())) { if (isConnected()) { disconnect(); @@ -145,23 +142,21 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { }); } - private static Icon connectedIcon16 = - new ImageIcon(VMPanel.class.getResource("resources/connected16.png")); + new ImageIcon(VMPanel.class.getResource("resources/connected16.png")); private static Icon connectedIcon24 = - new ImageIcon(VMPanel.class.getResource("resources/connected24.png")); + new ImageIcon(VMPanel.class.getResource("resources/connected24.png")); private static Icon disconnectedIcon16 = - new ImageIcon(VMPanel.class.getResource("resources/disconnected16.png")); + new ImageIcon(VMPanel.class.getResource("resources/disconnected16.png")); private static Icon disconnectedIcon24 = - new ImageIcon(VMPanel.class.getResource("resources/disconnected24.png")); - + new ImageIcon(VMPanel.class.getResource("resources/disconnected24.png")); private Rectangle connectedIconBounds; // Override to increase right inset for tab area, // in order to reserve space for the connect toggle. public void setUI(TabbedPaneUI ui) { - Insets insets = (Insets)UIManager.getLookAndFeelDefaults().get("TabbedPane.tabAreaInsets"); - insets = (Insets)insets.clone(); + Insets insets = (Insets) UIManager.getLookAndFeelDefaults().get("TabbedPane.tabAreaInsets"); + insets = (Insets) insets.clone(); insets.right += connectedIcon24.getIconWidth() + 8; UIManager.put("TabbedPane.tabAreaInsets", insets); super.setUI(ui); @@ -225,7 +220,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { private Tab instantiate(TabInfo tabInfo) { try { Constructor con = tabInfo.tabClass.getConstructor(VMPanel.class); - return (Tab)con.newInstance(this); + return (Tab) con.newInstance(this); } catch (Exception ex) { System.err.println(ex); return null; @@ -247,10 +242,11 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { * IT IS USED TO MAKE SOME LOCAL MANIPULATIONS. */ ProxyClient getProxyClient(boolean assertThread) { - if(assertThread) + if (assertThread) { return getProxyClient(); - else + } else { return proxyClient; + } } public ProxyClient getProxyClient() { @@ -294,6 +290,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { startUpdateTimer(); } else { new Thread("VMPanel.connect") { + public void run() { proxyClient.connect(); } @@ -301,68 +298,63 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { } } - // Call on EDT public void disconnect() { proxyClient.disconnect(); updateFrameTitle(); } - - // Called on EDT public void propertyChange(PropertyChangeEvent ev) { String prop = ev.getPropertyName(); if (prop == CONNECTION_STATE_PROPERTY) { - ConnectionState oldState = (ConnectionState)ev.getOldValue(); - ConnectionState newState = (ConnectionState)ev.getNewValue(); + ConnectionState oldState = (ConnectionState) ev.getOldValue(); + ConnectionState newState = (ConnectionState) ev.getNewValue(); switch (newState) { - case CONNECTING: - onConnecting(); - break; - - case CONNECTED: - if (progressBar != null) { - progressBar.setIndeterminate(false); - progressBar.setValue(100); - } - closeOptionPane(); - updateFrameTitle(); - // create tabs if not done - createPluginTabs(); - repaint(); - // Notify tabs - fireConnectedChange(true); - // Enable/disable tabs on initial update - initialUpdate = true; - // Start/Restart update timer on connect/reconnect - startUpdateTimer(); - break; - - case DISCONNECTED: - if (progressBar != null) { - progressBar.setIndeterminate(false); - progressBar.setValue(0); + case CONNECTING: + onConnecting(); + break; + + case CONNECTED: + if (progressBar != null) { + progressBar.setIndeterminate(false); + progressBar.setValue(100); + } closeOptionPane(); - } - vmPanelDied(); - if (oldState == ConnectionState.CONNECTED) { + updateFrameTitle(); + // create tabs if not done + createPluginTabs(); + repaint(); // Notify tabs - fireConnectedChange(false); - } - break; + fireConnectedChange(true); + // Enable/disable tabs on initial update + initialUpdate = true; + // Start/Restart update timer on connect/reconnect + startUpdateTimer(); + break; + + case DISCONNECTED: + if (progressBar != null) { + progressBar.setIndeterminate(false); + progressBar.setValue(0); + closeOptionPane(); + } + vmPanelDied(); + if (oldState == ConnectionState.CONNECTED) { + // Notify tabs + fireConnectedChange(false); + } + break; } } } - - // Called on EDT private void onConnecting() { time0 = System.currentTimeMillis(); - final JConsole jc = (JConsole)SwingUtilities.getWindowAncestor(this); + final JConsole jc = (JConsole) SwingUtilities.getWindowAncestor(this); String connectionName = getConnectionName(); progressBar = new JProgressBar(); @@ -373,17 +365,16 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { Object[] message = { "

        " + getText("connectingTo1", connectionName) + "

        ", progressPanel, - "" + getText("connectingTo2", connectionName) + "" + "" + getText("connectingTo2", connectionName) + "" }; - optionPane = - SheetDialog.showOptionDialog(this, - message, - JOptionPane.DEFAULT_OPTION, - JOptionPane.INFORMATION_MESSAGE, null, - new String[] { getText("Cancel") }, - 0); + SheetDialog.showOptionDialog(this, + message, + JOptionPane.DEFAULT_OPTION, + JOptionPane.INFORMATION_MESSAGE, null, + new String[]{getText("Cancel")}, + 0); } @@ -398,10 +389,11 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { try { sleep(2000 - elapsed); } catch (InterruptedException ex) { - // Ignore + // Ignore } } SwingUtilities.invokeLater(new Runnable() { + public void run() { optionPane.setVisible(false); progressBar = null; @@ -425,8 +417,8 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { private VMInternalFrame getFrame() { if (vmIF == null) { - vmIF = (VMInternalFrame)SwingUtilities.getAncestorOfClass(VMInternalFrame.class, - this); + vmIF = (VMInternalFrame) SwingUtilities.getAncestorOfClass(VMInternalFrame.class, + this); } return vmIF; } @@ -452,27 +444,27 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { timer.cancel(); } TimerTask timerTask = new TimerTask() { + public void run() { update(); } }; - String timerName = "Timer-"+getConnectionName(); + String timerName = "Timer-" + getConnectionName(); timer = new Timer(timerName, true); timer.schedule(timerTask, 0, updateInterval); } - // Call on EDT private void vmPanelDied() { disconnect(); - final JConsole jc = (JConsole)SwingUtilities.getWindowAncestor(this); + final JConsole jc = (JConsole) SwingUtilities.getWindowAncestor(this); JOptionPane optionPane; - final String connectStr = getText("Connect"); + final String connectStr = getText("Connect"); final String reconnectStr = getText("Reconnect"); - final String cancelStr = getText("Cancel"); + final String cancelStr = getText("Cancel"); String msgTitle, msgExplanation, buttonStr; @@ -488,15 +480,16 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { } optionPane = - SheetDialog.showOptionDialog(this, - "

        " + msgTitle + "

        " + - "" + msgExplanation + "", - JOptionPane.DEFAULT_OPTION, - JOptionPane.WARNING_MESSAGE, null, - new String[] { buttonStr, cancelStr }, - 0); + SheetDialog.showOptionDialog(this, + "

        " + msgTitle + "

        " + + "" + msgExplanation + "", + JOptionPane.DEFAULT_OPTION, + JOptionPane.WARNING_MESSAGE, null, + new String[]{buttonStr, cancelStr}, + 0); optionPane.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { Object value = event.getNewValue(); @@ -507,7 +500,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { try { getFrame().setClosed(true); } catch (PropertyVetoException ex) { - // Should not happen, but can be ignored. + // Should not happen, but can be ignored. } } } @@ -518,11 +511,13 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { // Note: This method is called on a TimerTask thread. Any GUI manipulation // must be performed with invokeLater() or invokeAndWait(). private Object lockObject = new Object(); + private void update() { - synchronized(lockObject) { + synchronized (lockObject) { if (!isConnected()) { if (wasConnected) { EventQueue.invokeLater(new Runnable() { + public void run() { vmPanelDied(); } @@ -548,6 +543,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { // if (initialUpdate) { EventQueue.invokeLater(new Runnable() { + public void run() { setEnabledAt(index, true); } @@ -569,8 +565,8 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { // plugin GUI update for (JConsolePlugin p : plugins.keySet()) { - SwingWorker sw = p.newSwingWorker(); - SwingWorker prevSW = plugins.get(p); + SwingWorker sw = p.newSwingWorker(); + SwingWorker prevSW = plugins.get(p); // schedule SwingWorker to run only if the previous // SwingWorker has finished its task and it hasn't started. if (prevSW == null || prevSW.isDone()) { @@ -583,7 +579,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { } } - // Set the first enabled tab in the tab´s list + // Set the first enabled tab in the tab's list // as the selected tab on initial update // if (initialUpdate) { @@ -622,7 +618,6 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { return url; } - public String getPassword() { return password; } @@ -636,6 +631,7 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { } static class TabInfo { + Class tabClass; String name; boolean tabVisible; diff --git a/src/share/classes/sun/tools/jconsole/inspector/OperationEntry.java b/src/share/classes/sun/tools/jconsole/inspector/OperationEntry.java index 0eb3876838ab6495f6ac750b5c4d0c3d5bea05ff..c6a805ab391ebee040bdcf0fcfe7351c9bbf8101 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/OperationEntry.java +++ b/src/share/classes/sun/tools/jconsole/inspector/OperationEntry.java @@ -22,8 +22,8 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ -package sun.tools.jconsole.inspector; +package sun.tools.jconsole.inspector; // java import import java.awt.*; diff --git a/src/share/classes/sun/tools/jconsole/inspector/TableSorter.java b/src/share/classes/sun/tools/jconsole/inspector/TableSorter.java index 886b11c57f0e8822d872fd9c08626824953107dd..14ac7bc2ebb96ce584f8c1cfd3d7a54ae7bfe93a 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/TableSorter.java +++ b/src/share/classes/sun/tools/jconsole/inspector/TableSorter.java @@ -22,6 +22,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole.inspector; import java.util.*; diff --git a/src/share/classes/sun/tools/jconsole/inspector/ThreadDialog.java b/src/share/classes/sun/tools/jconsole/inspector/ThreadDialog.java index ea07d1393c10abe748225e4d3b5554aaa8bd8abe..a548fadd60f1277f899d6e3aede638fc9add04af 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/ThreadDialog.java +++ b/src/share/classes/sun/tools/jconsole/inspector/ThreadDialog.java @@ -22,6 +22,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole.inspector; // java import diff --git a/src/share/classes/sun/tools/jconsole/inspector/Utils.java b/src/share/classes/sun/tools/jconsole/inspector/Utils.java index 7ae531eff3afddc614478735024f8d6a7c5e7f03..eee13d6709490a5e4e7ae7e104db1ffcbfba433c 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/Utils.java +++ b/src/share/classes/sun/tools/jconsole/inspector/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2004-2007 Sun Microsystems, 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 @@ -29,55 +29,51 @@ import java.awt.event.*; import java.lang.reflect.*; import java.math.BigDecimal; import java.math.BigInteger; +import java.util.*; +import java.util.concurrent.ExecutionException; import javax.management.*; import javax.management.openmbean.*; import javax.swing.*; import javax.swing.text.*; -import java.util.*; public class Utils { private Utils() { } - private static Set tableNavigationKeys = - new HashSet(Arrays.asList(new Integer[] { + new HashSet(Arrays.asList(new Integer[]{ KeyEvent.VK_TAB, KeyEvent.VK_ENTER, KeyEvent.VK_HOME, KeyEvent.VK_END, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT, KeyEvent.VK_UP, KeyEvent.VK_DOWN, - KeyEvent.VK_PAGE_UP, KeyEvent.VK_PAGE_DOWN})); - + KeyEvent.VK_PAGE_UP, KeyEvent.VK_PAGE_DOWN + })); private static final Set> primitiveWrappers = - new HashSet>(Arrays.asList(new Class[] { + new HashSet>(Arrays.asList(new Class[]{ Byte.class, Short.class, Integer.class, Long.class, - Float.class, Double.class, Character.class, Boolean.class})); - + Float.class, Double.class, Character.class, Boolean.class + })); private static final Set> primitives = new HashSet>(); - private static final Map> primitiveMap = new HashMap>(); - private static final Map> primitiveToWrapper = new HashMap>(); - private static final Set editableTypes = new HashSet(); - private static final Set> extraEditableClasses = - new HashSet>(Arrays.asList(new Class[] { + new HashSet>(Arrays.asList(new Class[]{ BigDecimal.class, BigInteger.class, Number.class, - String.class, ObjectName.class})); - + String.class, ObjectName.class + })); private static final Set numericalTypes = new HashSet(); - private static final Set extraNumericalTypes = - new HashSet(Arrays.asList(new String[] { + new HashSet(Arrays.asList(new String[]{ BigDecimal.class.getName(), BigInteger.class.getName(), - Number.class.getName()})); - + Number.class.getName() + })); private static final Set booleanTypes = - new HashSet(Arrays.asList(new String[] { - Boolean.TYPE.getName(), Boolean.class.getName()})); + new HashSet(Arrays.asList(new String[]{ + Boolean.TYPE.getName(), Boolean.class.getName() + })); static { // compute primitives/primitiveMap/primitiveToWrapper @@ -122,10 +118,11 @@ public class Utils { * It's used to cater for the primitive types. */ public static Class getClass(String className) - throws ClassNotFoundException { + throws ClassNotFoundException { Class c; - if ((c = primitiveMap.get(className)) != null) + if ((c = primitiveMap.get(className)) != null) { return c; + } return Class.forName(className); } @@ -155,7 +152,9 @@ public class Utils { * structure, i.e. a data structure jconsole can render as an array. */ public static boolean canBeRenderedAsArray(Object elem) { - if (isSupportedArray(elem)) return true; + if (isSupportedArray(elem)) { + return true; + } if (elem instanceof Collection) { Collection c = (Collection) elem; if (c.isEmpty()) { @@ -168,7 +167,7 @@ public class Utils { // - Collections of other Java types are handled as arrays // return !isUniformCollection(c, CompositeData.class) && - !isUniformCollection(c, TabularData.class); + !isUniformCollection(c, TabularData.class); } } if (elem instanceof Map) { @@ -239,7 +238,9 @@ public class Utils { */ public static String getReadableClassName(String name) { String className = getArrayClassName(name); - if (className == null) return name; + if (className == null) { + return name; + } int index = name.lastIndexOf("["); StringBuilder brackets = new StringBuilder(className); for (int i = 0; i <= index; i++) { @@ -282,7 +283,7 @@ public class Utils { * Try to create a Java object using a one-string-param constructor. */ public static Object newStringConstructor(String type, String param) - throws Exception { + throws Exception { Constructor c = Utils.getClass(type).getConstructor(String.class); try { return c.newInstance(param); @@ -300,7 +301,7 @@ public class Utils { * Try to convert a string value into a numerical value. */ private static Number createNumberFromStringValue(String value) - throws NumberFormatException { + throws NumberFormatException { final String suffix = value.substring(value.length() - 1); if ("L".equalsIgnoreCase(suffix)) { return Long.valueOf(value.substring(0, value.length() - 1)); @@ -314,17 +315,17 @@ public class Utils { try { return Integer.valueOf(value); } catch (NumberFormatException e) { - // OK: Ignore exception... + // OK: Ignore exception... } try { return Long.valueOf(value); } catch (NumberFormatException e1) { - // OK: Ignore exception... + // OK: Ignore exception... } try { return Double.valueOf(value); } catch (NumberFormatException e2) { - // OK: Ignore exception... + // OK: Ignore exception... } throw new NumberFormatException("Cannot convert string value '" + value + "' into a numerical value"); @@ -337,7 +338,7 @@ public class Utils { * will return an Integer object initialized to 10. */ public static Object createObjectFromString(String type, String value) - throws Exception { + throws Exception { Object result; if (primitiveToWrapper.containsKey(type)) { if (type.equals(Character.TYPE.getName())) { @@ -367,7 +368,7 @@ public class Utils { * into a useful object array for passing into a parameter array. */ public static Object[] getParameters(XTextField[] inputs, String[] params) - throws Exception { + throws Exception { Object result[] = new Object[inputs.length]; Object userInput; for (int i = 0; i < inputs.length; i++) { @@ -388,12 +389,17 @@ public class Utils { * If the exception is wrapped, unwrap it. */ public static Throwable getActualException(Throwable e) { + if (e instanceof ExecutionException) { + e = e.getCause(); + } if (e instanceof MBeanException || e instanceof RuntimeMBeanException || e instanceof RuntimeOperationsException || e instanceof ReflectionException) { Throwable t = e.getCause(); - if (t != null) return t; + if (t != null) { + return t; + } } return e; } @@ -401,6 +407,7 @@ public class Utils { @SuppressWarnings("serial") public static class ReadOnlyTableCellEditor extends DefaultCellEditor { + public ReadOnlyTableCellEditor(JTextField tf) { super(tf); tf.addFocusListener(new Utils.EditFocusAdapter(this)); @@ -409,20 +416,25 @@ public class Utils { } public static class EditFocusAdapter extends FocusAdapter { + private CellEditor editor; + public EditFocusAdapter(CellEditor editor) { this.editor = editor; } + + @Override public void focusLost(FocusEvent e) { editor.stopCellEditing(); } - }; + } public static class CopyKeyAdapter extends KeyAdapter { private static final String defaultEditorKitCopyActionName = DefaultEditorKit.copyAction; private static final String transferHandlerCopyActionName = (String) TransferHandler.getCopyAction().getValue(Action.NAME); + @Override public void keyPressed(KeyEvent e) { // Accept "copy" key strokes KeyStroke ks = KeyStroke.getKeyStroke( @@ -441,6 +453,8 @@ public class Utils { e.consume(); } } + + @Override public void keyTyped(KeyEvent e) { e.consume(); } diff --git a/src/share/classes/sun/tools/jconsole/inspector/XDataViewer.java b/src/share/classes/sun/tools/jconsole/inspector/XDataViewer.java index 21b3f44189edafaf4906f05d47128c820e23e3dc..8a339f2ac4952495047516cde471679f5771fe42 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XDataViewer.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XDataViewer.java @@ -22,6 +22,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole.inspector; import javax.swing.JTable; @@ -108,6 +109,7 @@ public class XDataViewer { public Component createOperationViewer(Object value, XMBean mbean) { if(value instanceof Number) return null; + if(value instanceof Component) return (Component) value; return createAttributeViewer(value, mbean, null, null); } diff --git a/src/share/classes/sun/tools/jconsole/inspector/XMBean.java b/src/share/classes/sun/tools/jconsole/inspector/XMBean.java index eed56044e0969b8d25d6a291ca53b2cf3675ec3e..9999d7dbda16682d14e771a059e9e831fb6400cc 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XMBean.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XMBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2004-2007 Sun Microsystems, 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 @@ -28,47 +28,56 @@ package sun.tools.jconsole.inspector; import java.io.IOException; import javax.management.*; import javax.swing.Icon; +import sun.tools.jconsole.JConsole; import sun.tools.jconsole.MBeansTab; -public class XMBean extends Object { - private ObjectName objectName; +public class XMBean { + + private final MBeansTab mbeansTab; + private final ObjectName objectName; private Icon icon; private String text; - private boolean broadcaster; + private Boolean broadcaster; + private final Object broadcasterLock = new Object(); private MBeanInfo mbeanInfo; - private MBeansTab mbeansTab; + private final Object mbeanInfoLock = new Object(); - public XMBean(ObjectName objectName, MBeansTab mbeansTab) - throws InstanceNotFoundException, IntrospectionException, - ReflectionException, IOException { + public XMBean(ObjectName objectName, MBeansTab mbeansTab) { this.mbeansTab = mbeansTab; - setObjectName(objectName); + this.objectName = objectName; + text = objectName.getKeyProperty("name"); + if (text == null) { + text = objectName.getDomain(); + } if (MBeanServerDelegate.DELEGATE_NAME.equals(objectName)) { icon = IconManager.MBEANSERVERDELEGATE; } else { icon = IconManager.MBEAN; } - this.broadcaster = isBroadcaster(objectName); - this.mbeanInfo = getMBeanInfo(objectName); } MBeanServerConnection getMBeanServerConnection() { return mbeansTab.getMBeanServerConnection(); } - public boolean isBroadcaster() { - return broadcaster; - } - - private boolean isBroadcaster(ObjectName name) { - try { - return getMBeanServerConnection().isInstanceOf( - name, "javax.management.NotificationBroadcaster"); - } catch (Exception e) { - System.out.println("Error calling isBroadcaster: " + - e.getMessage()); + public Boolean isBroadcaster() { + synchronized (broadcasterLock) { + if (broadcaster == null) { + try { + broadcaster = getMBeanServerConnection().isInstanceOf( + getObjectName(), + "javax.management.NotificationBroadcaster"); + } catch (Exception e) { + if (JConsole.isDebug()) { + System.err.println("Couldn't check if MBean [" + + objectName + "] is a notification broadcaster"); + e.printStackTrace(); + } + return false; + } + } + return broadcaster; } - return false; } public Object invoke(String operationName) throws Exception { @@ -78,35 +87,35 @@ public class XMBean extends Object { } public Object invoke(String operationName, Object params[], String sig[]) - throws Exception { + throws Exception { Object result = getMBeanServerConnection().invoke( getObjectName(), operationName, params, sig); return result; } public void setAttribute(Attribute attribute) - throws AttributeNotFoundException, InstanceNotFoundException, + throws AttributeNotFoundException, InstanceNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException, IOException { getMBeanServerConnection().setAttribute(getObjectName(), attribute); } public Object getAttribute(String attributeName) - throws AttributeNotFoundException, InstanceNotFoundException, + throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException { return getMBeanServerConnection().getAttribute( getObjectName(), attributeName); } public AttributeList getAttributes(String attributeNames[]) - throws AttributeNotFoundException, InstanceNotFoundException, + throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException { return getMBeanServerConnection().getAttributes( getObjectName(), attributeNames); } public AttributeList getAttributes(MBeanAttributeInfo attributeNames[]) - throws AttributeNotFoundException, InstanceNotFoundException, + throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException { String attributeString[] = new String[attributeNames.length]; for (int i = 0; i < attributeNames.length; i++) { @@ -119,32 +128,34 @@ public class XMBean extends Object { return objectName; } - private void setObjectName(ObjectName objectName) { - this.objectName = objectName; - // generate a readable name now - String name = getObjectName().getKeyProperty("name"); - if (name == null) - setText(getObjectName().getDomain()); - else - setText(name); - } - - public MBeanInfo getMBeanInfo() { - return mbeanInfo; + public MBeanInfo getMBeanInfo() throws InstanceNotFoundException, + IntrospectionException, ReflectionException, IOException { + synchronized (mbeanInfoLock) { + if (mbeanInfo == null) { + mbeanInfo = getMBeanServerConnection().getMBeanInfo(objectName); + } + return mbeanInfo; + } } - private MBeanInfo getMBeanInfo(ObjectName name) - throws InstanceNotFoundException, IntrospectionException, - ReflectionException, IOException { - return getMBeanServerConnection().getMBeanInfo(name); + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (!(obj instanceof XMBean)) { + return false; + } + XMBean that = (XMBean) obj; + return getObjectName().equals(that.getObjectName()); } - public boolean equals(Object o) { - if (o instanceof XMBean) { - XMBean mbean = (XMBean) o; - return getObjectName().equals((mbean).getObjectName()); - } - return false; + @Override + public int hashCode() { + return (objectName == null ? 0 : objectName.hashCode()); } public String getText() { @@ -163,6 +174,7 @@ public class XMBean extends Object { this.icon = icon; } + @Override public String toString() { return getText(); } diff --git a/src/share/classes/sun/tools/jconsole/inspector/XMBeanInfo.java b/src/share/classes/sun/tools/jconsole/inspector/XMBeanInfo.java index 5a87772f87cd00cee1ad03a296ce40f1d7d72f1b..bb195cd990e27a3ed7a707e568d698f0e46035da 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XMBeanInfo.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XMBeanInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2004-2007 Sun Microsystems, 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 @@ -35,10 +35,7 @@ import javax.swing.*; import javax.swing.border.TitledBorder; import javax.swing.event.*; import javax.swing.table.*; -import javax.swing.tree.*; -import sun.tools.jconsole.JConsole; import sun.tools.jconsole.Resources; -import sun.tools.jconsole.inspector.XNodeInfo.Type; import static sun.tools.jconsole.Utilities.*; @@ -46,21 +43,20 @@ import static sun.tools.jconsole.Utilities.*; public class XMBeanInfo extends JPanel { private static final Color lightYellow = new Color(255, 255, 128); - private final int NAME_COLUMN = 0; private final int VALUE_COLUMN = 1; - private final String[] columnNames = { Resources.getText("Name"), Resources.getText("Value") }; - private JTable infoTable = new JTable(); private JTable descTable = new JTable(); private JPanel infoBorderPanel = new JPanel(new BorderLayout()); private JPanel descBorderPanel = new JPanel(new BorderLayout()); private static class ReadOnlyDefaultTableModel extends DefaultTableModel { + + @Override public void setValueAt(Object value, int row, int col) { } } @@ -73,17 +69,18 @@ public class XMBeanInfo extends JPanel { this.tableRowDividerText = tableRowDividerText; } + @Override public String toString() { return tableRowDividerText; } } - private static MBeanInfoTableCellRenderer renderer = new MBeanInfoTableCellRenderer(); private static class MBeanInfoTableCellRenderer extends DefaultTableCellRenderer { + @Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { @@ -92,22 +89,24 @@ public class XMBeanInfo extends JPanel { if (value instanceof TableRowDivider) { JLabel label = new JLabel(value.toString()); label.setBackground(ensureContrast(lightYellow, - label.getForeground())); + label.getForeground())); label.setOpaque(true); return label; } return comp; } } - private static TableCellEditor editor = new MBeanInfoTableCellEditor(new JTextField()); private static class MBeanInfoTableCellEditor extends Utils.ReadOnlyTableCellEditor { + public MBeanInfoTableCellEditor(JTextField tf) { super(tf); } + + @Override public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { @@ -116,7 +115,7 @@ public class XMBeanInfo extends JPanel { if (value instanceof TableRowDivider) { JLabel label = new JLabel(value.toString()); label.setBackground(ensureContrast(lightYellow, - label.getForeground())); + label.getForeground())); label.setOpaque(true); return label; } @@ -172,6 +171,7 @@ public class XMBeanInfo extends JPanel { add(descBorderPanel); } + // Call on EDT public void emptyInfoTable() { DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel(); while (tableModel.getRowCount() > 0) { @@ -179,6 +179,7 @@ public class XMBeanInfo extends JPanel { } } + // Call on EDT public void emptyDescTable() { DefaultTableModel tableModel = (DefaultTableModel) descTable.getModel(); while (tableModel.getRowCount() > 0) { @@ -186,6 +187,7 @@ public class XMBeanInfo extends JPanel { } } + // Call on EDT private void addDescriptor(Descriptor desc, String text) { if (desc != null && desc.getFieldNames().length > 0) { DefaultTableModel tableModel = (DefaultTableModel) descTable.getModel(); @@ -223,6 +225,7 @@ public class XMBeanInfo extends JPanel { } } + // Call on EDT public void addMBeanInfo(XMBean mbean, MBeanInfo mbeanInfo) { emptyInfoTable(); emptyDescTable(); @@ -263,6 +266,7 @@ public class XMBeanInfo extends JPanel { tableModel.newDataAvailable(new TableModelEvent(tableModel)); } + // Call on EDT public void addMBeanAttributeInfo(MBeanAttributeInfo mbai) { emptyInfoTable(); emptyDescTable(); @@ -296,6 +300,7 @@ public class XMBeanInfo extends JPanel { tableModel.newDataAvailable(new TableModelEvent(tableModel)); } + // Call on EDT public void addMBeanOperationInfo(MBeanOperationInfo mboi) { emptyInfoTable(); emptyDescTable(); @@ -343,6 +348,7 @@ public class XMBeanInfo extends JPanel { tableModel.newDataAvailable(new TableModelEvent(tableModel)); } + // Call on EDT public void addMBeanNotificationInfo(MBeanNotificationInfo mbni) { emptyInfoTable(); emptyDescTable(); @@ -367,6 +373,7 @@ public class XMBeanInfo extends JPanel { tableModel.newDataAvailable(new TableModelEvent(tableModel)); } + // Call on EDT private void addMBeanConstructorInfo(MBeanConstructorInfo mbci, String text) { DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel(); Object rowData[] = new Object[2]; @@ -383,6 +390,7 @@ public class XMBeanInfo extends JPanel { tableModel.newDataAvailable(new TableModelEvent(tableModel)); } + // Call on EDT private void addMBeanParameterInfo(MBeanParameterInfo mbpi, String text) { DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel(); Object rowData[] = new Object[2]; @@ -401,91 +409,4 @@ public class XMBeanInfo extends JPanel { addDescriptor(mbpi.getDescriptor(), text); tableModel.newDataAvailable(new TableModelEvent(tableModel)); } - - public static void loadInfo(DefaultMutableTreeNode root) { - // Retrieve XMBean from XNodeInfo - // - XMBean mbean = (XMBean) ((XNodeInfo) root.getUserObject()).getData(); - // Initialize MBean*Info - // - final MBeanInfo mbeanInfo; - try { - mbeanInfo = mbean.getMBeanInfo(); - } catch (Exception e) { - if (JConsole.isDebug()) { - e.printStackTrace(); - } - return; - } - MBeanAttributeInfo[] ai = mbeanInfo.getAttributes(); - MBeanOperationInfo[] oi = mbeanInfo.getOperations(); - MBeanNotificationInfo[] ni = mbeanInfo.getNotifications(); - // MBeanAttributeInfo node - // - if (ai != null && ai.length > 0) { - DefaultMutableTreeNode attributes = new DefaultMutableTreeNode(); - XNodeInfo attributesUO = new XNodeInfo(Type.ATTRIBUTES, mbean, - Resources.getText("Attributes"), null); - attributes.setUserObject(attributesUO); - root.add(attributes); - for (MBeanAttributeInfo mbai : ai) { - DefaultMutableTreeNode attribute = new DefaultMutableTreeNode(); - XNodeInfo attributeUO = new XNodeInfo(Type.ATTRIBUTE, - new Object[] {mbean, mbai}, mbai.getName(), null); - attribute.setUserObject(attributeUO); - attributes.add(attribute); - } - } - // MBeanOperationInfo node - // - if (oi != null && oi.length > 0) { - DefaultMutableTreeNode operations = new DefaultMutableTreeNode(); - XNodeInfo operationsUO = new XNodeInfo(Type.OPERATIONS, mbean, - Resources.getText("Operations"), null); - operations.setUserObject(operationsUO); - root.add(operations); - for (MBeanOperationInfo mboi : oi) { - // Compute the operation's tool tip text: - // "operationname(param1type,param2type,...)" - // - StringBuilder sb = new StringBuilder(); - for (MBeanParameterInfo mbpi : mboi.getSignature()) { - sb.append(mbpi.getType() + ","); - } - String signature = sb.toString(); - if (signature.length() > 0) { - // Remove the trailing ',' - // - signature = signature.substring(0, signature.length() - 1); - } - String toolTipText = mboi.getName() + "(" + signature + ")"; - // Create operation node - // - DefaultMutableTreeNode operation = new DefaultMutableTreeNode(); - XNodeInfo operationUO = new XNodeInfo(Type.OPERATION, - new Object[] {mbean, mboi}, mboi.getName(), toolTipText); - operation.setUserObject(operationUO); - operations.add(operation); - } - } - // MBeanNotificationInfo node - // - if (mbean.isBroadcaster()) { - DefaultMutableTreeNode notifications = new DefaultMutableTreeNode(); - XNodeInfo notificationsUO = new XNodeInfo(Type.NOTIFICATIONS, mbean, - Resources.getText("Notifications"), null); - notifications.setUserObject(notificationsUO); - root.add(notifications); - if (ni != null && ni.length > 0) { - for (MBeanNotificationInfo mbni : ni) { - DefaultMutableTreeNode notification = - new DefaultMutableTreeNode(); - XNodeInfo notificationUO = new XNodeInfo(Type.NOTIFICATION, - mbni, mbni.getName(), null); - notification.setUserObject(notificationUO); - notifications.add(notification); - } - } - } - } } diff --git a/src/share/classes/sun/tools/jconsole/inspector/XMBeanNotifications.java b/src/share/classes/sun/tools/jconsole/inspector/XMBeanNotifications.java index c3e059a4bac6596d0a02d1d8994c733e361b1f92..20c31b001d6bb545313a70607addf641837341b3 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XMBeanNotifications.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XMBeanNotifications.java @@ -29,17 +29,13 @@ import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; import javax.swing.tree.*; -import java.awt.BorderLayout; -import java.awt.GridLayout; import java.awt.Font; import java.text.SimpleDateFormat; -import java.awt.FlowLayout; import java.awt.Component; import java.awt.EventQueue; import java.awt.event.*; -import java.awt.Insets; import java.awt.Dimension; import java.util.*; import java.io.*; @@ -49,45 +45,44 @@ import javax.management.*; import javax.management.openmbean.CompositeData; import javax.management.openmbean.TabularData; +import sun.tools.jconsole.JConsole; import sun.tools.jconsole.Resources; @SuppressWarnings("serial") public class XMBeanNotifications extends JTable implements NotificationListener { - private final static String[] columnNames = { + private final static String[] columnNames = { Resources.getText("TimeStamp"), Resources.getText("Type"), Resources.getText("UserData"), Resources.getText("SeqNum"), Resources.getText("Message"), Resources.getText("Event"), - Resources.getText("Source")}; - + Resources.getText("Source") + }; private HashMap listeners = - new HashMap(); - private boolean subscribed; + new HashMap(); + private volatile boolean subscribed; private XMBeanNotificationsListener currentListener; public final static String NOTIFICATION_RECEIVED_EVENT = - "jconsole.xnotification.received"; - + "jconsole.xnotification.received"; private List notificationListenersList; - private boolean enabled; - private Font normalFont, boldFont; + private volatile boolean enabled; + private Font normalFont, boldFont; private int rowMinHeight = -1; private TableCellEditor userDataEditor = new UserDataCellEditor(); private NotifMouseListener mouseListener = new NotifMouseListener(); private SimpleDateFormat timeFormater = new SimpleDateFormat("HH:mm:ss:SSS"); - private static TableCellEditor editor = new Utils.ReadOnlyTableCellEditor(new JTextField()); public XMBeanNotifications() { - super(new TableSorter(columnNames,0)); + super(new TableSorter(columnNames, 0)); setColumnSelectionAllowed(false); setRowSelectionAllowed(false); getTableHeader().setReorderingAllowed(false); ArrayList l = - new ArrayList(1); + new ArrayList(1); notificationListenersList = Collections.synchronizedList(l); addMouseListener(mouseListener); @@ -103,20 +98,24 @@ public class XMBeanNotifications extends JTable implements NotificationListener addKeyListener(new Utils.CopyKeyAdapter()); } + // Call on EDT public void cancelCellEditing() { - TableCellEditor editor = getCellEditor(); - if (editor != null) { - editor.cancelCellEditing(); + TableCellEditor tce = getCellEditor(); + if (tce != null) { + tce.cancelCellEditing(); } } + // Call on EDT public void stopCellEditing() { - TableCellEditor editor = getCellEditor(); - if (editor != null) { - editor.stopCellEditing(); + TableCellEditor tce = getCellEditor(); + if (tce != null) { + tce.stopCellEditing(); } } + // Call on EDT + @Override public boolean isCellEditable(int row, int col) { UserDataCell cell = getUserDataCell(row, col); if (cell != null) { @@ -125,16 +124,21 @@ public class XMBeanNotifications extends JTable implements NotificationListener return true; } + // Call on EDT + @Override public void setValueAt(Object value, int row, int column) { } - public synchronized Component prepareRenderer(TableCellRenderer renderer, - int row, int column) { + // Call on EDT + @Override + public synchronized Component prepareRenderer( + TableCellRenderer renderer, int row, int column) { //In case we have a repaint thread that is in the process of //repainting an obsolete table, just ignore the call. //It can happen when MBean selection is switched at a very quick rate - if(row >= getRowCount()) + if (row >= getRowCount()) { return null; + } Component comp = super.prepareRenderer(renderer, row, column); @@ -146,9 +150,10 @@ public class XMBeanNotifications extends JTable implements NotificationListener if (column == 2 && cell != null) { comp.setFont(boldFont); int size = cell.getHeight(); - if(size > 0) { - if(getRowHeight(row) != size) + if (size > 0) { + if (getRowHeight(row) != size) { setRowHeight(row, size); + } } } else { comp.setFont(normalFont); @@ -157,34 +162,35 @@ public class XMBeanNotifications extends JTable implements NotificationListener return comp; } - public synchronized TableCellRenderer getCellRenderer(int row, - int column) { + // Call on EDT + @Override + public synchronized TableCellRenderer getCellRenderer(int row, int column) { //In case we have a repaint thread that is in the process of //repainting an obsolete table, just ignore the call. //It can happen when MBean selection is switched at a very quick rate - if(row >= getRowCount()) + if (row >= getRowCount()) { return null; + } DefaultTableCellRenderer renderer; String toolTip = null; UserDataCell cell = getUserDataCell(row, column); - if(cell != null && cell.isInited()) { + if (cell != null && cell.isInited()) { renderer = (DefaultTableCellRenderer) cell.getRenderer(); - } - else { - renderer = (DefaultTableCellRenderer) - super.getCellRenderer(row, - column); + } else { + renderer = + (DefaultTableCellRenderer) super.getCellRenderer(row, column); } - if(cell != null) - toolTip = Resources.getText("Double click to expand/collapse")+". " - + cell.toString(); - else { + if (cell != null) { + toolTip = Resources.getText("Double click to expand/collapse") + + ". " + cell.toString(); + } else { Object val = - ((DefaultTableModel) getModel()).getValueAt(row,column); - if(val != null) + ((DefaultTableModel) getModel()).getValueAt(row, column); + if (val != null) { toolTip = val.toString(); + } } renderer.setToolTipText(toolTip); @@ -192,9 +198,12 @@ public class XMBeanNotifications extends JTable implements NotificationListener return renderer; } + // Call on EDT private UserDataCell getUserDataCell(int row, int column) { - Object obj = ((DefaultTableModel) getModel()).getValueAt(row,column); - if(obj instanceof UserDataCell) return (UserDataCell) obj; + Object obj = ((DefaultTableModel) getModel()).getValueAt(row, column); + if (obj instanceof UserDataCell) { + return (UserDataCell) obj; + } return null; } @@ -204,19 +213,22 @@ public class XMBeanNotifications extends JTable implements NotificationListener public long getReceivedNotifications(XMBean mbean) { XMBeanNotificationsListener listener = - listeners.get(mbean.getObjectName()); - if(listener == null) return 0; - else + listeners.get(mbean.getObjectName()); + if (listener == null) { + return 0; + } else { return listener.getReceivedNotifications(); + } } public synchronized boolean clearCurrentNotifications() { emptyTable(); - if(currentListener != null) { + if (currentListener != null) { currentListener.clear(); return true; - } else + } else { return false; + } } public synchronized boolean unregisterListener(DefaultMutableTreeNode node) { @@ -225,29 +237,25 @@ public class XMBeanNotifications extends JTable implements NotificationListener } public synchronized void registerListener(DefaultMutableTreeNode node) - throws InstanceNotFoundException, IOException { + throws InstanceNotFoundException, IOException { XMBean mbean = (XMBean) ((XNodeInfo) node.getUserObject()).getData(); - if(!subscribed) { + if (!subscribed) { try { - mbean.getMBeanServerConnection(). - addNotificationListener(new ObjectName("JMImplementation:type=MBeanServerDelegate"), - this, - null, - null); + mbean.getMBeanServerConnection().addNotificationListener( + MBeanServerDelegate.DELEGATE_NAME, this, null, null); subscribed = true; - }catch(Exception e) { - System.out.println("Error adding listener for delegate :"+ - e.getMessage()); + } catch (Exception e) { + if (JConsole.isDebug()) { + System.err.println("Error adding listener for delegate:"); + e.printStackTrace(); + } } } - XMBeanNotificationsListener listener = - listeners.get(mbean.getObjectName()); + listeners.get(mbean.getObjectName()); if (listener == null) { - listener = new XMBeanNotificationsListener(this, - mbean, - node, - columnNames); + listener = new XMBeanNotificationsListener( + this, mbean, node, columnNames); listeners.put(mbean.getObjectName(), listener); } else { if (!listener.isRegistered()) { @@ -259,19 +267,21 @@ public class XMBeanNotifications extends JTable implements NotificationListener currentListener = listener; } - public synchronized void handleNotification(Notification notif, - Object handback) { + public synchronized void handleNotification( + Notification notif, Object handback) { try { if (notif instanceof MBeanServerNotification) { ObjectName mbean = - ((MBeanServerNotification)notif).getMBeanName(); - if (notif.getType().indexOf("JMX.mbean.unregistered")>=0){ + ((MBeanServerNotification) notif).getMBeanName(); + if (notif.getType().indexOf("JMX.mbean.unregistered") >= 0) { unregister(mbean); } } - } catch(Exception e) { - System.out.println("Error unregistering notification:"+ - e.getMessage()); + } catch (Exception e) { + if (JConsole.isDebug()) { + System.err.println("Error unregistering notification:"); + e.printStackTrace(); + } } } @@ -283,75 +293,77 @@ public class XMBeanNotifications extends JTable implements NotificationListener private synchronized boolean unregister(ObjectName mbean) { XMBeanNotificationsListener listener = listeners.get(mbean); - if(listener != null && listener.isRegistered()) { + if (listener != null && listener.isRegistered()) { listener.unregister(); return true; - } else + } else { return false; + } } public void addNotificationsListener(NotificationListener nl) { - notificationListenersList.add(nl); + notificationListenersList.add(nl); } public void removeNotificationsListener(NotificationListener nl) { notificationListenersList.remove(nl); } - void fireNotificationReceived(XMBeanNotificationsListener listener, - XMBean mbean, - DefaultMutableTreeNode node, - Object[] rowData, - long received) { - if(enabled) { + // Call on EDT + void fireNotificationReceived( + XMBeanNotificationsListener listener, XMBean mbean, + DefaultMutableTreeNode node, Object[] rowData, long received) { + if (enabled) { DefaultTableModel tableModel = (DefaultTableModel) getModel(); - if(listener == currentListener) { - - //tableModel.addRow(rowData); + if (listener == currentListener) { tableModel.insertRow(0, rowData); - - //tableModel.newDataAvailable(new TableModelEvent(tableModel)); repaint(); } } - - Notification notif = new Notification(NOTIFICATION_RECEIVED_EVENT, - this, - 0); - notif.setUserData(new Long(received)); - for(NotificationListener nl : notificationListenersList) - nl.handleNotification(notif,node); + Notification notif = + new Notification(NOTIFICATION_RECEIVED_EVENT, this, 0); + notif.setUserData(received); + for (NotificationListener nl : notificationListenersList) { + nl.handleNotification(notif, node); + } } + // Call on EDT private void updateModel(List data) { emptyTable(); DefaultTableModel tableModel = (DefaultTableModel) getModel(); - for(Object[] rowData : data) + for (Object[] rowData : data) { tableModel.addRow(rowData); + } } public synchronized boolean isListenerRegistered(XMBean mbean) { XMBeanNotificationsListener listener = - listeners.get(mbean.getObjectName()); - if(listener == null) return false; + listeners.get(mbean.getObjectName()); + if (listener == null) { + return false; + } return listener.isRegistered(); } + // Call on EDT public synchronized void loadNotifications(XMBean mbean) { XMBeanNotificationsListener listener = - listeners.get(mbean.getObjectName()); + listeners.get(mbean.getObjectName()); emptyTable(); - if(listener != null ) { + if (listener != null) { enabled = true; List data = listener.getData(); updateModel(data); currentListener = listener; validate(); repaint(); - } else + } else { enabled = false; + } } + // Call on EDT private void setColumnEditors() { TableColumnModel tcm = getColumnModel(); for (int i = 0; i < columnNames.length; i++) { @@ -364,40 +376,40 @@ public class XMBeanNotifications extends JTable implements NotificationListener } } + // Call on EDT public boolean isTableEditable() { return true; } + // Call on EDT public synchronized void emptyTable() { - DefaultTableModel model = (DefaultTableModel)getModel(); + DefaultTableModel model = (DefaultTableModel) getModel(); //invalidate(); - while (model.getRowCount()>0) + while (model.getRowCount() > 0) { model.removeRow(0); + } validate(); } - synchronized void updateUserDataCell(int row, - int col) { + // Call on EDT + synchronized void updateUserDataCell(int row, int col) { Object obj = getModel().getValueAt(row, 2); - if(obj instanceof UserDataCell) { + if (obj instanceof UserDataCell) { UserDataCell cell = (UserDataCell) obj; - if(!cell.isInited()) { - if(rowMinHeight == -1) + if (!cell.isInited()) { + if (rowMinHeight == -1) { rowMinHeight = getRowHeight(row); - - cell.init(super.getCellRenderer(row, col), - rowMinHeight); + } + cell.init(super.getCellRenderer(row, col), rowMinHeight); } cell.switchState(); - setRowHeight(row, - cell.getHeight()); + setRowHeight(row, cell.getHeight()); - if(!cell.isMaximized()) { + if (!cell.isMaximized()) { cancelCellEditing(); //Back to simple editor. - editCellAt(row, - 2); + editCellAt(row, 2); } invalidate(); @@ -406,7 +418,9 @@ public class XMBeanNotifications extends JTable implements NotificationListener } class UserDataCellRenderer extends DefaultTableCellRenderer { + Component comp; + UserDataCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); @@ -415,56 +429,62 @@ public class XMBeanNotifications extends JTable implements NotificationListener } } - public Component getTableCellRendererComponent(JTable table, - Object value, - boolean isSelected, - boolean hasFocus, - int row, - int column) { + @Override + public Component getTableCellRendererComponent( + JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) { return comp; } public Component getComponent() { return comp; } - } class UserDataCell { + TableCellRenderer minRenderer; UserDataCellRenderer maxRenderer; int minHeight; boolean minimized = true; boolean init = false; Object userData; - UserDataCell(Object userData, Component max) { - this.userData = userData; - this.maxRenderer = new UserDataCellRenderer(max); - - } - - public String toString() { - if(userData == null) return null; - if(userData.getClass().isArray()) { - String name = - Utils.getArrayClassName(userData.getClass().getName()); - int length = Array.getLength(userData); - return name + "[" + length +"]"; - } - - if(userData instanceof CompositeData || - userData instanceof TabularData) + + UserDataCell(Object userData, Component max) { + this.userData = userData; + this.maxRenderer = new UserDataCellRenderer(max); + + } + + @Override + public String toString() { + if (userData == null) { + return null; + } + if (userData.getClass().isArray()) { + String name = + Utils.getArrayClassName(userData.getClass().getName()); + int length = Array.getLength(userData); + return name + "[" + length + "]"; + } + + if (userData instanceof CompositeData || + userData instanceof TabularData) { return userData.getClass().getName(); + } return userData.toString(); - } + } boolean isInited() { return init; } - void init(TableCellRenderer minRenderer, - int minHeight) { + void init(TableCellRenderer minRenderer, int minHeight) { this.minRenderer = minRenderer; this.minHeight = minHeight; init = true; @@ -473,9 +493,11 @@ public class XMBeanNotifications extends JTable implements NotificationListener void switchState() { minimized = !minimized; } + boolean isMaximized() { return !minimized; } + void minimize() { minimized = true; } @@ -485,30 +507,39 @@ public class XMBeanNotifications extends JTable implements NotificationListener } int getHeight() { - if(minimized) return minHeight; - else + if (minimized) { + return minHeight; + } else { return (int) maxRenderer.getComponent(). - getPreferredSize().getHeight() ; + getPreferredSize().getHeight(); + } } TableCellRenderer getRenderer() { - if(minimized) return minRenderer; - else return maxRenderer; + if (minimized) { + return minRenderer; + } else { + return maxRenderer; + } } } class NotifMouseListener extends MouseAdapter { + @Override public void mousePressed(MouseEvent e) { - if(e.getButton() == MouseEvent.BUTTON1) { - if(e.getClickCount() >= 2) { + if (e.getButton() == MouseEvent.BUTTON1) { + if (e.getClickCount() >= 2) { int row = XMBeanNotifications.this.getSelectedRow(); int col = XMBeanNotifications.this.getSelectedColumn(); - if(col != 2) return; - if(col == -1 || row == -1) return; + if (col != 2) { + return; + } + if (col == -1 || row == -1) { + return; + } - XMBeanNotifications.this.updateUserDataCell(row, - col); + XMBeanNotifications.this.updateUserDataCell(row, col); } } } @@ -516,20 +547,21 @@ public class XMBeanNotifications extends JTable implements NotificationListener class UserDataCellEditor extends XTextFieldEditor { // implements javax.swing.table.TableCellEditor - public Component getTableCellEditorComponent(JTable table, - Object value, - boolean isSelected, - int row, - int column) { + @Override + public Component getTableCellEditorComponent( + JTable table, + Object value, + boolean isSelected, + int row, + int column) { Object val = value; - if(column == 2) { - Object obj = getModel().getValueAt(row, - column); - if(obj instanceof UserDataCell) { + if (column == 2) { + Object obj = getModel().getValueAt(row, column); + if (obj instanceof UserDataCell) { UserDataCell cell = (UserDataCell) obj; - if(cell.getRenderer() instanceof UserDataCellRenderer) { + if (cell.getRenderer() instanceof UserDataCellRenderer) { UserDataCellRenderer zr = - (UserDataCellRenderer) cell.getRenderer(); + (UserDataCellRenderer) cell.getRenderer(); return zr.getComponent(); } } else { @@ -539,12 +571,14 @@ public class XMBeanNotifications extends JTable implements NotificationListener return comp; } } - return super.getTableCellEditorComponent(table, - val, - isSelected, - row, - column); + return super.getTableCellEditorComponent( + table, + val, + isSelected, + row, + column); } + @Override public boolean stopCellEditing() { int editingRow = getEditingRow(); @@ -554,7 +588,7 @@ public class XMBeanNotifications extends JTable implements NotificationListener if (obj instanceof UserDataCell) { UserDataCell cell = (UserDataCell) obj; if (cell.isMaximized()) { - this.cancelCellEditing(); + cancelCellEditing(); return true; } } @@ -564,17 +598,20 @@ public class XMBeanNotifications extends JTable implements NotificationListener } class XMBeanNotificationsListener implements NotificationListener { + private String[] columnNames; private XMBean xmbean; private DefaultMutableTreeNode node; - private long received; + private volatile long received; private XMBeanNotifications notifications; - private boolean unregistered; + private volatile boolean unregistered; private ArrayList data = new ArrayList(); - public XMBeanNotificationsListener(XMBeanNotifications notifications, - XMBean xmbean, - DefaultMutableTreeNode node, - String[] columnNames) { + + public XMBeanNotificationsListener( + XMBeanNotifications notifications, + XMBean xmbean, + DefaultMutableTreeNode node, + String[] columnNames) { this.notifications = notifications; this.xmbean = xmbean; this.node = node; @@ -591,22 +628,24 @@ public class XMBeanNotifications extends JTable implements NotificationListener received = 0; } - public boolean isRegistered() { + public synchronized boolean isRegistered() { return !unregistered; } public synchronized void unregister() { try { - xmbean.getMBeanServerConnection(). - removeNotificationListener(xmbean.getObjectName(),this,null,null); - }catch(Exception e) { - System.out.println("Error removing listener :"+ - e.getMessage()); + xmbean.getMBeanServerConnection().removeNotificationListener( + xmbean.getObjectName(), this, null, null); + } catch (Exception e) { + if (JConsole.isDebug()) { + System.err.println("Error removing listener:"); + e.printStackTrace(); + } } unregistered = true; } - public long getReceivedNotifications() { + public synchronized long getReceivedNotifications() { return received; } @@ -614,52 +653,62 @@ public class XMBeanNotifications extends JTable implements NotificationListener clear(); this.node = node; try { - xmbean.getMBeanServerConnection(). - addNotificationListener(xmbean.getObjectName(),this,null,null); + xmbean.getMBeanServerConnection().addNotificationListener( + xmbean.getObjectName(), this, null, null); unregistered = false; - }catch(Exception e) { - System.out.println("Error adding listener :"+ - e.getMessage()); + } catch (Exception e) { + if (JConsole.isDebug()) { + System.err.println("Error adding listener:"); + e.printStackTrace(); + } } } - public synchronized void handleNotification(Notification e, - Object handback) { - try { - if(unregistered) return; - Date receivedDate = new Date(e.getTimeStamp()); - String time = timeFormater.format(receivedDate); - - Object userData = e.getUserData(); - Component comp = null; - UserDataCell cell = null; - if((comp = XDataViewer.createNotificationViewer(userData)) - != null) { - XDataViewer.registerForMouseEvent(comp, mouseListener); - cell = new UserDataCell(userData, comp); + public synchronized void handleNotification( + final Notification n, Object hb) { + EventQueue.invokeLater(new Runnable() { + + public void run() { + synchronized (XMBeanNotificationsListener.this) { + try { + if (unregistered) { + return; + } + Date receivedDate = new Date(n.getTimeStamp()); + String time = timeFormater.format(receivedDate); + + Object userData = n.getUserData(); + Component comp = null; + UserDataCell cell = null; + if ((comp = XDataViewer.createNotificationViewer(userData)) != null) { + XDataViewer.registerForMouseEvent(comp, mouseListener); + cell = new UserDataCell(userData, comp); + } + + Object[] rowData = { + time, + n.getType(), + (cell == null ? userData : cell), + n.getSequenceNumber(), + n.getMessage(), + n, + n.getSource() + }; + received++; + data.add(0, rowData); + + notifications.fireNotificationReceived( + XMBeanNotificationsListener.this, + xmbean, node, rowData, received); + } catch (Exception e) { + if (JConsole.isDebug()) { + System.err.println("Error handling notification:"); + e.printStackTrace(); + } + } + } } - - Object[] rowData = {time, - e.getType(), - (cell == null ? userData : cell), - new Long(e.getSequenceNumber()), - e.getMessage(), - e, - e.getSource()}; - received++; - data.add(0, rowData); - - notifications.fireNotificationReceived(this, - xmbean, - node, - rowData, - received); - } - catch (Exception ex) { - ex.printStackTrace(); - System.out.println("Error when handling notification :"+ - ex.toString()); - } + }); } } } diff --git a/src/share/classes/sun/tools/jconsole/inspector/XMBeanOperations.java b/src/share/classes/sun/tools/jconsole/inspector/XMBeanOperations.java index c5325e14344276b02eedaaaf3ad004187b1d99c0..81f295f3215f87feb2a9a6eb1ae61ba319824d54 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XMBeanOperations.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XMBeanOperations.java @@ -22,6 +22,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole.inspector; import javax.management.*; diff --git a/src/share/classes/sun/tools/jconsole/inspector/XObject.java b/src/share/classes/sun/tools/jconsole/inspector/XObject.java index 280607b74d2f2af471828b1c92aa6c199e9f726d..f5aa3132ca2f8ab7ab62ce7101e989cdab50de36 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XObject.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XObject.java @@ -22,6 +22,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole.inspector; // java import diff --git a/src/share/classes/sun/tools/jconsole/inspector/XOperations.java b/src/share/classes/sun/tools/jconsole/inspector/XOperations.java index c74bb948b1b58d0d5e42c40e9f1a43e6347b0d8a..14b9a676f0032f5e8bd1e2421c5129c78d333d52 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XOperations.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XOperations.java @@ -33,10 +33,7 @@ import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.FlowLayout; import java.awt.Component; -import java.awt.EventQueue; import java.awt.event.*; -import java.awt.Insets; -import java.awt.Dimension; import java.util.*; import java.io.*; @@ -49,29 +46,30 @@ import sun.tools.jconsole.JConsole; public abstract class XOperations extends JPanel implements ActionListener { public final static String OPERATION_INVOCATION_EVENT = - "jam.xoperations.invoke.result"; + "jam.xoperations.invoke.result"; private java.util.List notificationListenersList; - private Hashtable operationEntryTable; - private XMBean mbean; private MBeanInfo mbeanInfo; private MBeansTab mbeansTab; + public XOperations(MBeansTab mbeansTab) { - super(new GridLayout(1,1)); + super(new GridLayout(1, 1)); this.mbeansTab = mbeansTab; operationEntryTable = new Hashtable(); ArrayList l = - new ArrayList(1); + new ArrayList(1); notificationListenersList = - Collections.synchronizedList(l); + Collections.synchronizedList(l); } + // Call on EDT public void removeOperations() { removeAll(); } - public void loadOperations(XMBean mbean,MBeanInfo mbeanInfo) { + // Call on EDT + public void loadOperations(XMBean mbean, MBeanInfo mbeanInfo) { this.mbean = mbean; this.mbeanInfo = mbeanInfo; // add operations information @@ -80,131 +78,149 @@ public abstract class XOperations extends JPanel implements ActionListener { // remove listeners, if any Component listeners[] = getComponents(); - for (int i = 0; i < listeners.length; i++) - if (listeners[i] instanceof JButton) - ((JButton)listeners[i]).removeActionListener(this); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] instanceof JButton) { + ((JButton) listeners[i]).removeActionListener(this); + } + } removeAll(); setLayout(new BorderLayout()); JButton methodButton; JLabel methodLabel; - JPanel innerPanelLeft,innerPanelRight; - JPanel outerPanelLeft,outerPanelRight; - outerPanelLeft = new JPanel(new GridLayout(operations.length,1)); - outerPanelRight = new JPanel(new GridLayout(operations.length,1)); + JPanel innerPanelLeft, innerPanelRight; + JPanel outerPanelLeft, outerPanelRight; + outerPanelLeft = new JPanel(new GridLayout(operations.length, 1)); + outerPanelRight = new JPanel(new GridLayout(operations.length, 1)); - for (int i=0;i20) { + String returnType = operations[i].getReturnType(); + if (returnType == null) { + methodLabel = new JLabel("null", JLabel.RIGHT); + if (JConsole.isDebug()) { + System.err.println( + "WARNING: The operation's return type " + + "shouldn't be \"null\". Check how the " + + "MBeanOperationInfo for the \"" + + operations[i].getName() + "\" operation has " + + "been defined in the MBean's implementation code."); + } + } else { + methodLabel = new JLabel( + Utils.getReadableClassName(returnType), JLabel.RIGHT); + } + innerPanelLeft.add(methodLabel); + if (methodLabel.getText().length() > 20) { methodLabel.setText(methodLabel.getText(). - substring(methodLabel.getText(). - lastIndexOf(".")+1, - methodLabel.getText().length())); + substring(methodLabel.getText(). + lastIndexOf(".") + 1, + methodLabel.getText().length())); } methodButton = new JButton(operations[i].getName()); methodButton.setToolTipText(operations[i].getDescription()); boolean callable = isCallable(operations[i].getSignature()); - if(callable) + if (callable) { methodButton.addActionListener(this); - else + } else { methodButton.setEnabled(false); + } MBeanParameterInfo[] signature = operations[i].getSignature(); OperationEntry paramEntry = new OperationEntry(operations[i], - callable, - methodButton, - this); + callable, + methodButton, + this); operationEntryTable.put(methodButton, paramEntry); innerPanelRight.add(methodButton); - if(signature.length==0) - innerPanelRight.add(new JLabel("( )",JLabel.CENTER)); - else - innerPanelRight.add(paramEntry); + if (signature.length == 0) { + innerPanelRight.add(new JLabel("( )", JLabel.CENTER)); + } else { + innerPanelRight.add(paramEntry); + } - outerPanelLeft.add(innerPanelLeft,BorderLayout.WEST); - outerPanelRight.add(innerPanelRight,BorderLayout.CENTER); + outerPanelLeft.add(innerPanelLeft, BorderLayout.WEST); + outerPanelRight.add(innerPanelRight, BorderLayout.CENTER); } - add(outerPanelLeft,BorderLayout.WEST); - add(outerPanelRight,BorderLayout.CENTER); + add(outerPanelLeft, BorderLayout.WEST); + add(outerPanelRight, BorderLayout.CENTER); validate(); } private boolean isCallable(MBeanParameterInfo[] signature) { - for(int i = 0; i < signature.length; i++) { - if(!Utils.isEditableType(signature[i].getType())) + for (int i = 0; i < signature.length; i++) { + if (!Utils.isEditableType(signature[i].getType())) { return false; + } } return true; } + // Call on EDT public void actionPerformed(final ActionEvent e) { - performInvokeRequest((JButton)e.getSource()); + performInvokeRequest((JButton) e.getSource()); } void performInvokeRequest(final JButton button) { - mbeansTab.workerAdd(new Runnable() { - public void run() { + final OperationEntry entryIf = operationEntryTable.get(button); + new SwingWorker() { + @Override + public Object doInBackground() throws Exception { + return mbean.invoke(button.getText(), + entryIf.getParameters(), entryIf.getSignature()); + } + @Override + protected void done() { try { - OperationEntry entryIf = operationEntryTable.get(button); - Object result = null; - result = mbean.invoke(button.getText(), - entryIf.getParameters(), - entryIf.getSignature()); + Object result = get(); // sends result notification to upper level if // there is a return value if (entryIf.getReturnType() != null && - !entryIf.getReturnType().equals(Void.TYPE.getName()) && - !entryIf.getReturnType().equals(Void.class.getName())) - fireChangedNotification(OPERATION_INVOCATION_EVENT, - button, - result); - else - EventQueue.invokeLater(new ThreadDialog( - button, - Resources.getText("Method successfully invoked"), - Resources.getText("Info"), - JOptionPane.INFORMATION_MESSAGE)); - } catch (Throwable ex) { + !entryIf.getReturnType().equals(Void.TYPE.getName()) && + !entryIf.getReturnType().equals(Void.class.getName())) { + fireChangedNotification(OPERATION_INVOCATION_EVENT, button, result); + } else { + new ThreadDialog( + button, + Resources.getText("Method successfully invoked"), + Resources.getText("Info"), + JOptionPane.INFORMATION_MESSAGE).run(); + } + } catch (Throwable t) { + t = Utils.getActualException(t); if (JConsole.isDebug()) { - ex.printStackTrace(); + t.printStackTrace(); } - ex = Utils.getActualException(ex); - String message = ex.toString(); - EventQueue.invokeLater(new ThreadDialog( - button, - Resources.getText("Problem invoking") + " " + - button.getText() + " : " + message, - Resources.getText("Error"), - JOptionPane.ERROR_MESSAGE)); + new ThreadDialog( + button, + Resources.getText("Problem invoking") + " " + + button.getText() + " : " + t.toString(), + Resources.getText("Error"), + JOptionPane.ERROR_MESSAGE).run(); } } - }); + }.execute(); } public void addOperationsListener(NotificationListener nl) { - notificationListenersList.add(nl); - } + notificationListenersList.add(nl); + } public void removeOperationsListener(NotificationListener nl) { notificationListenersList.remove(nl); } - private void fireChangedNotification(String type, - Object source, - Object handback) { - Notification e = new Notification(type,source,0); - for(NotificationListener nl : notificationListenersList) - nl.handleNotification(e,handback); + // Call on EDT + private void fireChangedNotification( + String type, Object source, Object handback) { + Notification n = new Notification(type, source, 0); + for (NotificationListener nl : notificationListenersList) { + nl.handleNotification(n, handback); + } } - protected abstract MBeanOperationInfo[] - updateOperations(MBeanOperationInfo[] operations); + protected abstract MBeanOperationInfo[] updateOperations(MBeanOperationInfo[] operations); } diff --git a/src/share/classes/sun/tools/jconsole/inspector/XPlotter.java b/src/share/classes/sun/tools/jconsole/inspector/XPlotter.java index 292dc78adf6ef7109aa053adfab6397f1ac07e6a..9135b7a540205c0b825cf54cd05e1e0a6840ea4e 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XPlotter.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XPlotter.java @@ -22,7 +22,9 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole.inspector; + import sun.tools.jconsole.Plotter; import javax.swing.JTable; import java.awt.Graphics; diff --git a/src/share/classes/sun/tools/jconsole/inspector/XPlottingViewer.java b/src/share/classes/sun/tools/jconsole/inspector/XPlottingViewer.java index 017a4a7df93d3e4c88d54bddc6ca656bf91cb629..5bcf72dd719585efcb36a0dc09fe272669819712 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XPlottingViewer.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XPlottingViewer.java @@ -22,6 +22,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole.inspector; import java.awt.*; diff --git a/src/share/classes/sun/tools/jconsole/inspector/XSheet.java b/src/share/classes/sun/tools/jconsole/inspector/XSheet.java index 6360a082ae4030ef68508a3028337e15e8fd4560..11fce7f45bf04ac6ca2167608b42dc2069a79ac1 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XSheet.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XSheet.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2004-2007 Sun Microsystems, 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 @@ -28,7 +28,6 @@ package sun.tools.jconsole.inspector; import java.awt.*; import java.awt.event.*; import java.io.*; -import java.util.Enumeration; import javax.management.*; import javax.swing.*; import javax.swing.border.*; @@ -45,31 +44,22 @@ public class XSheet extends JPanel private JPanel mainPanel; private JPanel southPanel; - // Node being currently displayed - private DefaultMutableTreeNode node; - + private volatile DefaultMutableTreeNode currentNode; // MBean being currently displayed - private XMBean mbean; - + private volatile XMBean mbean; // XMBeanAttributes container private XMBeanAttributes mbeanAttributes; - // XMBeanOperations container private XMBeanOperations mbeanOperations; - // XMBeanNotifications container private XMBeanNotifications mbeanNotifications; - // XMBeanInfo container private XMBeanInfo mbeanInfo; - // Refresh JButton (mbean attributes case) private JButton refreshButton; - // Subscribe/Unsubscribe/Clear JButton (mbean notifications case) - private JButton clearButton, subscribeButton, unsubscribeButton; - + private JButton clearButton, subscribeButton, unsubscribeButton; // Reference to MBeans tab private MBeansTab mbeansTab; @@ -86,6 +76,7 @@ public class XSheet extends JPanel private void setupScreen() { setLayout(new BorderLayout()); + setBorder(BorderFactory.createLineBorder(Color.GRAY)); // add main panel to XSheet mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); @@ -129,17 +120,32 @@ public class XSheet extends JPanel mbeanInfo = new XMBeanInfo(); } + private boolean isSelectedNode(DefaultMutableTreeNode n, DefaultMutableTreeNode cn) { + return (cn == n); + } + + // Call on EDT + private void showErrorDialog(Object message, String title) { + new ThreadDialog(this, message, title, JOptionPane.ERROR_MESSAGE).run(); + } + public boolean isMBeanNode(DefaultMutableTreeNode node) { - XNodeInfo uo = (XNodeInfo) node.getUserObject(); - return uo.getType().equals(Type.MBEAN); + Object userObject = node.getUserObject(); + if (userObject instanceof XNodeInfo) { + XNodeInfo uo = (XNodeInfo) userObject; + return uo.getType().equals(Type.MBEAN); + } + return false; } - public void displayNode(DefaultMutableTreeNode node) { + // Call on EDT + public synchronized void displayNode(DefaultMutableTreeNode node) { clear(); + displayEmptyNode(); if (node == null) { - displayEmptyNode(); return; } + currentNode = node; Object userObject = node.getUserObject(); if (userObject instanceof XNodeInfo) { XNodeInfo uo = (XNodeInfo) userObject; @@ -173,27 +179,28 @@ public class XSheet extends JPanel } } + // Call on EDT private void displayMBeanNode(final DefaultMutableTreeNode node) { final XNodeInfo uo = (XNodeInfo) node.getUserObject(); if (!uo.getType().equals(Type.MBEAN)) { return; } - mbeansTab.workerAdd(new Runnable() { - public void run() { + mbean = (XMBean) uo.getData(); + SwingWorker sw = new SwingWorker() { + @Override + public MBeanInfo doInBackground() throws InstanceNotFoundException, + IntrospectionException, ReflectionException, IOException { + return mbean.getMBeanInfo(); + } + @Override + protected void done() { try { - XSheet.this.node = node; - XSheet.this.mbean = (XMBean) uo.getData(); - mbeanInfo.addMBeanInfo(mbean, mbean.getMBeanInfo()); - } catch (Throwable ex) { - EventQueue.invokeLater(new ThreadDialog( - XSheet.this, - ex.getMessage(), - Resources.getText("Problem displaying MBean"), - JOptionPane.ERROR_MESSAGE)); - return; - } - EventQueue.invokeLater(new Runnable() { - public void run() { + MBeanInfo mbi = get(); + if (mbi != null) { + if (!isSelectedNode(node, currentNode)) { + return; + } + mbeanInfo.addMBeanInfo(mbean, mbi); invalidate(); mainPanel.removeAll(); mainPanel.add(mbeanInfo, BorderLayout.CENTER); @@ -202,9 +209,19 @@ public class XSheet extends JPanel validate(); repaint(); } - }); + } catch (Exception e) { + Throwable t = Utils.getActualException(e); + if (JConsole.isDebug()) { + System.err.println("Couldn't get MBeanInfo for MBean [" + + mbean.getObjectName() + "]"); + t.printStackTrace(); + } + showErrorDialog(t.toString(), + Resources.getText("Problem displaying MBean")); + } } - }); + }; + sw.execute(); } // Call on EDT @@ -213,90 +230,90 @@ public class XSheet extends JPanel final XMBeanInfo mbi = mbeanInfo; switch (uo.getType()) { case ATTRIBUTE: - mbeansTab.workerAdd(new Runnable() { - public void run() { - Object attrData = uo.getData(); - XSheet.this.mbean = (XMBean) ((Object[]) attrData)[0]; - final MBeanAttributeInfo mbai = - (MBeanAttributeInfo) ((Object[]) attrData)[1]; - final XMBeanAttributes mba = mbeanAttributes; - try { - mba.loadAttributes(mbean, new MBeanInfo( - null, null, new MBeanAttributeInfo[] {mbai}, - null, null, null)); - } catch (Exception e) { - EventQueue.invokeLater(new ThreadDialog( - XSheet.this, - e.getMessage(), - Resources.getText("Problem displaying MBean"), - JOptionPane.ERROR_MESSAGE)); - return; - } - EventQueue.invokeLater(new Runnable() { - public void run() { - invalidate(); - mainPanel.removeAll(); - JPanel attributePanel = - new JPanel(new BorderLayout()); - JPanel attributeBorderPanel = - new JPanel(new BorderLayout()); - attributeBorderPanel.setBorder( - BorderFactory.createTitledBorder( - Resources.getText("Attribute value"))); - JPanel attributeValuePanel = - new JPanel(new BorderLayout()); - attributeValuePanel.setBorder( - LineBorder.createGrayLineBorder()); - attributeValuePanel.add(mba.getTableHeader(), - BorderLayout.PAGE_START); - attributeValuePanel.add(mba, - BorderLayout.CENTER); - attributeBorderPanel.add(attributeValuePanel, - BorderLayout.CENTER); - JPanel refreshButtonPanel = new JPanel(); - refreshButtonPanel.add(refreshButton); - attributeBorderPanel.add(refreshButtonPanel, - BorderLayout.SOUTH); - refreshButton.setEnabled(true); - attributePanel.add(attributeBorderPanel, - BorderLayout.NORTH); - mbi.addMBeanAttributeInfo(mbai); - attributePanel.add(mbi, BorderLayout.CENTER); - mainPanel.add(attributePanel, - BorderLayout.CENTER); - southPanel.setVisible(false); - southPanel.removeAll(); - validate(); - repaint(); + SwingWorker sw = + new SwingWorker() { + @Override + public MBeanAttributeInfo doInBackground() { + Object attrData = uo.getData(); + mbean = (XMBean) ((Object[]) attrData)[0]; + MBeanAttributeInfo mbai = + (MBeanAttributeInfo) ((Object[]) attrData)[1]; + mbeanAttributes.loadAttributes(mbean, new MBeanInfo( + null, null, new MBeanAttributeInfo[]{mbai}, + null, null, null)); + return mbai; } - }); - } - }); + @Override + protected void done() { + try { + MBeanAttributeInfo mbai = get(); + if (!isSelectedNode(node, currentNode)) { + return; + } + invalidate(); + mainPanel.removeAll(); + JPanel attributePanel = + new JPanel(new BorderLayout()); + JPanel attributeBorderPanel = + new JPanel(new BorderLayout()); + attributeBorderPanel.setBorder( + BorderFactory.createTitledBorder( + Resources.getText("Attribute value"))); + JPanel attributeValuePanel = + new JPanel(new BorderLayout()); + attributeValuePanel.setBorder( + LineBorder.createGrayLineBorder()); + attributeValuePanel.add(mbeanAttributes.getTableHeader(), + BorderLayout.PAGE_START); + attributeValuePanel.add(mbeanAttributes, + BorderLayout.CENTER); + attributeBorderPanel.add(attributeValuePanel, + BorderLayout.CENTER); + JPanel refreshButtonPanel = new JPanel(); + refreshButtonPanel.add(refreshButton); + attributeBorderPanel.add(refreshButtonPanel, + BorderLayout.SOUTH); + refreshButton.setEnabled(true); + attributePanel.add(attributeBorderPanel, + BorderLayout.NORTH); + mbi.addMBeanAttributeInfo(mbai); + attributePanel.add(mbi, BorderLayout.CENTER); + mainPanel.add(attributePanel, + BorderLayout.CENTER); + southPanel.setVisible(false); + southPanel.removeAll(); + validate(); + repaint(); + } catch (Exception e) { + Throwable t = Utils.getActualException(e); + if (JConsole.isDebug()) { + System.err.println("Problem displaying MBean " + + "attribute for MBean [" + + mbean.getObjectName() + "]"); + t.printStackTrace(); + } + showErrorDialog(t.toString(), + Resources.getText("Problem displaying MBean")); + } + } + }; + sw.execute(); break; case OPERATION: Object operData = uo.getData(); - XSheet.this.mbean = (XMBean) ((Object[]) operData)[0]; + mbean = (XMBean) ((Object[]) operData)[0]; MBeanOperationInfo mboi = (MBeanOperationInfo) ((Object[]) operData)[1]; - XMBeanOperations mbo = mbeanOperations; - try { - mbo.loadOperations(mbean, new MBeanInfo(null, null, null, - null, new MBeanOperationInfo[] {mboi}, null)); - } catch (Exception e) { - EventQueue.invokeLater(new ThreadDialog( - XSheet.this, - e.getMessage(), - Resources.getText("Problem displaying MBean"), - JOptionPane.ERROR_MESSAGE)); - return; - } + mbeanOperations.loadOperations(mbean, + new MBeanInfo(null, null, null, null, + new MBeanOperationInfo[]{mboi}, null)); invalidate(); mainPanel.removeAll(); JPanel operationPanel = new JPanel(new BorderLayout()); JPanel operationBorderPanel = new JPanel(new BorderLayout()); operationBorderPanel.setBorder(BorderFactory.createTitledBorder( Resources.getText("Operation invocation"))); - operationBorderPanel.add(new JScrollPane(mbo)); + operationBorderPanel.add(new JScrollPane(mbeanOperations)); operationPanel.add(operationBorderPanel, BorderLayout.NORTH); mbi.addMBeanOperationInfo(mboi); operationPanel.add(mbi, BorderLayout.CENTER); @@ -320,134 +337,134 @@ public class XSheet extends JPanel } } + // Call on EDT private void displayMBeanAttributesNode(final DefaultMutableTreeNode node) { final XNodeInfo uo = (XNodeInfo) node.getUserObject(); if (!uo.getType().equals(Type.ATTRIBUTES)) { return; } - final XMBeanAttributes mba = mbeanAttributes; - mbeansTab.workerAdd(new Runnable() { - public void run() { + mbean = (XMBean) uo.getData(); + SwingWorker sw = new SwingWorker() { + @Override + public Void doInBackground() throws InstanceNotFoundException, + IntrospectionException, ReflectionException, IOException { + mbeanAttributes.loadAttributes(mbean, mbean.getMBeanInfo()); + return null; + } + @Override + protected void done() { try { - XSheet.this.node = node; - XSheet.this.mbean = (XMBean) uo.getData(); - mba.loadAttributes(mbean, mbean.getMBeanInfo()); - } catch (Throwable ex) { - EventQueue.invokeLater(new ThreadDialog( - XSheet.this, - ex.getMessage(), - Resources.getText("Problem displaying MBean"), - JOptionPane.ERROR_MESSAGE)); - return; - } - EventQueue.invokeLater(new Runnable() { - public void run() { - invalidate(); - mainPanel.removeAll(); - JPanel borderPanel = new JPanel(new BorderLayout()); - borderPanel.setBorder(BorderFactory.createTitledBorder( - Resources.getText("Attribute values"))); - borderPanel.add(new JScrollPane(mba)); - mainPanel.add(borderPanel, BorderLayout.CENTER); - // add the refresh button to the south panel - southPanel.removeAll(); - southPanel.add(refreshButton, BorderLayout.SOUTH); - southPanel.setVisible(true); - refreshButton.setEnabled(true); - validate(); - repaint(); + get(); + if (!isSelectedNode(node, currentNode)) { + return; } - }); + invalidate(); + mainPanel.removeAll(); + JPanel borderPanel = new JPanel(new BorderLayout()); + borderPanel.setBorder(BorderFactory.createTitledBorder( + Resources.getText("Attribute values"))); + borderPanel.add(new JScrollPane(mbeanAttributes)); + mainPanel.add(borderPanel, BorderLayout.CENTER); + // add the refresh button to the south panel + southPanel.removeAll(); + southPanel.add(refreshButton, BorderLayout.SOUTH); + southPanel.setVisible(true); + refreshButton.setEnabled(true); + validate(); + repaint(); + } catch (Exception e) { + Throwable t = Utils.getActualException(e); + if (JConsole.isDebug()) { + System.err.println("Problem displaying MBean " + + "attributes for MBean [" + + mbean.getObjectName() + "]"); + t.printStackTrace(); + } + showErrorDialog(t.toString(), + Resources.getText("Problem displaying MBean")); + } } - }); + }; + sw.execute(); } + // Call on EDT private void displayMBeanOperationsNode(final DefaultMutableTreeNode node) { final XNodeInfo uo = (XNodeInfo) node.getUserObject(); if (!uo.getType().equals(Type.OPERATIONS)) { return; } - final XMBeanOperations mbo = mbeanOperations; - mbeansTab.workerAdd(new Runnable() { - public void run() { + mbean = (XMBean) uo.getData(); + SwingWorker sw = new SwingWorker() { + @Override + public MBeanInfo doInBackground() throws InstanceNotFoundException, + IntrospectionException, ReflectionException, IOException { + return mbean.getMBeanInfo(); + } + @Override + protected void done() { try { - XSheet.this.node = node; - XSheet.this.mbean = (XMBean) uo.getData(); - mbo.loadOperations(mbean, mbean.getMBeanInfo()); - } catch (Throwable ex) { - EventQueue.invokeLater(new ThreadDialog( - XSheet.this, - ex.getMessage(), - Resources.getText("Problem displaying MBean"), - JOptionPane.ERROR_MESSAGE)); - return; - } - EventQueue.invokeLater(new Runnable() { - public void run() { + MBeanInfo mbi = get(); + if (mbi != null) { + if (!isSelectedNode(node, currentNode)) { + return; + } + mbeanOperations.loadOperations(mbean, mbi); invalidate(); mainPanel.removeAll(); JPanel borderPanel = new JPanel(new BorderLayout()); borderPanel.setBorder(BorderFactory.createTitledBorder( Resources.getText("Operation invocation"))); - borderPanel.add(new JScrollPane(mbo)); + borderPanel.add(new JScrollPane(mbeanOperations)); mainPanel.add(borderPanel, BorderLayout.CENTER); southPanel.setVisible(false); southPanel.removeAll(); validate(); repaint(); } - }); + } catch (Exception e) { + Throwable t = Utils.getActualException(e); + if (JConsole.isDebug()) { + System.err.println("Problem displaying MBean " + + "operations for MBean [" + + mbean.getObjectName() + "]"); + t.printStackTrace(); + } + showErrorDialog(t.toString(), + Resources.getText("Problem displaying MBean")); + } } - }); + }; + sw.execute(); } - private void displayMBeanNotificationsNode( - final DefaultMutableTreeNode node) { + // Call on EDT + private void displayMBeanNotificationsNode(DefaultMutableTreeNode node) { final XNodeInfo uo = (XNodeInfo) node.getUserObject(); if (!uo.getType().equals(Type.NOTIFICATIONS)) { return; } - final XMBeanNotifications mbn = mbeanNotifications; - mbeansTab.workerAdd(new Runnable() { - public void run() { - try { - XSheet.this.node = node; - XSheet.this.mbean = (XMBean) uo.getData(); - mbn.loadNotifications(mbean); - updateNotifications(); - } catch (Throwable ex) { - EventQueue.invokeLater(new ThreadDialog( - XSheet.this, - ex.getMessage(), - Resources.getText("Problem displaying MBean"), - JOptionPane.ERROR_MESSAGE)); - return; - } - EventQueue.invokeLater(new Runnable() { - public void run() { - invalidate(); - mainPanel.removeAll(); - JPanel borderPanel = new JPanel(new BorderLayout()); - borderPanel.setBorder(BorderFactory.createTitledBorder( - Resources.getText("Notification buffer"))); - borderPanel.add(new JScrollPane(mbn)); - mainPanel.add(borderPanel, BorderLayout.CENTER); - // add the subscribe/unsubscribe/clear buttons to - // the south panel - southPanel.removeAll(); - southPanel.add(subscribeButton, BorderLayout.WEST); - southPanel.add(unsubscribeButton, BorderLayout.CENTER); - southPanel.add(clearButton, BorderLayout.EAST); - southPanel.setVisible(true); - subscribeButton.setEnabled(true); - unsubscribeButton.setEnabled(true); - clearButton.setEnabled(true); - validate(); - repaint(); - } - }); - } - }); + mbean = (XMBean) uo.getData(); + mbeanNotifications.loadNotifications(mbean); + updateNotifications(); + invalidate(); + mainPanel.removeAll(); + JPanel borderPanel = new JPanel(new BorderLayout()); + borderPanel.setBorder(BorderFactory.createTitledBorder( + Resources.getText("Notification buffer"))); + borderPanel.add(new JScrollPane(mbeanNotifications)); + mainPanel.add(borderPanel, BorderLayout.CENTER); + // add the subscribe/unsubscribe/clear buttons to the south panel + southPanel.removeAll(); + southPanel.add(subscribeButton, BorderLayout.WEST); + southPanel.add(unsubscribeButton, BorderLayout.CENTER); + southPanel.add(clearButton, BorderLayout.EAST); + southPanel.setVisible(true); + subscribeButton.setEnabled(true); + unsubscribeButton.setEnabled(true); + clearButton.setEnabled(true); + validate(); + repaint(); } // Call on EDT @@ -462,21 +479,60 @@ public class XSheet extends JPanel /** * Subscribe button action. */ - private void registerListener() throws InstanceNotFoundException, - IOException { - mbeanNotifications.registerListener(node); - updateNotifications(); - validate(); + private void registerListener() { + new SwingWorker() { + @Override + public Void doInBackground() + throws InstanceNotFoundException, IOException { + mbeanNotifications.registerListener(currentNode); + return null; + } + @Override + protected void done() { + try { + get(); + updateNotifications(); + validate(); + } catch (Exception e) { + Throwable t = Utils.getActualException(e); + if (JConsole.isDebug()) { + System.err.println("Problem adding listener"); + t.printStackTrace(); + } + showErrorDialog(t.getMessage(), + Resources.getText("Problem adding listener")); + } + } + }.execute(); } /** * Unsubscribe button action. */ private void unregisterListener() { - if (mbeanNotifications.unregisterListener(node)) { - clearNotifications(); - validate(); - } + new SwingWorker() { + @Override + public Boolean doInBackground() { + return mbeanNotifications.unregisterListener(currentNode); + } + @Override + protected void done() { + try { + if (get()) { + updateNotifications(); + validate(); + } + } catch (Exception e) { + Throwable t = Utils.getActualException(e); + if (JConsole.isDebug()) { + System.err.println("Problem removing listener"); + t.printStackTrace(); + } + showErrorDialog(t.getMessage(), + Resources.getText("Problem removing listener")); + } + } + }.execute(); } /** @@ -486,15 +542,11 @@ public class XSheet extends JPanel mbeanAttributes.refreshAttributes(); } + // Call on EDT private void updateNotifications() { - if (mbean.isBroadcaster()) { - if (mbeanNotifications.isListenerRegistered(mbean)) { - long received = - mbeanNotifications.getReceivedNotifications(mbean); - updateReceivedNotifications(node, received, false); - } else { - clearNotifications(); - } + if (mbeanNotifications.isListenerRegistered(mbean)) { + long received = mbeanNotifications.getReceivedNotifications(mbean); + updateReceivedNotifications(currentNode, received, false); } else { clearNotifications(); } @@ -503,11 +555,11 @@ public class XSheet extends JPanel /** * Update notification node label in MBean tree: "Notifications[received]". */ + // Call on EDT private void updateReceivedNotifications( DefaultMutableTreeNode emitter, long received, boolean bold) { String text = Resources.getText("Notifications") + "[" + received + "]"; - DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) - mbeansTab.getTree().getLastSelectedPathComponent(); + DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) mbeansTab.getTree().getLastSelectedPathComponent(); if (bold && emitter != selectedNode) { text = "" + text + ""; } @@ -517,41 +569,40 @@ public class XSheet extends JPanel /** * Update notification node label in MBean tree: "Notifications". */ + // Call on EDT private void clearNotifications() { - updateNotificationsNodeLabel(node, + updateNotificationsNodeLabel(currentNode, Resources.getText("Notifications")); } /** * Update notification node label in MBean tree: "Notifications[0]". */ + // Call on EDT private void clearNotifications0() { - updateNotificationsNodeLabel(node, + updateNotificationsNodeLabel(currentNode, Resources.getText("Notifications") + "[0]"); } /** * Update the label of the supplied MBean tree node. */ + // Call on EDT private void updateNotificationsNodeLabel( - final DefaultMutableTreeNode node, final String label) { - EventQueue.invokeLater(new Runnable() { - public void run() { - synchronized (mbeansTab.getTree()) { - invalidate(); - XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject(); - XNodeInfo newUserObject = new XNodeInfo( - oldUserObject.getType(), oldUserObject.getData(), - label, oldUserObject.getToolTipText()); - node.setUserObject(newUserObject); - DefaultTreeModel model = - (DefaultTreeModel) mbeansTab.getTree().getModel(); - model.nodeChanged(node); - validate(); - repaint(); - } - } - }); + DefaultMutableTreeNode node, String label) { + synchronized (mbeansTab.getTree()) { + invalidate(); + XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject(); + XNodeInfo newUserObject = new XNodeInfo( + oldUserObject.getType(), oldUserObject.getData(), + label, oldUserObject.getToolTipText()); + node.setUserObject(newUserObject); + DefaultTreeModel model = + (DefaultTreeModel) mbeansTab.getTree().getModel(); + model.nodeChanged(node); + validate(); + repaint(); + } } /** @@ -577,6 +628,7 @@ public class XSheet extends JPanel } } + // Call on EDT private void clear() { mbeanAttributes.stopCellEditing(); mbeanAttributes.emptyTable(); @@ -586,13 +638,14 @@ public class XSheet extends JPanel mbeanNotifications.emptyTable(); mbeanNotifications.disableNotifications(); mbean = null; - node = null; + currentNode = null; } /** * Notification listener: handles asynchronous reception * of MBean operation results and MBean notifications. */ + // Call on EDT public void handleNotification(Notification e, Object handback) { // Operation result if (e.getType().equals(XOperations.OPERATION_INVOCATION_EVENT)) { @@ -628,13 +681,12 @@ public class XSheet extends JPanel message = comp; } } - EventQueue.invokeLater(new ThreadDialog( + new ThreadDialog( (Component) e.getSource(), message, Resources.getText("Operation return value"), - JOptionPane.INFORMATION_MESSAGE)); - } - // Got notification + JOptionPane.INFORMATION_MESSAGE).run(); + } // Got notification else if (e.getType().equals( XMBeanNotifications.NOTIFICATION_RECEIVED_EVENT)) { DefaultMutableTreeNode emitter = (DefaultMutableTreeNode) handback; @@ -646,16 +698,19 @@ public class XSheet extends JPanel /** * Action listener: handles actions in panel buttons */ + // Call on EDT public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JButton) { JButton button = (JButton) e.getSource(); // Refresh button if (button == refreshButton) { - mbeansTab.workerAdd(new Runnable() { - public void run() { + new SwingWorker() { + @Override + public Void doInBackground() { refreshAttributes(); + return null; } - }); + }.execute(); return; } // Clear button @@ -665,38 +720,12 @@ public class XSheet extends JPanel } // Subscribe button if (button == subscribeButton) { - mbeansTab.workerAdd(new Runnable() { - public void run() { - try { - registerListener(); - } catch (Throwable ex) { - ex = Utils.getActualException(ex); - EventQueue.invokeLater(new ThreadDialog( - XSheet.this, - ex.getMessage(), - Resources.getText("Problem adding listener"), - JOptionPane.ERROR_MESSAGE)); - } - } - }); + registerListener(); return; } // Unsubscribe button if (button == unsubscribeButton) { - mbeansTab.workerAdd(new Runnable() { - public void run() { - try { - unregisterListener(); - } catch (Throwable ex) { - ex = Utils.getActualException(ex); - EventQueue.invokeLater(new ThreadDialog( - XSheet.this, - ex.getMessage(), - Resources.getText("Problem removing listener"), - JOptionPane.ERROR_MESSAGE)); - } - } - }); + unregisterListener(); return; } } diff --git a/src/share/classes/sun/tools/jconsole/inspector/XTable.java b/src/share/classes/sun/tools/jconsole/inspector/XTable.java index 5b695c81699fec6f893aacf58593c35377ee560d..c75ca66ccf5df21b38069c9e1184611f87f4a5bc 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XTable.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XTable.java @@ -22,6 +22,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole.inspector; import javax.swing.*; diff --git a/src/share/classes/sun/tools/jconsole/inspector/XTextField.java b/src/share/classes/sun/tools/jconsole/inspector/XTextField.java index 2e7f8cb6f676d01b6b307724375f363a1521ac45..a84819d27c55df73b27b452590d4c91c83784a62 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XTextField.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XTextField.java @@ -22,6 +22,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole.inspector; import java.awt.*; diff --git a/src/share/classes/sun/tools/jconsole/inspector/XTextFieldEditor.java b/src/share/classes/sun/tools/jconsole/inspector/XTextFieldEditor.java index 9476d5a8500b521bcf1ec2bdc3459cae48b3ba7b..237df93778875fddbb82295fb51a7344d75fc6e8 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XTextFieldEditor.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XTextFieldEditor.java @@ -22,6 +22,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + package sun.tools.jconsole.inspector; import java.awt.Component; diff --git a/src/share/classes/sun/tools/jconsole/inspector/XTree.java b/src/share/classes/sun/tools/jconsole/inspector/XTree.java index c6f4ce4976de1b6000cf8d1322647ed38cb0b2c9..38ee4065a359daba1d1f2c09069845e675d8767f 100644 --- a/src/share/classes/sun/tools/jconsole/inspector/XTree.java +++ b/src/share/classes/sun/tools/jconsole/inspector/XTree.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2004-2007 Sun Microsystems, 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 @@ -25,7 +25,7 @@ package sun.tools.jconsole.inspector; -import java.awt.EventQueue; +import java.io.IOException; import java.util.*; import javax.management.*; import javax.swing.*; @@ -34,13 +34,14 @@ import sun.tools.jconsole.JConsole; import sun.tools.jconsole.MBeansTab; import sun.tools.jconsole.Resources; import sun.tools.jconsole.inspector.XNodeInfo; -import sun.tools.jconsole.inspector.XNodeInfo.Type; +import static sun.tools.jconsole.inspector.XNodeInfo.Type; @SuppressWarnings("serial") public class XTree extends JTree { private static final List orderedKeyPropertyList = new ArrayList(); + static { String keyPropertyList = System.getProperty("com.sun.tools.jconsole.mbeans.keyPropertyList"); @@ -54,9 +55,7 @@ public class XTree extends JTree { } } } - private MBeansTab mbeansTab; - private Map nodes = new HashMap(); @@ -65,7 +64,7 @@ public class XTree extends JTree { } public XTree(TreeNode root, MBeansTab mbeansTab) { - super(root); + super(root, true); this.mbeansTab = mbeansTab; setRootVisible(false); setShowsRootHandles(true); @@ -90,15 +89,8 @@ public class XTree extends JTree { DefaultMutableTreeNode parent, DefaultMutableTreeNode child, int index) { - // Tree does not show up when there is only the root node - // DefaultTreeModel model = (DefaultTreeModel) getModel(); - DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); - boolean rootLeaf = root.isLeaf(); model.insertNodeInto(child, parent, index); - if (rootLeaf) { - model.nodeStructureChanged(root); - } } /** @@ -114,32 +106,29 @@ public class XTree extends JTree { int childCount = parent.getChildCount(); if (childCount == 0) { addChildNode(parent, child, 0); - } else if (child instanceof ComparableDefaultMutableTreeNode) { + return; + } + if (child instanceof ComparableDefaultMutableTreeNode) { ComparableDefaultMutableTreeNode comparableChild = - (ComparableDefaultMutableTreeNode)child; - int i = 0; - for (; i < childCount; i++) { + (ComparableDefaultMutableTreeNode) child; + for (int i = childCount - 1; i >= 0; i--) { DefaultMutableTreeNode brother = (DefaultMutableTreeNode) parent.getChildAt(i); - //child < brother - if (comparableChild.compareTo(brother) < 0) { - addChildNode(parent, child, i); - break; - } - //child = brother - else if (comparableChild.compareTo(brother) == 0) { - addChildNode(parent, child, i); - break; + // expr1: child node must be inserted after metadata nodes + // - OR - + // expr2: "child >= brother" + if ((i <= 2 && isMetadataNode(brother)) || + comparableChild.compareTo(brother) >= 0) { + addChildNode(parent, child, i + 1); + return; } } - //child < all brothers - if (i == childCount) { - addChildNode(parent, child, childCount); - } - } else { - //not comparable, add at the end - addChildNode(parent, child, childCount); + // "child < all brothers", add at the beginning + addChildNode(parent, child, 0); + return; } + // "child not comparable", add at the end + addChildNode(parent, child, childCount); } /** @@ -147,6 +136,7 @@ public class XTree extends JTree { * but does not affect actual MBeanServer contents. */ // Call on EDT + @Override public synchronized void removeAll() { DefaultTreeModel model = (DefaultTreeModel) getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); @@ -155,51 +145,56 @@ public class XTree extends JTree { nodes.clear(); } - public void delMBeanFromView(final ObjectName mbean) { - EventQueue.invokeLater(new Runnable() { - public void run() { - // We assume here that MBeans are removed one by one (on MBean - // unregistered notification). Deletes the tree node associated - // with the given MBean and recursively all the node parents - // which are leaves and non XMBean. - // - synchronized (XTree.this) { - DefaultMutableTreeNode node = null; - Dn dn = buildDn(mbean); - if (dn.size() > 0) { - DefaultTreeModel model = (DefaultTreeModel) getModel(); - Token token = dn.getToken(0); - String hashKey = dn.getHashKey(token); - node = nodes.get(hashKey); - if ((node != null) && (!node.isRoot())) { - if (hasMBeanChildren(node)) { - removeNonMBeanChildren(node); - String label = token.getValue().toString(); - XNodeInfo userObject = new XNodeInfo( - Type.NONMBEAN, label, - label, token.toString()); - changeNodeValue(node, userObject); - } else { - DefaultMutableTreeNode parent = - (DefaultMutableTreeNode) node.getParent(); - model.removeNodeFromParent(node); - nodes.remove(hashKey); - delParentFromView(dn, 1, parent); - } - } - } + // Call on EDT + public synchronized void removeMBeanFromView(ObjectName mbean) { + // We assume here that MBeans are removed one by one (on MBean + // unregistered notification). Deletes the tree node associated + // with the given MBean and recursively all the node parents + // which are leaves and non XMBean. + // + DefaultMutableTreeNode node = null; + Dn dn = new Dn(mbean); + if (dn.getTokenCount() > 0) { + DefaultTreeModel model = (DefaultTreeModel) getModel(); + Token token = dn.getToken(0); + String hashKey = dn.getHashKey(token); + node = nodes.get(hashKey); + if ((node != null) && (!node.isRoot())) { + if (hasNonMetadataNodes(node)) { + removeMetadataNodes(node); + String label = token.getValue(); + XNodeInfo userObject = new XNodeInfo( + Type.NONMBEAN, label, + label, token.getTokenValue()); + changeNodeValue(node, userObject); + } else { + DefaultMutableTreeNode parent = + (DefaultMutableTreeNode) node.getParent(); + model.removeNodeFromParent(node); + nodes.remove(hashKey); + removeParentFromView(dn, 1, parent); } } - }); + } } /** - * Returns true if any of the children nodes is an MBean. + * Returns true if any of the children nodes is a non MBean metadata node. */ - private boolean hasMBeanChildren(DefaultMutableTreeNode node) { - for (Enumeration e = node.children(); e.hasMoreElements(); ) { + private boolean hasNonMetadataNodes(DefaultMutableTreeNode node) { + for (Enumeration e = node.children(); e.hasMoreElements();) { DefaultMutableTreeNode n = (DefaultMutableTreeNode) e.nextElement(); - if (((XNodeInfo) n.getUserObject()).getType().equals(Type.MBEAN)) { + Object uo = n.getUserObject(); + if (uo instanceof XNodeInfo) { + switch (((XNodeInfo) uo).getType()) { + case ATTRIBUTES: + case NOTIFICATIONS: + case OPERATIONS: + break; + default: + return true; + } + } else { return true; } } @@ -207,16 +202,68 @@ public class XTree extends JTree { } /** - * Remove all the children nodes which are not MBean. + * Returns true if any of the children nodes is an MBean metadata node. */ - private void removeNonMBeanChildren(DefaultMutableTreeNode node) { + public boolean hasMetadataNodes(DefaultMutableTreeNode node) { + for (Enumeration e = node.children(); e.hasMoreElements();) { + DefaultMutableTreeNode n = (DefaultMutableTreeNode) e.nextElement(); + Object uo = n.getUserObject(); + if (uo instanceof XNodeInfo) { + switch (((XNodeInfo) uo).getType()) { + case ATTRIBUTES: + case NOTIFICATIONS: + case OPERATIONS: + return true; + default: + break; + } + } else { + return false; + } + } + return false; + } + + /** + * Returns true if the given node is an MBean metadata node. + */ + public boolean isMetadataNode(DefaultMutableTreeNode node) { + Object uo = node.getUserObject(); + if (uo instanceof XNodeInfo) { + switch (((XNodeInfo) uo).getType()) { + case ATTRIBUTES: + case NOTIFICATIONS: + case OPERATIONS: + return true; + default: + return false; + } + } else { + return false; + } + } + + /** + * Remove the metadata nodes associated with a given MBean node. + */ + // Call on EDT + private void removeMetadataNodes(DefaultMutableTreeNode node) { Set metadataNodes = new HashSet(); DefaultTreeModel model = (DefaultTreeModel) getModel(); - for (Enumeration e = node.children(); e.hasMoreElements(); ) { + for (Enumeration e = node.children(); e.hasMoreElements();) { DefaultMutableTreeNode n = (DefaultMutableTreeNode) e.nextElement(); - if (!((XNodeInfo) n.getUserObject()).getType().equals(Type.MBEAN)) { - metadataNodes.add(n); + Object uo = n.getUserObject(); + if (uo instanceof XNodeInfo) { + switch (((XNodeInfo) uo).getType()) { + case ATTRIBUTES: + case NOTIFICATIONS: + case OPERATIONS: + metadataNodes.add(n); + break; + default: + break; + } } } for (DefaultMutableTreeNode n : metadataNodes) { @@ -228,7 +275,8 @@ public class XTree extends JTree { * Removes only the parent nodes which are non MBean and leaf. * This method assumes the child nodes have been removed before. */ - private DefaultMutableTreeNode delParentFromView( + // Call on EDT + private DefaultMutableTreeNode removeParentFromView( Dn dn, int index, DefaultMutableTreeNode node) { if ((!node.isRoot()) && node.isLeaf() && (!(((XNodeInfo) node.getUserObject()).getType().equals(Type.MBEAN)))) { @@ -237,115 +285,100 @@ public class XTree extends JTree { removeChildNode(node); String hashKey = dn.getHashKey(dn.getToken(index)); nodes.remove(hashKey); - delParentFromView(dn, index + 1, parent); + removeParentFromView(dn, index + 1, parent); } return node; } - public synchronized void addMBeanToView(final ObjectName mbean) { - final XMBean xmbean; - try { - xmbean = new XMBean(mbean, mbeansTab); - if (xmbean == null) { - return; - } - } catch (Exception e) { - // Got exception while trying to retrieve the - // given MBean from the underlying MBeanServer - // - if (JConsole.isDebug()) { - e.printStackTrace(); - } - return; + // Call on EDT + public synchronized void addMBeansToView(Set mbeans) { + Set dns = new TreeSet(); + for (ObjectName mbean : mbeans) { + Dn dn = new Dn(mbean); + dns.add(dn); } - EventQueue.invokeLater(new Runnable() { - public void run() { - synchronized (XTree.this) { - // Add the new nodes to the MBean tree from leaf to root + for (Dn dn : dns) { + ObjectName mbean = dn.getObjectName(); + XMBean xmbean = new XMBean(mbean, mbeansTab); + addMBeanToView(mbean, xmbean, dn); + } + } - Dn dn = buildDn(mbean); - if (dn.size() == 0) return; - Token token = dn.getToken(0); - DefaultMutableTreeNode node = null; - boolean nodeCreated = true; + // Call on EDT + public synchronized void addMBeanToView(ObjectName mbean) { + // Build XMBean for the given MBean + // + XMBean xmbean = new XMBean(mbean, mbeansTab); + // Build Dn for the given MBean + // + Dn dn = new Dn(mbean); + // Add the new nodes to the MBean tree from leaf to root + // + addMBeanToView(mbean, xmbean, dn); + } - // - // Add the node or replace its user object if already added - // + // Call on EDT + private synchronized void addMBeanToView( + ObjectName mbean, XMBean xmbean, Dn dn) { - String hashKey = dn.getHashKey(token); - if (nodes.containsKey(hashKey)) { - //already in the tree, means it has been created previously - //when adding another node - node = nodes.get(hashKey); - //sets the user object - final Object data = createNodeValue(xmbean, token); - final String label = data.toString(); - final XNodeInfo userObject = - new XNodeInfo(Type.MBEAN, data, label, mbean.toString()); - changeNodeValue(node, userObject); - nodeCreated = false; - } else { - //create a new node - node = createDnNode(dn, token, xmbean); - if (node != null) { - nodes.put(hashKey, node); - nodeCreated = true; - } else { - return; - } - } + DefaultMutableTreeNode childNode = null; + DefaultMutableTreeNode parentNode = null; - // - // Add (virtual) nodes without user object if necessary - // + // Add the node or replace its user object if already added + // + Token token = dn.getToken(0); + String hashKey = dn.getHashKey(token); + if (nodes.containsKey(hashKey)) { + // Found existing node previously created when adding another node + // + childNode = nodes.get(hashKey); + // Replace user object to reflect that this node is an MBean + // + Object data = createNodeValue(xmbean, token); + String label = data.toString(); + XNodeInfo userObject = + new XNodeInfo(Type.MBEAN, data, label, mbean.toString()); + changeNodeValue(childNode, userObject); + return; + } - for (int i = 1; i < dn.size(); i++) { - DefaultMutableTreeNode currentNode = null; - token = dn.getToken(i); - hashKey = dn.getHashKey(token); - if (nodes.containsKey(hashKey)) { - //node already present - if (nodeCreated) { - //previous node created, link to do - currentNode = nodes.get(hashKey); - addChildNode(currentNode, node); - return; - } else { - //both nodes already present - return; - } - } else { - //creates the node that can be a virtual one - if (token.getKeyDn().equals("domain")) { - //better match on keyDn that on Dn - currentNode = createDomainNode(dn, token); - if (currentNode != null) { - final DefaultMutableTreeNode root = - (DefaultMutableTreeNode) getModel().getRoot(); - addChildNode(root, currentNode); - } - } else { - currentNode = createSubDnNode(dn, token); - if (currentNode == null) { - //skip - continue; - } - } - nodes.put(hashKey, currentNode); - addChildNode(currentNode, node); - nodeCreated = true; - } - node = currentNode; - } + // Create new leaf node + // + childNode = createDnNode(dn, token, xmbean); + nodes.put(hashKey, childNode); + + // Add intermediate non MBean nodes + // + for (int i = 1; i < dn.getTokenCount(); i++) { + token = dn.getToken(i); + hashKey = dn.getHashKey(token); + if (nodes.containsKey(hashKey)) { + // Intermediate node already present, add new node as child + // + parentNode = nodes.get(hashKey); + addChildNode(parentNode, childNode); + return; + } else { + // Create new intermediate node + // + if ("domain".equals(token.getTokenType())) { + parentNode = createDomainNode(dn, token); + DefaultMutableTreeNode root = + (DefaultMutableTreeNode) getModel().getRoot(); + addChildNode(root, parentNode); + } else { + parentNode = createSubDnNode(dn, token); } + nodes.put(hashKey, parentNode); + addChildNode(parentNode, childNode); } - }); + childNode = parentNode; + } } // Call on EDT private synchronized void changeNodeValue( - final DefaultMutableTreeNode node, XNodeInfo nodeValue) { + DefaultMutableTreeNode node, XNodeInfo nodeValue) { if (node instanceof ComparableDefaultMutableTreeNode) { // should it stay at the same place? DefaultMutableTreeNode clone = @@ -373,9 +406,12 @@ public class XTree extends JTree { } // Load the MBean metadata if type is MBEAN if (nodeValue.getType().equals(Type.MBEAN)) { - XMBeanInfo.loadInfo(node); - DefaultTreeModel model = (DefaultTreeModel) getModel(); - model.nodeStructureChanged(node); + removeMetadataNodes(node); + TreeNode[] treeNodes = node.getPath(); + TreePath path = new TreePath(treeNodes); + if (isExpanded(path)) { + addMetadataNodes(node); + } } // Clear the current selection and set it // again so valueChanged() gets called @@ -386,7 +422,9 @@ public class XTree extends JTree { } } - //creates the domain node, called on a domain token + /** + * Creates the domain node. + */ private DefaultMutableTreeNode createDomainNode(Dn dn, Token token) { DefaultMutableTreeNode node = new ComparableDefaultMutableTreeNode(); String label = dn.getDomain(); @@ -396,7 +434,9 @@ public class XTree extends JTree { return node; } - //creates the node corresponding to the whole Dn + /** + * Creates the node corresponding to the whole Dn, i.e. an MBean. + */ private DefaultMutableTreeNode createDnNode( Dn dn, Token token, XMBean xmbean) { DefaultMutableTreeNode node = new ComparableDefaultMutableTreeNode(); @@ -405,38 +445,36 @@ public class XTree extends JTree { XNodeInfo userObject = new XNodeInfo(Type.MBEAN, data, label, xmbean.getObjectName().toString()); node.setUserObject(userObject); - XMBeanInfo.loadInfo(node); return node; } - //creates a node with the token value, call for each non domain sub - //dn token + /** + * Creates the node corresponding to a subDn, i.e. a non-MBean + * intermediate node. + */ private DefaultMutableTreeNode createSubDnNode(Dn dn, Token token) { DefaultMutableTreeNode node = new ComparableDefaultMutableTreeNode(); - String label = isKeyValueView() ? token.toString() : - token.getValue().toString(); + String label = isKeyValueView() ? token.getTokenValue() : token.getValue(); XNodeInfo userObject = - new XNodeInfo(Type.NONMBEAN, label, label, token.toString()); + new XNodeInfo(Type.NONMBEAN, label, label, token.getTokenValue()); node.setUserObject(userObject); return node; } private Object createNodeValue(XMBean xmbean, Token token) { - String label = isKeyValueView() ? token.toString() : - token.getValue().toString(); + String label = isKeyValueView() ? token.getTokenValue() : token.getValue(); xmbean.setText(label); return xmbean; } /** - * Parses MBean ObjectName comma-separated properties string and put the - * individual key/value pairs into the map. Key order in the properties + * Parses the MBean ObjectName comma-separated properties string and puts + * the individual key/value pairs into the map. Key order in the properties * string is preserved by the map. */ - private Map extractKeyValuePairs( - String properties, ObjectName mbean) { - String props = properties; - Map map = new LinkedHashMap(); + private static Map extractKeyValuePairs( + String props, ObjectName mbean) { + Map map = new LinkedHashMap(); int eq = props.indexOf("="); while (eq != -1) { String key = props.substring(0, eq); @@ -461,9 +499,9 @@ public class XTree extends JTree { * in the comma-separated key property list does not apply to the given * MBean then it will be discarded. */ - private String getKeyPropertyListString(ObjectName mbean) { + private static String getKeyPropertyListString(ObjectName mbean) { String props = mbean.getKeyPropertyListString(); - Map map = extractKeyValuePairs(props, mbean); + Map map = extractKeyValuePairs(props, mbean); StringBuilder sb = new StringBuilder(); // Add the key/value pairs to the buffer following the // key order defined by the "orderedKeyPropertyList" @@ -474,7 +512,7 @@ public class XTree extends JTree { } } // Add the remaining key/value pairs to the buffer - for (Map.Entry entry : map.entrySet()) { + for (Map.Entry entry : map.entrySet()) { sb.append(entry.getKey() + "=" + entry.getValue() + ","); } String orderedKeyPropertyListString = sb.toString(); @@ -483,67 +521,158 @@ public class XTree extends JTree { return orderedKeyPropertyListString; } - /** - * Builds the Dn for the given MBean. - */ - private Dn buildDn(ObjectName mbean) { - - String domain = mbean.getDomain(); - String globalDn = getKeyPropertyListString(mbean); - - Dn dn = buildDn(domain, globalDn, mbean); - - //update the Dn tokens to add the domain - dn.updateDn(); - - //reverse the Dn (from leaf to root) - dn.reverseOrder(); - - //compute the hashDn - dn.computeHashDn(); - - return dn; + // Call on EDT + public void addMetadataNodes(DefaultMutableTreeNode node) { + XMBean mbean = (XMBean) ((XNodeInfo) node.getUserObject()).getData(); + DefaultTreeModel model = (DefaultTreeModel) getModel(); + MBeanInfoNodesSwingWorker sw = + new MBeanInfoNodesSwingWorker(model, node, mbean); + if (sw != null) { + sw.execute(); + } } - /** - * Builds the Dn for the given MBean. - */ - private Dn buildDn(String domain, String globalDn, ObjectName mbean) { - Dn dn = new Dn(domain, globalDn); - String keyDn = "no_key"; - if (isTreeView()) { - String props = globalDn; - Map map = extractKeyValuePairs(props, mbean); - for (Map.Entry entry : map.entrySet()) { - dn.addToken(new Token(keyDn, - entry.getKey() + "=" + entry.getValue())); + private static class MBeanInfoNodesSwingWorker + extends SwingWorker { + + private final DefaultTreeModel model; + private final DefaultMutableTreeNode node; + private final XMBean mbean; + + public MBeanInfoNodesSwingWorker( + DefaultTreeModel model, + DefaultMutableTreeNode node, + XMBean mbean) { + this.model = model; + this.node = node; + this.mbean = mbean; + } + + @Override + public Object[] doInBackground() throws InstanceNotFoundException, + IntrospectionException, ReflectionException, IOException { + Object result[] = new Object[2]; + // Retrieve MBeanInfo for this MBean + result[0] = mbean.getMBeanInfo(); + // Check if this MBean is a notification emitter + result[1] = mbean.isBroadcaster(); + return result; + } + + @Override + protected void done() { + try { + Object result[] = get(); + MBeanInfo mbeanInfo = (MBeanInfo) result[0]; + Boolean isBroadcaster = (Boolean) result[1]; + if (mbeanInfo != null) { + addMBeanInfoNodes(model, node, mbean, mbeanInfo, isBroadcaster); + } + } catch (Exception e) { + Throwable t = Utils.getActualException(e); + if (JConsole.isDebug()) { + t.printStackTrace(); + } } - } else { - //flat view - dn.addToken(new Token(keyDn, "properties=" + globalDn)); } - return dn; - } - // - //utility objects - // + // Call on EDT + private void addMBeanInfoNodes( + DefaultTreeModel tree, DefaultMutableTreeNode node, + XMBean mbean, MBeanInfo mbeanInfo, Boolean isBroadcaster) { + MBeanAttributeInfo[] ai = mbeanInfo.getAttributes(); + MBeanOperationInfo[] oi = mbeanInfo.getOperations(); + MBeanNotificationInfo[] ni = mbeanInfo.getNotifications(); - public static class ComparableDefaultMutableTreeNode - extends DefaultMutableTreeNode - implements Comparable { - public int compareTo(DefaultMutableTreeNode node) { - return (this.toString().compareTo(node.toString())); + // Insert the Attributes/Operations/Notifications metadata nodes as + // the three first children of this MBean node. This is only useful + // when this MBean node denotes an MBean but it's not a leaf in the + // MBean tree + // + int childIndex = 0; + + // MBeanAttributeInfo node + // + if (ai != null && ai.length > 0) { + DefaultMutableTreeNode attributes = new DefaultMutableTreeNode(); + XNodeInfo attributesUO = new XNodeInfo(Type.ATTRIBUTES, mbean, + Resources.getText("Attributes"), null); + attributes.setUserObject(attributesUO); + node.insert(attributes, childIndex++); + for (MBeanAttributeInfo mbai : ai) { + DefaultMutableTreeNode attribute = new DefaultMutableTreeNode(); + XNodeInfo attributeUO = new XNodeInfo(Type.ATTRIBUTE, + new Object[]{mbean, mbai}, mbai.getName(), null); + attribute.setUserObject(attributeUO); + attribute.setAllowsChildren(false); + attributes.add(attribute); + } + } + // MBeanOperationInfo node + // + if (oi != null && oi.length > 0) { + DefaultMutableTreeNode operations = new DefaultMutableTreeNode(); + XNodeInfo operationsUO = new XNodeInfo(Type.OPERATIONS, mbean, + Resources.getText("Operations"), null); + operations.setUserObject(operationsUO); + node.insert(operations, childIndex++); + for (MBeanOperationInfo mboi : oi) { + // Compute the operation's tool tip text: + // "operationname(param1type,param2type,...)" + // + StringBuilder sb = new StringBuilder(); + for (MBeanParameterInfo mbpi : mboi.getSignature()) { + sb.append(mbpi.getType() + ","); + } + String signature = sb.toString(); + if (signature.length() > 0) { + // Remove the trailing ',' + // + signature = signature.substring(0, signature.length() - 1); + } + String toolTipText = mboi.getName() + "(" + signature + ")"; + // Create operation node + // + DefaultMutableTreeNode operation = new DefaultMutableTreeNode(); + XNodeInfo operationUO = new XNodeInfo(Type.OPERATION, + new Object[]{mbean, mboi}, mboi.getName(), toolTipText); + operation.setUserObject(operationUO); + operation.setAllowsChildren(false); + operations.add(operation); + } + } + // MBeanNotificationInfo node + // + if (isBroadcaster != null && isBroadcaster.booleanValue()) { + DefaultMutableTreeNode notifications = new DefaultMutableTreeNode(); + XNodeInfo notificationsUO = new XNodeInfo(Type.NOTIFICATIONS, mbean, + Resources.getText("Notifications"), null); + notifications.setUserObject(notificationsUO); + node.insert(notifications, childIndex++); + if (ni != null && ni.length > 0) { + for (MBeanNotificationInfo mbni : ni) { + DefaultMutableTreeNode notification = + new DefaultMutableTreeNode(); + XNodeInfo notificationUO = new XNodeInfo(Type.NOTIFICATION, + mbni, mbni.getName(), null); + notification.setUserObject(notificationUO); + notification.setAllowsChildren(false); + notifications.add(notification); + } + } + } + // Update tree model + // + model.reload(node); } } - // - //tree preferences + // Tree preferences // + private static boolean treeView; + private static boolean treeViewInit = false; - private boolean treeView; - private boolean treeViewInit = false; - public boolean isTreeView() { + private static boolean isTreeView() { if (!treeViewInit) { treeView = getTreeViewValue(); treeViewInit = true; @@ -551,170 +680,136 @@ public class XTree extends JTree { return treeView; } - private boolean getTreeViewValue() { - String treeView = System.getProperty("treeView"); - return ((treeView == null) ? true : !(treeView.equals("false"))); + private static boolean getTreeViewValue() { + String tv = System.getProperty("treeView"); + return ((tv == null) ? true : !(tv.equals("false"))); } - // - //MBean key-value preferences + // MBean key-value preferences // - private boolean keyValueView = Boolean.getBoolean("keyValueView"); - public boolean isKeyValueView() { + + private boolean isKeyValueView() { return keyValueView; } // - //utility classes + // Utility classes // + private static class ComparableDefaultMutableTreeNode + extends DefaultMutableTreeNode + implements Comparable { + + public int compareTo(DefaultMutableTreeNode node) { + return (this.toString().compareTo(node.toString())); + } + } - public static class Dn { + private static class Dn implements Comparable { + private ObjectName mbean; private String domain; - private String dn; + private String keyPropertyList; private String hashDn; - private ArrayList tokens = new ArrayList(); + private List tokens = new ArrayList(); + + public Dn(ObjectName mbean) { + this.mbean = mbean; + this.domain = mbean.getDomain(); + this.keyPropertyList = getKeyPropertyListString(mbean); + + if (isTreeView()) { + // Tree view + Map map = + extractKeyValuePairs(keyPropertyList, mbean); + for (Map.Entry entry : map.entrySet()) { + tokens.add(new Token("key", entry.getKey() + "=" + entry.getValue())); + } + } else { + // Flat view + tokens.add(new Token("key", "properties=" + keyPropertyList)); + } - public Dn(String domain, String dn) { - this.domain = domain; - this.dn = dn; - } + // Add the domain as the first token in the Dn + tokens.add(0, new Token("domain", "domain=" + domain)); - public void clearTokens() { - tokens.clear(); - } + // Reverse the Dn (from leaf to root) + Collections.reverse(tokens); - public void addToken(Token token) { - tokens.add(token); + // Compute hash for Dn + computeHashDn(); } - public void addToken(int index, Token token) { - tokens.add(index, token); + public ObjectName getObjectName() { + return mbean; } - public void setToken(int index, Token token) { - tokens.set(index, token); + public String getDomain() { + return domain; } - public void removeToken(int index) { - tokens.remove(index); + public String getKeyPropertyList() { + return keyPropertyList; } public Token getToken(int index) { return tokens.get(index); } - public void reverseOrder() { - ArrayList newOrder = new ArrayList(tokens.size()); - for (int i = tokens.size() - 1; i >= 0; i--) { - newOrder.add(tokens.get(i)); - } - tokens = newOrder; - } - - public int size() { + public int getTokenCount() { return tokens.size(); } - public String getDomain() { - return domain; - } - - public String getDn() { - return dn; - } - public String getHashDn() { return hashDn; } public String getHashKey(Token token) { - final int begin = getHashDn().indexOf(token.getHashToken()); - return getHashDn().substring(begin, getHashDn().length()); - } - - public void computeHashDn() { - final StringBuilder hashDn = new StringBuilder(); - final int tokensSize = tokens.size(); - for (int i = 0; i < tokensSize; i++) { - Token token = tokens.get(i); - String hashToken = token.getHashToken(); - if (hashToken == null) { - hashToken = token.getToken() + (tokensSize - i); - token.setHashToken(hashToken); - } - hashDn.append(hashToken); - hashDn.append(","); + final int begin = hashDn.indexOf(token.getTokenValue()); + return hashDn.substring(begin, hashDn.length()); + } + + private void computeHashDn() { + if (tokens.isEmpty()) { + return; } - if (tokensSize > 0) { - this.hashDn = hashDn.substring(0, hashDn.length() - 1); - } else { - this.hashDn = ""; + final StringBuilder hdn = new StringBuilder(); + for (int i = 0; i < tokens.size(); i++) { + hdn.append(tokens.get(i).getTokenValue()); + hdn.append(","); } + hashDn = hdn.substring(0, hdn.length() - 1); } - /** - * Adds the domain as the first token in the Dn. - */ - public void updateDn() { - addToken(0, new Token("domain", "domain=" + getDomain())); + @Override + public String toString() { + return domain + ":" + keyPropertyList; } - public String toString() { - return tokens.toString(); + public int compareTo(Dn dn) { + return this.toString().compareTo(dn.toString()); } } - public static class Token { + private static class Token { - private String keyDn; - private String token; - private String hashToken; + private String tokenType; + private String tokenValue; private String key; private String value; - public Token(String keyDn, String token) { - this.keyDn = keyDn; - this.token = token; - buildKeyValue(); - } - - public Token(String keyDn, String token, String hashToken) { - this.keyDn = keyDn; - this.token = token; - this.hashToken = hashToken; + public Token(String tokenType, String tokenValue) { + this.tokenType = tokenType; + this.tokenValue = tokenValue; buildKeyValue(); } - public String getKeyDn() { - return keyDn; - } - - public String getToken() { - return token; - } - - public void setValue(String value) { - this.value = value; - this.token = key + "=" + value; - } - - public void setKey(String key) { - this.key = key; - this.token = key + "=" + value; + public String getTokenType() { + return tokenType; } - public void setKeyDn(String keyDn) { - this.keyDn = keyDn; - } - - public void setHashToken(String hashToken) { - this.hashToken = hashToken; - } - - public String getHashToken() { - return hashToken; + public String getTokenValue() { + return tokenValue; } public String getKey() { @@ -725,26 +820,14 @@ public class XTree extends JTree { return value; } - public String toString(){ - return getToken(); - } - - public boolean equals(Object object) { - if (object instanceof Token) { - return token.equals(((Token) object)); - } else { - return false; - } - } - private void buildKeyValue() { - int index = token.indexOf("="); + int index = tokenValue.indexOf("="); if (index < 0) { - key = token; - value = token; + key = tokenValue; + value = tokenValue; } else { - key = token.substring(0, index); - value = token.substring(index + 1, token.length()); + key = tokenValue.substring(0, index); + value = tokenValue.substring(index + 1, tokenValue.length()); } } } diff --git a/src/share/classes/sun/tools/native2ascii/N2AFilter.java b/src/share/classes/sun/tools/native2ascii/N2AFilter.java index 0a5706e061c7a585de5bc2fe9c1c9d6750790f95..82c807d2e1b0f8351658f432d6bf20eedf415ba5 100644 --- a/src/share/classes/sun/tools/native2ascii/N2AFilter.java +++ b/src/share/classes/sun/tools/native2ascii/N2AFilter.java @@ -42,7 +42,7 @@ class N2AFilter extends FilterWriter { public void write(char b) throws IOException { char[] buf = new char[1]; - buf[0] = (char)b; + buf[0] = b; write(buf, 0, 1); } diff --git a/src/share/classes/sun/tracing/MultiplexProviderFactory.java b/src/share/classes/sun/tracing/MultiplexProviderFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..1caf7a64257ca3a82a4c4c88f07d8f33fcfa355c --- /dev/null +++ b/src/share/classes/sun/tracing/MultiplexProviderFactory.java @@ -0,0 +1,124 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package sun.tracing; + +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Logger; + +import com.sun.tracing.ProviderFactory; +import com.sun.tracing.Provider; +import com.sun.tracing.Probe; + +/** + * Factory class to create tracing Providers. + * + * This factory creates a "multiplex provider", which is a provider that + * encapsulates a list of providers and whose probes trigger a corresponding + * trigger in each of the encapsulated providers' probes. + * + * This is used when there are multiple tracing frameworks activated at once. + * A user-defined provider gets implementation for each of the activated + * frameworks and this multiplex framework is what is ultimately passed + * back to the user. All probe triggers are multiplexed to each + * active framework. + * + * @since 1.7 + */ +public class MultiplexProviderFactory extends ProviderFactory { + + private Set factories; + + public MultiplexProviderFactory(Set factories) { + this.factories = factories; + } + + public T createProvider(Class cls) { + HashSet providers = new HashSet(); + for (ProviderFactory factory : factories) { + providers.add(factory.createProvider(cls)); + } + MultiplexProvider provider = new MultiplexProvider(cls, providers); + try { + provider.init(); + } catch (Exception e) { + // Probably a permission problem (can't get declared members) + Logger.getAnonymousLogger().warning( + "Could not initialize tracing provider: " + e.getMessage()); + } + return provider.newProxyInstance(); + } +} + +class MultiplexProvider extends ProviderSkeleton { + + private Set providers; + + protected ProbeSkeleton createProbe(Method m) { + return new MultiplexProbe(m, providers); + } + + MultiplexProvider(Class type, Set providers) { + super(type); + this.providers = providers; + } + + public void dispose() { + for (Provider p : providers) { + p.dispose(); + } + super.dispose(); + } +} + +class MultiplexProbe extends ProbeSkeleton { + + private Set probes; + + MultiplexProbe(Method m, Set providers) { + super(m.getParameterTypes()); + probes = new HashSet(); + for (Provider p : providers) { + Probe probe = p.getProbe(m); + if (probe != null) { + probes.add(probe); + } + } + } + + public boolean isEnabled() { + for (Probe p : probes) { + if (p.isEnabled()) { + return true; + } + } + return false; + } + + public void uncheckedTrigger(Object[] args) { + for (Probe p : probes) { + try { + // try the fast path + ProbeSkeleton ps = (ProbeSkeleton)p; + ps.uncheckedTrigger(args); + } catch (ClassCastException e) { + // Probe.trigger takes an "Object ..." varargs parameter, + // so we can't call it directly. + try { + Method m = Probe.class.getMethod( + "trigger", Class.forName("[java.lang.Object")); + m.invoke(p, args); + } catch (Exception e1) { + assert false; // This shouldn't happen + } + } + } + } +} + diff --git a/src/share/classes/sun/tracing/NullProviderFactory.java b/src/share/classes/sun/tracing/NullProviderFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..70004e45df461bc56778e949a92dbd20f6bdb459 --- /dev/null +++ b/src/share/classes/sun/tracing/NullProviderFactory.java @@ -0,0 +1,71 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package sun.tracing; + +import java.lang.reflect.Method; +import java.util.logging.Logger; + +import com.sun.tracing.ProviderFactory; +import com.sun.tracing.Provider; + +/** + * Factory class to create tracing Providers. + * + * This factory will create tracing instances that do nothing. + * It is used when no tracing is desired, but Provider instances still + * must be generated so that tracing calls in the application continue to + * run. + * + * @since 1.7 + */ +public class NullProviderFactory extends ProviderFactory { + + /** + * Creates and returns a Null provider. + * + * See comments at {@code ProviderSkeleton.createProvider()} for more + * details. + * + * @return a provider whose probe trigger are no-ops. + */ + public T createProvider(Class cls) { + NullProvider provider = new NullProvider(cls); + try { + provider.init(); + } catch (Exception e) { + // Probably a permission problem (can't get declared members) + Logger.getAnonymousLogger().warning( + "Could not initialize tracing provider: " + e.getMessage()); + } + return provider.newProxyInstance(); + } +} + +class NullProvider extends ProviderSkeleton { + + NullProvider(Class type) { + super(type); + } + + protected ProbeSkeleton createProbe(Method m) { + return new NullProbe(m.getParameterTypes()); + } +} + +class NullProbe extends ProbeSkeleton { + + public NullProbe(Class[] parameters) { + super(parameters); + } + + public boolean isEnabled() { + return false; + } + + public void uncheckedTrigger(Object[] args) { + } +} + diff --git a/src/share/classes/sun/tracing/PrintStreamProviderFactory.java b/src/share/classes/sun/tracing/PrintStreamProviderFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..a5c25338567191b4be1cf3311588376751456a60 --- /dev/null +++ b/src/share/classes/sun/tracing/PrintStreamProviderFactory.java @@ -0,0 +1,107 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package sun.tracing; + +import java.lang.reflect.Method; +import java.io.PrintStream; +import java.util.HashMap; +import java.util.logging.Logger; + +import com.sun.tracing.ProviderFactory; +import com.sun.tracing.Provider; +import com.sun.tracing.ProviderName; +import com.sun.tracing.Probe; +import com.sun.tracing.ProbeName; + +/** + * Factory class to create tracing Providers. + * + * This factory will create tracing instances that print to a PrintStream + * when activated. + * + * @since 1.7 + */ +public class PrintStreamProviderFactory extends ProviderFactory { + + private PrintStream stream; + + public PrintStreamProviderFactory(PrintStream stream) { + this.stream = stream; + } + + public T createProvider(Class cls) { + PrintStreamProvider provider = new PrintStreamProvider(cls, stream); + try { + provider.init(); + } catch (Exception e) { + // Probably a permission problem (can't get declared members) + Logger.getAnonymousLogger().warning( + "Could not initialize tracing provider: " + e.getMessage()); + } + return provider.newProxyInstance(); + } +} + +class PrintStreamProvider extends ProviderSkeleton { + + private PrintStream stream; + private String providerName; + + protected ProbeSkeleton createProbe(Method m) { + String probeName = getAnnotationString(m, ProbeName.class, m.getName()); + return new PrintStreamProbe(this, probeName, m.getParameterTypes()); + } + + PrintStreamProvider(Class type, PrintStream stream) { + super(type); + this.stream = stream; + this.providerName = getProviderName(); + } + + PrintStream getStream() { + return stream; + } + + String getName() { + return providerName; + } +} + +class PrintStreamProbe extends ProbeSkeleton { + + private PrintStreamProvider provider; + private String name; + + PrintStreamProbe(PrintStreamProvider p, String name, Class[] params) { + super(params); + this.provider = p; + this.name = name; + } + + public boolean isEnabled() { + return true; + } + + public void uncheckedTrigger(Object[] args) { + StringBuffer sb = new StringBuffer(); + sb.append(provider.getName()); + sb.append("."); + sb.append(name); + sb.append("("); + boolean first = true; + for (Object o : args) { + if (first == false) { + sb.append(","); + } else { + first = false; + } + sb.append(o.toString()); + } + sb.append(")"); + provider.getStream().println(sb.toString()); + } +} + diff --git a/src/share/classes/sun/tracing/ProbeSkeleton.java b/src/share/classes/sun/tracing/ProbeSkeleton.java new file mode 100644 index 0000000000000000000000000000000000000000..17028f77d52e30ea634505a338a74463b8c16d87 --- /dev/null +++ b/src/share/classes/sun/tracing/ProbeSkeleton.java @@ -0,0 +1,70 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package sun.tracing; + +import java.lang.reflect.Method; +import java.lang.reflect.Field; +import com.sun.tracing.Probe; + +/** + * Provides common code for implementation of {@code Probe} classes. + * + * @since 1.7 + */ +public abstract class ProbeSkeleton implements Probe { + + protected Class[] parameters; + + protected ProbeSkeleton(Class[] parameters) { + this.parameters = parameters; + } + + public abstract boolean isEnabled(); // framework-dependent + + /** + * Triggers the probe with verified arguments. + * + * The caller of this method must have already determined that the + * arity and types of the arguments match what the probe was + * declared with. + */ + public abstract void uncheckedTrigger(Object[] args); // framework-dependent + + private static boolean isAssignable(Object o, Class formal) { + if (o != null) { + if ( !formal.isInstance(o) ) { + if ( formal.isPrimitive() ) { // o might be a boxed primitive + try { + // Yuck. There must be a better way of doing this + Field f = o.getClass().getField("TYPE"); + return formal.isAssignableFrom((Class)f.get(null)); + } catch (Exception e) { + /* fall-through. */ + } + } + return false; + } + } + return true; + } + + /** + * Performs a type-check of the parameters before triggering the probe. + */ + public void trigger(Object ... args) { + if (args.length != parameters.length) { + throw new IllegalArgumentException("Wrong number of arguments"); + } else { + for (int i = 0; i < parameters.length; ++i) { + if ( !isAssignable(args[i], parameters[i]) ) { + throw new IllegalArgumentException( + "Wrong type of argument at position " + i); + } + } + uncheckedTrigger(args); + } + } +} diff --git a/src/share/classes/sun/tracing/ProviderSkeleton.java b/src/share/classes/sun/tracing/ProviderSkeleton.java new file mode 100644 index 0000000000000000000000000000000000000000..5343f092137915f03bbdf9ca3079adaf0b7945e6 --- /dev/null +++ b/src/share/classes/sun/tracing/ProviderSkeleton.java @@ -0,0 +1,223 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package sun.tracing; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.AnnotatedElement; +import java.lang.annotation.Annotation; +import java.util.HashMap; + +import com.sun.tracing.Provider; +import com.sun.tracing.Probe; +import com.sun.tracing.ProviderName; + +/** + * Provides a common code for implementation of {@code Provider} classes. + * + * Each tracing subsystem needs to provide three classes, a factory + * (derived from {@code ProviderFactory}, a provider (a subclass of + * {@code Provider}, and a probe type (subclass of {@code ProbeSkeleton}). + * + * The factory object takes a user-defined interface and provides an + * implementation of it whose method calls will trigger probes in the + * tracing framework. + * + * The framework's provider class, and its instances, are not seen by the + * user at all -- they usually sit in the background and receive and dispatch + * the calls to the user's provider interface. The {@code ProviderSkeleton} + * class provides almost all of the implementation needed by a framework + * provider. Framework providers must only provide a constructor and + * disposal method, and implement the {@code createProbe} method to create + * an appropriate {@code ProbeSkeleton} subclass. + * + * The framework's probe class provides the implementation of the two + * probe methods, {@code isEnabled()} and {@code uncheckedTrigger()}. Both are + * framework-dependent implementations. + * + * @since 1.7 + */ + +public abstract class ProviderSkeleton implements InvocationHandler, Provider { + + protected boolean active; // set to false after dispose() is called + protected Class providerType; // user's interface + protected HashMap probes; // methods to probes + + + /** + * Creates a framework-specific probe subtype. + * + * This method is implemented by the framework's provider and returns + * framework-specific probes for a method. + * + * @param method A method in the user's interface + * @return a subclass of ProbeSkeleton for the particular framework. + */ + protected abstract ProbeSkeleton createProbe(Method method); + + /** + * Initializes the provider. + * + * @param type the user's interface + */ + protected ProviderSkeleton(Class type) { + this.active = false; // in case of some error during initialization + this.providerType = type; + this.probes = new HashMap(); + } + + /** + * Post-constructor initialization routine. + * + * Subclass instances must be initialized before they can create probes. + * It is up to the factory implementations to call this after construction. + */ + public void init() { + for (Method m : providerType.getDeclaredMethods()) { + if ( m.getReturnType() != Void.TYPE ) { + throw new IllegalArgumentException( + "Return value of method is not void"); + } else { + probes.put(m, createProbe(m)); + } + } + this.active = true; + } + + /** + * Magic routine which creates an implementation of the user's interface. + * + * This method creates the instance of the user's interface which is + * passed back to the user. Every call upon that interface will be + * redirected to the {@code invoke()} method of this class (until + * overridden by the VM). + * + * @return an implementation of the user's interface + */ + @SuppressWarnings("unchecked") + public T newProxyInstance() { + return (T)Proxy.newProxyInstance(providerType.getClassLoader(), + new Class[] { providerType }, this); + } + + /** + * Triggers a framework probe when a user interface method is called. + * + * This method dispatches a user interface method call to the appropriate + * probe associated with this framework. + * + * If the invoked method is not a user-defined member of the interface, + * then it is a member of {@code Provider} or {@code Object} and we + * invoke the method directly. + * + * @param proxy the instance whose method was invoked + * @param method the method that was called + * @param args the arguments passed in the call. + * @return always null, if the method is a user-defined probe + */ + public Object invoke(Object proxy, Method method, Object[] args) { + if (method.getDeclaringClass() != providerType) { + try { + return method.invoke(this, args); + } catch (IllegalAccessException e) { + assert false; + } catch (InvocationTargetException e) { + assert false; + } + } else if (active) { + ProbeSkeleton p = probes.get(method); + if (p != null) { + // Skips argument check -- already done by javac + p.uncheckedTrigger(args); + } + } + return null; + } + + /** + * Direct accessor for {@code Probe} objects. + * + * @param m the method corresponding to a probe + * @return the method associated probe object, or null + */ + public Probe getProbe(Method m) { + return active ? probes.get(m) : null; + } + + /** + * Default provider disposal method. + * + * This is overridden in subclasses as needed. + */ + public void dispose() { + active = false; + probes.clear(); + } + + /** + * Gets the user-specified provider name for the user's interface. + * + * If the user's interface has a {@ProviderName} annotation, that value + * is used. Otherwise we use the simple name of the user interface's class. + * @return the provider name + */ + protected String getProviderName() { + return getAnnotationString( + providerType, ProviderName.class, providerType.getSimpleName()); + } + + /** + * Utility method for getting a string value from an annotation. + * + * Used for getting a string value from an annotation with a 'value' method. + * + * @param element the element that was annotated, either a class or method + * @param annotation the class of the annotation we're interested in + * @param defaultValue the value to return if the annotation doesn't + * exist, doesn't have a "value", or the value is empty. + */ + protected static String getAnnotationString( + AnnotatedElement element, Class annotation, + String defaultValue) { + String ret = (String)getAnnotationValue( + element, annotation, "value", defaultValue); + return ret.isEmpty() ? defaultValue : ret; + } + + /** + * Utility method for calling an arbitrary method in an annotation. + * + * @param element the element that was annotated, either a class or method + * @param annotation the class of the annotation we're interested in + * @param methodName the name of the method in the annotation we wish + * to call. + * @param defaultValue the value to return if the annotation doesn't + * exist, or we couldn't invoke the method for some reason. + * @return the result of calling the annotation method, or the default. + */ + protected static Object getAnnotationValue( + AnnotatedElement element, Class annotation, + String methodName, Object defaultValue) { + Object ret = defaultValue; + try { + Method m = annotation.getMethod(methodName); + Annotation a = element.getAnnotation(annotation); + ret = m.invoke(a); + } catch (NoSuchMethodException e) { + assert false; + } catch (IllegalAccessException e) { + assert false; + } catch (InvocationTargetException e) { + assert false; + } catch (NullPointerException e) { + assert false; + } + return ret; + } +} diff --git a/src/share/classes/sun/tracing/dtrace/Activation.java b/src/share/classes/sun/tracing/dtrace/Activation.java new file mode 100644 index 0000000000000000000000000000000000000000..b102dfe7ba5dd8080031c7636cb2be3b564ed3f4 --- /dev/null +++ b/src/share/classes/sun/tracing/dtrace/Activation.java @@ -0,0 +1,87 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package sun.tracing.dtrace; + +import java.lang.ref.WeakReference; +import java.lang.ref.ReferenceQueue; +import java.security.Permission; +import java.util.HashSet; + +class Activation { + private SystemResource resource; + private int referenceCount; + + Activation(String moduleName, DTraceProvider[] providers) { + SecurityManager security = System.getSecurityManager(); + if (security != null) { + Permission perm = + new RuntimePermission("com.sun.tracing.dtrace.createProvider"); + security.checkPermission(perm); + } + referenceCount = providers.length; + for (DTraceProvider p : providers) { + p.setActivation(this); + } + resource = new SystemResource( + this, JVM.activate(moduleName, providers)); + } + + void disposeProvider(DTraceProvider p) { + if (--referenceCount == 0) { + resource.dispose(); + } + } +} + +/** + * The native resource part of an Activation. + * + * This holds the native handle. + * + * If the user loses a reference to a set of Providers without disposing them, + * and GC determines the Activation is unreachable, then the next + * activation or flush call will automatically dispose the unreachable objects + * + * The SystemResource instances are creating during activation, and + * unattached during disposal. When created, they always have a + * strong reference to them via the {@code resources} static member. Explicit + * {@code dispose} calls will unregister the native resource and remove + * references to the SystemResource object. Absent an explicit dispose, + * when their associated Activation object becomes garbage, the SystemResource + * object will be enqueued on the reference queue and disposed at the + * next call to {@code flush}. + */ +class SystemResource extends WeakReference { + + private long handle; + + private static ReferenceQueue referenceQueue = + referenceQueue = new ReferenceQueue(); + static HashSet resources = new HashSet(); + + SystemResource(Activation activation, long handle) { + super(activation, referenceQueue); + this.handle = handle; + flush(); + resources.add(this); + } + + void dispose() { + JVM.dispose(handle); + resources.remove(this); + handle = 0; + } + + static void flush() { + SystemResource resource = null; + while ((resource = (SystemResource)referenceQueue.poll()) != null) { + if (resource.handle != 0) { + resource.dispose(); + } + } + } +} + diff --git a/src/share/classes/sun/tracing/dtrace/DTraceProbe.java b/src/share/classes/sun/tracing/dtrace/DTraceProbe.java new file mode 100644 index 0000000000000000000000000000000000000000..c98fb038ae59ca4ac4d91684924d0d844a38cd69 --- /dev/null +++ b/src/share/classes/sun/tracing/dtrace/DTraceProbe.java @@ -0,0 +1,62 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package sun.tracing.dtrace; + +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; + +import sun.tracing.ProbeSkeleton; + +class DTraceProbe extends ProbeSkeleton { + private Object proxy; + private Method declared_method; + private Method implementing_method; + + DTraceProbe(Object proxy, Method m) { + super(m.getParameterTypes()); + this.proxy = proxy; + this.declared_method = m; + try { + // The JVM will override the proxy method's implementation with + // a version that will invoke the probe. + this.implementing_method = proxy.getClass().getMethod( + m.getName(), m.getParameterTypes()); + } catch (NoSuchMethodException e) { + throw new RuntimeException("Internal error, wrong proxy class"); + } + } + + public boolean isEnabled() { + return JVM.isEnabled(implementing_method); + } + + public void uncheckedTrigger(Object[] args) { + try { + implementing_method.invoke(proxy, args); + } catch (IllegalAccessException e) { + assert false; + } catch (InvocationTargetException e) { + assert false; + } + } + + String getProbeName() { + return DTraceProvider.getProbeName(declared_method); + } + + String getFunctionName() { + return DTraceProvider.getFunctionName(declared_method); + } + + Method getMethod() { + return implementing_method; + } + + Class[] getParameterTypes() { + return this.parameters; + } +} + diff --git a/src/share/classes/sun/tracing/dtrace/DTraceProvider.java b/src/share/classes/sun/tracing/dtrace/DTraceProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..4021faa25381acadefcaa8a9b52f6e6bb6290e9f --- /dev/null +++ b/src/share/classes/sun/tracing/dtrace/DTraceProvider.java @@ -0,0 +1,210 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package sun.tracing.dtrace; + +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.annotation.Annotation; +import java.util.HashMap; + +import sun.tracing.ProviderSkeleton; +import sun.tracing.ProbeSkeleton; +import com.sun.tracing.Provider; +import com.sun.tracing.ProviderName; +import com.sun.tracing.ProbeName; +import com.sun.tracing.dtrace.Attributes; +import com.sun.tracing.dtrace.ModuleName; +import com.sun.tracing.dtrace.FunctionName; +import com.sun.tracing.dtrace.StabilityLevel; +import com.sun.tracing.dtrace.DependencyClass; + +import sun.misc.ProxyGenerator; + +class DTraceProvider extends ProviderSkeleton { + + private Activation activation; + private Object proxy; + + // For proxy generation + private final static Class[] constructorParams = { InvocationHandler.class }; + private final String proxyClassNamePrefix = "$DTraceTracingProxy"; + + static final String DEFAULT_MODULE = "java_tracing"; + static final String DEFAULT_FUNCTION = "unspecified"; + + private static long nextUniqueNumber = 0; + private static synchronized long getUniqueNumber() { + return nextUniqueNumber++; + } + + protected ProbeSkeleton createProbe(Method m) { + return new DTraceProbe(proxy, m); + } + + DTraceProvider(Class type) { + super(type); + } + + void setProxy(Object p) { + proxy = p; + } + + void setActivation(Activation a) { + this.activation = a; + } + + public void dispose() { + if (activation != null) { + activation.disposeProvider(this); + activation = null; + } + super.dispose(); + } + + /** + * Magic routine which creates an implementation of the user's interface. + * + * This method uses the ProxyGenerator directly to bypass the + * java.lang.reflect.proxy cache so that we get a unique class each + * time it's called and can't accidently reuse a $Proxy class. + * + * @return an implementation of the user's interface + */ + @SuppressWarnings("unchecked") + public T newProxyInstance() { + /* + * Choose a name for the proxy class to generate. + */ + long num = getUniqueNumber(); + + String proxyPkg = ""; + if (!Modifier.isPublic(providerType.getModifiers())) { + String name = providerType.getName(); + int n = name.lastIndexOf('.'); + proxyPkg = ((n == -1) ? "" : name.substring(0, n + 1)); + } + + String proxyName = proxyPkg + proxyClassNamePrefix + num; + + /* + * Generate the specified proxy class. + */ + Class proxyClass = null; + byte[] proxyClassFile = ProxyGenerator.generateProxyClass( + proxyName, new Class[] { providerType }); + try { + proxyClass = JVM.defineClass( + providerType.getClassLoader(), proxyName, + proxyClassFile, 0, proxyClassFile.length); + } catch (ClassFormatError e) { + /* + * A ClassFormatError here means that (barring bugs in the + * proxy class generation code) there was some other + * invalid aspect of the arguments supplied to the proxy + * class creation (such as virtual machine limitations + * exceeded). + */ + throw new IllegalArgumentException(e.toString()); + } + + /* + * Invoke its constructor with the designated invocation handler. + */ + try { + Constructor cons = proxyClass.getConstructor(constructorParams); + return (T)cons.newInstance(new Object[] { this }); + } catch (NoSuchMethodException e) { + throw new InternalError(e.toString()); + } catch (IllegalAccessException e) { + throw new InternalError(e.toString()); + } catch (InstantiationException e) { + throw new InternalError(e.toString()); + } catch (InvocationTargetException e) { + throw new InternalError(e.toString()); + } + } + + // In the normal case, the proxy object's method implementations will call + // this method (it usually calls the ProviderSkeleton's version). That + // method uses the passed 'method' object to lookup the associated + // 'ProbeSkeleton' and calls uncheckedTrigger() on that probe to cause the + // probe to fire. DTrace probes are different in that the proxy class's + // methods are immediately overridden with native code to fire the probe + // directly. So this method should never get invoked. We also wire up the + // DTraceProbe.uncheckedTrigger() method to call the proxy method instead + // of doing the work itself. + public Object invoke(Object proxy, Method method, Object[] args) { + if (method.getDeclaringClass() != providerType) { + try { + return method.invoke(this, args); + } catch (IllegalAccessException e) { + assert false; + } catch (InvocationTargetException e) { + assert false; + } + } else if (active) { + assert false : "This method should have been overridden by the JVM"; + } + return null; + } + + public String getProviderName() { + return super.getProviderName(); + } + + String getModuleName() { + return getAnnotationString( + providerType, ModuleName.class, DEFAULT_MODULE); + } + + static String getProbeName(Method method) { + return getAnnotationString( + method, ProbeName.class, method.getName()); + } + + static String getFunctionName(Method method) { + return getAnnotationString( + method, FunctionName.class, DEFAULT_FUNCTION); + } + + DTraceProbe[] getProbes() { + return probes.values().toArray(new DTraceProbe[0]); + } + + StabilityLevel getNameStabilityFor(Class type) { + Attributes attrs = (Attributes)getAnnotationValue( + providerType, type, "value", null); + if (attrs == null) { + return StabilityLevel.PRIVATE; + } else { + return attrs.name(); + } + } + + StabilityLevel getDataStabilityFor(Class type) { + Attributes attrs = (Attributes)getAnnotationValue( + providerType, type, "value", null); + if (attrs == null) { + return StabilityLevel.PRIVATE; + } else { + return attrs.data(); + } + } + + DependencyClass getDependencyClassFor(Class type) { + Attributes attrs = (Attributes)getAnnotationValue( + providerType, type, "value", null); + if (attrs == null) { + return DependencyClass.UNKNOWN; + } else { + return attrs.dependency(); + } + } +} diff --git a/src/share/classes/sun/tracing/dtrace/DTraceProviderFactory.java b/src/share/classes/sun/tracing/dtrace/DTraceProviderFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..a89dd7ae0ab5bbb07e1ad3f9b52f6f1364657442 --- /dev/null +++ b/src/share/classes/sun/tracing/dtrace/DTraceProviderFactory.java @@ -0,0 +1,144 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package sun.tracing.dtrace; + +import java.util.Map; +import java.util.Set; +import java.util.HashMap; +import java.util.HashSet; +import java.util.logging.Logger; +import java.security.Permission; + +import com.sun.tracing.ProviderFactory; +import com.sun.tracing.Provider; + +/** + * Factory class to create JSDT Providers. + * + * This class contains methods to create an instance of a Provider + * interface which can be used to place tracepoints in an application. + * Method calls upon that instance trigger DTrace probes that + * are visible from DTrace scripts. Such calls have no other + * side effects in the application. + *

        + * The DTrace script mechanisms for listing and matching probes will not see + * nor match any probes until the provider they reside in is created by a + * call to {@code createProvider()} (or {@code createProviders()}). + *

        + * Providers that are created should be disposed of when they are no longer + * needed to free up system resources, at which point the associated + * DTrace probes will no longer be available to DTrace. One disposes a + * provider by calling + * {@link com.sun.tracing.Provider#dispose Provider.dispose()} on a + * created provider instance. + * + * @since 1.7 + */ +public final class DTraceProviderFactory extends ProviderFactory { + /** + * Creates an instance of a provider which can then be used to trigger + * DTrace probes. + * + * The provider specification, provided as an argument, should only + * contain methods which have a 'void' return type and String or + * integer-based typed arguments (long, int, short, char, byte, or boolean). + * + * @param cls A user-defined interface which extends {@code Provider}. + * @return An instance of the interface which is used to trigger + * the DTrace probes. + * @throws java.lang.SecurityException if a security manager has been + * installed and it denies + * RuntimePermission("com.sun.dtrace.jsdt.createProvider") + * @throws java.lang.IllegalArgumentException if the interface contains + * methods that do not return null, or that contain arguments that are + * not String or integer types. + */ + public T createProvider(Class cls) { + DTraceProvider jsdt = new DTraceProvider(cls); + T proxy = jsdt.newProxyInstance(); + jsdt.setProxy(proxy); + try { + jsdt.init(); + new Activation(jsdt.getModuleName(), new DTraceProvider[] { jsdt }); + } catch (Exception e) { + // Probably a permission problem (can't get declared members) + Logger.getAnonymousLogger().warning( + "Could not initialize tracing provider: " + e.getMessage()); + jsdt.dispose(); + } + return proxy; + } + + /** + * Creates multiple providers at once. + * + * This method batches together a number of provider instantiations. + * It works similarly + * to {@code createProvider}, but operates on a set of providers instead + * of one at a time. This method is in place since some DTrace + * implementations limit the number of times that providers can be + * created. When numerous providers can be created at once with this + * method, it will count only as a single creation point to DTrace, thus + * it uses less system resources. + *

        + * All of the probes in the providers will be visible to DTrace after + * this call and all will remain visible until all of the providers + * are disposed. + *

        + * The {@code moduleName} parameter will override any {@code ModuleName} + * annotation associated with any of the providers in the set. + * All of the probes created by this call will share the same + * module name. + *

        + * @param providers a set of provider specification interfaces + * @param moduleName the module name to associate with all probes + * @return A map which maps the provider interface specification to an + * implementing instance. + * @throws java.lang.SecurityException if a security manager has been + * installed and it denies + * RuntimePermission("com.sun.dtrace.jsdt.createProvider") + * @throws java.lang.IllegalArgumentException if any of the interface + * contains methods that do not return null, or that contain arguments + * that are not String or integer types. + */ + public Map,Provider> createProviders( + Set> providers, String moduleName) { + HashMap,Provider> map = + new HashMap,Provider>(); + HashSet jsdts = new HashSet(); + for (Class cls : providers) { + DTraceProvider jsdt = new DTraceProvider(cls); + jsdts.add(jsdt); + map.put(cls, jsdt.newProxyInstance()); + } + new Activation(moduleName, jsdts.toArray(new DTraceProvider[0])); + return map; + } + + /** + * Used to check the status of DTrace support in the underlying JVM and + * operating system. + * + * This is an informative method only - the Java-level effects of + * creating providers and triggering probes will not change whether or + * not DTrace is supported by the underlying systems. + * + * @return true if DTrace is supported + */ + public static boolean isSupported() { + try { + SecurityManager security = System.getSecurityManager(); + if (security != null) { + Permission perm = new RuntimePermission( + "com.sun.tracing.dtrace.createProvider"); + security.checkPermission(perm); + } + return JVM.isSupported(); + } catch (SecurityException e) { + return false; + } + } +} diff --git a/src/share/classes/sun/tracing/dtrace/JVM.java b/src/share/classes/sun/tracing/dtrace/JVM.java new file mode 100644 index 0000000000000000000000000000000000000000..d7a96d9709cb642b2d5b86bcfed9203c3911aa3a --- /dev/null +++ b/src/share/classes/sun/tracing/dtrace/JVM.java @@ -0,0 +1,50 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package sun.tracing.dtrace; + +import java.lang.reflect.Method; + +/** + * Container class for JVM interface native methods + * + * @since 1.7 + */ +class JVM { + + static { + java.security.AccessController.doPrivileged( + new sun.security.action.LoadLibraryAction("jsdt")); + } + + static long activate(String moduleName, DTraceProvider[] providers) { + return activate0(moduleName, providers); + } + + static void dispose(long handle) { + dispose0(handle); + } + + static boolean isEnabled(Method m) { + return isEnabled0(m); + } + + static boolean isSupported() { + return isSupported0(); + } + + static Class defineClass( + ClassLoader loader, String name, byte[] b, int off, int len) { + return defineClass0(loader, name, b, off, len); + } + + private static native long activate0( + String moduleName, DTraceProvider[] providers); + private static native void dispose0(long activation_handle); + private static native boolean isEnabled0(Method m); + private static native boolean isSupported0(); + private static native Class defineClass0( + ClassLoader loader, String name, byte[] b, int off, int len); +} diff --git a/src/share/classes/sun/tracing/package-info.java b/src/share/classes/sun/tracing/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..56d45761bf487731eaa1afffdd8005a0585dbf4d --- /dev/null +++ b/src/share/classes/sun/tracing/package-info.java @@ -0,0 +1,37 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/** + * This package contains internal common code for implementing tracing + * frameworks, and defined a number of existing frameworks. + *

        + * There are four tracing frameworks currently defined. The "Null" and + * "Multiplex" frameworks are used internally as part of the implementation. + * The "DTrace" framework is the prime consumer framework at the moment, + * while the "PrintStream" framework is a functional, but hidden, framework + * which can be used to track probe firings. All but the "DTrace" framework + * are defined in this package. The "DTrace" framework is implemented in the + * {@code sun.tracing.dtrace} package. + *

        + * This package also contains the {@code ProviderSkeleton} class, which + * holds most of the common code needed for implementing frameworks. + *

        + * The "Null" framework is used when there are no other active frameworks. + * It accomplishes absolutely nothing and is merely a placeholder so that + * the application can call the tracing routines without error. + *

        + * The "Multiplex" framework is used when there are multiple active frameworks. + * It is initialized with the framework factories and create providers and + * probes that dispatch to each active framework in turn. + *

        + * The "PrintStream" framework is currently a debugging framework which + * dispatches trace calls to a user-defined PrintStream class, defined by + * a property. It may some day be opened up to general use. + *

        + * See the {@code sun.tracing.dtrace} and {@code com.sun.tracing.dtrace} + * packages for information on the "DTrace" framework. + */ + +package sun.tracing; diff --git a/src/share/demo/jfc/Notepad/resources/Notepad.properties b/src/share/demo/jfc/Notepad/resources/Notepad.properties index 9f9ec3a75319665e3fa560544a4db1f1065c608c..fdd5c5a22468817d64b832b8cf4712f7f39c139d 100644 --- a/src/share/demo/jfc/Notepad/resources/Notepad.properties +++ b/src/share/demo/jfc/Notepad/resources/Notepad.properties @@ -1,76 +1,76 @@ -# -# Resource strings for Notepad example - -Title=Notepad -ElementTreeFrameTitle=Elements -ViewportBackingStore=false - -# menubar definition -# -# Each of the strings that follow form a key to be -# used to the actual menu definition. -menubar=file edit debug - -# file Menu definition -# -# Each of the strings that follow form a key to be -# used as the basis of a menu item definition. -# -# open -> Notepad.openAction -# new -> Notepad.newAction -# save -> Notepad.saveAction -# exit -> Notepad.exitAction -file=new open save - exit -fileLabel=File -openLabel=Open -openImage=resources/open.gif -newLabel=New -newImage=resources/new.gif -saveLabel=Save -saveImage=resources/save.gif -exitLabel=Exit - -# -# edit Menu definition -# -# cut -> JTextComponent.cutAction -# copy -> JTextComponent.copyAction -# paste -> JTextComponent.pasteAction -edit=cut copy paste - undo redo -editLabel=Edit -cutLabel=Cut -cutAction=cut-to-clipboard -cutImage=resources/cut.gif -copyLabel=Copy -copyAction=copy-to-clipboard -copyImage=resources/copy.gif -pasteLabel=Paste -pasteAction=paste-from-clipboard -pasteImage=resources/paste.gif -undoLabel=Undo -undoAction=Undo -redoLabel=Redo -redoAction=Redo - -# -# debug Menu definition -# -debug=dump showElementTree -debugLabel=Debug -dumpLabel=Dump model to System.err -dumpAction=dump-model -showElementTreeLabel=Show Elements - -# toolbar definition -# -# Each of the strings that follow form a key to be -# used as the basis of the tool definition. Actions -# are of course sharable, and in this case are shared -# with the menu items. -toolbar=new open save - cut copy paste -newTooltip=Create a new file -openTooltip=Open a file -saveTooltip=Save to a file -cutTooltip=Move selection to clipboard -copyTooltip=Copy selection to clipboard -pasteTooltip=Paste clipboard to selection +# +# Resource strings for Notepad example + +Title=Notepad +ElementTreeFrameTitle=Elements +ViewportBackingStore=false + +# menubar definition +# +# Each of the strings that follow form a key to be +# used to the actual menu definition. +menubar=file edit debug + +# file Menu definition +# +# Each of the strings that follow form a key to be +# used as the basis of a menu item definition. +# +# open -> Notepad.openAction +# new -> Notepad.newAction +# save -> Notepad.saveAction +# exit -> Notepad.exitAction +file=new open save - exit +fileLabel=File +openLabel=Open +openImage=resources/open.gif +newLabel=New +newImage=resources/new.gif +saveLabel=Save +saveImage=resources/save.gif +exitLabel=Exit + +# +# edit Menu definition +# +# cut -> JTextComponent.cutAction +# copy -> JTextComponent.copyAction +# paste -> JTextComponent.pasteAction +edit=cut copy paste - undo redo +editLabel=Edit +cutLabel=Cut +cutAction=cut-to-clipboard +cutImage=resources/cut.gif +copyLabel=Copy +copyAction=copy-to-clipboard +copyImage=resources/copy.gif +pasteLabel=Paste +pasteAction=paste-from-clipboard +pasteImage=resources/paste.gif +undoLabel=Undo +undoAction=Undo +redoLabel=Redo +redoAction=Redo + +# +# debug Menu definition +# +debug=dump showElementTree +debugLabel=Debug +dumpLabel=Dump model to System.err +dumpAction=dump-model +showElementTreeLabel=Show Elements + +# toolbar definition +# +# Each of the strings that follow form a key to be +# used as the basis of the tool definition. Actions +# are of course sharable, and in this case are shared +# with the menu items. +toolbar=new open save - cut copy paste +newTooltip=Create a new file +openTooltip=Open a file +saveTooltip=Save to a file +cutTooltip=Move selection to clipboard +copyTooltip=Copy selection to clipboard +pasteTooltip=Paste clipboard to selection diff --git a/src/share/instrument/InvocationAdapter.c b/src/share/instrument/InvocationAdapter.c index 9221ab58f99cd87606b47fcee5402f9609a26f8b..a7747f12e03f0ff7a0b3da88691272154eb2b57d 100644 --- a/src/share/instrument/InvocationAdapter.c +++ b/src/share/instrument/InvocationAdapter.c @@ -626,6 +626,7 @@ appendClassPath( JPLISAgent* agent, jvmtiError jvmtierr; jvmtierr = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, jarfile); + check_phase_ret_1(jvmtierr); if (jvmtierr == JVMTI_ERROR_NONE) { return 0; @@ -634,6 +635,7 @@ appendClassPath( JPLISAgent* agent, jvmtiError err; err = (*jvmtienv)->GetPhase(jvmtienv, &phase); + /* can be called from any phase */ jplis_assert(err == JVMTI_ERROR_NONE); if (phase == JVMTI_PHASE_LIVE) { @@ -805,6 +807,8 @@ appendBootClassPath( JPLISAgent* agent, /* print warning if boot class path not updated */ if (jvmtierr != JVMTI_ERROR_NONE) { + check_phase_blob_ret(jvmtierr, free(path)); + fprintf(stderr, "WARNING: %s not added to bootstrap class loader search: ", path); switch (jvmtierr) { case JVMTI_ERROR_ILLEGAL_ARGUMENT : diff --git a/src/share/instrument/JPLISAgent.c b/src/share/instrument/JPLISAgent.c index 6deb291c9e8b7b530c6cecc4f55df5cdbfacd430..4b01c88484eeeeaebec2a79d0a205743da02410d 100644 --- a/src/share/instrument/JPLISAgent.c +++ b/src/share/instrument/JPLISAgent.c @@ -179,6 +179,7 @@ getJPLISEnvironment(jvmtiEnv * jvmtienv) { jvmtierror = (*jvmtienv)->GetEnvironmentLocalStorage( jvmtienv, (void**)&environment); + /* can be called from any phase */ jplis_assert(jvmtierror == JVMTI_ERROR_NONE); if (jvmtierror == JVMTI_ERROR_NONE) { @@ -230,6 +231,7 @@ createNewJPLISAgent(JavaVM * vm, JPLISAgent **agent_ptr) { /* don't leak envs */ if ( initerror != JPLIS_INIT_ERROR_NONE ) { jvmtiError jvmtierror = (*jvmtienv)->DisposeEnvironment(jvmtienv); + /* can be called from any phase */ jplis_assert(jvmtierror == JVMTI_ERROR_NONE); } } @@ -259,7 +261,7 @@ initializeJPLISAgent( JPLISAgent * agent, agent->mNormalEnvironment.mIsRetransformer = JNI_FALSE; agent->mRetransformEnvironment.mJVMTIEnv = NULL; /* NULL until needed */ agent->mRetransformEnvironment.mAgent = agent; - agent->mRetransformEnvironment.mIsRetransformer = JNI_TRUE; + agent->mRetransformEnvironment.mIsRetransformer = JNI_FALSE; /* JNI_FALSE until mJVMTIEnv is set */ agent->mAgentmainCaller = NULL; agent->mInstrumentationImpl = NULL; agent->mPremainCaller = NULL; @@ -277,18 +279,25 @@ initializeJPLISAgent( JPLISAgent * agent, jvmtierror = (*jvmtienv)->SetEnvironmentLocalStorage( jvmtienv, &(agent->mNormalEnvironment)); + /* can be called from any phase */ jplis_assert(jvmtierror == JVMTI_ERROR_NONE); /* check what capabilities are available */ checkCapabilities(agent); /* check phase - if live phase then we don't need the VMInit event */ - jvmtierror == (*jvmtienv)->GetPhase(jvmtienv, &phase); + jvmtierror = (*jvmtienv)->GetPhase(jvmtienv, &phase); + /* can be called from any phase */ jplis_assert(jvmtierror == JVMTI_ERROR_NONE); if (phase == JVMTI_PHASE_LIVE) { return JPLIS_INIT_ERROR_NONE; } + if (phase != JVMTI_PHASE_ONLOAD) { + /* called too early or called too late; either way bail out */ + return JPLIS_INIT_ERROR_FAILURE; + } + /* now turn on the VMInit event */ if ( jvmtierror == JVMTI_ERROR_NONE ) { jvmtiEventCallbacks callbacks; @@ -298,6 +307,7 @@ initializeJPLISAgent( JPLISAgent * agent, jvmtierror = (*jvmtienv)->SetEventCallbacks( jvmtienv, &callbacks, sizeof(callbacks)); + check_phase_ret_blob(jvmtierror, JPLIS_INIT_ERROR_FAILURE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE); } @@ -307,6 +317,7 @@ initializeJPLISAgent( JPLISAgent * agent, JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL /* all threads */); + check_phase_ret_blob(jvmtierror, JPLIS_INIT_ERROR_FAILURE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE); } @@ -622,6 +633,7 @@ setLivePhaseEventHandlers( JPLISAgent * agent) { jvmtierror = (*jvmtienv)->SetEventCallbacks( jvmtienv, &callbacks, sizeof(callbacks)); + check_phase_ret_false(jvmtierror); jplis_assert(jvmtierror == JVMTI_ERROR_NONE); @@ -632,6 +644,7 @@ setLivePhaseEventHandlers( JPLISAgent * agent) { JVMTI_DISABLE, JVMTI_EVENT_VM_INIT, NULL /* all threads */); + check_phase_ret_false(jvmtierror); jplis_assert(jvmtierror == JVMTI_ERROR_NONE); } @@ -642,6 +655,7 @@ setLivePhaseEventHandlers( JPLISAgent * agent) { JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL /* all threads */); + check_phase_ret_false(jvmtierror); jplis_assert(jvmtierror == JVMTI_ERROR_NONE); } @@ -660,6 +674,7 @@ checkCapabilities(JPLISAgent * agent) { memset(&potentialCapabilities, 0, sizeof(potentialCapabilities)); jvmtierror = (*jvmtienv)->GetPotentialCapabilities(jvmtienv, &potentialCapabilities); + check_phase_ret(jvmtierror); jplis_assert(jvmtierror == JVMTI_ERROR_NONE); if ( jvmtierror == JVMTI_ERROR_NONE ) { @@ -681,9 +696,11 @@ enableNativeMethodPrefixCapability(jvmtiEnv * jvmtienv) { jvmtiError jvmtierror; jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities); + /* can be called from any phase */ jplis_assert(jvmtierror == JVMTI_ERROR_NONE); desiredCapabilities.can_set_native_method_prefix = 1; jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities); + check_phase_ret(jvmtierror); jplis_assert(jvmtierror == JVMTI_ERROR_NONE); } @@ -715,9 +732,11 @@ addOriginalMethodOrderCapability(JPLISAgent * agent) { jvmtiError jvmtierror; jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities); + /* can be called from any phase */ jplis_assert(jvmtierror == JVMTI_ERROR_NONE); desiredCapabilities.can_maintain_original_method_order = 1; jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities); + check_phase_ret(jvmtierror); jplis_assert(jvmtierror == JVMTI_ERROR_NONE); } @@ -732,9 +751,11 @@ addRedefineClassesCapability(JPLISAgent * agent) { if (agent->mRedefineAvailable && !agent->mRedefineAdded) { jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities); + /* can be called from any phase */ jplis_assert(jvmtierror == JVMTI_ERROR_NONE); desiredCapabilities.can_redefine_classes = 1; jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities); + check_phase_ret(jvmtierror); /* * With mixed premain/agentmain agents then it's possible that the @@ -998,6 +1019,7 @@ retransformableEnvironment(JPLISAgent * agent) { if (jvmtierror == JVMTI_ERROR_NONE) { // install the retransforming environment agent->mRetransformEnvironment.mJVMTIEnv = retransformerEnv; + agent->mRetransformEnvironment.mIsRetransformer = JNI_TRUE; // Make it for ClassFileLoadHook handling jvmtierror = (*retransformerEnv)->SetEnvironmentLocalStorage( @@ -1025,6 +1047,7 @@ isModifiableClass(JNIEnv * jnienv, JPLISAgent * agent, jclass clazz) { jvmtierror = (*jvmtienv)->IsModifiableClass( jvmtienv, clazz, &is_modifiable); + check_phase_ret_false(jvmtierror); jplis_assert(jvmtierror == JVMTI_ERROR_NONE); return is_modifiable; @@ -1032,7 +1055,7 @@ isModifiableClass(JNIEnv * jnienv, JPLISAgent * agent, jclass clazz) { jboolean isRetransformClassesSupported(JNIEnv * jnienv, JPLISAgent * agent) { - return retransformableEnvironment(agent) != NULL; + return agent->mRetransformEnvironment.mIsRetransformer; } void @@ -1075,6 +1098,12 @@ retransformClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classes) { numClasses = (*jnienv)->GetArrayLength(jnienv, classes); errorOccurred = checkForThrowable(jnienv); jplis_assert(!errorOccurred); + + if (!errorOccurred && numClasses == 0) { + jplis_assert(numClasses != 0); + errorOccurred = JNI_TRUE; + errorCode = JVMTI_ERROR_NULL_POINTER; + } } if (!errorOccurred) { @@ -1096,6 +1125,13 @@ retransformClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classes) { if (errorOccurred) { break; } + + if (classArray[index] == NULL) { + jplis_assert(classArray[index] != NULL); + errorOccurred = JNI_TRUE; + errorCode = JVMTI_ERROR_NULL_POINTER; + break; + } } } @@ -1217,6 +1253,7 @@ redefineClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classDefinitio if (!errorOccurred) { jvmtiError errorCode = JVMTI_ERROR_NONE; errorCode = (*jvmtienv)->RedefineClasses(jvmtienv, numDefs, classDefs); + check_phase_blob_ret(errorCode, deallocate(jvmtienv, (void*)classDefs)); errorOccurred = (errorCode != JVMTI_ERROR_NONE); if ( errorOccurred ) { createAndThrowThrowableFromJVMTIErrorCode(jnienv, errorCode); @@ -1250,6 +1287,7 @@ commonGetClassList( JNIEnv * jnienv, classLoader, &classCount, &classes); + check_phase_ret_blob(jvmtierror, localArray); errorOccurred = (jvmtierror != JVMTI_ERROR_NONE); jplis_assert(!errorOccurred); @@ -1311,6 +1349,7 @@ getObjectSize(JNIEnv * jnienv, JPLISAgent * agent, jobject objectToSize) { jvmtiError jvmtierror = JVMTI_ERROR_NONE; jvmtierror = (*jvmtienv)->GetObjectSize(jvmtienv, objectToSize, &objectSize); + check_phase_ret_0(jvmtierror); jplis_assert(jvmtierror == JVMTI_ERROR_NONE); if ( jvmtierror != JVMTI_ERROR_NONE ) { createAndThrowThrowableFromJVMTIErrorCode(jnienv, jvmtierror); @@ -1360,6 +1399,7 @@ appendToClassLoaderSearch(JNIEnv * jnienv, JPLISAgent * agent, jstring jarFile, } else { jvmtierror = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, platformChars); } + check_phase_ret(jvmtierror); if ( jvmtierror != JVMTI_ERROR_NONE ) { createAndThrowThrowableFromJVMTIErrorCode(jnienv, jvmtierror); @@ -1450,6 +1490,7 @@ setNativeMethodPrefixes(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray prefix } err = (*jvmtienv)->SetNativeMethodPrefixes(jvmtienv, inx, (char**)prefixes); + /* can be called from any phase */ jplis_assert(err == JVMTI_ERROR_NONE); for (i = 0; i < inx; i++) { diff --git a/src/share/instrument/JPLISAgent.h b/src/share/instrument/JPLISAgent.h index 8bc1ace04b0ccd9ccf42e26b106f4d5a732caaf6..444f4a81454219ed3ac2fcf6fa14e77a3505634b 100644 --- a/src/share/instrument/JPLISAgent.h +++ b/src/share/instrument/JPLISAgent.h @@ -266,6 +266,48 @@ setNativeMethodPrefixes(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray prefix #define jvmti(a) a->mNormalEnvironment.mJVMTIEnv +/* + * A set of macros for insulating the JLI method callers from + * JVMTI_ERROR_WRONG_PHASE return codes. + */ + +/* for a JLI method where "blob" is executed before simply returning */ +#define check_phase_blob_ret(ret, blob) \ + if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \ + blob; \ + return; \ + } + +/* for a JLI method where simply returning is benign */ +#define check_phase_ret(ret) \ + if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \ + return; \ + } + +/* for a JLI method where returning zero (0) is benign */ +#define check_phase_ret_0(ret) \ + if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \ + return 0; \ + } + +/* for a JLI method where returning one (1) is benign */ +#define check_phase_ret_1(ret) \ + if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \ + return 1; \ + } + +/* for a case where a specific "blob" must be returned */ +#define check_phase_ret_blob(ret, blob) \ + if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \ + return (blob); \ + } + +/* for a JLI method where returning false is benign */ +#define check_phase_ret_false(ret) \ + if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \ + return (jboolean) 0; \ + } + #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ diff --git a/src/share/instrument/JarFacade.c b/src/share/instrument/JarFacade.c index aef9fa587970bdfd8f4a2829098b98faa8918f7f..85c5bd30b2016e2b9c1b595115a893dddca590bb 100644 --- a/src/share/instrument/JarFacade.c +++ b/src/share/instrument/JarFacade.c @@ -23,6 +23,14 @@ * have any questions. */ +#ifdef _WIN32 +/* + * Win* needs this include. However, Linux and Solaris do not. + * Having this include on Solaris SPARC breaks having non US-ASCII + * characters in the value of the Premain-Class attribute. + */ +#include +#endif /* _WIN32 */ #include #include @@ -45,11 +53,37 @@ doAttribute(const char* name, const char* value, void* user_data) { if (attribute->name == NULL) { free(attribute); } else { - attribute->value = strdup(value); + char *begin = (char *)value; + char *end; + size_t value_len; + + /* skip any leading white space */ + while (isspace(*begin)) { + begin++; + } + + /* skip any trailing white space */ + end = &begin[strlen(begin)]; + while (end > begin && isspace(end[-1])) { + end--; + } + + if (begin == end) { + /* no value so skip this attribute */ + free(attribute->name); + free(attribute); + return; + } + + value_len = (size_t)(end - begin); + attribute->value = malloc(value_len + 1); if (attribute->value == NULL) { free(attribute->name); free(attribute); } else { + /* save the value without leading or trailing whitespace */ + strncpy(attribute->value, begin, value_len); + attribute->value[value_len] = '\0'; attribute->next = NULL; if (context->head == NULL) { context->head = attribute; diff --git a/src/share/instrument/Reentrancy.c b/src/share/instrument/Reentrancy.c index e5f9c62a73ee3e24ed61bbadf12c0640618ce1eb..3fcc4e7f1db4d90c28b071ad09c673d53b6fabed 100644 --- a/src/share/instrument/Reentrancy.c +++ b/src/share/instrument/Reentrancy.c @@ -74,6 +74,7 @@ confirmingTLSSet( jvmtiEnv * jvmtienv, jvmtienv, thread, newValue); + check_phase_ret_blob(error, error); #if JPLISASSERT_ENABLEASSERTIONS assertTLSValue( jvmtienv, @@ -96,6 +97,7 @@ assertTLSValue( jvmtiEnv * jvmtienv, jvmtienv, thread, &test); + check_phase_ret(error); jplis_assert(error == JVMTI_ERROR_NONE); jplis_assert(test == expected); } @@ -111,6 +113,7 @@ tryToAcquireReentrancyToken( jvmtiEnv * jvmtienv, jvmtienv, thread, &storedValue); + check_phase_ret_false(error); jplis_assert(error == JVMTI_ERROR_NONE); if ( error == JVMTI_ERROR_NONE ) { /* if this thread is already inside, just return false and short-circuit */ diff --git a/src/share/instrument/Utilities.c b/src/share/instrument/Utilities.c index 120b30a862b1e14c1a2a17c3539e1f2392d84325..2bcb25ec30adedcf44dfc50d809be98f22e48a55 100644 --- a/src/share/instrument/Utilities.c +++ b/src/share/instrument/Utilities.c @@ -46,6 +46,7 @@ allocate(jvmtiEnv * jvmtienv, size_t bytecount) { error = (*jvmtienv)->Allocate(jvmtienv, bytecount, (unsigned char**) &resultBuffer); + /* may be called from any phase */ jplis_assert(error == JVMTI_ERROR_NONE); if ( error != JVMTI_ERROR_NONE ) { resultBuffer = NULL; @@ -66,6 +67,7 @@ deallocate(jvmtiEnv * jvmtienv, void * buffer) { error = (*jvmtienv)->Deallocate(jvmtienv, (unsigned char*)buffer); + /* may be called from any phase */ jplis_assert_msg(error == JVMTI_ERROR_NONE, "Can't deallocate memory"); return; } diff --git a/src/share/javavm/export/jvm.h b/src/share/javavm/export/jvm.h index a94a0488fb1da8ecfbe5df6ff6e5bd9184933bbd..75a1b5eca4dc693f760d1d818ae9250595ad8e55 100644 --- a/src/share/javavm/export/jvm.h +++ b/src/share/javavm/export/jvm.h @@ -591,6 +591,80 @@ JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused); JNIEXPORT jboolean JNICALL JVM_SupportsCX8(void); +/* + * com.sun.dtrace.jsdt support + */ + +#define JVM_TRACING_DTRACE_VERSION 1 + +/* + * Structure to pass one probe description to JVM + */ +typedef struct { + jmethodID method; + jstring function; + jstring name; + void* reserved[4]; // for future use +} JVM_DTraceProbe; + +/** + * Encapsulates the stability ratings for a DTrace provider field + */ +typedef struct { + jint nameStability; + jint dataStability; + jint dependencyClass; +} JVM_DTraceInterfaceAttributes; + +/* + * Structure to pass one provider description to JVM + */ +typedef struct { + jstring name; + JVM_DTraceProbe* probes; + jint probe_count; + JVM_DTraceInterfaceAttributes providerAttributes; + JVM_DTraceInterfaceAttributes moduleAttributes; + JVM_DTraceInterfaceAttributes functionAttributes; + JVM_DTraceInterfaceAttributes nameAttributes; + JVM_DTraceInterfaceAttributes argsAttributes; + void* reserved[4]; // for future use +} JVM_DTraceProvider; + +/* + * Get the version number the JVM was built with + */ +JNIEXPORT jint JNICALL +JVM_DTraceGetVersion(JNIEnv* env); + +/* + * Register new probe with given signature, return global handle + * + * The version passed in is the version that the library code was + * built with. + */ +JNIEXPORT jlong JNICALL +JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name, + jint providers_count, JVM_DTraceProvider* providers); + +/* + * Check JSDT probe + */ +JNIEXPORT jboolean JNICALL +JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method); + +/* + * Destroy custom DOF + */ +JNIEXPORT void JNICALL +JVM_DTraceDispose(JNIEnv* env, jlong activation_handle); + +/* + * Check to see if DTrace is supported by OS + */ +JNIEXPORT jboolean JNICALL +JVM_DTraceIsSupported(JNIEnv* env); + /************************************************************************* PART 2: Support for the Verifier and Class File Format Checker ************************************************************************/ diff --git a/src/share/native/java/io/io_util.c b/src/share/native/java/io/io_util.c index 4f7372babb971e85a807c8f50a8698c1736bb657..f355069cd0aa258ba11065bbdcba98b11b5349f2 100644 --- a/src/share/native/java/io/io_util.c +++ b/src/share/native/java/io/io_util.c @@ -40,7 +40,7 @@ readSingle(JNIEnv *env, jobject this, jfieldID fid) { char ret; FD fd = GET_FD(this, fid); if (fd == -1) { - JNU_ThrowIOException (env, "Stream Closed"); + JNU_ThrowIOException(env, "Stream Closed"); return -1; } nread = IO_Read(fd, &ret, 1); @@ -94,8 +94,8 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes, fd = GET_FD(this, fid); if (fd == -1) { - JNU_ThrowIOException (env, "Stream Closed"); - return -1; + JNU_ThrowIOException(env, "Stream Closed"); + return -1; } nread = IO_Read(fd, buf, len); @@ -121,7 +121,7 @@ writeSingle(JNIEnv *env, jobject this, jint byte, jfieldID fid) { int n; FD fd = GET_FD(this, fid); if (fd == -1) { - JNU_ThrowIOException (env, "Stream Closed"); + JNU_ThrowIOException(env, "Stream Closed"); return; } n = IO_Write(fd, &c, 1); @@ -172,8 +172,8 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes, while (len > 0) { fd = GET_FD(this, fid); if (fd == -1) { - JNU_ThrowIOException (env, "Stream Closed"); - return; + JNU_ThrowIOException(env, "Stream Closed"); + break; } n = IO_Write(fd, buf+off, len); if (n == JVM_IO_ERR) { diff --git a/src/share/native/sun/tracing/dtrace/JVM.c b/src/share/native/sun/tracing/dtrace/JVM.c new file mode 100644 index 0000000000000000000000000000000000000000..549e309937a0e4659f577ac667383c9ea279d810 --- /dev/null +++ b/src/share/native/sun/tracing/dtrace/JVM.c @@ -0,0 +1,304 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +#include + +#include "jvm.h" +#include "jni.h" +#include "jni_util.h" + +#include "jvm_symbols.h" +#include "sun_tracing_dtrace_JVM.h" + +#ifdef __cplusplus +extern "C" { +#endif + +static JvmSymbols* jvm_symbols = NULL; + +static void initialize() { + static int initialized = 0; + if (initialized == 0) { + jvm_symbols = lookupJvmSymbols(); + initialized = 1; + } +} + +/* + * Class: sun_tracing_dtrace_JVM + * Method: isSupported0 + * Signature: ()I + */ +JNIEXPORT jboolean JNICALL Java_sun_tracing_dtrace_JVM_isSupported0( + JNIEnv* env, jclass cls) { + initialize(); + if (jvm_symbols != NULL) { + return jvm_symbols->IsSupported(env) ? JNI_TRUE : JNI_FALSE; + } else { + return JNI_FALSE; + } +} + +// Macros that cause an immediate return if we detect an exception +#define CHECK if ((*env)->ExceptionOccurred(env)) { return; } +#define CHECK_(x) if ((*env)->ExceptionOccurred(env)) { return x; } + +static void readProbeData ( + JNIEnv* env, jobject probe, JVM_DTraceProbe* jvm_probe) { + jclass clazz; + jmethodID mid; + jobject method; + + if (jvm_probe == NULL) { + return; // just in case + } + + clazz = (*env)->GetObjectClass(env, probe); CHECK + + mid = (*env)->GetMethodID( + env, clazz, "getFunctionName", "()Ljava/lang/String;"); CHECK + jvm_probe->function = (jstring)(*env)->CallObjectMethod( + env, probe, mid); CHECK + + mid = (*env)->GetMethodID( + env, clazz, "getProbeName", "()Ljava/lang/String;"); CHECK + jvm_probe->name = (jstring)(*env)->CallObjectMethod(env, probe, mid); CHECK + + mid = (*env)->GetMethodID( + env, clazz, "getMethod", "()Ljava/lang/reflect/Method;"); CHECK + method = (*env)->CallObjectMethod(env, probe, mid); CHECK + jvm_probe->method = (*env)->FromReflectedMethod(env, method); CHECK +} + +static void readFieldInterfaceAttributes( + char* annotationName, JNIEnv* env, jobject provider, + JVM_DTraceInterfaceAttributes* attrs) { + jobject result; + jobject result_clazz; + jclass provider_clazz; + jclass annotation_clazz; + jmethodID get; + jmethodID enc; + + provider_clazz = (*env)->GetObjectClass(env, provider); CHECK + annotation_clazz = (*env)->FindClass(env, annotationName); CHECK + + get = (*env)->GetMethodID(env, provider_clazz, "getNameStabilityFor", + "(Ljava/lang/Class;)Lcom/sun/tracing/dtrace/StabilityLevel;"); CHECK + result = (*env)->CallObjectMethod( + env, provider, get, annotation_clazz); CHECK + result_clazz = (*env)->GetObjectClass(env, result); CHECK + enc = (*env)->GetMethodID(env, result_clazz, "getEncoding", "()I"); CHECK + attrs->nameStability = (*env)->CallIntMethod(env, result, enc); CHECK + + get = (*env)->GetMethodID(env, provider_clazz, "getDataStabilityFor", + "(Ljava/lang/Class;)Lcom/sun/tracing/dtrace/StabilityLevel;"); CHECK + result = (*env)->CallObjectMethod( + env, provider, get, annotation_clazz); CHECK + result_clazz = (*env)->GetObjectClass(env, result); CHECK + enc = (*env)->GetMethodID(env, result_clazz, "getEncoding", "()I"); CHECK + attrs->dataStability = (*env)->CallIntMethod(env, result, enc); CHECK + + get = (*env)->GetMethodID(env, provider_clazz, "getDependencyClassFor", + "(Ljava/lang/Class;)Lcom/sun/tracing/dtrace/DependencyClass;"); CHECK + result = (*env)->CallObjectMethod( + env, provider, get, annotation_clazz); CHECK + result_clazz = (*env)->GetObjectClass(env, result); CHECK + enc = (*env)->GetMethodID(env, result_clazz, "getEncoding", "()I"); CHECK + attrs->dependencyClass = (*env)->CallIntMethod(env, result, enc); CHECK +} + +static void readInterfaceAttributes( + JNIEnv* env, jobject provider, JVM_DTraceProvider* jvm_provider) { + readFieldInterfaceAttributes("com/sun/tracing/dtrace/ProviderAttributes", + env, provider, &(jvm_provider->providerAttributes)); + readFieldInterfaceAttributes("com/sun/tracing/dtrace/ModuleAttributes", + env, provider, &(jvm_provider->moduleAttributes)); + readFieldInterfaceAttributes("com/sun/tracing/dtrace/FunctionAttributes", + env, provider, &(jvm_provider->functionAttributes)); + readFieldInterfaceAttributes("com/sun/tracing/dtrace/NameAttributes", + env, provider, &(jvm_provider->nameAttributes)); + readFieldInterfaceAttributes("com/sun/tracing/dtrace/ArgsAttributes", + env, provider, &(jvm_provider->argsAttributes)); +} + +static void readProviderData( + JNIEnv* env, jobject provider, JVM_DTraceProvider* jvm_provider) { + jmethodID mid; + jobjectArray probes; + jsize i; + jclass clazz = (*env)->GetObjectClass(env, provider); CHECK + mid = (*env)->GetMethodID( + env, clazz, "getProbes", "()[Lsun/tracing/dtrace/DTraceProbe;"); CHECK + probes = (jobjectArray)(*env)->CallObjectMethod( + env, provider, mid); CHECK + + // Fill JVM structure, describing provider + jvm_provider->probe_count = (*env)->GetArrayLength(env, probes); CHECK + jvm_provider->probes = (JVM_DTraceProbe*)calloc( + jvm_provider->probe_count, sizeof(*jvm_provider->probes)); + mid = (*env)->GetMethodID( + env, clazz, "getProviderName", "()Ljava/lang/String;"); CHECK + jvm_provider->name = (jstring)(*env)->CallObjectMethod( + env, provider, mid); CHECK + + readInterfaceAttributes(env, provider, jvm_provider); CHECK + + for (i = 0; i < jvm_provider->probe_count; ++i) { + jobject probe = (*env)->GetObjectArrayElement(env, probes, i); CHECK + readProbeData(env, probe, &jvm_provider->probes[i]); CHECK + } +} + +/* + * Class: sun_tracing_dtrace_JVM + * Method: activate0 + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_sun_tracing_dtrace_JVM_activate0( + JNIEnv* env, jclass cls, jstring moduleName, jobjectArray providers) { + jlong handle = 0; + jsize num_providers; + jsize i; + JVM_DTraceProvider* jvm_providers; + + initialize(); + + if (jvm_symbols == NULL) { + return 0; + } + + num_providers = (*env)->GetArrayLength(env, providers); CHECK_(0L) + + jvm_providers = (JVM_DTraceProvider*)calloc( + num_providers, sizeof(*jvm_providers)); + + for (i = 0; i < num_providers; ++i) { + JVM_DTraceProvider* p = &(jvm_providers[i]); + jobject provider = (*env)->GetObjectArrayElement( + env, providers, i); + readProviderData(env, provider, p); + } + + handle = jvm_symbols->Activate( + env, JVM_TRACING_DTRACE_VERSION, moduleName, + num_providers, jvm_providers); + + for (i = 0; i < num_providers; ++i) { + JVM_DTraceProvider* p = &(jvm_providers[i]); + free(p->probes); + } + free(jvm_providers); + + return handle; +} + +/* + * Class: sun_tracing_dtrace_JVM + * Method: dispose0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_sun_tracing_dtrace_JVM_dispose0( + JNIEnv* env, jclass cls, jlong handle) { + if (jvm_symbols != NULL && handle != 0) { + jvm_symbols->Dispose(env, handle); + } +} + +/* + * Class: sun_tracing_dtrace_JVM + * Method: isEnabled0 + * Signature: (Ljava/lang/String;Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_sun_tracing_dtrace_JVM_isEnabled0( + JNIEnv* env, jclass cls, jobject method) { + jmethodID mid; + if (jvm_symbols != NULL && method != NULL) { + mid = (*env)->FromReflectedMethod(env, method); + return jvm_symbols->IsProbeEnabled(env, mid); + } + return JNI_FALSE; +} + +/* + * Class: sun_tracing_dtrace_JVM + * Method: defineClass0 + * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;[BII)Ljava/lang/Class; + * + * The implementation of this native static method is a copy of that of + * the native instance method Java_java_lang_ClassLoader_defineClass0() + * with the implicit "this" parameter becoming the "loader" parameter. + * + * This code was cloned and modified from java_lang_reflect_Proxy + */ +JNIEXPORT jclass JNICALL +Java_sun_tracing_dtrace_JVM_defineClass0( + JNIEnv *env, jclass ignore, jobject loader, jstring name, jbyteArray data, + jint offset, jint length) +{ + jbyte *body; + char *utfName; + jclass result = 0; + char buf[128]; + + if (data == NULL) { + return 0; + } + + /* Work around 4153825. malloc crashes on Solaris when passed a + * negative size. + */ + if (length < 0) { + return 0; + } + + body = (jbyte *)malloc(length); + + if (body == 0) { + return 0; + } + + (*env)->GetByteArrayRegion(env, data, offset, length, body); + + if ((*env)->ExceptionOccurred(env)) + goto free_body; + + if (name != NULL) { + int i; + int len = (*env)->GetStringUTFLength(env, name); + int unicode_len = (*env)->GetStringLength(env, name); + if (len >= sizeof(buf)) { + utfName = malloc(len + 1); + if (utfName == NULL) { + goto free_body; + } + } else { + utfName = buf; + } + (*env)->GetStringUTFRegion(env, name, 0, unicode_len, utfName); + + // Convert '.' to '/' in the package name + for (i = 0; i < unicode_len; ++i) { + if (utfName[i] == '.') { + utfName[i] = '/'; + } + } + } else { + utfName = NULL; + } + + result = (*env)->DefineClass(env, utfName, loader, body, length); + + if (utfName && utfName != buf) + free(utfName); + + free_body: + free(body); + return result; +} + +#ifdef __cplusplus +} +#endif diff --git a/src/share/native/sun/tracing/dtrace/jvm_symbols.h b/src/share/native/sun/tracing/dtrace/jvm_symbols.h new file mode 100644 index 0000000000000000000000000000000000000000..9fa263a28fca0894e5abe9f45fe57f93e40c0fda --- /dev/null +++ b/src/share/native/sun/tracing/dtrace/jvm_symbols.h @@ -0,0 +1,30 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +#ifndef _JVM_SYMBOLS_H +#define _JVM_SYMBOLS_H + +#include "jvm.h" + +typedef jint (JNICALL* GetVersion_t)(JNIEnv*); +typedef jboolean (JNICALL *IsSupported_t)(JNIEnv*); +typedef jlong (JNICALL* Activate_t)( + JNIEnv*, jint, jstring, jint, JVM_DTraceProvider*); +typedef void (JNICALL *Dispose_t)(JNIEnv*, jlong); +typedef jboolean (JNICALL *IsProbeEnabled_t)(JNIEnv*, jmethodID); + +typedef struct { + GetVersion_t GetVersion; + IsSupported_t IsSupported; + Activate_t Activate; + Dispose_t Dispose; + IsProbeEnabled_t IsProbeEnabled; +} JvmSymbols; + +// Platform-dependent implementation. +// Returns NULL if the symbols are not found +extern JvmSymbols* lookupJvmSymbols(); + +#endif // def _JVM_SYMBOLS_H diff --git a/src/share/sample/vm/clr-jvm/Makefile b/src/share/sample/vm/clr-jvm/Makefile index 2515650d1d518ccf4ac1d17a43fb47c11c0d45d3..5b8e6f3b6faf4e3041933df5f853991abbb9ba3f 100644 --- a/src/share/sample/vm/clr-jvm/Makefile +++ b/src/share/sample/vm/clr-jvm/Makefile @@ -29,16 +29,16 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -all: jinvoker.dll invoked.class invoker.exe - -jinvoker.dll: jinvoker.obj Makefile - cl /LD /o jinvoker.dll jinvoker.obj - -jinvoker.obj: jinvoker.cpp jinvokerExp.h Makefile - cl /Fojinvoker.obj /DJINVOKEREEXPORT /c jinvoker.cpp - -invoked.class: invoked.java Makefile - javac invoked.java - -invoker.exe: invoker.cs Makefile - csc /unsafe invoker.cs +all: jinvoker.dll invoked.class invoker.exe + +jinvoker.dll: jinvoker.obj Makefile + cl /LD /o jinvoker.dll jinvoker.obj + +jinvoker.obj: jinvoker.cpp jinvokerExp.h Makefile + cl /Fojinvoker.obj /DJINVOKEREEXPORT /c jinvoker.cpp + +invoked.class: invoked.java Makefile + javac invoked.java + +invoker.exe: invoker.cs Makefile + csc /unsafe invoker.cs diff --git a/src/share/sample/vm/clr-jvm/README.txt b/src/share/sample/vm/clr-jvm/README.txt index a081c878c94bcdbc1fd1a54be31b7e9dc4cd4910..52ed44e6d820c8abd88a16802e7e3cb55475b47b 100644 --- a/src/share/sample/vm/clr-jvm/README.txt +++ b/src/share/sample/vm/clr-jvm/README.txt @@ -1,54 +1,54 @@ -This sample provides Java "Hello World" program that is invoked -from C# application in the same process. - -The problem of direct call of the JVM API from CLR applications -by PInvoke interface is the JVM API functions do not have static -adresses, they need to be got by JNI_CreateJavaVM() call. -The sample contains C++ libraty that wraps JVM API calls by the -static functions that are called from the C# application by -PInvoke interface. - -The sample contains the following files: - -Makefile - make file -README.txt - this readme -invoked.java - the invoked HelloWorld Java program -invoker.cs - C# invoker application -jinvoker.cpp - C++ wrapper -jinvokerExp.h - wrapper library exports - -After the success making the following files are produced: - -invoked.class - the compiled HelloWorld class -invoker.exe - the executable .NET program that invokes Java -jinvoker.dll - the wrapper library - -The following environment needs to be set for the correct sample -build and execution: - -INCLUDE must contain the paths to: - 1. MS Visual C++ standard include - 2. .NET SDK include - 3. Java includes - Example: %MSDEV%/VC98/Include;%DOTNET%/Include;%JAVA_HOME%/include;%JAVA_HOME%/include/win32 - -LIB must contain the paths to: - 1. MS Visual C++ standard libraries - 2. .NET SDK libraries - 3. jvm.dll - Example: %MSDEV%/VC98/Lib;%DOTNET%/Lib;%JAVA_HOME%/jre/bin/client - -PATH must contain the paths to: - 1. MS Visual C++ standard bin - 2. MS Dev common bin - 3. .NET SDK libraries - 4. Java bin - 5. jvm.dll - Example: %MSDEV%/VC98/Bin;%MSDEV%/Common/MSDev98/Bin;%DOTNET%/Lib;%JAVA_HOME%/bin;%JAVA_HOME%/jre/bin/client;%PATH% - -To run the sample please do: - - invoker.exe invoked - - ---Dmitry Ryashchentsev +This sample provides Java "Hello World" program that is invoked +from C# application in the same process. + +The problem of direct call of the JVM API from CLR applications +by PInvoke interface is the JVM API functions do not have static +adresses, they need to be got by JNI_CreateJavaVM() call. +The sample contains C++ libraty that wraps JVM API calls by the +static functions that are called from the C# application by +PInvoke interface. + +The sample contains the following files: + +Makefile - make file +README.txt - this readme +invoked.java - the invoked HelloWorld Java program +invoker.cs - C# invoker application +jinvoker.cpp - C++ wrapper +jinvokerExp.h - wrapper library exports + +After the success making the following files are produced: + +invoked.class - the compiled HelloWorld class +invoker.exe - the executable .NET program that invokes Java +jinvoker.dll - the wrapper library + +The following environment needs to be set for the correct sample +build and execution: + +INCLUDE must contain the paths to: + 1. MS Visual C++ standard include + 2. .NET SDK include + 3. Java includes + Example: %MSDEV%/VC98/Include;%DOTNET%/Include;%JAVA_HOME%/include;%JAVA_HOME%/include/win32 + +LIB must contain the paths to: + 1. MS Visual C++ standard libraries + 2. .NET SDK libraries + 3. jvm.dll + Example: %MSDEV%/VC98/Lib;%DOTNET%/Lib;%JAVA_HOME%/jre/bin/client + +PATH must contain the paths to: + 1. MS Visual C++ standard bin + 2. MS Dev common bin + 3. .NET SDK libraries + 4. Java bin + 5. jvm.dll + Example: %MSDEV%/VC98/Bin;%MSDEV%/Common/MSDev98/Bin;%DOTNET%/Lib;%JAVA_HOME%/bin;%JAVA_HOME%/jre/bin/client;%PATH% + +To run the sample please do: + + invoker.exe invoked + + +--Dmitry Ryashchentsev diff --git a/src/share/sample/vm/clr-jvm/invoker.cs b/src/share/sample/vm/clr-jvm/invoker.cs index 7e5646230bfa48e68b0d21f94d2098a9f90f6a58..b4ae1bb3d0ae1844636e8e1d7b857d4d38e3f3b2 100644 --- a/src/share/sample/vm/clr-jvm/invoker.cs +++ b/src/share/sample/vm/clr-jvm/invoker.cs @@ -29,30 +29,30 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* -*/ - +/* +*/ + using System; using System.Runtime.InteropServices; class jinvoker{ public static int Main(string[] aArgs){ - - // Print Hello to show we are in CLR - Console.WriteLine("Hello from C#"); - if(aArgs.Length > 0) - // invoke JVM - return InvokeMain(aArgs[0]); - else - return -1; + + // Print Hello to show we are in CLR + Console.WriteLine("Hello from C#"); + if(aArgs.Length > 0) + // invoke JVM + return InvokeMain(aArgs[0]); + else + return -1; } // Link the JVM API functions and the wrappers [DllImport("jvm.dll")] public unsafe static extern int JNI_CreateJavaVM(void** ppVm, void** ppEnv, void* pArgs); [DllImport("jinvoker.dll")] public unsafe static extern int MakeJavaVMInitArgs( void** ppArgs ); - [DllImport("jinvoker.dll")] public unsafe static extern void FreeJavaVMInitArgs( void* pArgs ); + [DllImport("jinvoker.dll")] public unsafe static extern void FreeJavaVMInitArgs( void* pArgs ); [DllImport("jinvoker.dll")] public unsafe static extern int FindClass( void* pEnv, String sClass, void** ppClass ); [DllImport("jinvoker.dll")] public unsafe static extern int GetStaticMethodID( void* pEnv, void* pClass, @@ -73,7 +73,7 @@ class jinvoker{ [DllImport("jinvoker.dll")] public unsafe static extern int DestroyJavaVM( void* pJVM ); public unsafe static int InvokeMain( String sClass ){ - + void* pJVM; // JVM struct void* pEnv; // JVM environment void* pVMArgs; // VM args @@ -81,23 +81,23 @@ class jinvoker{ void* pMethod; // The executed method struct void* pArgs; // The executed method arguments struct - // Fill the pVMArgs structs + // Fill the pVMArgs structs MakeJavaVMInitArgs( &pVMArgs ); - // Create JVM + // Create JVM int nRes = JNI_CreateJavaVM( &pJVM, &pEnv, pVMArgs ); if( nRes == 0 ){ - - // Find the executed method class + + // Find the executed method class if(FindClass( pEnv, sClass, &pClass) == 0 ) - - // Find the executed method + + // Find the executed method if( GetStaticMethodID( pEnv, pClass, "main", "([Ljava/lang/String;)V", &pMethod ) == 0 ) - - // Create empty String[] array to pass to the main() + + // Create empty String[] array to pass to the main() if( NewObjectArray( pEnv, 0, "java/lang/String", &pArgs ) == 0 ){ - - // Call main() + + // Call main() nRes = CallStaticVoidMethod( pEnv, pClass, pMethod, pArgs ); if( nRes != -1 ) Console.WriteLine("Result:"+nRes); @@ -116,16 +116,16 @@ class jinvoker{ Console.WriteLine("can not find class:"+sClass); nRes = -102; } - - // Destroy the JVM + + // Destroy the JVM DestroyJavaVM( pJVM ); }else - Console.WriteLine("Can not create Java VM"); - - // Free the JVM args structs + Console.WriteLine("Can not create Java VM"); + + // Free the JVM args structs FreeJavaVMInitArgs(pVMArgs); - + return nRes; } } diff --git a/src/share/sample/vm/jvm-clr/README.txt b/src/share/sample/vm/jvm-clr/README.txt index a8fe79db343b3ab902827229ff704377cd274539..1d1c2f4bb12575c200d15587bb00dea85bc0ab05 100644 --- a/src/share/sample/vm/jvm-clr/README.txt +++ b/src/share/sample/vm/jvm-clr/README.txt @@ -42,10 +42,10 @@ PATH must contain the paths to: 3. .NET SDK libraries 4. Java bin Example: %MSDEV%/VC98/Bin;%MSDEV%/Common/MSDev98/Bin;%DOTNET%/Lib;%JAVA_HOME%/bin;%PATH% - -To run the sample please do: - -java invoker invoked.exe - - ---Dmitry Ryashchentsev + +To run the sample please do: + +java invoker invoked.exe + + +--Dmitry Ryashchentsev diff --git a/src/share/sample/vm/jvm-clr/invoked.cs b/src/share/sample/vm/jvm-clr/invoked.cs index 1904bb7191b8b495b68c73b964119f30e0f4b6ba..e5eead480afcc7d87fa2e71e3c7452f800266f39 100644 --- a/src/share/sample/vm/jvm-clr/invoked.cs +++ b/src/share/sample/vm/jvm-clr/invoked.cs @@ -29,17 +29,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* -*/ - - +/* +*/ + + using System; class App{ public static int Main(){ - - // Print Hello to show we are in CLR + + // Print Hello to show we are in CLR Console.WriteLine("Hello from C#!!!"); return 0; } diff --git a/src/solaris/bin/java_md.c b/src/solaris/bin/java_md.c index 5d96c2780f009aa702428faca964fd4a0068a5d6..74dd1a3ef8ea4b07221ea5ee9bf0dbbdbe9a517e 100644 --- a/src/solaris/bin/java_md.c +++ b/src/solaris/bin/java_md.c @@ -1299,12 +1299,6 @@ void SetJavaLauncherPlatformProps() { AddOption(pid_prop_str, NULL); #endif } -void -SetJavaw() -{ - /* noop on UNIX */ - return; -} jboolean IsJavaw() @@ -1312,3 +1306,9 @@ IsJavaw() /* noop on UNIX */ return JNI_FALSE; } + +void +InitLauncher(jboolean javaw) +{ + JLI_SetTraceLauncher(); +} diff --git a/src/solaris/classes/java/io/FileDescriptor.java b/src/solaris/classes/java/io/FileDescriptor.java index fdd1d143b82c0f7765e135f792b2891a83f41468..ef8aa1c4602d64e272eef1860ba3be142c3603ba 100644 --- a/src/solaris/classes/java/io/FileDescriptor.java +++ b/src/solaris/classes/java/io/FileDescriptor.java @@ -152,11 +152,19 @@ public final class FileDescriptor { public int get(FileDescriptor obj) { return obj.fd; } + + public void setHandle(FileDescriptor obj, long handle) { + throw new UnsupportedOperationException(); + } + + public long getHandle(FileDescriptor obj) { + throw new UnsupportedOperationException(); + } } ); } - // pacakge private methods used by FIS,FOS and RAF + // package private methods used by FIS, FOS and RAF int incrementAndGetUseCount() { return useCount.incrementAndGet(); diff --git a/src/solaris/classes/java/lang/ProcessImpl.java b/src/solaris/classes/java/lang/ProcessImpl.java index d7bdbe191173916313d7dcab987d8fc458ce8632..b9074349efac8a9ac3e4cb710213d4616238e820 100644 --- a/src/solaris/classes/java/lang/ProcessImpl.java +++ b/src/solaris/classes/java/lang/ProcessImpl.java @@ -26,7 +26,10 @@ package java.lang; import java.io.IOException; -import java.lang.Process; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.lang.ProcessBuilder.Redirect; +import java.lang.ProcessBuilder.Redirect; /** * This class is for the exclusive use of ProcessBuilder.start() to @@ -36,6 +39,9 @@ import java.lang.Process; * @since 1.5 */ final class ProcessImpl { + private static final sun.misc.JavaIOFileDescriptorAccess fdAccess + = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess(); + private ProcessImpl() {} // Not instantiable private static byte[] toCString(String s) { @@ -54,6 +60,7 @@ final class ProcessImpl { static Process start(String[] cmdarray, java.util.Map environment, String dir, + ProcessBuilder.Redirect[] redirects, boolean redirectErrorStream) throws IOException { @@ -78,11 +85,61 @@ final class ProcessImpl { int[] envc = new int[1]; byte[] envBlock = ProcessEnvironment.toEnvironmentBlock(environment, envc); + int[] std_fds; + + FileInputStream f0 = null; + FileOutputStream f1 = null; + FileOutputStream f2 = null; + + try { + if (redirects == null) { + std_fds = new int[] { -1, -1, -1 }; + } else { + std_fds = new int[3]; + + if (redirects[0] == Redirect.PIPE) + std_fds[0] = -1; + else if (redirects[0] == Redirect.INHERIT) + std_fds[0] = 0; + else { + f0 = new FileInputStream(redirects[0].file()); + std_fds[0] = fdAccess.get(f0.getFD()); + } + + if (redirects[1] == Redirect.PIPE) + std_fds[1] = -1; + else if (redirects[1] == Redirect.INHERIT) + std_fds[1] = 1; + else { + f1 = redirects[1].toFileOutputStream(); + std_fds[1] = fdAccess.get(f1.getFD()); + } + + if (redirects[2] == Redirect.PIPE) + std_fds[2] = -1; + else if (redirects[2] == Redirect.INHERIT) + std_fds[2] = 2; + else { + f2 = redirects[2].toFileOutputStream(); + std_fds[2] = fdAccess.get(f2.getFD()); + } + } + return new UNIXProcess (toCString(cmdarray[0]), argBlock, args.length, envBlock, envc[0], toCString(dir), + std_fds, redirectErrorStream); + } finally { + // In theory, close() can throw IOException + // (although it is rather unlikely to happen here) + try { if (f0 != null) f0.close(); } + finally { + try { if (f1 != null) f1.close(); } + finally { if (f2 != null) f2.close(); } + } + } } } diff --git a/src/solaris/classes/java/lang/UNIXProcess.java.linux b/src/solaris/classes/java/lang/UNIXProcess.java.linux index ded83065eb781d454763ba4b82c2bd57e0a054c8..9fc9e9da6452617792155f0a8b8b229cfe6656b1 100644 --- a/src/solaris/classes/java/lang/UNIXProcess.java.linux +++ b/src/solaris/classes/java/lang/UNIXProcess.java.linux @@ -1,5 +1,5 @@ -/* - * Copyright 1995-2006 Sun Microsystems, Inc. All Rights Reserved. +/* + * Copyright 1995-2008 Sun Microsystems, 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 @@ -34,9 +34,9 @@ import java.io.*; */ final class UNIXProcess extends Process { - private FileDescriptor stdin_fd; - private FileDescriptor stdout_fd; - private FileDescriptor stderr_fd; + private static final sun.misc.JavaIOFileDescriptorAccess fdAccess + = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess(); + private int pid; private int exitcode; private boolean hasExited; @@ -48,15 +48,26 @@ final class UNIXProcess extends Process { /* this is for the reaping thread */ private native int waitForProcessExit(int pid); + /** + * Create a process using fork(2) and exec(2). + * + * @param std_fds array of file descriptors. Indexes 0, 1, and + * 2 correspond to standard input, standard output and + * standard error, respectively. On input, a value of -1 + * means to create a pipe to connect child and parent + * processes. On output, a value which is not -1 is the + * parent pipe fd corresponding to the pipe which has + * been created. An element of this array is -1 on input + * if and only if it is not -1 on output. + * @return the pid of the subprocess + */ private native int forkAndExec(byte[] prog, - byte[] argBlock, int argc, - byte[] envBlock, int envc, - byte[] dir, - boolean redirectErrorStream, - FileDescriptor stdin_fd, - FileDescriptor stdout_fd, - FileDescriptor stderr_fd) - throws IOException; + byte[] argBlock, int argc, + byte[] envBlock, int envc, + byte[] dir, + int[] std_fds, + boolean redirectErrorStream) + throws IOException; /* In the process constructor we wait on this gate until the process */ /* has been created. Then we return from the constructor. */ @@ -97,67 +108,82 @@ final class UNIXProcess extends Process { } UNIXProcess(final byte[] prog, - final byte[] argBlock, final int argc, - final byte[] envBlock, final int envc, - final byte[] dir, - final boolean redirectErrorStream) + final byte[] argBlock, final int argc, + final byte[] envBlock, final int envc, + final byte[] dir, + final int[] std_fds, + final boolean redirectErrorStream) throws IOException { - stdin_fd = new FileDescriptor(); - stdout_fd = new FileDescriptor(); - stderr_fd = new FileDescriptor(); final Gate gate = new Gate(); - /* - * For each subprocess forked a corresponding reaper thread - * is started. That thread is the only thread which waits - * for the subprocess to terminate and it doesn't hold any - * locks while doing so. This design allows waitFor() and - * exitStatus() to be safely executed in parallel (and they - * need no native code). - */ - - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - Thread t = new Thread("process reaper") { - public void run() { + /* + * For each subprocess forked a corresponding reaper thread + * is started. That thread is the only thread which waits + * for the subprocess to terminate and it doesn't hold any + * locks while doing so. This design allows waitFor() and + * exitStatus() to be safely executed in parallel (and they + * need no native code). + */ + + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Void run() { + Thread t = new Thread("process reaper") { + public void run() { try { pid = forkAndExec(prog, - argBlock, argc, - envBlock, envc, - dir, - redirectErrorStream, - stdin_fd, stdout_fd, stderr_fd); + argBlock, argc, + envBlock, envc, + dir, + std_fds, + redirectErrorStream); } catch (IOException e) { gate.setException(e); /*remember to rethrow later*/ gate.exit(); return; } java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - stdin_stream = new BufferedOutputStream(new - FileOutputStream(stdin_fd)); - stdout_stream = new BufferedInputStream(new - FileInputStream(stdout_fd)); + new java.security.PrivilegedAction() { + public Void run() { + if (std_fds[0] == -1) + stdin_stream = new ProcessBuilder.NullOutputStream(); + else { + FileDescriptor stdin_fd = new FileDescriptor(); + fdAccess.set(stdin_fd, std_fds[0]); + stdin_stream = new BufferedOutputStream( + new FileOutputStream(stdin_fd)); + } + + if (std_fds[1] == -1) + stdout_stream = new ProcessBuilder.NullInputStream(); + else { + FileDescriptor stdout_fd = new FileDescriptor(); + fdAccess.set(stdout_fd, std_fds[1]); + stdout_stream = new BufferedInputStream( + new FileInputStream(stdout_fd)); + } + + if (std_fds[2] == -1) + stderr_stream = new ProcessBuilder.NullInputStream(); + else { + FileDescriptor stderr_fd = new FileDescriptor(); + fdAccess.set(stderr_fd, std_fds[2]); stderr_stream = new FileInputStream(stderr_fd); - return null; } - }); + + return null; }}); gate.exit(); /* exit from constructor */ - int res = waitForProcessExit(pid); - synchronized (UNIXProcess.this) { - hasExited = true; - exitcode = res; - UNIXProcess.this.notifyAll(); - } - } - }; + int res = waitForProcessExit(pid); + synchronized (UNIXProcess.this) { + hasExited = true; + exitcode = res; + UNIXProcess.this.notifyAll(); + } + } + }; t.setDaemon(true); t.start(); - return null; - } - }); + return null; }}); gate.waitForExit(); IOException e = gate.getException(); if (e != null) @@ -165,43 +191,43 @@ final class UNIXProcess extends Process { } public OutputStream getOutputStream() { - return stdin_stream; + return stdin_stream; } public InputStream getInputStream() { - return stdout_stream; + return stdout_stream; } public InputStream getErrorStream() { - return stderr_stream; + return stderr_stream; } public synchronized int waitFor() throws InterruptedException { while (!hasExited) { - wait(); - } - return exitcode; + wait(); + } + return exitcode; } public synchronized int exitValue() { - if (!hasExited) { - throw new IllegalThreadStateException("process hasn't exited"); - } - return exitcode; + if (!hasExited) { + throw new IllegalThreadStateException("process hasn't exited"); + } + return exitcode; } private static native void destroyProcess(int pid); public void destroy() { - // There is a risk that pid will be recycled, causing us to - // kill the wrong process! So we only terminate processes - // that appear to still be running. Even with this check, - // there is an unavoidable race condition here, but the window - // is very small, and OSes try hard to not recycle pids too - // soon, so this is quite safe. - synchronized (this) { - if (!hasExited) - destroyProcess(pid); - } + // There is a risk that pid will be recycled, causing us to + // kill the wrong process! So we only terminate processes + // that appear to still be running. Even with this check, + // there is an unavoidable race condition here, but the window + // is very small, and OSes try hard to not recycle pids too + // soon, so this is quite safe. + synchronized (this) { + if (!hasExited) + destroyProcess(pid); + } try { stdin_stream.close(); stdout_stream.close(); @@ -215,6 +241,6 @@ final class UNIXProcess extends Process { private static native void initIDs(); static { - initIDs(); + initIDs(); } } diff --git a/src/solaris/classes/java/lang/UNIXProcess.java.solaris b/src/solaris/classes/java/lang/UNIXProcess.java.solaris index ae29a09e5624f3414fbae5dc20c9b58a1c0c2ef9..f47d1043175192f8d877a1397d05f99fef185c94 100644 --- a/src/solaris/classes/java/lang/UNIXProcess.java.solaris +++ b/src/solaris/classes/java/lang/UNIXProcess.java.solaris @@ -1,5 +1,5 @@ -/* - * Copyright 1995-2006 Sun Microsystems, Inc. All Rights Reserved. +/* + * Copyright 1995-2008 Sun Microsystems, 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 @@ -33,129 +33,155 @@ import java.io.*; */ final class UNIXProcess extends Process { - private FileDescriptor stdin_fd; - private FileDescriptor stdout_fd; - private FileDescriptor stderr_fd; - private int pid; + private static final sun.misc.JavaIOFileDescriptorAccess fdAccess + = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess(); + + private final int pid; private int exitcode; private boolean hasExited; private OutputStream stdin_stream; - private BufferedInputStream stdout_stream; + private InputStream stdout_stream; private DeferredCloseInputStream stdout_inner_stream; - private DeferredCloseInputStream stderr_stream; + private InputStream stderr_stream; /* this is for the reaping thread */ private native int waitForProcessExit(int pid); + /** + * Create a process using fork(2) and exec(2). + * + * @param std_fds array of file descriptors. Indexes 0, 1, and + * 2 correspond to standard input, standard output and + * standard error, respectively. On input, a value of -1 + * means to create a pipe to connect child and parent + * processes. On output, a value which is not -1 is the + * parent pipe fd corresponding to the pipe which has + * been created. An element of this array is -1 on input + * if and only if it is not -1 on output. + * @return the pid of the subprocess + */ private native int forkAndExec(byte[] prog, - byte[] argBlock, int argc, - byte[] envBlock, int envc, - byte[] dir, - boolean redirectErrorStream, - FileDescriptor stdin_fd, - FileDescriptor stdout_fd, - FileDescriptor stderr_fd) - throws IOException; + byte[] argBlock, int argc, + byte[] envBlock, int envc, + byte[] dir, + int[] std_fds, + boolean redirectErrorStream) + throws IOException; UNIXProcess(final byte[] prog, - final byte[] argBlock, int argc, - final byte[] envBlock, int envc, - final byte[] dir, - final boolean redirectErrorStream) + final byte[] argBlock, int argc, + final byte[] envBlock, int envc, + final byte[] dir, + final int[] std_fds, + final boolean redirectErrorStream) throws IOException { - stdin_fd = new FileDescriptor(); - stdout_fd = new FileDescriptor(); - stderr_fd = new FileDescriptor(); - - pid = forkAndExec(prog, - argBlock, argc, - envBlock, envc, - dir, - redirectErrorStream, - stdin_fd, stdout_fd, stderr_fd); - - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - stdin_stream - = new BufferedOutputStream(new FileOutputStream(stdin_fd)); - stdout_inner_stream = new DeferredCloseInputStream(stdout_fd); - stdout_stream = new BufferedInputStream(stdout_inner_stream); - stderr_stream = new DeferredCloseInputStream(stderr_fd); - return null; - } - }); - - /* - * For each subprocess forked a corresponding reaper thread - * is started. That thread is the only thread which waits - * for the subprocess to terminate and it doesn't hold any - * locks while doing so. This design allows waitFor() and - * exitStatus() to be safely executed in parallel (and they - * need no native code). - */ - - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - Thread t = new Thread("process reaper") { - public void run() { - int res = waitForProcessExit(pid); - synchronized (UNIXProcess.this) { - hasExited = true; - exitcode = res; - UNIXProcess.this.notifyAll(); - } - } - }; - t.setDaemon(true); - t.start(); - return null; - } - }); + pid = forkAndExec(prog, + argBlock, argc, + envBlock, envc, + dir, + std_fds, + redirectErrorStream); + + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { public Void run() { + if (std_fds[0] == -1) + stdin_stream = new ProcessBuilder.NullOutputStream(); + else { + FileDescriptor stdin_fd = new FileDescriptor(); + fdAccess.set(stdin_fd, std_fds[0]); + stdin_stream = new BufferedOutputStream( + new FileOutputStream(stdin_fd)); + } + + if (std_fds[1] == -1) + stdout_stream = new ProcessBuilder.NullInputStream(); + else { + FileDescriptor stdout_fd = new FileDescriptor(); + fdAccess.set(stdout_fd, std_fds[1]); + stdout_inner_stream = new DeferredCloseInputStream(stdout_fd); + stdout_stream = new BufferedInputStream(stdout_inner_stream); + } + + if (std_fds[2] == -1) + stderr_stream = new ProcessBuilder.NullInputStream(); + else { + FileDescriptor stderr_fd = new FileDescriptor(); + fdAccess.set(stderr_fd, std_fds[2]); + stderr_stream = new DeferredCloseInputStream(stderr_fd); + } + + return null; }}); + + /* + * For each subprocess forked a corresponding reaper thread + * is started. That thread is the only thread which waits + * for the subprocess to terminate and it doesn't hold any + * locks while doing so. This design allows waitFor() and + * exitStatus() to be safely executed in parallel (and they + * need no native code). + */ + + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { public Void run() { + Thread t = new Thread("process reaper") { + public void run() { + int res = waitForProcessExit(pid); + synchronized (UNIXProcess.this) { + hasExited = true; + exitcode = res; + UNIXProcess.this.notifyAll(); + } + } + }; + t.setDaemon(true); + t.start(); + return null; }}); } public OutputStream getOutputStream() { - return stdin_stream; + return stdin_stream; } public InputStream getInputStream() { - return stdout_stream; + return stdout_stream; } public InputStream getErrorStream() { - return stderr_stream; + return stderr_stream; } public synchronized int waitFor() throws InterruptedException { while (!hasExited) { - wait(); - } - return exitcode; + wait(); + } + return exitcode; } public synchronized int exitValue() { - if (!hasExited) { - throw new IllegalThreadStateException("process hasn't exited"); - } - return exitcode; + if (!hasExited) { + throw new IllegalThreadStateException("process hasn't exited"); + } + return exitcode; } private static native void destroyProcess(int pid); public synchronized void destroy() { - // There is a risk that pid will be recycled, causing us to - // kill the wrong process! So we only terminate processes - // that appear to still be running. Even with this check, - // there is an unavoidable race condition here, but the window - // is very small, and OSes try hard to not recycle pids too - // soon, so this is quite safe. - if (!hasExited) - destroyProcess(pid); - try { + // There is a risk that pid will be recycled, causing us to + // kill the wrong process! So we only terminate processes + // that appear to still be running. Even with this check, + // there is an unavoidable race condition here, but the window + // is very small, and OSes try hard to not recycle pids too + // soon, so this is quite safe. + if (!hasExited) + destroyProcess(pid); + try { stdin_stream.close(); - stdout_inner_stream.closeDeferred(stdout_stream); - stderr_stream.closeDeferred(stderr_stream); + if (stdout_inner_stream != null) + stdout_inner_stream.closeDeferred(stdout_stream); + if (stderr_stream instanceof DeferredCloseInputStream) + ((DeferredCloseInputStream) stderr_stream) + .closeDeferred(stderr_stream); } catch (IOException e) { // ignore } @@ -172,99 +198,99 @@ final class UNIXProcess extends Process { // (EOF) as they did before. // private static class DeferredCloseInputStream - extends FileInputStream + extends FileInputStream { - private DeferredCloseInputStream(FileDescriptor fd) { - super(fd); - } - - private Object lock = new Object(); // For the following fields - private boolean closePending = false; - private int useCount = 0; - private InputStream streamToClose; - - private void raise() { - synchronized (lock) { - useCount++; - } - } - - private void lower() throws IOException { - synchronized (lock) { - useCount--; - if (useCount == 0 && closePending) { - streamToClose.close(); - } - } - } - - // stc is the actual stream to be closed; it might be this object, or - // it might be an upstream object for which this object is downstream. - // - private void closeDeferred(InputStream stc) throws IOException { - synchronized (lock) { - if (useCount == 0) { - stc.close(); - } else { - closePending = true; - streamToClose = stc; - } - } - } - - public void close() throws IOException { - synchronized (lock) { - useCount = 0; - closePending = false; - } - super.close(); - } - - public int read() throws IOException { - raise(); - try { - return super.read(); - } finally { - lower(); - } - } - - public int read(byte[] b) throws IOException { - raise(); - try { - return super.read(b); - } finally { - lower(); - } - } - - public int read(byte[] b, int off, int len) throws IOException { - raise(); - try { - return super.read(b, off, len); - } finally { - lower(); - } - } - - public long skip(long n) throws IOException { - raise(); - try { - return super.skip(n); - } finally { - lower(); - } - } - - public int available() throws IOException { - raise(); - try { - return super.available(); - } finally { - lower(); - } - } + private DeferredCloseInputStream(FileDescriptor fd) { + super(fd); + } + + private Object lock = new Object(); // For the following fields + private boolean closePending = false; + private int useCount = 0; + private InputStream streamToClose; + + private void raise() { + synchronized (lock) { + useCount++; + } + } + + private void lower() throws IOException { + synchronized (lock) { + useCount--; + if (useCount == 0 && closePending) { + streamToClose.close(); + } + } + } + + // stc is the actual stream to be closed; it might be this object, or + // it might be an upstream object for which this object is downstream. + // + private void closeDeferred(InputStream stc) throws IOException { + synchronized (lock) { + if (useCount == 0) { + stc.close(); + } else { + closePending = true; + streamToClose = stc; + } + } + } + + public void close() throws IOException { + synchronized (lock) { + useCount = 0; + closePending = false; + } + super.close(); + } + + public int read() throws IOException { + raise(); + try { + return super.read(); + } finally { + lower(); + } + } + + public int read(byte[] b) throws IOException { + raise(); + try { + return super.read(b); + } finally { + lower(); + } + } + + public int read(byte[] b, int off, int len) throws IOException { + raise(); + try { + return super.read(b, off, len); + } finally { + lower(); + } + } + + public long skip(long n) throws IOException { + raise(); + try { + return super.skip(n); + } finally { + lower(); + } + } + + public int available() throws IOException { + raise(); + try { + return super.available(); + } finally { + lower(); + } + } } @@ -272,6 +298,6 @@ final class UNIXProcess extends Process { private static native void initIDs(); static { - initIDs(); + initIDs(); } } diff --git a/src/solaris/classes/java/net/PlainSocketImpl.java b/src/solaris/classes/java/net/PlainSocketImpl.java index 113bcb0183e9177f9ef65b49f04528b4f8271816..25e2bab81f597fb2aac0acd68707e4dcd327a10f 100644 --- a/src/solaris/classes/java/net/PlainSocketImpl.java +++ b/src/solaris/classes/java/net/PlainSocketImpl.java @@ -76,9 +76,6 @@ class PlainSocketImpl extends AbstractPlainSocketImpl native int socketGetOption(int opt, Object iaContainerObj) throws SocketException; - native int socketGetOption1(int opt, Object iaContainerObj, FileDescriptor fd) - throws SocketException; - native void socketSendUrgentData(int data) throws IOException; } diff --git a/src/solaris/classes/java/util/prefs/FileSystemPreferences.java b/src/solaris/classes/java/util/prefs/FileSystemPreferences.java index 4b5b6d20d427e594b8b31bb643c155b95f0feb43..a48dc65fbbb296570b8c919500e9a4938753de54 100644 --- a/src/solaris/classes/java/util/prefs/FileSystemPreferences.java +++ b/src/solaris/classes/java/util/prefs/FileSystemPreferences.java @@ -52,14 +52,10 @@ class FileSystemPreferences extends AbstractPreferences { * Sync interval in seconds. */ private static final int SYNC_INTERVAL = Math.max(1, - Integer.parseInt((String) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty("java.util.prefs.syncInterval", - "30"); - } - }))); - + Integer.parseInt( + AccessController.doPrivileged( + new sun.security.action.GetPropertyAction( + "java.util.prefs.syncInterval", "30")))); /** * Returns logger for error messages. Backing store exceptions are logged at @@ -103,8 +99,8 @@ class FileSystemPreferences extends AbstractPreferences { } private static void setupUserRoot() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { userRootDir = new File(System.getProperty("java.util.prefs.userRoot", System.getProperty("user.home")), ".java/.userPrefs"); @@ -164,9 +160,9 @@ class FileSystemPreferences extends AbstractPreferences { } private static void setupSystemRoot() { - AccessController.doPrivileged( new PrivilegedAction() { - public Object run() { - String systemPrefsDirName = (String) + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { + String systemPrefsDirName = System.getProperty("java.util.prefs.systemRoot","/etc/.java"); systemRootDir = new File(systemPrefsDirName, ".systemPrefs"); @@ -322,7 +318,7 @@ class FileSystemPreferences extends AbstractPreferences { * corresponding disk file (prefsFile) by the sync operation. The initial * value is read *without* acquiring the file-lock. */ - private Map prefsCache = null; + private Map prefsCache = null; /** * The last modification time of the file backing this node at the time @@ -358,7 +354,7 @@ class FileSystemPreferences extends AbstractPreferences { * log against that map. The resulting map is then written back * to the disk. */ - final List changeLog = new ArrayList(); + final List changeLog = new ArrayList(); /** * Represents a change to a preference. @@ -424,7 +420,7 @@ class FileSystemPreferences extends AbstractPreferences { */ private void replayChanges() { for (int i = 0, n = changeLog.size(); i() { + public Void run() { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { syncTimer.cancel(); @@ -503,15 +499,15 @@ class FileSystemPreferences extends AbstractPreferences { dir = new File(parent.dir, dirName(name)); prefsFile = new File(dir, "prefs.xml"); tmpFile = new File(dir, "prefs.tmp"); - AccessController.doPrivileged( new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { newNode = !dir.exists(); return null; } }); if (newNode) { // These 2 things guarantee node will get wrtten at next flush/sync - prefsCache = new TreeMap(); + prefsCache = new TreeMap(); nodeCreate = new NodeCreate(); changeLog.add(nodeCreate); } @@ -529,7 +525,7 @@ class FileSystemPreferences extends AbstractPreferences { protected String getSpi(String key) { initCacheIfNecessary(); - return (String) prefsCache.get(key); + return prefsCache.get(key); } protected void removeSpi(String key) { @@ -554,7 +550,7 @@ class FileSystemPreferences extends AbstractPreferences { loadCache(); } catch(Exception e) { // assert lastSyncTime == 0; - prefsCache = new TreeMap(); + prefsCache = new TreeMap(); } } @@ -568,9 +564,10 @@ class FileSystemPreferences extends AbstractPreferences { */ private void loadCache() throws BackingStoreException { try { - AccessController.doPrivileged( new PrivilegedExceptionAction() { - public Object run() throws BackingStoreException { - Map m = new TreeMap(); + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws BackingStoreException { + Map m = new TreeMap(); long newLastSyncTime = 0; try { newLastSyncTime = prefsFile.lastModified(); @@ -584,7 +581,7 @@ class FileSystemPreferences extends AbstractPreferences { prefsFile.renameTo( new File( prefsFile.getParentFile(), "IncorrectFormatPrefs.xml")); - m = new TreeMap(); + m = new TreeMap(); } else if (e instanceof FileNotFoundException) { getLogger().warning("Prefs file removed in background " + prefsFile.getPath()); @@ -614,8 +611,9 @@ class FileSystemPreferences extends AbstractPreferences { */ private void writeBackCache() throws BackingStoreException { try { - AccessController.doPrivileged( new PrivilegedExceptionAction() { - public Object run() throws BackingStoreException { + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws BackingStoreException { try { if (!dir.exists() && !dir.mkdirs()) throw new BackingStoreException(dir + @@ -641,15 +639,14 @@ class FileSystemPreferences extends AbstractPreferences { protected String[] keysSpi() { initCacheIfNecessary(); - return (String[]) - prefsCache.keySet().toArray(new String[prefsCache.size()]); + return prefsCache.keySet().toArray(new String[prefsCache.size()]); } protected String[] childrenNamesSpi() { - return (String[]) - AccessController.doPrivileged( new PrivilegedAction() { - public Object run() { - List result = new ArrayList(); + return AccessController.doPrivileged( + new PrivilegedAction() { + public String[] run() { + List result = new ArrayList(); File[] dirContents = dir.listFiles(); if (dirContents != null) { for (int i = 0; i < dirContents.length; i++) @@ -685,8 +682,9 @@ class FileSystemPreferences extends AbstractPreferences { */ protected void removeNodeSpi() throws BackingStoreException { try { - AccessController.doPrivileged( new PrivilegedExceptionAction() { - public Object run() throws BackingStoreException { + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws BackingStoreException { if (changeLog.contains(nodeCreate)) { changeLog.remove(nodeCreate); nodeCreate = null; @@ -731,8 +729,9 @@ class FileSystemPreferences extends AbstractPreferences { if (!lockFile(shared)) throw(new BackingStoreException("Couldn't get file lock.")); final Long newModTime = - (Long) AccessController.doPrivileged( new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged( + new PrivilegedAction() { + public Long run() { long nmt; if (isUserNode()) { nmt = userRootModFile.lastModified(); @@ -746,8 +745,8 @@ class FileSystemPreferences extends AbstractPreferences { }); try { super.sync(); - AccessController.doPrivileged( new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { if (isUserNode()) { userRootModTime = newModTime.longValue() + 1000; userRootModFile.setLastModified(userRootModTime); @@ -766,8 +765,9 @@ class FileSystemPreferences extends AbstractPreferences { protected void syncSpi() throws BackingStoreException { try { - AccessController.doPrivileged( new PrivilegedExceptionAction() { - public Object run() throws BackingStoreException { + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws BackingStoreException { syncSpiPrivileged(); return null; } @@ -794,7 +794,7 @@ class FileSystemPreferences extends AbstractPreferences { } else if (lastSyncTime != 0 && !dir.exists()) { // This node was removed in the background. Playback any changes // against a virgin (empty) Map. - prefsCache = new TreeMap(); + prefsCache = new TreeMap(); replayChanges(); } if (!changeLog.isEmpty()) { diff --git a/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java b/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java index f9940eefb9330bd2102164c7c7df6eaf3589f4c4..9302361b04dee954a8fbf54a9e4b009fe9e7f6cf 100644 --- a/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java +++ b/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -39,6 +39,8 @@ import sun.misc.Unsafe; * @since 1.5 */ class MotifDnDConstants { + // utility class can not be instantiated + private MotifDnDConstants() {} // Note that offsets in all native structures below do not depend on the // architecture. private static final Unsafe unsafe = XlibWrapper.unsafe; @@ -55,8 +57,7 @@ class MotifDnDConstants { XAtom.get("XmTRANSFER_SUCCESS"); static final XAtom XA_XmTRANSFER_FAILURE = XAtom.get("XmTRANSFER_FAILURE"); - static final XSelection MotifDnDSelection = - new XSelection(XA_MOTIF_ATOM_0, null); + static final XSelection MotifDnDSelection = new XSelection(XA_MOTIF_ATOM_0); public static final byte MOTIF_DND_PROTOCOL_VERSION = 0; @@ -231,6 +232,9 @@ class MotifDnDConstants { } public static final class Swapper { + // utility class can not be instantiated + private Swapper() {} + public static short swap(short s) { return (short)(((s & 0xFF00) >>> 8) | ((s & 0xFF) << 8)); } diff --git a/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java b/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java index a67a2f552a05ac63e158ffb645623481c806cf4a..df348594fc560a36833f25557efa5c0f9d73c60c 100644 --- a/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java +++ b/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -933,7 +933,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { XSelection selection = XSelection.getSelection(selectionAtom); if (selection == null) { - selection = new XSelection(selectionAtom, null); + selection = new XSelection(selectionAtom); } return selection.getData(format, time_stamp); @@ -1056,7 +1056,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { // the original structure can be freed before this // SunDropTargetEvent is dispatched. if (xclient != null) { - int size = new XClientMessageEvent(nativeCtxt).getSize(); + int size = XClientMessageEvent.getSize(); nativeCtxt = unsafe.allocateMemory(size + 4 * Native.getLongSize()); diff --git a/src/solaris/classes/sun/awt/X11/OwnershipListener.java b/src/solaris/classes/sun/awt/X11/OwnershipListener.java new file mode 100644 index 0000000000000000000000000000000000000000..482b9cc7597893c5d251816ce636fee3f6101940 --- /dev/null +++ b/src/solaris/classes/sun/awt/X11/OwnershipListener.java @@ -0,0 +1,30 @@ +/* + * Copyright 2008 Sun Microsystems, 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package sun.awt.X11; + +interface OwnershipListener { + public void ownershipChanged(final boolean isOwner); +} diff --git a/src/solaris/classes/sun/awt/X11/XAtom.java b/src/solaris/classes/sun/awt/X11/XAtom.java index b98fc9b8ee968a3d592f29e730f6ca4aabd176c4..b72e790a043e15e1e2f71d0fc4287131514af125 100644 --- a/src/solaris/classes/sun/awt/X11/XAtom.java +++ b/src/solaris/classes/sun/awt/X11/XAtom.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, 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 @@ -58,7 +58,7 @@ package sun.awt.X11; import sun.misc.Unsafe; import java.util.HashMap; -public class XAtom { +public final class XAtom { // Order of lock: XAWTLock -> XAtom.class @@ -175,7 +175,7 @@ public class XAtom { public static XAtom get(String name) { XAtom xatom = lookup(name); if (xatom == null) { - xatom = new XAtom(name); + xatom = new XAtom(XToolkit.getDisplay(), name); } return xatom; } @@ -232,10 +232,6 @@ public class XAtom { this(display, name, true); } - private XAtom(String name) { - this(XToolkit.getDisplay(), name, true); - } - public XAtom(String name, boolean autoIntern) { this(XToolkit.getDisplay(), name, autoIntern); } @@ -262,7 +258,7 @@ public class XAtom { * @since 1.5 */ - public XAtom(long display, String name, boolean autoIntern) { + private XAtom(long display, String name, boolean autoIntern) { this.name = name; this.display = display; if (autoIntern) { @@ -651,28 +647,6 @@ public class XAtom { } } - /** - * Initializes atom with name and display values - */ - public void setValues(long display, String name, boolean autoIntern) { - this.display = display; - this.name = name; - if (autoIntern) { - XToolkit.awtLock(); - try { - atom = XlibWrapper.InternAtom(display,name,0); - } finally { - XToolkit.awtUnlock(); - } - } - register(); - } - - public void setValues(long display, long atom) { - this.display = display; - this.atom = atom; - register(); - } public void setValues(long display, String name, long atom) { this.display = display; this.atom = atom; diff --git a/src/solaris/classes/sun/awt/X11/XClipboard.java b/src/solaris/classes/sun/awt/X11/XClipboard.java index 5a7faef354758f51e6c4022201370a08d1fc200f..138e11d9a8c7402b33849933187657ad9a349a50 100644 --- a/src/solaris/classes/sun/awt/X11/XClipboard.java +++ b/src/solaris/classes/sun/awt/X11/XClipboard.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -26,30 +26,32 @@ package sun.awt.X11; import java.awt.datatransfer.Transferable; - import java.util.SortedMap; -import java.util.Set; -import java.util.Iterator; -import java.util.HashSet; - import java.io.IOException; - import java.security.AccessController; - +import java.util.HashMap; +import java.util.Map; +import sun.awt.UNIXToolkit; import sun.awt.datatransfer.DataTransferer; import sun.awt.datatransfer.SunClipboard; import sun.awt.datatransfer.ClipboardTransferable; - import sun.security.action.GetIntegerAction; - - /** * A class which interfaces with the X11 selection service in order to support * data transfer via Clipboard operations. */ -public class XClipboard extends SunClipboard implements Runnable { +public final class XClipboard extends SunClipboard implements OwnershipListener +{ private final XSelection selection; + // Time of calling XConvertSelection(). + private long convertSelectionTime; + // The flag used not to call XConvertSelection() if the previous SelectionNotify + // has not been processed by checkChange(). + private volatile boolean isSelectionNotifyProcessed; + // The property in which the owner should place requested targets + // when tracking changes of available data flavors (practically targets). + private volatile XAtom targetsPropertyAtom; private static final Object classLock = new Object(); @@ -57,31 +59,33 @@ public class XClipboard extends SunClipboard implements Runnable { private static int pollInterval; - private static Set listenedClipboards; - + private static Map targetsAtom2Clipboard; /** * Creates a system clipboard object. */ public XClipboard(String name, String selectionName) { super(name); - selection = new XSelection(XAtom.get(selectionName), this); + selection = new XSelection(XAtom.get(selectionName)); + selection.registerOwershipListener(this); } - /** - * The action to be run when we lose ownership + /* * NOTE: This method may be called by privileged threads. * DO NOT INVOKE CLIENT CODE ON THIS THREAD! */ - public void run() { - lostOwnershipImpl(); + public void ownershipChanged(final boolean isOwner) { + if (isOwner) { + checkChangeHere(contents); + } else { + lostOwnershipImpl(); + } } protected synchronized void setContentsNative(Transferable contents) { SortedMap formatMap = DataTransferer.getInstance().getFormatsForTransferable (contents, DataTransferer.adaptFlavorMap(flavorMap)); - long[] formats = - DataTransferer.getInstance().keysToLongArray(formatMap); + long[] formats = DataTransferer.keysToLongArray(formatMap); if (!selection.setOwner(contents, formatMap, formats, XToolkit.getCurrentServerTime())) { @@ -94,6 +98,7 @@ public class XClipboard extends SunClipboard implements Runnable { return selection.getSelectionAtom().getAtom(); } + @Override public synchronized Transferable getContents(Object requestor) { if (contents != null) { return contents; @@ -115,62 +120,163 @@ public class XClipboard extends SunClipboard implements Runnable { return selection.getData(format, XToolkit.getCurrentServerTime()); } - // Called on the toolkit thread under awtLock. - public void checkChange(long[] formats) { - if (!selection.isOwner()) { - super.checkChange(formats); - } - } - - void checkChangeHere(Transferable contents) { + private void checkChangeHere(Transferable contents) { if (areFlavorListenersRegistered()) { - super.checkChange(DataTransferer.getInstance(). + checkChange(DataTransferer.getInstance(). getFormatsForTransferableAsArray(contents, flavorMap)); } } - protected void registerClipboardViewerChecked() { - if (pollInterval <= 0) { - pollInterval = ((Integer)AccessController.doPrivileged( - new GetIntegerAction("awt.datatransfer.clipboard.poll.interval", - defaultPollInterval))).intValue(); + private static int getPollInterval() { + synchronized (XClipboard.classLock) { if (pollInterval <= 0) { - pollInterval = defaultPollInterval; + pollInterval = AccessController.doPrivileged( + new GetIntegerAction("awt.datatransfer.clipboard.poll.interval", + defaultPollInterval)); + if (pollInterval <= 0) { + pollInterval = defaultPollInterval; + } } + return pollInterval; + } + } + + private XAtom getTargetsPropertyAtom() { + if (null == targetsPropertyAtom) { + targetsPropertyAtom = + XAtom.get("XAWT_TARGETS_OF_SELECTION:" + selection.getSelectionAtom().getName()); } - selection.initializeSelectionForTrackingChanges(); + return targetsPropertyAtom; + } + + protected void registerClipboardViewerChecked() { + // for XConvertSelection() to be called for the first time in getTargetsDelayed() + isSelectionNotifyProcessed = true; + boolean mustSchedule = false; synchronized (XClipboard.classLock) { - if (listenedClipboards == null) { - listenedClipboards = new HashSet(2); + if (targetsAtom2Clipboard == null) { + targetsAtom2Clipboard = new HashMap(2); + } + mustSchedule = targetsAtom2Clipboard.isEmpty(); + targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this); + if (mustSchedule) { + XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), + new SelectionNotifyHandler()); } - mustSchedule = listenedClipboards.isEmpty(); - listenedClipboards.add(this); } if (mustSchedule) { - XToolkit.schedule(new CheckChangeTimerTask(), pollInterval); + XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval()); } } private static class CheckChangeTimerTask implements Runnable { public void run() { - for (Iterator iter = listenedClipboards.iterator(); iter.hasNext();) { - XClipboard clpbrd = (XClipboard)iter.next(); - clpbrd.selection.getTargetsDelayed(); + for (XClipboard clpbrd : targetsAtom2Clipboard.values()) { + clpbrd.getTargetsDelayed(); } synchronized (XClipboard.classLock) { - if (listenedClipboards != null && !listenedClipboards.isEmpty()) { - XToolkit.schedule(this, pollInterval); + if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) { + XToolkit.schedule(this, XClipboard.getPollInterval()); + } + } + } + } + + private static class SelectionNotifyHandler implements XEventDispatcher { + public void dispatchEvent(XEvent ev) { + if (ev.get_type() == XlibWrapper.SelectionNotify) { + final XSelectionEvent xse = ev.get_xselection(); + XClipboard clipboard = null; + synchronized (XClipboard.classLock) { + if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) { + XToolkit.removeEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), this); + return; + } + final long propertyAtom = xse.get_property(); + clipboard = targetsAtom2Clipboard.get(propertyAtom); + } + if (null != clipboard) { + clipboard.checkChange(xse); } } } } protected void unregisterClipboardViewerChecked() { - selection.deinitializeSelectionForTrackingChanges(); + isSelectionNotifyProcessed = false; synchronized (XClipboard.classLock) { - listenedClipboards.remove(this); + targetsAtom2Clipboard.remove(getTargetsPropertyAtom().getAtom()); } } + // checkChange() will be called on SelectionNotify + private void getTargetsDelayed() { + XToolkit.awtLock(); + try { + long curTime = System.currentTimeMillis(); + if (isSelectionNotifyProcessed || curTime >= (convertSelectionTime + UNIXToolkit.getDatatransferTimeout())) + { + convertSelectionTime = curTime; + XlibWrapper.XConvertSelection(XToolkit.getDisplay(), + selection.getSelectionAtom().getAtom(), + XDataTransferer.TARGETS_ATOM.getAtom(), + getTargetsPropertyAtom().getAtom(), + XWindow.getXAWTRootWindow().getWindow(), + XlibWrapper.CurrentTime); + isSelectionNotifyProcessed = false; + } + } finally { + XToolkit.awtUnlock(); + } + } + + /* + * Tracks changes of available formats. + * NOTE: This method may be called by privileged threads. + * DO NOT INVOKE CLIENT CODE ON THIS THREAD! + */ + private void checkChange(XSelectionEvent xse) { + final long propertyAtom = xse.get_property(); + if (propertyAtom != getTargetsPropertyAtom().getAtom()) { + // wrong atom + return; + } + + final XAtom selectionAtom = XAtom.get(xse.get_selection()); + final XSelection changedSelection = XSelection.getSelection(selectionAtom); + + if (null == changedSelection || changedSelection != selection) { + // unknown selection - do nothing + return; + } + + isSelectionNotifyProcessed = true; + + if (selection.isOwner()) { + // selection is owner - do not need formats + return; + } + + long[] formats = null; + + if (propertyAtom == XlibWrapper.None) { + // We treat None property atom as "empty selection". + formats = new long[0]; + } else { + WindowPropertyGetter targetsGetter = + new WindowPropertyGetter(XWindow.getXAWTRootWindow().getWindow(), + XAtom.get(propertyAtom), 0, + XSelection.MAX_LENGTH, true, + XlibWrapper.AnyPropertyType); + try { + targetsGetter.execute(); + formats = XSelection.getFormats(targetsGetter); + } finally { + targetsGetter.dispose(); + } + } + + checkChange(formats); + } } diff --git a/src/solaris/classes/sun/awt/X11/XComponentPeer.java b/src/solaris/classes/sun/awt/X11/XComponentPeer.java index 4657f75c49b06f9a1d52f3539cbbc05d835275ab..fb687e368307ca46a52ba619bea435498a4d9d10 100644 --- a/src/solaris/classes/sun/awt/X11/XComponentPeer.java +++ b/src/solaris/classes/sun/awt/X11/XComponentPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, 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 @@ -31,17 +31,13 @@ import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Cursor; -import java.awt.DefaultKeyboardFocusManager; import java.awt.Dimension; -import java.awt.Event; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Image; import java.awt.Insets; import java.awt.KeyboardFocusManager; -import java.awt.MenuBar; -import java.awt.Point; import java.awt.Rectangle; import java.awt.SystemColor; import java.awt.Toolkit; @@ -60,12 +56,9 @@ import java.awt.event.InvocationEvent; import java.awt.image.ImageObserver; import java.awt.image.ImageProducer; import java.awt.image.VolatileImage; -import java.awt.peer.CanvasPeer; import java.awt.peer.ComponentPeer; import java.awt.peer.ContainerPeer; import java.awt.peer.LightweightPeer; -import java.awt.peer.PanelPeer; -import java.awt.peer.WindowPeer; import java.lang.reflect.*; import java.security.*; import java.util.Collection; @@ -821,7 +814,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget public void setFont(Font f) { synchronized (getStateLock()) { if (f == null) { - f = defaultFont; + f = XWindow.getDefaultFont(); } font = f; } diff --git a/src/solaris/classes/sun/awt/X11/XContentWindow.java b/src/solaris/classes/sun/awt/X11/XContentWindow.java index 72737df0691720b6932367e8d33c733c44180f3b..268f7f5d151be251289fd87ab36d06a0947f7b60 100644 --- a/src/solaris/classes/sun/awt/X11/XContentWindow.java +++ b/src/solaris/classes/sun/awt/X11/XContentWindow.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -39,16 +39,37 @@ import sun.awt.ComponentAccessor; * This class implements window which serves as content window for decorated frames. * Its purpose to provide correct events dispatching for the complex * constructs such as decorated frames. + * + * It should always be located at (- left inset, - top inset) in the associated + * decorated window. So coordinates in it would be the same as java coordinates. */ -public class XContentWindow extends XWindow implements XConstants { +public final class XContentWindow extends XWindow implements XConstants { private static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XContentWindow"); - XDecoratedPeer parentFrame; + static XContentWindow createContent(XDecoratedPeer parentFrame) { + final WindowDimensions dims = parentFrame.getDimensions(); + Rectangle rec = dims.getBounds(); + // Fix for - set the location of the content window to the (-left inset, -top inset) + Insets ins = dims.getInsets(); + if (ins != null) { + rec.x = -ins.left; + rec.y = -ins.top; + } else { + rec.x = 0; + rec.y = 0; + } + final XContentWindow cw = new XContentWindow(parentFrame, rec); + cw.xSetVisible(true); + return cw; + } + + private final XDecoratedPeer parentFrame; // A list of expose events that come when the parentFrame is iconified - private java.util.List iconifiedExposeEvents = new java.util.ArrayList(); + private final java.util.List iconifiedExposeEvents = + new java.util.ArrayList(); - XContentWindow(XDecoratedPeer parentFrame, Rectangle bounds) { + private XContentWindow(XDecoratedPeer parentFrame, Rectangle bounds) { super((Component)parentFrame.getTarget(), parentFrame.getShell(), bounds); this.parentFrame = parentFrame; } @@ -63,9 +84,6 @@ public class XContentWindow extends XWindow implements XConstants { } } - void initialize() { - xSetVisible(true); - } protected String getWMName() { return "Content window"; } diff --git a/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java b/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java index a6b8c36f8f67962543f463a7bedd8eefd7494514..8aa3085282f4ca107f6ca06c7be2bbd56ad3d59f 100644 --- a/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java +++ b/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java @@ -36,7 +36,7 @@ import java.util.logging.Logger; import sun.awt.ComponentAccessor; import sun.awt.SunToolkit; -class XDecoratedPeer extends XWindowPeer { +abstract class XDecoratedPeer extends XWindowPeer { private static final Logger log = Logger.getLogger("sun.awt.X11.XDecoratedPeer"); private static final Logger insLog = Logger.getLogger("sun.awt.X11.insets.XDecoratedPeer"); private static final Logger focusLog = Logger.getLogger("sun.awt.X11.focus.XDecoratedPeer"); @@ -98,8 +98,7 @@ class XDecoratedPeer extends XWindowPeer { // happen after the X window is created. initResizability(); updateSizeHints(dimensions); - content = createContent(dimensions); - content.initialize(); + content = XContentWindow.createContent(this); if (warningWindow != null) { warningWindow.toFront(); } @@ -160,20 +159,6 @@ class XDecoratedPeer extends XWindowPeer { } } - XContentWindow createContent(WindowDimensions dims) { - Rectangle rec = dims.getBounds(); - // Fix for - set the location of the content window to the (-left inset, -top inset) - Insets ins = dims.getInsets(); - if (ins != null) { - rec.x = -ins.left; - rec.y = -ins.top; - } else { - rec.x = 0; - rec.y = 0; - } - return new XContentWindow(this, rec); - } - XFocusProxyWindow createFocusProxy() { return new XFocusProxyWindow(this); } @@ -286,7 +271,7 @@ class XDecoratedPeer extends XWindowPeer { return; } Component t = (Component)target; - if (getDecorations() == winAttr.AWT_DECOR_NONE) { + if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) { setReparented(true); insets_corrected = true; reshape(dimensions, SET_SIZE, false); @@ -471,6 +456,15 @@ class XDecoratedPeer extends XWindowPeer { if (insLog.isLoggable(Level.FINE)) { insLog.fine("Reshaping " + this + " to " + newDimensions + " op " + op + " user reshape " + userReshape); } + if (userReshape) { + // We handle only userReshape == true cases. It means that + // if the window manager or any other part of the windowing + // system sets inappropriate size for this window, we can + // do nothing but accept it. + Rectangle reqBounds = newDimensions.getBounds(); + Rectangle newBounds = constrainBounds(reqBounds.x, reqBounds.y, reqBounds.width, reqBounds.height); + newDimensions = new WindowDimensions(newBounds, newDimensions.getInsets(), newDimensions.isClientSizeSet()); + } XToolkit.awtLock(); try { if (!isReparented() || !isVisible()) { @@ -586,6 +580,49 @@ class XDecoratedPeer extends XWindowPeer { reshape(dims, operation, userReshape); } + // This method gets overriden in XFramePeer & XDialogPeer. + abstract boolean isTargetUndecorated(); + + @Override + Rectangle constrainBounds(int x, int y, int width, int height) { + // We don't restrict the setBounds() operation if the code is trusted. + if (!hasWarningWindow()) { + return new Rectangle(x, y, width, height); + } + + // If it's undecorated or is not currently visible, + // apply the same constraints as for the Window. + if (!isVisible() || isTargetUndecorated()) { + return super.constrainBounds(x, y, width, height); + } + + // If it's visible & decorated, constraint the size only + int newX = x; + int newY = y; + int newW = width; + int newH = height; + + GraphicsConfiguration gc = ((Window)target).getGraphicsConfiguration(); + Rectangle sB = gc.getBounds(); + Insets sIn = ((Window)target).getToolkit().getScreenInsets(gc); + + Rectangle curBounds = getBounds(); + + int maxW = Math.max(sB.width - sIn.left - sIn.right, curBounds.width); + int maxH = Math.max(sB.height - sIn.top - sIn.bottom, curBounds.height); + + // First make sure the size is withing the visible part of the screen + if (newW > maxW) { + newW = maxW; + } + + if (newH > maxH) { + newH = maxH; + } + + return new Rectangle(newX, newY, newW, newH); + } + /** * @see java.awt.peer.ComponentPeer#setBounds */ @@ -651,12 +688,12 @@ class XDecoratedPeer extends XWindowPeer { } if (!isReparented() && isVisible() && runningWM != XWM.NO_WM && !XWM.isNonReparentingWM() - && getDecorations() != winAttr.AWT_DECOR_NONE) { + && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) { insLog.fine("- visible but not reparented, skipping"); return; } //Last chance to correct insets - if (!insets_corrected && getDecorations() != winAttr.AWT_DECOR_NONE) { + if (!insets_corrected && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) { long parent = XlibUtil.getParentWindow(window); Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null; if (insLog.isLoggable(Level.FINER)) { @@ -824,7 +861,7 @@ class XDecoratedPeer extends XWindowPeer { fs &= ~(MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); } winAttr.functions = fs; - XWM.setShellNotResizable(this, dimensions, dimensions.getScreenBounds(), false); + XWM.setShellNotResizable(this, dimensions, dimensions.getBounds(), false); } } @@ -870,7 +907,7 @@ class XDecoratedPeer extends XWindowPeer { return getSize().height; } - public WindowDimensions getDimensions() { + final public WindowDimensions getDimensions() { return dimensions; } diff --git a/src/solaris/classes/sun/awt/X11/XDialogPeer.java b/src/solaris/classes/sun/awt/X11/XDialogPeer.java index 248e6f8e60ceb21b2689b7c0de9ec3b4f349c417..40822e2c27da2e31e3fb2dcc31116ae8fcfed389 100644 --- a/src/solaris/classes/sun/awt/X11/XDialogPeer.java +++ b/src/solaris/classes/sun/awt/X11/XDialogPeer.java @@ -88,7 +88,8 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer { } } - private boolean isTargetUndecorated() { + @Override + boolean isTargetUndecorated() { if (undecorated != null) { return undecorated.booleanValue(); } else { diff --git a/src/solaris/classes/sun/awt/X11/XDnDConstants.java b/src/solaris/classes/sun/awt/X11/XDnDConstants.java index 7974d12960d8284ce0d7ebdf719f4376a0d3c785..26967f76995e545059aa993cb0a0d2cdb6d14ce4 100644 --- a/src/solaris/classes/sun/awt/X11/XDnDConstants.java +++ b/src/solaris/classes/sun/awt/X11/XDnDConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -48,8 +48,7 @@ class XDnDConstants { static final XAtom XA_XdndStatus = XAtom.get("XdndStatus"); static final XAtom XA_XdndFinished = XAtom.get("XdndFinished"); - static final XSelection XDnDSelection = - new XSelection(XA_XdndSelection, null); + static final XSelection XDnDSelection = new XSelection(XA_XdndSelection); public static final int XDND_MIN_PROTOCOL_VERSION = 3; public static final int XDND_PROTOCOL_VERSION = 5; diff --git a/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java b/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java index 14cedf1fffa87bcd5119b6c63bf3e14c33ade963..10b71a453b4605e79c406ab0e6ba990569d1cac2 100644 --- a/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java +++ b/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java @@ -647,12 +647,6 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener } if (isXEmbedActive()) { switch ((int)msg.get_data(1)) { - case _SUN_XEMBED_START: - // Child has finished initialization and waits for notify - xembed.processXEmbedInfo(); - - notifyChildEmbedded(); - break; case XEMBED_REQUEST_FOCUS: requestXEmbedFocus(); break; diff --git a/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java b/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java index 582c2f05578fd9e4a4e87be1e0e8050e17182600..c56883e46af958977832e9687761274ad7f2a8f8 100644 --- a/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java +++ b/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java @@ -74,7 +74,6 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher XToolkit.awtUnlock(); } } - notifyReady(); } void handleClientMessage(XEvent xev) { @@ -84,7 +83,6 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Embedded message: " + msgidToString((int)msg.get_data(1))); switch ((int)msg.get_data(1)) { case XEMBED_EMBEDDED_NOTIFY: // Notification about embedding protocol start - // NOTE: May be called two times because we send _SUN_XEMBED_START active = true; server = getEmbedder(embedded, msg); // Check if window is reparented. If not - it was created with @@ -223,13 +221,4 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher long getX11Mods(AWTKeyStroke stroke) { return XWindow.getXModifiers(stroke); } - - void notifyReady() { - long wnd = server; - if (wnd == 0) { - // Server is still 0, get the parent - wnd = embedded.getParentWindowHandle(); - } - sendMessage(wnd, _SUN_XEMBED_START); - } } diff --git a/src/solaris/classes/sun/awt/X11/XEmbedHelper.java b/src/solaris/classes/sun/awt/X11/XEmbedHelper.java index ae2fc8507a64992f603bc7432c5eafaffbd9050f..aab7855200736d3af21095d3a620a9d2ce94e9c4 100644 --- a/src/solaris/classes/sun/awt/X11/XEmbedHelper.java +++ b/src/solaris/classes/sun/awt/X11/XEmbedHelper.java @@ -58,7 +58,6 @@ public class XEmbedHelper { final static int XEMBED_REGISTER_ACCELERATOR = 12; final static int XEMBED_UNREGISTER_ACCELERATOR= 13; final static int XEMBED_ACTIVATE_ACCELERATOR = 14; - final static int _SUN_XEMBED_START = 1119; final static int NON_STANDARD_XEMBED_GTK_GRAB_KEY = 108; final static int NON_STANDARD_XEMBED_GTK_UNGRAB_KEY = 109; @@ -151,8 +150,6 @@ public class XEmbedHelper { return "NON_STANDARD_XEMBED_GTK_UNGRAB_KEY"; case NON_STANDARD_XEMBED_GTK_GRAB_KEY: return "NON_STANDARD_XEMBED_GTK_GRAB_KEY"; - case _SUN_XEMBED_START: - return "XEMBED_START"; case XConstants.KeyPress | XEmbedServerTester.SYSTEM_EVENT_MASK: return "KeyPress"; case XConstants.MapNotify | XEmbedServerTester.SYSTEM_EVENT_MASK: diff --git a/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java b/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java index 5fab6876a5e5774569eb85c1d0c988084e96cf06..a5ce2df74049862b3bcb21b9cda47808edd721b8 100644 --- a/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java +++ b/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java @@ -177,13 +177,6 @@ public class XEmbedServerTester implements XEventDispatcher { embedCompletely(); } - public void test3_2() { - embedCompletely(); - int res = getEventPos(); - sendMessage(XEmbedHelper._SUN_XEMBED_START); - waitEmbeddedNotify(res); - } - public void test3_3() { reparent = true; embedCompletely(); diff --git a/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java b/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java index d33e545e27920c3b9f2e50971da9f1afd9e5e16c..b0cb3aa6d074fb25b2f64a5284ca50a419ca9122 100644 --- a/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java +++ b/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java @@ -184,6 +184,12 @@ public class XEmbeddedFramePeer extends XFramePeer { } } + @Override + Rectangle constrainBounds(int x, int y, int width, int height) { + // We don't constrain the bounds of the EmbeddedFrames + return new Rectangle(x, y, width, height); + } + // don't use getBounds() inherited from XDecoratedPeer public Rectangle getBounds() { return new Rectangle(x, y, width, height); diff --git a/src/solaris/classes/sun/awt/X11/XFramePeer.java b/src/solaris/classes/sun/awt/X11/XFramePeer.java index 84469bd649fc32aac2070b775f289d0b816ffd8a..28989acc60937a83ab3e3f01f31b303c1a48caa0 100644 --- a/src/solaris/classes/sun/awt/X11/XFramePeer.java +++ b/src/solaris/classes/sun/awt/X11/XFramePeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, 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 @@ -24,15 +24,18 @@ */ package sun.awt.X11; -import java.util.Vector; -import java.awt.*; -import java.awt.peer.*; -import java.awt.event.*; -import sun.awt.im.*; -import sun.awt.*; -import java.util.logging.*; -import java.lang.reflect.Field; -import java.util.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.MenuBar; +import java.awt.Rectangle; +import java.awt.peer.FramePeer; +import java.util.logging.Level; +import java.util.logging.Logger; class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { private static Logger log = Logger.getLogger("sun.awt.X11.XFramePeer"); @@ -92,7 +95,8 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { } } - private boolean isTargetUndecorated() { + @Override + boolean isTargetUndecorated() { if (undecorated != null) { return undecorated.booleanValue(); } else { @@ -285,19 +289,20 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { * Let's see if this is a window state protocol message, and * if it is - decode a new state in terms of java constants. */ - Integer newState = XWM.getWM().isStateChange(this, ev); - if (newState == null) { + if (!XWM.getWM().isStateChange(this, ev)) { + stateLog.finer("either not a state atom or state has not been changed"); return; } - int changed = state ^ newState.intValue(); + final int newState = XWM.getWM().getState(this); + int changed = state ^ newState; if (changed == 0) { stateLog.finer("State is the same: " + state); return; } int old_state = state; - state = newState.intValue(); + state = newState; if ((changed & Frame.ICONIFIED) != 0) { if ((state & Frame.ICONIFIED) != 0) { diff --git a/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java b/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java index c679dbecd5d2b395fd1b66b9f2adbf1cb0d4d438..ec80cebcec1b171f7ab7e5ae976b16531a23f7c6 100644 --- a/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java +++ b/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, 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 @@ -218,7 +218,7 @@ public class XMenuItemPeer implements MenuItemPeer { Font getTargetFont() { if (target == null) { - return XWindow.defaultFont; + return XWindow.getDefaultFont(); } try { return (Font)m_getFont.invoke(target, new Object[0]); @@ -227,7 +227,7 @@ public class XMenuItemPeer implements MenuItemPeer { } catch (InvocationTargetException e) { e.printStackTrace(); } - return XWindow.defaultFont; + return XWindow.getDefaultFont(); } String getTargetLabel() { diff --git a/src/solaris/classes/sun/awt/X11/XNETProtocol.java b/src/solaris/classes/sun/awt/X11/XNETProtocol.java index 8ae5334cba3b0295aa7a763c19a55d6dcec5e740..f61c476e57eceb013bb4f4e028f99be15c5976e9 100644 --- a/src/solaris/classes/sun/awt/X11/XNETProtocol.java +++ b/src/solaris/classes/sun/awt/X11/XNETProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -26,17 +26,15 @@ package sun.awt.X11; -import java.awt.*; +import java.awt.Frame; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.logging.LogManager; -import java.awt.*; -import java.awt.image.*; -import java.util.*; -class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol { - final static Logger log = Logger.getLogger("sun.awt.X11.XNETProtocol"); +final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol +{ + private final static Logger log = Logger.getLogger("sun.awt.X11.XNETProtocol"); private final static Logger iconLog = Logger.getLogger("sun.awt.X11.icon.XNETProtocol"); + private static Logger stateLog = Logger.getLogger("sun.awt.X11.states.XNETProtocol"); /** * XStateProtocol @@ -276,6 +274,7 @@ class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol { boolean doStateProtocol() { boolean res = active() && checkProtocol(XA_NET_SUPPORTED, XA_NET_WM_STATE); + stateLog.finer("doStateProtocol() returns " + res); return res; } diff --git a/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java b/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java index 8523bd7fffad72e235017f47c6e90acead152741..55fcfb5743f13256e102a14ea101fe618e172c01 100644 --- a/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java +++ b/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, 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 @@ -187,7 +187,7 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer { //Fix for 6267144: PIT: Popup menu label is not shown, XToolkit Font getTargetFont() { if (popupMenuTarget == null) { - return XWindow.defaultFont; + return XWindow.getDefaultFont(); } try { return (Font)m_getFont.invoke(popupMenuTarget, new Object[0]); @@ -196,7 +196,7 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer { } catch (InvocationTargetException e) { e.printStackTrace(); } - return XWindow.defaultFont; + return XWindow.getDefaultFont(); } String getTargetLabel() { diff --git a/src/solaris/classes/sun/awt/X11/XSelection.java b/src/solaris/classes/sun/awt/X11/XSelection.java index 9759a8175ca49c79ff6dcd6853ef9b5fee53aa08..b472bec7646ff2ae1506c60a30eefa8d0d0e9865 100644 --- a/src/solaris/classes/sun/awt/X11/XSelection.java +++ b/src/solaris/classes/sun/awt/X11/XSelection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -32,9 +32,6 @@ import java.io.IOException; import java.util.Hashtable; import java.util.Map; -import java.util.Set; -import java.util.HashSet; -import java.util.Collections; import sun.awt.AppContext; import sun.awt.SunToolkit; @@ -45,7 +42,7 @@ import sun.awt.datatransfer.DataTransferer; /** * A class which interfaces with the X11 selection service. */ -public class XSelection { +public final class XSelection { /* Maps atoms to XSelection instances. */ private static final Hashtable table = new Hashtable(); @@ -69,8 +66,6 @@ public class XSelection { XToolkit.awtUnlock(); } } - /* The selection timeout. */ - private static long SELECTION_TIMEOUT = UNIXToolkit.getDatatransferTimeout(); /* The PropertyNotify event handler for incremental data transfer. */ private static final XEventDispatcher incrementalTransferHandler = @@ -84,11 +79,6 @@ public class XSelection { /* The X atom for the underlying selection. */ private final XAtom selectionAtom; - /* - * XClipboard.run() is to be called when we lose ownership. - * XClipbioard.checkChange() is to be called when tracking changes of flavors. - */ - private final XClipboard clipboard; /* * Owner-related variables - protected with synchronized (this). @@ -109,17 +99,8 @@ public class XSelection { private long ownershipTime = 0; // True if we are the owner of this selection. private boolean isOwner; - // The property in which the owner should place requested targets - // when tracking changes of available data flavors (practically targets). - private volatile XAtom targetsPropertyAtom; - // A set of these property atoms. - private static volatile Set targetsPropertyAtoms; - // The flag used not to call XConvertSelection() if the previous SelectionNotify - // has not been processed by checkChange(). - private volatile boolean isSelectionNotifyProcessed; - // Time of calling XConvertSelection(). - private long convertSelectionTime; - + private OwnershipListener ownershipListener = null; + private final Object stateLock = new Object(); static { XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), @@ -141,12 +122,11 @@ public class XSelection { * @param clpbrd the corresponding clipoboard * @exception NullPointerException if atom is null. */ - public XSelection(XAtom atom, XClipboard clpbrd) { + public XSelection(XAtom atom) { if (atom == null) { throw new NullPointerException("Null atom"); } selectionAtom = atom; - clipboard = clpbrd; table.put(selectionAtom, this); } @@ -154,25 +134,9 @@ public class XSelection { return selectionAtom; } - void initializeSelectionForTrackingChanges() { - targetsPropertyAtom = XAtom.get("XAWT_TARGETS_OF_SELECTION:" + selectionAtom.getName()); - if (targetsPropertyAtoms == null) { - targetsPropertyAtoms = Collections.synchronizedSet(new HashSet(2)); - } - targetsPropertyAtoms.add(Long.valueOf(targetsPropertyAtom.getAtom())); - // for XConvertSelection() to be called for the first time in getTargetsDelayed() - isSelectionNotifyProcessed = true; - } - - void deinitializeSelectionForTrackingChanges() { - if (targetsPropertyAtoms != null && targetsPropertyAtom != null) { - targetsPropertyAtoms.remove(Long.valueOf(targetsPropertyAtom.getAtom())); - } - isSelectionNotifyProcessed = false; - } - public synchronized boolean setOwner(Transferable contents, Map formatMap, - long[] formats, long time) { + long[] formats, long time) + { long owner = XWindow.getXAWTRootWindow().getWindow(); long selection = selectionAtom.getAtom(); @@ -192,15 +156,12 @@ public class XSelection { XlibWrapper.XSetSelectionOwner(XToolkit.getDisplay(), selection, owner, time); if (XlibWrapper.XGetSelectionOwner(XToolkit.getDisplay(), - selection) != owner) { - + selection) != owner) + { reset(); return false; } - isOwner = true; - if (clipboard != null) { - clipboard.checkChangeHere(contents); - } + setOwnerProp(true); return true; } finally { XToolkit.awtUnlock(); @@ -217,7 +178,7 @@ public class XSelection { do { DataTransferer.getInstance().processDataConversionRequests(); XToolkit.awtLockWait(250); - } while (propertyGetter == dataGetter && System.currentTimeMillis() < startTime + SELECTION_TIMEOUT); + } while (propertyGetter == dataGetter && System.currentTimeMillis() < startTime + UNIXToolkit.getDatatransferTimeout()); } finally { XToolkit.awtUnlock(); } @@ -232,11 +193,9 @@ public class XSelection { throw new Error("UNIMPLEMENTED"); } - long[] formats = null; + long[] targets = null; synchronized (lock) { - SELECTION_TIMEOUT = UNIXToolkit.getDatatransferTimeout(); - WindowPropertyGetter targetsGetter = new WindowPropertyGetter(XWindow.getXAWTRootWindow().getWindow(), selectionPropertyAtom, 0, MAX_LENGTH, @@ -267,23 +226,25 @@ public class XSelection { } finally { XToolkit.awtUnlock(); } - formats = getFormats(targetsGetter); + targets = getFormats(targetsGetter); } finally { targetsGetter.dispose(); } } - return formats; + return targets; } - private static long[] getFormats(WindowPropertyGetter targetsGetter) { + static long[] getFormats(WindowPropertyGetter targetsGetter) { long[] formats = null; if (targetsGetter.isExecuted() && !targetsGetter.isDisposed() && (targetsGetter.getActualType() == XAtom.XA_ATOM || targetsGetter.getActualType() == XDataTransferer.TARGETS_ATOM.getAtom()) && - targetsGetter.getActualFormat() == 32) { - - int count = (int)targetsGetter.getNumberOfItems(); + targetsGetter.getActualFormat() == 32) + { + // we accept property with TARGETS type to be compatible with old jdks + // see 6607163 + int count = targetsGetter.getNumberOfItems(); if (count > 0) { long atoms = targetsGetter.getData(); formats = new long[count]; @@ -297,26 +258,6 @@ public class XSelection { return formats != null ? formats : new long[0]; } - // checkChange() will be called on SelectionNotify - void getTargetsDelayed() { - XToolkit.awtLock(); - try { - long curTime = System.currentTimeMillis(); - if (isSelectionNotifyProcessed || curTime >= convertSelectionTime + SELECTION_TIMEOUT) { - convertSelectionTime = curTime; - XlibWrapper.XConvertSelection(XToolkit.getDisplay(), - getSelectionAtom().getAtom(), - XDataTransferer.TARGETS_ATOM.getAtom(), - targetsPropertyAtom.getAtom(), - XWindow.getXAWTRootWindow().getWindow(), - XlibWrapper.CurrentTime); - isSelectionNotifyProcessed = false; - } - } finally { - XToolkit.awtUnlock(); - } - } - /* * Requests the selection data in the specified format and returns * the data provided by the owner. @@ -329,8 +270,6 @@ public class XSelection { byte[] data = null; synchronized (lock) { - SELECTION_TIMEOUT = UNIXToolkit.getDatatransferTimeout(); - WindowPropertyGetter dataGetter = new WindowPropertyGetter(XWindow.getXAWTRootWindow().getWindow(), selectionPropertyAtom, 0, MAX_LENGTH, @@ -379,7 +318,7 @@ public class XSelection { dataGetter.getActualFormat()); } - int count = (int)dataGetter.getNumberOfItems(); + int count = dataGetter.getNumberOfItems(); if (count <= 0) { throw new IOException("INCR data is missed."); @@ -455,7 +394,7 @@ public class XSelection { incrDataGetter.getActualFormat()); } - count = (int)incrDataGetter.getNumberOfItems(); + count = incrDataGetter.getNumberOfItems(); if (count == 0) { break; @@ -489,7 +428,7 @@ public class XSelection { dataGetter.getActualFormat()); } - int count = (int)dataGetter.getNumberOfItems(); + int count = dataGetter.getNumberOfItems(); if (count > 0) { data = new byte[count]; long ptr = dataGetter.getData(); @@ -511,11 +450,14 @@ public class XSelection { return isOwner; } - public void lostOwnership() { - isOwner = false; - if (clipboard != null) { - clipboard.run(); - } + // To be MT-safe this method should be called under awtLock. + private void setOwnerProp(boolean f) { + isOwner = f; + fireOwnershipChanges(isOwner); + } + + private void lostOwnership() { + setOwnerProp(false); } public synchronized void reset() { @@ -595,125 +537,39 @@ public class XSelection { private void handleSelectionRequest(XSelectionRequestEvent xsre) { long property = xsre.get_property(); - long requestor = xsre.get_requestor(); - long requestTime = xsre.get_time(); - long format = xsre.get_target(); - int dataFormat = 0; + final long requestor = xsre.get_requestor(); + final long requestTime = xsre.get_time(); + final long format = xsre.get_target(); boolean conversionSucceeded = false; if (ownershipTime != 0 && - (requestTime == XlibWrapper.CurrentTime || - requestTime >= ownershipTime)) { - - property = xsre.get_property(); - + (requestTime == XlibWrapper.CurrentTime || requestTime >= ownershipTime)) + { // Handle MULTIPLE requests as per ICCCM. if (format == XDataTransferer.MULTIPLE_ATOM.getAtom()) { - // The property cannot be 0 for a MULTIPLE request. - if (property != 0) { - // First retrieve the list of requested targets. - WindowPropertyGetter wpg = - new WindowPropertyGetter(requestor, XAtom.get(property), 0, - MAX_LENGTH, false, - XlibWrapper.AnyPropertyType); - try { - wpg.execute(); - - if (wpg.getActualFormat() == 32 && - (wpg.getNumberOfItems() % 2) == 0) { - long count = wpg.getNumberOfItems() / 2; - long pairsPtr = wpg.getData(); - boolean writeBack = false; - for (int i = 0; i < count; i++) { - long target = Native.getLong(pairsPtr, 2*i); - long prop = Native.getLong(pairsPtr, 2*i + 1); - - if (!convertAndStore(requestor, target, prop)) { - // To report failure, we should replace the - // target atom with 0 in the MULTIPLE property. - Native.putLong(pairsPtr, 2*i, 0); - writeBack = true; - } - } - if (writeBack) { - XToolkit.awtLock(); - try { - XlibWrapper.XChangeProperty(XToolkit.getDisplay(), requestor, - property, - wpg.getActualType(), - wpg.getActualFormat(), - XlibWrapper.PropModeReplace, - wpg.getData(), - wpg.getNumberOfItems()); - } finally { - XToolkit.awtUnlock(); - } - } - conversionSucceeded = true; - } - } finally { - wpg.dispose(); - } - } + conversionSucceeded = handleMultipleRequest(requestor, property); } else { - // Support for obsolete clients as per ICCCM. - if (property == 0) { + if (property == XlibWrapper.None) { property = format; } if (format == XDataTransferer.TARGETS_ATOM.getAtom()) { - long nativeDataPtr = 0; - int count = 0; - dataFormat = 32; - - // Use a local copy to avoid synchronization. - long[] formatsLocal = formats; - - if (formatsLocal == null) { - throw new IllegalStateException("Not an owner."); - } - - count = formatsLocal.length; - - try { - if (count > 0) { - nativeDataPtr = Native.allocateLongArray(count); - Native.put(nativeDataPtr, formatsLocal); - } - - conversionSucceeded = true; - - XToolkit.awtLock(); - try { - XlibWrapper.XChangeProperty(XToolkit.getDisplay(), requestor, - property, format, dataFormat, - XlibWrapper.PropModeReplace, - nativeDataPtr, count); - } finally { - XToolkit.awtUnlock(); - } - } finally { - if (nativeDataPtr != 0) { - XlibWrapper.unsafe.freeMemory(nativeDataPtr); - nativeDataPtr = 0; - } - } + conversionSucceeded = handleTargetsRequest(property, requestor); } else { - conversionSucceeded = convertAndStore(requestor, format, - property); + conversionSucceeded = convertAndStore(requestor, format, property); } } } if (!conversionSucceeded) { - // Zero property indicates conversion failure. - property = 0; + // None property indicates conversion failure. + property = XlibWrapper.None; } XSelectionEvent xse = new XSelectionEvent(); try { - xse.set_type((int)XlibWrapper.SelectionNotify); + xse.set_type(XlibWrapper.SelectionNotify); xse.set_send_event(true); xse.set_requestor(requestor); xse.set_selection(selectionAtom.getAtom()); @@ -733,40 +589,123 @@ public class XSelection { } } - private static void checkChange(XSelectionEvent xse) { - if (targetsPropertyAtoms == null || targetsPropertyAtoms.isEmpty()) { - // We are not tracking changes. - return; + private boolean handleMultipleRequest(final long requestor, long property) { + if (XlibWrapper.None == property) { + // The property cannot be None for a MULTIPLE request. + return false; } - long propertyAtom = xse.get_property(); - long[] formats = null; + boolean conversionSucceeded = false; - if (propertyAtom == XlibWrapper.None) { - // We threat None property atom as "empty selection". - formats = new long[0]; - } else if (!targetsPropertyAtoms.contains(Long.valueOf(propertyAtom))) { - return; - } else { - WindowPropertyGetter targetsGetter = - new WindowPropertyGetter(XWindow.getXAWTRootWindow().getWindow(), - XAtom.get(propertyAtom), 0, MAX_LENGTH, - true, XlibWrapper.AnyPropertyType); + // First retrieve the list of requested targets. + WindowPropertyGetter wpg = + new WindowPropertyGetter(requestor, XAtom.get(property), + 0, MAX_LENGTH, false, + XlibWrapper.AnyPropertyType); + try { + wpg.execute(); + + if (wpg.getActualFormat() == 32 && (wpg.getNumberOfItems() % 2) == 0) { + final long count = wpg.getNumberOfItems() / 2; + final long pairsPtr = wpg.getData(); + boolean writeBack = false; + + for (int i = 0; i < count; i++) { + long target = Native.getLong(pairsPtr, 2 * i); + long prop = Native.getLong(pairsPtr, 2 * i + 1); + + if (!convertAndStore(requestor, target, prop)) { + // To report failure, we should replace the + // target atom with 0 in the MULTIPLE property. + Native.putLong(pairsPtr, 2 * i, 0); + writeBack = true; + } + } + if (writeBack) { + XToolkit.awtLock(); + try { + XlibWrapper.XChangeProperty(XToolkit.getDisplay(), + requestor, + property, + wpg.getActualType(), + wpg.getActualFormat(), + XlibWrapper.PropModeReplace, + wpg.getData(), + wpg.getNumberOfItems()); + } finally { + XToolkit.awtUnlock(); + } + } + conversionSucceeded = true; + } + } finally { + wpg.dispose(); + } + + return conversionSucceeded; + } + + private boolean handleTargetsRequest(long property, long requestor) + throws IllegalStateException + { + boolean conversionSucceeded = false; + // Use a local copy to avoid synchronization. + long[] formatsLocal = formats; + + if (formatsLocal == null) { + throw new IllegalStateException("Not an owner."); + } + + long nativeDataPtr = 0; + + try { + final int count = formatsLocal.length; + final int dataFormat = 32; + + if (count > 0) { + nativeDataPtr = Native.allocateLongArray(count); + Native.put(nativeDataPtr, formatsLocal); + } + + conversionSucceeded = true; + + XToolkit.awtLock(); try { - targetsGetter.execute(); - formats = getFormats(targetsGetter); + XlibWrapper.XChangeProperty(XToolkit.getDisplay(), requestor, + property, XAtom.XA_ATOM, dataFormat, + XlibWrapper.PropModeReplace, + nativeDataPtr, count); } finally { - targetsGetter.dispose(); + XToolkit.awtUnlock(); + } + } finally { + if (nativeDataPtr != 0) { + XlibWrapper.unsafe.freeMemory(nativeDataPtr); + nativeDataPtr = 0; } } + return conversionSucceeded; + } - XAtom selectionAtom = XAtom.get(xse.get_selection()); - XSelection selection = getSelection(selectionAtom); - if (selection != null) { - selection.isSelectionNotifyProcessed = true; - if (selection.clipboard != null) { - selection.clipboard.checkChange(formats); - } + private void fireOwnershipChanges(final boolean isOwner) { + OwnershipListener l = null; + synchronized (stateLock) { + l = ownershipListener; + } + if (null != l) { + l.ownershipChanged(isOwner); + } + } + + void registerOwershipListener(OwnershipListener l) { + synchronized (stateLock) { + ownershipListener = l; + } + } + + void unregisterOwnershipListener() { + synchronized (stateLock) { + ownershipListener = null; } } @@ -774,10 +713,9 @@ public class XSelection { public void dispatchEvent(XEvent ev) { switch (ev.get_type()) { case XlibWrapper.SelectionNotify: { - XSelectionEvent xse = ev.get_xselection(); - checkChange(xse); XToolkit.awtLock(); try { + XSelectionEvent xse = ev.get_xselection(); // Ignore the SelectionNotify event if it is not the response to our last request. if (propertyGetter != null && xse.get_time() == lastRequestServerTime) { // The property will be None in case of convertion failure. diff --git a/src/solaris/classes/sun/awt/X11/XToolkit.java b/src/solaris/classes/sun/awt/X11/XToolkit.java index b94d01f2257a6a3d626f6aecb2ed185d68675756..069568519d8b62ecaaf025764b1971138fe72b69 100644 --- a/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, 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 @@ -25,11 +25,9 @@ package sun.awt.X11; import java.awt.*; -import java.awt.event.*; -import java.awt.peer.*; -import java.beans.PropertyChangeListener; -import sun.awt.*; -import java.util.*; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.datatransfer.Clipboard; import java.awt.dnd.DragSource; import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragGestureEvent; @@ -37,20 +35,27 @@ import java.awt.dnd.DragGestureRecognizer; import java.awt.dnd.MouseDragGestureRecognizer; import java.awt.dnd.InvalidDnDOperationException; import java.awt.dnd.peer.DragSourceContextPeer; -import java.awt.image.*; -import java.security.*; import java.awt.im.InputMethodHighlight; import java.awt.im.spi.InputMethodDescriptor; -import java.awt.datatransfer.Clipboard; +import java.awt.image.ColorModel; +import java.awt.peer.*; +import java.beans.PropertyChangeListener; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.LookAndFeel; import javax.swing.UIDefaults; -import java.util.logging.*; +import sun.awt.*; import sun.font.FontManager; import sun.misc.PerformanceLogger; import sun.print.PrintJob2D; -import java.lang.reflect.*; -public class XToolkit extends UNIXToolkit implements Runnable, XConstants { +public final class XToolkit extends UNIXToolkit implements Runnable, XConstants +{ private static Logger log = Logger.getLogger("sun.awt.X11.XToolkit"); private static Logger eventLog = Logger.getLogger("sun.awt.X11.event.XToolkit"); private static final Logger timeoutTaskLog = Logger.getLogger("sun.awt.X11.timeoutTask.XToolkit"); @@ -1871,9 +1876,7 @@ public class XToolkit extends UNIXToolkit implements Runnable, XConstants { } public boolean isAlwaysOnTopSupported() { - Iterator iter = XWM.getWM().getProtocols(XLayerProtocol.class).iterator(); - while (iter.hasNext()) { - XLayerProtocol proto = (XLayerProtocol)iter.next(); + for (XLayerProtocol proto : XWM.getWM().getProtocols(XLayerProtocol.class)) { if (proto.supportsLayer(XLayerProtocol.LAYER_ALWAYS_ON_TOP)) { return true; } diff --git a/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java b/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java index c9b9a1abfd3a231ea1bb8cda304d67620d071826..5c8ccd02913ce41569e9d5768777193d8488c497 100644 --- a/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java +++ b/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2008 Sun Microsystems, 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 @@ -31,11 +31,8 @@ import java.awt.peer.TrayIconPeer; import sun.awt.*; import java.awt.image.*; import java.text.BreakIterator; -import java.util.Vector; -import java.lang.reflect.Field; import java.util.logging.Logger; import java.util.logging.Level; -import java.util.AbstractQueue; import java.util.concurrent.ArrayBlockingQueue; import java.security.AccessController; import java.security.PrivilegedAction; @@ -629,7 +626,7 @@ public class XTrayIconPeer implements TrayIconPeer { final static int TOOLTIP_MAX_LENGTH = 64; final static int TOOLTIP_MOUSE_CURSOR_INDENT = 5; final static Color TOOLTIP_BACKGROUND_COLOR = new Color(255, 255, 220); - final static Font TOOLTIP_TEXT_FONT = XWindow.defaultFont; + final static Font TOOLTIP_TEXT_FONT = XWindow.getDefaultFont(); Tooltip(XTrayIconPeer xtiPeer, Frame parent) { super(parent, Color.black); diff --git a/src/solaris/classes/sun/awt/X11/XWM.java b/src/solaris/classes/sun/awt/X11/XWM.java index 68d1ff73e5f2e3c14c67772c4a8631763f093537..d8e0d6b031dacfc21b39350d9b7be4720139a46e 100644 --- a/src/solaris/classes/sun/awt/X11/XWM.java +++ b/src/solaris/classes/sun/awt/X11/XWM.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -31,20 +31,23 @@ package sun.awt.X11; import sun.misc.Unsafe; -import java.util.regex.*; +import java.awt.Insets; import java.awt.Frame; import java.awt.Rectangle; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; import java.util.logging.Level; -import java.util.logging.LogManager; import java.util.logging.Logger; -import java.awt.Insets; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Class incapsulating knowledge about window managers in general * Descendants should provide some information about specific window manager. */ -class XWM implements MWMConstants, XUtilConstants { +final class XWM implements MWMConstants, XUtilConstants +{ private final static Logger log = Logger.getLogger("sun.awt.X11.XWM"); private final static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XWM"); @@ -1026,21 +1029,21 @@ class XWM implements MWMConstants, XUtilConstants { /*****************************************************************************\ * Protocols support */ - HashMap, Collection> protocolsMap = new HashMap, Collection>(); + private HashMap, Collection> protocolsMap = new HashMap, Collection>(); /** * Returns all protocols supporting given protocol interface */ - Collection getProtocols(Class protocolInterface) { - Collection res = protocolsMap.get(protocolInterface); + Collection getProtocols(Class protocolInterface) { + Collection res = (Collection) protocolsMap.get(protocolInterface); if (res != null) { - return (Collection)res; + return res; } else { - return new LinkedList(); + return new LinkedList(); } } - void addProtocol(Class protocolInterface, XProtocol protocol) { - Collection protocols = getProtocols(protocolInterface); + private void addProtocol(Class protocolInterface, T protocol) { + Collection protocols = getProtocols(protocolInterface); protocols.add(protocol); protocolsMap.put(protocolInterface, protocols); } @@ -1085,9 +1088,7 @@ class XWM implements MWMConstants, XUtilConstants { } /* FALLTROUGH */ case Frame.MAXIMIZED_BOTH: - Iterator iter = getProtocols(XStateProtocol.class).iterator(); - while (iter.hasNext()) { - XStateProtocol proto = (XStateProtocol)iter.next(); + for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { if (proto.supportsState(state)) { return true; } @@ -1105,10 +1106,8 @@ class XWM implements MWMConstants, XUtilConstants { int getExtendedState(XWindowPeer window) { - Iterator iter = getProtocols(XStateProtocol.class).iterator(); int state = 0; - while (iter.hasNext()) { - XStateProtocol proto = (XStateProtocol)iter.next(); + for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { state |= proto.getState(window); } if (state != 0) { @@ -1127,18 +1126,17 @@ class XWM implements MWMConstants, XUtilConstants { /* * Check if property change is a window state protocol message. - * If it is - return the new state as Integer, otherwise return null */ - Integer isStateChange(XDecoratedPeer window, XPropertyEvent e) { + boolean isStateChange(XDecoratedPeer window, XPropertyEvent e) { if (!window.isShowing()) { stateLog.finer("Window is not showing"); - return null; + return false; } int wm_state = window.getWMState(); if (wm_state == XlibWrapper.WithdrawnState) { stateLog.finer("WithdrawnState"); - return null; + return false; } else { stateLog.finer("Window WM_STATE is " + wm_state); } @@ -1147,26 +1145,26 @@ class XWM implements MWMConstants, XUtilConstants { is_state_change = true; } - Iterator iter = getProtocols(XStateProtocol.class).iterator(); - while (iter.hasNext()) { - XStateProtocol proto = (XStateProtocol)iter.next(); + for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { is_state_change |= proto.isStateChange(e); + stateLog.finest(proto + ": is state changed = " + is_state_change); } - int res = 0; + return is_state_change; + } - if (is_state_change) { - if (wm_state == XlibWrapper.IconicState) { - res = Frame.ICONIFIED; - } else { - res = Frame.NORMAL; - } - res |= getExtendedState(window); - } - if (is_state_change) { - return Integer.valueOf(res); + /* + * Returns current state (including extended) of a given window. + */ + int getState(XDecoratedPeer window) { + int res = 0; + final int wm_state = window.getWMState(); + if (wm_state == XlibWrapper.IconicState) { + res = Frame.ICONIFIED; } else { - return null; + res = Frame.NORMAL; } + res |= getExtendedState(window); + return res; } /*****************************************************************************\ @@ -1180,9 +1178,7 @@ class XWM implements MWMConstants, XUtilConstants { * in XLayerProtocol */ void setLayer(XWindowPeer window, int layer) { - Iterator iter = getProtocols(XLayerProtocol.class).iterator(); - while (iter.hasNext()) { - XLayerProtocol proto = (XLayerProtocol)iter.next(); + for (XLayerProtocol proto : getProtocols(XLayerProtocol.class)) { if (proto.supportsLayer(layer)) { proto.setLayer(window, layer); } @@ -1191,9 +1187,7 @@ class XWM implements MWMConstants, XUtilConstants { } void setExtendedState(XWindowPeer window, int state) { - Iterator iter = getProtocols(XStateProtocol.class).iterator(); - while (iter.hasNext()) { - XStateProtocol proto = (XStateProtocol)iter.next(); + for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { if (proto.supportsState(state)) { proto.setState(window, state); break; @@ -1239,9 +1233,7 @@ class XWM implements MWMConstants, XUtilConstants { void unshadeKludge(XDecoratedPeer window) { assert(window.isShowing()); - Iterator iter = getProtocols(XStateProtocol.class).iterator(); - while (iter.hasNext()) { - XStateProtocol proto = (XStateProtocol)iter.next(); + for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { proto.unshadeKludge(window); } XToolkit.XSync(); diff --git a/src/solaris/classes/sun/awt/X11/XWindow.java b/src/solaris/classes/sun/awt/X11/XWindow.java index 9e3c877fa11af0ca30466c05fc2c4a5c75d33a0b..2d55ef889fbdec8cb8d923d79e3322a4198c89f3 100644 --- a/src/solaris/classes/sun/awt/X11/XWindow.java +++ b/src/solaris/classes/sun/awt/X11/XWindow.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, 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 @@ -92,8 +92,16 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { SurfaceData surfaceData; XRepaintArea paintArea; + // fallback default font object - final static Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12); + private static Font defaultFont; + + static synchronized Font getDefaultFont() { + if (null == defaultFont) { + defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12); + } + return defaultFont; + } /* * Keeps all buttons which were pressed at the time of the last mouse @@ -333,7 +341,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { } Font font = afont; if (font == null) { - font = defaultFont; + font = XWindow.getDefaultFont(); } return new SunGraphics2D(surfData, fgColor, bgColor, font); } @@ -902,13 +910,11 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { super.handleConfigureNotifyEvent(xev); insLog.log(Level.FINER, "Configure, {0}, event disabled: {1}", - new Object[] {xev, isEventDisabled(xev)}); + new Object[] {xev.get_xconfigure(), isEventDisabled(xev)}); if (isEventDisabled(xev)) { return; } - long eventWindow = xev.get_xany().get_window(); - // if ( Check if it's a resize, a move, or a stacking order change ) // { Rectangle bounds = getBounds(); @@ -982,7 +988,6 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { // called directly from this package, unlike handleKeyRelease. // un-final it if you need to override it in a subclass. final void handleKeyPress(XKeyEvent ev) { - int keycode = java.awt.event.KeyEvent.VK_UNDEFINED; long keysym[] = new long[2]; char unicodeKey = 0; keysym[0] = NoSymbol; @@ -1066,7 +1071,6 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { } // un-private it if you need to call it from elsewhere private void handleKeyRelease(XKeyEvent ev) { - int keycode = java.awt.event.KeyEvent.VK_UNDEFINED; long keysym[] = new long[2]; char unicodeKey = 0; keysym[0] = NoSymbol; diff --git a/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/src/solaris/classes/sun/awt/X11/XWindowPeer.java index 18ccbcba8dadae1c14d7ce6bec3a2d43735e053f..be6792089745ce5c6e4635c8728bbd735fbde224 100644 --- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java +++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, 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 @@ -112,9 +112,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, PARENT_WINDOW, Long.valueOf(0)})); } - // fallback default font object - static Font defaultFont; - /* * This constant defines icon size recommended for using. * Apparently, we should use XGetIconSizes which should @@ -162,10 +159,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, Font f = target.getFont(); if (f == null) { - if (defaultFont == null) { - defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12); - } - f = defaultFont; + f = XWindow.getDefaultFont(); target.setFont(f); // we should not call setFont because it will call a repaint // which the peer may not be ready to do yet. @@ -188,6 +182,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, GraphicsConfiguration gc = getGraphicsConfiguration(); ((X11GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this); + + Rectangle bounds = (Rectangle)(params.get(BOUNDS)); + params.put(BOUNDS, constrainBounds(bounds.x, bounds.y, bounds.width, bounds.height)); } private void initWMProtocols() { @@ -437,6 +434,56 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, return ownerPeer; } + // This method is overriden at the XDecoratedPeer to handle + // decorated windows a bit differently. + Rectangle constrainBounds(int x, int y, int width, int height) { + // We don't restrict the setBounds() operation if the code is trusted. + if (!hasWarningWindow()) { + return new Rectangle(x, y, width, height); + } + + // The window bounds should be within the visible part of the screen + int newX = x; + int newY = y; + int newW = width; + int newH = height; + + // Now check each point is within the visible part of the screen + GraphicsConfiguration gc = ((Window)target).getGraphicsConfiguration(); + Rectangle sB = gc.getBounds(); + Insets sIn = ((Window)target).getToolkit().getScreenInsets(gc); + + int screenX = sB.x + sIn.left; + int screenY = sB.y + sIn.top; + int screenW = sB.width - sIn.left - sIn.right; + int screenH = sB.height - sIn.top - sIn.bottom; + + + // First make sure the size is withing the visible part of the screen + if (newW > screenW) { + newW = screenW; + } + + if (newH > screenH) { + newH = screenH; + } + + // Tweak the location if needed + if (newX < screenX) { + newX = screenX; + } else if (newX + newW > screenX + screenW) { + newX = screenX + screenW - newW; + } + + if (newY < screenY) { + newY = screenY; + } else if (newY + newH > screenY + screenH) { + newY = screenY + screenH - newH; + } + + return new Rectangle(newX, newY, newW, newH); + } + //Fix for 6318144: PIT:Setting Min Size bigger than current size enlarges //the window but fails to revalidate, Sol-CDE //This bug is regression for @@ -445,10 +492,14 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, //Note that this function is overriden in XDecoratedPeer so event //posting is not changing for decorated peers public void setBounds(int x, int y, int width, int height, int op) { + Rectangle newBounds = constrainBounds(x, y, width, height); + XToolkit.awtLock(); try { Rectangle oldBounds = getBounds(); - super.setBounds(x, y, width, height, op); + + super.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height, op); + Rectangle bounds = getBounds(); XSizeHints hints = getHints(); @@ -1035,7 +1086,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, return !(target instanceof Frame || target instanceof Dialog); } boolean hasWarningWindow() { - return warningWindow != null; + return ((Window)target).getWarningString() != null; } // The height of menu bar window diff --git a/src/solaris/classes/sun/awt/motif/MDialogPeer.java b/src/solaris/classes/sun/awt/motif/MDialogPeer.java index 16ccab54ca6f9d6b6e8809b8aa792b9d92564351..5e22931aa600f8f6efbcf5fe73248c5570208377 100644 --- a/src/solaris/classes/sun/awt/motif/MDialogPeer.java +++ b/src/solaris/classes/sun/awt/motif/MDialogPeer.java @@ -102,4 +102,9 @@ class MDialogPeer extends MWindowPeer implements DialogPeer, MInputMethodControl public void blockWindows(java.util.List toBlock) { // do nothing } + + @Override + final boolean isTargetUndecorated() { + return ((Dialog)target).isUndecorated(); + } } diff --git a/src/solaris/classes/sun/awt/motif/MEmbeddedFramePeer.java b/src/solaris/classes/sun/awt/motif/MEmbeddedFramePeer.java index d608721d97dd4553e7e1fabbcb51da3c2fe0ed43..60de1a245f6192ad002a54f69a3e2d4e851f7f8b 100644 --- a/src/solaris/classes/sun/awt/motif/MEmbeddedFramePeer.java +++ b/src/solaris/classes/sun/awt/motif/MEmbeddedFramePeer.java @@ -204,4 +204,10 @@ public class MEmbeddedFramePeer extends MFramePeer { } public native Rectangle getBoundsPrivate(); + + @Override + Rectangle constrainBounds(int x, int y, int width, int height) { + // We don't constrain the bounds of the EmbeddedFrames + return new Rectangle(x, y, width, height); + } } diff --git a/src/solaris/classes/sun/awt/motif/MFramePeer.java b/src/solaris/classes/sun/awt/motif/MFramePeer.java index 99516d5a98b520c65e39aaf299f9dee073391e7a..d772b99c4c2fceb2b39e5d13c97d20c6caa3ae4d 100644 --- a/src/solaris/classes/sun/awt/motif/MFramePeer.java +++ b/src/solaris/classes/sun/awt/motif/MFramePeer.java @@ -503,4 +503,9 @@ class MFramePeer extends MWindowPeer implements FramePeer, MInputMethodControl { public Rectangle getBoundsPrivate() { return getBounds(); } + + @Override + final boolean isTargetUndecorated() { + return ((Frame)target).isUndecorated(); + } } diff --git a/src/solaris/classes/sun/awt/motif/MWindowPeer.java b/src/solaris/classes/sun/awt/motif/MWindowPeer.java index c59750aec5120b878f57591f523ffdc036760b40..15c5c80de3b3c8720aa635c348c329ad24649f0f 100644 --- a/src/solaris/classes/sun/awt/motif/MWindowPeer.java +++ b/src/solaris/classes/sun/awt/motif/MWindowPeer.java @@ -113,6 +113,12 @@ DisplayChangedListener { insets.right = getInset("awt.frame.rightInset", -1); } + Rectangle bounds = target.getBounds(); + sysX = bounds.x; + sysY = bounds.y; + sysW = bounds.width; + sysH = bounds.height; + super.init(target); InputMethodManager imm = InputMethodManager.getInstance(); String menuString = imm.getTriggerMenuString(); @@ -150,6 +156,7 @@ DisplayChangedListener { GraphicsConfiguration gc = getGraphicsConfiguration(); ((X11GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this); + } /* Support for multiple icons is not implemented in MAWT */ @@ -246,6 +253,8 @@ DisplayChangedListener { // NOTE: This method may be called by privileged threads. // DO NOT INVOKE CLIENT CODE ON THIS THREAD! public void handleResize(int width, int height) { + sysW = width; + sysH = height; // REMIND: Is this secure? Can client code subclass input method? if (!tcList.isEmpty() && @@ -268,6 +277,8 @@ DisplayChangedListener { } public void handleMoved(int x, int y) { + sysX = x; + sysY = y; postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED)); } @@ -505,4 +516,87 @@ DisplayChangedListener { } return false; } + + private final boolean hasWarningWindow() { + return ((Window)target).getWarningString() != null; + } + + // This method is overriden at Dialog and Frame peers. + boolean isTargetUndecorated() { + return true; + } + + private volatile int sysX = 0; + private volatile int sysY = 0; + private volatile int sysW = 0; + private volatile int sysH = 0; + + Rectangle constrainBounds(int x, int y, int width, int height) { + // We don't restrict the setBounds() operation if the code is trusted. + if (!hasWarningWindow()) { + return new Rectangle(x, y, width, height); + } + + int newX = x; + int newY = y; + int newW = width; + int newH = height; + + GraphicsConfiguration gc = ((Window)target).getGraphicsConfiguration(); + Rectangle sB = gc.getBounds(); + Insets sIn = ((Window)target).getToolkit().getScreenInsets(gc); + + int screenW = sB.width - sIn.left - sIn.right; + int screenH = sB.height - sIn.top - sIn.bottom; + + // If it's undecorated or is not currently visible, + // then check each point is within the visible part of the screen + if (!target.isVisible() || isTargetUndecorated()) { + int screenX = sB.x + sIn.left; + int screenY = sB.y + sIn.top; + + // First make sure the size is withing the visible part of the screen + if (newW > screenW) { + newW = screenW; + } + + if (newH > screenH) { + newH = screenH; + } + + // Tweak the location if needed + if (newX < screenX) { + newX = screenX; + } else if (newX + newW > screenX + screenW) { + newX = screenX + screenW - newW; + } + + if (newY < screenY) { + newY = screenY; + } else if (newY + newH > screenY + screenH) { + newY = screenY + screenH - newH; + } + } else { + int maxW = Math.max(screenW, sysW); + int maxH = Math.max(screenH, sysH); + + // Make sure the size is withing the visible part of the screen + // OR is less that the current size of the window. + if (newW > maxW) { + newW = maxW; + } + + if (newH > maxH) { + newH = maxH; + } + } + + return new Rectangle(newX, newY, newW, newH); + } + + public void setBounds(int x, int y, int width, int height, int op) { + Rectangle newBounds = constrainBounds(x, y, width, height); + super.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height, op); + } + } diff --git a/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java b/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java index 2514a2fffc013ef07a0be89a34e97ceaaeec8793..f56a159294e24a0747d15ebc1ad87b9fff3c7147 100644 --- a/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java +++ b/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java @@ -217,8 +217,7 @@ class DevPollArrayWrapper { Updator u = null; while ((u = updateList.poll()) != null) { // First add pollfd struct to clear out this fd - putPollFD(updatePollArray, index, u.fd, - (short)POLLREMOVE); + putPollFD(updatePollArray, index, u.fd, POLLREMOVE); index++; // Now add pollfd to update this fd, if necessary if (u.mask != POLLREMOVE) { diff --git a/src/solaris/classes/sun/security/provider/NativePRNG.java b/src/solaris/classes/sun/security/provider/NativePRNG.java index 8e25f2560683db09cb049d73ac2ed837e7d90a11..cfa19f8f47895167e924a347e1526384cf2cc47f 100644 --- a/src/solaris/classes/sun/security/provider/NativePRNG.java +++ b/src/solaris/classes/sun/security/provider/NativePRNG.java @@ -71,8 +71,9 @@ public final class NativePRNG extends SecureRandomSpi { private static final RandomIO INSTANCE = initIO(); private static RandomIO initIO() { - Object o = AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged( + new PrivilegedAction() { + public RandomIO run() { File randomFile = new File(NAME_RANDOM); if (randomFile.exists() == false) { return null; @@ -88,7 +89,6 @@ public final class NativePRNG extends SecureRandomSpi { } } }); - return (RandomIO)o; } // return whether the NativePRNG is available diff --git a/src/solaris/hpi/native_threads/src/sys_api_td.c b/src/solaris/hpi/native_threads/src/sys_api_td.c index 37b098aae4390f9fe514fd64c075f470f5bae4aa..c61324a4d0fef03eec65baa6a8b41d4e6b1ce759 100644 --- a/src/solaris/hpi/native_threads/src/sys_api_td.c +++ b/src/solaris/hpi/native_threads/src/sys_api_td.c @@ -63,15 +63,8 @@ #define CLOSEIO #endif /* NO_INTERRUPTIBLE_IO */ -/* - * Linux does not define rlim_t (solaris - * does). THIS IS PROBABLY NOT THE RIGHT THING TO DO, so - * somebody please fix this. - */ -#ifdef __linux__ -typedef int rlim_t ; -#endif - +/* Get typedef for rlim_t */ +#include #ifdef CLOSEIO diff --git a/src/solaris/native/java/io/FileOutputStream_md.c b/src/solaris/native/java/io/FileOutputStream_md.c index 3bee404589cdefd6b2c9258a4d883c865973cd14..4fc5904660be2862d5f5524172edbbf22a724825 100644 --- a/src/solaris/native/java/io/FileOutputStream_md.c +++ b/src/solaris/native/java/io/FileOutputStream_md.c @@ -53,13 +53,10 @@ Java_java_io_FileOutputStream_initIDs(JNIEnv *env, jclass fdClass) { */ JNIEXPORT void JNICALL -Java_java_io_FileOutputStream_open(JNIEnv *env, jobject this, jstring path) { - fileOpen(env, this, path, fos_fd, O_WRONLY | O_CREAT | O_TRUNC); -} - -JNIEXPORT void JNICALL -Java_java_io_FileOutputStream_openAppend(JNIEnv *env, jobject this, jstring path) { - fileOpen(env, this, path, fos_fd, O_WRONLY | O_CREAT | O_APPEND); +Java_java_io_FileOutputStream_open(JNIEnv *env, jobject this, + jstring path, jboolean append) { + fileOpen(env, this, path, fos_fd, + O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC)); } JNIEXPORT void JNICALL diff --git a/src/solaris/native/java/lang/UNIXProcess_md.c b/src/solaris/native/java/lang/UNIXProcess_md.c index a14496e7456d1ea05c623d86e81f88a0d2cb4b56..8390a2baad58eb67980c471fcaae15a5ebe328d3 100644 --- a/src/solaris/native/java/lang/UNIXProcess_md.c +++ b/src/solaris/native/java/lang/UNIXProcess_md.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1995-2008 Sun Microsystems, 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 @@ -479,6 +479,37 @@ closeSafely(int fd) close(fd); } +/* + * Reads nbyte bytes from file descriptor fd into buf, + * The read operation is retried in case of EINTR or partial reads. + * + * Returns number of bytes read (normally nbyte, but may be less in + * case of EOF). In case of read errors, returns -1 and sets errno. + */ +static ssize_t +readFully(int fd, void *buf, size_t nbyte) +{ + ssize_t remaining = nbyte; + for (;;) { + ssize_t n = read(fd, buf, remaining); + if (n == 0) { + return nbyte - remaining; + } else if (n > 0) { + remaining -= n; + if (remaining <= 0) + return nbyte; + /* We were interrupted in the middle of reading the bytes. + * Unlikely, but possible. */ + buf = (void *) (((char *)buf) + n); + } else if (errno == EINTR) { + /* Strange signals like SIGJVM1 are possible at any time. + * See http://www.dreamsongs.com/WorseIsBetter.html */ + } else { + return -1; + } + } +} + #ifndef __solaris__ #undef fork1 #define fork1() fork() @@ -491,10 +522,8 @@ Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env, jbyteArray argBlock, jint argc, jbyteArray envBlock, jint envc, jbyteArray dir, - jboolean redirectErrorStream, - jobject stdin_fd, - jobject stdout_fd, - jobject stderr_fd) + jintArray std_fds, + jboolean redirectErrorStream) { int errnum; int resultPid = -1; @@ -505,6 +534,7 @@ Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env, const char *pargBlock = getBytes(env, argBlock); const char *penvBlock = getBytes(env, envBlock); const char *pdir = getBytes(env, dir); + jint *fds = NULL; in[0] = in[1] = out[0] = out[1] = err[0] = err[1] = fail[0] = fail[1] = -1; @@ -527,9 +557,13 @@ Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env, initVectorFromBlock(envv, penvBlock, envc); } - if ((pipe(in) < 0) || - (pipe(out) < 0) || - (pipe(err) < 0) || + assert(std_fds != NULL); + fds = (*env)->GetIntArrayElements(env, std_fds, NULL); + if (fds == NULL) goto Catch; + + if ((fds[0] == -1 && pipe(in) < 0) || + (fds[1] == -1 && pipe(out) < 0) || + (fds[2] == -1 && pipe(err) < 0) || (pipe(fail) < 0)) { throwIOException(env, errno, "Bad file descriptor"); goto Catch; @@ -544,23 +578,26 @@ Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env, if (resultPid == 0) { /* Child process */ - /* Close the parent sides of the pipe. - Give the child sides of the pipes the right fileno's. + /* Close the parent sides of the pipes. Closing pipe fds here is redundant, since closeDescriptors() would do it anyways, but a little paranoia is a good thing. */ + closeSafely(in[1]); + closeSafely(out[0]); + closeSafely(err[0]); + closeSafely(fail[0]); + + /* Give the child sides of the pipes the right fileno's. */ /* Note: it is possible for in[0] == 0 */ - close(in[1]); - moveDescriptor(in[0], STDIN_FILENO); - close(out[0]); - moveDescriptor(out[1], STDOUT_FILENO); - close(err[0]); + moveDescriptor(in[0] != -1 ? in[0] : fds[0], STDIN_FILENO); + moveDescriptor(out[1]!= -1 ? out[1] : fds[1], STDOUT_FILENO); + if (redirectErrorStream) { - close(err[1]); + closeSafely(err[1]); dup2(STDOUT_FILENO, STDERR_FILENO); } else { - moveDescriptor(err[1], STDERR_FILENO); + moveDescriptor(err[1] != -1 ? err[1] : fds[2], STDERR_FILENO); } - close(fail[0]); + moveDescriptor(fail[1], FAIL_FILENO); /* close everything */ @@ -600,15 +637,21 @@ Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env, /* parent process */ close(fail[1]); fail[1] = -1; /* See: WhyCantJohnnyExec */ - if (read(fail[0], &errnum, sizeof(errnum)) != 0) { + + switch (readFully(fail[0], &errnum, sizeof(errnum))) { + case 0: break; /* Exec succeeded */ + case sizeof(errnum): waitpid(resultPid, NULL, 0); throwIOException(env, errnum, "Exec failed"); goto Catch; + default: + throwIOException(env, errno, "Read failed"); + goto Catch; } - (*env)->SetIntField(env, stdin_fd, IO_fd_fdID, in [1]); - (*env)->SetIntField(env, stdout_fd, IO_fd_fdID, out[0]); - (*env)->SetIntField(env, stderr_fd, IO_fd_fdID, err[0]); + fds[0] = (in [1] != -1) ? in [1] : -1; + fds[1] = (out[0] != -1) ? out[0] : -1; + fds[2] = (err[0] != -1) ? err[0] : -1; Finally: /* Always clean up the child's side of the pipes */ @@ -628,6 +671,9 @@ Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env, releaseBytes(env, envBlock, penvBlock); releaseBytes(env, dir, pdir); + if (fds != NULL) + (*env)->ReleaseIntArrayElements(env, std_fds, fds, 0); + return resultPid; Catch: diff --git a/src/solaris/native/sun/nio/ch/FileChannelImpl.c b/src/solaris/native/sun/nio/ch/FileChannelImpl.c index 897ad488e949a13f67bfec8cfd8f9f29eb7f7909..6110143de7bcf834067f9b88566e17b08cc3d899 100644 --- a/src/solaris/native/sun/nio/ch/FileChannelImpl.c +++ b/src/solaris/native/sun/nio/ch/FileChannelImpl.c @@ -31,6 +31,7 @@ #include #include "sun_nio_ch_FileChannelImpl.h" #include "java_lang_Integer.h" +#include "java_lang_Long.h" #include "nio.h" #include "nio_util.h" #include @@ -291,7 +292,11 @@ Java_sun_nio_ch_FileChannelImpl_lock0(JNIEnv *env, jobject this, jobject fdo, struct flock64 fl; fl.l_whence = SEEK_SET; - fl.l_len = (off64_t)size; + if (size == (jlong)java_lang_Long_MAX_VALUE) { + fl.l_len = (off64_t)0; + } else { + fl.l_len = (off64_t)size; + } fl.l_start = (off64_t)pos; if (shared == JNI_TRUE) { fl.l_type = F_RDLCK; @@ -325,7 +330,11 @@ Java_sun_nio_ch_FileChannelImpl_release0(JNIEnv *env, jobject this, int cmd = F_SETLK64; fl.l_whence = SEEK_SET; - fl.l_len = (off64_t)size; + if (size == (jlong)java_lang_Long_MAX_VALUE) { + fl.l_len = (off64_t)0; + } else { + fl.l_len = (off64_t)size; + } fl.l_start = (off64_t)pos; fl.l_type = F_UNLCK; lockResult = fcntl(fd, cmd, &fl); 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 40c38e0640fd27e74cfe6ea3c1875d9cd64ee5c4..ea46ea59c9aacd46aacd8956a5125d5ac3ff0d2c 100644 --- a/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c +++ b/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c @@ -123,7 +123,10 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect C_GetFunctionList = (CK_C_GetFunctionList) dlsym(hModule, getFunctionListStr); (*env)->ReleaseStringUTFChars(env, jGetFunctionList, getFunctionListStr); } - if ((C_GetFunctionList == NULL) || ((systemErrorMessage = dlerror()) != NULL)){ + if (C_GetFunctionList == NULL) { + throwIOException(env, "ERROR: C_GetFunctionList == NULL"); + return; + } else if ( (systemErrorMessage = dlerror()) != NULL ){ throwIOException(env, systemErrorMessage); return; } diff --git a/src/solaris/native/sun/tracing/dtrace/jvm_symbols_md.c b/src/solaris/native/sun/tracing/dtrace/jvm_symbols_md.c new file mode 100644 index 0000000000000000000000000000000000000000..c35586165941301b4fbb2fe0bd6edfa0b26d1c7f --- /dev/null +++ b/src/solaris/native/sun/tracing/dtrace/jvm_symbols_md.c @@ -0,0 +1,35 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +#include +#include + +#include + +#include "jvm_symbols.h" + +JvmSymbols* lookupJvmSymbols() { + JvmSymbols* syms = (JvmSymbols*)malloc(sizeof(JvmSymbols)); + if (syms != NULL) { + syms->GetVersion = (GetVersion_t) + dlsym(RTLD_DEFAULT, "JVM_DTraceGetVersion"); + syms->IsSupported = (IsSupported_t) + dlsym(RTLD_DEFAULT, "JVM_DTraceIsSupported"); + syms->Activate = (Activate_t) + dlsym(RTLD_DEFAULT, "JVM_DTraceActivate"); + syms->Dispose = (Dispose_t) + dlsym(RTLD_DEFAULT, "JVM_DTraceDispose"); + syms->IsProbeEnabled = (IsProbeEnabled_t) + dlsym(RTLD_DEFAULT, "JVM_DTraceIsProbeEnabled"); + + if ( syms->GetVersion == NULL || syms->Activate == NULL || + syms->IsProbeEnabled == NULL || syms->Dispose == NULL || + syms->IsSupported == NULL) { + free(syms); + syms = NULL; + } + } + return syms; +} diff --git a/src/windows/bin/java_md.c b/src/windows/bin/java_md.c index 2e1c787838d1d1956fab5a8569352889fd0ee069..f252e0b1b3821815d3612a689ccb71fa5efabebe 100644 --- a/src/windows/bin/java_md.c +++ b/src/windows/bin/java_md.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "java.h" @@ -52,11 +53,6 @@ static jboolean GetJREPath(char *path, jint pathsize); static jboolean _isjavaw = JNI_FALSE; -void -SetJavaw() -{ - _isjavaw = JNI_TRUE; -} jboolean IsJavaw() @@ -999,3 +995,20 @@ ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void /* Linux only, empty on windows. */ void SetJavaLauncherPlatformProps() {} + +void +InitLauncher(boolean javaw) +{ + INITCOMMONCONTROLSEX icx; + + /* + * Required for javaw mode MessageBox output as well as for + * HotSpot -XX:+ShowMessageBoxOnError in java mode, an empty + * flag field is sufficient to perform the basic UI initialization. + */ + memset(&icx, 0, sizeof(INITCOMMONCONTROLSEX)); + icx.dwSize = sizeof(INITCOMMONCONTROLSEX); + InitCommonControlsEx(&icx); + _isjavaw = javaw; + JLI_SetTraceLauncher(); +} diff --git a/src/windows/classes/java/io/FileDescriptor.java b/src/windows/classes/java/io/FileDescriptor.java index c02c1619c1086e19305db9e5bb2c187fac05d7b9..f2036263e8decb16f59c095ff8b71c3b57ad4fb7 100644 --- a/src/windows/classes/java/io/FileDescriptor.java +++ b/src/windows/classes/java/io/FileDescriptor.java @@ -29,17 +29,14 @@ import java.util.concurrent.atomic.AtomicInteger; /** * Instances of the file descriptor class serve as an opaque handle - * to the underlying machine-specific structure representing an open - * file, an open socket, or another source or sink of bytes. The - * main practical use for a file descriptor is to create a - * FileInputStream or FileOutputStream to - * contain it. - *

        - * Applications should not create their own file descriptors. + * to the underlying machine-specific structure representing an + * open file, an open socket, or another source or sink of bytes. + * The main practical use for a file descriptor is to create a + * {@link FileInputStream} or {@link FileOutputStream} to contain it. + * + *

        Applications should not create their own file descriptors. * * @author Pavani Diwanji - * @see java.io.FileInputStream - * @see java.io.FileOutputStream * @since JDK1.0 */ public final class FileDescriptor { @@ -81,6 +78,14 @@ public final class FileDescriptor { public int get(FileDescriptor obj) { return obj.fd; } + + public void setHandle(FileDescriptor obj, long handle) { + obj.handle = handle; + } + + public long getHandle(FileDescriptor obj) { + return obj.handle; + } } ); } @@ -88,7 +93,7 @@ public final class FileDescriptor { /** * A handle to the standard input stream. Usually, this file * descriptor is not used directly, but rather via the input stream - * known as System.in. + * known as {@code System.in}. * * @see java.lang.System#in */ @@ -97,7 +102,7 @@ public final class FileDescriptor { /** * A handle to the standard output stream. Usually, this file * descriptor is not used directly, but rather via the output stream - * known as System.out. + * known as {@code System.out}. * @see java.lang.System#out */ public static final FileDescriptor out = standardStream(1); @@ -105,7 +110,7 @@ public final class FileDescriptor { /** * A handle to the standard error stream. Usually, this file * descriptor is not used directly, but rather via the output stream - * known as System.err. + * known as {@code System.err}. * * @see java.lang.System#err */ @@ -114,9 +119,9 @@ public final class FileDescriptor { /** * Tests if this file descriptor object is valid. * - * @return true if the file descriptor object represents a + * @return {@code true} if the file descriptor object represents a * valid, open file, socket, or other active I/O connection; - * false otherwise. + * {@code false} otherwise. */ public boolean valid() { return ((handle != -1) || (fd != -1)); diff --git a/src/windows/classes/java/lang/ProcessImpl.java b/src/windows/classes/java/lang/ProcessImpl.java index 9db29772571d90d6d27db22a7ff6868573ba8970..910575c44474ed18ed47bb9b7b8f594a5ff27044 100644 --- a/src/windows/classes/java/lang/ProcessImpl.java +++ b/src/windows/classes/java/lang/ProcessImpl.java @@ -25,7 +25,16 @@ package java.lang; -import java.io.*; +import java.io.IOException; +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileDescriptor; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.lang.ProcessBuilder.Redirect; /* This class is for the exclusive use of ProcessBuilder.start() to * create new processes. @@ -35,30 +44,82 @@ import java.io.*; */ final class ProcessImpl extends Process { + private static final sun.misc.JavaIOFileDescriptorAccess fdAccess + = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess(); // System-dependent portion of ProcessBuilder.start() static Process start(String cmdarray[], java.util.Map environment, String dir, + ProcessBuilder.Redirect[] redirects, boolean redirectErrorStream) throws IOException { String envblock = ProcessEnvironment.toEnvironmentBlock(environment); - return new ProcessImpl(cmdarray, envblock, dir, redirectErrorStream); + + FileInputStream f0 = null; + FileOutputStream f1 = null; + FileOutputStream f2 = null; + + try { + long[] stdHandles; + if (redirects == null) { + stdHandles = new long[] { -1L, -1L, -1L }; + } else { + stdHandles = new long[3]; + + if (redirects[0] == Redirect.PIPE) + stdHandles[0] = -1L; + else if (redirects[0] == Redirect.INHERIT) + stdHandles[0] = fdAccess.getHandle(FileDescriptor.in); + else { + f0 = new FileInputStream(redirects[0].file()); + stdHandles[0] = fdAccess.getHandle(f0.getFD()); + } + + if (redirects[1] == Redirect.PIPE) + stdHandles[1] = -1L; + else if (redirects[1] == Redirect.INHERIT) + stdHandles[1] = fdAccess.getHandle(FileDescriptor.out); + else { + f1 = redirects[1].toFileOutputStream(); + stdHandles[1] = fdAccess.getHandle(f1.getFD()); + } + + if (redirects[2] == Redirect.PIPE) + stdHandles[2] = -1L; + else if (redirects[2] == Redirect.INHERIT) + stdHandles[2] = fdAccess.getHandle(FileDescriptor.err); + else { + f2 = redirects[2].toFileOutputStream(); + stdHandles[2] = fdAccess.getHandle(f2.getFD()); + } + } + + return new ProcessImpl(cmdarray, envblock, dir, + stdHandles, redirectErrorStream); + } finally { + // In theory, close() can throw IOException + // (although it is rather unlikely to happen here) + try { if (f0 != null) f0.close(); } + finally { + try { if (f1 != null) f1.close(); } + finally { if (f2 != null) f2.close(); } + } + } + } private long handle = 0; - private FileDescriptor stdin_fd; - private FileDescriptor stdout_fd; - private FileDescriptor stderr_fd; private OutputStream stdin_stream; private InputStream stdout_stream; private InputStream stderr_stream; - private ProcessImpl(String cmd[], - String envblock, - String path, - boolean redirectErrorStream) + private ProcessImpl(final String cmd[], + final String envblock, + final String path, + final long[] stdHandles, + final boolean redirectErrorStream) throws IOException { // Win32 CreateProcess requires cmd[0] to be normalized @@ -91,25 +152,39 @@ final class ProcessImpl extends Process { } String cmdstr = cmdbuf.toString(); - stdin_fd = new FileDescriptor(); - stdout_fd = new FileDescriptor(); - stderr_fd = new FileDescriptor(); - - handle = create(cmdstr, envblock, path, redirectErrorStream, - stdin_fd, stdout_fd, stderr_fd); + handle = create(cmdstr, envblock, path, + stdHandles, redirectErrorStream); java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - stdin_stream = - new BufferedOutputStream(new FileOutputStream(stdin_fd)); - stdout_stream = - new BufferedInputStream(new FileInputStream(stdout_fd)); - stderr_stream = - new FileInputStream(stderr_fd); - return null; + new java.security.PrivilegedAction() { + public Void run() { + if (stdHandles[0] == -1L) + stdin_stream = new ProcessBuilder.NullOutputStream(); + else { + FileDescriptor stdin_fd = new FileDescriptor(); + fdAccess.setHandle(stdin_fd, stdHandles[0]); + stdin_stream = new BufferedOutputStream( + new FileOutputStream(stdin_fd)); } - }); + + if (stdHandles[1] == -1L) + stdout_stream = new ProcessBuilder.NullInputStream(); + else { + FileDescriptor stdout_fd = new FileDescriptor(); + fdAccess.setHandle(stdout_fd, stdHandles[1]); + stdout_stream = new BufferedInputStream( + new FileInputStream(stdout_fd)); + } + + if (stdHandles[2] == -1L) + stderr_stream = new ProcessBuilder.NullInputStream(); + else { + FileDescriptor stderr_fd = new FileDescriptor(); + fdAccess.setHandle(stderr_fd, stdHandles[2]); + stderr_stream = new FileInputStream(stderr_fd); + } + + return null; }}); } public OutputStream getOutputStream() { @@ -150,13 +225,30 @@ final class ProcessImpl extends Process { public void destroy() { terminateProcess(handle); } private static native void terminateProcess(long handle); + /** + * Create a process using the win32 function CreateProcess. + * + * @param cmdstr the Windows commandline + * @param envblock NUL-separated, double-NUL-terminated list of + * environment strings in VAR=VALUE form + * @param dir the working directory of the process, or null if + * inheriting the current directory from the parent process + * @param stdHandles array of windows HANDLEs. Indexes 0, 1, and + * 2 correspond to standard input, standard output and + * standard error, respectively. On input, a value of -1 + * means to create a pipe to connect child and parent + * processes. On output, a value which is not -1 is the + * parent pipe handle corresponding to the pipe which has + * been created. An element of this array is -1 on input + * if and only if it is not -1 on output. + * @param redirectErrorStream redirectErrorStream attribute + * @return the native subprocess HANDLE returned by CreateProcess + */ private static native long create(String cmdstr, String envblock, String dir, - boolean redirectErrorStream, - FileDescriptor in_fd, - FileDescriptor out_fd, - FileDescriptor err_fd) + long[] stdHandles, + boolean redirectErrorStream) throws IOException; private static native boolean closeHandle(long handle); diff --git a/src/windows/classes/java/net/DualStackPlainSocketImpl.java b/src/windows/classes/java/net/DualStackPlainSocketImpl.java index 116046603f8592cdb676615b6e78a4d94c6293fd..4e92df7f687d7c6121fec182dd56e1d571c42961 100644 --- a/src/windows/classes/java/net/DualStackPlainSocketImpl.java +++ b/src/windows/classes/java/net/DualStackPlainSocketImpl.java @@ -218,9 +218,6 @@ class DualStackPlainSocketImpl extends AbstractPlainSocketImpl return value; } - int socketGetOption1(int opt, Object iaContainerObj, FileDescriptor fd) - throws SocketException {return 0;} // un-implemented REMOVE - void socketSendUrgentData(int data) throws IOException { int nativefd = checkAndReturnNativeFD(); sendOOB(nativefd, data); diff --git a/src/windows/classes/java/net/PlainSocketImpl.java b/src/windows/classes/java/net/PlainSocketImpl.java index c65c71c670f9a192a4c9bac8dd2b8a89aab8b6e3..cde60b530878050fa00c99bca7ef6523a566271c 100644 --- a/src/windows/classes/java/net/PlainSocketImpl.java +++ b/src/windows/classes/java/net/PlainSocketImpl.java @@ -304,11 +304,6 @@ class PlainSocketImpl extends AbstractPlainSocketImpl return impl.socketGetOption(opt, iaContainerObj); } - int socketGetOption1(int opt, Object iaContainerObj, FileDescriptor fd) - throws SocketException { - return impl.socketGetOption1(opt, iaContainerObj, fd); - } - void socketSendUrgentData(int data) throws IOException { impl.socketSendUrgentData(data); } diff --git a/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java b/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java index 9475bd3f7a10e17ed845d2b7df49599e04344c35..13851124b32ce7723bc12a4f43d30a67d2c21961 100644 --- a/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java +++ b/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java @@ -199,8 +199,5 @@ class TwoStacksPlainSocketImpl extends AbstractPlainSocketImpl native int socketGetOption(int opt, Object iaContainerObj) throws SocketException; - native int socketGetOption1(int opt, Object iaContainerObj, FileDescriptor fd) - throws SocketException; - native void socketSendUrgentData(int data) throws IOException; } diff --git a/src/windows/classes/sun/awt/windows/WDialogPeer.java b/src/windows/classes/sun/awt/windows/WDialogPeer.java index 735e5f9f1356147e89b77c4c084bc28179052916..4056c4a6f65baafce0dff2bec56edd2bb6576a8b 100644 --- a/src/windows/classes/sun/awt/windows/WDialogPeer.java +++ b/src/windows/classes/sun/awt/windows/WDialogPeer.java @@ -108,11 +108,18 @@ class WDialogPeer extends WWindowPeer implements DialogPeer { } } + @Override + boolean isTargetUndecorated() { + return ((Dialog)target).isUndecorated(); + } + public void reshape(int x, int y, int width, int height) { + Rectangle newBounds = constrainBounds(x, y, width, height); + if (((Dialog)target).isUndecorated()) { - super.reshape(x,y,width,height); + super.reshape(newBounds.x, newBounds.y, newBounds.width, newBounds.height); } else { - reshapeFrame(x,y,width,height); + reshapeFrame(newBounds.x, newBounds.y, newBounds.width, newBounds.height); } } diff --git a/src/windows/classes/sun/awt/windows/WEmbeddedFramePeer.java b/src/windows/classes/sun/awt/windows/WEmbeddedFramePeer.java index 56513d30863c157263be126800923da24bef8956..8c446ff91842f8b23826e575f0a8d40ca466b0c3 100644 --- a/src/windows/classes/sun/awt/windows/WEmbeddedFramePeer.java +++ b/src/windows/classes/sun/awt/windows/WEmbeddedFramePeer.java @@ -65,4 +65,10 @@ public class WEmbeddedFramePeer extends WFramePeer { public native Rectangle getBoundsPrivate(); public native void synthesizeWmActivate(boolean doActivate); + + @Override + Rectangle constrainBounds(int x, int y, int width, int height) { + // We don't constrain the bounds of the EmbeddedFrames + return new Rectangle(x, y, width, height); + } } diff --git a/src/windows/classes/sun/awt/windows/WFramePeer.java b/src/windows/classes/sun/awt/windows/WFramePeer.java index cdf23ec7d3b7879f380bad13744e5e777f1f0d4a..2667fafe0473aedea1c8e1351ed79e0a1e53b606 100644 --- a/src/windows/classes/sun/awt/windows/WFramePeer.java +++ b/src/windows/classes/sun/awt/windows/WFramePeer.java @@ -64,11 +64,18 @@ class WFramePeer extends WWindowPeer implements FramePeer { } } + @Override + boolean isTargetUndecorated() { + return ((Frame)target).isUndecorated(); + } + public void reshape(int x, int y, int width, int height) { + Rectangle newBounds = constrainBounds(x, y, width, height); + if (((Frame)target).isUndecorated()) { - super.reshape(x,y,width,height); + super.reshape(newBounds.x, newBounds.y, newBounds.width, newBounds.height); } else { - reshapeFrame(x,y,width,height); + reshapeFrame(newBounds.x, newBounds.y, newBounds.width, newBounds.height); } } diff --git a/src/windows/classes/sun/awt/windows/WObjectPeer.java b/src/windows/classes/sun/awt/windows/WObjectPeer.java index efe00a63950d47d7dd33d9942c35fa14e9df7f99..d67329e8422cab16111554e9c0aec7caeb9eed91 100644 --- a/src/windows/classes/sun/awt/windows/WObjectPeer.java +++ b/src/windows/classes/sun/awt/windows/WObjectPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, 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 @@ -30,8 +30,12 @@ abstract class WObjectPeer { initIDs(); } - long pData; // The Windows handle for the native widget. - Object target; // The associated AWT object. + // The Windows handle for the native widget. + long pData; + // if the native peer has been destroyed + boolean destroyed = false; + // The associated AWT object. + Object target; private volatile boolean disposed; diff --git a/src/windows/classes/sun/awt/windows/WWindowPeer.java b/src/windows/classes/sun/awt/windows/WWindowPeer.java index 03fb08c7c7610c69339cb5ce50ac6d79d0e34d97..070c67dd15e9d8c5f44541a93297cf155b4abf0c 100644 --- a/src/windows/classes/sun/awt/windows/WWindowPeer.java +++ b/src/windows/classes/sun/awt/windows/WWindowPeer.java @@ -434,6 +434,97 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer { private native void nativeGrab(); private native void nativeUngrab(); + private final boolean hasWarningWindow() { + return ((Window)target).getWarningString() != null; + } + + boolean isTargetUndecorated() { + return true; + } + + // These are the peer bounds. They get updated at: + // 1. the WWindowPeer.setBounds() method. + // 2. the native code (on WM_SIZE/WM_MOVE) + private volatile int sysX = 0; + private volatile int sysY = 0; + private volatile int sysW = 0; + private volatile int sysH = 0; + + Rectangle constrainBounds(int x, int y, int width, int height) { + // We don't restrict the setBounds() operation if the code is trusted. + if (!hasWarningWindow()) { + return new Rectangle(x, y, width, height); + } + + int newX = x; + int newY = y; + int newW = width; + int newH = height; + + GraphicsConfiguration gc = ((Window)target).getGraphicsConfiguration(); + Rectangle sB = gc.getBounds(); + Insets sIn = ((Window)target).getToolkit().getScreenInsets(gc); + + int screenW = sB.width - sIn.left - sIn.right; + int screenH = sB.height - sIn.top - sIn.bottom; + + // If it's undecorated or is not currently visible + if (!((Window)target).isVisible() || isTargetUndecorated()) { + // Now check each point is within the visible part of the screen + int screenX = sB.x + sIn.left; + int screenY = sB.y + sIn.top; + + // First make sure the size is withing the visible part of the screen + if (newW > screenW) { + newW = screenW; + } + + if (newH > screenH) { + newH = screenH; + } + + // Tweak the location if needed + if (newX < screenX) { + newX = screenX; + } else if (newX + newW > screenX + screenW) { + newX = screenX + screenW - newW; + } + + if (newY < screenY) { + newY = screenY; + } else if (newY + newH > screenY + screenH) { + newY = screenY + screenH - newH; + } + } else { + int maxW = Math.max(screenW, sysW); + int maxH = Math.max(screenH, sysH); + + // Make sure the size is withing the visible part of the screen + // OR less that the current size of the window. + if (newW > maxW) { + newW = maxW; + } + + if (newH > maxH) { + newH = maxH; + } + } + + return new Rectangle(newX, newY, newW, newH); + } + + @Override + public void setBounds(int x, int y, int width, int height, int op) { + Rectangle newBounds = constrainBounds(x, y, width, height); + + sysX = newBounds.x; + sysY = newBounds.y; + sysW = newBounds.width; + sysH = newBounds.height; + + super.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height, op); + } + /* * The method maps the list of the active windows to the window's AppContext, * then the method registers ActiveWindowListener, GuiDisposedListener listeners; diff --git a/src/windows/classes/sun/security/mscapi/SunMSCAPI.java b/src/windows/classes/sun/security/mscapi/SunMSCAPI.java index b867a76e5d969411dd9a7b081131c009676b9f83..99a5165a90db2ff213729eb95ee7abc2407e4b7d 100644 --- a/src/windows/classes/sun/security/mscapi/SunMSCAPI.java +++ b/src/windows/classes/sun/security/mscapi/SunMSCAPI.java @@ -48,8 +48,8 @@ public final class SunMSCAPI extends Provider { private static final String INFO = "Sun's Microsoft Crypto API provider"; static { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { System.loadLibrary("sunmscapi"); return null; } diff --git a/src/windows/native/java/io/FileOutputStream_md.c b/src/windows/native/java/io/FileOutputStream_md.c index b5c29abe3e520c29c8c17e9f1f6714da81100c60..97862c5d2d8d21b9993a152494105a2f6bd299e9 100644 --- a/src/windows/native/java/io/FileOutputStream_md.c +++ b/src/windows/native/java/io/FileOutputStream_md.c @@ -39,8 +39,6 @@ jfieldID fos_fd; /* id for jobject 'fd' in java.io.FileOutputStream */ -jfieldID fos_append; - /************************************************************** * static methods to store field ID's in initializers */ @@ -49,7 +47,6 @@ JNIEXPORT void JNICALL Java_java_io_FileOutputStream_initIDs(JNIEnv *env, jclass fosClass) { fos_fd = (*env)->GetFieldID(env, fosClass, "fd", "Ljava/io/FileDescriptor;"); - fos_append = (*env)->GetFieldID(env, fosClass, "append", "Z"); } /************************************************************** @@ -57,45 +54,20 @@ Java_java_io_FileOutputStream_initIDs(JNIEnv *env, jclass fosClass) { */ JNIEXPORT void JNICALL -Java_java_io_FileOutputStream_open(JNIEnv *env, jobject this, jstring path) { - fileOpen(env, this, path, fos_fd, O_WRONLY | O_CREAT | O_TRUNC); -} - -JNIEXPORT void JNICALL -Java_java_io_FileOutputStream_openAppend(JNIEnv *env, jobject this, jstring path) { - fileOpen(env, this, path, fos_fd, O_WRONLY | O_CREAT | O_APPEND); +Java_java_io_FileOutputStream_open(JNIEnv *env, jobject this, + jstring path, jboolean append) { + fileOpen(env, this, path, fos_fd, + O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC)); } JNIEXPORT void JNICALL Java_java_io_FileOutputStream_write(JNIEnv *env, jobject this, jint byte) { - jboolean append = (*env)->GetBooleanField(env, this, fos_append); - FD fd = GET_FD(this, fos_fd); - if (fd == -1) { - JNU_ThrowIOException(env, "Stream Closed"); - return; - } - if (append == JNI_TRUE) { - if (IO_Lseek(fd, 0L, SEEK_END) == -1) { - JNU_ThrowIOExceptionWithLastError(env, "Append failed"); - } - } writeSingle(env, this, byte, fos_fd); } JNIEXPORT void JNICALL Java_java_io_FileOutputStream_writeBytes(JNIEnv *env, jobject this, jbyteArray bytes, jint off, jint len) { - jboolean append = (*env)->GetBooleanField(env, this, fos_append); - FD fd = GET_FD(this, fos_fd); - if (fd == -1) { - JNU_ThrowIOException(env, "Stream Closed"); - return; - } - if (append == JNI_TRUE) { - if (IO_Lseek(fd, 0L, SEEK_END) == -1) { - JNU_ThrowIOExceptionWithLastError(env, "Append failed"); - } - } writeBytes(env, this, bytes, off, len, fos_fd); } diff --git a/src/windows/native/java/io/io_util_md.c b/src/windows/native/java/io/io_util_md.c index a18894ca885dbf74dd2f2a980ab0712a7c140d10..89290c778f744216a0a6e16147ae2637612b9226 100644 --- a/src/windows/native/java/io/io_util_md.c +++ b/src/windows/native/java/io/io_util_md.c @@ -42,7 +42,7 @@ extern jboolean onNT = JNI_FALSE; -static int MAX_INPUT_EVENTS = 2000; +static DWORD MAX_INPUT_EVENTS = 2000; void initializeWindowsVersion() { @@ -190,9 +190,16 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) { jlong winFileHandleOpen(JNIEnv *env, jstring path, int flags) { + /* To implement O_APPEND, we use the strategy from + http://msdn2.microsoft.com/en-us/library/aa363858.aspx + "You can get atomic append by opening a file with + FILE_APPEND_DATA access and _without_ FILE_WRITE_DATA access. + If you do this then all writes will ignore the current file + pointer and be done at the end-of file." */ const DWORD access = - (flags & O_RDWR) ? (GENERIC_WRITE | GENERIC_READ) : + (flags & O_APPEND) ? (FILE_GENERIC_WRITE & ~FILE_WRITE_DATA) : (flags & O_WRONLY) ? GENERIC_WRITE : + (flags & O_RDWR) ? (GENERIC_READ | GENERIC_WRITE) : GENERIC_READ; const DWORD sharing = FILE_SHARE_READ | FILE_SHARE_WRITE; @@ -444,24 +451,6 @@ handleSetLength(jlong fd, jlong length) { return 0; } -int -handleFileSizeFD(jlong fd, jlong *size) -{ - DWORD sizeLow = 0; - DWORD sizeHigh = 0; - HANDLE h = (HANDLE)fd; - if (h == INVALID_HANDLE_VALUE) { - return -1; - } - sizeLow = GetFileSize(h, &sizeHigh); - if (sizeLow == ((DWORD)-1)) { - if (GetLastError() != ERROR_SUCCESS) { - return -1; - } - } - return (((jlong)sizeHigh) << 32) | sizeLow; -} - JNIEXPORT size_t handleRead(jlong fd, void *buf, jint len) @@ -513,7 +502,7 @@ handleClose(JNIEnv *env, jobject this, jfieldID fid) FD fd = GET_FD(this, fid); HANDLE h = (HANDLE)fd; - if (fd == INVALID_HANDLE_VALUE) { + if (h == INVALID_HANDLE_VALUE) { 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 fdbd5bf22e299f140d347452433b408a082af47f..bf9047d7c6527fd46f3b5571b5b002042db34a5b 100644 --- a/src/windows/native/java/io/io_util_md.h +++ b/src/windows/native/java/io/io_util_md.h @@ -38,7 +38,6 @@ 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); -int handleFileSizeFD(jlong fd, jlong *size); JNIEXPORT size_t handleRead(jlong fd, void *buf, jint len); JNIEXPORT size_t handleWrite(jlong fd, const void *buf, jint len); jint handleClose(JNIEnv *env, jobject this, jfieldID fid); diff --git a/src/windows/native/java/lang/ProcessImpl_md.c b/src/windows/native/java/lang/ProcessImpl_md.c index fd9da8e41685eae0c0451635d8043a84ea2c1aac..f6a8cad4e4b83511e70fa3515f5ffce43f30bd12 100644 --- a/src/windows/native/java/lang/ProcessImpl_md.c +++ b/src/windows/native/java/lang/ProcessImpl_md.c @@ -33,7 +33,12 @@ #include #include -#define PIPE_SIZE 4096 +/* We try to make sure that we can read and write 4095 bytes (the + * fixed limit on Linux) to the pipe on all operating systems without + * deadlock. Windows 2000 inexplicably appears to need an extra 24 + * bytes of slop to avoid deadlock. + */ +#define PIPE_SIZE (4096+24) char * extractExecutablePath(JNIEnv *env, char *source) @@ -120,7 +125,7 @@ win32Error(JNIEnv *env, const char *functionName) static void closeSafely(HANDLE handle) { - if (handle) + if (handle != INVALID_HANDLE_VALUE) CloseHandle(handle); } @@ -129,23 +134,22 @@ Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored, jstring cmd, jstring envBlock, jstring dir, - jboolean redirectErrorStream, - jobject in_fd, - jobject out_fd, - jobject err_fd) + jlongArray stdHandles, + jboolean redirectErrorStream) { - HANDLE inRead = 0; - HANDLE inWrite = 0; - HANDLE outRead = 0; - HANDLE outWrite = 0; - HANDLE errRead = 0; - HANDLE errWrite = 0; + HANDLE inRead = INVALID_HANDLE_VALUE; + HANDLE inWrite = INVALID_HANDLE_VALUE; + HANDLE outRead = INVALID_HANDLE_VALUE; + HANDLE outWrite = INVALID_HANDLE_VALUE; + HANDLE errRead = INVALID_HANDLE_VALUE; + HANDLE errWrite = INVALID_HANDLE_VALUE; SECURITY_ATTRIBUTES sa; PROCESS_INFORMATION pi; STARTUPINFO si; LPTSTR pcmd = NULL; LPCTSTR pdir = NULL; LPVOID penvBlock = NULL; + jlong *handles = NULL; jlong ret = 0; OSVERSIONINFO ver; jboolean onNT = JNI_FALSE; @@ -156,17 +160,6 @@ Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored, if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) onNT = JNI_TRUE; - sa.nLength = sizeof(sa); - sa.lpSecurityDescriptor = 0; - sa.bInheritHandle = TRUE; - - if (!(CreatePipe(&inRead, &inWrite, &sa, PIPE_SIZE) && - CreatePipe(&outRead, &outWrite, &sa, PIPE_SIZE) && - CreatePipe(&errRead, &errWrite, &sa, PIPE_SIZE))) { - win32Error(env, "CreatePipe"); - goto Catch; - } - assert(cmd != NULL); pcmd = (LPTSTR) JNU_GetStringPlatformChars(env, cmd, NULL); if (pcmd == NULL) goto Catch; @@ -184,19 +177,62 @@ Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored, if (penvBlock == NULL) goto Catch; } + assert(stdHandles != NULL); + handles = (*env)->GetLongArrayElements(env, stdHandles, NULL); + if (handles == NULL) goto Catch; + memset(&si, 0, sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = inRead; - si.hStdOutput = outWrite; - si.hStdError = redirectErrorStream ? outWrite : errWrite; - SetHandleInformation(inWrite, HANDLE_FLAG_INHERIT, FALSE); - SetHandleInformation(outRead, HANDLE_FLAG_INHERIT, FALSE); - SetHandleInformation(errRead, HANDLE_FLAG_INHERIT, FALSE); + sa.nLength = sizeof(sa); + sa.lpSecurityDescriptor = 0; + sa.bInheritHandle = TRUE; - if (redirectErrorStream) - SetHandleInformation(errWrite, HANDLE_FLAG_INHERIT, FALSE); + if (handles[0] != (jlong) -1) { + si.hStdInput = (HANDLE) handles[0]; + handles[0] = (jlong) -1; + } else { + if (! CreatePipe(&inRead, &inWrite, &sa, PIPE_SIZE)) { + win32Error(env, "CreatePipe"); + goto Catch; + } + si.hStdInput = inRead; + SetHandleInformation(inWrite, HANDLE_FLAG_INHERIT, FALSE); + handles[0] = (jlong) inWrite; + } + SetHandleInformation(si.hStdInput, HANDLE_FLAG_INHERIT, TRUE); + + if (handles[1] != (jlong) -1) { + si.hStdOutput = (HANDLE) handles[1]; + handles[1] = (jlong) -1; + } else { + if (! CreatePipe(&outRead, &outWrite, &sa, PIPE_SIZE)) { + win32Error(env, "CreatePipe"); + goto Catch; + } + si.hStdOutput = outWrite; + SetHandleInformation(outRead, HANDLE_FLAG_INHERIT, FALSE); + handles[1] = (jlong) outRead; + } + SetHandleInformation(si.hStdOutput, HANDLE_FLAG_INHERIT, TRUE); + + if (redirectErrorStream) { + si.hStdError = si.hStdOutput; + handles[2] = (jlong) -1; + } else if (handles[2] != (jlong) -1) { + si.hStdError = (HANDLE) handles[2]; + handles[2] = (jlong) -1; + } else { + if (! CreatePipe(&errRead, &errWrite, &sa, PIPE_SIZE)) { + win32Error(env, "CreatePipe"); + goto Catch; + } + si.hStdError = errWrite; + SetHandleInformation(errRead, HANDLE_FLAG_INHERIT, FALSE); + handles[2] = (jlong) errRead; + } + SetHandleInformation(si.hStdError, HANDLE_FLAG_INHERIT, TRUE); if (onNT) processFlag = CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT; @@ -232,9 +268,6 @@ Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored, CloseHandle(pi.hThread); ret = (jlong)pi.hProcess; - (*env)->SetLongField(env, in_fd, IO_handle_fdID, (jlong)inWrite); - (*env)->SetLongField(env, out_fd, IO_handle_fdID, (jlong)outRead); - (*env)->SetLongField(env, err_fd, IO_handle_fdID, (jlong)errRead); Finally: /* Always clean up the child's side of the pipes */ @@ -252,6 +285,9 @@ Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored, else JNU_ReleaseStringPlatformChars(env, dir, (char *) penvBlock); } + if (handles != NULL) + (*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0); + return ret; Catch: diff --git a/src/windows/native/java/lang/java_props_md.c b/src/windows/native/java/lang/java_props_md.c index ec0561c04e11db95e7ea9045306de8defe6877e8..7c758e5a9947bb9b38e72ad5e9d144d363520059 100644 --- a/src/windows/native/java/lang/java_props_md.c +++ b/src/windows/native/java/lang/java_props_md.c @@ -673,13 +673,13 @@ GetJavaProperties(JNIEnv* env) /* OS properties */ { char buf[100]; - OSVERSIONINFO ver; + OSVERSIONINFOEX ver; ver.dwOSVersionInfoSize = sizeof(ver); - GetVersionEx(&ver); + GetVersionEx((OSVERSIONINFO *) &ver); /* * From msdn page on OSVERSIONINFOEX, current as of this - * writing decoding of dwMajorVersion and dwMinorVersion. + * writing, decoding of dwMajorVersion and dwMinorVersion. * * Operating system dwMajorVersion dwMinorVersion * ================== ============== ============== @@ -692,7 +692,7 @@ GetJavaProperties(JNIEnv* env) * Windows 2000 5 0 * Windows XP 5 1 * Windows Server 2003 family 5 2 - * Windows Vista 6 0 + * Windows Vista family 6 0 * * This mapping will presumably be augmented as new Windows * versions are released. @@ -724,7 +724,20 @@ GetJavaProperties(JNIEnv* env) default: sprops.os_name = "Windows NT (unknown)"; break; } } else if (ver.dwMajorVersion == 6) { - sprops.os_name = "Windows Vista"; + /* + * From MSDN OSVERSIONINFOEX documentation: + * + * "Because the version numbers for Windows Server 2008 + * and Windows Vista are identical, you must also test + * whether the wProductType member is VER_NT_WORKSTATION. + * If wProductType is VER_NT_WORKSTATION, the operating + * system is Windows Vista; otherwise, it is Windows + * Server 2008." + */ + if (ver.wProductType == VER_NT_WORKSTATION) + sprops.os_name = "Windows Vista"; + else + sprops.os_name = "Windows Server 2008"; } else { sprops.os_name = "Windows NT (unknown)"; } diff --git a/src/windows/native/sun/net/www/protocol/http/NTLMAuthSequence.c b/src/windows/native/sun/net/www/protocol/http/NTLMAuthSequence.c index 29c0a2b3b70e31e0cf8c937df6f3a5d473efd778..580e2fabadb6a5c000069b46cf114245b24e924c 100644 --- a/src/windows/native/sun/net/www/protocol/http/NTLMAuthSequence.c +++ b/src/windows/native/sun/net/www/protocol/http/NTLMAuthSequence.c @@ -36,6 +36,8 @@ #include #include +#include "jni_util.h" + #define SECURITY_WIN32 #include "sspi.h" #include "issperr.h" @@ -52,7 +54,7 @@ static INITIALIZE_SECURITY_CONTEXT_FN pInitializeSecurityContext; static COMPLETE_AUTH_TOKEN_FN pCompleteAuthToken; static DELETE_SECURITY_CONTEXT_FN pDeleteSecurityContext; -static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle, SecBufferDesc OutBuffDesc); +static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle); static jfieldID ntlm_ctxHandleID; static jfieldID ntlm_crdHandleID; @@ -117,22 +119,36 @@ JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_NTLMAuthSequence_getCrede { SEC_WINNT_AUTH_IDENTITY AuthId; SEC_WINNT_AUTH_IDENTITY * pAuthId; - CHAR *pUser = 0; - CHAR *pDomain = 0; - CHAR *pPassword = 0; + const CHAR *pUser = 0; + const CHAR *pDomain = 0; + const CHAR *pPassword = 0; CredHandle *pCred; TimeStamp ltime; jboolean isCopy; SECURITY_STATUS ss; if (user != 0) { - pUser = (CHAR *)(*env)->GetStringUTFChars(env, user, &isCopy); + pUser = JNU_GetStringPlatformChars(env, user, &isCopy); + if (pUser == NULL) + return 0; // pending Exception } if (domain != 0) { - pDomain = (CHAR *)(*env)->GetStringUTFChars(env, domain, &isCopy); + pDomain = JNU_GetStringPlatformChars(env, domain, &isCopy); + if (pDomain == NULL) { + if (pUser != NULL) + JNU_ReleaseStringPlatformChars(env, user, pUser); + return 0; // pending Exception + } } if (password != 0) { - pPassword = (CHAR *)(*env)->GetStringUTFChars(env, password, &isCopy); + pPassword = JNU_GetStringPlatformChars(env, password, &isCopy); + if (pPassword == NULL) { + if(pUser != NULL) + JNU_ReleaseStringPlatformChars(env, user, pUser); + if(pDomain != NULL) + JNU_ReleaseStringPlatformChars(env, domain, pDomain); + return 0; // pending Exception + } } pCred = (CredHandle *)malloc(sizeof (CredHandle)); @@ -167,6 +183,14 @@ JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_NTLMAuthSequence_getCrede pCred, <ime ); + /* Release resources held by JNU_GetStringPlatformChars */ + if (pUser != NULL) + JNU_ReleaseStringPlatformChars(env, user, pUser); + if (pPassword != NULL) + JNU_ReleaseStringPlatformChars(env, password, pPassword); + if (pDomain != NULL) + JNU_ReleaseStringPlatformChars(env, domain, pDomain); + if (ss == 0) { return (jlong) pCred; } else { @@ -181,7 +205,6 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_NTLMAuthSequence_get VOID *pInput = 0; DWORD inputLen; CHAR buffOut[512]; - DWORD pcbBuffOut; jboolean isCopy; SECURITY_STATUS ss; SecBufferDesc OutBuffDesc; @@ -247,7 +270,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_NTLMAuthSequence_get } if (ss < 0) { - endSequence (pCred, pCtx, OutBuffDesc); + endSequence (pCred, pCtx); return 0; } @@ -255,7 +278,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_NTLMAuthSequence_get ss = pCompleteAuthToken( pCtx, &OutBuffDesc ); if (ss < 0) { - endSequence (pCred, pCtx, OutBuffDesc); + endSequence (pCred, pCtx); return 0; } } @@ -265,25 +288,23 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_NTLMAuthSequence_get (*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer, OutSecBuff.pvBuffer); if (lastToken != 0) // 2nd stage - endSequence (pCred, pCtx, OutBuffDesc); + endSequence (pCred, pCtx); result = ret; } if ((ss != SEC_I_CONTINUE_NEEDED) && (ss == SEC_I_COMPLETE_AND_CONTINUE)) { - endSequence (pCred, pCtx, OutBuffDesc); + endSequence (pCred, pCtx); } return result; } -static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle, SecBufferDesc OutBuffDesc) { +static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle) { if (credHand != 0) { pFreeCredentialsHandle (credHand); free (credHand); } - pFreeContextBuffer (&OutBuffDesc); - if (ctxHandle != 0) { pDeleteSecurityContext(ctxHandle); free (ctxHandle); diff --git a/src/windows/native/sun/security/krb5/NativeCreds.c b/src/windows/native/sun/security/krb5/NativeCreds.c index 879dab473880822c42438554c7a2df65bbc548bf..5d2365a415a92040471b617eb3882eab1529a2bd 100644 --- a/src/windows/native/sun/security/krb5/NativeCreds.c +++ b/src/windows/native/sun/security/krb5/NativeCreds.c @@ -88,9 +88,9 @@ VOID ShowNTError(LPSTR,NTSTATUS); VOID InitUnicodeString( - PUNICODE_STRING DestinationString, + PUNICODE_STRING DestinationString, PCWSTR SourceString OPTIONAL - ); +); jobject BuildTicket(JNIEnv *env, PUCHAR encodedTicket, ULONG encodedTicketSize); @@ -108,215 +108,215 @@ jobject BuildKerberosTime(JNIEnv *env, PLARGE_INTEGER kerbtime); */ JNIEXPORT jint JNICALL JNI_OnLoad( - JavaVM *jvm, - void *reserved) { - - jclass cls; - JNIEnv *env; - - if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2)) { - return JNI_EVERSION; /* JNI version not supported */ - } - - cls = (*env)->FindClass(env,"sun/security/krb5/internal/Ticket"); - - if (cls == NULL) { - printf("Couldn't find Ticket\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found Ticket\n"); - #endif /* DEBUG */ + JavaVM *jvm, + void *reserved) { - ticketClass = (*env)->NewWeakGlobalRef(env,cls); - if (ticketClass == NULL) { - return JNI_ERR; - } - #ifdef DEBUG - printf("Made NewWeakGlobalRef\n"); - #endif /* DEBUG */ - - cls = (*env)->FindClass(env, "sun/security/krb5/PrincipalName"); + jclass cls; + JNIEnv *env; - if (cls == NULL) { - printf("Couldn't find PrincipalName\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found PrincipalName\n"); - #endif /* DEBUG */ - - principalNameClass = (*env)->NewWeakGlobalRef(env,cls); - if (principalNameClass == NULL) { - return JNI_ERR; - } - #ifdef DEBUG - printf("Made NewWeakGlobalRef\n"); - #endif /* DEBUG */ - - cls = (*env)->FindClass(env,"sun/security/util/DerValue"); + if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2)) { + return JNI_EVERSION; /* JNI version not supported */ + } - if (cls == NULL) { - printf("Couldn't find DerValue\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found DerValue\n"); - #endif /* DEBUG */ + cls = (*env)->FindClass(env,"sun/security/krb5/internal/Ticket"); - derValueClass = (*env)->NewWeakGlobalRef(env,cls); - if (derValueClass == NULL) { - return JNI_ERR; - } - #ifdef DEBUG - printf("Made NewWeakGlobalRef\n"); - #endif /* DEBUG */ + if (cls == NULL) { + printf("Couldn't find Ticket\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found Ticket\n"); + #endif /* DEBUG */ - cls = (*env)->FindClass(env,"sun/security/krb5/EncryptionKey"); + ticketClass = (*env)->NewWeakGlobalRef(env,cls); + if (ticketClass == NULL) { + return JNI_ERR; + } + #ifdef DEBUG + printf("Made NewWeakGlobalRef\n"); + #endif /* DEBUG */ - if (cls == NULL) { - printf("Couldn't find EncryptionKey\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found EncryptionKey\n"); - #endif /* DEBUG */ + cls = (*env)->FindClass(env, "sun/security/krb5/PrincipalName"); - encryptionKeyClass = (*env)->NewWeakGlobalRef(env,cls); - if (encryptionKeyClass == NULL) { - return JNI_ERR; - } - #ifdef DEBUG - printf("Made NewWeakGlobalRef\n"); - #endif /* DEBUG */ + if (cls == NULL) { + printf("Couldn't find PrincipalName\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found PrincipalName\n"); + #endif /* DEBUG */ - cls = (*env)->FindClass(env,"sun/security/krb5/internal/TicketFlags"); + principalNameClass = (*env)->NewWeakGlobalRef(env,cls); + if (principalNameClass == NULL) { + return JNI_ERR; + } + #ifdef DEBUG + printf("Made NewWeakGlobalRef\n"); + #endif /* DEBUG */ - if (cls == NULL) { - printf("Couldn't find TicketFlags\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found TicketFlags\n"); - #endif /* DEBUG */ + cls = (*env)->FindClass(env,"sun/security/util/DerValue"); - ticketFlagsClass = (*env)->NewWeakGlobalRef(env,cls); - if (ticketFlagsClass == NULL) { - return JNI_ERR; - } - #ifdef DEBUG - printf("Made NewWeakGlobalRef\n"); - #endif /* DEBUG */ + if (cls == NULL) { + printf("Couldn't find DerValue\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found DerValue\n"); + #endif /* DEBUG */ - cls = (*env)->FindClass(env,"sun/security/krb5/internal/KerberosTime"); + derValueClass = (*env)->NewWeakGlobalRef(env,cls); + if (derValueClass == NULL) { + return JNI_ERR; + } + #ifdef DEBUG + printf("Made NewWeakGlobalRef\n"); + #endif /* DEBUG */ - if (cls == NULL) { - printf("Couldn't find KerberosTime\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found KerberosTime\n"); - #endif /* DEBUG */ + cls = (*env)->FindClass(env,"sun/security/krb5/EncryptionKey"); - kerberosTimeClass = (*env)->NewWeakGlobalRef(env,cls); - if (kerberosTimeClass == NULL) { - return JNI_ERR; - } - #ifdef DEBUG - printf("Made NewWeakGlobalRef\n"); - #endif /* DEBUG */ + if (cls == NULL) { + printf("Couldn't find EncryptionKey\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found EncryptionKey\n"); + #endif /* DEBUG */ - cls = (*env)->FindClass(env,"java/lang/String"); + encryptionKeyClass = (*env)->NewWeakGlobalRef(env,cls); + if (encryptionKeyClass == NULL) { + return JNI_ERR; + } + #ifdef DEBUG + printf("Made NewWeakGlobalRef\n"); + #endif /* DEBUG */ - if (cls == NULL) { - printf("Couldn't find String\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found String\n"); - #endif /* DEBUG */ + cls = (*env)->FindClass(env,"sun/security/krb5/internal/TicketFlags"); - javaLangStringClass = (*env)->NewWeakGlobalRef(env,cls); - if (javaLangStringClass == NULL) { - return JNI_ERR; - } - #ifdef DEBUG - printf("Made NewWeakGlobalRef\n"); - #endif /* DEBUG */ + if (cls == NULL) { + printf("Couldn't find TicketFlags\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found TicketFlags\n"); + #endif /* DEBUG */ - derValueConstructor = (*env)->GetMethodID(env, derValueClass, - "", "([B)V"); - if (derValueConstructor == 0) { - printf("Couldn't find DerValue constructor\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found DerValue constructor\n"); - #endif /* DEBUG */ + ticketFlagsClass = (*env)->NewWeakGlobalRef(env,cls); + if (ticketFlagsClass == NULL) { + return JNI_ERR; + } + #ifdef DEBUG + printf("Made NewWeakGlobalRef\n"); + #endif /* DEBUG */ - ticketConstructor = (*env)->GetMethodID(env, ticketClass, - "", "(Lsun/security/util/DerValue;)V"); - if (ticketConstructor == 0) { - printf("Couldn't find Ticket constructor\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found Ticket constructor\n"); - #endif /* DEBUG */ + cls = (*env)->FindClass(env,"sun/security/krb5/internal/KerberosTime"); - principalNameConstructor = (*env)->GetMethodID(env, principalNameClass, - "", "([Ljava/lang/String;)V"); - if (principalNameConstructor == 0) { - printf("Couldn't find PrincipalName constructor\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found PrincipalName constructor\n"); - #endif /* DEBUG */ + if (cls == NULL) { + printf("Couldn't find KerberosTime\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found KerberosTime\n"); + #endif /* DEBUG */ - encryptionKeyConstructor = (*env)->GetMethodID(env, encryptionKeyClass, - "", "(I[B)V"); - if (encryptionKeyConstructor == 0) { - printf("Couldn't find EncryptionKey constructor\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found EncryptionKey constructor\n"); - #endif /* DEBUG */ + kerberosTimeClass = (*env)->NewWeakGlobalRef(env,cls); + if (kerberosTimeClass == NULL) { + return JNI_ERR; + } + #ifdef DEBUG + printf("Made NewWeakGlobalRef\n"); + #endif /* DEBUG */ - ticketFlagsConstructor = (*env)->GetMethodID(env, ticketFlagsClass, - "", "(I[B)V"); - if (ticketFlagsConstructor == 0) { - printf("Couldn't find TicketFlags constructor\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found TicketFlags constructor\n"); - #endif /* DEBUG */ + cls = (*env)->FindClass(env,"java/lang/String"); - kerberosTimeConstructor = (*env)->GetMethodID(env, kerberosTimeClass, - "", "(Ljava/lang/String;)V"); - if (kerberosTimeConstructor == 0) { - printf("Couldn't find KerberosTime constructor\n"); - return JNI_ERR; - } - #ifdef DEBUG - printf("Found KerberosTime constructor\n"); - #endif /* DEBUG */ + if (cls == NULL) { + printf("Couldn't find String\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found String\n"); + #endif /* DEBUG */ - // load the setRealm method in PrincipalName - setRealmMethod = (*env)->GetMethodID(env, principalNameClass, - "setRealm", "(Ljava/lang/String;)V"); - if (setRealmMethod == 0) { - printf("Couldn't find setRealm in PrincipalName\n"); - return JNI_ERR; - } + javaLangStringClass = (*env)->NewWeakGlobalRef(env,cls); + if (javaLangStringClass == NULL) { + return JNI_ERR; + } + #ifdef DEBUG + printf("Made NewWeakGlobalRef\n"); + #endif /* DEBUG */ + + derValueConstructor = (*env)->GetMethodID(env, derValueClass, + "", "([B)V"); + if (derValueConstructor == 0) { + printf("Couldn't find DerValue constructor\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found DerValue constructor\n"); + #endif /* DEBUG */ + + ticketConstructor = (*env)->GetMethodID(env, ticketClass, + "", "(Lsun/security/util/DerValue;)V"); + if (ticketConstructor == 0) { + printf("Couldn't find Ticket constructor\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found Ticket constructor\n"); + #endif /* DEBUG */ + + principalNameConstructor = (*env)->GetMethodID(env, principalNameClass, + "", "([Ljava/lang/String;)V"); + if (principalNameConstructor == 0) { + printf("Couldn't find PrincipalName constructor\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found PrincipalName constructor\n"); + #endif /* DEBUG */ + + encryptionKeyConstructor = (*env)->GetMethodID(env, encryptionKeyClass, + "", "(I[B)V"); + if (encryptionKeyConstructor == 0) { + printf("Couldn't find EncryptionKey constructor\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found EncryptionKey constructor\n"); + #endif /* DEBUG */ + + ticketFlagsConstructor = (*env)->GetMethodID(env, ticketFlagsClass, + "", "(I[B)V"); + if (ticketFlagsConstructor == 0) { + printf("Couldn't find TicketFlags constructor\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found TicketFlags constructor\n"); + #endif /* DEBUG */ + + kerberosTimeConstructor = (*env)->GetMethodID(env, kerberosTimeClass, + "", "(Ljava/lang/String;)V"); + if (kerberosTimeConstructor == 0) { + printf("Couldn't find KerberosTime constructor\n"); + return JNI_ERR; + } + #ifdef DEBUG + printf("Found KerberosTime constructor\n"); + #endif /* DEBUG */ + + // load the setRealm method in PrincipalName + setRealmMethod = (*env)->GetMethodID(env, principalNameClass, + "setRealm", "(Ljava/lang/String;)V"); + if (setRealmMethod == 0) { + printf("Couldn't find setRealm in PrincipalName\n"); + return JNI_ERR; + } - #ifdef DEBUG - printf("Finished OnLoad processing\n"); - #endif /* DEBUG */ + #ifdef DEBUG + printf("Finished OnLoad processing\n"); + #endif /* DEBUG */ - return JNI_VERSION_1_2; + return JNI_VERSION_1_2; } /* @@ -325,38 +325,38 @@ JNIEXPORT jint JNICALL JNI_OnLoad( */ JNIEXPORT void JNICALL JNI_OnUnload( - JavaVM *jvm, - void *reserved) { + JavaVM *jvm, + void *reserved) { - JNIEnv *env; + JNIEnv *env; - if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2)) { - return; /* Nothing else we can do */ - } + if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2)) { + return; /* Nothing else we can do */ + } - if (ticketClass != NULL) { - (*env)->DeleteWeakGlobalRef(env,ticketClass); - } - if (derValueClass != NULL) { - (*env)->DeleteWeakGlobalRef(env,derValueClass); - } - if (principalNameClass != NULL) { - (*env)->DeleteWeakGlobalRef(env,principalNameClass); - } - if (encryptionKeyClass != NULL) { - (*env)->DeleteWeakGlobalRef(env,encryptionKeyClass); - } - if (ticketFlagsClass != NULL) { - (*env)->DeleteWeakGlobalRef(env,ticketFlagsClass); - } - if (kerberosTimeClass != NULL) { - (*env)->DeleteWeakGlobalRef(env,kerberosTimeClass); - } - if (javaLangStringClass != NULL) { - (*env)->DeleteWeakGlobalRef(env,javaLangStringClass); - } + if (ticketClass != NULL) { + (*env)->DeleteWeakGlobalRef(env,ticketClass); + } + if (derValueClass != NULL) { + (*env)->DeleteWeakGlobalRef(env,derValueClass); + } + if (principalNameClass != NULL) { + (*env)->DeleteWeakGlobalRef(env,principalNameClass); + } + if (encryptionKeyClass != NULL) { + (*env)->DeleteWeakGlobalRef(env,encryptionKeyClass); + } + if (ticketFlagsClass != NULL) { + (*env)->DeleteWeakGlobalRef(env,ticketFlagsClass); + } + if (kerberosTimeClass != NULL) { + (*env)->DeleteWeakGlobalRef(env,kerberosTimeClass); + } + if (javaLangStringClass != NULL) { + (*env)->DeleteWeakGlobalRef(env,javaLangStringClass); + } - return; + return; } /* @@ -365,31 +365,31 @@ JNIEXPORT void JNICALL JNI_OnUnload( * Signature: ()Lsun/security/krb5/Credentials; */ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativeCreds( - JNIEnv *env, - jclass krbcredsClass) { - - KERB_QUERY_TKT_CACHE_REQUEST CacheRequest; - PKERB_RETRIEVE_TKT_RESPONSE TktCacheResponse = NULL; - PKERB_RETRIEVE_TKT_REQUEST pTicketRequest = NULL; - PKERB_RETRIEVE_TKT_RESPONSE pTicketResponse = NULL; - NTSTATUS Status, SubStatus; - ULONG requestSize = 0; - ULONG responseSize = 0; - ULONG rspSize = 0; - HANDLE LogonHandle = NULL; - ULONG PackageId; - jobject ticket, clientPrincipal, targetPrincipal, encryptionKey; - jobject ticketFlags, startTime, endTime, krbCreds = NULL; - jobject authTime, renewTillTime, hostAddresses = NULL; - KERB_EXTERNAL_TICKET *msticket; - int ignore_cache = 0; - FILETIME Now, EndTime, LocalEndTime; - - while (TRUE) { + JNIEnv *env, + jclass krbcredsClass) { + + KERB_QUERY_TKT_CACHE_REQUEST CacheRequest; + PKERB_RETRIEVE_TKT_RESPONSE TktCacheResponse = NULL; + PKERB_RETRIEVE_TKT_REQUEST pTicketRequest = NULL; + PKERB_RETRIEVE_TKT_RESPONSE pTicketResponse = NULL; + NTSTATUS Status, SubStatus; + ULONG requestSize = 0; + ULONG responseSize = 0; + ULONG rspSize = 0; + HANDLE LogonHandle = NULL; + ULONG PackageId; + jobject ticket, clientPrincipal, targetPrincipal, encryptionKey; + jobject ticketFlags, startTime, endTime, krbCreds = NULL; + jobject authTime, renewTillTime, hostAddresses = NULL; + KERB_EXTERNAL_TICKET *msticket; + int ignore_cache = 0; + FILETIME Now, EndTime, LocalEndTime; + + while (TRUE) { if (krbcredsConstructor == 0) { - krbcredsConstructor = (*env)->GetMethodID(env, krbcredsClass, "", - "(Lsun/security/krb5/internal/Ticket;Lsun/security/krb5/PrincipalName;Lsun/security/krb5/PrincipalName;Lsun/security/krb5/EncryptionKey;Lsun/security/krb5/internal/TicketFlags;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/HostAddresses;)V"); + krbcredsConstructor = (*env)->GetMethodID(env, krbcredsClass, "", + "(Lsun/security/krb5/internal/Ticket;Lsun/security/krb5/PrincipalName;Lsun/security/krb5/PrincipalName;Lsun/security/krb5/EncryptionKey;Lsun/security/krb5/internal/TicketFlags;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/KerberosTime;Lsun/security/krb5/internal/HostAddresses;)V"); if (krbcredsConstructor == 0) { printf("Couldn't find sun.security.krb5.Credentials constructor\n"); break; @@ -510,88 +510,88 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ msticket = &(pTicketResponse->Ticket); } -/* - -typedef struct _KERB_RETRIEVE_TKT_RESPONSE { - KERB_EXTERNAL_TICKET Ticket; -} KERB_RETRIEVE_TKT_RESPONSE, *PKERB_RETRIEVE_TKT_RESPONSE; - -typedef struct _KERB_EXTERNAL_TICKET { - PKERB_EXTERNAL_NAME ServiceName; - PKERB_EXTERNAL_NAME TargetName; - PKERB_EXTERNAL_NAME ClientName; - UNICODE_STRING DomainName; - UNICODE_STRING TargetDomainName; - UNICODE_STRING AltTargetDomainName; - KERB_CRYPTO_KEY SessionKey; - ULONG TicketFlags; - ULONG Flags; - LARGE_INTEGER KeyExpirationTime; - LARGE_INTEGER StartTime; - LARGE_INTEGER EndTime; - LARGE_INTEGER RenewUntil; - LARGE_INTEGER TimeSkew; - ULONG EncodedTicketSize; - PUCHAR EncodedTicket; <========== Here's the good stuff -} KERB_EXTERNAL_TICKET, *PKERB_EXTERNAL_TICKET; - -typedef struct _KERB_EXTERNAL_NAME { - SHORT NameType; - USHORT NameCount; - UNICODE_STRING Names[ANYSIZE_ARRAY]; -} KERB_EXTERNAL_NAME, *PKERB_EXTERNAL_NAME; - -typedef struct _LSA_UNICODE_STRING { - USHORT Length; - USHORT MaximumLength; - PWSTR Buffer; -} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING; - -typedef LSA_UNICODE_STRING UNICODE_STRING, *PUNICODE_STRING; - -typedef struct KERB_CRYPTO_KEY { - LONG KeyType; - ULONG Length; - PUCHAR Value; -} KERB_CRYPTO_KEY, *PKERB_CRYPTO_KEY; + /* -*/ + typedef struct _KERB_RETRIEVE_TKT_RESPONSE { + KERB_EXTERNAL_TICKET Ticket; + } KERB_RETRIEVE_TKT_RESPONSE, *PKERB_RETRIEVE_TKT_RESPONSE; + + typedef struct _KERB_EXTERNAL_TICKET { + PKERB_EXTERNAL_NAME ServiceName; + PKERB_EXTERNAL_NAME TargetName; + PKERB_EXTERNAL_NAME ClientName; + UNICODE_STRING DomainName; + UNICODE_STRING TargetDomainName; + UNICODE_STRING AltTargetDomainName; + KERB_CRYPTO_KEY SessionKey; + ULONG TicketFlags; + ULONG Flags; + LARGE_INTEGER KeyExpirationTime; + LARGE_INTEGER StartTime; + LARGE_INTEGER EndTime; + LARGE_INTEGER RenewUntil; + LARGE_INTEGER TimeSkew; + ULONG EncodedTicketSize; + PUCHAR EncodedTicket; <========== Here's the good stuff + } KERB_EXTERNAL_TICKET, *PKERB_EXTERNAL_TICKET; + + typedef struct _KERB_EXTERNAL_NAME { + SHORT NameType; + USHORT NameCount; + UNICODE_STRING Names[ANYSIZE_ARRAY]; + } KERB_EXTERNAL_NAME, *PKERB_EXTERNAL_NAME; + + typedef struct _LSA_UNICODE_STRING { + USHORT Length; + USHORT MaximumLength; + PWSTR Buffer; + } LSA_UNICODE_STRING, *PLSA_UNICODE_STRING; + + typedef LSA_UNICODE_STRING UNICODE_STRING, *PUNICODE_STRING; + + typedef struct KERB_CRYPTO_KEY { + LONG KeyType; + ULONG Length; + PUCHAR Value; + } KERB_CRYPTO_KEY, *PKERB_CRYPTO_KEY; + + */ // Build a com.sun.security.krb5.Ticket ticket = BuildTicket(env, msticket->EncodedTicket, msticket->EncodedTicketSize); if (ticket == NULL) { - break; + break; } // OK, have a Ticket, now need to get the client name clientPrincipal = BuildPrincipal(env, msticket->ClientName, msticket->TargetDomainName); // mdu if (clientPrincipal == NULL) { - break; + break; } // and the "name" of tgt targetPrincipal = BuildPrincipal(env, msticket->ServiceName, msticket->DomainName); if (targetPrincipal == NULL) { - break; + break; } // Get the encryption key encryptionKey = BuildEncryptionKey(env, &(msticket->SessionKey)); if (encryptionKey == NULL) { - break; + break; } // and the ticket flags ticketFlags = BuildTicketFlags(env, &(msticket->TicketFlags)); if (ticketFlags == NULL) { - break; + break; } // Get the start time startTime = BuildKerberosTime(env, &(msticket->StartTime)); if (startTime == NULL) { - break; + break; } /* @@ -604,13 +604,13 @@ typedef struct KERB_CRYPTO_KEY { // and the end time endTime = BuildKerberosTime(env, &(msticket->EndTime)); if (endTime == NULL) { - break; + break; } // Get the renew till time renewTillTime = BuildKerberosTime(env, &(msticket->RenewUntil)); if (renewTillTime == NULL) { - break; + break; } // and now go build a KrbCreds object @@ -630,87 +630,87 @@ typedef struct KERB_CRYPTO_KEY { hostAddresses); break; - } // end of WHILE + } // end of WHILE - // clean up resources - if (TktCacheResponse != NULL) { - LsaFreeReturnBuffer(TktCacheResponse); - } - if (pTicketRequest) { - LocalFree(pTicketRequest); - } - if (pTicketResponse != NULL) { - LsaFreeReturnBuffer(pTicketResponse); - } + // clean up resources + if (TktCacheResponse != NULL) { + LsaFreeReturnBuffer(TktCacheResponse); + } + if (pTicketRequest) { + LocalFree(pTicketRequest); + } + if (pTicketResponse != NULL) { + LsaFreeReturnBuffer(pTicketResponse); + } - return krbCreds; + return krbCreds; } static NTSTATUS ConstructTicketRequest(UNICODE_STRING DomainName, PKERB_RETRIEVE_TKT_REQUEST *outRequest, ULONG *outSize) { - NTSTATUS Status; - UNICODE_STRING TargetPrefix; - USHORT TargetSize; - ULONG RequestSize; - ULONG Length; - PKERB_RETRIEVE_TKT_REQUEST pTicketRequest = NULL; + NTSTATUS Status; + UNICODE_STRING TargetPrefix; + USHORT TargetSize; + ULONG RequestSize; + ULONG Length; + PKERB_RETRIEVE_TKT_REQUEST pTicketRequest = NULL; - *outRequest = NULL; - *outSize = 0; + *outRequest = NULL; + *outSize = 0; - // - // Set up the "krbtgt/" target prefix into a UNICODE_STRING so we - // can easily concatenate it later. - // + // + // Set up the "krbtgt/" target prefix into a UNICODE_STRING so we + // can easily concatenate it later. + // - TargetPrefix.Buffer = L"krbtgt/"; - Length = (ULONG)wcslen(TargetPrefix.Buffer) * sizeof(WCHAR); - TargetPrefix.Length = (USHORT)Length; - TargetPrefix.MaximumLength = TargetPrefix.Length; + TargetPrefix.Buffer = L"krbtgt/"; + Length = (ULONG)wcslen(TargetPrefix.Buffer) * sizeof(WCHAR); + TargetPrefix.Length = (USHORT)Length; + TargetPrefix.MaximumLength = TargetPrefix.Length; - // - // We will need to concatenate the "krbtgt/" prefix and the - // Logon Session's DnsDomainName into our request's target name. - // - // Therefore, first compute the necessary buffer size for that. - // - // Note that we might theoretically have integer overflow. - // + // + // We will need to concatenate the "krbtgt/" prefix and the + // Logon Session's DnsDomainName into our request's target name. + // + // Therefore, first compute the necessary buffer size for that. + // + // Note that we might theoretically have integer overflow. + // - TargetSize = TargetPrefix.Length + DomainName.Length; + TargetSize = TargetPrefix.Length + DomainName.Length; - // - // The ticket request buffer needs to be a single buffer. That buffer - // needs to include the buffer for the target name. - // + // + // The ticket request buffer needs to be a single buffer. That buffer + // needs to include the buffer for the target name. + // - RequestSize = sizeof (*pTicketRequest) + TargetSize; + RequestSize = sizeof (*pTicketRequest) + TargetSize; - // - // Allocate the request buffer and make sure it's zero-filled. - // + // + // Allocate the request buffer and make sure it's zero-filled. + // - pTicketRequest = (PKERB_RETRIEVE_TKT_REQUEST) - LocalAlloc(LMEM_ZEROINIT, RequestSize); - if (!pTicketRequest) - return GetLastError(); + pTicketRequest = (PKERB_RETRIEVE_TKT_REQUEST) + LocalAlloc(LMEM_ZEROINIT, RequestSize); + if (!pTicketRequest) + return GetLastError(); - // - // Concatenate the target prefix with the previous reponse's - // target domain. - // + // + // Concatenate the target prefix with the previous reponse's + // target domain. + // - pTicketRequest->TargetName.Length = 0; - pTicketRequest->TargetName.MaximumLength = TargetSize; - pTicketRequest->TargetName.Buffer = (PWSTR) (pTicketRequest + 1); - Status = ConcatenateUnicodeStrings(&(pTicketRequest->TargetName), - TargetPrefix, - DomainName); - *outRequest = pTicketRequest; - *outSize = RequestSize; - return Status; + pTicketRequest->TargetName.Length = 0; + pTicketRequest->TargetName.MaximumLength = TargetSize; + pTicketRequest->TargetName.Buffer = (PWSTR) (pTicketRequest + 1); + Status = ConcatenateUnicodeStrings(&(pTicketRequest->TargetName), + TargetPrefix, + DomainName); + *outRequest = pTicketRequest; + *outSize = RequestSize; + return Status; } DWORD @@ -720,22 +720,22 @@ ConcatenateUnicodeStrings( UNICODE_STRING Source2 ) { - // - // The buffers for Source1 and Source2 cannot overlap pTarget's - // buffer. Source1.Length + Source2.Length must be <= 0xFFFF, - // otherwise we overflow... - // + // + // The buffers for Source1 and Source2 cannot overlap pTarget's + // buffer. Source1.Length + Source2.Length must be <= 0xFFFF, + // otherwise we overflow... + // - USHORT TotalSize = Source1.Length + Source2.Length; - PBYTE buffer = (PBYTE) pTarget->Buffer; + USHORT TotalSize = Source1.Length + Source2.Length; + PBYTE buffer = (PBYTE) pTarget->Buffer; - if (TotalSize > pTarget->MaximumLength) - return ERROR_INSUFFICIENT_BUFFER; + if (TotalSize > pTarget->MaximumLength) + return ERROR_INSUFFICIENT_BUFFER; - pTarget->Length = TotalSize; - memcpy(buffer, Source1.Buffer, Source1.Length); - memcpy(buffer + Source1.Length, Source2.Buffer, Source2.Length); - return ERROR_SUCCESS; + pTarget->Length = TotalSize; + memcpy(buffer, Source1.Buffer, Source1.Length); + memcpy(buffer + Source1.Length, Source2.Buffer, Source2.Length); + return ERROR_SUCCESS; } BOOL @@ -783,27 +783,27 @@ ShowLastError( DWORD dwError ) { - #define MAX_MSG_SIZE 256 - - static WCHAR szMsgBuf[MAX_MSG_SIZE]; - DWORD dwRes; - - printf("Error calling function %s: %lu\n", szAPI, dwError); - - dwRes = FormatMessage ( - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - dwError, - 0, - szMsgBuf, - MAX_MSG_SIZE, - NULL); - if (0 == dwRes) { - printf("FormatMessage failed with %d\n", GetLastError()); - // ExitProcess(EXIT_FAILURE); - } else { - printf("%S",szMsgBuf); - } + #define MAX_MSG_SIZE 256 + + static WCHAR szMsgBuf[MAX_MSG_SIZE]; + DWORD dwRes; + + printf("Error calling function %s: %lu\n", szAPI, dwError); + + dwRes = FormatMessage ( + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + dwError, + 0, + szMsgBuf, + MAX_MSG_SIZE, + NULL); + if (0 == dwRes) { + printf("FormatMessage failed with %d\n", GetLastError()); + // ExitProcess(EXIT_FAILURE); + } else { + printf("%S",szMsgBuf); + } } VOID @@ -831,189 +831,189 @@ InitUnicodeString( Length = (ULONG)wcslen( SourceString ) * sizeof( WCHAR ); DestinationString->Length = (USHORT)Length; DestinationString->MaximumLength = (USHORT)(Length + sizeof(UNICODE_NULL)); - } + } else { DestinationString->MaximumLength = 0; DestinationString->Length = 0; - } + } } jobject BuildTicket(JNIEnv *env, PUCHAR encodedTicket, ULONG encodedTicketSize) { - /* To build a Ticket, we first need to build a DerValue out of the EncodedTicket. - * But before we can do that, we need to make a byte array out of the ET. - */ - - jobject derValue, ticket; - jbyteArray ary; + /* To build a Ticket, we first need to build a DerValue out of the EncodedTicket. + * But before we can do that, we need to make a byte array out of the ET. + */ - ary = (*env)->NewByteArray(env,encodedTicketSize); - if ((*env)->ExceptionOccurred(env)) { - return (jobject) NULL; - } + jobject derValue, ticket; + jbyteArray ary; - (*env)->SetByteArrayRegion(env, ary, (jsize) 0, encodedTicketSize, - (jbyte *)encodedTicket); - if ((*env)->ExceptionOccurred(env)) { - (*env)->DeleteLocalRef(env, ary); - return (jobject) NULL; - } + ary = (*env)->NewByteArray(env,encodedTicketSize); + if ((*env)->ExceptionOccurred(env)) { + return (jobject) NULL; + } - derValue = (*env)->NewObject(env, derValueClass, derValueConstructor, ary); - if ((*env)->ExceptionOccurred(env)) { - (*env)->DeleteLocalRef(env, ary); - return (jobject) NULL; - } + (*env)->SetByteArrayRegion(env, ary, (jsize) 0, encodedTicketSize, + (jbyte *)encodedTicket); + if ((*env)->ExceptionOccurred(env)) { + (*env)->DeleteLocalRef(env, ary); + return (jobject) NULL; + } + derValue = (*env)->NewObject(env, derValueClass, derValueConstructor, ary); + if ((*env)->ExceptionOccurred(env)) { (*env)->DeleteLocalRef(env, ary); - ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, derValue); - if ((*env)->ExceptionOccurred(env)) { - (*env)->DeleteLocalRef(env, derValue); - return (jobject) NULL; - } + return (jobject) NULL; + } + + (*env)->DeleteLocalRef(env, ary); + ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, derValue); + if ((*env)->ExceptionOccurred(env)) { (*env)->DeleteLocalRef(env, derValue); - return ticket; + return (jobject) NULL; + } + (*env)->DeleteLocalRef(env, derValue); + return ticket; } // mdu jobject BuildPrincipal(JNIEnv *env, PKERB_EXTERNAL_NAME principalName, UNICODE_STRING domainName) { - /* - * To build the Principal, we need to get the names out of - * this goofy MS structure - */ - jobject principal = NULL; - jobject realmStr = NULL; - jobjectArray stringArray; - jstring tempString; - int nameCount,i; - PUNICODE_STRING scanner; - WCHAR *realm; - ULONG realmLen; - - realm = (WCHAR *) LocalAlloc(LMEM_ZEROINIT, - ((domainName.Length)*sizeof(WCHAR) + sizeof(UNICODE_NULL))); - wcsncpy(realm, domainName.Buffer, domainName.Length/sizeof(WCHAR)); - - #ifdef DEBUG - printf("Principal domain is %S\n", realm); - printf("Name type is %x\n", principalName->NameType); - printf("Name count is %x\n", principalName->NameCount); - #endif - - nameCount = principalName->NameCount; - stringArray = (*env)->NewObjectArray(env, nameCount, - javaLangStringClass, NULL); - if (stringArray == NULL) { - printf("Can't allocate String array for Principal\n"); - LocalFree(realm); - return principal; - } + /* + * To build the Principal, we need to get the names out of + * this goofy MS structure + */ + jobject principal = NULL; + jobject realmStr = NULL; + jobjectArray stringArray; + jstring tempString; + int nameCount,i; + PUNICODE_STRING scanner; + WCHAR *realm; + ULONG realmLen; + + realm = (WCHAR *) LocalAlloc(LMEM_ZEROINIT, + ((domainName.Length)*sizeof(WCHAR) + sizeof(UNICODE_NULL))); + wcsncpy(realm, domainName.Buffer, domainName.Length/sizeof(WCHAR)); + + #ifdef DEBUG + printf("Principal domain is %S\n", realm); + printf("Name type is %x\n", principalName->NameType); + printf("Name count is %x\n", principalName->NameCount); + #endif + + nameCount = principalName->NameCount; + stringArray = (*env)->NewObjectArray(env, nameCount, + javaLangStringClass, NULL); + if (stringArray == NULL) { + printf("Can't allocate String array for Principal\n"); + LocalFree(realm); + return principal; + } - for (i=0; iNames[i]); + for (i=0; iNames[i]); - // OK, got a Char array, so construct a String - tempString = (*env)->NewString(env, (const jchar*)scanner->Buffer, - scanner->Length/sizeof(WCHAR)); - // Set the String into the StringArray - (*env)->SetObjectArrayElement(env, stringArray, i, tempString); + // OK, got a Char array, so construct a String + tempString = (*env)->NewString(env, (const jchar*)scanner->Buffer, + scanner->Length/sizeof(WCHAR)); + // Set the String into the StringArray + (*env)->SetObjectArrayElement(env, stringArray, i, tempString); - // Do I have to worry about storage reclamation here? - } - principal = (*env)->NewObject(env, principalNameClass, - principalNameConstructor, stringArray); + // Do I have to worry about storage reclamation here? + } + principal = (*env)->NewObject(env, principalNameClass, + principalNameConstructor, stringArray); - // now set the realm in the principal - realmLen = (ULONG)wcslen((PWCHAR)realm); - realmStr = (*env)->NewString(env, (PWCHAR)realm, (USHORT)realmLen); - (*env)->CallVoidMethod(env, principal, setRealmMethod, realmStr); + // now set the realm in the principal + realmLen = (ULONG)wcslen((PWCHAR)realm); + realmStr = (*env)->NewString(env, (PWCHAR)realm, (USHORT)realmLen); + (*env)->CallVoidMethod(env, principal, setRealmMethod, realmStr); - // free local resources - LocalFree(realm); + // free local resources + LocalFree(realm); - return principal; + return principal; } jobject BuildEncryptionKey(JNIEnv *env, PKERB_CRYPTO_KEY cryptoKey) { - // First, need to build a byte array - jbyteArray ary; - jobject encryptionKey = NULL; - - ary = (*env)->NewByteArray(env,cryptoKey->Length); - (*env)->SetByteArrayRegion(env, ary, (jsize) 0, cryptoKey->Length, - (jbyte *)cryptoKey->Value); - if ((*env)->ExceptionOccurred(env)) { - (*env)->DeleteLocalRef(env, ary); - } else { - encryptionKey = (*env)->NewObject(env, encryptionKeyClass, - encryptionKeyConstructor, cryptoKey->KeyType, ary); - } + // First, need to build a byte array + jbyteArray ary; + jobject encryptionKey = NULL; + + ary = (*env)->NewByteArray(env,cryptoKey->Length); + (*env)->SetByteArrayRegion(env, ary, (jsize) 0, cryptoKey->Length, + (jbyte *)cryptoKey->Value); + if ((*env)->ExceptionOccurred(env)) { + (*env)->DeleteLocalRef(env, ary); + } else { + encryptionKey = (*env)->NewObject(env, encryptionKeyClass, + encryptionKeyConstructor, cryptoKey->KeyType, ary); + } - return encryptionKey; + return encryptionKey; } jobject BuildTicketFlags(JNIEnv *env, PULONG flags) { - jobject ticketFlags = NULL; - jbyteArray ary; - /* - * mdu: Convert the bytes to nework byte order before copying - * them to a Java byte array. - */ - ULONG nlflags = htonl(*flags); - - ary = (*env)->NewByteArray(env, sizeof(*flags)); - (*env)->SetByteArrayRegion(env, ary, (jsize) 0, sizeof(*flags), - (jbyte *)&nlflags); - if ((*env)->ExceptionOccurred(env)) { - (*env)->DeleteLocalRef(env, ary); - } else { - ticketFlags = (*env)->NewObject(env, ticketFlagsClass, - ticketFlagsConstructor, sizeof(*flags)*8, ary); - } + jobject ticketFlags = NULL; + jbyteArray ary; + /* + * mdu: Convert the bytes to nework byte order before copying + * them to a Java byte array. + */ + ULONG nlflags = htonl(*flags); + + ary = (*env)->NewByteArray(env, sizeof(*flags)); + (*env)->SetByteArrayRegion(env, ary, (jsize) 0, sizeof(*flags), + (jbyte *)&nlflags); + if ((*env)->ExceptionOccurred(env)) { + (*env)->DeleteLocalRef(env, ary); + } else { + ticketFlags = (*env)->NewObject(env, ticketFlagsClass, + ticketFlagsConstructor, sizeof(*flags)*8, ary); + } - return ticketFlags; + return ticketFlags; } jobject BuildKerberosTime(JNIEnv *env, PLARGE_INTEGER kerbtime) { - jobject kerberosTime = NULL; - jstring stringTime = NULL; - SYSTEMTIME systemTime; - WCHAR timeString[16]; - WCHAR month[3]; - WCHAR day[3]; - WCHAR hour[3]; - WCHAR minute[3]; - WCHAR second[3]; - - if (FileTimeToSystemTime((FILETIME *)kerbtime, &systemTime)) { -// XXX Cannot use %02.2ld, because the leading 0 is ignored for integers. -// So, print them to strings, and then print them to the master string with a -// format pattern that makes it two digits and prefix with a 0 if necessary. - swprintf( (wchar_t *)month, L"%2.2d", systemTime.wMonth); - swprintf( (wchar_t *)day, L"%2.2d", systemTime.wDay); - swprintf( (wchar_t *)hour, L"%2.2d", systemTime.wHour); - swprintf( (wchar_t *)minute, L"%2.2d", systemTime.wMinute); - swprintf( (wchar_t *)second, L"%2.2d", systemTime.wSecond); - swprintf( (wchar_t *)timeString, - L"%ld%02.2s%02.2s%02.2s%02.2s%02.2sZ", + jobject kerberosTime = NULL; + jstring stringTime = NULL; + SYSTEMTIME systemTime; + WCHAR timeString[16]; + WCHAR month[3]; + WCHAR day[3]; + WCHAR hour[3]; + WCHAR minute[3]; + WCHAR second[3]; + + if (FileTimeToSystemTime((FILETIME *)kerbtime, &systemTime)) { + // XXX Cannot use %02.2ld, because the leading 0 is ignored for integers. + // So, print them to strings, and then print them to the master string with a + // format pattern that makes it two digits and prefix with a 0 if necessary. + swprintf( (wchar_t *)month, L"%2.2d", systemTime.wMonth); + swprintf( (wchar_t *)day, L"%2.2d", systemTime.wDay); + swprintf( (wchar_t *)hour, L"%2.2d", systemTime.wHour); + swprintf( (wchar_t *)minute, L"%2.2d", systemTime.wMinute); + swprintf( (wchar_t *)second, L"%2.2d", systemTime.wSecond); + swprintf( (wchar_t *)timeString, + L"%ld%02.2s%02.2s%02.2s%02.2s%02.2sZ", systemTime.wYear, month, day, hour, minute, second ); - #ifdef DEBUG - printf("%S\n", (wchar_t *)timeString); - #endif /* DEBUG */ - stringTime = (*env)->NewString(env, timeString, - (sizeof(timeString)/sizeof(WCHAR))-1); - if (stringTime != NULL) { // everything's OK so far - kerberosTime = (*env)->NewObject(env, kerberosTimeClass, - kerberosTimeConstructor, stringTime); - } + #ifdef DEBUG + printf("%S\n", (wchar_t *)timeString); + #endif /* DEBUG */ + stringTime = (*env)->NewString(env, timeString, + (sizeof(timeString)/sizeof(WCHAR))-1); + if (stringTime != NULL) { // everything's OK so far + kerberosTime = (*env)->NewObject(env, kerberosTimeClass, + kerberosTimeConstructor, stringTime); } - return kerberosTime; + } + return kerberosTime; } diff --git a/src/windows/native/sun/tracing/dtrace/jvm_symbols_md.c b/src/windows/native/sun/tracing/dtrace/jvm_symbols_md.c new file mode 100644 index 0000000000000000000000000000000000000000..95a141c5b959692a37d009b8715a8beba4942dd2 --- /dev/null +++ b/src/windows/native/sun/tracing/dtrace/jvm_symbols_md.c @@ -0,0 +1,44 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +#include +#include +#include +#include + +#include + +#include "jvm_symbols.h" + +JvmSymbols* lookupJvmSymbols() { + JvmSymbols* syms = (JvmSymbols*)malloc(sizeof(JvmSymbols)); + if (syms != NULL) { + HINSTANCE jvm = LoadLibrary("jvm.dll"); + if (jvm == NULL) { + free(syms); + return NULL; + } + syms->GetVersion = (GetVersion_t) + GetProcAddress(jvm, "JVM_DTraceGetVersion"); + syms->IsSupported = (IsSupported_t) + GetProcAddress(jvm, "JVM_DTraceIsSupported"); + syms->Activate = (Activate_t) + GetProcAddress(jvm, "JVM_DTraceActivate"); + syms->Dispose = (Dispose_t) + GetProcAddress(jvm, "JVM_DTraceDispose"); + syms->IsProbeEnabled = (IsProbeEnabled_t) + GetProcAddress(jvm, "JVM_DTraceIsProbeEnabled"); + + (void)FreeLibrary(jvm); + if ( syms->GetVersion == NULL || syms->IsSupported == NULL || + syms->Activate == NULL || syms->Dispose == NULL || + syms->IsProbeEnabled == NULL) { + free(syms); + syms = NULL; + } + + } + return syms; +} diff --git a/src/windows/native/sun/windows/awt.h b/src/windows/native/sun/windows/awt.h index 9043367f6794b638c14164157e2605cec840e8e4..2a1d9904c9bb0f2faf3303ac6257d2734b55c503 100644 --- a/src/windows/native/sun/windows/awt.h +++ b/src/windows/native/sun/windows/awt.h @@ -1,5 +1,5 @@ /* - * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, 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 @@ -47,7 +47,7 @@ typedef AwtObject* PDATA; JNI_CHECK_NULL_GOTO(peer, "peer", where); \ pData = JNI_GET_PDATA(peer); \ if (pData == NULL) { \ - JNU_ThrowNullPointerException(env, "null pData"); \ + THROW_NULL_PDATA_IF_NOT_DESTROYED(peer); \ goto where; \ } \ } @@ -63,7 +63,7 @@ typedef AwtObject* PDATA; JNI_CHECK_NULL_RETURN(peer, "peer"); \ pData = JNI_GET_PDATA(peer); \ if (pData == NULL) { \ - JNU_ThrowNullPointerException(env, "null pData"); \ + THROW_NULL_PDATA_IF_NOT_DESTROYED(peer); \ return; \ } \ } @@ -96,7 +96,7 @@ typedef AwtObject* PDATA; JNI_CHECK_NULL_RETURN_NULL(peer, "peer"); \ pData = JNI_GET_PDATA(peer); \ if (pData == NULL) { \ - JNU_ThrowNullPointerException(env, "null pData"); \ + THROW_NULL_PDATA_IF_NOT_DESTROYED(peer); \ return 0; \ } \ } @@ -105,16 +105,27 @@ typedef AwtObject* PDATA; JNI_CHECK_NULL_RETURN_VAL(peer, "peer", val); \ pData = JNI_GET_PDATA(peer); \ if (pData == NULL) { \ - JNU_ThrowNullPointerException(env, "null pData"); \ + THROW_NULL_PDATA_IF_NOT_DESTROYED(peer); \ return val; \ } \ } +#define THROW_NULL_PDATA_IF_NOT_DESTROYED(peer) { \ + jboolean destroyed = JNI_GET_DESTROYED(peer); \ + if (destroyed != JNI_TRUE) { \ + JNU_ThrowNullPointerException(env, "null pData"); \ + } \ +} + #define JNI_GET_PDATA(peer) (PDATA) env->GetLongField(peer, AwtObject::pDataID) +#define JNI_GET_DESTROYED(peer) env->GetBooleanField(peer, AwtObject::destroyedID) #define JNI_SET_PDATA(peer, data) env->SetLongField(peer, \ - AwtObject::pDataID, \ - (jlong)data) + AwtObject::pDataID, \ + (jlong)data) +#define JNI_SET_DESTROYED(peer) env->SetBooleanField(peer, \ + AwtObject::destroyedID, \ + JNI_TRUE) /* /NEW JNI */ /* diff --git a/src/windows/native/sun/windows/awt_Component.cpp b/src/windows/native/sun/windows/awt_Component.cpp index cba88cdf8c4f2982e792128207f2beec736fad74..f58237861109137dc09672ba5c99cfae8cda3b4f 100644 --- a/src/windows/native/sun/windows/awt_Component.cpp +++ b/src/windows/native/sun/windows/awt_Component.cpp @@ -1,5 +1,5 @@ /* - * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, 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 @@ -226,6 +226,8 @@ BOOL AwtComponent::m_QueryNewPaletteCalled = FALSE; CriticalSection windowMoveLock; BOOL windowMoveLockHeld = FALSE; +int AwtComponent::sm_wheelRotationAmount = 0; + /************************************************************************ * AwtComponent methods */ @@ -2074,6 +2076,8 @@ MsgRouting AwtComponent::WmSetFocus(HWND hWndLostFocus) sm_realFocusOpposite = NULL; } + sm_wheelRotationAmount = 0; + SendFocusEvent(java_awt_event_FocusEvent_FOCUS_GAINED, hWndLostFocus); return mrDoDefault; @@ -2105,6 +2109,7 @@ MsgRouting AwtComponent::WmKillFocus(HWND hWndGotFocus) } sm_focusOwner = NULL; + sm_wheelRotationAmount = 0; SendFocusEvent(java_awt_event_FocusEvent_FOCUS_LOST, hWndGotFocus); return mrDoDefault; @@ -2190,8 +2195,11 @@ AwtComponent::AwtSetFocus() DWORD fgProcessID; ::GetWindowThreadProcessId(fgWindow, &fgProcessID); - if (fgProcessID != ::GetCurrentProcessId()) { - // fix for 6458497. we shouldn't request focus if it is out of our application. + if (fgProcessID != ::GetCurrentProcessId() + && !AwtToolkit::GetInstance().IsEmbedderProcessId(fgProcessID)) + { + // fix for 6458497. we shouldn't request focus if it is out of both + // our and embedder process. return FALSE; } } @@ -2619,9 +2627,13 @@ MsgRouting AwtComponent::WmMouseWheel(UINT flags, int x, int y, BOOL result; UINT platformLines; + sm_wheelRotationAmount += wheelRotation; + // AWT interprets wheel rotation differently than win32, so we need to // decode wheel amount. - jint newWheelRotation = wheelRotation / (-1 * WHEEL_DELTA); + jint roundedWheelRotation = sm_wheelRotationAmount / (-1 * WHEEL_DELTA); + jdouble preciseWheelRotation = (jdouble) wheelRotation / (-1 * WHEEL_DELTA); + MSG msg; if (IS_WIN95 && !IS_WIN98) { @@ -2654,7 +2666,9 @@ MsgRouting AwtComponent::WmMouseWheel(UINT flags, int x, int y, SendMouseWheelEvent(java_awt_event_MouseEvent_MOUSE_WHEEL, TimeHelper::getMessageTimeUTC(), eventPt.x, eventPt.y, GetJavaModifiers(), 0, 0, scrollType, - scrollLines, newWheelRotation, &msg); + scrollLines, roundedWheelRotation, preciseWheelRotation, &msg); + + sm_wheelRotationAmount %= WHEEL_DELTA; return mrConsume; } @@ -4986,8 +5000,8 @@ void AwtComponent::SendMouseWheelEvent(jint id, jlong when, jint x, jint y, jint modifiers, jint clickCount, jboolean popupTrigger, jint scrollType, - jint scrollAmount, jint wheelRotation, - MSG *pMsg) + jint scrollAmount, jint roundedWheelRotation, + jdouble preciseWheelRotation, MSG *pMsg) { /* Code based not so loosely on AwtComponent::SendMouseEvent */ JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); @@ -5015,7 +5029,7 @@ AwtComponent::SendMouseWheelEvent(jint id, jlong when, jint x, jint y, if (mouseWheelEventConst == NULL) { mouseWheelEventConst = env->GetMethodID(mouseWheelEventCls, "", - "(Ljava/awt/Component;IJIIIIZIII)V"); + "(Ljava/awt/Component;IJIIIIIIZIIID)V"); DASSERT(mouseWheelEventConst); } if (env->EnsureLocalCapacity(2) < 0) { @@ -5023,14 +5037,16 @@ AwtComponent::SendMouseWheelEvent(jint id, jlong when, jint x, jint y, } jobject target = GetTarget(env); DTRACE_PRINTLN("creating MWE in JNI"); + jobject mouseWheelEvent = env->NewObject(mouseWheelEventCls, mouseWheelEventConst, target, id, when, modifiers, x+insets.left, y+insets.top, + 0, 0, clickCount, popupTrigger, scrollType, scrollAmount, - wheelRotation); + roundedWheelRotation, preciseWheelRotation); if (safe_ExceptionOccurred(env)) { env->ExceptionDescribe(); env->ExceptionClear(); @@ -5400,6 +5416,7 @@ void AwtComponent::UnlinkObjects() if (m_peerObject) { env->SetLongField(m_peerObject, AwtComponent::hwndID, 0); JNI_SET_PDATA(m_peerObject, static_cast(NULL)); + JNI_SET_DESTROYED(m_peerObject); env->DeleteGlobalRef(m_peerObject); m_peerObject = NULL; } @@ -5408,7 +5425,13 @@ void AwtComponent::UnlinkObjects() void AwtComponent::Enable(BOOL bEnable) { sm_suppressFocusAndActivation = TRUE; + + if (bEnable && IsTopLevel()) { + // we should not enable blocked toplevels + bEnable = !::IsWindow(AwtWindow::GetModalBlocker(GetHWnd())); + } ::EnableWindow(GetHWnd(), bEnable); + sm_suppressFocusAndActivation = FALSE; CriticalSection::Lock l(GetLock()); VerifyState(); diff --git a/src/windows/native/sun/windows/awt_Component.h b/src/windows/native/sun/windows/awt_Component.h index cecab39830519dc9fec507c697e378393c17f539..ecc7ef5ea33daa9883b2a12dc725e8a001be1a77 100644 --- a/src/windows/native/sun/windows/awt_Component.h +++ b/src/windows/native/sun/windows/awt_Component.h @@ -392,7 +392,7 @@ public: jint modifiers, jint clickCount, jboolean popupTrigger, jint scrollType, jint scrollAmount, jint wheelRotation, - MSG *msg = NULL); + jdouble preciseWheelRotation, MSG *msg = NULL); /* * Allocate and initialize a new java.awt.event.FocusEvent, and @@ -785,7 +785,9 @@ private: int windowMoveLockPosCX; int windowMoveLockPosCY; -private: + // 6524352: support finer-resolution + static int sm_wheelRotationAmount; + /* * The association list of children's IDs and corresponding components. * Some components like Choice or List are required their sizes while diff --git a/src/windows/native/sun/windows/awt_Dialog.cpp b/src/windows/native/sun/windows/awt_Dialog.cpp index 072ed2ba65b3024c20c4326c9c80d408290bc621..0c98fc0d9fe8982974d2ced60ae9ee9df865ca93 100644 --- a/src/windows/native/sun/windows/awt_Dialog.cpp +++ b/src/windows/native/sun/windows/awt_Dialog.cpp @@ -273,6 +273,10 @@ LRESULT CALLBACK AwtDialog::MouseHookProc(int nCode, { HWND blocker = AwtWindow::GetModalBlocker(AwtComponent::GetTopLevelParentForWindow(hWnd)); HWND topMostBlocker = blocker; + HWND prevForegroundWindow = ::GetForegroundWindow(); + if (::IsWindow(blocker)) { + ::BringWindowToTop(hWnd); + } while (::IsWindow(blocker)) { topMostBlocker = blocker; ::BringWindowToTop(blocker); @@ -282,7 +286,7 @@ LRESULT CALLBACK AwtDialog::MouseHookProc(int nCode, // no beep/flash if the mouse was clicked in the taskbar menu // or the dialog is currently inactive if ((::WindowFromPoint(mhs->pt) == hWnd) && - (::GetForegroundWindow() == topMostBlocker)) + (prevForegroundWindow == topMostBlocker)) { ::MessageBeep(MB_OK); // some heuristics: 3 times x 64 milliseconds @@ -292,6 +296,7 @@ LRESULT CALLBACK AwtDialog::MouseHookProc(int nCode, ::BringWindowToTop(topMostBlocker); ::SetForegroundWindow(topMostBlocker); } + return 1; } } } diff --git a/src/windows/native/sun/windows/awt_Frame.cpp b/src/windows/native/sun/windows/awt_Frame.cpp index 0ba898419269978f557feb2fd7e974f0583fd8a6..37e8546ed49efa52a3621a2693dad6a4ee1b614b 100644 --- a/src/windows/native/sun/windows/awt_Frame.cpp +++ b/src/windows/native/sun/windows/awt_Frame.cpp @@ -1,5 +1,5 @@ /* - * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, 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 @@ -221,8 +221,7 @@ AwtFrame* AwtFrame::Create(jobject self, jobject parent) // Update target's dimensions to reflect this embedded window. ::GetClientRect(frame->m_hwnd, &rect); - ::MapWindowPoints(frame->m_hwnd, hwndParent, (LPPOINT)&rect, - 2); + ::MapWindowPoints(frame->m_hwnd, hwndParent, (LPPOINT)&rect, 2); env->SetIntField(target, AwtComponent::xID, rect.left); env->SetIntField(target, AwtComponent::yID, rect.top); @@ -231,6 +230,7 @@ AwtFrame* AwtFrame::Create(jobject self, jobject parent) env->SetIntField(target, AwtComponent::heightID, rect.bottom-rect.top); frame->InitPeerGraphicsConfig(env, self); + AwtToolkit::GetInstance().RegisterEmbedderProcessId(hwndParent); } else { jint state = env->GetIntField(target, AwtFrame::stateID); DWORD exStyle; @@ -408,8 +408,9 @@ MsgRouting AwtFrame::WmShowWindow(BOOL show, UINT status) * message. This breaks Java focus. To workaround the problem we * set the toplevel being shown foreground programmatically. * The fix is localized to non-foreground process case only. + * (See also: 6599270) */ - if (show == TRUE && status == 0) { + if (!IsEmbeddedFrame() && show == TRUE && status == 0) { HWND fgHWnd = ::GetForegroundWindow(); if (fgHWnd != NULL) { DWORD fgProcessID; @@ -495,7 +496,7 @@ MsgRouting AwtFrame::WmMouseMove(UINT flags, int x, int y) { ::SetWindowPos(GetHWnd(), NULL, r.left, r.top, r.right-r.left, r.bottom-r.top, - SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOZORDER | + SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOCOPYBITS | SWP_DEFERERASE); } return mrConsume; diff --git a/src/windows/native/sun/windows/awt_Object.cpp b/src/windows/native/sun/windows/awt_Object.cpp index 96153f1600f239818e9512a0294091874044899e..aab7e98b50201d9c5fb15310ea083f4ab4a389d4 100644 --- a/src/windows/native/sun/windows/awt_Object.cpp +++ b/src/windows/native/sun/windows/awt_Object.cpp @@ -1,5 +1,5 @@ /* - * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, 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 @@ -39,6 +39,7 @@ static BOOL reportEvents = FALSE; */ jfieldID AwtObject::pDataID; +jfieldID AwtObject::destroyedID; jfieldID AwtObject::targetID; jclass AwtObject::wObjectPeerClass; jmethodID AwtObject::getPeerForTargetMID; @@ -223,6 +224,7 @@ Java_sun_awt_windows_WObjectPeer_initIDs(JNIEnv *env, jclass cls) { AwtObject::wObjectPeerClass = (jclass)env->NewGlobalRef(cls); AwtObject::pDataID = env->GetFieldID(cls, "pData", "J"); + AwtObject::destroyedID = env->GetFieldID(cls, "destroyed", "Z"); AwtObject::targetID = env->GetFieldID(cls, "target", "Ljava/lang/Object;"); @@ -233,6 +235,7 @@ Java_sun_awt_windows_WObjectPeer_initIDs(JNIEnv *env, jclass cls) { AwtObject::createErrorID = env->GetFieldID(cls, "createError", "Ljava/lang/Error;"); DASSERT(AwtObject::pDataID != NULL); + DASSERT(AwtObject::destroyedID != NULL); DASSERT(AwtObject::targetID != NULL); DASSERT(AwtObject::getPeerForTargetMID != NULL); DASSERT(AwtObject::createErrorID != NULL); diff --git a/src/windows/native/sun/windows/awt_Object.h b/src/windows/native/sun/windows/awt_Object.h index 3e69dd89cca339cbfac380f78a0865ca17b6fa26..bcfa6b6f555308eadb8e40ea5158069a8ce61e71 100644 --- a/src/windows/native/sun/windows/awt_Object.h +++ b/src/windows/native/sun/windows/awt_Object.h @@ -1,5 +1,5 @@ /* - * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, 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 @@ -51,6 +51,7 @@ public: /* sun.awt.windows.WObjectPeer field and method ids */ static jfieldID pDataID; + static jfieldID destroyedID; static jfieldID targetID; static jmethodID getPeerForTargetMID; diff --git a/src/windows/native/sun/windows/awt_Toolkit.cpp b/src/windows/native/sun/windows/awt_Toolkit.cpp index 4a8e45177aa1db88c85993c0280434f1e470836d..958ca8d871d1fe2c17d0d40216bd9e98a111a586 100644 --- a/src/windows/native/sun/windows/awt_Toolkit.cpp +++ b/src/windows/native/sun/windows/awt_Toolkit.cpp @@ -1,5 +1,5 @@ /* - * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, 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 @@ -354,6 +354,7 @@ AwtToolkit::AwtToolkit() { m_dllHandle = NULL; m_displayChanged = FALSE; + m_embedderProcessID = 0; // XXX: keyboard mapping should really be moved out of AwtComponent AwtComponent::InitDynamicKeyMapTable(); @@ -1442,49 +1443,17 @@ void hang_if_shutdown(void) } } -/* - * Returns a reference to the class java.awt.Component. - */ -jclass -getComponentClass(JNIEnv *env) +// for now we support only one embedder, but should be ready for future +void AwtToolkit::RegisterEmbedderProcessId(HWND embedder) { - static jclass componentCls = NULL; - - // get global reference of java/awt/Component class (run only once) - if (componentCls == NULL) { - jclass componentClsLocal = env->FindClass("java/awt/Component"); - DASSERT(componentClsLocal != NULL); - if (componentClsLocal == NULL) { - /* exception already thrown */ - return NULL; - } - componentCls = (jclass)env->NewGlobalRef(componentClsLocal); - env->DeleteLocalRef(componentClsLocal); + if (m_embedderProcessID) { + // we already set embedder process and do not expect + // two different processes to embed the same AwtToolkit + return; } - return componentCls; -} - -/* - * Returns a reference to the class java.awt.MenuComponent. - */ -jclass -getMenuComponentClass(JNIEnv *env) -{ - static jclass menuComponentCls = NULL; - - // get global reference of java/awt/MenuComponent class (run only once) - if (menuComponentCls == NULL) { - jclass menuComponentClsLocal = env->FindClass("java/awt/MenuComponent"); - DASSERT(menuComponentClsLocal != NULL); - if (menuComponentClsLocal == NULL) { - /* exception already thrown */ - return NULL; - } - menuComponentCls = (jclass)env->NewGlobalRef(menuComponentClsLocal); - env->DeleteLocalRef(menuComponentClsLocal); - } - return menuComponentCls; + embedder = ::GetAncestor(embedder, GA_ROOT); + ::GetWindowThreadProcessId(embedder, &m_embedderProcessID); } JNIEnv* AwtToolkit::m_env; diff --git a/src/windows/native/sun/windows/awt_Toolkit.h b/src/windows/native/sun/windows/awt_Toolkit.h index e7ffb1d29033d8ecb49340833e1418fcacdac7e6..fcee2d4ad5cb756e7d84d595c4b27f475a9b29cb 100644 --- a/src/windows/native/sun/windows/awt_Toolkit.h +++ b/src/windows/native/sun/windows/awt_Toolkit.h @@ -1,5 +1,5 @@ /* - * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, 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 @@ -426,10 +426,17 @@ private: */ private: BOOL m_displayChanged; /* Tracks displayChanged events */ + // 0 means we are not embedded. + DWORD m_embedderProcessID; public: BOOL HasDisplayChanged() { return m_displayChanged; } void ResetDisplayChanged() { m_displayChanged = FALSE; } + void RegisterEmbedderProcessId(HWND); + BOOL IsEmbedderProcessId(const DWORD processID) const + { + return m_embedderProcessID && (processID == m_embedderProcessID); + } private: static JNIEnv *m_env; diff --git a/src/windows/native/sun/windows/awt_Window.cpp b/src/windows/native/sun/windows/awt_Window.cpp index adc3ee6af2af118c08199a29bf294147e3f944e7..7e2f31fb13949bde6ff99344505e04e5c2ecec6d 100644 --- a/src/windows/native/sun/windows/awt_Window.cpp +++ b/src/windows/native/sun/windows/awt_Window.cpp @@ -125,6 +125,11 @@ jfieldID AwtWindow::autoRequestFocusID; jclass AwtWindow::wwindowPeerCls; jmethodID AwtWindow::getActiveWindowsMID; +jfieldID AwtWindow::sysXID; +jfieldID AwtWindow::sysYID; +jfieldID AwtWindow::sysWID; +jfieldID AwtWindow::sysHID; + int AwtWindow::ms_instanceCounter = 0; HHOOK AwtWindow::ms_hCBTFilter; AwtWindow * AwtWindow::m_grabbedWindow = NULL; @@ -180,7 +185,6 @@ void AwtWindow::Dispose() } ::RemoveProp(GetHWnd(), ModalBlockerProp); - ::RemoveProp(GetHWnd(), ModalSaveWSEXProp); if (m_grabbedWindow == this) { Ungrab(); @@ -330,8 +334,11 @@ LRESULT CALLBACK AwtWindow::CBTFilter(int nCode, WPARAM wParam, LPARAM lParam) if (nCode == HCBT_ACTIVATE || nCode == HCBT_SETFOCUS) { AwtComponent *comp = AwtComponent::GetComponent((HWND)wParam); - if (comp != NULL && comp->IsTopLevel() && !((AwtWindow*)comp)->IsFocusableWindow()) { - return 1; // Don't change focus/activation. + if (comp != NULL && comp->IsTopLevel()) { + AwtWindow* win = (AwtWindow*)comp; + if (!win->IsFocusableWindow() || win->m_filterFocusAndActivation) { + return 1; // Don't change focus/activation. + } } } return ::CallNextHookEx(AwtWindow::ms_hCBTFilter, nCode, wParam, lParam); @@ -1053,6 +1060,8 @@ MsgRouting AwtWindow::WmMove(int x, int y) (env)->SetIntField(target, AwtComponent::xID, rect.left); (env)->SetIntField(target, AwtComponent::yID, rect.top); + (env)->SetIntField(peer, AwtWindow::sysXID, rect.left); + (env)->SetIntField(peer, AwtWindow::sysYID, rect.top); SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_MOVED); env->DeleteLocalRef(target); @@ -1116,6 +1125,11 @@ MsgRouting AwtWindow::WmSize(UINT type, int w, int h) (env)->SetIntField(target, AwtComponent::widthID, newWidth); (env)->SetIntField(target, AwtComponent::heightID, newHeight); + + jobject peer = GetPeer(env); + (env)->SetIntField(peer, AwtWindow::sysWID, newWidth); + (env)->SetIntField(peer, AwtWindow::sysHID, newHeight); + if (!AwtWindow::IsResizing()) { WindowResized(); } @@ -1455,20 +1469,17 @@ void AwtWindow::SetModalBlocker(HWND window, HWND blocker) { if (!::IsWindow(window)) { return; } - DWORD exStyle = ::GetWindowLong(window, GWL_EXSTYLE); + if (::IsWindow(blocker)) { - // save WS_EX_NOACTIVATE and WS_EX_APPWINDOW styles - DWORD saveStyle = exStyle & (AWT_WS_EX_NOACTIVATE | WS_EX_APPWINDOW); - ::SetProp(window, ModalSaveWSEXProp, reinterpret_cast(saveStyle)); - ::SetWindowLong(window, GWL_EXSTYLE, (exStyle | AWT_WS_EX_NOACTIVATE) & ~WS_EX_APPWINDOW); ::SetProp(window, ModalBlockerProp, reinterpret_cast(blocker)); + ::EnableWindow(window, FALSE); } else { - // restore WS_EX_NOACTIVATE and WS_EX_APPWINDOW styles - DWORD saveStyle = reinterpret_cast(::GetProp(window, ModalSaveWSEXProp)); - ::SetWindowLong(window, GWL_EXSTYLE, - (exStyle & ~(AWT_WS_EX_NOACTIVATE | WS_EX_APPWINDOW)) | saveStyle); - ::RemoveProp(window, ModalSaveWSEXProp); ::RemoveProp(window, ModalBlockerProp); + AwtComponent *comp = AwtComponent::GetComponent(window); + // we don't expect to be called with non-java HWNDs + DASSERT(comp && comp->IsTopLevel()); + // we should not unblock disabled toplevels + ::EnableWindow(window, comp->isEnabled()); } } @@ -1754,17 +1765,22 @@ void AwtWindow::_ReshapeFrame(void *param) // Fix for 4459064 : do not enforce thresholds for embedded frames if (!p->IsEmbeddedFrame()) { + jobject peer = p->GetPeer(env); int minWidth = ::GetSystemMetrics(SM_CXMIN); int minHeight = ::GetSystemMetrics(SM_CYMIN); if (w < minWidth) { env->SetIntField(target, AwtComponent::widthID, w = minWidth); + env->SetIntField(peer, AwtWindow::sysWID, + w); } if (h < minHeight) { env->SetIntField(target, AwtComponent::heightID, h = minHeight); + env->SetIntField(peer, AwtWindow::sysHID, + h); } } env->DeleteLocalRef(target); @@ -2148,6 +2164,11 @@ Java_sun_awt_windows_WWindowPeer_initIDs(JNIEnv *env, jclass cls) env->GetStaticMethodID(cls, "getActiveWindowHandles", "()[J"); DASSERT(AwtWindow::getActiveWindowsMID != NULL); + AwtWindow::sysXID = env->GetFieldID(cls, "sysX", "I"); + AwtWindow::sysYID = env->GetFieldID(cls, "sysY", "I"); + AwtWindow::sysWID = env->GetFieldID(cls, "sysW", "I"); + AwtWindow::sysHID = env->GetFieldID(cls, "sysH", "I"); + CATCH_BAD_ALLOC; } diff --git a/src/windows/native/sun/windows/awt_Window.h b/src/windows/native/sun/windows/awt_Window.h index 1edb9b04dd73ac7f7db7e836f2f0bbd0bf681064..8e654a2d81337ef9d86512eac371a5f152be7348 100644 --- a/src/windows/native/sun/windows/awt_Window.h +++ b/src/windows/native/sun/windows/awt_Window.h @@ -33,7 +33,6 @@ // property name tagging windows disabled by modality static LPCTSTR ModalBlockerProp = TEXT("SunAwtModalBlockerProp"); -static LPCTSTR ModalSaveWSEXProp = TEXT("SunAwtModalSaveWSEXProp"); static LPCTSTR ModalDialogPeerProp = TEXT("SunAwtModalDialogPeerProp"); #ifndef WH_MOUSE_LL @@ -63,6 +62,12 @@ public: /* long[] getActiveWindowHandles() method in WWindowPeer */ static jmethodID getActiveWindowsMID; + // The coordinates at the peer. + static jfieldID sysXID; + static jfieldID sysYID; + static jfieldID sysWID; + static jfieldID sysHID; + AwtWindow(); virtual ~AwtWindow(); diff --git a/test/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java b/test/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java new file mode 100644 index 0000000000000000000000000000000000000000..6fe480cb6e08cd03c6db4574f3a64cba85d78c6f --- /dev/null +++ b/test/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java @@ -0,0 +1,72 @@ +/* + * Copyright 2005-2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6578538 + * @summary com.sun.crypto.provider.SunJCE instance leak using KRB5 and + * LoginContext + * @author Brad Wetmore + * + * @run main/othervm -Xmx2m TestProviderLeak + */ + +/* + * We force the leak to become a problem by specifying the minimum + * size heap we can (above). In current runs on a server and client + * machine, it took roughly 220-240 iterations to have the memory leak + * shut down other operations. It complained about "Unable to verify + * the SunJCE provider." + */ + +import javax.crypto.*; +import javax.crypto.spec.*; + +public class TestProviderLeak { + private static void dumpMemoryStats(String s) throws Exception { + Runtime rt = Runtime.getRuntime(); + System.out.println(s + ":\t" + + rt.freeMemory() + " bytes free"); + } + + public static void main(String [] args) throws Exception { + SecretKeyFactory skf = + SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1", "SunJCE"); + PBEKeySpec pbeKS = new PBEKeySpec( + "passPhrase".toCharArray(), new byte [] { 0 }, 5, 512); + for (int i = 0; i <= 1000; i++) { + try { + skf.generateSecret(pbeKS); + if ((i % 20) == 0) { + // Calling gc() isn't dependable, but doesn't hurt. + // Gives better output in leak cases. + System.gc(); + dumpMemoryStats("Iteration " + i); + } + } catch (Exception e) { + dumpMemoryStats("\nException seen at iteration " + i); + throw e; + } + } + } +} diff --git a/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java b/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java index 84a01f9fd10e8ace17f61bf714ac28d570934683..6ad2581e862adafff67598f18e356684c5ce189e 100644 --- a/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java +++ b/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java @@ -29,14 +29,14 @@ */ import java.lang.management.*; +import java.util.List; import javax.management.MBeanServer; import com.sun.management.HotSpotDiagnosticMXBean; public class DumpHeap { public static void main(String[] argv) throws Exception { - MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); - HotSpotDiagnosticMXBean dm = sun.management.ManagementFactory.getDiagnosticMXBean(); + List list = ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class); System.out.println("Dumping to file: " + argv[0] + " ...."); - dm.dumpHeap(argv[0], true); + list.get(0).dumpHeap(argv[0], true); } } diff --git a/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticOptions.java b/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticOptions.java new file mode 100644 index 0000000000000000000000000000000000000000..c71888bbaee014510928c14dfd2553e48f0073d7 --- /dev/null +++ b/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticOptions.java @@ -0,0 +1,62 @@ +/* + * Copyright 2005 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6658779 + * @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticOptions() + * @author Daniel Fuchs + * + * @run main GetDiagnosticOptions + */ + +import com.sun.management.HotSpotDiagnosticMXBean; +import com.sun.management.VMOption; +import java.lang.management.ManagementFactory; +import java.util.List; +import javax.management.MBeanServer; + +public class GetDiagnosticOptions { + private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME = + "com.sun.management:type=HotSpotDiagnostic"; + + public static void main(String[] args) throws Exception { + List list = + ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class); + HotSpotDiagnosticMXBean mbean = list.get(0); + checkDiagnosticOptions(mbean); + + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + mbean = ManagementFactory.newPlatformMXBeanProxy(mbs, + HOTSPOT_DIAGNOSTIC_MXBEAN_NAME, + HotSpotDiagnosticMXBean.class); + checkDiagnosticOptions(mbean); + } + + private static void checkDiagnosticOptions(HotSpotDiagnosticMXBean mbean) { + List options = mbean.getDiagnosticOptions(); + for (VMOption opt : options) { + System.out.println("option: "+opt.getName()+"="+opt.getValue()); + } + } +} diff --git a/test/com/sun/management/HotSpotDiagnosticMXBean/GetVMOption.java b/test/com/sun/management/HotSpotDiagnosticMXBean/GetVMOption.java index e29d0be43206ab7588f391589e032b08b1a417c8..1f835173ab0c48b73424cf6b8b96aeb0839f386f 100644 --- a/test/com/sun/management/HotSpotDiagnosticMXBean/GetVMOption.java +++ b/test/com/sun/management/HotSpotDiagnosticMXBean/GetVMOption.java @@ -34,6 +34,7 @@ import com.sun.management.HotSpotDiagnosticMXBean; import com.sun.management.VMOption; import com.sun.management.VMOption.Origin; import java.lang.management.ManagementFactory; +import java.util.List; import javax.management.MBeanServer; public class GetVMOption { @@ -44,8 +45,9 @@ public class GetVMOption { "com.sun.management:type=HotSpotDiagnostic"; public static void main(String[] args) throws Exception { - HotSpotDiagnosticMXBean mbean = - sun.management.ManagementFactory.getDiagnosticMXBean(); + List list = + ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class); + HotSpotDiagnosticMXBean mbean = list.get(0); checkVMOption(mbean); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); diff --git a/test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java b/test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java index e9183f7f268ab82860631a7473574143237d91c2..404a7373dfd7f88505c92f34f9e401c284109b83 100644 --- a/test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java +++ b/test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java @@ -31,11 +31,11 @@ * @run main/othervm -XX:+PrintGCDetails SetVMOption */ +import java.lang.management.ManagementFactory; import java.util.*; import com.sun.management.HotSpotDiagnosticMXBean; import com.sun.management.VMOption; import com.sun.management.VMOption.Origin; -import sun.management.ManagementFactory; import sun.misc.Version; public class SetVMOption { @@ -44,10 +44,11 @@ public class SetVMOption { private static String BAD_VALUE = "yes"; private static String NEW_VALUE = "false"; private static String MANAGEMENT_SERVER = "ManagementServer"; - private static HotSpotDiagnosticMXBean mbean = - ManagementFactory.getDiagnosticMXBean(); + private static HotSpotDiagnosticMXBean mbean; public static void main(String[] args) throws Exception { + List list = + ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class); // The following test is transitional only and should be removed // once build 52 is promoted. diff --git a/test/com/sun/tracing/BasicFunctionality.java b/test/com/sun/tracing/BasicFunctionality.java new file mode 100644 index 0000000000000000000000000000000000000000..5cf925137ab3bff0cbce7245c1b7e2bd57bd6179 --- /dev/null +++ b/test/com/sun/tracing/BasicFunctionality.java @@ -0,0 +1,146 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6537506 + * @summary Basic unit test for tracing framework + */ + +import com.sun.tracing.*; +import java.lang.reflect.Method; + +@ProviderName("NamedProvider") +interface BasicProvider extends Provider { + void plainProbe(); + void probeWithArgs(int a, float f, String s, Long l); + @ProbeName("namedProbe") void probeWithName(); + void overloadedProbe(); + void overloadedProbe(int i); +} + +interface InvalidProvider extends Provider { + int nonVoidProbe(); +} + +public class BasicFunctionality { + + public static ProviderFactory factory; + public static BasicProvider bp; + + public static void main(String[] args) throws Exception { + + factory = ProviderFactory.getDefaultFactory(); + if (factory != null) { + bp = factory.createProvider(BasicProvider.class); + } + + testProviderFactory(); + testProbe(); + testProvider(); + } + + static void fail(String s) throws Exception { + throw new Exception(s); + } + + static void testProviderFactory() throws Exception { + if (factory == null) { + fail("ProviderFactory.getDefaultFactory: Did not create factory"); + } + if (bp == null) { + fail("ProviderFactory.createProvider: Did not create provider"); + } + try { + factory.createProvider(null); + fail("ProviderFactory.createProvider: Did not throw NPE for null"); + } catch (NullPointerException e) {} + + try { + factory.createProvider(InvalidProvider.class); + fail("Factory.createProvider: Should error with non-void probes"); + } catch (IllegalArgumentException e) {} + } + + public static void testProvider() throws Exception { + + // These just shouldn't throw any exeptions: + bp.plainProbe(); + bp.probeWithArgs(42, (float)3.14, "spam", new Long(2L)); + bp.probeWithArgs(42, (float)3.14, null, null); + bp.probeWithName(); + bp.overloadedProbe(); + bp.overloadedProbe(42); + + Method m = BasicProvider.class.getMethod("plainProbe"); + Probe p = bp.getProbe(m); + if (p == null) { + fail("Provider.getProbe: Did not return probe"); + } + + Method m2 = BasicFunctionality.class.getMethod("testProvider"); + p = bp.getProbe(m2); + if (p != null) { + fail("Provider.getProbe: Got probe with invalid spec"); + } + + bp.dispose(); + // These just shouldn't throw any exeptions: + bp.plainProbe(); + bp.probeWithArgs(42, (float)3.14, "spam", new Long(2L)); + bp.probeWithArgs(42, (float)3.14, null, null); + bp.probeWithName(); + bp.overloadedProbe(); + bp.overloadedProbe(42); + + if (bp.getProbe(m) != null) { + fail("Provider.getProbe: Should return null after dispose()"); + } + + bp.dispose(); // just to make sure nothing bad happens + } + + static void testProbe() throws Exception { + Method m = BasicProvider.class.getMethod("plainProbe"); + Probe p = bp.getProbe(m); + p.isEnabled(); // just make sure it doesn't do anything bad + p.trigger(); + + try { + p.trigger(0); + fail("Probe.trigger: too many arguments not caught"); + } catch (IllegalArgumentException e) {} + + p = bp.getProbe(BasicProvider.class.getMethod( + "probeWithArgs", int.class, float.class, String.class, Long.class)); + try { + p.trigger(); + fail("Probe.trigger: too few arguments not caught"); + } catch (IllegalArgumentException e) {} + + try { + p.trigger((float)3.14, (float)3.14, "", new Long(0L)); + fail("Probe.trigger: wrong type primitive arguments not caught"); + } catch (IllegalArgumentException e) {} + } +} diff --git a/test/java/awt/Focus/NonFocusableResizableTooSmall/NonFocusableResizableTooSmall.java b/test/java/awt/Focus/NonFocusableResizableTooSmall/NonFocusableResizableTooSmall.java new file mode 100644 index 0000000000000000000000000000000000000000..ef3207ffcb810292e1204570bb672f810dc03f62 --- /dev/null +++ b/test/java/awt/Focus/NonFocusableResizableTooSmall/NonFocusableResizableTooSmall.java @@ -0,0 +1,413 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test + @bug 6581927 + @summary Non-focusable frame should honor the size of the frame buttons/decorations when resizing + @library ../../regtesthelpers + @build Util + @author anthony.petrov@...: area=awt.toplevel + @run main NonFocusableResizableTooSmall +*/ + +/** + * NonFocusableResizableTooSmall.java + * + * summary: Non-focusable frame should honor the size of the frame buttons/decorations when resizing + */ + +import java.awt.*; +import java.awt.event.*; +import test.java.awt.regtesthelpers.Util; + +public class NonFocusableResizableTooSmall +{ + + //*** test-writer defined static variables go here *** + + + private static void init() + { + //*** Create instructions for the user here *** + + String[] instructions = + { + "This is an AUTOMATIC test, simply wait until it is done.", + "The result (passed or failed) will be shown in the", + "message window below." + }; + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + + final Frame frame = new Frame(); + frame.setFocusableWindowState(false); + frame.setSize(200, 100); + frame.setVisible(true); + + final Robot robot = Util.createRobot(); + robot.setAutoDelay(20); + + // To be sure the window is shown and packed + Util.waitForIdle(robot); + + final Insets insets = frame.getInsets(); + System.out.println("The insets of the frame: " + insets); + if (insets.right == 0 || insets.bottom == 0) { + System.out.println("The test environment must have non-zero right & bottom insets!"); + pass(); + return; + } + + // Let's move the mouse pointer to the bottom-right coner of the frame (the "size-grip") + final Rectangle bounds1 = frame.getBounds(); + System.out.println("The bounds before resizing: " + bounds1); + + robot.mouseMove(bounds1.x + bounds1.width - 1, bounds1.y + bounds1.height - 1); + + // ... and start resizing to some very small + robot.mousePress( InputEvent.BUTTON1_MASK ); + + // Now resize the frame so that the width is smaller + // than the widths of the left and the right borders. + // The sum of widths of the icon of the frame + the control-buttons + // (close, minimize, etc.) should be definitely larger! + robot.mouseMove(bounds1.x + insets.left + insets.right - 5, bounds1.y + bounds1.height - 1); + Util.waitForIdle(robot); + + robot.mouseRelease( InputEvent.BUTTON1_MASK ); + + Util.waitForIdle(robot); + + // Check the current bounds of the frame + final Rectangle bounds2 = frame.getBounds(); + System.out.println("The bounds after resizing: " + bounds2); + + if (bounds2.width <= (insets.left + insets.right)) { + fail("The frame has been resized to very small."); + } + pass(); + }//End init() + + + + /***************************************************** + * Standard Test Machinery Section + * DO NOT modify anything in this section -- it's a + * standard chunk of code which has all of the + * synchronisation necessary for the test harness. + * By keeping it the same in all tests, it is easier + * to read and understand someone else's test, as + * well as insuring that all tests behave correctly + * with the test harness. + * There is a section following this for test- + * classes + ******************************************************/ + private static boolean theTestPassed = false; + private static boolean testGeneratedInterrupt = false; + private static String failureMessage = ""; + + private static Thread mainThread = null; + + private static int sleepTime = 300000; + + // Not sure about what happens if multiple of this test are + // instantiated in the same VM. Being static (and using + // static vars), it aint gonna work. Not worrying about + // it for now. + public static void main( String args[] ) throws InterruptedException + { + mainThread = Thread.currentThread(); + try + { + init(); + } + catch( TestPassedException e ) + { + //The test passed, so just return from main and harness will + // interepret this return as a pass + return; + } + //At this point, neither test pass nor test fail has been + // called -- either would have thrown an exception and ended the + // test, so we know we have multiple threads. + + //Test involves other threads, so sleep and wait for them to + // called pass() or fail() + try + { + Thread.sleep( sleepTime ); + //Timed out, so fail the test + throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); + } + catch (InterruptedException e) + { + //The test harness may have interrupted the test. If so, rethrow the exception + // so that the harness gets it and deals with it. + if( ! testGeneratedInterrupt ) throw e; + + //reset flag in case hit this code more than once for some reason (just safety) + testGeneratedInterrupt = false; + + if ( theTestPassed == false ) + { + throw new RuntimeException( failureMessage ); + } + } + + }//main + + public static synchronized void setTimeoutTo( int seconds ) + { + sleepTime = seconds * 1000; + } + + public static synchronized void pass() + { + Sysout.println( "The test passed." ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //first check if this is executing in main thread + if ( mainThread == Thread.currentThread() ) + { + //Still in the main thread, so set the flag just for kicks, + // and throw a test passed exception which will be caught + // and end the test. + theTestPassed = true; + throw new TestPassedException(); + } + theTestPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + }//pass() + + public static synchronized void fail() + { + //test writer didn't specify why test failed, so give generic + fail( "it just plain failed! :-)" ); + } + + public static synchronized void fail( String whyFailed ) + { + Sysout.println( "The test failed: " + whyFailed ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //check if this called from main thread + if ( mainThread == Thread.currentThread() ) + { + //If main thread, fail now 'cause not sleeping + throw new RuntimeException( whyFailed ); + } + theTestPassed = false; + testGeneratedInterrupt = true; + failureMessage = whyFailed; + mainThread.interrupt(); + }//fail() + +}// class NonFocusableResizableTooSmall + +//This exception is used to exit from any level of call nesting +// when it's determined that the test has passed, and immediately +// end the test. +class TestPassedException extends RuntimeException +{ +} + +//*********** End Standard Test Machinery Section ********** + + +//************ Begin classes defined for the test **************** + +// if want to make listeners, here is the recommended place for them, then instantiate +// them in init() + +/* Example of a class which may be written as part of a test +class NewClass implements anInterface + { + static int newVar = 0; + + public void eventDispatched(AWTEvent e) + { + //Counting events to see if we get enough + eventCount++; + + if( eventCount == 20 ) + { + //got enough events, so pass + + NonFocusableResizableTooSmall.pass(); + } + else if( tries == 20 ) + { + //tried too many times without getting enough events so fail + + NonFocusableResizableTooSmall.fail(); + } + + }// eventDispatched() + + }// NewClass class + +*/ + + +//************** End classes defined for the test ******************* + + + + +/**************************************************** + Standard Test Machinery + DO NOT modify anything below -- it's a standard + chunk of code whose purpose is to make user + interaction uniform, and thereby make it simpler + to read and understand someone else's test. + ****************************************************/ + +/** + This is part of the standard test machinery. + It creates a dialog (with the instructions), and is the interface + for sending text messages to the user. + To print the instructions, send an array of strings to Sysout.createDialog + WithInstructions method. Put one line of instructions per array entry. + To display a message for the tester to see, simply call Sysout.println + with the string to be displayed. + This mimics System.out.println but works within the test harness as well + as standalone. + */ + +class Sysout +{ + private static TestDialog dialog; + + public static void createDialogWithInstructions( String[] instructions ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + dialog.printInstructions( instructions ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + public static void createDialog( ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + String[] defInstr = { "Instructions will appear here. ", "" } ; + dialog.printInstructions( defInstr ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + + public static void printInstructions( String[] instructions ) + { + dialog.printInstructions( instructions ); + } + + + public static void println( String messageIn ) + { + dialog.displayMessage( messageIn ); + System.out.println(messageIn); + } + +}// Sysout class + +/** + This is part of the standard test machinery. It provides a place for the + test instructions to be displayed, and a place for interactive messages + to the user to be displayed. + To have the test instructions displayed, see Sysout. + To have a message to the user be displayed, see Sysout. + Do not call anything in this dialog directly. + */ +class TestDialog extends Dialog +{ + + TextArea instructionsText; + TextArea messageText; + int maxStringLength = 80; + + //DO NOT call this directly, go through Sysout + public TestDialog( Frame frame, String name ) + { + super( frame, name ); + int scrollBoth = TextArea.SCROLLBARS_BOTH; + instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); + add( "North", instructionsText ); + + messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); + add("Center", messageText); + + pack(); + + setVisible(true); + }// TestDialog() + + //DO NOT call this directly, go through Sysout + public void printInstructions( String[] instructions ) + { + //Clear out any current instructions + instructionsText.setText( "" ); + + //Go down array of instruction strings + + String printStr, remainingStr; + for( int i=0; i < instructions.length; i++ ) + { + //chop up each into pieces maxSringLength long + remainingStr = instructions[ i ]; + while( remainingStr.length() > 0 ) + { + //if longer than max then chop off first max chars to print + if( remainingStr.length() >= maxStringLength ) + { + //Try to chop on a word boundary + int posOfSpace = remainingStr. + lastIndexOf( ' ', maxStringLength - 1 ); + + if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; + + printStr = remainingStr.substring( 0, posOfSpace + 1 ); + remainingStr = remainingStr.substring( posOfSpace + 1 ); + } + //else just print + else + { + printStr = remainingStr; + remainingStr = ""; + } + + instructionsText.append( printStr + "\n" ); + + }// while + + }// for + + }//printInstructions() + + //DO NOT call this directly, go through Sysout + public void displayMessage( String messageIn ) + { + messageText.append( messageIn + "\n" ); + System.out.println(messageIn); + } + +}// TestDialog class diff --git a/test/java/awt/Focus/RestoreFocusOnDisabledComponentTest/RestoreFocusOnDisabledComponentTest.java b/test/java/awt/Focus/RestoreFocusOnDisabledComponentTest/RestoreFocusOnDisabledComponentTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b813ce9599e4d574bc7c85cbc0d8fce2bc2807cf --- /dev/null +++ b/test/java/awt/Focus/RestoreFocusOnDisabledComponentTest/RestoreFocusOnDisabledComponentTest.java @@ -0,0 +1,108 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test %W% %E% + @bug 6598089 + @summary Tests restoring focus on a single disabled coponent + @author Anton Tarasov: area=awt-focus + @library ../../regtesthelpers + @build Util + @run main RestoreFocusOnDisabledComponentTest +*/ + +import java.awt.*; +import java.awt.event.*; +import java.applet.Applet; +import test.java.awt.regtesthelpers.Util; + +/* + * The bug is not reproducible on Windows. + */ +public class RestoreFocusOnDisabledComponentTest extends Applet { + Frame frame = new Frame("Frame") {public String toString() {return "FRAME";}}; + Button b0 = new Button("button0") {public String toString() {return "B-0";}}; + Button b1 = new Button("button1") {public String toString() {return "B-1";}}; + volatile int nFocused; + Robot robot; + + public static void main(String[] args) { + RestoreFocusOnDisabledComponentTest app = new RestoreFocusOnDisabledComponentTest(); + app.init(); + app.start(); + } + + public void init() { + robot = Util.createRobot(); + } + + public void start() { + frame.add(b0); + frame.add(b1); + frame.setLayout(new FlowLayout()); + frame.pack(); + + frame.setVisible(true); + + Util.waitForIdle(robot); + KeyboardFocusManager.setCurrentKeyboardFocusManager(new DefaultKeyboardFocusManager() { + public boolean dispatchEvent(AWTEvent e) { + if (e.getID() == FocusEvent.FOCUS_GAINED) { + // Trying to emulate timings. b1 should be disabled just by the time it gets + // FOCUS_GAINED event. The latter is a result of disabling b0 that initiates + // focus auto transfer. + if (e.getSource() == b1) { + b1.setEnabled(false); + + } else if (e.getSource() == b0) { + if (++nFocused > 10) { + nFocused = -1; + throw new TestFailedException("Focus went into busy loop!"); + } + } + } + return super.dispatchEvent(e); + } + }); + // Initiating focus auto transfer. + // Focus will be requested to b1. When FOCUS_GAINED is being dispatched to b1, it will + // be disabled. This will trigger focus restoring. Focus will be requested to b0 (the + // last opposite component). When FOCUS_GAINED is being dispatched to b0, it will + // also be disabled. However, the last opposite component (and the most recent focus owner) + // will still be b0. When DKFM initiates focus restoring it should detect restoring + // on the same component and break. + b0.setEnabled(false); + + Util.waitForIdle(robot); + if (nFocused != -1) { + System.out.println("Test passed."); + } + } +} + +class TestFailedException extends RuntimeException { + TestFailedException(String msg) { + super("Test failed: " + msg); + } +} + diff --git a/test/java/awt/Mixing/ValidBounds.java b/test/java/awt/Mixing/ValidBounds.java new file mode 100644 index 0000000000000000000000000000000000000000..dec7e6fce44e4f7e408c42b85b4890d14a1f43df --- /dev/null +++ b/test/java/awt/Mixing/ValidBounds.java @@ -0,0 +1,411 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test + @bug 6637796 + @summary Shape should be correctly updated on invalid components + @author anthony.petrov@...: area=awt.mixing + @library ../regtesthelpers + @build Util + @run main ValidBounds +*/ + +/** + * ValidBounds.java + * + * summary: Shape should be correctly updated on invalid components + */ + +import java.awt.*; +import java.awt.event.*; +import test.java.awt.regtesthelpers.Util; + +public class ValidBounds +{ + + static volatile boolean clickPassed = false; + + private static void init() + { + //*** Create instructions for the user here *** + + String[] instructions = + { + "This is an AUTOMATIC test, simply wait until it is done.", + "The result (passed or failed) will be shown in the", + "message window below." + }; + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + + + // Create the frame and the button + Frame f = new Frame(); + f.setBounds(100, 100, 400, 300); + + Button b = new Button("OK"); + + f.setLayout(null); + f.add(b); + b.setBounds(50, 50, 200, 50); + + b.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent e) { + clickPassed = true; + } + }); + + f.setVisible(true); + + // Let's make the button much smaller first... + Robot robot = Util.createRobot(); + robot.setAutoDelay(20); + + Util.waitForIdle(robot); + + b.setBounds(50, 50, 5, 5); + Util.waitForIdle(robot); + + // ... and now let's enlarge it. + b.setBounds(50, 50, 200, 50); + Util.waitForIdle(robot); + + // If the button doesn't receive the click, it means that the test + // failed: the shape of the button was not enlarged. + Point heavyLoc = b.getLocationOnScreen(); + robot.mouseMove(heavyLoc.x + 20, heavyLoc.y + 20); + + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + Util.waitForIdle(robot); + + if (clickPassed) { + pass(); + } else { + fail("The button cannot be clicked."); + } + }//End init() + + + + /***************************************************** + * Standard Test Machinery Section + * DO NOT modify anything in this section -- it's a + * standard chunk of code which has all of the + * synchronisation necessary for the test harness. + * By keeping it the same in all tests, it is easier + * to read and understand someone else's test, as + * well as insuring that all tests behave correctly + * with the test harness. + * There is a section following this for test- + * classes + ******************************************************/ + private static boolean theTestPassed = false; + private static boolean testGeneratedInterrupt = false; + private static String failureMessage = ""; + + private static Thread mainThread = null; + + private static int sleepTime = 300000; + + // Not sure about what happens if multiple of this test are + // instantiated in the same VM. Being static (and using + // static vars), it aint gonna work. Not worrying about + // it for now. + public static void main( String args[] ) throws InterruptedException + { + mainThread = Thread.currentThread(); + try + { + init(); + } + catch( TestPassedException e ) + { + //The test passed, so just return from main and harness will + // interepret this return as a pass + return; + } + //At this point, neither test pass nor test fail has been + // called -- either would have thrown an exception and ended the + // test, so we know we have multiple threads. + + //Test involves other threads, so sleep and wait for them to + // called pass() or fail() + try + { + Thread.sleep( sleepTime ); + //Timed out, so fail the test + throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); + } + catch (InterruptedException e) + { + //The test harness may have interrupted the test. If so, rethrow the exception + // so that the harness gets it and deals with it. + if( ! testGeneratedInterrupt ) throw e; + + //reset flag in case hit this code more than once for some reason (just safety) + testGeneratedInterrupt = false; + + if ( theTestPassed == false ) + { + throw new RuntimeException( failureMessage ); + } + } + + }//main + + public static synchronized void setTimeoutTo( int seconds ) + { + sleepTime = seconds * 1000; + } + + public static synchronized void pass() + { + Sysout.println( "The test passed." ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //first check if this is executing in main thread + if ( mainThread == Thread.currentThread() ) + { + //Still in the main thread, so set the flag just for kicks, + // and throw a test passed exception which will be caught + // and end the test. + theTestPassed = true; + throw new TestPassedException(); + } + theTestPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + }//pass() + + public static synchronized void fail() + { + //test writer didn't specify why test failed, so give generic + fail( "it just plain failed! :-)" ); + } + + public static synchronized void fail( String whyFailed ) + { + Sysout.println( "The test failed: " + whyFailed ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //check if this called from main thread + if ( mainThread == Thread.currentThread() ) + { + //If main thread, fail now 'cause not sleeping + throw new RuntimeException( whyFailed ); + } + theTestPassed = false; + testGeneratedInterrupt = true; + failureMessage = whyFailed; + mainThread.interrupt(); + }//fail() + +}// class ValidBounds + +//This exception is used to exit from any level of call nesting +// when it's determined that the test has passed, and immediately +// end the test. +class TestPassedException extends RuntimeException +{ +} + +//*********** End Standard Test Machinery Section ********** + + +//************ Begin classes defined for the test **************** + +// if want to make listeners, here is the recommended place for them, then instantiate +// them in init() + +/* Example of a class which may be written as part of a test +class NewClass implements anInterface + { + static int newVar = 0; + + public void eventDispatched(AWTEvent e) + { + //Counting events to see if we get enough + eventCount++; + + if( eventCount == 20 ) + { + //got enough events, so pass + + ValidBounds.pass(); + } + else if( tries == 20 ) + { + //tried too many times without getting enough events so fail + + ValidBounds.fail(); + } + + }// eventDispatched() + + }// NewClass class + +*/ + + +//************** End classes defined for the test ******************* + + + + +/**************************************************** + Standard Test Machinery + DO NOT modify anything below -- it's a standard + chunk of code whose purpose is to make user + interaction uniform, and thereby make it simpler + to read and understand someone else's test. + ****************************************************/ + +/** + This is part of the standard test machinery. + It creates a dialog (with the instructions), and is the interface + for sending text messages to the user. + To print the instructions, send an array of strings to Sysout.createDialog + WithInstructions method. Put one line of instructions per array entry. + To display a message for the tester to see, simply call Sysout.println + with the string to be displayed. + This mimics System.out.println but works within the test harness as well + as standalone. + */ + +class Sysout +{ + private static TestDialog dialog; + + public static void createDialogWithInstructions( String[] instructions ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + dialog.printInstructions( instructions ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + public static void createDialog( ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + String[] defInstr = { "Instructions will appear here. ", "" } ; + dialog.printInstructions( defInstr ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + + public static void printInstructions( String[] instructions ) + { + dialog.printInstructions( instructions ); + } + + + public static void println( String messageIn ) + { + dialog.displayMessage( messageIn ); + System.out.println(messageIn); + } + +}// Sysout class + +/** + This is part of the standard test machinery. It provides a place for the + test instructions to be displayed, and a place for interactive messages + to the user to be displayed. + To have the test instructions displayed, see Sysout. + To have a message to the user be displayed, see Sysout. + Do not call anything in this dialog directly. + */ +class TestDialog extends Dialog +{ + + TextArea instructionsText; + TextArea messageText; + int maxStringLength = 80; + + //DO NOT call this directly, go through Sysout + public TestDialog( Frame frame, String name ) + { + super( frame, name ); + int scrollBoth = TextArea.SCROLLBARS_BOTH; + instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); + add( "North", instructionsText ); + + messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); + add("Center", messageText); + + pack(); + + setVisible(true); + }// TestDialog() + + //DO NOT call this directly, go through Sysout + public void printInstructions( String[] instructions ) + { + //Clear out any current instructions + instructionsText.setText( "" ); + + //Go down array of instruction strings + + String printStr, remainingStr; + for( int i=0; i < instructions.length; i++ ) + { + //chop up each into pieces maxSringLength long + remainingStr = instructions[ i ]; + while( remainingStr.length() > 0 ) + { + //if longer than max then chop off first max chars to print + if( remainingStr.length() >= maxStringLength ) + { + //Try to chop on a word boundary + int posOfSpace = remainingStr. + lastIndexOf( ' ', maxStringLength - 1 ); + + if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; + + printStr = remainingStr.substring( 0, posOfSpace + 1 ); + remainingStr = remainingStr.substring( posOfSpace + 1 ); + } + //else just print + else + { + printStr = remainingStr; + remainingStr = ""; + } + + instructionsText.append( printStr + "\n" ); + + }// while + + }// for + + }//printInstructions() + + //DO NOT call this directly, go through Sysout + public void displayMessage( String messageIn ) + { + messageText.append( messageIn + "\n" ); + System.out.println(messageIn); + } + +}// TestDialog class diff --git a/test/java/awt/Modal/WsDisabledStyle/CloseBlocker/CloseBlocker.java b/test/java/awt/Modal/WsDisabledStyle/CloseBlocker/CloseBlocker.java new file mode 100644 index 0000000000000000000000000000000000000000..ad48949b3acb9dcc6cd1ff9e8a49d6156c36aa6a --- /dev/null +++ b/test/java/awt/Modal/WsDisabledStyle/CloseBlocker/CloseBlocker.java @@ -0,0 +1,466 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test %I% %E% + @bug 4080029 + @summary Modal Dialog block input to all frame windows not just its parent. + @author dmitry.cherepanov: area=awt.modal + @run main/manual CloseBlocker +*/ + +/** + * ManualMainTest.java + * + * summary: The test opens and closes blocker dialog, the test verifies + * that active window is correct when the dialog is closed. + */ + +import java.awt.*; +import java.awt.event.*; + +public class CloseBlocker +{ + + private static void init() + { + //*** Create instructions for the user here *** + + String[] instructions = + { + " the test will be run 6 times, to start next test just close all ", + " windows of previous; the instructions are the same for all tests: ", + " 1) there are two frames (one the frames has 'show modal' button), ", + " 2) press the button to show a dialog, ", + " 3) close the dialog (an alternative scenario - activate another", + " native window before closing the dialog), ", + " 4) the frame with button should become next active window, ", + " if it's true, then the test passed, otherwise, it failed. ", + " Press 'pass' button only after all of the 6 tests are completed, ", + " the number of the currently executed test is displayed on the ", + " output window. " + }; + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + + test(true, true, false); + test(true, true, true); + test(false, true, false); // 3rd parameter has no affect for ownerless + + test(true, false, false); + test(true, false, true); + test(false, false, false); // 3rd parameter has no affect for ownerless + + }//End init() + + private static final Object obj = new Object(); + private static int counter = 0; + + /* + * The ownerless parameter indicates whether the blocker dialog + * has owner. The usual parameter indicates whether the blocker + * dialog is a Java dialog (non-native dialog like file dialog). + */ + private static void test(final boolean ownerless, final boolean usual, final boolean initiallyOwnerIsActive) { + + Sysout.print(" * test #" + (++counter) + " is running ... "); + + final Frame active = new Frame(); + final Frame nonactive = new Frame(); + Button button = new Button("show modal"); + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + Dialog dialog = null; + Frame parent = ownerless ? null : (initiallyOwnerIsActive? active : nonactive); + if (usual) { + dialog = new Dialog(parent, "Sample", true); + } else { + dialog = new FileDialog(parent, "Sample", FileDialog.LOAD); + } + dialog.addWindowListener(new WindowAdapter(){ + public void windowClosing(WindowEvent e){ + e.getWindow().dispose(); + } + }); + dialog.setBounds(200, 200, 200, 200); + dialog.setVisible(true); + } + }); + + active.add(button); + active.setBounds(200, 400, 200, 200); + WindowAdapter adapter = new WindowAdapter(){ + public void windowClosing(WindowEvent e){ + active.dispose(); + nonactive.dispose(); + synchronized(obj) { + obj.notify(); + } + } + }; + active.addWindowListener(adapter); + active.setVisible(true); + + nonactive.setBounds(400, 400, 200, 200); + nonactive.addWindowListener(adapter); + nonactive.setVisible(true); + + synchronized(obj) { + try{ + obj.wait(); + } catch(Exception e) { + throw new RuntimeException(e); + } + } + + Sysout.println(" completed. "); + + } + + /***************************************************** + * Standard Test Machinery Section + * DO NOT modify anything in this section -- it's a + * standard chunk of code which has all of the + * synchronisation necessary for the test harness. + * By keeping it the same in all tests, it is easier + * to read and understand someone else's test, as + * well as insuring that all tests behave correctly + * with the test harness. + * There is a section following this for test-defined + * classes + ******************************************************/ + private static boolean theTestPassed = false; + private static boolean testGeneratedInterrupt = false; + private static String failureMessage = ""; + + private static Thread mainThread = null; + + private static int sleepTime = 300000; + + public static void main( String args[] ) throws InterruptedException + { + mainThread = Thread.currentThread(); + try + { + init(); + } + catch( TestPassedException e ) + { + //The test passed, so just return from main and harness will + // interepret this return as a pass + return; + } + //At this point, neither test passed nor test failed has been + // called -- either would have thrown an exception and ended the + // test, so we know we have multiple threads. + + //Test involves other threads, so sleep and wait for them to + // called pass() or fail() + try + { + Thread.sleep( sleepTime ); + //Timed out, so fail the test + throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); + } + catch (InterruptedException e) + { + if( ! testGeneratedInterrupt ) throw e; + + //reset flag in case hit this code more than once for some reason (just safety) + testGeneratedInterrupt = false; + if ( theTestPassed == false ) + { + throw new RuntimeException( failureMessage ); + } + } + + }//main + + public static synchronized void setTimeoutTo( int seconds ) + { + sleepTime = seconds * 1000; + } + + public static synchronized void pass() + { + Sysout.println( "The test passed." ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //first check if this is executing in main thread + if ( mainThread == Thread.currentThread() ) + { + //Still in the main thread, so set the flag just for kicks, + // and throw a test passed exception which will be caught + // and end the test. + theTestPassed = true; + throw new TestPassedException(); + } + //pass was called from a different thread, so set the flag and interrupt + // the main thead. + theTestPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + }//pass() + + public static synchronized void fail() + { + //test writer didn't specify why test failed, so give generic + fail( "it just plain failed! :-)" ); + } + + public static synchronized void fail( String whyFailed ) + { + Sysout.println( "The test failed: " + whyFailed ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //check if this called from main thread + if ( mainThread == Thread.currentThread() ) + { + //If main thread, fail now 'cause not sleeping + throw new RuntimeException( whyFailed ); + } + theTestPassed = false; + testGeneratedInterrupt = true; + failureMessage = whyFailed; + mainThread.interrupt(); + }//fail() + +}// class ManualMainTest + +//This exception is used to exit from any level of call nesting +// when it's determined that the test has passed, and immediately +// end the test. +class TestPassedException extends RuntimeException +{ +} + +//*********** End Standard Test Machinery Section ********** + + +//************ Begin classes defined for the test **************** + +// make listeners in a class defined here, and instantiate them in init() + +/* Example of a class which may be written as part of a test +class NewClass implements anInterface + { + static int newVar = 0; + + public void eventDispatched(AWTEvent e) + { + //Counting events to see if we get enough + eventCount++; + + if( eventCount == 20 ) + { + //got enough events, so pass + + ManualMainTest.pass(); + } + else if( tries == 20 ) + { + //tried too many times without getting enough events so fail + + ManualMainTest.fail(); + } + + }// eventDispatched() + + }// NewClass class + +*/ + + +//************** End classes defined for the test ******************* + + + + +/**************************************************** + Standard Test Machinery + DO NOT modify anything below -- it's a standard + chunk of code whose purpose is to make user + interaction uniform, and thereby make it simpler + to read and understand someone else's test. + ****************************************************/ + +/** + This is part of the standard test machinery. + It creates a dialog (with the instructions), and is the interface + for sending text messages to the user. + To print the instructions, send an array of strings to Sysout.createDialog + WithInstructions method. Put one line of instructions per array entry. + To display a message for the tester to see, simply call Sysout.println + with the string to be displayed. + This mimics System.out.println but works within the test harness as well + as standalone. + */ + +class Sysout +{ + private static TestDialog dialog; + + public static void createDialogWithInstructions( String[] instructions ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + dialog.printInstructions( instructions ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + public static void createDialog( ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + String[] defInstr = { "Instructions will appear here. ", "" } ; + dialog.printInstructions( defInstr ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + + public static void printInstructions( String[] instructions ) + { + dialog.printInstructions( instructions ); + } + + + public static void println( String messageIn ) + { + dialog.displayMessage( messageIn, true ); + } + + public static void print( String messageIn ) + { + dialog.displayMessage( messageIn, false ); + } + +}// Sysout class + +/** + This is part of the standard test machinery. It provides a place for the + test instructions to be displayed, and a place for interactive messages + to the user to be displayed. + To have the test instructions displayed, see Sysout. + To have a message to the user be displayed, see Sysout. + Do not call anything in this dialog directly. + */ +class TestDialog extends Dialog implements ActionListener +{ + + TextArea instructionsText; + TextArea messageText; + int maxStringLength = 80; + Panel buttonP = new Panel(); + Button passB = new Button( "pass" ); + Button failB = new Button( "fail" ); + + //DO NOT call this directly, go through Sysout + public TestDialog( Frame frame, String name ) + { + super( frame, name ); + int scrollBoth = TextArea.SCROLLBARS_BOTH; + instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); + add( "North", instructionsText ); + + messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); + add("Center", messageText); + + passB = new Button( "pass" ); + passB.setActionCommand( "pass" ); + passB.addActionListener( this ); + buttonP.add( "East", passB ); + + failB = new Button( "fail" ); + failB.setActionCommand( "fail" ); + failB.addActionListener( this ); + buttonP.add( "West", failB ); + + add( "South", buttonP ); + pack(); + + setVisible(true); + }// TestDialog() + + //DO NOT call this directly, go through Sysout + public void printInstructions( String[] instructions ) + { + //Clear out any current instructions + instructionsText.setText( "" ); + + //Go down array of instruction strings + + String printStr, remainingStr; + for( int i=0; i < instructions.length; i++ ) + { + //chop up each into pieces maxSringLength long + remainingStr = instructions[ i ]; + while( remainingStr.length() > 0 ) + { + //if longer than max then chop off first max chars to print + if( remainingStr.length() >= maxStringLength ) + { + //Try to chop on a word boundary + int posOfSpace = remainingStr. + lastIndexOf( ' ', maxStringLength - 1 ); + + if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; + + printStr = remainingStr.substring( 0, posOfSpace + 1 ); + remainingStr = remainingStr.substring( posOfSpace + 1 ); + } + //else just print + else + { + printStr = remainingStr; + remainingStr = ""; + } + + instructionsText.append( printStr + "\n" ); + + }// while + + }// for + + }//printInstructions() + + //DO NOT call this directly, go through Sysout + public void displayMessage( String messageIn, boolean nextLine ) + { + messageText.append( messageIn + (nextLine? "\n" : "") ); + System.out.println(messageIn); + } + + //catch presses of the passed and failed buttons. + //simply call the standard pass() or fail() static methods of + //ManualMainTest + public void actionPerformed( ActionEvent e ) + { + if( e.getActionCommand() == "pass" ) + { + CloseBlocker.pass(); + } + else + { + CloseBlocker.fail(); + } + } + +}// TestDialog class diff --git a/test/java/awt/Modal/WsDisabledStyle/OverBlocker/OverBlocker.java b/test/java/awt/Modal/WsDisabledStyle/OverBlocker/OverBlocker.java new file mode 100644 index 0000000000000000000000000000000000000000..15d963baa08acdc6d818495f029eef265ec34658 --- /dev/null +++ b/test/java/awt/Modal/WsDisabledStyle/OverBlocker/OverBlocker.java @@ -0,0 +1,456 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test %I% %E% + @bug 4080029 + @summary Modal Dialog block input to all frame windows not just its parent. + @author dmitry.cherepanov: area=awt.modal + @run main/manual OverBlocker +*/ + +/** + * OverBlocker.java + * + * summary: The test verifies that if user tries to activate the blocked dialog + * then the blocker dialog appears over the other windows + */ + +import java.awt.*; +import java.awt.event.*; + +public class OverBlocker +{ + + private static void init() + { + //*** Create instructions for the user here *** + + String[] instructions = + { + " the test will be run 4 times, to start next test just close all ", + " windows of previous; the instructions are the same for all tests: ", + " 1) there is a frame with 'show modal' button, ", + " 2) press the button to show a dialog, ", + " 3) activate any non-Java application, move the app over the dialog, ", + " 4) click on the frame by mouse, ", + " 5) make sure that the dialog comes up from the application and ", + " now the dialog overlaps the app as well as the frame, ", + " if it's true, then the test passed, otherwise, it failed. ", + " Press 'pass' button only after all of the 4 tests are completed, ", + " the number of the currently executed test is displayed on the ", + " output window. " + }; + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + + test(false, true); + test(true, true); + test(true, false); + test(false, false); + + }//End init() + + private static final Object obj = new Object(); + private static int counter = 0; + + /* + * The ownerless parameter indicates whether the blocker dialog + * has owner. The usual parameter indicates whether the blocker + * dialog is a Java dialog (non-native dialog like file dialog). + */ + private static void test(final boolean ownerless, final boolean usual) { + + Sysout.print(" * test #" + (++counter) + " is running ... "); + + final Frame frame = new Frame(); + Button button = new Button("show modal"); + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + Dialog dialog = null; + Frame parent = ownerless ? null : frame; + if (usual) { + dialog = new Dialog(parent, "Sample", true); + } else { + dialog = new FileDialog(parent, "Sample", FileDialog.LOAD); + } + dialog.addWindowListener(new WindowAdapter(){ + public void windowClosing(WindowEvent e){ + e.getWindow().dispose(); + } + }); + dialog.setBounds(200, 200, 200, 200); + dialog.setVisible(true); + } + }); + frame.add(button); + frame.setBounds(400, 400, 200, 200); + frame.addWindowListener(new WindowAdapter(){ + public void windowClosing(WindowEvent e){ + e.getWindow().dispose(); + synchronized(obj) { + obj.notify(); + } + } + }); + frame.setVisible(true); + + synchronized(obj) { + try{ + obj.wait(); + } catch(Exception e) { + throw new RuntimeException(e); + } + } + + Sysout.println(" completed. "); + + } + + /***************************************************** + * Standard Test Machinery Section + * DO NOT modify anything in this section -- it's a + * standard chunk of code which has all of the + * synchronisation necessary for the test harness. + * By keeping it the same in all tests, it is easier + * to read and understand someone else's test, as + * well as insuring that all tests behave correctly + * with the test harness. + * There is a section following this for test-defined + * classes + ******************************************************/ + private static boolean theTestPassed = false; + private static boolean testGeneratedInterrupt = false; + private static String failureMessage = ""; + + private static Thread mainThread = null; + + private static int sleepTime = 300000; + + public static void main( String args[] ) throws InterruptedException + { + mainThread = Thread.currentThread(); + try + { + init(); + } + catch( TestPassedException e ) + { + //The test passed, so just return from main and harness will + // interepret this return as a pass + return; + } + //At this point, neither test passed nor test failed has been + // called -- either would have thrown an exception and ended the + // test, so we know we have multiple threads. + + //Test involves other threads, so sleep and wait for them to + // called pass() or fail() + try + { + Thread.sleep( sleepTime ); + //Timed out, so fail the test + throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); + } + catch (InterruptedException e) + { + if( ! testGeneratedInterrupt ) throw e; + + //reset flag in case hit this code more than once for some reason (just safety) + testGeneratedInterrupt = false; + if ( theTestPassed == false ) + { + throw new RuntimeException( failureMessage ); + } + } + + }//main + + public static synchronized void setTimeoutTo( int seconds ) + { + sleepTime = seconds * 1000; + } + + public static synchronized void pass() + { + Sysout.println( "The test passed." ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //first check if this is executing in main thread + if ( mainThread == Thread.currentThread() ) + { + //Still in the main thread, so set the flag just for kicks, + // and throw a test passed exception which will be caught + // and end the test. + theTestPassed = true; + throw new TestPassedException(); + } + //pass was called from a different thread, so set the flag and interrupt + // the main thead. + theTestPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + }//pass() + + public static synchronized void fail() + { + //test writer didn't specify why test failed, so give generic + fail( "it just plain failed! :-)" ); + } + + public static synchronized void fail( String whyFailed ) + { + Sysout.println( "The test failed: " + whyFailed ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //check if this called from main thread + if ( mainThread == Thread.currentThread() ) + { + //If main thread, fail now 'cause not sleeping + throw new RuntimeException( whyFailed ); + } + theTestPassed = false; + testGeneratedInterrupt = true; + failureMessage = whyFailed; + mainThread.interrupt(); + }//fail() + +}// class ManualMainTest + +//This exception is used to exit from any level of call nesting +// when it's determined that the test has passed, and immediately +// end the test. +class TestPassedException extends RuntimeException +{ +} + +//*********** End Standard Test Machinery Section ********** + + +//************ Begin classes defined for the test **************** + +// make listeners in a class defined here, and instantiate them in init() + +/* Example of a class which may be written as part of a test +class NewClass implements anInterface + { + static int newVar = 0; + + public void eventDispatched(AWTEvent e) + { + //Counting events to see if we get enough + eventCount++; + + if( eventCount == 20 ) + { + //got enough events, so pass + + ManualMainTest.pass(); + } + else if( tries == 20 ) + { + //tried too many times without getting enough events so fail + + ManualMainTest.fail(); + } + + }// eventDispatched() + + }// NewClass class + +*/ + + +//************** End classes defined for the test ******************* + + + + +/**************************************************** + Standard Test Machinery + DO NOT modify anything below -- it's a standard + chunk of code whose purpose is to make user + interaction uniform, and thereby make it simpler + to read and understand someone else's test. + ****************************************************/ + +/** + This is part of the standard test machinery. + It creates a dialog (with the instructions), and is the interface + for sending text messages to the user. + To print the instructions, send an array of strings to Sysout.createDialog + WithInstructions method. Put one line of instructions per array entry. + To display a message for the tester to see, simply call Sysout.println + with the string to be displayed. + This mimics System.out.println but works within the test harness as well + as standalone. + */ + +class Sysout +{ + private static TestDialog dialog; + + public static void createDialogWithInstructions( String[] instructions ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + dialog.printInstructions( instructions ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + public static void createDialog( ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + String[] defInstr = { "Instructions will appear here. ", "" } ; + dialog.printInstructions( defInstr ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + + public static void printInstructions( String[] instructions ) + { + dialog.printInstructions( instructions ); + } + + + public static void println( String messageIn ) + { + dialog.displayMessage( messageIn, true ); + } + + public static void print( String messageIn ) + { + dialog.displayMessage( messageIn, false ); + } + +}// Sysout class + +/** + This is part of the standard test machinery. It provides a place for the + test instructions to be displayed, and a place for interactive messages + to the user to be displayed. + To have the test instructions displayed, see Sysout. + To have a message to the user be displayed, see Sysout. + Do not call anything in this dialog directly. + */ +class TestDialog extends Dialog implements ActionListener +{ + + TextArea instructionsText; + TextArea messageText; + int maxStringLength = 80; + Panel buttonP = new Panel(); + Button passB = new Button( "pass" ); + Button failB = new Button( "fail" ); + + //DO NOT call this directly, go through Sysout + public TestDialog( Frame frame, String name ) + { + super( frame, name ); + int scrollBoth = TextArea.SCROLLBARS_BOTH; + instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); + add( "North", instructionsText ); + + messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); + add("Center", messageText); + + passB = new Button( "pass" ); + passB.setActionCommand( "pass" ); + passB.addActionListener( this ); + buttonP.add( "East", passB ); + + failB = new Button( "fail" ); + failB.setActionCommand( "fail" ); + failB.addActionListener( this ); + buttonP.add( "West", failB ); + + add( "South", buttonP ); + pack(); + + setVisible(true); + }// TestDialog() + + //DO NOT call this directly, go through Sysout + public void printInstructions( String[] instructions ) + { + //Clear out any current instructions + instructionsText.setText( "" ); + + //Go down array of instruction strings + + String printStr, remainingStr; + for( int i=0; i < instructions.length; i++ ) + { + //chop up each into pieces maxSringLength long + remainingStr = instructions[ i ]; + while( remainingStr.length() > 0 ) + { + //if longer than max then chop off first max chars to print + if( remainingStr.length() >= maxStringLength ) + { + //Try to chop on a word boundary + int posOfSpace = remainingStr. + lastIndexOf( ' ', maxStringLength - 1 ); + + if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; + + printStr = remainingStr.substring( 0, posOfSpace + 1 ); + remainingStr = remainingStr.substring( posOfSpace + 1 ); + } + //else just print + else + { + printStr = remainingStr; + remainingStr = ""; + } + + instructionsText.append( printStr + "\n" ); + + }// while + + }// for + + }//printInstructions() + + //DO NOT call this directly, go through Sysout + public void displayMessage( String messageIn, boolean nextLine ) + { + messageText.append( messageIn + (nextLine? "\n" : "") ); + System.out.println(messageIn); + } + + //catch presses of the passed and failed buttons. + //simply call the standard pass() or fail() static methods of + //ManualMainTest + public void actionPerformed( ActionEvent e ) + { + if( e.getActionCommand() == "pass" ) + { + OverBlocker.pass(); + } + else + { + OverBlocker.fail(); + } + } + +}// TestDialog class diff --git a/test/java/awt/Modal/WsDisabledStyle/Winkey/Winkey.java b/test/java/awt/Modal/WsDisabledStyle/Winkey/Winkey.java new file mode 100644 index 0000000000000000000000000000000000000000..59297463a2efa99861cf1ee69440060e9486501d --- /dev/null +++ b/test/java/awt/Modal/WsDisabledStyle/Winkey/Winkey.java @@ -0,0 +1,403 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test %I% %E% + @bug 6572263 6571808 + @summary PIT:FileDialog minimized to taskbar(through 'Show Desktop')selecting the fileDialog using windowList + @author dmitry.cherepanov: area=awt.modal + @run main/manual Winkey +*/ + +/** + * Winkey.java + * + * summary: the test verifies that pressing combination of Windows key + * and M key to minimize all windows doesn't break AWT modality + */ + +import java.awt.*; +import java.awt.event.*; + +public class Winkey +{ + + private static void init() + { + //*** Create instructions for the user here *** + + String[] instructions = + { + " 1. there is a frame with a 'show modal' button, ", + " 2. press the button to show a modal dialog, ", + " 3. the modal dialog will be shown over the frame, ", + " 4. please verify that all (5.1, 5.2.1, 5.2.2) the following tests pass: ", + " ", + " 5.1. press combination Windows Key and M key to minimize all windows, ", + " 5.2. press combination Windows Key and D key to show desktop, ", + " 5.2.1. restore the dialog by choosing this one in the ALT-TAB list, ", + " 5.2.2. restore the dialog by mouse click on taskbar (on java or any other item)", + " ", + " 6. make sure that the dialog and the frame are visible, ", + " the bounds of the windows should be the same as before, ", + " if it's true, then the test passed; otherwise, it failed. " + }; + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + + final Frame frame = new Frame(); + Button button = new Button("show modal"); + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + FileDialog dialog = new FileDialog((Frame)null, "Sample", FileDialog.LOAD); + dialog.setVisible(true); + } + }); + frame.add(button); + frame.setBounds(400, 400, 200, 200); + frame.setVisible(true); + + }//End init() + + /***************************************************** + * Standard Test Machinery Section + * DO NOT modify anything in this section -- it's a + * standard chunk of code which has all of the + * synchronisation necessary for the test harness. + * By keeping it the same in all tests, it is easier + * to read and understand someone else's test, as + * well as insuring that all tests behave correctly + * with the test harness. + * There is a section following this for test-defined + * classes + ******************************************************/ + private static boolean theTestPassed = false; + private static boolean testGeneratedInterrupt = false; + private static String failureMessage = ""; + + private static Thread mainThread = null; + + private static int sleepTime = 300000; + + public static void main( String args[] ) throws InterruptedException + { + mainThread = Thread.currentThread(); + try + { + init(); + } + catch( TestPassedException e ) + { + //The test passed, so just return from main and harness will + // interepret this return as a pass + return; + } + //At this point, neither test passed nor test failed has been + // called -- either would have thrown an exception and ended the + // test, so we know we have multiple threads. + + //Test involves other threads, so sleep and wait for them to + // called pass() or fail() + try + { + Thread.sleep( sleepTime ); + //Timed out, so fail the test + throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); + } + catch (InterruptedException e) + { + if( ! testGeneratedInterrupt ) throw e; + + //reset flag in case hit this code more than once for some reason (just safety) + testGeneratedInterrupt = false; + if ( theTestPassed == false ) + { + throw new RuntimeException( failureMessage ); + } + } + + }//main + + public static synchronized void setTimeoutTo( int seconds ) + { + sleepTime = seconds * 1000; + } + + public static synchronized void pass() + { + Sysout.println( "The test passed." ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //first check if this is executing in main thread + if ( mainThread == Thread.currentThread() ) + { + //Still in the main thread, so set the flag just for kicks, + // and throw a test passed exception which will be caught + // and end the test. + theTestPassed = true; + throw new TestPassedException(); + } + //pass was called from a different thread, so set the flag and interrupt + // the main thead. + theTestPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + }//pass() + + public static synchronized void fail() + { + //test writer didn't specify why test failed, so give generic + fail( "it just plain failed! :-)" ); + } + + public static synchronized void fail( String whyFailed ) + { + Sysout.println( "The test failed: " + whyFailed ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //check if this called from main thread + if ( mainThread == Thread.currentThread() ) + { + //If main thread, fail now 'cause not sleeping + throw new RuntimeException( whyFailed ); + } + theTestPassed = false; + testGeneratedInterrupt = true; + failureMessage = whyFailed; + mainThread.interrupt(); + }//fail() + +}// class ManualMainTest + +//This exception is used to exit from any level of call nesting +// when it's determined that the test has passed, and immediately +// end the test. +class TestPassedException extends RuntimeException +{ +} + +//*********** End Standard Test Machinery Section ********** + + +//************ Begin classes defined for the test **************** + +// make listeners in a class defined here, and instantiate them in init() + +/* Example of a class which may be written as part of a test +class NewClass implements anInterface + { + static int newVar = 0; + + public void eventDispatched(AWTEvent e) + { + //Counting events to see if we get enough + eventCount++; + + if( eventCount == 20 ) + { + //got enough events, so pass + + ManualMainTest.pass(); + } + else if( tries == 20 ) + { + //tried too many times without getting enough events so fail + + ManualMainTest.fail(); + } + + }// eventDispatched() + + }// NewClass class + +*/ + + +//************** End classes defined for the test ******************* + + + + +/**************************************************** + Standard Test Machinery + DO NOT modify anything below -- it's a standard + chunk of code whose purpose is to make user + interaction uniform, and thereby make it simpler + to read and understand someone else's test. + ****************************************************/ + +/** + This is part of the standard test machinery. + It creates a dialog (with the instructions), and is the interface + for sending text messages to the user. + To print the instructions, send an array of strings to Sysout.createDialog + WithInstructions method. Put one line of instructions per array entry. + To display a message for the tester to see, simply call Sysout.println + with the string to be displayed. + This mimics System.out.println but works within the test harness as well + as standalone. + */ + +class Sysout +{ + private static TestDialog dialog; + + public static void createDialogWithInstructions( String[] instructions ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + dialog.printInstructions( instructions ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + public static void createDialog( ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + String[] defInstr = { "Instructions will appear here. ", "" } ; + dialog.printInstructions( defInstr ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + + public static void printInstructions( String[] instructions ) + { + dialog.printInstructions( instructions ); + } + + + public static void println( String messageIn ) + { + dialog.displayMessage( messageIn ); + } + +}// Sysout class + +/** + This is part of the standard test machinery. It provides a place for the + test instructions to be displayed, and a place for interactive messages + to the user to be displayed. + To have the test instructions displayed, see Sysout. + To have a message to the user be displayed, see Sysout. + Do not call anything in this dialog directly. + */ +class TestDialog extends Dialog implements ActionListener +{ + + TextArea instructionsText; + TextArea messageText; + int maxStringLength = 80; + Panel buttonP = new Panel(); + Button passB = new Button( "pass" ); + Button failB = new Button( "fail" ); + + //DO NOT call this directly, go through Sysout + public TestDialog( Frame frame, String name ) + { + super( frame, name ); + int scrollBoth = TextArea.SCROLLBARS_BOTH; + instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); + add( "North", instructionsText ); + + messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); + add("Center", messageText); + + passB = new Button( "pass" ); + passB.setActionCommand( "pass" ); + passB.addActionListener( this ); + buttonP.add( "East", passB ); + + failB = new Button( "fail" ); + failB.setActionCommand( "fail" ); + failB.addActionListener( this ); + buttonP.add( "West", failB ); + + add( "South", buttonP ); + pack(); + + setVisible(true); + }// TestDialog() + + //DO NOT call this directly, go through Sysout + public void printInstructions( String[] instructions ) + { + //Clear out any current instructions + instructionsText.setText( "" ); + + //Go down array of instruction strings + + String printStr, remainingStr; + for( int i=0; i < instructions.length; i++ ) + { + //chop up each into pieces maxSringLength long + remainingStr = instructions[ i ]; + while( remainingStr.length() > 0 ) + { + //if longer than max then chop off first max chars to print + if( remainingStr.length() >= maxStringLength ) + { + //Try to chop on a word boundary + int posOfSpace = remainingStr. + lastIndexOf( ' ', maxStringLength - 1 ); + + if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; + + printStr = remainingStr.substring( 0, posOfSpace + 1 ); + remainingStr = remainingStr.substring( posOfSpace + 1 ); + } + //else just print + else + { + printStr = remainingStr; + remainingStr = ""; + } + + instructionsText.append( printStr + "\n" ); + + }// while + + }// for + + }//printInstructions() + + //DO NOT call this directly, go through Sysout + public void displayMessage( String messageIn ) + { + messageText.append( messageIn + "\n" ); + System.out.println(messageIn); + } + + //catch presses of the passed and failed buttons. + //simply call the standard pass() or fail() static methods of + //ManualMainTest + public void actionPerformed( ActionEvent e ) + { + if( e.getActionCommand() == "pass" ) + { + Winkey.pass(); + } + else + { + Winkey.fail(); + } + } + +}// TestDialog class diff --git a/test/java/awt/event/MouseEvent/SmoothWheel/SmoothWheel.java b/test/java/awt/event/MouseEvent/SmoothWheel/SmoothWheel.java new file mode 100644 index 0000000000000000000000000000000000000000..00e07c84d3c6685a1968f6863e0318a8dcf836f6 --- /dev/null +++ b/test/java/awt/event/MouseEvent/SmoothWheel/SmoothWheel.java @@ -0,0 +1,432 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test %W% %E% %I%, %G% + @bug 6524352 + @summary support for high-resolution mouse wheel + @author dmitry cherepanov: area=awt.event + @run main/manual SmoothWheel +*/ + +/** + * SmoothWheel.java + * + * summary: + */ + +import java.awt.*; +import java.awt.event.*; + +public class SmoothWheel +{ + + //*** test-writer defined static variables go here *** + + + private static void init() + { + String[] instructions = + { + "1. the test is for high-resolution mouse wheel only, ", + " refer to the cr# 6524352 for more info about such devices, ", + "2. you'll see a frame, the frame contains a checkbox, ", + "3. initially, the state of the checkbox is off, ", + " use mouse wheel over the frame, ", + " and the frame will change its size gradually, ", + "4. turn on the checkbox, ", + " use mouse wheel again over the frame, ", + " now the frame will change its size smoothly, ", + "5. if the frame has always the same size or", + " if the frame changes its size equally in 3,4 cases, ", + " then the test failed. Otherwise, it passed." + }; + + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + + final Frame frame = new Frame(); + final Checkbox checkbox = new Checkbox("smooth wheel?"); + checkbox.setState(false); + + frame.setLayout (new FlowLayout()); + frame.add(checkbox); + + frame.addMouseWheelListener(new MouseWheelListener() { + public void mouseWheelMoved(MouseWheelEvent e) { + Sysout.println(e.toString()); + double wheelRotation = 0; + if (checkbox.getState()) { + wheelRotation = e.getPreciseWheelRotation(); + } else { + wheelRotation = e.getWheelRotation(); + } + Dimension size = frame.getSize(); + size.width += 10 * wheelRotation; + size.height += 10 * wheelRotation; + frame.setSize(size); + } + }); + + frame.setBounds(200, 200, 200, 200); + frame.setVisible(true); + + }//End init() + + + + /***************************************************** + * Standard Test Machinery Section + * DO NOT modify anything in this section -- it's a + * standard chunk of code which has all of the + * synchronisation necessary for the test harness. + * By keeping it the same in all tests, it is easier + * to read and understand someone else's test, as + * well as insuring that all tests behave correctly + * with the test harness. + * There is a section following this for test-defined + * classes + ******************************************************/ + private static boolean theTestPassed = false; + private static boolean testGeneratedInterrupt = false; + private static String failureMessage = ""; + + private static Thread mainThread = null; + + private static int sleepTime = 300000; + + public static void main( String args[] ) throws InterruptedException + { + mainThread = Thread.currentThread(); + try + { + init(); + } + catch( TestPassedException e ) + { + //The test passed, so just return from main and harness will + // interepret this return as a pass + return; + } + //At this point, neither test passed nor test failed has been + // called -- either would have thrown an exception and ended the + // test, so we know we have multiple threads. + + //Test involves other threads, so sleep and wait for them to + // called pass() or fail() + try + { + Thread.sleep( sleepTime ); + //Timed out, so fail the test + throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); + } + catch (InterruptedException e) + { + if( ! testGeneratedInterrupt ) throw e; + + //reset flag in case hit this code more than once for some reason (just safety) + testGeneratedInterrupt = false; + if ( theTestPassed == false ) + { + throw new RuntimeException( failureMessage ); + } + } + + }//main + + public static synchronized void setTimeoutTo( int seconds ) + { + sleepTime = seconds * 1000; + } + + public static synchronized void pass() + { + Sysout.println( "The test passed." ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //first check if this is executing in main thread + if ( mainThread == Thread.currentThread() ) + { + //Still in the main thread, so set the flag just for kicks, + // and throw a test passed exception which will be caught + // and end the test. + theTestPassed = true; + throw new TestPassedException(); + } + //pass was called from a different thread, so set the flag and interrupt + // the main thead. + theTestPassed = true; + testGeneratedInterrupt = true; + if (mainThread != null){ + mainThread.interrupt(); + } + }//pass() + + public static synchronized void fail() + { + //test writer didn't specify why test failed, so give generic + fail( "it just plain failed! :-)" ); + } + + public static synchronized void fail( String whyFailed ) + { + Sysout.println( "The test failed: " + whyFailed ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //check if this called from main thread + if ( mainThread == Thread.currentThread() ) + { + //If main thread, fail now 'cause not sleeping + throw new RuntimeException( whyFailed ); + } + theTestPassed = false; + testGeneratedInterrupt = true; + failureMessage = whyFailed; + mainThread.interrupt(); + }//fail() + +}// class ManualMainTest + +//This exception is used to exit from any level of call nesting +// when it's determined that the test has passed, and immediately +// end the test. +class TestPassedException extends RuntimeException +{ +} + +//*********** End Standard Test Machinery Section ********** + + +//************ Begin classes defined for the test **************** + +// make listeners in a class defined here, and instantiate them in init() + +/* Example of a class which may be written as part of a test +class NewClass implements anInterface + { + static int newVar = 0; + + public void eventDispatched(AWTEvent e) + { + //Counting events to see if we get enough + eventCount++; + + if( eventCount == 20 ) + { + //got enough events, so pass + + ManualMainTest.pass(); + } + else if( tries == 20 ) + { + //tried too many times without getting enough events so fail + + ManualMainTest.fail(); + } + + }// eventDispatched() + + }// NewClass class + +*/ + + +//************** End classes defined for the test ******************* + + + + +/**************************************************** + Standard Test Machinery + DO NOT modify anything below -- it's a standard + chunk of code whose purpose is to make user + interaction uniform, and thereby make it simpler + to read and understand someone else's test. + ****************************************************/ + +/** + This is part of the standard test machinery. + It creates a dialog (with the instructions), and is the interface + for sending text messages to the user. + To print the instructions, send an array of strings to Sysout.createDialog + WithInstructions method. Put one line of instructions per array entry. + To display a message for the tester to see, simply call Sysout.println + with the string to be displayed. + This mimics System.out.println but works within the test harness as well + as standalone. + */ + +class Sysout +{ + private static TestDialog dialog; + private static boolean numbering = false; + private static int messageNumber = 0; + + public static void createDialogWithInstructions( String[] instructions ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + dialog.printInstructions( instructions ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + public static void createDialog( ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + String[] defInstr = { "Instructions will appear here. ", "" } ; + dialog.printInstructions( defInstr ); + dialog.setVisible(true); + println( "Any messages for the tester will display here." ); + } + + + /* Enables message counting for the tester. */ + public static void enableNumbering(boolean enable){ + numbering = enable; + } + + public static void printInstructions( String[] instructions ) + { + dialog.printInstructions( instructions ); + } + + + public static void println( String messageIn ) + { + if (numbering) { + messageIn = "" + messageNumber + " " + messageIn; + messageNumber++; + } + dialog.displayMessage( messageIn ); + } + +}// Sysout class + +/** + This is part of the standard test machinery. It provides a place for the + test instructions to be displayed, and a place for interactive messages + to the user to be displayed. + To have the test instructions displayed, see Sysout. + To have a message to the user be displayed, see Sysout. + Do not call anything in this dialog directly. + */ +class TestDialog extends Dialog implements ActionListener +{ + + TextArea instructionsText; + TextArea messageText; + int maxStringLength = 80; + Panel buttonP = new Panel(); + Button passB = new Button( "pass" ); + Button failB = new Button( "fail" ); + + //DO NOT call this directly, go through Sysout + public TestDialog( Frame frame, String name ) + { + super( frame, name ); + int scrollBoth = TextArea.SCROLLBARS_BOTH; + instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); + add( "North", instructionsText ); + + messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); + add("Center", messageText); + + passB = new Button( "pass" ); + passB.setActionCommand( "pass" ); + passB.addActionListener( this ); + buttonP.add( "East", passB ); + + failB = new Button( "fail" ); + failB.setActionCommand( "fail" ); + failB.addActionListener( this ); + buttonP.add( "West", failB ); + + add( "South", buttonP ); + pack(); + + setVisible(true); + }// TestDialog() + + //DO NOT call this directly, go through Sysout + public void printInstructions( String[] instructions ) + { + //Clear out any current instructions + instructionsText.setText( "" ); + + //Go down array of instruction strings + + String printStr, remainingStr; + for( int i=0; i < instructions.length; i++ ) + { + //chop up each into pieces maxSringLength long + remainingStr = instructions[ i ]; + while( remainingStr.length() > 0 ) + { + //if longer than max then chop off first max chars to print + if( remainingStr.length() >= maxStringLength ) + { + //Try to chop on a word boundary + int posOfSpace = remainingStr. + lastIndexOf( ' ', maxStringLength - 1 ); + + if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; + + printStr = remainingStr.substring( 0, posOfSpace + 1 ); + remainingStr = remainingStr.substring( posOfSpace + 1 ); + } + //else just print + else + { + printStr = remainingStr; + remainingStr = ""; + } + + instructionsText.append( printStr + "\n" ); + + }// while + + }// for + + }//printInstructions() + + //DO NOT call this directly, go through Sysout + public void displayMessage( String messageIn ) + { + messageText.append( messageIn + "\n" ); + System.out.println(messageIn); + } + + //catch presses of the passed and failed buttons. + //simply call the standard pass() or fail() static methods of + //ManualMainTest + public void actionPerformed( ActionEvent e ) + { + if( e.getActionCommand() == "pass" ) + { + SmoothWheel.pass(); + } + else + { + SmoothWheel.fail(); + } + } + +}// TestDialog class diff --git a/test/java/io/FileOutputStream/AtomicAppend.java b/test/java/io/FileOutputStream/AtomicAppend.java new file mode 100644 index 0000000000000000000000000000000000000000..f5f0c23606c4f5e1202cc9cce1e9afa4283ad62a --- /dev/null +++ b/test/java/io/FileOutputStream/AtomicAppend.java @@ -0,0 +1,81 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6631352 + * @summary Check that appends are atomic + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.util.concurrent.Executors; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; + +public class AtomicAppend { + // Before the fix for + // 6631352: Implement atomic append mode using FILE_APPEND_DATA (win) + // this would fail intermittently on windows + void test(String[] args) throws Throwable { + final int nThreads = 10; + final int writes = 1000; + final File file = new File("foo"); + file.delete(); + try { + final ExecutorService es = Executors.newFixedThreadPool(nThreads); + for (int i = 0; i < nThreads; i++) + es.execute(new Runnable() { public void run() { + try { + FileOutputStream s = new FileOutputStream(file, true); + for (int j = 0; j < 1000; j++) { + s.write((int) 'x'); + s.flush(); + } + s.close(); + } catch (Throwable t) { unexpected(t); }}}); + es.shutdown(); + es.awaitTermination(10L, TimeUnit.MINUTES); + equal(file.length(), (long) (nThreads * writes)); + } finally { + file.delete(); + } + } + + //--------------------- Infrastructure --------------------------- + volatile int passed = 0, failed = 0; + void pass() {passed++;} + void fail() {failed++; Thread.dumpStack();} + void fail(String msg) {System.err.println(msg); fail();} + void unexpected(Throwable t) {failed++; t.printStackTrace();} + void check(boolean cond) {if (cond) pass(); else fail();} + void equal(Object x, Object y) { + if (x == null ? y == null : x.equals(y)) pass(); + else fail(x + " not equal to " + y);} + public static void main(String[] args) throws Throwable { + new AtomicAppend().instanceMain(args);} + void instanceMain(String[] args) throws Throwable { + try {test(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/lang/ProcessBuilder/Basic.java b/test/java/lang/ProcessBuilder/Basic.java index 4a57ad94ba6e897dca6979dae315ff26c7a9dce7..b0bfe12f250e06ad639a18bbc7479c7ce04a7a5d 100644 --- a/test/java/lang/ProcessBuilder/Basic.java +++ b/test/java/lang/ProcessBuilder/Basic.java @@ -25,12 +25,15 @@ * @test * @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689 * 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313 - * 6464154 6523983 6206031 + * 6464154 6523983 6206031 4960438 6631352 6631966 * @summary Basic tests for Process and Environment Variable code * @run main/othervm Basic * @author Martin Buchholz */ +import java.lang.ProcessBuilder.Redirect; +import static java.lang.ProcessBuilder.Redirect.*; + import java.io.*; import java.util.*; import java.security.*; @@ -257,7 +260,29 @@ public class Basic { public static class JavaChild { public static void main(String args[]) throws Throwable { String action = args[0]; - if (action.equals("System.getenv(String)")) { + if (action.equals("testIO")) { + String expected = "standard input"; + char[] buf = new char[expected.length()+1]; + int n = new InputStreamReader(System.in).read(buf,0,buf.length); + if (n != expected.length()) + System.exit(5); + if (! new String(buf,0,n).equals(expected)) + System.exit(5); + System.err.print("standard error"); + System.out.print("standard output"); + } else if (action.equals("testInheritIO")) { + List childArgs = new ArrayList(javaChildArgs); + childArgs.add("testIO"); + ProcessBuilder pb = new ProcessBuilder(childArgs); + pb.inheritIO(); + ProcessResults r = run(pb); + if (! r.out().equals("")) + System.exit(7); + if (! r.err().equals("")) + System.exit(8); + if (r.exitValue() != 0) + System.exit(9); + } else if (action.equals("System.getenv(String)")) { String val = System.getenv(args[1]); printUTF8(val == null ? "null" : val); } else if (action.equals("System.getenv(\\u1234)")) { @@ -599,6 +624,333 @@ public class Basic { } catch (Throwable t) { unexpected(t); } } + static void checkRedirects(ProcessBuilder pb, + Redirect in, Redirect out, Redirect err) { + equal(pb.redirectInput(), in); + equal(pb.redirectOutput(), out); + equal(pb.redirectError(), err); + } + + static void redirectIO(ProcessBuilder pb, + Redirect in, Redirect out, Redirect err) { + pb.redirectInput(in); + pb.redirectOutput(out); + pb.redirectError(err); + } + + static void setFileContents(File file, String contents) { + try { + Writer w = new FileWriter(file); + w.write(contents); + w.close(); + } catch (Throwable t) { unexpected(t); } + } + + static String fileContents(File file) { + try { + Reader r = new FileReader(file); + StringBuilder sb = new StringBuilder(); + char[] buffer = new char[1024]; + int n; + while ((n = r.read(buffer)) != -1) + sb.append(buffer,0,n); + r.close(); + return new String(sb); + } catch (Throwable t) { unexpected(t); return ""; } + } + + static void testIORedirection() throws Throwable { + final File ifile = new File("ifile"); + final File ofile = new File("ofile"); + final File efile = new File("efile"); + ifile.delete(); + ofile.delete(); + efile.delete(); + + //---------------------------------------------------------------- + // Check mutual inequality of different types of Redirect + //---------------------------------------------------------------- + Redirect[] redirects = + { PIPE, + INHERIT, + Redirect.from(ifile), + Redirect.to(ifile), + Redirect.appendTo(ifile), + Redirect.from(ofile), + Redirect.to(ofile), + Redirect.appendTo(ofile), + }; + for (int i = 0; i < redirects.length; i++) + for (int j = 0; j < redirects.length; j++) + equal(redirects[i].equals(redirects[j]), (i == j)); + + //---------------------------------------------------------------- + // Check basic properties of different types of Redirect + //---------------------------------------------------------------- + equal(PIPE.type(), Redirect.Type.PIPE); + equal(PIPE.toString(), "PIPE"); + equal(PIPE.file(), null); + + equal(INHERIT.type(), Redirect.Type.INHERIT); + equal(INHERIT.toString(), "INHERIT"); + equal(INHERIT.file(), null); + + equal(Redirect.from(ifile).type(), Redirect.Type.READ); + equal(Redirect.from(ifile).toString(), + "redirect to read from file \"ifile\""); + equal(Redirect.from(ifile).file(), ifile); + equal(Redirect.from(ifile), + Redirect.from(ifile)); + equal(Redirect.from(ifile).hashCode(), + Redirect.from(ifile).hashCode()); + + equal(Redirect.to(ofile).type(), Redirect.Type.WRITE); + equal(Redirect.to(ofile).toString(), + "redirect to write to file \"ofile\""); + equal(Redirect.to(ofile).file(), ofile); + equal(Redirect.to(ofile), + Redirect.to(ofile)); + equal(Redirect.to(ofile).hashCode(), + Redirect.to(ofile).hashCode()); + + equal(Redirect.appendTo(ofile).type(), Redirect.Type.APPEND); + equal(Redirect.appendTo(efile).toString(), + "redirect to append to file \"efile\""); + equal(Redirect.appendTo(efile).file(), efile); + equal(Redirect.appendTo(efile), + Redirect.appendTo(efile)); + equal(Redirect.appendTo(efile).hashCode(), + Redirect.appendTo(efile).hashCode()); + + //---------------------------------------------------------------- + // Check initial values of redirects + //---------------------------------------------------------------- + List childArgs = new ArrayList(javaChildArgs); + childArgs.add("testIO"); + final ProcessBuilder pb = new ProcessBuilder(childArgs); + checkRedirects(pb, PIPE, PIPE, PIPE); + + //---------------------------------------------------------------- + // Check inheritIO + //---------------------------------------------------------------- + pb.inheritIO(); + checkRedirects(pb, INHERIT, INHERIT, INHERIT); + + //---------------------------------------------------------------- + // Check setters and getters agree + //---------------------------------------------------------------- + pb.redirectInput(ifile); + equal(pb.redirectInput().file(), ifile); + equal(pb.redirectInput(), Redirect.from(ifile)); + + pb.redirectOutput(ofile); + equal(pb.redirectOutput().file(), ofile); + equal(pb.redirectOutput(), Redirect.to(ofile)); + + pb.redirectError(efile); + equal(pb.redirectError().file(), efile); + equal(pb.redirectError(), Redirect.to(efile)); + + THROWS(IllegalArgumentException.class, + new Fun(){void f() { + pb.redirectInput(Redirect.to(ofile)); }}, + new Fun(){void f() { + pb.redirectInput(Redirect.appendTo(ofile)); }}, + new Fun(){void f() { + pb.redirectOutput(Redirect.from(ifile)); }}, + new Fun(){void f() { + pb.redirectError(Redirect.from(ifile)); }}); + + THROWS(IOException.class, + // Input file does not exist + new Fun(){void f() throws Throwable { pb.start(); }}); + setFileContents(ifile, "standard input"); + + //---------------------------------------------------------------- + // Writing to non-existent files + //---------------------------------------------------------------- + { + ProcessResults r = run(pb); + equal(r.exitValue(), 0); + equal(fileContents(ofile), "standard output"); + equal(fileContents(efile), "standard error"); + equal(r.out(), ""); + equal(r.err(), ""); + ofile.delete(); + efile.delete(); + } + + //---------------------------------------------------------------- + // Both redirectErrorStream + redirectError + //---------------------------------------------------------------- + { + pb.redirectErrorStream(true); + ProcessResults r = run(pb); + equal(r.exitValue(), 0); + equal(fileContents(ofile), + "standard error" + "standard output"); + equal(fileContents(efile), ""); + equal(r.out(), ""); + equal(r.err(), ""); + ofile.delete(); + efile.delete(); + } + + //---------------------------------------------------------------- + // Appending to existing files + //---------------------------------------------------------------- + { + setFileContents(ofile, "ofile-contents"); + setFileContents(efile, "efile-contents"); + pb.redirectOutput(Redirect.appendTo(ofile)); + pb.redirectError(Redirect.appendTo(efile)); + pb.redirectErrorStream(false); + ProcessResults r = run(pb); + equal(r.exitValue(), 0); + equal(fileContents(ofile), + "ofile-contents" + "standard output"); + equal(fileContents(efile), + "efile-contents" + "standard error"); + equal(r.out(), ""); + equal(r.err(), ""); + ofile.delete(); + efile.delete(); + } + + //---------------------------------------------------------------- + // Replacing existing files + //---------------------------------------------------------------- + { + setFileContents(ofile, "ofile-contents"); + setFileContents(efile, "efile-contents"); + pb.redirectOutput(ofile); + pb.redirectError(Redirect.to(efile)); + ProcessResults r = run(pb); + equal(r.exitValue(), 0); + equal(fileContents(ofile), "standard output"); + equal(fileContents(efile), "standard error"); + equal(r.out(), ""); + equal(r.err(), ""); + ofile.delete(); + efile.delete(); + } + + //---------------------------------------------------------------- + // Appending twice to the same file? + //---------------------------------------------------------------- + { + setFileContents(ofile, "ofile-contents"); + setFileContents(efile, "efile-contents"); + Redirect appender = Redirect.appendTo(ofile); + pb.redirectOutput(appender); + pb.redirectError(appender); + ProcessResults r = run(pb); + equal(r.exitValue(), 0); + equal(fileContents(ofile), + "ofile-contents" + + "standard error" + + "standard output"); + equal(fileContents(efile), "efile-contents"); + equal(r.out(), ""); + equal(r.err(), ""); + ifile.delete(); + ofile.delete(); + efile.delete(); + } + + //---------------------------------------------------------------- + // Testing INHERIT is harder. + // Note that this requires __FOUR__ nested JVMs involved in one test, + // if you count the harness JVM. + //---------------------------------------------------------------- + { + redirectIO(pb, PIPE, PIPE, PIPE); + List command = pb.command(); + command.set(command.size() - 1, "testInheritIO"); + Process p = pb.start(); + new PrintStream(p.getOutputStream()).print("standard input"); + p.getOutputStream().close(); + ProcessResults r = run(p); + equal(r.exitValue(), 0); + equal(r.out(), "standard output"); + equal(r.err(), "standard error"); + } + + //---------------------------------------------------------------- + // Test security implications of I/O redirection + //---------------------------------------------------------------- + + // Read access to current directory is always granted; + // So create a tmpfile for input instead. + final File tmpFile = File.createTempFile("Basic", "tmp"); + setFileContents(tmpFile, "standard input"); + + final Policy policy = new Policy(); + Policy.setPolicy(policy); + System.setSecurityManager(new SecurityManager()); + try { + final Permission xPermission + = new FilePermission("<>", "execute"); + final Permission rxPermission + = new FilePermission("<>", "read,execute"); + final Permission wxPermission + = new FilePermission("<>", "write,execute"); + final Permission rwxPermission + = new FilePermission("<>", "read,write,execute"); + + THROWS(SecurityException.class, + new Fun() { void f() throws IOException { + policy.setPermissions(xPermission); + redirectIO(pb, from(tmpFile), PIPE, PIPE); + pb.start();}}, + new Fun() { void f() throws IOException { + policy.setPermissions(rxPermission); + redirectIO(pb, PIPE, to(ofile), PIPE); + pb.start();}}, + new Fun() { void f() throws IOException { + policy.setPermissions(rxPermission); + redirectIO(pb, PIPE, PIPE, to(efile)); + pb.start();}}); + + { + policy.setPermissions(rxPermission); + redirectIO(pb, from(tmpFile), PIPE, PIPE); + ProcessResults r = run(pb); + equal(r.out(), "standard output"); + equal(r.err(), "standard error"); + } + + { + policy.setPermissions(wxPermission); + redirectIO(pb, PIPE, to(ofile), to(efile)); + Process p = pb.start(); + new PrintStream(p.getOutputStream()).print("standard input"); + p.getOutputStream().close(); + ProcessResults r = run(p); + policy.setPermissions(rwxPermission); + equal(fileContents(ofile), "standard output"); + equal(fileContents(efile), "standard error"); + } + + { + policy.setPermissions(rwxPermission); + redirectIO(pb, from(tmpFile), to(ofile), to(efile)); + ProcessResults r = run(pb); + policy.setPermissions(rwxPermission); + equal(fileContents(ofile), "standard output"); + equal(fileContents(efile), "standard error"); + } + + } finally { + policy.setPermissions(new RuntimePermission("setSecurityManager")); + System.setSecurityManager(null); + tmpFile.delete(); + ifile.delete(); + ofile.delete(); + efile.delete(); + } + } + private static void realMain(String[] args) throws Throwable { if (Windows.is()) System.out.println("This appears to be a Windows system."); @@ -607,6 +959,9 @@ public class Basic { if (UnicodeOS.is()) System.out.println("This appears to be a Unicode-based OS."); + try { testIORedirection(); } + catch (Throwable t) { unexpected(t); } + //---------------------------------------------------------------- // Basic tests for setting, replacing and deleting envvars //---------------------------------------------------------------- @@ -1354,7 +1709,8 @@ public class Basic { execPermission); ProcessBuilder pb = new ProcessBuilder("env"); pb.environment().put("foo","bar"); - pb.start(); + Process p = pb.start(); + closeStreams(p); } catch (IOException e) { // OK } catch (Throwable t) { unexpected(t); } @@ -1378,6 +1734,14 @@ public class Basic { } + static void closeStreams(Process p) { + try { + p.getOutputStream().close(); + p.getInputStream().close(); + p.getErrorStream().close(); + } catch (Throwable t) { unexpected(t); } + } + //---------------------------------------------------------------- // A Policy class designed to make permissions fiddling very easy. //---------------------------------------------------------------- @@ -1432,10 +1796,19 @@ public class Basic { } } catch (Throwable t) { throwable = t; + } finally { + try { is.close(); } + catch (Throwable t) { throwable = t; } } } } + static ProcessResults run(ProcessBuilder pb) { + try { + return run(pb.start()); + } catch (Throwable t) { unexpected(t); return null; } + } + private static ProcessResults run(Process p) { Throwable throwable = null; int exitValue = -1; diff --git a/test/java/lang/instrument/BootClassPath/BootClassPathTest.sh b/test/java/lang/instrument/BootClassPath/BootClassPathTest.sh index f5b79a6f640bcc401809a4475370aeb2039b3ab3..937b66004314183489ba95ac933c95ce2e8450fe 100644 --- a/test/java/lang/instrument/BootClassPath/BootClassPathTest.sh +++ b/test/java/lang/instrument/BootClassPath/BootClassPathTest.sh @@ -23,8 +23,10 @@ # @test # @bug 5055293 -# @summary Test non US-ASCII characters in the value of the Boot-Class-Path +# @summary Test non US-ASCII characters in the value of the Boot-Class-Path # attribute. +# +# @run shell/timeout=240 BootClassPathTest.sh if [ "${TESTJAVA}" = "" ] then @@ -72,7 +74,7 @@ echo "Creating agent jar file..." echo "Running test..." -"${JAVA}" -javaagent:"${TESTCLASSES}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain +"${JAVA}" ${TESTVMOPTS} -javaagent:"${TESTCLASSES}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain result=$? echo "Cleanup..." diff --git a/test/java/lang/instrument/MakeJAR2.sh b/test/java/lang/instrument/MakeJAR2.sh index 2ee0c1254a98434bb86f9e5caba49f91dd0853c9..6b6721ed5501597b2ac63887154d46933b97c871 100644 --- a/test/java/lang/instrument/MakeJAR2.sh +++ b/test/java/lang/instrument/MakeJAR2.sh @@ -70,9 +70,11 @@ JAR="${TESTJAVA}/bin/jar" cp ${TESTSRC}/${AGENT}.java . cp ${TESTSRC}/${APP}.java . rm -rf ilib -cp -r ${TESTSRC}/ilib . -mkdir bootpath -cp -r ${TESTSRC}/bootreporter bootpath +mkdir ilib +cp ${TESTSRC}/ilib/*.java ilib +rm -rf bootpath +mkdir -p bootpath/bootreporter +cp ${TESTSRC}/bootreporter/*.java bootpath/bootreporter cd bootpath ${JAVAC} bootreporter/*.java diff --git a/test/java/lang/instrument/ManifestTest.sh b/test/java/lang/instrument/ManifestTest.sh new file mode 100644 index 0000000000000000000000000000000000000000..c65bb90f514a1be11a54651fac758f78fdc40f3f --- /dev/null +++ b/test/java/lang/instrument/ManifestTest.sh @@ -0,0 +1,483 @@ +# +# Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +# @test +# @bug 6274276 +# @summary JLI JAR manifest processing should ignore leading and trailing white space. +# @author Daniel D. Daugherty +# +# @run build ManifestTestApp +# @run shell/timeout=900 ManifestTest.sh +# + +make_a_JAR() { + # version_line and premain_line are required + version_line="Manifest-Version: 1.0" + premain_line="Premain-Class: ${AGENT}" + boot_cp_line="" + expect_boot_cp_line="ExampleForBootClassPath was not loaded." + can_redef_line="" + expect_redef_line="isRedefineClassesSupported()=false" + can_retrans_line="" + expect_retrans_line="isRetransformClassesSupported()=false" + can_set_nmp_line="" + expect_set_nmp_line="isNativeMethodPrefixSupported()=false" + + while [ $# != 0 ] ; do + case "$1" in + defaults) + # just use the defaults for the test + ;; + + boot_cp_line1) + boot_cp_line="Boot-Class-Path: no_white_space" + expect_boot_cp_line="ExampleForBootClassPath was loaded." + mkdir -p no_white_space + cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class no_white_space + ;; + + boot_cp_line2) + boot_cp_line="Boot-Class-Path: has_leading_blank" + expect_boot_cp_line="ExampleForBootClassPath was loaded." + mkdir -p has_leading_blank " has_leading_blank" + # the good class is in the directory without the blank + cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class \ + has_leading_blank + # the bad class is in the directory with the blank + cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class.bad \ + " has_leading_blank"/ExampleForBootClassPath.class + ;; + + boot_cp_line3) + boot_cp_line="Boot-Class-Path: has_trailing_blank " + expect_boot_cp_line="ExampleForBootClassPath was loaded." + mkdir -p has_trailing_blank "has_trailing_blank " + # the good class is in the directory without the blank + cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class \ + has_trailing_blank + # the bad class is in the directory with the blank + cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class.bad \ + "has_trailing_blank "/ExampleForBootClassPath.class + ;; + + boot_cp_line4) + boot_cp_line="Boot-Class-Path: has_leading_and_trailing_blank " + expect_boot_cp_line="ExampleForBootClassPath was loaded." + mkdir -p has_leading_and_trailing_blank \ + " has_leading_and_trailing_blank " + # the good class is in the directory without the blanks + cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class \ + has_leading_and_trailing_blank + # the bad class is in the directory with the blanks + cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class.bad \ + " has_leading_and_trailing_blank "/ExampleForBootClassPath.class + ;; + + boot_cp_line5) + boot_cp_line="Boot-Class-Path: has_embedded blank" + expect_boot_cp_line="ExampleForBootClassPath was loaded." + mkdir -p has_embedded "has_embedded blank" + # the good class is in the first blank separated word + cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class has_embedded + # the bad class is in the directory with the blank + cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class.bad \ + "has_embedded blank"/ExampleForBootClassPath.class + ;; + + can_redef_line1) + can_redef_line="Can-Redefine-Classes: true" + expect_redef_line="isRedefineClassesSupported()=true" + ;; + + can_redef_line2) + can_redef_line="Can-Redefine-Classes: true" + expect_redef_line="isRedefineClassesSupported()=true" + ;; + + can_redef_line3) + can_redef_line="Can-Redefine-Classes: true " + expect_redef_line="isRedefineClassesSupported()=true" + ;; + + can_redef_line4) + can_redef_line="Can-Redefine-Classes: true " + expect_redef_line="isRedefineClassesSupported()=true" + ;; + + can_redef_line5) + can_redef_line="Can-Redefine-Classes: false" + ;; + + can_redef_line6) + can_redef_line="Can-Redefine-Classes: false" + ;; + + can_redef_line7) + can_redef_line="Can-Redefine-Classes: false " + ;; + + can_redef_line8) + can_redef_line="Can-Redefine-Classes: false " + ;; + + can_redef_line9) + # this line makes the jar command unhappy and that's + # not what we're testing so skip this case + can_redef_line="Can-Redefine-Classes:" + ;; + + can_redef_line10) + can_redef_line="Can-Redefine-Classes: " + ;; + + can_redef_line11) + can_redef_line="Can-Redefine-Classes: " + ;; + + can_retrans_line1) + can_retrans_line="Can-Retransform-Classes: true" + expect_retrans_line="isRetransformClassesSupported()=true" + ;; + + can_retrans_line2) + can_retrans_line="Can-Retransform-Classes: true" + expect_retrans_line="isRetransformClassesSupported()=true" + ;; + + can_retrans_line3) + can_retrans_line="Can-Retransform-Classes: true " + expect_retrans_line="isRetransformClassesSupported()=true" + ;; + + can_retrans_line4) + can_retrans_line="Can-Retransform-Classes: true " + expect_retrans_line="isRetransformClassesSupported()=true" + ;; + + can_retrans_line5) + can_retrans_line="Can-Retransform-Classes: false" + ;; + + can_retrans_line6) + can_retrans_line="Can-Retransform-Classes: false" + ;; + + can_retrans_line7) + can_retrans_line="Can-Retransform-Classes: false " + ;; + + can_retrans_line8) + can_retrans_line="Can-Retransform-Classes: false " + ;; + + can_retrans_line9) + # this line makes the jar command unhappy and that's + # not what we're testing so skip this case + can_retrans_line="Can-Retransform-Classes:" + ;; + + can_retrans_line10) + can_retrans_line="Can-Retransform-Classes: " + ;; + + can_retrans_line11) + can_retrans_line="Can-Retransform-Classes: " + ;; + + can_set_nmp_line1) + can_set_nmp_line="Can-Set-Native-Method-Prefix: true" + expect_set_nmp_line="isNativeMethodPrefixSupported()=true" + ;; + + can_set_nmp_line2) + can_set_nmp_line="Can-Set-Native-Method-Prefix: true" + expect_set_nmp_line="isNativeMethodPrefixSupported()=true" + ;; + + can_set_nmp_line3) + can_set_nmp_line="Can-Set-Native-Method-Prefix: true " + expect_set_nmp_line="isNativeMethodPrefixSupported()=true" + ;; + + can_set_nmp_line4) + can_set_nmp_line="Can-Set-Native-Method-Prefix: true " + expect_set_nmp_line="isNativeMethodPrefixSupported()=true" + ;; + + can_set_nmp_line5) + can_set_nmp_line="Can-Set-Native-Method-Prefix: false" + ;; + + can_set_nmp_line6) + can_set_nmp_line="Can-Set-Native-Method-Prefix: false" + ;; + + can_set_nmp_line7) + can_set_nmp_line="Can-Set-Native-Method-Prefix: false " + ;; + + can_set_nmp_line8) + can_set_nmp_line="Can-Set-Native-Method-Prefix: false " + ;; + + can_set_nmp_line9) + # this line makes the jar command unhappy and that's + # not what we're testing so skip this case + can_set_nmp_line="Can-Set-Native-Method-Prefix:" + ;; + + can_set_nmp_line10) + can_set_nmp_line="Can-Set-Native-Method-Prefix: " + ;; + + can_set_nmp_line11) + can_set_nmp_line="Can-Set-Native-Method-Prefix: " + ;; + + premain_line1) + premain_line="Premain-Class: ${AGENT}" + ;; + + premain_line2) + premain_line="Premain-Class: ${AGENT} " + ;; + + premain_line3) + premain_line="Premain-Class: ${AGENT} " + ;; + + version_line1) + version_line="Manifest-Version: 1.0" + ;; + + version_line2) + version_line="Manifest-Version: 1.0 " + ;; + + version_line3) + version_line="Manifest-Version: 1.0 " + ;; + + *) + echo "ERROR: invalid test token" + exit 1 + esac + shift + done + + echo "${version_line}" > ${AGENT}.mf + echo "${premain_line}" >> ${AGENT}.mf + + if [ -n "$boot_cp_line" ]; then + echo "${boot_cp_line}" >> ${AGENT}.mf + fi + + if [ -n "$can_redef_line" ]; then + echo "${can_redef_line}" >> ${AGENT}.mf + fi + + if [ -n "$can_retrans_line" ]; then + echo "${can_retrans_line}" >> ${AGENT}.mf + fi + + if [ -n "$can_set_nmp_line" ]; then + echo "${can_set_nmp_line}" >> ${AGENT}.mf + fi + + rm -f ${AGENT}.jar + ${JAR} cvfm ${AGENT}.jar ${AGENT}.mf ${AGENT}.class + + echo "$expect_boot_cp_line" > expect_boot_cp_line + echo "$expect_redef_line" > expect_redef_line + echo "$expect_retrans_line" > expect_retrans_line + echo "$expect_set_nmp_line" > expect_set_nmp_line +} + +if [ "${TESTJAVA}" = "" ] +then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTSRC}" = "" ] +then + echo "TESTSRC not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTCLASSES}" = "" ] +then + echo "TESTCLASSES not set. Test cannot execute. Failed." + exit 1 +fi + +JAR="${TESTJAVA}/bin/jar" +JAVAC="${TESTJAVA}"/bin/javac +JAVA="${TESTJAVA}"/bin/java + +# Now that ManifestTestApp.class is built, we move +# ExampleForBootClassPath.class so that it cannot be found +# by default +OUT_OF_THE_WAY=out_of_the_way +mkdir $OUT_OF_THE_WAY +mv "${TESTCLASSES}/ExampleForBootClassPath.class" $OUT_OF_THE_WAY + +# create a bad version of ExampleForBootClassPath.class +# so we can tell when the wrong version is run +sed 's/return 15/return 42/' "${TESTSRC}"/ExampleForBootClassPath.java \ + > ExampleForBootClassPath.java +"$JAVAC" ExampleForBootClassPath.java +mv ExampleForBootClassPath.class \ + $OUT_OF_THE_WAY/ExampleForBootClassPath.class.bad +mv ExampleForBootClassPath.java \ + $OUT_OF_THE_WAY/ExampleForBootClassPath.java.bad + +AGENT=ManifestTestAgent +# We compile the agent in the working directory instead of with +# a build task because we construct a different agent JAR file +# for each test case. +${JAVAC} -d . ${TESTSRC}/${AGENT}.java + +FAIL_MARKER=fail_marker +rm -f $FAIL_MARKER + +while read token; do + echo + echo "===== begin test case: $token =====" + make_a_JAR "$token" + + "${JAVA}" ${TESTVMOPTS} -javaagent:${AGENT}.jar \ + -classpath "${TESTCLASSES}" ManifestTestApp > output.log 2>&1 + result=$? + + cat output.log + + if [ "$result" = 0 ]; then + echo "PASS: ManifestTestApp exited with status of 0." + else + echo "FAIL: ManifestTestApp exited with status of $result" + touch $FAIL_MARKER + fi + + MESG="Hello from ${AGENT}!" + grep -s "$MESG" output.log > /dev/null + result=$? + if [ "$result" = 0 ]; then + echo "PASS: found '$MESG' in the test output" + else + echo "FAIL: did NOT find '$MESG' in the test output" + touch $FAIL_MARKER + fi + + MESG=`cat expect_boot_cp_line` + grep -s "$MESG" output.log > /dev/null + result=$? + if [ "$result" = 0 ]; then + echo "PASS: found '$MESG' in the test output" + else + echo "FAIL: did NOT find '$MESG' in the test output" + touch $FAIL_MARKER + fi + + MESG=`cat expect_redef_line` + grep -s "$MESG" output.log > /dev/null + result=$? + if [ "$result" = 0 ]; then + echo "PASS: found '$MESG' in the test output" + else + echo "FAIL: did NOT find '$MESG' in the test output" + touch $FAIL_MARKER + fi + + MESG=`cat expect_retrans_line` + grep -s "$MESG" output.log > /dev/null + result=$? + if [ "$result" = 0 ]; then + echo "PASS: found '$MESG' in the test output" + else + echo "FAIL: did NOT find '$MESG' in the test output" + touch $FAIL_MARKER + fi + + MESG=`cat expect_set_nmp_line` + grep -s "$MESG" output.log > /dev/null + result=$? + if [ "$result" = 0 ]; then + echo "PASS: found '$MESG' in the test output" + else + echo "FAIL: did NOT find '$MESG' in the test output" + touch $FAIL_MARKER + fi + + echo "===== end test case: $token =====" + echo +done << EOF +defaults +version_line1 +version_line2 +version_line3 +premain_line1 +premain_line2 +premain_line3 +boot_cp_line1 +boot_cp_line2 +boot_cp_line3 +boot_cp_line4 +boot_cp_line5 +can_redef_line1 +can_redef_line2 +can_redef_line3 +can_redef_line4 +can_redef_line5 +can_redef_line6 +can_redef_line7 +can_redef_line8 +can_redef_line10 +can_redef_line11 +can_retrans_line1 +can_retrans_line2 +can_retrans_line3 +can_retrans_line4 +can_retrans_line5 +can_retrans_line6 +can_retrans_line7 +can_retrans_line8 +can_retrans_line10 +can_retrans_line11 +can_set_nmp_line1 +can_set_nmp_line2 +can_set_nmp_line3 +can_set_nmp_line4 +can_set_nmp_line5 +can_set_nmp_line6 +can_set_nmp_line7 +can_set_nmp_line8 +can_set_nmp_line10 +can_set_nmp_line11 +EOF + +if [ -f $FAIL_MARKER ]; then + exit 1 +else + exit 0 +fi diff --git a/test/java/lang/instrument/ManifestTestAgent.java b/test/java/lang/instrument/ManifestTestAgent.java new file mode 100644 index 0000000000000000000000000000000000000000..e8b4252a51c9528b62d36f87b84500d093f7e2ae --- /dev/null +++ b/test/java/lang/instrument/ManifestTestAgent.java @@ -0,0 +1,41 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.lang.instrument.Instrumentation; + +public class ManifestTestAgent { + private static Instrumentation instrumentation; + + private ManifestTestAgent() { + } + + public static void premain(String agentArgs, Instrumentation inst) { + System.out.println("Hello from ManifestTestAgent!"); + System.out.println("isNativeMethodPrefixSupported()=" + + inst.isNativeMethodPrefixSupported()); + System.out.println("isRedefineClassesSupported()=" + + inst.isRedefineClassesSupported()); + System.out.println("isRetransformClassesSupported()=" + + inst.isRetransformClassesSupported()); + } +} diff --git a/test/java/lang/instrument/ManifestTestApp.java b/test/java/lang/instrument/ManifestTestApp.java new file mode 100644 index 0000000000000000000000000000000000000000..c1d8482f789646016506b7dc4a8cebac649bb3f4 --- /dev/null +++ b/test/java/lang/instrument/ManifestTestApp.java @@ -0,0 +1,69 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +public class ManifestTestApp { + public static void main(String args[]) { + System.out.println("Hello from ManifestTestApp!"); + + new ManifestTestApp().doTest(); + System.exit(0); + } + + private void doTest() { + try { + // load the class only found via the Boot-Class-Path attribute + Object instance = loadExampleClass(); + if (instance.getClass().getClassLoader() == null) { + System.out.println("PASS: ExampleForBootClassPath was loaded" + + " by the boot class path loader."); + } else { + System.out.println("FAIL: ExampleForBootClassPath was loaded" + + " by a non-boot class path loader."); + System.exit(1); + } + } catch (NoClassDefFoundError ncdfe) { + // This message just lets ManifestTest.sh know whether or + // not ExampleForBootClassPath was loaded. Depending on + // the current test case, that will be either a PASSing + // condition or a FAILing condition as determined by + // ManifestTest.sh. + System.out.println("ExampleForBootClassPath was not loaded."); + } + } + + Object loadExampleClass() { + ExampleForBootClassPath instance = new ExampleForBootClassPath(); + System.out.println("ExampleForBootClassPath was loaded."); + if (instance.fifteen() == 15) { + System.out.println("PASS: the correct" + + " ExampleForBootClassPath was loaded."); + } else { + System.out.println("FAIL: the wrong ExampleForBootClassPath" + + " was loaded."); + System.out.println("FAIL: instance.fifteen()=" + + instance.fifteen()); + System.exit(1); + } + return instance; + } +} diff --git a/test/java/lang/instrument/NativeMethodPrefixAgent.java b/test/java/lang/instrument/NativeMethodPrefixAgent.java index a31a4d1c9762abd2cbb39dc160d0ab985c1becda..5ff3d5599e294e7751283953cba0b3ad64a2b8a7 100644 --- a/test/java/lang/instrument/NativeMethodPrefixAgent.java +++ b/test/java/lang/instrument/NativeMethodPrefixAgent.java @@ -27,7 +27,7 @@ * @summary test setNativeMethodPrefix * @author Robert Field, Sun Microsystems * - * @run shell MakeJAR2.sh NativeMethodPrefixAgent NativeMethodPrefixApp 'Can-Retransform-Classes: true' 'Can-Set-Native-Method-Prefix: true' + * @run shell/timeout=240 MakeJAR2.sh NativeMethodPrefixAgent NativeMethodPrefixApp 'Can-Retransform-Classes: true' 'Can-Set-Native-Method-Prefix: true' * @run main/othervm -javaagent:NativeMethodPrefixAgent.jar NativeMethodPrefixApp */ diff --git a/test/java/lang/instrument/ParallelTransformerLoader.sh b/test/java/lang/instrument/ParallelTransformerLoader.sh new file mode 100644 index 0000000000000000000000000000000000000000..cab081a5176926d9fdcbe6234416b5aa5da99226 --- /dev/null +++ b/test/java/lang/instrument/ParallelTransformerLoader.sh @@ -0,0 +1,72 @@ +# +# Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +# @test +# @bug 5088398 +# @summary Test parallel class loading by parallel transformers. +# @author Daniel D. Daugherty as modified from the code of Daryl Puryear @ Wily +# +# @run shell MakeJAR3.sh ParallelTransformerLoaderAgent +# @run build ParallelTransformerLoaderApp +# @run shell/timeout=240 ParallelTransformerLoader.sh +# + +if [ "${TESTJAVA}" = "" ] +then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTSRC}" = "" ] +then + echo "TESTSRC not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTCLASSES}" = "" ] +then + echo "TESTCLASSES not set. Test cannot execute. Failed." + exit 1 +fi + +JAR="${TESTJAVA}"/bin/jar +JAVAC="${TESTJAVA}"/bin/javac +JAVA="${TESTJAVA}"/bin/java + +"${JAVAC}" -d . \ + "${TESTSRC}"/TestClass1.java \ + "${TESTSRC}"/TestClass2.java \ + "${TESTSRC}"/TestClass3.java + +"${JAR}" cvf Test.jar Test*.class +# Removing the test class files is important. If these +# .class files are available on the classpath other +# than via Test.jar, then the deadlock will not reproduce. +rm -f Test*.class + +"${JAVA}" ${TESTVMOPTS} -javaagent:ParallelTransformerLoaderAgent.jar=Test.jar \ + -classpath "${TESTCLASSES}" ParallelTransformerLoaderApp +result=$? +echo "result=$result" + +exit $result diff --git a/test/java/lang/instrument/ParallelTransformerLoaderAgent.java b/test/java/lang/instrument/ParallelTransformerLoaderAgent.java new file mode 100644 index 0000000000000000000000000000000000000000..9b707eb22af06b8e9d54abe8ad84b86cc89dd6e8 --- /dev/null +++ b/test/java/lang/instrument/ParallelTransformerLoaderAgent.java @@ -0,0 +1,120 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.lang.instrument.*; +import java.net.*; +import java.io.*; +import java.security.*; + +/** + * Test Java Agent + * + * @author Daryl Puryear + * @copyright 1999-2004 Wily Technology, Inc. All rights reserved. + */ +public class ParallelTransformerLoaderAgent +{ + private static URL sURL; + private static ClassLoader sClassLoader; + + public static synchronized ClassLoader + getClassLoader() + { + return sClassLoader; + } + + public static synchronized void + generateNewClassLoader() + { + sClassLoader = new URLClassLoader(new URL[] {sURL}); + } + + public static void + premain( String agentArgs, + Instrumentation instrumentation) + throws Exception + { + if (agentArgs == null || agentArgs == "") + { + System.err.println("Error: No jar file name provided, test will not run."); + return; + } + + sURL = (new File(agentArgs)).toURL(); + System.out.println("Using jar file: " + sURL); + generateNewClassLoader(); + + instrumentation.addTransformer(new TestTransformer()); + } + + private static class TestTransformer + implements ClassFileTransformer + { + public byte[] + transform( ClassLoader loader, + String className, + Class classBeingRedefined, + ProtectionDomain protectionDomain, + byte[] classfileBuffer) + throws IllegalClassFormatException + { + String tName = Thread.currentThread().getName(); + // In 160_03 and older, transform() is called + // with the "system_loader_lock" held and that + // prevents the bootstrap class loaded from + // running in parallel. If we add a slight sleep + // delay here when the transform() call is not + // main or TestThread, then the deadlock in + // 160_03 and older is much more reproducible. + if (!tName.equals("main") && !tName.equals("TestThread")) { + System.out.println("Thread '" + tName + + "' has called transform()"); + try { + Thread.sleep(500); + } catch (InterruptedException ie) { + } + } + + // load additional classes when called from other threads + if (!tName.equals("main")) + { + loadClasses(3); + } + return null; + } + + public static void + loadClasses( int index) + { + ClassLoader loader = ParallelTransformerLoaderAgent.getClassLoader(); + try + { + Class.forName("TestClass" + index, true, loader); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } +} diff --git a/test/java/lang/instrument/ParallelTransformerLoaderApp.java b/test/java/lang/instrument/ParallelTransformerLoaderApp.java new file mode 100644 index 0000000000000000000000000000000000000000..62216e2d0c6c62f7aabb21643dd230328220825b --- /dev/null +++ b/test/java/lang/instrument/ParallelTransformerLoaderApp.java @@ -0,0 +1,90 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * Test Java Program + * + * @author Daryl Puryear + * @copyright 1999-2004 Wily Technology, Inc. All rights reserved. + */ +public class ParallelTransformerLoaderApp +{ + private static final int kNumIterations = 1000; + + public static void + main( String[] args) + throws Exception + { + System.out.println(); + System.out.print("Starting test with " + kNumIterations + " iterations"); + for (int i = 0; i < kNumIterations; i++) + { + // load some classes from multiple threads (this thread and one other) + Thread testThread = new TestThread(2); + testThread.start(); + loadClasses(1); + + // log that it completed and reset for the next iteration + testThread.join(); + System.out.print("."); + ParallelTransformerLoaderAgent.generateNewClassLoader(); + } + + System.out.println(); + System.out.println("Test completed successfully"); + } + + private static class TestThread + extends Thread + { + private final int fIndex; + + public + TestThread( int index) + { + super("TestThread"); + + fIndex = index; + } + + public void + run() + { + loadClasses(fIndex); + } + } + + public static void + loadClasses( int index) + { + ClassLoader loader = ParallelTransformerLoaderAgent.getClassLoader(); + try + { + Class.forName("TestClass" + index, true, loader); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/test/java/lang/instrument/PremainClass/DummyMain.java b/test/java/lang/instrument/PremainClass/DummyMain.java index e5fd157e55b70bc3f80d4ca53069cc0665c6cdd4..0cf20ef6c1f631145b94a1d4c7d140880e81af6e 100644 --- a/test/java/lang/instrument/PremainClass/DummyMain.java +++ b/test/java/lang/instrument/PremainClass/DummyMain.java @@ -22,11 +22,10 @@ */ /* - * - * - * Used by PremainClassTest.sh - dummy "main application" which doesn't do anything + * dummy "Hello World"ish application for "premain" tests */ public class DummyMain { public static void main(String[] args) { + System.out.println("Hello from DummyMain!"); } } diff --git a/test/java/lang/instrument/PremainClass/InheritAgent0001.java b/test/java/lang/instrument/PremainClass/InheritAgent0001.java new file mode 100644 index 0000000000000000000000000000000000000000..41e574f284cadc13ffa6fe5335a908c0fc091a43 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent0001.java @@ -0,0 +1,54 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (0,0,0,1): declared 1-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent0001 + * @run main/othervm -javaagent:InheritAgent0001.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent0001 extends InheritAgent0001Super { + + // + // This agent has a single argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent0001!"); + } + + // This agent does NOT have a double argument premain() method. +} + +class InheritAgent0001Super { + + // This agent does NOT have a single argument premain() method. + + // This agent does NOT have a double argument premain() method. +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent0010.java b/test/java/lang/instrument/PremainClass/InheritAgent0010.java new file mode 100644 index 0000000000000000000000000000000000000000..a9bdf2be25eeaa5c24cd1dfde63c6aef07558500 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent0010.java @@ -0,0 +1,54 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (0,0,1,0): declared 2-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent0010 + * @run main/othervm -javaagent:InheritAgent0010.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent0010 extends InheritAgent0010Super { + + // This agent does NOT have a single argument premain() method. + + // + // This agent has a double argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent0010!"); + } +} + +class InheritAgent0010Super { + + // This agent does NOT have a single argument premain() method. + + // This agent does NOT have a double argument premain() method. +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent0011.java b/test/java/lang/instrument/PremainClass/InheritAgent0011.java new file mode 100644 index 0000000000000000000000000000000000000000..ea7012d0f2534af0c169b37b75f2247e7387dffc --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent0011.java @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (0,0,1,1): declared 2-arg and declared 1-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent0011 + * @run main/othervm -javaagent:InheritAgent0011.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent0011 extends InheritAgent0011Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent0011!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // + // This agent has a double argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent0011!"); + } +} + +class InheritAgent0011Super { + + // This agent does NOT have a single argument premain() method. + + // This agent does NOT have a double argument premain() method. +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent0100.java b/test/java/lang/instrument/PremainClass/InheritAgent0100.java new file mode 100644 index 0000000000000000000000000000000000000000..273471b68c53b59640897a2168c5a691df71ee56 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent0100.java @@ -0,0 +1,54 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (0,1,0,0): inherited 1-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent0100 + * @run main/othervm -javaagent:InheritAgent0100.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent0100 extends InheritAgent0100Super { + + // This agent does NOT have a single argument premain() method. + + // This agent does NOT have a double argument premain() method. +} + +class InheritAgent0100Super { + + // + // This agent has a single argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent0100Super!"); + } + + // This agent does NOT have a double argument premain() method. +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent0101.java b/test/java/lang/instrument/PremainClass/InheritAgent0101.java new file mode 100644 index 0000000000000000000000000000000000000000..a6bbcf91d3342dd70d7ee9653b66dfd1219a97fe --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent0101.java @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (0,1,0,1): inherited 1-arg and declared 1-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent0101 + * @run main/othervm -javaagent:InheritAgent0101.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent0101 extends InheritAgent0101Super { + + // + // This agent has a single argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent0101!"); + } + + // This agent does NOT have a double argument premain() method. +} + +class InheritAgent0101Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent0101Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // This agent does NOT have a double argument premain() method. +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent0110.java b/test/java/lang/instrument/PremainClass/InheritAgent0110.java new file mode 100644 index 0000000000000000000000000000000000000000..712d746aaf76451cc844ccfe1d2727cd606d1da3 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent0110.java @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (0,1,1,0): inherited 1-arg and declared 2-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent0110 + * @run main/othervm -javaagent:InheritAgent0110.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent0110 extends InheritAgent0110Super { + + // This agent does NOT have a one argument premain() method. + + // + // This agent has a double argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent0110!"); + } +} + +class InheritAgent0110Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent0110Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // This agent does NOT have a double argument premain() method. +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent0111.java b/test/java/lang/instrument/PremainClass/InheritAgent0111.java new file mode 100644 index 0000000000000000000000000000000000000000..cf482236d204f5b24bafcb07a94cce5678b25bc2 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent0111.java @@ -0,0 +1,69 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (0,1,1,1): inherited 1-arg, declared 2-arg and declared 1-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent0111 + * @run main/othervm -javaagent:InheritAgent0111.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent0111 extends InheritAgent0111Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent0111!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // + // This agent has a double argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent0111!"); + } + +} + +class InheritAgent0111Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent0111Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // This agent does NOT have a double argument premain() method. +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent1000.java b/test/java/lang/instrument/PremainClass/InheritAgent1000.java new file mode 100644 index 0000000000000000000000000000000000000000..6b9f2259a3a8da7fa3a5e46d0637aa7aafd65ebc --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent1000.java @@ -0,0 +1,54 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (1,0,0,0): inherited 2-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent1000 + * @run main/othervm -javaagent:InheritAgent1000.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent1000 extends InheritAgent1000Super { + + // This agent does NOT have a single argument premain() method. + + // This agent does NOT have a double argument premain() method. +} + +class InheritAgent1000Super { + + // This agent does NOT have a single argument premain() method. + + // + // This agent has a double argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1000Super!"); + } +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent1001.java b/test/java/lang/instrument/PremainClass/InheritAgent1001.java new file mode 100644 index 0000000000000000000000000000000000000000..a9abd92b29b5f50fc6bb5ccae9a64abca889c796 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent1001.java @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (1,0,0,1): inherited 2-arg, and declared 1-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent1001 + * @run main/othervm -javaagent:InheritAgent1001.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent1001 extends InheritAgent1001Super { + + // + // This agent has a single argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent1001!"); + } + + // This agent does NOT have a double argument premain() method. +} + +class InheritAgent1001Super { + + // This agent does NOT have a single argument premain() method. + + // + // This agent has a double argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1001Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent1010.java b/test/java/lang/instrument/PremainClass/InheritAgent1010.java new file mode 100644 index 0000000000000000000000000000000000000000..4a59d521bafc75c19c5e59b381ff04aa90fbe4cb --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent1010.java @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (1,0,1,0): inherited 2-arg, and declared 2-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent1010 + * @run main/othervm -javaagent:InheritAgent1010.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent1010 extends InheritAgent1010Super { + + // This agent does NOT have a single argument premain() method. + + // + // This agent has a double argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1010!"); + } +} + +class InheritAgent1010Super { + + // This agent does NOT have a single argument premain() method. + + // + // This agent has a double argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1010Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent1011.java b/test/java/lang/instrument/PremainClass/InheritAgent1011.java new file mode 100644 index 0000000000000000000000000000000000000000..ea337b2c764a8ae35e52f7c754bbe323c02ee2e0 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent1011.java @@ -0,0 +1,68 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (1,0,1,1): inherited 2-arg, declared 2-arg and declared 1-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent1011 + * @run main/othervm -javaagent:InheritAgent1011.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent1011 extends InheritAgent1011Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent1011!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // + // This agent has a double argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1011!"); + } +} + +class InheritAgent1011Super { + + // This agent does NOT have a single argument premain() method. + + // + // This agent has a double argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1011Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent1100.java b/test/java/lang/instrument/PremainClass/InheritAgent1100.java new file mode 100644 index 0000000000000000000000000000000000000000..30dc128f10e38da108ffc4fff2c53dd76814cecd --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent1100.java @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (1,1,0,0): inherited 2-arg and inherited 1-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent1100 + * @run main/othervm -javaagent:InheritAgent1100.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent1100 extends InheritAgent1100Super { + + // This agent does NOT have a single argument premain() method. + + // This agent does NOT have a double argument premain() method. +} + +class InheritAgent1100Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent1100Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // + // This agent has a double argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1100Super!"); + } +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent1101.java b/test/java/lang/instrument/PremainClass/InheritAgent1101.java new file mode 100644 index 0000000000000000000000000000000000000000..09ae7b7519b82d7bc8fd78a19b8a10ea91cbe6a0 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent1101.java @@ -0,0 +1,68 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (1,1,0,1): inherited 2-arg, inherited 1-arg, and declared 1-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent1101 + * @run main/othervm -javaagent:InheritAgent1101.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent1101 extends InheritAgent1101Super { + + // + // This agent has a single argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent1101!"); + } + + // This agent does NOT have a double argument premain() method. +} + +class InheritAgent1101Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent1101Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // + // This agent has a double argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1101Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent1110.java b/test/java/lang/instrument/PremainClass/InheritAgent1110.java new file mode 100644 index 0000000000000000000000000000000000000000..079578b18ff089c75a471a33bfd0e7b16ee35360 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent1110.java @@ -0,0 +1,68 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (1,1,1,0): inherited 2-arg, inherited 1-arg, and declared 2-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent1110 + * @run main/othervm -javaagent:InheritAgent1110.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent1110 extends InheritAgent1110Super { + + // This agent does NOT have a single argument premain() method. + + // + // This agent has a double argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1110!"); + } +} + +class InheritAgent1110Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent1110Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // + // This agent has a double argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1110Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } +} diff --git a/test/java/lang/instrument/PremainClass/InheritAgent1111.java b/test/java/lang/instrument/PremainClass/InheritAgent1111.java new file mode 100644 index 0000000000000000000000000000000000000000..e891c86b2f94e105c74ffb2a27692ce30c85e14b --- /dev/null +++ b/test/java/lang/instrument/PremainClass/InheritAgent1111.java @@ -0,0 +1,75 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6289149 + * @summary test config (1,1,1,1): inherited 2-arg, inherited 1-arg, declared 2-arg and declared 1-arg in agent class + * @author Daniel D. Daugherty, Sun Microsystems + * + * @run shell ../MakeJAR3.sh InheritAgent1111 + * @run main/othervm -javaagent:InheritAgent1111.jar DummyMain + */ + +import java.lang.instrument.*; + +class InheritAgent1111 extends InheritAgent1111Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent1111!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // + // This agent has a double argument premain() method which + // is the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1111!"); + } +} + +class InheritAgent1111Super { + + // + // This agent has a single argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs) { + System.out.println("Hello from Single-Arg InheritAgent1111Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } + + // + // This agent has a double argument premain() method which + // is NOT the one that should be called. + // + public static void premain (String agentArgs, Instrumentation instArg) { + System.out.println("Hello from Double-Arg InheritAgent1111Super!"); + throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED."); + } +} diff --git a/test/java/lang/instrument/PremainClass/NoPremainAgent.java b/test/java/lang/instrument/PremainClass/NoPremainAgent.java new file mode 100644 index 0000000000000000000000000000000000000000..f534453103bca6fad301d6a56bd8d52ddefa0c88 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/NoPremainAgent.java @@ -0,0 +1,29 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.lang.instrument.*; + +class NoPremainAgent { + + // This agent is missing the premain() function. +} diff --git a/test/java/lang/instrument/PremainClass/NoPremainAgent.sh b/test/java/lang/instrument/PremainClass/NoPremainAgent.sh new file mode 100644 index 0000000000000000000000000000000000000000..dc957c6e60580c3735edd8da4720a545f10bf817 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/NoPremainAgent.sh @@ -0,0 +1,68 @@ +# +# Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +# @test +# @bug 6289149 +# @summary test when the agent's class is missing the premain() function. +# @author Daniel D. Daugherty, Sun Microsystems +# +# @run build DummyMain +# @run shell ../MakeJAR3.sh NoPremainAgent +# @run shell NoPremainAgent.sh +# + +if [ "${TESTJAVA}" = "" ] +then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTSRC}" = "" ] +then + echo "TESTSRC not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTCLASSES}" = "" ] +then + echo "TESTCLASSES not set. Test cannot execute. Failed." + exit 1 +fi + +JAVAC="${TESTJAVA}"/bin/javac +JAVA="${TESTJAVA}"/bin/java + +"${JAVA}" ${TESTVMOPTS} -javaagent:NoPremainAgent.jar \ + -classpath "${TESTCLASSES}" DummyMain > output.log 2>&1 +cat output.log + +MESG="java.lang.NoSuchMethodException" +grep "$MESG" output.log +result=$? +if [ "$result" = 0 ]; then + echo "PASS: found '$MESG' in the test output" +else + echo "FAIL: did NOT find '$MESG' in the test output" +fi + +exit $result diff --git a/test/java/lang/instrument/PremainClass/PremainClassTest.sh b/test/java/lang/instrument/PremainClass/PremainClassTest.sh index 7295c34071375daa2c2e80450b11bb12014cc4cc..d6c34e44f57dce0411132323ceba30cda0617be7 100644 --- a/test/java/lang/instrument/PremainClass/PremainClassTest.sh +++ b/test/java/lang/instrument/PremainClass/PremainClassTest.sh @@ -49,7 +49,7 @@ JAVA="${TESTJAVA}"/bin/java "$JAVAC" -d "${TESTCLASSES}" "${TESTSRC}"/DummyMain.java -"${JAVA}" -javaagent:"${TESTSRC}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain +"${JAVA}" ${TESTVMOPTS} -javaagent:"${TESTSRC}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain result=$? exit $result diff --git a/test/java/lang/instrument/PremainClass/ZeroArgPremainAgent.java b/test/java/lang/instrument/PremainClass/ZeroArgPremainAgent.java new file mode 100644 index 0000000000000000000000000000000000000000..aa6758bd8cc41526eb3b199082e7d82b0732caa8 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/ZeroArgPremainAgent.java @@ -0,0 +1,32 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.lang.instrument.*; + +class ZeroArgPremainAgent { + + // This agent has a zero arg premain() function. + public static void premain () { + System.out.println("Hello from ZeroArgInheritAgent!"); + } +} diff --git a/test/java/lang/instrument/PremainClass/ZeroArgPremainAgent.sh b/test/java/lang/instrument/PremainClass/ZeroArgPremainAgent.sh new file mode 100644 index 0000000000000000000000000000000000000000..a79e38a72bfc480fb04b887a13fd74957950df03 --- /dev/null +++ b/test/java/lang/instrument/PremainClass/ZeroArgPremainAgent.sh @@ -0,0 +1,68 @@ +# +# Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +# @test +# @bug 6289149 +# @summary test when the agent's class has a zero arg premain() function. +# @author Daniel D. Daugherty, Sun Microsystems +# +# @run build DummyMain +# @run shell ../MakeJAR3.sh ZeroArgPremainAgent +# @run shell ZeroArgPremainAgent.sh +# + +if [ "${TESTJAVA}" = "" ] +then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTSRC}" = "" ] +then + echo "TESTSRC not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTCLASSES}" = "" ] +then + echo "TESTCLASSES not set. Test cannot execute. Failed." + exit 1 +fi + +JAVAC="${TESTJAVA}"/bin/javac +JAVA="${TESTJAVA}"/bin/java + +"${JAVA}" ${TESTVMOPTS} -javaagent:ZeroArgPremainAgent.jar \ + -classpath "${TESTCLASSES}" DummyMain > output.log 2>&1 +cat output.log + +MESG="java.lang.NoSuchMethodException" +grep "$MESG" output.log +result=$? +if [ "$result" = 0 ]; then + echo "PASS: found '$MESG' in the test output" +else + echo "FAIL: did NOT find '$MESG' in the test output" +fi + +exit $result diff --git a/test/java/lang/instrument/RedefineClassWithNativeMethod.sh b/test/java/lang/instrument/RedefineClassWithNativeMethod.sh new file mode 100644 index 0000000000000000000000000000000000000000..e6254d7e25d23480c549b36c13687adeca2728b8 --- /dev/null +++ b/test/java/lang/instrument/RedefineClassWithNativeMethod.sh @@ -0,0 +1,81 @@ +# +# Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +# @test +# @bug 5003341 4917140 6545149 +# @summary Redefine a class with a native method. +# @author Daniel D. Daugherty as modified from the test submitted by clovis@par.univie.ac.at +# +# @run shell MakeJAR3.sh RedefineClassWithNativeMethodAgent 'Can-Redefine-Classes: true' +# @run build RedefineClassWithNativeMethodApp +# @run shell RedefineClassWithNativeMethod.sh +# + +if [ "${TESTJAVA}" = "" ] +then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTSRC}" = "" ] +then + echo "TESTSRC not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTCLASSES}" = "" ] +then + echo "TESTCLASSES not set. Test cannot execute. Failed." + exit 1 +fi + +JAVAC="${TESTJAVA}"/bin/javac +JAVA="${TESTJAVA}"/bin/java + +"${JAVA}" ${TESTVMOPTS} \ + -javaagent:RedefineClassWithNativeMethodAgent.jar=java/lang/Thread.class \ + -classpath "${TESTCLASSES}" RedefineClassWithNativeMethodApp \ + > output.log 2>&1 +result=$? + +cat output.log + +if [ "$result" = 0 ]; then + echo "PASS: RedefineClassWithNativeMethodApp exited with status of 0." +else + echo "FAIL: RedefineClassWithNativeMethodApp exited with status of $result" + exit "$result" +fi + +MESG="Exception" +grep "$MESG" output.log +result=$? +if [ "$result" = 0 ]; then + echo "FAIL: found '$MESG' in the test output" + result=1 +else + echo "PASS: did NOT find '$MESG' in the test output" + result=0 +fi + +exit $result diff --git a/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java b/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java new file mode 100644 index 0000000000000000000000000000000000000000..cfb7712aae0907fcb4be242acb1b0284a5d2bd8b --- /dev/null +++ b/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java @@ -0,0 +1,70 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.lang.instrument.*; +import java.net.*; +import java.util.*; +import java.io.*; + +public class RedefineClassWithNativeMethodAgent { + static Class clz; + + // just read the original class and redefine it via a Timer + public static void premain(String agentArgs, final Instrumentation inst) throws Exception { + String s = agentArgs.substring(0, agentArgs.indexOf(".class")); + clz = Class.forName(s.replace('/', '.')); + ClassLoader loader = + RedefineClassWithNativeMethodAgent.class.getClassLoader(); + URL classURL = loader.getResource(agentArgs); + if (classURL == null) { + throw new Exception("Cannot find class: " + agentArgs); + } + + int redefineLength; + InputStream redefineStream; + + System.out.println("Reading test class from " + classURL); + if (classURL.getProtocol().equals("file")) { + File f = new File(classURL.getFile()); + redefineStream = new FileInputStream(f); + redefineLength = (int) f.length(); + } else { + URLConnection conn = classURL.openConnection(); + redefineStream = conn.getInputStream(); + redefineLength = conn.getContentLength(); + } + + final byte[] buffer = new byte[redefineLength]; + new BufferedInputStream(redefineStream).read(buffer); + new Timer(true).schedule(new TimerTask() { + public void run() { + try { + System.out.println("Instrumenting"); + ClassDefinition cld = new ClassDefinition(clz, buffer); + inst.redefineClasses(new ClassDefinition[] { cld }); + } + catch (Exception e) { e.printStackTrace(); } + } + }, 500); + } +} diff --git a/test/java/lang/instrument/RedefineClassWithNativeMethodApp.java b/test/java/lang/instrument/RedefineClassWithNativeMethodApp.java new file mode 100644 index 0000000000000000000000000000000000000000..629704ac03112c2b1a0c3eb7062aa2eb63a9013c --- /dev/null +++ b/test/java/lang/instrument/RedefineClassWithNativeMethodApp.java @@ -0,0 +1,38 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +public class RedefineClassWithNativeMethodApp { + public static void main(String[] args) throws Exception { + try { + // give the agent a chance to redefine the target class + Thread.sleep(2000); + } catch (InterruptedException ie) { + } + + System.out.println("Creating instance of " + + RedefineClassWithNativeMethodAgent.clz); + RedefineClassWithNativeMethodAgent.clz.newInstance(); + + System.exit(0); + } +} diff --git a/test/java/lang/instrument/RedefineMethodAddInvoke.sh b/test/java/lang/instrument/RedefineMethodAddInvoke.sh new file mode 100644 index 0000000000000000000000000000000000000000..641d56246cc3dd0a11a89c1e441bc9d6a811480e --- /dev/null +++ b/test/java/lang/instrument/RedefineMethodAddInvoke.sh @@ -0,0 +1,82 @@ +# +# Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +# @test +# @bug 6667089 +# @summary Reflexive invocation of newly added methods broken. +# @author Daniel D. Daugherty +# +# @run shell MakeJAR3.sh RedefineMethodAddInvokeAgent 'Can-Redefine-Classes: true' +# @run build RedefineMethodAddInvokeApp +# @run shell RedefineMethodAddInvoke.sh +# + +if [ "${TESTJAVA}" = "" ] +then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTSRC}" = "" ] +then + echo "TESTSRC not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTCLASSES}" = "" ] +then + echo "TESTCLASSES not set. Test cannot execute. Failed." + exit 1 +fi + +JAVAC="${TESTJAVA}"/bin/javac +JAVA="${TESTJAVA}"/bin/java + +cp "${TESTSRC}"/RedefineMethodAddInvokeTarget_1.java \ + RedefineMethodAddInvokeTarget.java +"${JAVAC}" -d . RedefineMethodAddInvokeTarget.java +mv RedefineMethodAddInvokeTarget.java RedefineMethodAddInvokeTarget_1.java +mv RedefineMethodAddInvokeTarget.class RedefineMethodAddInvokeTarget_1.class + +cp "${TESTSRC}"/RedefineMethodAddInvokeTarget_2.java \ + RedefineMethodAddInvokeTarget.java +"${JAVAC}" -d . RedefineMethodAddInvokeTarget.java +mv RedefineMethodAddInvokeTarget.java RedefineMethodAddInvokeTarget_2.java +mv RedefineMethodAddInvokeTarget.class RedefineMethodAddInvokeTarget_2.class + +"${JAVA}" ${TESTVMOPTS} -javaagent:RedefineMethodAddInvokeAgent.jar \ + -classpath "${TESTCLASSES}" RedefineMethodAddInvokeApp > output.log 2>&1 +cat output.log + +MESG="Exception" +grep "$MESG" output.log +result=$? +if [ "$result" = 0 ]; then + echo "FAIL: found '$MESG' in the test output" + result=1 +else + echo "PASS: did NOT find '$MESG' in the test output" + result=0 +fi + +exit $result diff --git a/test/java/lang/instrument/RedefineMethodAddInvokeAgent.java b/test/java/lang/instrument/RedefineMethodAddInvokeAgent.java new file mode 100644 index 0000000000000000000000000000000000000000..dd0ab924ca3b1ccd8bd672614763f3f355ca7c22 --- /dev/null +++ b/test/java/lang/instrument/RedefineMethodAddInvokeAgent.java @@ -0,0 +1,43 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.lang.instrument.Instrumentation; + +public class RedefineMethodAddInvokeAgent { + private static Instrumentation instrumentation; + + private RedefineMethodAddInvokeAgent() { + } + + public static void premain(String agentArgs, Instrumentation inst) { + System.out.println("Hello from RedefineMethodAddInvokeAgent!"); + System.out.println("isRedefineClassesSupported()=" + + inst.isRedefineClassesSupported()); + + instrumentation = inst; + } + + public static Instrumentation getInstrumentation() { + return instrumentation; + } +} diff --git a/test/java/lang/instrument/RedefineMethodAddInvokeApp.java b/test/java/lang/instrument/RedefineMethodAddInvokeApp.java new file mode 100644 index 0000000000000000000000000000000000000000..72b769388bab6c3fe647e16faa9940191587ed5e --- /dev/null +++ b/test/java/lang/instrument/RedefineMethodAddInvokeApp.java @@ -0,0 +1,70 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.io.*; +import java.lang.instrument.*; + +public class RedefineMethodAddInvokeApp { + public static void main(String args[]) throws Exception { + System.out.println("Hello from RedefineMethodAddInvokeApp!"); + + new RedefineMethodAddInvokeApp().doTest(); + + System.exit(0); + } + + private void doTest() throws Exception { + RedefineMethodAddInvokeTarget target = + new RedefineMethodAddInvokeTarget(); + + System.out.println("RedefineMethodAddInvokeApp: invoking myMethod()"); + target.test(0); // invoke the original myMethod() + + // add myMethod1() + do_redefine(1); + + System.out.println("RedefineMethodAddInvokeApp: invoking myMethod1()"); + target.test(1); // invoke myMethod1() + + // add myMethod2() + do_redefine(2); + + System.out.println("RedefineMethodAddInvokeApp: invoking myMethod2()"); + target.test(2); // invoke myMethod2() + } + + private static void do_redefine(int counter) throws Exception { + File f = new File("RedefineMethodAddInvokeTarget_" + counter + + ".class"); + System.out.println("Reading test class from " + f); + InputStream redefineStream = new FileInputStream(f); + + byte[] redefineBuffer = NamedBuffer.loadBufferFromStream(redefineStream); + + ClassDefinition redefineParamBlock = new ClassDefinition( + RedefineMethodAddInvokeTarget.class, redefineBuffer); + + RedefineMethodAddInvokeAgent.getInstrumentation().redefineClasses( + new ClassDefinition[] {redefineParamBlock}); + } +} diff --git a/test/java/lang/instrument/RedefineMethodAddInvokeTarget.java b/test/java/lang/instrument/RedefineMethodAddInvokeTarget.java new file mode 100644 index 0000000000000000000000000000000000000000..a073ecb523316d5e925077b4909557587da95274 --- /dev/null +++ b/test/java/lang/instrument/RedefineMethodAddInvokeTarget.java @@ -0,0 +1,37 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.lang.reflect.Method; + +public class RedefineMethodAddInvokeTarget { + public void test(int counter) throws Exception { + Method method = getClass().getDeclaredMethod("myMethod" + + (counter == 0 ? "" : counter)); + method.setAccessible(true); + method.invoke(this); + } + + public void myMethod() { + System.out.println("Hello from the original myMethod()!"); + } +} diff --git a/test/java/lang/instrument/RedefineMethodAddInvokeTarget_1.java b/test/java/lang/instrument/RedefineMethodAddInvokeTarget_1.java new file mode 100644 index 0000000000000000000000000000000000000000..8844cacfa8e6edcd16f29a8cc6555d6eb2d5b6a9 --- /dev/null +++ b/test/java/lang/instrument/RedefineMethodAddInvokeTarget_1.java @@ -0,0 +1,43 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.lang.reflect.Method; + +public class RedefineMethodAddInvokeTarget { + public void test(int counter) throws Exception { + Method method = getClass().getDeclaredMethod("myMethod" + + (counter == 0 ? "" : counter)); + method.setAccessible(true); + method.invoke(this); + } + + public void myMethod() { + System.out.println("Hello from the non-EMCP myMethod()!"); + } + + private final void myMethod1() { + System.out.println("Hello from myMethod1()!"); + System.out.println("Calling myMethod() from myMethod1():"); + myMethod(); + } +} diff --git a/test/java/lang/instrument/RedefineMethodAddInvokeTarget_2.java b/test/java/lang/instrument/RedefineMethodAddInvokeTarget_2.java new file mode 100644 index 0000000000000000000000000000000000000000..b50700c960b39c373476ecc4527fb82c933cf9ab --- /dev/null +++ b/test/java/lang/instrument/RedefineMethodAddInvokeTarget_2.java @@ -0,0 +1,49 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.lang.reflect.Method; + +public class RedefineMethodAddInvokeTarget { + public void test(int counter) throws Exception { + Method method = getClass().getDeclaredMethod("myMethod" + + (counter == 0 ? "" : counter)); + method.setAccessible(true); + method.invoke(this); + } + + public void myMethod() { + System.out.println("Hello from the non-EMCP again myMethod()!"); + } + + private final void myMethod1() { + System.out.println("Hello from myMethod1()!"); + System.out.println("Calling myMethod() from myMethod1():"); + myMethod(); + } + + private final void myMethod2() { + System.out.println("Hello from myMethod2()!"); + System.out.println("Calling myMethod1() from myMethod2():"); + myMethod1(); + } +} diff --git a/test/java/lang/instrument/RetransformAgent.java b/test/java/lang/instrument/RetransformAgent.java index a88b75678ac97f43118a995b65e87b78b57c8408..cd8db7458e8d9710a5bd623bac9c2b31ce66e0b5 100644 --- a/test/java/lang/instrument/RetransformAgent.java +++ b/test/java/lang/instrument/RetransformAgent.java @@ -27,7 +27,7 @@ * @summary test retransformClasses * @author Robert Field, Sun Microsystems * - * @run shell MakeJAR2.sh RetransformAgent RetransformApp 'Can-Retransform-Classes: true' + * @run shell/timeout=240 MakeJAR2.sh RetransformAgent RetransformApp 'Can-Retransform-Classes: true' * @run main/othervm -javaagent:RetransformAgent.jar RetransformApp */ diff --git a/test/java/lang/instrument/StressGetObjectSizeApp.java b/test/java/lang/instrument/StressGetObjectSizeApp.java new file mode 100644 index 0000000000000000000000000000000000000000..77f9c5f10076661cd95401da2cb9537297769d32 --- /dev/null +++ b/test/java/lang/instrument/StressGetObjectSizeApp.java @@ -0,0 +1,86 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.lang.instrument.Instrumentation; + +public class StressGetObjectSizeApp + extends ASimpleInstrumentationTestCase +{ + + /** + * Constructor for StressGetObjectSizeApp. + * @param name + */ + public StressGetObjectSizeApp(String name) + { + super(name); + } + + public static void + main (String[] args) + throws Throwable { + ATestCaseScaffold test = new StressGetObjectSizeApp(args[0]); + test.runTest(); + } + + protected final void + doRunTest() + throws Throwable { + stressGetObjectSize(); + } + + public void stressGetObjectSize() { + System.out.println("main: an object size=" + + fInst.getObjectSize(new Object())); + + RoundAndRound[] threads = new RoundAndRound[10]; + for (int i = 0; i < threads.length; ++i) { + threads[i] = new RoundAndRound(fInst); + threads[i].start(); + } + try { + Thread.sleep(500); // let all threads get going in their loops + } catch (InterruptedException ie) { + } + System.out.println("stressGetObjectSize: returning"); + return; + } + + private static class RoundAndRound extends Thread { + private final Instrumentation inst; + private final Object anObject; + + public RoundAndRound(Instrumentation inst) { + this.inst = inst; + this.anObject = new Object(); + setDaemon(true); + } + + public void run() { + long sum = 0; + while (true) { + sum += inst.getObjectSize(anObject); + } + } + } +} diff --git a/test/java/lang/instrument/StressGetObjectSizeTest.sh b/test/java/lang/instrument/StressGetObjectSizeTest.sh new file mode 100644 index 0000000000000000000000000000000000000000..de8169e4e715c78e791ffede25c5964369bd8e2f --- /dev/null +++ b/test/java/lang/instrument/StressGetObjectSizeTest.sh @@ -0,0 +1,70 @@ +# +# Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +# @test +# @bug 6572160 +# @summary stress getObjectSize() API +# @author Daniel D. Daugherty as modified from the code of fischman@google.com +# +# @run build StressGetObjectSizeApp +# @run shell MakeJAR.sh basicAgent +# @run shell StressGetObjectSizeTest.sh +# + +if [ "${TESTJAVA}" = "" ] +then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTSRC}" = "" ] +then + echo "TESTSRC not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTCLASSES}" = "" ] +then + echo "TESTCLASSES not set. Test cannot execute. Failed." + exit 1 +fi + +JAVA="${TESTJAVA}"/bin/java + +"${JAVA}" ${TESTVMOPTS} -javaagent:basicAgent.jar \ + -classpath "${TESTCLASSES}" StressGetObjectSizeApp StressGetObjectSizeApp \ + > output.log 2>&1 +cat output.log + +MESG="ASSERTION FAILED" +grep "$MESG" output.log +result=$? +if [ "$result" = 0 ]; then + echo "FAIL: found '$MESG' in the test output" + result=1 +else + echo "PASS: did NOT find '$MESG' in the test output" + result=0 +fi + +exit $result diff --git a/test/java/lang/instrument/TestClass1.java b/test/java/lang/instrument/TestClass1.java new file mode 100644 index 0000000000000000000000000000000000000000..70895273678fcedd8061838a1fbd2550a330bb9f --- /dev/null +++ b/test/java/lang/instrument/TestClass1.java @@ -0,0 +1,36 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * Test Java Program + * + * @author Daryl Puryear + * @copyright 1999-2004 Wily Technology, Inc. All rights reserved. + */ +public class TestClass1 +{ + public + TestClass1() + { + } +} diff --git a/test/java/lang/instrument/TestClass2.java b/test/java/lang/instrument/TestClass2.java new file mode 100644 index 0000000000000000000000000000000000000000..145ac59a30658188fa0525fb5ae55463f764b5b7 --- /dev/null +++ b/test/java/lang/instrument/TestClass2.java @@ -0,0 +1,36 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * Test Java Program + * + * @author Daryl Puryear + * @copyright 1999-2004 Wily Technology, Inc. All rights reserved. + */ +public class TestClass2 +{ + public + TestClass2() + { + } +} diff --git a/test/java/lang/instrument/TestClass3.java b/test/java/lang/instrument/TestClass3.java new file mode 100644 index 0000000000000000000000000000000000000000..0189ee16b64f14afb3a1ded50b4a6935d54bbd76 --- /dev/null +++ b/test/java/lang/instrument/TestClass3.java @@ -0,0 +1,36 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * Test Java Program + * + * @author Daryl Puryear + * @copyright 1999-2004 Wily Technology, Inc. All rights reserved. + */ +public class TestClass3 +{ + public + TestClass3() + { + } +} diff --git a/test/java/lang/instrument/TransformerManagementThreadAddTests.java b/test/java/lang/instrument/TransformerManagementThreadAddTests.java index cc5a4b68940430c6ece880f958cb7d65ccc52857..de1573a53a5d5eb2c267583c234fb9d891072f29 100644 --- a/test/java/lang/instrument/TransformerManagementThreadAddTests.java +++ b/test/java/lang/instrument/TransformerManagementThreadAddTests.java @@ -79,6 +79,12 @@ public class TransformerManagementThreadAddTests extends ATestCaseScaffold protected static final int TOTAL_THREADS = MAX_TRANS - MIN_TRANS + 1; private byte[] fDummyClassBytes; + // fCheckedTransformers is a Vector that is used to verify + // that the transform() function is called in the same + // order in which the transformers were added to the + // TransformerManager. The test currently verifies that all + // transformers for a specific worker thread are in + // increasing order by index value. private Vector fCheckedTransformers; private Instrumentation fInstrumentation; private int fFinished; @@ -131,9 +137,16 @@ public class TransformerManagementThreadAddTests extends ATestCaseScaffold threads[i].start(); } - while (!exec.fDone) + // Effective Java - Item 48: Synchronize access to shared mutable data + // Don't use a direct field getter. + while (!exec.isDone()) { - Thread.currentThread().yield(); + // Effective Java - Item 51: Don't depend on the thread scheduler + // Use sleep() instead of yield(). + try { + Thread.sleep(500); + } catch (InterruptedException ie) { + } } assertTrue(finalCheck()); @@ -169,13 +182,17 @@ public class TransformerManagementThreadAddTests extends ATestCaseScaffold this.fExec = exec; } + // Effective Java - Item 48: Synchronize access to shared mutable data + // Document a synchronized setter. protected synchronized void threadFinished(Thread t) { fFinished++; } - protected boolean + // Effective Java - Item 48: Synchronize access to shared mutable data + // Provide synchronized getter. + protected synchronized boolean threadsDone() { return fFinished == TOTAL_THREADS; @@ -188,7 +205,9 @@ public class TransformerManagementThreadAddTests extends ATestCaseScaffold protected boolean testCompleted() { - return getExecThread().fDone; + // Effective Java - Item 48: Synchronize access to shared mutable data + // Don't use direct field getter. + return getExecThread().isDone(); } /** @@ -264,11 +283,19 @@ public class TransformerManagementThreadAddTests extends ATestCaseScaffold private void executeTransform() { - fCheckedTransformers.clear(); - try { ClassDefinition cd = new ClassDefinition(DummyClass.class, fDummyClassBytes); + + // When the ClassDefinition above is created for the first + // time and every time redefineClasses() below is called, + // the transform() function is called for each registered + // transformer. We only want one complete set of calls to + // be logged in the fCheckedTransformers Vector so we clear + // any calls logged for ClassDefinition above and just use + // the ones logged for redefineClasses() below. + fCheckedTransformers.clear(); + getInstrumentation().redefineClasses(new ClassDefinition[]{ cd }); } catch (ClassNotFoundException e) @@ -325,6 +352,18 @@ public class TransformerManagementThreadAddTests extends ATestCaseScaffold { private boolean fDone = false; + // Effective Java - Item 48: Synchronize access to shared mutable data + // Provide a synchronized getter. + private synchronized boolean isDone() { + return fDone; + } + + // Effective Java - Item 48: Synchronize access to shared mutable data + // Provide a synchronized setter. + private synchronized void setIsDone() { + fDone = true; + } + public void run() { @@ -335,7 +374,9 @@ public class TransformerManagementThreadAddTests extends ATestCaseScaffold // Do a final check for good measure executeTransform(); - fDone = true; + // Effective Java - Item 48: Synchronize access to shared mutable data + // Don't use direct field setter. + setIsDone(); } } diff --git a/test/java/lang/instrument/TransformerManagementThreadRemoveTests.java b/test/java/lang/instrument/TransformerManagementThreadRemoveTests.java index 2836bde566563184de091b08256fecd87c50e672..a7d381ff82183e28c9da843941e544c04a43c30e 100644 --- a/test/java/lang/instrument/TransformerManagementThreadRemoveTests.java +++ b/test/java/lang/instrument/TransformerManagementThreadRemoveTests.java @@ -27,10 +27,9 @@ * @summary multi-thread test to exercise sync and contention for removes to transformer registry * @author Gabriel Adauto, Wily Technology * - * @ignore Disabled until race condition which hangs test can be fixed. * @run build TransformerManagementThreadRemoveTests - * @run shell MakeJAR.sh basicAgent - * @run main/othervm -javaagent:basicAgent.jar TransformerManagementThreadRemoveTests TransformerManagementThreadRemoveTests + * @run shell MakeJAR.sh redefineAgent + * @run main/othervm -javaagent:redefineAgent.jar TransformerManagementThreadRemoveTests TransformerManagementThreadRemoveTests */ import java.util.*; @@ -87,7 +86,12 @@ public class TransformerManagementThreadRemoveTests while (!testCompleted()) { - Thread.currentThread().yield(); + // Effective Java - Item 51: Don't depend on the thread scheduler + // Use sleep() instead of yield(). + try { + Thread.sleep(500); + } catch (InterruptedException ie) { + } } assertTrue(finalCheck()); diff --git a/test/java/lang/instrument/appendToClassLoaderSearch/CircularityErrorTest.sh b/test/java/lang/instrument/appendToClassLoaderSearch/CircularityErrorTest.sh index c68016a4f9fd62b3e7218effd9b11cd5098b012d..3f4e08b9c95c8e620924e918e30a470cf919afaf 100644 --- a/test/java/lang/instrument/appendToClassLoaderSearch/CircularityErrorTest.sh +++ b/test/java/lang/instrument/appendToClassLoaderSearch/CircularityErrorTest.sh @@ -26,14 +26,14 @@ # @summary Unit tests for appendToBootstrapClassLoaderSearch and # appendToSystemClasLoaderSearch methods. # -# @run shell CircularityErrorTest.sh +# @run shell/timeout=240 CircularityErrorTest.sh if [ "${TESTSRC}" = "" ] then echo "TESTSRC not set. Test cannot execute. Failed." exit 1 fi - + . ${TESTSRC}/CommonSetup.sh # Setup to create circularity condition @@ -71,5 +71,5 @@ $JAR -cfm "${TESTCLASSES}"/CircularityErrorTest.jar "${MANIFEST}" \ -C "${TESTCLASSES}" CircularityErrorTest.class # Finally we run the test -(cd "${TESTCLASSES}"; - $JAVA -javaagent:CircularityErrorTest.jar CircularityErrorTest) +(cd "${TESTCLASSES}"; + $JAVA ${TESTVMOPTS} -javaagent:CircularityErrorTest.jar CircularityErrorTest) diff --git a/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh b/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh index cea223160ad1f8f8aea7701f945663168e3167e6..5b7411ac9897e2a8977ef784c7eb5048fbac07b0 100644 --- a/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh +++ b/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh @@ -34,11 +34,11 @@ then echo "TESTSRC not set. Test cannot execute. Failed." exit 1 fi - + . ${TESTSRC}/CommonSetup.sh # Create Foo and Bar -# Foo has a reference to Bar but we deleted Bar so that +# Foo has a reference to Bar but we deleted Bar so that # a NoClassDefFoundError will be thrown when Foo tries to # resolve the reference to Bar @@ -53,11 +53,11 @@ cat << EOF > "${FOO}" public class Foo { public static boolean doSomething() { try { - Bar b = new Bar(); - return true; - } catch (NoClassDefFoundError x) { - return false; - } + Bar b = new Bar(); + return true; + } catch (NoClassDefFoundError x) { + return false; + } } } EOF @@ -79,5 +79,5 @@ $JAR -cfm "${TESTCLASSES}"/ClassUnloadTest.jar "${MANIFEST}" \ # Finally we run the test (cd "${TESTCLASSES}"; \ - $JAVA -Xverify:none -XX:+TraceClassUnloading -javaagent:ClassUnloadTest.jar \ - ClassUnloadTest "${OTHERDIR}" Bar.jar) + $JAVA ${TESTVMOPTS} -Xverify:none -XX:+TraceClassUnloading \ + -javaagent:ClassUnloadTest.jar ClassUnloadTest "${OTHERDIR}" Bar.jar) diff --git a/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh b/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh index 4c594720ea5a086f2ef1ead59bca85a116c5be29..2cd7032cedc8f99775040d22a6503b80f01fdc70 100644 --- a/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh +++ b/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh @@ -24,7 +24,6 @@ # -#%E # # Common setup for unit tests. Setups up the following variables: # @@ -66,7 +65,7 @@ then echo "TESTSRC not set. Test cannot execute. Failed." exit 1 fi - + if [ "${TESTCLASSES}" = "" ] then echo "TESTCLASSES not set. Test cannot execute. Failed." diff --git a/test/java/lang/instrument/appendToClassLoaderSearch/run_tests.sh b/test/java/lang/instrument/appendToClassLoaderSearch/run_tests.sh index 0302b7a6385ba786f8a679dfd639a0de8380ac89..ba6d985f21833b17dab18284560a8522243aee15 100644 --- a/test/java/lang/instrument/appendToClassLoaderSearch/run_tests.sh +++ b/test/java/lang/instrument/appendToClassLoaderSearch/run_tests.sh @@ -23,24 +23,24 @@ # have any questions. # - + # @test # @bug 6173575 6388987 -# @summary Unit tests for appendToBootstrapClassLoaderSearch and +# @summary Unit tests for appendToBootstrapClassLoaderSearch and # appendToSystemClasLoaderSearch methods. # # @build Agent AgentSupport BootSupport BasicTest PrematureLoadTest DynamicTest -# @run shell run_tests.sh +# @run shell/timeout=240 run_tests.sh if [ "${TESTSRC}" = "" ] then echo "TESTSRC not set. Test cannot execute. Failed." exit 1 fi - + . ${TESTSRC}/CommonSetup.sh - + # Simple tests echo "Creating jar files for simple tests..." @@ -50,13 +50,13 @@ cd ${TESTCLASSES} "$JAR" -cfm Agent.jar "${TESTSRC}"/manifest.mf Agent.class "$JAR" -cf AgentSupport.jar AgentSupport.class "$JAR" -cf BootSupport.jar BootSupport.class -"$JAR" -cf SimpleTests.jar BasicTest.class PrematureLoadTest.class +"$JAR" -cf SimpleTests.jar BasicTest.class PrematureLoadTest.class failures=0 go() { echo '' - sh -xc "$JAVA -javaagent:Agent.jar -classpath SimpleTests.jar $1 $2 $3" 2>&1 + sh -xc "$JAVA ${TESTVMOPTS} -javaagent:Agent.jar -classpath SimpleTests.jar $1 $2 $3" 2>&1 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi } @@ -75,7 +75,7 @@ mkdir tmp "${JAVAC}" -d tmp "${TESTSRC}"/Tracer.java (cd tmp; "${JAR}" cf ../Tracer.jar org/tools/Tracer.class) -# InstrumentedApplication is Application+instrmentation - don't copy as +# InstrumentedApplication is Application+instrmentation - don't copy as # we don't want the original file permission cat "${TESTSRC}"/InstrumentedApplication.java > ./Application.java @@ -85,11 +85,11 @@ mv Application.class InstrumentedApplication.bytes cp "${TESTSRC}"/Application.java . "${JAVAC}" -d . Application.java -sh -xc "$JAVA -classpath . -javaagent:Agent.jar DynamicTest" 2>&1 +sh -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar DynamicTest" 2>&1 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi # Repeat test with security manager -sh -xc "$JAVA -classpath . -javaagent:Agent.jar -Djava.security.manager DynamicTest" 2>&1 +sh -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar -Djava.security.manager DynamicTest" 2>&1 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi # diff --git a/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java b/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java new file mode 100644 index 0000000000000000000000000000000000000000..a778f450af2e9e6167c935feeece5101c5cab3ae --- /dev/null +++ b/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java @@ -0,0 +1,180 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6610094 + * @summary Basic unit test of ManagementFactory.getPlatformMXBeans() + * and also PlatformManagedObject.getObjectName() + * @author Mandy Chung + * + * @run main GetPlatformMXBeans + */ + +import java.lang.management.*; +import static java.lang.management.ManagementFactory.*; +import java.util.*; +import javax.management.*; + +public class GetPlatformMXBeans { + private static MBeanServer platformMBeanServer = + getPlatformMBeanServer(); + public static void main(String[] argv) throws Exception { + checkPlatformMXBean(getClassLoadingMXBean(), + ClassLoadingMXBean.class, + CLASS_LOADING_MXBEAN_NAME); + checkPlatformMXBean(getCompilationMXBean(), + CompilationMXBean.class, + COMPILATION_MXBEAN_NAME); + checkPlatformMXBean(getMemoryMXBean(), + MemoryMXBean.class, + MEMORY_MXBEAN_NAME); + checkPlatformMXBean(getOperatingSystemMXBean(), + OperatingSystemMXBean.class, + OPERATING_SYSTEM_MXBEAN_NAME); + checkPlatformMXBean(getRuntimeMXBean(), + RuntimeMXBean.class, + RUNTIME_MXBEAN_NAME); + checkPlatformMXBean(getThreadMXBean(), + ThreadMXBean.class, + THREAD_MXBEAN_NAME); + checkGarbageCollectorMXBeans(getGarbageCollectorMXBeans()); + checkMemoryManagerMXBeans(getMemoryManagerMXBeans()); + checkMemoryPoolMXBeans(getMemoryPoolMXBeans()); + } + + private static + void checkPlatformMXBean(T obj, Class mxbeanInterface, + String mxbeanName) throws Exception + { + int numElements = (obj != null ? 1 : 0); + // verify local list of platform MXBeans + List mxbeans = + getPlatformMXBeans(mxbeanInterface); + if (mxbeans.size() != numElements) { + throw new RuntimeException("Unmatched number of platform MXBeans " + + mxbeans.size() + ". Expected = " + numElements); + } + + if (obj != null) { + PlatformManagedObject pmo = mxbeans.get(0); + if (obj != pmo) { + throw new RuntimeException("The list returned by getPlatformMXBeans" + + " not matched"); + } + ObjectName on = new ObjectName(mxbeanName); + if (!on.equals(pmo.getObjectName())) { + throw new RuntimeException("Unmatched ObjectName " + + pmo.getObjectName() + " Expected = " + on); + } + } + + // verify platform MXBeans in the platform MBeanServer + mxbeans = getPlatformMXBeans(platformMBeanServer, mxbeanInterface); + if (mxbeans.size() != numElements) { + throw new RuntimeException("Unmatched number of platform MXBeans " + + mxbeans.size() + ". Expected = " + numElements); + } + } + + private static void checkMemoryManagerMXBeans(List objs) + throws Exception + { + checkPlatformMXBeans(objs, MemoryManagerMXBean.class); + for (MemoryManagerMXBean mxbean : objs) { + String domainAndType; + if (mxbean instanceof GarbageCollectorMXBean) { + domainAndType = GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE; + } else { + domainAndType = MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE; + } + ObjectName on = new ObjectName(domainAndType + + ",name=" + mxbean.getName()); + if (!on.equals(mxbean.getObjectName())) { + throw new RuntimeException("Unmatched ObjectName " + + mxbean.getObjectName() + " Expected = " + on); + } + } + } + private static void checkMemoryPoolMXBeans(List objs) + throws Exception + { + checkPlatformMXBeans(objs, MemoryPoolMXBean.class); + for (MemoryPoolMXBean mxbean : objs) { + ObjectName on = new ObjectName(MEMORY_POOL_MXBEAN_DOMAIN_TYPE + + ",name=" + mxbean.getName()); + if (!on.equals(mxbean.getObjectName())) { + throw new RuntimeException("Unmatched ObjectName " + + mxbean.getObjectName() + " Expected = " + on); + } + } + } + + private static void checkGarbageCollectorMXBeans(List objs) + throws Exception + { + checkPlatformMXBeans(objs, GarbageCollectorMXBean.class); + for (GarbageCollectorMXBean mxbean : objs) { + ObjectName on = new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + + ",name=" + mxbean.getName()); + if (!on.equals(mxbean.getObjectName())) { + throw new RuntimeException("Unmatched ObjectName " + + mxbean.getObjectName() + " Expected = " + on); + } + } + } + + private static + void checkPlatformMXBeans(List objs, Class mxbeanInterface) + throws Exception + { + // verify local list of platform MXBeans + List mxbeans = + getPlatformMXBeans(mxbeanInterface); + if (objs.size() != mxbeans.size()) { + throw new RuntimeException("Unmatched number of platform MXBeans " + + mxbeans.size() + ". Expected = " + objs.size()); + } + List list = new ArrayList(objs); + for (PlatformManagedObject pmo : mxbeans) { + if (list.contains(pmo)) { + list.remove(pmo); + } else { + throw new RuntimeException(pmo + + " not in the platform MXBean list"); + } + } + + if (!list.isEmpty()) { + throw new RuntimeException("The list returned by getPlatformMXBeans" + + " not matched"); + } + + // verify platform MXBeans in the platform MBeanServer + mxbeans = getPlatformMXBeans(platformMBeanServer, mxbeanInterface); + if (objs.size() != mxbeans.size()) { + throw new RuntimeException("Unmatched number of platform MXBeans " + + mxbeans.size() + ". Expected = " + objs.size()); + } + } +} diff --git a/test/java/lang/management/OperatingSystemMXBean/PlatformMXBeanTest.java b/test/java/lang/management/OperatingSystemMXBean/PlatformMXBeanTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b7a1d56680ff8f69457d4d5852142bfc27312954 --- /dev/null +++ b/test/java/lang/management/OperatingSystemMXBean/PlatformMXBeanTest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6610094 + * @summary Test the OperatingSystemMXBean instance returned by + * ManagementFactory.getPlatformMXBeans() + * @author Mandy Chung + * + * @run main PlatformMXBeanTest + */ + +import java.lang.management.*; +import java.util.List; + +public class PlatformMXBeanTest { + public static void main(String[] argv) throws Exception { + OperatingSystemMXBean osMBean = getOSPlatformMXBean(OperatingSystemMXBean.class); + + // There should have only one single MXBean for the OS MXBean interfaces: + // java.lang.management.OperatingSystemMXBean + // com.sun.management.OperatingSystemMXBean + // com.sun.management.UnixOperatingSystemMXBean + if (osMBean != getOSPlatformMXBean(com.sun.management.OperatingSystemMXBean.class)) { + throw new RuntimeException( + "Invalid com.sun.management.OperatingSystemMXBean instance"); + } + + if (!System.getProperty("os.name").startsWith("Windows") && + osMBean != getOSPlatformMXBean(com.sun.management.UnixOperatingSystemMXBean.class)) { + throw new RuntimeException( + "Invalid com.sun.management.UnixOperatingSystemMXBean instance"); + } + } + + private static + T getOSPlatformMXBean(Class c) { + List result = ManagementFactory.getPlatformMXBeans(c); + if (result.isEmpty()) { + return null; + } else if (result.size() == 1) { + return result.get(0); + } else { + throw new RuntimeException(c.getName() + " has " + + result.size() + " number of instances"); + } + } +} diff --git a/test/java/net/CookieHandler/CookieManagerTest.java b/test/java/net/CookieHandler/CookieManagerTest.java index a2c9db3b411ea7ac4083ebbf82567630d1e78b54..b83c27fcefc7527825bedf72808b48a0d7ac22b4 100644 --- a/test/java/net/CookieHandler/CookieManagerTest.java +++ b/test/java/net/CookieHandler/CookieManagerTest.java @@ -132,17 +132,17 @@ class CookieHttpTransaction implements HttpCallback { ), new CookieTestCase("Set-Cookie", "PART_NUMBER=ROCKET_LAUNCHER_0001; path=/;" + "domain=." + localHostAddr, - "CUSTOMER=WILE:BOB;PART_NUMBER=ROCKET_LAUNCHER_0001", + "CUSTOMER=WILE:BOB; PART_NUMBER=ROCKET_LAUNCHER_0001", "/" ), new CookieTestCase("Set-Cookie", "SHIPPING=FEDEX; path=/foo;" + "domain=." + localHostAddr, - "CUSTOMER=WILE:BOB;PART_NUMBER=ROCKET_LAUNCHER_0001", + "CUSTOMER=WILE:BOB; PART_NUMBER=ROCKET_LAUNCHER_0001", "/" ), new CookieTestCase("Set-Cookie", "SHIPPING=FEDEX; path=/foo;" + "domain=." + localHostAddr, - "CUSTOMER=WILE:BOB;PART_NUMBER=ROCKET_LAUNCHER_0001;SHIPPING=FEDEX", + "CUSTOMER=WILE:BOB; PART_NUMBER=ROCKET_LAUNCHER_0001; SHIPPING=FEDEX", "/foo" ) }; @@ -157,7 +157,7 @@ class CookieHttpTransaction implements HttpCallback { ), new CookieTestCase("Set-Cookie", "PART_NUMBER=RIDING_ROCKET_0023; path=/ammo;" + "domain=." + localHostAddr, - "PART_NUMBER=RIDING_ROCKET_0023;PART_NUMBER=ROCKET_LAUNCHER_0001", + "PART_NUMBER=RIDING_ROCKET_0023; PART_NUMBER=ROCKET_LAUNCHER_0001", "/ammo" ) }; @@ -167,17 +167,17 @@ class CookieHttpTransaction implements HttpCallback { testCases[count++] = new CookieTestCase[]{ new CookieTestCase("Set-Cookie2", "Customer=\"WILE_E_COYOTE\"; Version=\"1\"; Path=\"/acme\";" + "domain=." + localHostAddr, - "$Version=\"1\";Customer=\"WILE_E_COYOTE\";$Path=\"/acme\";$Domain=\"." + localHostAddr + "\"", + "$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\";$Domain=\"." + localHostAddr + "\"", "/acme/login" ), new CookieTestCase("Set-Cookie2", "Part_Number=\"Rocket_Launcher_0001\"; Version=\"1\";Path=\"/acme\";" + "domain=." + localHostAddr, - "$Version=\"1\";Customer=\"WILE_E_COYOTE\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"" + ";Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"", + "$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"" + "; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"", "/acme/pickitem" ), new CookieTestCase("Set-Cookie2", "Shipping=\"FedEx\"; Version=\"1\"; Path=\"/acme\";" + "domain=." + localHostAddr, - "$Version=\"1\";Customer=\"WILE_E_COYOTE\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"" + ";Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"" + ";Shipping=\"FedEx\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"", + "$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"" + "; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"" + "; Shipping=\"FedEx\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"", "/acme/shipping" ) }; @@ -187,17 +187,17 @@ class CookieHttpTransaction implements HttpCallback { testCases[count++] = new CookieTestCase[]{ new CookieTestCase("Set-Cookie2", "Part_Number=\"Rocket_Launcher_0001\"; Version=\"1\"; Path=\"/acme\";" + "domain=." + localHostAddr, - "$Version=\"1\";Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";$Domain=\"." + localHostAddr + "\"", + "$Version=\"1\"; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";$Domain=\"." + localHostAddr + "\"", "/acme/ammo" ), new CookieTestCase("Set-Cookie2", "Part_Number=\"Riding_Rocket_0023\"; Version=\"1\"; Path=\"/acme/ammo\";" + "domain=." + localHostAddr, - "$Version=\"1\";Part_Number=\"Riding_Rocket_0023\";$Path=\"/acme/ammo\";$Domain=\"." + localHostAddr + "\"" + ";Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"", + "$Version=\"1\"; Part_Number=\"Riding_Rocket_0023\";$Path=\"/acme/ammo\";$Domain=\"." + localHostAddr + "\"" + "; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"", "/acme/ammo" ), new CookieTestCase("", "", - "$Version=\"1\";Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"", + "$Version=\"1\"; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";" + "$Domain=\"." + localHostAddr + "\"", "/acme/parts" ) }; @@ -207,12 +207,12 @@ class CookieHttpTransaction implements HttpCallback { testCases[count++] = new CookieTestCase[]{ new CookieTestCase("Set-Cookie2", "Part_Number=\"Rocket_Launcher_0001\"; Version=\"1\"; Path=\"/acme\";" + "domain=." + localHostAddr, - "$Version=\"1\";Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";$Domain=\"." + localHostAddr + "\"", + "$Version=\"1\"; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";$Domain=\"." + localHostAddr + "\"", "/acme" ), new CookieTestCase("Set-Cookie2", "Part_Number=\"Rocket_Launcher_2000\"; Version=\"1\"; Path=\"/acme\";" + "domain=." + localHostAddr, - "$Version=\"1\";Part_Number=\"Rocket_Launcher_2000\";$Path=\"/acme\";$Domain=\"." + localHostAddr + "\"", + "$Version=\"1\"; Part_Number=\"Rocket_Launcher_2000\";$Path=\"/acme\";$Domain=\"." + localHostAddr + "\"", "/acme" ) }; @@ -222,17 +222,17 @@ class CookieHttpTransaction implements HttpCallback { testCases[count++] = new CookieTestCase[]{ new CookieTestCase("Set-Cookie2", "Customer=\"WILE_E_COYOTE\"; Version=\"1\"; Path=\"/acme\"", - "$Version=\"1\";Customer=\"WILE_E_COYOTE\";$Path=\"/acme\"", + "$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\"", "/acme/login" ), new CookieTestCase("Set-Cookie2", "Part_Number=\"Rocket_Launcher_0001\"; Version=\"1\";Path=\"/acme\"", - "$Version=\"1\";Customer=\"WILE_E_COYOTE\";$Path=\"/acme\"" + ";Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\"", + "$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\"" + "; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\"", "/acme/pickitem" ), new CookieTestCase("Set-Cookie2", "Shipping=\"FedEx\"; Version=\"1\"; Path=\"/acme\"", - "$Version=\"1\";Customer=\"WILE_E_COYOTE\";$Path=\"/acme\"" + ";Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\"" + ";Shipping=\"FedEx\";$Path=\"/acme\"", + "$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\"" + "; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\"" + "; Shipping=\"FedEx\";$Path=\"/acme\"", "/acme/shipping" ) }; diff --git a/test/java/net/InterfaceAddress/Equals.java b/test/java/net/InterfaceAddress/Equals.java new file mode 100644 index 0000000000000000000000000000000000000000..5403bebe04c8866fd04f7fa6dba1c8c1a1cdc625 --- /dev/null +++ b/test/java/net/InterfaceAddress/Equals.java @@ -0,0 +1,119 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* @test + * @bug 6628576 + * @summary InterfaceAddress.equals() NPE when broadcast field == null + */ + +import java.net.InterfaceAddress; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; + +public class Equals +{ + public static void main(String[] args) { + InterfaceAddress ia1; + InterfaceAddress ia2; + InetAddress loopbackAddr = InetAddress.getLoopbackAddress(); + InetAddress broadcast1 = null; + InetAddress broadcast2 = null; + + try { + broadcast1 = InetAddress.getByName("255.255.255.0"); + broadcast2 = InetAddress.getByName("255.255.0.0"); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + + ia1 = createInterfaceAddress(loopbackAddr, (InetAddress) null, (short)45); + ia2 = createInterfaceAddress(loopbackAddr, (InetAddress) null, (short)45); + + compare(ia1, ia2, true); + + ia2 = createInterfaceAddress(loopbackAddr, broadcast1, (short)45); + compare(ia1, ia2, false); + + ia2 = createInterfaceAddress((InetAddress)null, broadcast1, (short)45); + compare(ia1, ia2, false); + + ia1 = createInterfaceAddress(loopbackAddr, broadcast2, (short)45); + ia2 = createInterfaceAddress(loopbackAddr, broadcast2, (short)45); + compare(ia1, ia2, true); + + ia1.equals(null); + } + + static void compare(InterfaceAddress ia1, InterfaceAddress ia2, boolean equal) { + if (ia1.equals(ia2) != equal) + throw new RuntimeException("Failed: " + ia1 + " not equals to " + ia2); + + if (ia2.equals(ia1) != equal) + throw new RuntimeException("Failed: " + ia2 + " not equals to " + ia1); + } + + /** + * Returns an InterfaceAddress instance with its fields set the the values + * specificed. + */ + static InterfaceAddress createInterfaceAddress( + InetAddress address, InetAddress broadcast, short prefixlength) { + try { + Class IAClass = InterfaceAddress.class; + InterfaceAddress ia; + Constructor ctr = IAClass.getDeclaredConstructor(); + ctr.setAccessible(true); + + Field addressField = IAClass.getDeclaredField("address"); + addressField.setAccessible(true); + + Field broadcastField = IAClass.getDeclaredField("broadcast"); + broadcastField.setAccessible(true); + + Field maskLengthField = IAClass.getDeclaredField("maskLength"); + maskLengthField.setAccessible(true); + + ia = ctr.newInstance(); + addressField.set(ia, address); + broadcastField.set(ia, broadcast); + maskLengthField.setShort(ia, prefixlength); + + return ia; + } catch (NoSuchFieldException nsfe) { + nsfe.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (InstantiationException ie) { + ie.printStackTrace(); + } catch (IllegalAccessException iae) { + iae.printStackTrace(); + } catch (InvocationTargetException ite) { + ite.printStackTrace(); + } + + return null; + } +} diff --git a/test/java/net/ResponseCache/file2.1 b/test/java/net/ResponseCache/file2.1 index 428de11adaa6bbf21e59db4908df028e401bb87f..1878bc2fe8824d743ea73c9d0fa986d15f14d440 100644 --- a/test/java/net/ResponseCache/file2.1 +++ b/test/java/net/ResponseCache/file2.1 @@ -1,4 +1,4 @@ -/* @test +/* @test @(#)file2.1 1.1 03/08/09 * @summary Unit test for java.net.ResponseCacheHandler * @bug 4837267 * @author Yingxian Wang diff --git a/test/java/nio/Buffer/StringCharBufferSliceTest.java b/test/java/nio/Buffer/StringCharBufferSliceTest.java index 56770025c32d2c8f35b8c1acc508c5e0a338699a..82d593c5d70b923b5cbd65d9194d4a6ebaca7c38 100644 --- a/test/java/nio/Buffer/StringCharBufferSliceTest.java +++ b/test/java/nio/Buffer/StringCharBufferSliceTest.java @@ -53,6 +53,57 @@ public class StringCharBufferSliceTest { buff = CharBuffer.wrap(in, 3, in.length()); test(buff, buff.slice()); + System.out.println( + ">>> StringCharBufferSliceTest-main: testing slice result with get()"); + buff.position(4); + buff.limit(7); + CharBuffer slice = buff.slice(); + for (int i = 0; i < 3; i++) { + if (slice.get() != buff.get()) { + throw new RuntimeException("Wrong characters in slice result."); + } + } + + System.out.println( + ">>> StringCharBufferSliceTest-main: testing slice result with get(int)"); + buff.position(4); + buff.limit(7); + slice = buff.slice(); + for (int i = 0; i < 3; i++) { + if (slice.get(i) != buff.get(4 + i)) { + throw new RuntimeException("Wrong characters in slice result."); + } + } + + System.out.println( + ">>> StringCharBufferSliceTest-main: testing toString."); + buff.position(4); + buff.limit(7); + slice = buff.slice(); + if (! slice.toString().equals("tes")) { + throw new RuntimeException("bad toString() after slice(): " + slice.toString()); + } + + System.out.println( + ">>> StringCharBufferSliceTest-main: testing subSequence."); + buff.position(4); + buff.limit(8); + slice = buff.slice(); + CharSequence subSeq = slice.subSequence(1, 3); + if (subSeq.charAt(0) != 'e' || subSeq.charAt(1) != 's') { + throw new RuntimeException("bad subSequence() after slice(): '" + subSeq + "'"); + } + + System.out.println( + ">>> StringCharBufferSliceTest-main: testing duplicate."); + buff.position(4); + buff.limit(8); + slice = buff.slice(); + CharBuffer dupe = slice.duplicate(); + if (dupe.charAt(0) != 't' || dupe.charAt(1) != 'e' + || dupe.charAt(2) != 's' || dupe.charAt(3) != 't') { + throw new RuntimeException("bad duplicate() after slice(): '" + dupe + "'"); + } System.out.println(">>> StringCharBufferSliceTest-main: done!"); } diff --git a/test/java/nio/channels/Channels/ShortWrite.java b/test/java/nio/channels/Channels/ShortWrite.java new file mode 100644 index 0000000000000000000000000000000000000000..0418add7359d7dfb62f2329c5d9273d532f5dcd7 --- /dev/null +++ b/test/java/nio/channels/Channels/ShortWrite.java @@ -0,0 +1,83 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* @test + * @bug 6448457 + * @summary Test Channels.newOutputStream returns OutputStream that handles + * short writes from the underlying channel + */ + +import java.io.OutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.*; +import java.util.Random; + +public class ShortWrite { + + static Random rand = new Random(); + static int bytesWritten = 0; + + public static void main(String[] args) throws IOException { + + WritableByteChannel wbc = new WritableByteChannel() { + public int write(ByteBuffer src) { + int rem = src.remaining(); + if (rem > 0) { + // short write + int n = rand.nextInt(rem) + 1; + src.position(src.position() + n); + bytesWritten += n; + return n; + } else { + return 0; + } + } + public void close() throws IOException { + throw new RuntimeException("not implemented"); + } + public boolean isOpen() { + throw new RuntimeException("not implemented"); + } + }; + + // wrap Channel with OutputStream + OutputStream out = Channels.newOutputStream(wbc); + + + // write 100, 99, 98, ... 1 + // and check that the expected number of bytes is written + int expected = 0; + byte[] buf = new byte[100]; + for (int i=0; i= 0) || - trace.equals("")) + public static void main(String args[]) { + + sameGroup = true; + + RMID rmid = null; + + System.err.println("\nRegression test for bug/rfe 4179055\n"); + + try { + TestLibrary.suggestSecurityManager("java.lang.SecurityManager"); + + registry = java.rmi.registry.LocateRegistry. + createRegistry(TestLibrary.REGISTRY_PORT); + + // must run with java.lang.SecurityManager or the test + // result will be nullified if running with a build where + // 4180392 has not been fixed. + String smClassName = + System.getSecurityManager().getClass().getName(); + if (!smClassName.equals("java.lang.SecurityManager")) { + TestLibrary.bomb("Test must run with java.lang.SecurityManager"); + } + + // start an rmid. + RMID.removeLog(); + rmid = RMID.createRMID(); + rmid.start(); + + //rmid.addOptions(new String[] {"-C-Djava.rmi.server.logCalls=true"}); + + // Ensure that activation groups run with the correct + // security manager. + // + Properties p = new Properties(); + p.put("java.security.policy", + TestParams.defaultGroupPolicy); + p.put("java.security.manager", + "java.lang.SecurityManager"); + + // This action causes the following classes to be created + // in this VM (RMI must permit the creation of these classes): + // + // sun.rmi.server.Activation$ActivationSystemImpl_Stub + // sun.rmi.server.Activation$ActivationMonitorImpl_Stub + // + System.err.println("Create activation group, in a new VM"); + ActivationGroupDesc groupDesc = + new ActivationGroupDesc(p, null); + ActivationSystem system = ActivationGroup.getSystem(); + ActivationGroupID groupID = system.registerGroup(groupDesc); + + System.err.println("register activatable"); + // Fix for: 4271615: make sure activation group runs in a new VM + ActivationDesc desc = new ActivationDesc + (groupID, "StubClassesPermitted", null, null); + canCreateStubs = (CanCreateStubs) Activatable.register(desc); + + // ensure registry stub can be passed in a remote call + System.err.println("getting the registry"); + registry = canCreateStubs.getRegistry(); + + // make sure a client cant load just any sun.* class, just + // as a sanity check, try to create a class we are not + // allowed to access but which was passed in a remote call + try { + System.err.println("accessing forbidden class"); + Object secureRandom = canCreateStubs.getForbiddenClass(); + + TestLibrary.bomb("test allowed to access forbidden class," + + " sun.security.provider.SecureRandom"); + } catch (java.security.AccessControlException e) { + + // Make sure we received a *local* AccessControlException + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(bout); + e.printStackTrace(ps); + ps.flush(); + String trace = new String(bout.toByteArray()); + if ((trace.indexOf("exceptionReceivedFromServer") >= 0) || + trace.equals("")) { - throw e; - } - System.err.println("received expected local access control exception"); - } - - // make sure that an ActivationGroupID can be passed in a - // remote call; this is slightly more inclusive than - // just passing a reference to the activation system - System.err.println("returning group desc"); - canCreateStubs.returnGroupID(); - - // Clean up object - System.err.println - ("Deactivate object via method call"); - canCreateStubs.shutdown(); - - System.err.println - ("\nsuccess: StubClassesPermitted test passed "); - - } catch (Exception e) { - TestLibrary.bomb("\nfailure: unexpected exception ", e); - } finally { - try { - Thread.sleep(4000); - } catch (InterruptedException e) { - } - - canCreateStubs = null; - ActivationLibrary.rmidCleanup(rmid); - System.err.println("rmid shut down"); - } + throw e; + } + System.err.println("received expected local access control exception"); + } + + // make sure that an ActivationGroupID can be passed in a + // remote call; this is slightly more inclusive than + // just passing a reference to the activation system + System.err.println("returning group desc"); + canCreateStubs.returnGroupID(); + + // Clean up object + System.err.println + ("Deactivate object via method call"); + canCreateStubs.shutdown(); + + System.err.println + ("\nsuccess: StubClassesPermitted test passed "); + + } catch (Exception e) { + TestLibrary.bomb("\nfailure: unexpected exception ", e); + } finally { + try { + Thread.sleep(4000); + } catch (InterruptedException e) { + } + + canCreateStubs = null; + ActivationLibrary.rmidCleanup(rmid); + System.err.println("rmid shut down"); + } } - + static ActivationGroupID GroupID = null; /** - * implementation of CanCreateStubs + * implementation of CanCreateStubs */ public StubClassesPermitted - (ActivationID id, MarshalledObject mo) throws RemoteException + (ActivationID id, MarshalledObject mo) throws RemoteException { - // register/export anonymously - super(id, 0); + // register/export anonymously + super(id, 0); - // obtain reference to the test registry - registry = java.rmi.registry.LocateRegistry. - getRegistry(TestLibrary.REGISTRY_PORT); + // obtain reference to the test registry + registry = java.rmi.registry.LocateRegistry. + getRegistry(TestLibrary.REGISTRY_PORT); } - + /** * Spawns a thread to deactivate the object. */ public void shutdown() throws Exception { - (new Thread(this,"StubClassesPermitted")).start(); + (new Thread(this,"StubClassesPermitted")).start(); } /** @@ -209,7 +209,7 @@ public class StubClassesPermitted * unexport the object forcibly. */ public void run() { - ActivationLibrary.deactivate(this, getID()); + ActivationLibrary.deactivate(this, getID()); } /** @@ -217,12 +217,12 @@ public class StubClassesPermitted * the stub for it can be deserialized in the test client VM. */ public Registry getRegistry() throws RemoteException { - if (sameGroup) { - System.out.println("in same group"); - } else { - System.out.println("not in same group"); - } - return registry; + if (sameGroup) { + System.out.println("in same group"); + } else { + System.out.println("not in same group"); + } + return registry; } /** @@ -232,8 +232,8 @@ public class StubClassesPermitted * can be resolved in a remote call. */ public Object getForbiddenClass() throws RemoteException { - System.err.println("creating sun class"); - return new sun.security.provider.SecureRandom(); + System.err.println("creating sun class"); + return new sun.security.provider.SecureRandom(); } /** @@ -242,6 +242,6 @@ public class StubClassesPermitted * system implementation). */ public ActivationGroupID returnGroupID() throws RemoteException { - return ActivationGroup.currentGroupID(); + return ActivationGroup.currentGroupID(); } } diff --git a/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted_Stub.java b/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted_Stub.java index 829e2abf6952fc79f82cb8aec782928ebef09e9f..a8cb2d81f5f04611de374a8caee5b727c566162d 100644 --- a/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted_Stub.java +++ b/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,152 +29,152 @@ public final class StubClassesPermitted_Stub implements CanCreateStubs, java.rmi.Remote { private static final java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("java.lang.Object getForbiddenClass()"), - new java.rmi.server.Operation("java.rmi.registry.Registry getRegistry()"), - new java.rmi.server.Operation("java.rmi.activation.ActivationGroupID returnGroupID()"), - new java.rmi.server.Operation("void shutdown()") + new java.rmi.server.Operation("java.lang.Object getForbiddenClass()"), + new java.rmi.server.Operation("java.rmi.registry.Registry getRegistry()"), + new java.rmi.server.Operation("java.rmi.activation.ActivationGroupID returnGroupID()"), + new java.rmi.server.Operation("void shutdown()") }; - + private static final long interfaceHash = 1677779850431817575L; - + private static final long serialVersionUID = 2; - + private static boolean useNewInvoke; private static java.lang.reflect.Method $method_getForbiddenClass_0; private static java.lang.reflect.Method $method_getRegistry_1; private static java.lang.reflect.Method $method_returnGroupID_2; private static java.lang.reflect.Method $method_shutdown_3; - + static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_getForbiddenClass_0 = CanCreateStubs.class.getMethod("getForbiddenClass", new java.lang.Class[] {}); - $method_getRegistry_1 = CanCreateStubs.class.getMethod("getRegistry", new java.lang.Class[] {}); - $method_returnGroupID_2 = CanCreateStubs.class.getMethod("returnGroupID", new java.lang.Class[] {}); - $method_shutdown_3 = CanCreateStubs.class.getMethod("shutdown", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } + try { + java.rmi.server.RemoteRef.class.getMethod("invoke", + new java.lang.Class[] { + java.rmi.Remote.class, + java.lang.reflect.Method.class, + java.lang.Object[].class, + long.class + }); + useNewInvoke = true; + $method_getForbiddenClass_0 = CanCreateStubs.class.getMethod("getForbiddenClass", new java.lang.Class[] {}); + $method_getRegistry_1 = CanCreateStubs.class.getMethod("getRegistry", new java.lang.Class[] {}); + $method_returnGroupID_2 = CanCreateStubs.class.getMethod("returnGroupID", new java.lang.Class[] {}); + $method_shutdown_3 = CanCreateStubs.class.getMethod("shutdown", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + useNewInvoke = false; + } } - + // constructors public StubClassesPermitted_Stub() { - super(); + super(); } public StubClassesPermitted_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of getForbiddenClass() public java.lang.Object getForbiddenClass() - throws java.lang.Exception + throws java.lang.Exception { - if (useNewInvoke) { - Object $result = ref.invoke(this, $method_getForbiddenClass_0, null, -658265783646674294L); - return ((java.lang.Object) $result); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - ref.invoke(call); - java.lang.Object $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = (java.lang.Object) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } + if (useNewInvoke) { + Object $result = ref.invoke(this, $method_getForbiddenClass_0, null, -658265783646674294L); + return ((java.lang.Object) $result); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + ref.invoke(call); + java.lang.Object $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = (java.lang.Object) in.readObject(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } catch (java.lang.ClassNotFoundException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } } - + // implementation of getRegistry() public java.rmi.registry.Registry getRegistry() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - Object $result = ref.invoke(this, $method_getRegistry_1, null, 255311215504696981L); - return ((java.rmi.registry.Registry) $result); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); - ref.invoke(call); - java.rmi.registry.Registry $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = (java.rmi.registry.Registry) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + Object $result = ref.invoke(this, $method_getRegistry_1, null, 255311215504696981L); + return ((java.rmi.registry.Registry) $result); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); + ref.invoke(call); + java.rmi.registry.Registry $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = (java.rmi.registry.Registry) in.readObject(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } catch (java.lang.ClassNotFoundException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of returnGroupID() public java.rmi.activation.ActivationGroupID returnGroupID() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - Object $result = ref.invoke(this, $method_returnGroupID_2, null, 6267304638191237098L); - return ((java.rmi.activation.ActivationGroupID) $result); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash); - ref.invoke(call); - java.rmi.activation.ActivationGroupID $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = (java.rmi.activation.ActivationGroupID) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + Object $result = ref.invoke(this, $method_returnGroupID_2, null, 6267304638191237098L); + return ((java.rmi.activation.ActivationGroupID) $result); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash); + ref.invoke(call); + java.rmi.activation.ActivationGroupID $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = (java.rmi.activation.ActivationGroupID) in.readObject(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } catch (java.lang.ClassNotFoundException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of shutdown() public void shutdown() - throws java.lang.Exception + throws java.lang.Exception { - if (useNewInvoke) { - ref.invoke(this, $method_shutdown_3, null, -7207851917985848402L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash); - ref.invoke(call); - ref.done(call); - } + if (useNewInvoke) { + ref.invoke(this, $method_shutdown_3, null, -7207851917985848402L); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash); + ref.invoke(call); + ref.done(call); + } } } diff --git a/test/java/rmi/activation/ActivationSystem/unregisterGroup/ActivateMe.java b/test/java/rmi/activation/ActivationSystem/unregisterGroup/ActivateMe.java index cf165fb3141fb49780d32f7a9050ed685f3d1215..d9848e3c815d002b8b8183cb4552998327551685 100644 --- a/test/java/rmi/activation/ActivationSystem/unregisterGroup/ActivateMe.java +++ b/test/java/rmi/activation/ActivationSystem/unregisterGroup/ActivateMe.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/java/rmi/activation/ActivationSystem/unregisterGroup/CallbackInterface.java b/test/java/rmi/activation/ActivationSystem/unregisterGroup/CallbackInterface.java index 287346fa031677b8baaf2da3b6a9bc7e93818bc6..e737ac91603a66bf9a91bfd8fd24d4573abac715 100644 --- a/test/java/rmi/activation/ActivationSystem/unregisterGroup/CallbackInterface.java +++ b/test/java/rmi/activation/ActivationSystem/unregisterGroup/CallbackInterface.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,4 +27,3 @@ public interface CallbackInterface extends Remote { public void inc() throws RemoteException; public int getNumDeactivated() throws RemoteException; } - diff --git a/test/java/rmi/activation/ActivationSystem/unregisterGroup/Callback_Stub.java b/test/java/rmi/activation/ActivationSystem/unregisterGroup/Callback_Stub.java index 8e77ed15094c3259079a77adc40469a187d2b93e..4e8a85d759b7d9631008631b2c2f095f73d02948 100644 --- a/test/java/rmi/activation/ActivationSystem/unregisterGroup/Callback_Stub.java +++ b/test/java/rmi/activation/ActivationSystem/unregisterGroup/Callback_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,94 +29,94 @@ public final class Callback_Stub implements CallbackInterface, java.rmi.Remote { private static final java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("int getNumDeactivated()"), - new java.rmi.server.Operation("void inc()") + new java.rmi.server.Operation("int getNumDeactivated()"), + new java.rmi.server.Operation("void inc()") }; - + private static final long interfaceHash = -1008194523112388035L; - + private static final long serialVersionUID = 2; - + private static boolean useNewInvoke; private static java.lang.reflect.Method $method_getNumDeactivated_0; private static java.lang.reflect.Method $method_inc_1; - + static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_getNumDeactivated_0 = CallbackInterface.class.getMethod("getNumDeactivated", new java.lang.Class[] {}); - $method_inc_1 = CallbackInterface.class.getMethod("inc", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } + try { + java.rmi.server.RemoteRef.class.getMethod("invoke", + new java.lang.Class[] { + java.rmi.Remote.class, + java.lang.reflect.Method.class, + java.lang.Object[].class, + long.class + }); + useNewInvoke = true; + $method_getNumDeactivated_0 = CallbackInterface.class.getMethod("getNumDeactivated", new java.lang.Class[] {}); + $method_inc_1 = CallbackInterface.class.getMethod("inc", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + useNewInvoke = false; + } } - + // constructors public Callback_Stub() { - super(); + super(); } public Callback_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of getNumDeactivated() public int getNumDeactivated() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - Object $result = ref.invoke(this, $method_getNumDeactivated_0, null, -761062487639949912L); - return ((java.lang.Integer) $result).intValue(); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - ref.invoke(call); - int $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = in.readInt(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + Object $result = ref.invoke(this, $method_getNumDeactivated_0, null, -761062487639949912L); + return ((java.lang.Integer) $result).intValue(); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + ref.invoke(call); + int $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = in.readInt(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of inc() public void inc() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - ref.invoke(this, $method_inc_1, null, 4394985085384332959L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); - ref.invoke(call); - ref.done(call); - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + ref.invoke(this, $method_inc_1, null, 4394985085384332959L); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); + ref.invoke(call); + ref.done(call); + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java b/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java index 6498f738ffa14cf3c9d6158fb056c9ca27130c41..605b66b1ec874e031be3bed3825bc4e057c8c1d2 100644 --- a/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java +++ b/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -65,8 +65,8 @@ class Callback extends UnicastRemoteObject implements CallbackInterface { } public class UnregisterGroup - extends Activatable - implements ActivateMe, Runnable + extends Activatable + implements ActivateMe, Runnable { private static Exception exception = null; @@ -77,30 +77,30 @@ public class UnregisterGroup private static int PORT = 2006; public UnregisterGroup(ActivationID id, MarshalledObject mobj) - throws Exception + throws Exception { - super(id, 0); + super(id, 0); } public void ping() {} public void unregister() throws Exception { - super.unregister(super.getID()); + super.unregister(super.getID()); } - + /** * Spawns a thread to deactivate the object. */ public void shutdown() throws Exception { - (new Thread(this,"UnregisterGroup")).start(); + (new Thread(this,"UnregisterGroup")).start(); } /** * To support exiting of group VM as a last resort */ public void justGoAway() { - System.exit(0); + System.exit(0); } /** @@ -111,151 +111,151 @@ public class UnregisterGroup */ public void run() { - ActivationLibrary.deactivate(this, getID()); - System.err.println("\tActivationLibrary.deactivate returned"); + ActivationLibrary.deactivate(this, getID()); + System.err.println("\tActivationLibrary.deactivate returned"); - try { - CallbackInterface cobj = - (CallbackInterface)Naming.lookup("//:" + PORT + "/Callback"); - cobj.inc(); - } catch (Exception e) { - System.err.println("cobj.inc exception"); - e.printStackTrace(); - } + try { + CallbackInterface cobj = + (CallbackInterface)Naming.lookup("//:" + PORT + "/Callback"); + cobj.inc(); + } catch (Exception e) { + System.err.println("cobj.inc exception"); + e.printStackTrace(); + } } public static void main(String[] args) { - Registry registry; - - System.err.println("\nRegression test for bug 4134233\n"); - - TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); - RMID rmid = null; - - try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); - - /* Cause activation groups to have a security policy that will - * allow security managers to be downloaded and installed - */ - final Properties p = new Properties(); - // this test must always set policies/managers in its - // activation groups - p.put("java.security.policy", - TestParams.defaultGroupPolicy); - p.put("java.security.manager", - TestParams.defaultSecurityManager); - - //final int NUM_OBJECTS = 10; - - Thread t = new Thread() { - public void run () { - try { - System.err.println("Creating group descriptor"); - ActivationGroupDesc groupDesc = - new ActivationGroupDesc(p, null); - ActivationSystem system = ActivationGroup.getSystem(); - ActivationGroupID groupID = - system.registerGroup(groupDesc); - - ActivateMe[] obj = new ActivateMe[NUM_OBJECTS]; - - for (int i = 0; i < NUM_OBJECTS; i++) { - System.err.println("Creating descriptor: " + i); - ActivationDesc desc = - new ActivationDesc(groupID, "UnregisterGroup", - null, null); - System.err.println("Registering descriptor: " + i); - obj[i] = (ActivateMe) Activatable.register(desc); - System.err.println("Activating object: " + i); - obj[i].ping(); - } - lastResortExitObj = obj[0]; - - System.err.println("Unregistering group"); - system.unregisterGroup(groupID); - - try { - System.err.println("Get the group descriptor"); - system.getActivationGroupDesc(groupID); - error = "test failed: group still registered"; - } catch (UnknownGroupException e) { - System.err.println("Test passed: " + - "group unregistered"); - } - - - /* - * Deactivate objects so group VM will exit. - */ - for (int i = 0; i < NUM_OBJECTS; i++) { - System.err.println("Deactivating object: " + i); - obj[i].shutdown(); - obj[i] = null; - } - lastResortExitObj = null; - - } catch (Exception e) { - exception = e; - } - - done = true; - } - }; - - t.start(); - t.join(120000); - - if (exception != null) { - TestLibrary.bomb("test failed", exception); - } else if (error != null) { - TestLibrary.bomb(error, null); - } else if (!done) { - TestLibrary.bomb("test failed: not completed before timeout", null); - } else { - System.err.println("Test passed"); - } - - - } catch (Exception e) { - TestLibrary.bomb("test failed", e); - } finally { - if (lastResortExitObj != null) { - try { - lastResortExitObj.justGoAway(); - } catch (Exception munch) { - } - } - - // Wait for the object deactivation to take place first - try { - - // create reg and export callback object - registry = LocateRegistry.createRegistry(PORT); - Callback robj = new Callback(); - registry.bind("Callback", robj); - - //get the callback object - int maxwait=30; - int nd = robj.getNumDeactivated(); - while ((nd < NUM_OBJECTS) && (maxwait> 0)) { - System.err.println("num_deactivated="+nd); - try { - Thread.sleep(1000); - } catch (InterruptedException ie) {} - maxwait--; - nd = robj.getNumDeactivated(); - } - } catch (Exception ce) { - System.err.println("E:"+ce); - ce.printStackTrace(); - } - - ActivationLibrary.rmidCleanup(rmid); - } + Registry registry; + + System.err.println("\nRegression test for bug 4134233\n"); + + TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); + RMID rmid = null; + + try { + RMID.removeLog(); + rmid = RMID.createRMID(); + rmid.start(); + + /* Cause activation groups to have a security policy that will + * allow security managers to be downloaded and installed + */ + final Properties p = new Properties(); + // this test must always set policies/managers in its + // activation groups + p.put("java.security.policy", + TestParams.defaultGroupPolicy); + p.put("java.security.manager", + TestParams.defaultSecurityManager); + + //final int NUM_OBJECTS = 10; + + Thread t = new Thread() { + public void run () { + try { + System.err.println("Creating group descriptor"); + ActivationGroupDesc groupDesc = + new ActivationGroupDesc(p, null); + ActivationSystem system = ActivationGroup.getSystem(); + ActivationGroupID groupID = + system.registerGroup(groupDesc); + + ActivateMe[] obj = new ActivateMe[NUM_OBJECTS]; + + for (int i = 0; i < NUM_OBJECTS; i++) { + System.err.println("Creating descriptor: " + i); + ActivationDesc desc = + new ActivationDesc(groupID, "UnregisterGroup", + null, null); + System.err.println("Registering descriptor: " + i); + obj[i] = (ActivateMe) Activatable.register(desc); + System.err.println("Activating object: " + i); + obj[i].ping(); + } + lastResortExitObj = obj[0]; + + System.err.println("Unregistering group"); + system.unregisterGroup(groupID); + + try { + System.err.println("Get the group descriptor"); + system.getActivationGroupDesc(groupID); + error = "test failed: group still registered"; + } catch (UnknownGroupException e) { + System.err.println("Test passed: " + + "group unregistered"); + } + + + /* + * Deactivate objects so group VM will exit. + */ + for (int i = 0; i < NUM_OBJECTS; i++) { + System.err.println("Deactivating object: " + i); + obj[i].shutdown(); + obj[i] = null; + } + lastResortExitObj = null; + + } catch (Exception e) { + exception = e; + } + + done = true; + } + }; + + t.start(); + t.join(120000); + + if (exception != null) { + TestLibrary.bomb("test failed", exception); + } else if (error != null) { + TestLibrary.bomb(error, null); + } else if (!done) { + TestLibrary.bomb("test failed: not completed before timeout", null); + } else { + System.err.println("Test passed"); + } + + + } catch (Exception e) { + TestLibrary.bomb("test failed", e); + } finally { + if (lastResortExitObj != null) { + try { + lastResortExitObj.justGoAway(); + } catch (Exception munch) { + } + } + + // Wait for the object deactivation to take place first + try { + + // create reg and export callback object + registry = LocateRegistry.createRegistry(PORT); + Callback robj = new Callback(); + registry.bind("Callback", robj); + + //get the callback object + int maxwait=30; + int nd = robj.getNumDeactivated(); + while ((nd < NUM_OBJECTS) && (maxwait> 0)) { + System.err.println("num_deactivated="+nd); + try { + Thread.sleep(1000); + } catch (InterruptedException ie) {} + maxwait--; + nd = robj.getNumDeactivated(); + } + } catch (Exception ce) { + System.err.println("E:"+ce); + ce.printStackTrace(); + } + + ActivationLibrary.rmidCleanup(rmid); + } } } diff --git a/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup_Stub.java b/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup_Stub.java index 16a3278505bbca43fa6e7f248db76d7c50f98a86..e9a5bcfb14184a0571fbc7c1d0990746ee3113e5 100644 --- a/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup_Stub.java +++ b/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,116 +29,116 @@ public final class UnregisterGroup_Stub implements ActivateMe, java.rmi.Remote { private static final java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("void justGoAway()"), - new java.rmi.server.Operation("void ping()"), - new java.rmi.server.Operation("void shutdown()"), - new java.rmi.server.Operation("void unregister()") + new java.rmi.server.Operation("void justGoAway()"), + new java.rmi.server.Operation("void ping()"), + new java.rmi.server.Operation("void shutdown()"), + new java.rmi.server.Operation("void unregister()") }; - + private static final long interfaceHash = -4733924075192691630L; - + private static final long serialVersionUID = 2; - + private static boolean useNewInvoke; private static java.lang.reflect.Method $method_justGoAway_0; private static java.lang.reflect.Method $method_ping_1; private static java.lang.reflect.Method $method_shutdown_2; private static java.lang.reflect.Method $method_unregister_3; - + static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_justGoAway_0 = ActivateMe.class.getMethod("justGoAway", new java.lang.Class[] {}); - $method_ping_1 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {}); - $method_shutdown_2 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {}); - $method_unregister_3 = ActivateMe.class.getMethod("unregister", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } + try { + java.rmi.server.RemoteRef.class.getMethod("invoke", + new java.lang.Class[] { + java.rmi.Remote.class, + java.lang.reflect.Method.class, + java.lang.Object[].class, + long.class + }); + useNewInvoke = true; + $method_justGoAway_0 = ActivateMe.class.getMethod("justGoAway", new java.lang.Class[] {}); + $method_ping_1 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {}); + $method_shutdown_2 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {}); + $method_unregister_3 = ActivateMe.class.getMethod("unregister", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + useNewInvoke = false; + } } - + // constructors public UnregisterGroup_Stub() { - super(); + super(); } public UnregisterGroup_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of justGoAway() public void justGoAway() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - ref.invoke(this, $method_justGoAway_0, null, -5382478058620783904L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - ref.invoke(call); - ref.done(call); - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + ref.invoke(this, $method_justGoAway_0, null, -5382478058620783904L); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + ref.invoke(call); + ref.done(call); + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of ping() public void ping() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - ref.invoke(this, $method_ping_1, null, 5866401369815527589L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); - ref.invoke(call); - ref.done(call); - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + ref.invoke(this, $method_ping_1, null, 5866401369815527589L); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); + ref.invoke(call); + ref.done(call); + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of shutdown() public void shutdown() - throws java.lang.Exception + throws java.lang.Exception { - if (useNewInvoke) { - ref.invoke(this, $method_shutdown_2, null, -7207851917985848402L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash); - ref.invoke(call); - ref.done(call); - } + if (useNewInvoke) { + ref.invoke(this, $method_shutdown_2, null, -7207851917985848402L); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash); + ref.invoke(call); + ref.done(call); + } } - + // implementation of unregister() public void unregister() - throws java.lang.Exception + throws java.lang.Exception { - if (useNewInvoke) { - ref.invoke(this, $method_unregister_3, null, -5366864281862648102L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash); - ref.invoke(call); - ref.done(call); - } + if (useNewInvoke) { + ref.invoke(this, $method_unregister_3, null, -5366864281862648102L); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash); + ref.invoke(call); + ref.done(call); + } } } diff --git a/test/java/rmi/dgc/VMID/CheckVMID.java b/test/java/rmi/dgc/VMID/CheckVMID.java index ae32872b9430836a87dc6060ca6ed59d933a4858..09e4cbec91e6e6a6202ba93881f447ee464fa512 100644 --- a/test/java/rmi/dgc/VMID/CheckVMID.java +++ b/test/java/rmi/dgc/VMID/CheckVMID.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -41,17 +41,17 @@ public class CheckVMID { public static void main(String[] args) { - System.err.println("\nRegression test for bug 4171370\n"); + System.err.println("\nRegression test for bug 4171370\n"); - TestLibrary.suggestSecurityManager(null); + TestLibrary.suggestSecurityManager(null); - try { - System.err.println("Create a VMID"); - VMID vmid = new VMID(); - System.err.println("vmid = " + vmid); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("TEST FAILED: " + e.toString()); - } + try { + System.err.println("Create a VMID"); + VMID vmid = new VMID(); + System.err.println("vmid = " + vmid); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("TEST FAILED: " + e.toString()); + } } } diff --git a/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure.java b/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure.java index 446b2405ccf77571f1a2d436e7411ce32e17c1b7..2a0e4309be26229841e630601e955e3090541035 100644 --- a/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure.java +++ b/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -51,123 +51,123 @@ public class DGCAckFailure implements ReturnRemote { private static final long TIMEOUT = 20000; public Object returnRemote() { - return new Wrapper(this); + return new Wrapper(this); } public static void main(String[] args) throws Exception { - System.setProperty("sun.rmi.dgc.ackTimeout", "10000"); - - /* - * Set a socket factory that has a hook for shutting down all client - * output (writes from client-created sockets and new connection - * attempts). We then use this hook right before a remote stub gets - * deserialized, so that the client will not be able to send a DGC - * dirty call, or a DGC acknowledgment. Without the DGC ack, we - * hope that the RMI runtime will still eventually allow the remote - * object to be garbage collected. - */ - RMISocketFactory.setSocketFactory(new TestSF()); - System.err.println("test socket factory set"); - - Remote impl = new DGCAckFailure(); - ReferenceQueue refQueue = new ReferenceQueue(); - Reference weakRef = new WeakReference(impl, refQueue); - ReturnRemote stub = - (ReturnRemote) UnicastRemoteObject.exportObject(impl); - System.err.println("remote object exported; stub = " + stub); - - try { - Object wrappedStub = stub.returnRemote(); - System.err.println("invocation returned: " + wrappedStub); - - impl = null; - stub = null; // in case 4114579 ever gets fixed - System.err.println("strong references to impl cleared"); - - System.err.println("waiting for weak reference notification:"); - Reference ref = null; - for (int i = 0; i < 6; i++) { - System.gc(); - ref = refQueue.remove(TIMEOUT / 5); - if (ref != null) { - break; - } - } - if (ref == weakRef) { - System.err.println("TEST PASSED"); - } else { - throw new RuntimeException("TEST FAILED: " + - "timed out, remote object not garbage collected"); - } - } finally { - try { - UnicastRemoteObject.unexportObject((Remote) weakRef.get(), - true); - } catch (Exception e) { - } - } + System.setProperty("sun.rmi.dgc.ackTimeout", "10000"); + + /* + * Set a socket factory that has a hook for shutting down all client + * output (writes from client-created sockets and new connection + * attempts). We then use this hook right before a remote stub gets + * deserialized, so that the client will not be able to send a DGC + * dirty call, or a DGC acknowledgment. Without the DGC ack, we + * hope that the RMI runtime will still eventually allow the remote + * object to be garbage collected. + */ + RMISocketFactory.setSocketFactory(new TestSF()); + System.err.println("test socket factory set"); + + Remote impl = new DGCAckFailure(); + ReferenceQueue refQueue = new ReferenceQueue(); + Reference weakRef = new WeakReference(impl, refQueue); + ReturnRemote stub = + (ReturnRemote) UnicastRemoteObject.exportObject(impl); + System.err.println("remote object exported; stub = " + stub); + + try { + Object wrappedStub = stub.returnRemote(); + System.err.println("invocation returned: " + wrappedStub); + + impl = null; + stub = null; // in case 4114579 ever gets fixed + System.err.println("strong references to impl cleared"); + + System.err.println("waiting for weak reference notification:"); + Reference ref = null; + for (int i = 0; i < 6; i++) { + System.gc(); + ref = refQueue.remove(TIMEOUT / 5); + if (ref != null) { + break; + } + } + if (ref == weakRef) { + System.err.println("TEST PASSED"); + } else { + throw new RuntimeException("TEST FAILED: " + + "timed out, remote object not garbage collected"); + } + } finally { + try { + UnicastRemoteObject.unexportObject((Remote) weakRef.get(), + true); + } catch (Exception e) { + } + } } private static class Wrapper implements Serializable { - private final Remote obj; - Wrapper(Remote obj) { this.obj = obj; } - - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException - { - TestSF.shutdownClientOutput(); - System.err.println( - "Wrapper.readObject: SHUTTING DOWN CLIENT OUTPUT"); - in.defaultReadObject(); - } - - public String toString() { return "Wrapper[" + obj + "]"; } + private final Remote obj; + Wrapper(Remote obj) { this.obj = obj; } + + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + TestSF.shutdownClientOutput(); + System.err.println( + "Wrapper.readObject: SHUTTING DOWN CLIENT OUTPUT"); + in.defaultReadObject(); + } + + public String toString() { return "Wrapper[" + obj + "]"; } } private static class TestSF extends RMISocketFactory { - private static volatile boolean shutdown = false; - static void shutdownClientOutput() { shutdown = true; } - - public Socket createSocket(String host, int port) throws IOException { - if (shutdown) { - IOException e = new java.net.ConnectException( - "test socket factory rejecting client connection"); - System.err.println(e); -// e.printStackTrace(); - throw e; - } else { - return new TestSocket(host, port); - } - } - - public ServerSocket createServerSocket(int port) throws IOException { - return new ServerSocket(port); - } - - private static class TestSocket extends Socket { - TestSocket(String host, int port) throws IOException { - super(host, port); - } - public OutputStream getOutputStream() throws IOException { - return new TestOutputStream(super.getOutputStream()); - } - } - - private static class TestOutputStream extends FilterOutputStream { - TestOutputStream(OutputStream out) { super(out); } - public void write(int b) throws IOException { - if (shutdown) { - IOException e = new IOException( - "connection broken by test socket factory"); - System.err.println(e); -// e.printStackTrace(); - throw e; - } else { - super.write(b); - } - } - } + private static volatile boolean shutdown = false; + static void shutdownClientOutput() { shutdown = true; } + + public Socket createSocket(String host, int port) throws IOException { + if (shutdown) { + IOException e = new java.net.ConnectException( + "test socket factory rejecting client connection"); + System.err.println(e); +// e.printStackTrace(); + throw e; + } else { + return new TestSocket(host, port); + } + } + + public ServerSocket createServerSocket(int port) throws IOException { + return new ServerSocket(port); + } + + private static class TestSocket extends Socket { + TestSocket(String host, int port) throws IOException { + super(host, port); + } + public OutputStream getOutputStream() throws IOException { + return new TestOutputStream(super.getOutputStream()); + } + } + + private static class TestOutputStream extends FilterOutputStream { + TestOutputStream(OutputStream out) { super(out); } + public void write(int b) throws IOException { + if (shutdown) { + IOException e = new IOException( + "connection broken by test socket factory"); + System.err.println(e); +// e.printStackTrace(); + throw e; + } else { + super.write(b); + } + } + } } } diff --git a/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure_Stub.java b/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure_Stub.java index 1a9ecee6bea4842f3662a628acd9f450a2d7d347..b581905011159c5be1c06733fa0f691bf1455120 100644 --- a/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure_Stub.java +++ b/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,38 +29,38 @@ public final class DGCAckFailure_Stub implements ReturnRemote { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_returnRemote_0; - + static { - try { - $method_returnRemote_0 = ReturnRemote.class.getMethod("returnRemote", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_returnRemote_0 = ReturnRemote.class.getMethod("returnRemote", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public DGCAckFailure_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of returnRemote() public java.lang.Object returnRemote() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - Object $result = ref.invoke(this, $method_returnRemote_0, null, -8981544221566403070L); - return ((java.lang.Object) $result); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + Object $result = ref.invoke(this, $method_returnRemote_0, null, -8981544221566403070L); + return ((java.lang.Object) $result); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation.java b/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation.java index 83520d217b224bd2b18212b648f15ef3dae4dad5..3f06432f3527dba36367723f643f6bd00e439b03 100644 --- a/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation.java +++ b/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -57,55 +57,55 @@ public class DGCImplInsulation implements java.rmi.Remote { public static void main(String[] args) throws Exception { - TestLibrary.suggestSecurityManager(null); + TestLibrary.suggestSecurityManager(null); - Permissions perms = new Permissions(); - perms.add(new SocketPermission("*:1024-", "listen")); - AccessControlContext acc = - new AccessControlContext(new ProtectionDomain[] { - new ProtectionDomain( - new CodeSource(null, (Certificate[]) null), perms) }); + Permissions perms = new Permissions(); + perms.add(new SocketPermission("*:1024-", "listen")); + AccessControlContext acc = + new AccessControlContext(new ProtectionDomain[] { + new ProtectionDomain( + new CodeSource(null, (Certificate[]) null), perms) }); - Remote impl = new DGCImplInsulation();; + Remote impl = new DGCImplInsulation();; - try { - Remote stub = (Remote) java.security.AccessController.doPrivileged( - new ExportAction(impl)); - System.err.println("exported remote object; local stub: " + stub); + try { + Remote stub = (Remote) java.security.AccessController.doPrivileged( + new ExportAction(impl)); + System.err.println("exported remote object; local stub: " + stub); - MarshalledObject mobj = new MarshalledObject(stub); - stub = (Remote) mobj.get(); - System.err.println("marshalled/unmarshalled stub: " + stub); + MarshalledObject mobj = new MarshalledObject(stub); + stub = (Remote) mobj.get(); + System.err.println("marshalled/unmarshalled stub: " + stub); - ReferenceQueue refQueue = new ReferenceQueue(); - Reference weakRef = new WeakReference(impl, refQueue); - impl = null; - System.gc(); - if (refQueue.remove(TIMEOUT) == weakRef) { - throw new RuntimeException( - "TEST FAILED: remote object garbage collected"); - } else { - System.err.println("TEST PASSED"); - stub = null; - System.gc(); - Thread.sleep(2000); - System.gc(); - } - } finally { - try { - UnicastRemoteObject.unexportObject(impl, true); - } catch (Exception e) { - } - } + ReferenceQueue refQueue = new ReferenceQueue(); + Reference weakRef = new WeakReference(impl, refQueue); + impl = null; + System.gc(); + if (refQueue.remove(TIMEOUT) == weakRef) { + throw new RuntimeException( + "TEST FAILED: remote object garbage collected"); + } else { + System.err.println("TEST PASSED"); + stub = null; + System.gc(); + Thread.sleep(2000); + System.gc(); + } + } finally { + try { + UnicastRemoteObject.unexportObject(impl, true); + } catch (Exception e) { + } + } } private static class ExportAction implements PrivilegedExceptionAction { - private final Remote impl; - ExportAction(Remote impl) { - this.impl = impl; - } - public Object run() throws Exception { - return UnicastRemoteObject.exportObject(impl); - } + private final Remote impl; + ExportAction(Remote impl) { + this.impl = impl; + } + public Object run() throws Exception { + return UnicastRemoteObject.exportObject(impl); + } } } diff --git a/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation_Stub.java b/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation_Stub.java index e77edf0948ea1b9090fbdf70bcd014a6b027ea43..b73581aa1de6b395fbebb2970a61fe80c180ad3f 100644 --- a/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation_Stub.java +++ b/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,10 +29,10 @@ public final class DGCImplInsulation_Stub implements java.rmi.Remote { private static final long serialVersionUID = 2; - + // constructors public DGCImplInsulation_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + } diff --git a/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls.java b/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls.java index 954615d0f0bc287aabdb47035d6463cf22942f9c..b74931a09434f3d1636e99bac956f756fb028050 100644 --- a/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls.java +++ b/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -55,108 +55,108 @@ public class RetryDirtyCalls implements Self, Unreferenced { * Return this object. The need for this method is explained below. */ public Self getSelf() { - return this; + return this; } public void unreferenced() { - synchronized (this) { - unreferenced = true; - notifyAll(); - } + synchronized (this) { + unreferenced = true; + notifyAll(); + } } public static void main(String[] args) { - System.err.println("\nRegression test for bug 4268258\n"); - - /* - * Set properties to tweak DGC behavior so that this test will execute - * quickly: set the granted lease duration to 10 seconds, the interval - * that leases are checked to 3 seconds. - */ - System.setProperty("java.rmi.dgc.leaseValue", "10000"); - System.setProperty("sun.rmi.dgc.checkInterval", "3000"); - - /* - * Make idle connections time out almost instantly (0.1 seconds) so - * that the DGC implementation will have to make a new connection for - * each dirty call, thus going through the socket factory, where we - * can easily cause the operation to fail. - */ - System.setProperty("sun.rmi.transport.connectionTimeout", "100"); - - RetryDirtyCalls impl = new RetryDirtyCalls(); - - try { - TestSF sf = new TestSF(); - RMISocketFactory.setSocketFactory(sf); - - /* - * The stub returned by UnicastRemoteObject.exportObject() does - * not participate in DGC, but it does allow us to invoke a method - * on the remote object through RMI. Therefore, we invoke the - * getSelf() method through RMI, which returns an equivalent stub - * that does participate in DGC. - */ - Self stub = (Self) UnicastRemoteObject.exportObject(impl); - Self dgcStub = stub.getSelf(); - stub = null; // in case 4114579 has been fixed - - /* - * Set the socket factory to cause 3 connections attempts in a row - * to fail before allowing a connection to succeed, expecting the - * client-side DGC implementation to make at least four attempts. - */ - final int FLAKE_FACTOR = 3; - sf.setFlakeFactor(FLAKE_FACTOR); - - long deadline = System.currentTimeMillis() + TIMEOUT; - boolean unreferenced; - - synchronized (impl) { - while (!(unreferenced = impl.unreferenced)) { - long timeToWait = deadline - System.currentTimeMillis(); - if (timeToWait > 0) { - impl.wait(timeToWait); - } else { - break; - } - } - } - - if (unreferenced) { - throw new RuntimeException("remote object unreferenced"); - } - - int createCount = sf.getCreateCount(); - if (createCount == 0) { - throw new RuntimeException("test socket factory never used"); - } else if (createCount < (FLAKE_FACTOR + 3)) { - /* - * The unreferenced method was not invoked for some reason, - * but the dirty calls were clearly not retried well enough. - */ - throw new RuntimeException( - "test failed because dirty calls not retried enough, " + - "but remote object not unreferenced"); - } - - System.err.println( - "TEST PASSED: remote object not unreferenced"); - - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("TEST FAILED: " + e.toString()); - } finally { - /* - * When all is said and done, try to unexport the remote object - * so that the VM has a chance to exit. - */ - try { - UnicastRemoteObject.unexportObject(impl, true); - } catch (Exception e) { - } - } + System.err.println("\nRegression test for bug 4268258\n"); + + /* + * Set properties to tweak DGC behavior so that this test will execute + * quickly: set the granted lease duration to 10 seconds, the interval + * that leases are checked to 3 seconds. + */ + System.setProperty("java.rmi.dgc.leaseValue", "10000"); + System.setProperty("sun.rmi.dgc.checkInterval", "3000"); + + /* + * Make idle connections time out almost instantly (0.1 seconds) so + * that the DGC implementation will have to make a new connection for + * each dirty call, thus going through the socket factory, where we + * can easily cause the operation to fail. + */ + System.setProperty("sun.rmi.transport.connectionTimeout", "100"); + + RetryDirtyCalls impl = new RetryDirtyCalls(); + + try { + TestSF sf = new TestSF(); + RMISocketFactory.setSocketFactory(sf); + + /* + * The stub returned by UnicastRemoteObject.exportObject() does + * not participate in DGC, but it does allow us to invoke a method + * on the remote object through RMI. Therefore, we invoke the + * getSelf() method through RMI, which returns an equivalent stub + * that does participate in DGC. + */ + Self stub = (Self) UnicastRemoteObject.exportObject(impl); + Self dgcStub = stub.getSelf(); + stub = null; // in case 4114579 has been fixed + + /* + * Set the socket factory to cause 3 connections attempts in a row + * to fail before allowing a connection to succeed, expecting the + * client-side DGC implementation to make at least four attempts. + */ + final int FLAKE_FACTOR = 3; + sf.setFlakeFactor(FLAKE_FACTOR); + + long deadline = System.currentTimeMillis() + TIMEOUT; + boolean unreferenced; + + synchronized (impl) { + while (!(unreferenced = impl.unreferenced)) { + long timeToWait = deadline - System.currentTimeMillis(); + if (timeToWait > 0) { + impl.wait(timeToWait); + } else { + break; + } + } + } + + if (unreferenced) { + throw new RuntimeException("remote object unreferenced"); + } + + int createCount = sf.getCreateCount(); + if (createCount == 0) { + throw new RuntimeException("test socket factory never used"); + } else if (createCount < (FLAKE_FACTOR + 3)) { + /* + * The unreferenced method was not invoked for some reason, + * but the dirty calls were clearly not retried well enough. + */ + throw new RuntimeException( + "test failed because dirty calls not retried enough, " + + "but remote object not unreferenced"); + } + + System.err.println( + "TEST PASSED: remote object not unreferenced"); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("TEST FAILED: " + e.toString()); + } finally { + /* + * When all is said and done, try to unexport the remote object + * so that the VM has a chance to exit. + */ + try { + UnicastRemoteObject.unexportObject(impl, true); + } catch (Exception e) { + } + } } } @@ -169,30 +169,30 @@ class TestSF extends RMISocketFactory { private int createCount = 0; public synchronized void setFlakeFactor(int newFlakeFactor) { - flakeFactor = newFlakeFactor; + flakeFactor = newFlakeFactor; } public synchronized int getCreateCount() { - return createCount; + return createCount; } public synchronized Socket createSocket(String host, int port) - throws IOException + throws IOException { - createCount++; + createCount++; - if (++flakeState > flakeFactor) { - flakeState = 0; - } + if (++flakeState > flakeFactor) { + flakeState = 0; + } - if (flakeState == 0) { - return new Socket(host, port); - } else { - throw new IOException("random network failure"); - } + if (flakeState == 0) { + return new Socket(host, port); + } else { + throw new IOException("random network failure"); + } } public ServerSocket createServerSocket(int port) throws IOException { - return new ServerSocket(port); + return new ServerSocket(port); } } diff --git a/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls_Stub.java b/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls_Stub.java index 4007980eff666334777f2086a80d7f6c530be601..f35e8dccbef0dd25bbe80d6d706d2753f0aaaa56 100644 --- a/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls_Stub.java +++ b/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,38 +29,38 @@ public final class RetryDirtyCalls_Stub implements Self { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_getSelf_0; - + static { - try { - $method_getSelf_0 = Self.class.getMethod("getSelf", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_getSelf_0 = Self.class.getMethod("getSelf", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public RetryDirtyCalls_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of getSelf() public Self getSelf() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - Object $result = ref.invoke(this, $method_getSelf_0, null, 2868857108246021904L); - return ((Self) $result); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + Object $result = ref.invoke(this, $method_getSelf_0, null, 2868857108246021904L); + return ((Self) $result); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java b/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java index 56234cfb3a7bb8f03c56bf69c5c3ff9db4be978a..4263351b2fb8defca91a4cf85635c2c09b5818bd 100644 --- a/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java +++ b/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,8 +26,8 @@ * @summary rmid and rmiregistry could allow alternate security manager * @author Laird Dornin * - * @library ../../testlibrary - * @build StreamPipe TestParams TestLibrary JavaVM + * @library ../../testlibrary + * @build StreamPipe TestParams TestLibrary JavaVM * @build AltSecurityManager TestSecurityManager * @run main/othervm AltSecurityManager */ @@ -38,7 +38,7 @@ * that throws a runtime exception in its checkListen method, this * will cause rmiregistry and rmid to exit early because those * utilities will be unable to export any remote objects; test fails - * if registry and rmid take too long to exit. + * if registry and rmid take too long to exit. */ public class AltSecurityManager implements Runnable { @@ -54,74 +54,74 @@ public class AltSecurityManager implements Runnable { static long TIME_OUT = 15000; public void run() { - try { - vm = new JavaVM(utilityToStart, - " -Djava.security.manager=TestSecurityManager", - ""); - System.err.println("starting " + utilityToStart); - vm.start(); - vm.getVM().waitFor(); - - } catch (Exception e) { - TestLibrary.bomb(e); - } + try { + vm = new JavaVM(utilityToStart, + " -Djava.security.manager=TestSecurityManager", + ""); + System.err.println("starting " + utilityToStart); + vm.start(); + vm.getVM().waitFor(); + + } catch (Exception e) { + TestLibrary.bomb(e); + } } - + /** * Wait to make sure that the registry and rmid exit after * their security manager is set. */ public static void ensureExit(String utility) throws Exception { - utilityToStart = utility; - - try { - Thread thread = new Thread(new AltSecurityManager()); - System.err.println("expecting RuntimeException for " + - "checkListen in child process"); - long start = System.currentTimeMillis(); - thread.start(); - thread.join(TIME_OUT); - - long time = System.currentTimeMillis() - start; - System.err.println("waited " + time + " millis for " + - utilityToStart + " to die"); - - if (time >= TIME_OUT) { - - // dont pollute other tests; increase the likelihood + utilityToStart = utility; + + try { + Thread thread = new Thread(new AltSecurityManager()); + System.err.println("expecting RuntimeException for " + + "checkListen in child process"); + long start = System.currentTimeMillis(); + thread.start(); + thread.join(TIME_OUT); + + long time = System.currentTimeMillis() - start; + System.err.println("waited " + time + " millis for " + + utilityToStart + " to die"); + + if (time >= TIME_OUT) { + + // dont pollute other tests; increase the likelihood // that rmid will go away if it did not exit already. - if (utility.equals(rmid)) { - RMID.shutdown(); - } - - TestLibrary.bomb(utilityToStart + - " took too long to die..."); - } else { - System.err.println(utilityToStart + - " terminated on time"); - } - } finally { - vm.destroy(); - vm = null; - } + if (utility.equals(rmid)) { + RMID.shutdown(); + } + + TestLibrary.bomb(utilityToStart + + " took too long to die..."); + } else { + System.err.println(utilityToStart + + " terminated on time"); + } + } finally { + vm.destroy(); + vm = null; + } } - + public static void main(String[] args) { - try { - System.err.println("\nRegression test for bug 4183202\n"); + try { + System.err.println("\nRegression test for bug 4183202\n"); - // make sure the registry exits early. - ensureExit(registry); + // make sure the registry exits early. + ensureExit(registry); - // make sure rmid exits early - ensureExit(rmid); + // make sure rmid exits early + ensureExit(rmid); - System.err.println("test passed"); + System.err.println("test passed"); - } catch (Exception e) { - TestLibrary.bomb(e); - } finally { - RMID.removeLog(); - } + } catch (Exception e) { + TestLibrary.bomb(e); + } finally { + RMID.removeLog(); + } } } diff --git a/test/java/rmi/registry/altSecurityManager/TestSecurityManager.java b/test/java/rmi/registry/altSecurityManager/TestSecurityManager.java index 4619540b0dd5e0c3ea48f8da07f059888acfea3c..5d9e16253d0761acfb1fef9d33a5a82dbff9984c 100644 --- a/test/java/rmi/registry/altSecurityManager/TestSecurityManager.java +++ b/test/java/rmi/registry/altSecurityManager/TestSecurityManager.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -28,18 +28,18 @@ public class TestSecurityManager extends SecurityManager { } public void checkListen(int port) { - // 4269910: ok, now rmid and the regsitry will *really* go - // away... - // - // rmid and the registry need to listen on sockets so they - // will exit when they try to do so... this is used as a sign - // by the main test process to detect that the proper security - // manager has been installed in the relevant VMs. - // - System.exit(1); + // 4269910: ok, now rmid and the regsitry will *really* go + // away... + // + // rmid and the registry need to listen on sockets so they + // will exit when they try to do so... this is used as a sign + // by the main test process to detect that the proper security + // manager has been installed in the relevant VMs. + // + System.exit(1); } public void checkExit(int status) { - // permit check exit for all code + // permit check exit for all code } } diff --git a/test/java/rmi/registry/checkusage/CheckUsage.java b/test/java/rmi/registry/checkusage/CheckUsage.java index dbf9a9517e350eaa4ec8699cebdc8c5ba74752a3..37556efb82071169851dfa6ef2084d44dce75364 100644 --- a/test/java/rmi/registry/checkusage/CheckUsage.java +++ b/test/java/rmi/registry/checkusage/CheckUsage.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,48 +36,48 @@ import java.io.ByteArrayOutputStream; /** * Make sure that the rmiregistry prints out a correct usage statement * when run with an incorrect command line; test written to conform to - * new tighter bug fix/regression test guidelines. + * new tighter bug fix/regression test guidelines. */ public class CheckUsage { public static void main(String[] args) { - System.err.println("\nregression test for 4151966\n"); + System.err.println("\nregression test for 4151966\n"); - JavaVM registryVM = null; + JavaVM registryVM = null; - try { - // make sure the registry exits with a proper usage statement - ByteArrayOutputStream berr = new ByteArrayOutputStream(); - - // run a VM to start the registry - registryVM = new JavaVM("sun.rmi.registry.RegistryImpl", - "", "foo", - System.out, berr); - System.err.println("starting registry"); - registryVM.start(); - - // wait for registry exit - System.err.println(" registry exited with status: " + - registryVM.getVM().waitFor()); - try { - Thread.sleep(7000); - } catch (InterruptedException ie) { - } - - String usage = new String(berr.toByteArray()); - - System.err.println("rmiregistry usage: " + usage); - - if (usage.indexOf("-J") < 0) { - TestLibrary.bomb("rmiregistry has incorrect usage statement"); - } else { - System.err.println("test passed"); - } - } catch (Exception e) { - TestLibrary.bomb(e); - } finally { - registryVM.destroy(); - registryVM = null; - } + try { + // make sure the registry exits with a proper usage statement + ByteArrayOutputStream berr = new ByteArrayOutputStream(); + + // run a VM to start the registry + registryVM = new JavaVM("sun.rmi.registry.RegistryImpl", + "", "foo", + System.out, berr); + System.err.println("starting registry"); + registryVM.start(); + + // wait for registry exit + System.err.println(" registry exited with status: " + + registryVM.getVM().waitFor()); + try { + Thread.sleep(7000); + } catch (InterruptedException ie) { + } + + String usage = new String(berr.toByteArray()); + + System.err.println("rmiregistry usage: " + usage); + + if (usage.indexOf("-J") < 0) { + TestLibrary.bomb("rmiregistry has incorrect usage statement"); + } else { + System.err.println("test passed"); + } + } catch (Exception e) { + TestLibrary.bomb(e); + } finally { + registryVM.destroy(); + registryVM = null; + } } } diff --git a/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java b/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java index f94ff8696a966326b498cf99da5e38d0886a1781..ad7ba02d35d5e7a6ff4f084cb106c378c3461306 100644 --- a/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java +++ b/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -55,121 +55,121 @@ public class ClassPathCodebase { public static void main(String[] args) { - System.err.println("\nRegression test for bug 4242317\n"); - - TestLibrary.suggestSecurityManager("java.lang.SecurityManager"); - - Process rmiregistry = null; - - try { - /* - * Install a dummy class in two codebases: one that will be in - * the rmiregistry's CLASSPATH (the "import" codebase) and one - * that will be in the rmiregistry's "java.rmi.server.codebase" - * property (the "export" codebase). - */ - URL importCodebaseURL = TestLibrary.installClassInCodebase( - dummyClassName, importCodebase, false); - URL exportCodebaseURL = TestLibrary.installClassInCodebase( - dummyClassName, exportCodebase, true); - - /* - * Spawn an rmiregistry in the "import" codebase directory. - */ - File rmiregistryDir = - new File(System.getProperty("user.dir", "."), importCodebase); - - String rmiregistryCommand = - System.getProperty("java.home") + File.separator + - "bin" + File.separator + "rmiregistry"; - - String cmdarray[] = new String[] { - rmiregistryCommand, - "-J-Denv.class.path=.", - "-J-Djava.rmi.server.codebase=" + exportCodebaseURL, - Integer.toString(TestLibrary.REGISTRY_PORT) }; - - System.err.println("\nCommand used to spawn rmiregistry process:"); - System.err.println("\t" + Arrays.asList(cmdarray).toString()); - - rmiregistry = Runtime.getRuntime().exec(cmdarray, null, rmiregistryDir); - - // pipe rmiregistry output to our output, for debugging failures - StreamPipe.plugTogether(rmiregistry.getInputStream(), System.err); - StreamPipe.plugTogether(rmiregistry.getErrorStream(), System.err); - - /* - * Wait for the registry to initialize and be ready to call. - */ - Thread.sleep(REGISTRY_WAIT); - System.err.println(); - - /* - * Create an instance of the dummy class, finding it from the - * "import" codebase. - */ - ClassLoader loader = URLClassLoader.newInstance( - new URL[] { importCodebaseURL }); - Class dummyClass = Class.forName(dummyClassName, false, loader); - Remote dummyObject = (Remote) dummyClass.newInstance(); - - /* - * Find the registry that we created and bind the - * dummy object to it. - */ - Registry registry = LocateRegistry.getRegistry( - "localhost", TestLibrary.REGISTRY_PORT); - - try { - registry.bind(dummyBinding, dummyObject); - System.err.println("Bound dummy object in registry"); - } catch (java.rmi.ConnectException e) { - System.err.println("Error: rmiregistry not started in time"); - throw e; - } catch (ServerException e) { - if (e.detail instanceof UnmarshalException && - ((UnmarshalException) e.detail).detail instanceof - ClassNotFoundException) - { - System.err.println( - "Error: another registry running on port " + - TestLibrary.REGISTRY_PORT + "?"); - } - throw e; - } - - /* - * Look up the dummy object from our registry and make sure - * that its class was annotated with the "export" codebase. - */ - Remote dummyLookup = registry.lookup(dummyBinding); - System.err.println( - "Looked up dummy object from registry: " + dummyLookup); - Class dummyLookupClass = dummyLookup.getClass(); - String dummyLookupAnnotation = - RMIClassLoader.getClassAnnotation(dummyLookupClass); - System.err.println( - "Class annotation from registry: " + dummyLookupAnnotation); - - System.err.println(); - if (dummyLookupAnnotation.indexOf(exportCodebase) >= 0) { - System.err.println("TEST PASSED"); - } else if (dummyLookupAnnotation.indexOf(importCodebase) >= 0) { - throw new RuntimeException( - "rmiregistry annotated with CLASSPATH element URL"); - } else { - throw new RuntimeException( - "rmiregistry used unexpected annotation: \"" + - dummyLookupAnnotation + "\""); - } - - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("TEST FAILED: " + e.toString()); - } finally { - if (rmiregistry != null) { - rmiregistry.destroy(); - } - } + System.err.println("\nRegression test for bug 4242317\n"); + + TestLibrary.suggestSecurityManager("java.lang.SecurityManager"); + + Process rmiregistry = null; + + try { + /* + * Install a dummy class in two codebases: one that will be in + * the rmiregistry's CLASSPATH (the "import" codebase) and one + * that will be in the rmiregistry's "java.rmi.server.codebase" + * property (the "export" codebase). + */ + URL importCodebaseURL = TestLibrary.installClassInCodebase( + dummyClassName, importCodebase, false); + URL exportCodebaseURL = TestLibrary.installClassInCodebase( + dummyClassName, exportCodebase, true); + + /* + * Spawn an rmiregistry in the "import" codebase directory. + */ + File rmiregistryDir = + new File(System.getProperty("user.dir", "."), importCodebase); + + String rmiregistryCommand = + System.getProperty("java.home") + File.separator + + "bin" + File.separator + "rmiregistry"; + + String cmdarray[] = new String[] { + rmiregistryCommand, + "-J-Denv.class.path=.", + "-J-Djava.rmi.server.codebase=" + exportCodebaseURL, + Integer.toString(TestLibrary.REGISTRY_PORT) }; + + System.err.println("\nCommand used to spawn rmiregistry process:"); + System.err.println("\t" + Arrays.asList(cmdarray).toString()); + + rmiregistry = Runtime.getRuntime().exec(cmdarray, null, rmiregistryDir); + + // pipe rmiregistry output to our output, for debugging failures + StreamPipe.plugTogether(rmiregistry.getInputStream(), System.err); + StreamPipe.plugTogether(rmiregistry.getErrorStream(), System.err); + + /* + * Wait for the registry to initialize and be ready to call. + */ + Thread.sleep(REGISTRY_WAIT); + System.err.println(); + + /* + * Create an instance of the dummy class, finding it from the + * "import" codebase. + */ + ClassLoader loader = URLClassLoader.newInstance( + new URL[] { importCodebaseURL }); + Class dummyClass = Class.forName(dummyClassName, false, loader); + Remote dummyObject = (Remote) dummyClass.newInstance(); + + /* + * Find the registry that we created and bind the + * dummy object to it. + */ + Registry registry = LocateRegistry.getRegistry( + "localhost", TestLibrary.REGISTRY_PORT); + + try { + registry.bind(dummyBinding, dummyObject); + System.err.println("Bound dummy object in registry"); + } catch (java.rmi.ConnectException e) { + System.err.println("Error: rmiregistry not started in time"); + throw e; + } catch (ServerException e) { + if (e.detail instanceof UnmarshalException && + ((UnmarshalException) e.detail).detail instanceof + ClassNotFoundException) + { + System.err.println( + "Error: another registry running on port " + + TestLibrary.REGISTRY_PORT + "?"); + } + throw e; + } + + /* + * Look up the dummy object from our registry and make sure + * that its class was annotated with the "export" codebase. + */ + Remote dummyLookup = registry.lookup(dummyBinding); + System.err.println( + "Looked up dummy object from registry: " + dummyLookup); + Class dummyLookupClass = dummyLookup.getClass(); + String dummyLookupAnnotation = + RMIClassLoader.getClassAnnotation(dummyLookupClass); + System.err.println( + "Class annotation from registry: " + dummyLookupAnnotation); + + System.err.println(); + if (dummyLookupAnnotation.indexOf(exportCodebase) >= 0) { + System.err.println("TEST PASSED"); + } else if (dummyLookupAnnotation.indexOf(importCodebase) >= 0) { + throw new RuntimeException( + "rmiregistry annotated with CLASSPATH element URL"); + } else { + throw new RuntimeException( + "rmiregistry used unexpected annotation: \"" + + dummyLookupAnnotation + "\""); + } + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("TEST FAILED: " + e.toString()); + } finally { + if (rmiregistry != null) { + rmiregistry.destroy(); + } + } } } diff --git a/test/java/rmi/registry/classPathCodebase/Dummy.java b/test/java/rmi/registry/classPathCodebase/Dummy.java index 9b57cf18cf4fe53e2890f3c0de515da24572ef76..ad40244578a9fb37a741c831d88e8992f8653c56 100644 --- a/test/java/rmi/registry/classPathCodebase/Dummy.java +++ b/test/java/rmi/registry/classPathCodebase/Dummy.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,12 +36,12 @@ public class Dummy } public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException + throws java.io.IOException { } public void readExternal(java.io.ObjectInput in) - throws java.io.IOException, ClassNotFoundException + throws java.io.IOException, ClassNotFoundException { } } diff --git a/test/java/rmi/registry/emptyName/EmptyName.java b/test/java/rmi/registry/emptyName/EmptyName.java index fd6cf64a91368a7b12d1b114fbc06eecb27e8427..7507dc7fa6300a87a77d363ae4cf4e34946bf01b 100644 --- a/test/java/rmi/registry/emptyName/EmptyName.java +++ b/test/java/rmi/registry/emptyName/EmptyName.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,12 +32,12 @@ import java.rmi.server.RemoteObject; public class EmptyName { public static void main(String[] args) throws Exception { - Registry impl = LocateRegistry.createRegistry(0); - Registry stub = (Registry) RemoteObject.toStub(impl); - stub.bind("", stub); - stub.lookup(""); - stub.rebind("", stub); - stub.lookup(""); - stub.unbind(""); + Registry impl = LocateRegistry.createRegistry(0); + Registry stub = (Registry) RemoteObject.toStub(impl); + stub.bind("", stub); + stub.lookup(""); + stub.rebind("", stub); + stub.lookup(""); + stub.unbind(""); } } diff --git a/test/java/rmi/registry/interfaceHash/InterfaceHash.java b/test/java/rmi/registry/interfaceHash/InterfaceHash.java index 011022e753f8d891795017e5e828331ec6b9cb6d..8ab80dd26f328fa2e55dd700e756c9e6d2813479 100644 --- a/test/java/rmi/registry/interfaceHash/InterfaceHash.java +++ b/test/java/rmi/registry/interfaceHash/InterfaceHash.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -62,157 +62,157 @@ public class InterfaceHash { private static final String NAME = "WMM"; public static void main(String[] args) throws Exception { - System.err.println("\nRegression test for bug 4472769"); - - System.err.println( - "\n=== verifying that J2SE registry's skeleton uses" + - "\ncorrect interface hash and operation numbers:"); - - Registry testImpl = LocateRegistry.createRegistry(PORT); - System.err.println("created test registry on port " + PORT); - - RemoteRef ref = new UnicastRef( - new LiveRef(new ObjID(ObjID.REGISTRY_ID), - new TCPEndpoint("", PORT), false)); - Registry referenceStub = new ReferenceRegistryStub(ref); - System.err.println("created reference registry stub: " + - referenceStub); - - referenceStub.bind(NAME, referenceStub); - System.err.println("bound name \"" + NAME + "\" in registry"); - - String[] list = referenceStub.list(); - System.err.println("list of registry contents: " + - Arrays.asList(list)); - if (list.length != 1 || !list[0].equals(NAME)) { - throw new RuntimeException( - "TEST FAILED: unexpected list contents"); - } - - Registry result = (Registry) referenceStub.lookup(NAME); - System.err.println("lookup of name \"" + NAME + "\" returned: " + - result); - if (!result.equals(referenceStub)) { - throw new RuntimeException( - "TEST FAILED: unexpected lookup result"); - } - - referenceStub.rebind(NAME, referenceStub); - referenceStub.unbind(NAME); - System.err.println("unbound name \"" + NAME + "\""); - - list = referenceStub.list(); - System.err.println("list of registry contents: " + - Arrays.asList(list)); - if (list.length != 0) { - throw new RuntimeException("TEST FAILED: list not empty"); - } - - System.err.println("\n=== verifying that J2SE registry's stub uses" + - "correct interface hash:"); - - class FakeRemoteRef implements RemoteRef { - long hash; - int opnum; - public RemoteCall newCall(RemoteObject obj, Operation[] op, - int opnum, long hash) - { - this.hash = hash; - this.opnum = opnum; - throw new UnsupportedOperationException(); - } - public void invoke(RemoteCall call) { } - public void done(RemoteCall call) { } - public Object invoke(Remote obj, Method method, - Object[] args, long hash) - { - throw new UnsupportedOperationException(); - } - public String getRefClass(java.io.ObjectOutput out) { - return "FakeRemoteRef"; - } - public int remoteHashCode() { return 1013; } - public boolean remoteEquals(RemoteRef obj) { return false; } - public String remoteToString() { return "FakeRemoteRef"; } - public void writeExternal(java.io.ObjectOutput out) { } - public void readExternal(java.io.ObjectInput in) { } - } - FakeRemoteRef f = new FakeRemoteRef(); - - Registry testRegistry = LocateRegistry.getRegistry(PORT); - System.err.println("created original test registry stub: " + - testRegistry); - - Class stubClass = testRegistry.getClass(); - System.err.println("test registry stub class: " + stubClass); - - Constructor cons = stubClass.getConstructor( - new Class[] { RemoteRef.class }); - Registry testStub = (Registry) cons.newInstance( - new Object[] { f }); - System.err.println("created new instrumented test registry stub: " + - testStub); - - System.err.println("invoking bind:"); - try { - testStub.bind(NAME, referenceStub); - } catch (UnsupportedOperationException e) { - } - System.err.println("hash == " + f.hash + ", opnum == " + f.opnum); - if (f.hash != 4905912898345647071L) { - throw new RuntimeException("TEST FAILED: wrong interface hash"); - } else if (f.opnum != 0) { - throw new RuntimeException("TEST FAILED: wrong operation number"); - } - - System.err.println("invoking list:"); - try { - testStub.list(); - } catch (UnsupportedOperationException e) { - } - System.err.println("hash == " + f.hash + ", opnum == " + f.opnum); - if (f.hash != 4905912898345647071L) { - throw new RuntimeException("TEST FAILED: wrong interface hash"); - } else if (f.opnum != 1) { - throw new RuntimeException("TEST FAILED: wrong operation number"); - } - - System.err.println("invoking lookup:"); - try { - testStub.lookup(NAME); - } catch (UnsupportedOperationException e) { - } - System.err.println("hash == " + f.hash + ", opnum == " + f.opnum); - if (f.hash != 4905912898345647071L) { - throw new RuntimeException("TEST FAILED: wrong interface hash"); - } else if (f.opnum != 2) { - throw new RuntimeException("TEST FAILED: wrong operation number"); - } - - System.err.println("invoking rebind:"); - try { - testStub.rebind(NAME, referenceStub); - } catch (UnsupportedOperationException e) { - } - System.err.println("hash == " + f.hash + ", opnum == " + f.opnum); - if (f.hash != 4905912898345647071L) { - throw new RuntimeException("TEST FAILED: wrong interface hash"); - } else if (f.opnum != 3) { - throw new RuntimeException("TEST FAILED: wrong operation number"); - } - - System.err.println("invoking unbind:"); - try { - testStub.unbind(NAME); - } catch (UnsupportedOperationException e) { - } - System.err.println("hash == " + f.hash + ", opnum == " + f.opnum); - if (f.hash != 4905912898345647071L) { - throw new RuntimeException("TEST FAILED: wrong interface hash"); - } else if (f.opnum != 4) { - throw new RuntimeException("TEST FAILED: wrong operation number"); - } - - System.err.println("TEST PASSED"); + System.err.println("\nRegression test for bug 4472769"); + + System.err.println( + "\n=== verifying that J2SE registry's skeleton uses" + + "\ncorrect interface hash and operation numbers:"); + + Registry testImpl = LocateRegistry.createRegistry(PORT); + System.err.println("created test registry on port " + PORT); + + RemoteRef ref = new UnicastRef( + new LiveRef(new ObjID(ObjID.REGISTRY_ID), + new TCPEndpoint("", PORT), false)); + Registry referenceStub = new ReferenceRegistryStub(ref); + System.err.println("created reference registry stub: " + + referenceStub); + + referenceStub.bind(NAME, referenceStub); + System.err.println("bound name \"" + NAME + "\" in registry"); + + String[] list = referenceStub.list(); + System.err.println("list of registry contents: " + + Arrays.asList(list)); + if (list.length != 1 || !list[0].equals(NAME)) { + throw new RuntimeException( + "TEST FAILED: unexpected list contents"); + } + + Registry result = (Registry) referenceStub.lookup(NAME); + System.err.println("lookup of name \"" + NAME + "\" returned: " + + result); + if (!result.equals(referenceStub)) { + throw new RuntimeException( + "TEST FAILED: unexpected lookup result"); + } + + referenceStub.rebind(NAME, referenceStub); + referenceStub.unbind(NAME); + System.err.println("unbound name \"" + NAME + "\""); + + list = referenceStub.list(); + System.err.println("list of registry contents: " + + Arrays.asList(list)); + if (list.length != 0) { + throw new RuntimeException("TEST FAILED: list not empty"); + } + + System.err.println("\n=== verifying that J2SE registry's stub uses" + + "correct interface hash:"); + + class FakeRemoteRef implements RemoteRef { + long hash; + int opnum; + public RemoteCall newCall(RemoteObject obj, Operation[] op, + int opnum, long hash) + { + this.hash = hash; + this.opnum = opnum; + throw new UnsupportedOperationException(); + } + public void invoke(RemoteCall call) { } + public void done(RemoteCall call) { } + public Object invoke(Remote obj, Method method, + Object[] args, long hash) + { + throw new UnsupportedOperationException(); + } + public String getRefClass(java.io.ObjectOutput out) { + return "FakeRemoteRef"; + } + public int remoteHashCode() { return 1013; } + public boolean remoteEquals(RemoteRef obj) { return false; } + public String remoteToString() { return "FakeRemoteRef"; } + public void writeExternal(java.io.ObjectOutput out) { } + public void readExternal(java.io.ObjectInput in) { } + } + FakeRemoteRef f = new FakeRemoteRef(); + + Registry testRegistry = LocateRegistry.getRegistry(PORT); + System.err.println("created original test registry stub: " + + testRegistry); + + Class stubClass = testRegistry.getClass(); + System.err.println("test registry stub class: " + stubClass); + + Constructor cons = stubClass.getConstructor( + new Class[] { RemoteRef.class }); + Registry testStub = (Registry) cons.newInstance( + new Object[] { f }); + System.err.println("created new instrumented test registry stub: " + + testStub); + + System.err.println("invoking bind:"); + try { + testStub.bind(NAME, referenceStub); + } catch (UnsupportedOperationException e) { + } + System.err.println("hash == " + f.hash + ", opnum == " + f.opnum); + if (f.hash != 4905912898345647071L) { + throw new RuntimeException("TEST FAILED: wrong interface hash"); + } else if (f.opnum != 0) { + throw new RuntimeException("TEST FAILED: wrong operation number"); + } + + System.err.println("invoking list:"); + try { + testStub.list(); + } catch (UnsupportedOperationException e) { + } + System.err.println("hash == " + f.hash + ", opnum == " + f.opnum); + if (f.hash != 4905912898345647071L) { + throw new RuntimeException("TEST FAILED: wrong interface hash"); + } else if (f.opnum != 1) { + throw new RuntimeException("TEST FAILED: wrong operation number"); + } + + System.err.println("invoking lookup:"); + try { + testStub.lookup(NAME); + } catch (UnsupportedOperationException e) { + } + System.err.println("hash == " + f.hash + ", opnum == " + f.opnum); + if (f.hash != 4905912898345647071L) { + throw new RuntimeException("TEST FAILED: wrong interface hash"); + } else if (f.opnum != 2) { + throw new RuntimeException("TEST FAILED: wrong operation number"); + } + + System.err.println("invoking rebind:"); + try { + testStub.rebind(NAME, referenceStub); + } catch (UnsupportedOperationException e) { + } + System.err.println("hash == " + f.hash + ", opnum == " + f.opnum); + if (f.hash != 4905912898345647071L) { + throw new RuntimeException("TEST FAILED: wrong interface hash"); + } else if (f.opnum != 3) { + throw new RuntimeException("TEST FAILED: wrong operation number"); + } + + System.err.println("invoking unbind:"); + try { + testStub.unbind(NAME); + } catch (UnsupportedOperationException e) { + } + System.err.println("hash == " + f.hash + ", opnum == " + f.opnum); + if (f.hash != 4905912898345647071L) { + throw new RuntimeException("TEST FAILED: wrong interface hash"); + } else if (f.opnum != 4) { + throw new RuntimeException("TEST FAILED: wrong operation number"); + } + + System.err.println("TEST PASSED"); } } diff --git a/test/java/rmi/registry/interfaceHash/ReferenceRegistryStub.java b/test/java/rmi/registry/interfaceHash/ReferenceRegistryStub.java index 2e4a1df143daca9f3e08137f0f79f25216d894da..9db88da5939d8f9506049746c77a1609adc0df8e 100644 --- a/test/java/rmi/registry/interfaceHash/ReferenceRegistryStub.java +++ b/test/java/rmi/registry/interfaceHash/ReferenceRegistryStub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,161 +26,161 @@ public final class ReferenceRegistryStub implements java.rmi.registry.Registry, java.rmi.Remote { private static final java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("void bind(java.lang.String, java.rmi.Remote)"), - new java.rmi.server.Operation("java.lang.String list()[]"), - new java.rmi.server.Operation("java.rmi.Remote lookup(java.lang.String)"), - new java.rmi.server.Operation("void rebind(java.lang.String, java.rmi.Remote)"), - new java.rmi.server.Operation("void unbind(java.lang.String)") + new java.rmi.server.Operation("void bind(java.lang.String, java.rmi.Remote)"), + new java.rmi.server.Operation("java.lang.String list()[]"), + new java.rmi.server.Operation("java.rmi.Remote lookup(java.lang.String)"), + new java.rmi.server.Operation("void rebind(java.lang.String, java.rmi.Remote)"), + new java.rmi.server.Operation("void unbind(java.lang.String)") }; - + private static final long interfaceHash = 4905912898345647071L; - + // constructors public ReferenceRegistryStub() { - super(); + super(); } public ReferenceRegistryStub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of bind(String, Remote) public void bind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2) - throws java.rmi.AccessException, java.rmi.AlreadyBoundException, java.rmi.RemoteException + throws java.rmi.AccessException, java.rmi.AlreadyBoundException, java.rmi.RemoteException { - try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - try { - java.io.ObjectOutput out = call.getOutputStream(); - out.writeObject($param_String_1); - out.writeObject($param_Remote_2); - } catch (java.io.IOException e) { - throw new java.rmi.MarshalException("error marshalling arguments", e); - } - ref.invoke(call); - ref.done(call); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.rmi.AlreadyBoundException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + try { + java.io.ObjectOutput out = call.getOutputStream(); + out.writeObject($param_String_1); + out.writeObject($param_Remote_2); + } catch (java.io.IOException e) { + throw new java.rmi.MarshalException("error marshalling arguments", e); + } + ref.invoke(call); + ref.done(call); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.rmi.AlreadyBoundException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of list() public java.lang.String[] list() - throws java.rmi.AccessException, java.rmi.RemoteException + throws java.rmi.AccessException, java.rmi.RemoteException { - try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); - ref.invoke(call); - java.lang.String[] $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = (java.lang.String[]) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); + ref.invoke(call); + java.lang.String[] $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = (java.lang.String[]) in.readObject(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } catch (java.lang.ClassNotFoundException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of lookup(String) public java.rmi.Remote lookup(java.lang.String $param_String_1) - throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException + throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException { - try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash); - try { - java.io.ObjectOutput out = call.getOutputStream(); - out.writeObject($param_String_1); - } catch (java.io.IOException e) { - throw new java.rmi.MarshalException("error marshalling arguments", e); - } - ref.invoke(call); - java.rmi.Remote $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = (java.rmi.Remote) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.rmi.NotBoundException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash); + try { + java.io.ObjectOutput out = call.getOutputStream(); + out.writeObject($param_String_1); + } catch (java.io.IOException e) { + throw new java.rmi.MarshalException("error marshalling arguments", e); + } + ref.invoke(call); + java.rmi.Remote $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = (java.rmi.Remote) in.readObject(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } catch (java.lang.ClassNotFoundException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.rmi.NotBoundException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of rebind(String, Remote) public void rebind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2) - throws java.rmi.AccessException, java.rmi.RemoteException + throws java.rmi.AccessException, java.rmi.RemoteException { - try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash); - try { - java.io.ObjectOutput out = call.getOutputStream(); - out.writeObject($param_String_1); - out.writeObject($param_Remote_2); - } catch (java.io.IOException e) { - throw new java.rmi.MarshalException("error marshalling arguments", e); - } - ref.invoke(call); - ref.done(call); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash); + try { + java.io.ObjectOutput out = call.getOutputStream(); + out.writeObject($param_String_1); + out.writeObject($param_Remote_2); + } catch (java.io.IOException e) { + throw new java.rmi.MarshalException("error marshalling arguments", e); + } + ref.invoke(call); + ref.done(call); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of unbind(String) public void unbind(java.lang.String $param_String_1) - throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException + throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException { - try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 4, interfaceHash); - try { - java.io.ObjectOutput out = call.getOutputStream(); - out.writeObject($param_String_1); - } catch (java.io.IOException e) { - throw new java.rmi.MarshalException("error marshalling arguments", e); - } - ref.invoke(call); - ref.done(call); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.rmi.NotBoundException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 4, interfaceHash); + try { + java.io.ObjectOutput out = call.getOutputStream(); + out.writeObject($param_String_1); + } catch (java.io.IOException e) { + throw new java.rmi.MarshalException("error marshalling arguments", e); + } + ref.invoke(call); + ref.done(call); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.rmi.NotBoundException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/registry/multipleRegistries/MultipleRegistries.java b/test/java/rmi/registry/multipleRegistries/MultipleRegistries.java index bdfb87c87edf4dd5acb04fa753b0d29f835af46d..8bca932dda352c01e49d39554911a69581eb8862 100644 --- a/test/java/rmi/registry/multipleRegistries/MultipleRegistries.java +++ b/test/java/rmi/registry/multipleRegistries/MultipleRegistries.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -41,49 +41,49 @@ public class MultipleRegistries implements RemoteInterface { private static final String NAME = "MultipleRegistries"; public Object passObject(Object obj) { - return obj; + return obj; } - + public static void main(String[] args) throws Exception { - - RemoteInterface server = null; - RemoteInterface proxy = null; - - try { - System.err.println("export object"); - server = new MultipleRegistries(); - proxy = - (RemoteInterface) UnicastRemoteObject.exportObject(server, 0); - - System.err.println("proxy = " + proxy); - - System.err.println("export registries"); - Registry registryImpl1 = LocateRegistry.createRegistry(2030); - Registry registryImpl2 = LocateRegistry.createRegistry(2040); - - System.err.println("bind remote object in registries"); - Registry registry1 = LocateRegistry.getRegistry(2030); - Registry registry2 = LocateRegistry.getRegistry(2040); - - registry1.bind(NAME, proxy); - registry2.bind(NAME, proxy); - - System.err.println("lookup remote object in registries"); - - RemoteInterface remote1 = (RemoteInterface) registry1.lookup(NAME); - RemoteInterface remote2 = (RemoteInterface) registry2.lookup(NAME); - - System.err.println("invoke methods on remote objects"); - remote1.passObject(remote1); - remote2.passObject(remote2); - - System.err.println("TEST PASSED"); - - } finally { - if (proxy != null) { - UnicastRemoteObject.unexportObject(server, true); - } - } + + RemoteInterface server = null; + RemoteInterface proxy = null; + + try { + System.err.println("export object"); + server = new MultipleRegistries(); + proxy = + (RemoteInterface) UnicastRemoteObject.exportObject(server, 0); + + System.err.println("proxy = " + proxy); + + System.err.println("export registries"); + Registry registryImpl1 = LocateRegistry.createRegistry(2030); + Registry registryImpl2 = LocateRegistry.createRegistry(2040); + + System.err.println("bind remote object in registries"); + Registry registry1 = LocateRegistry.getRegistry(2030); + Registry registry2 = LocateRegistry.getRegistry(2040); + + registry1.bind(NAME, proxy); + registry2.bind(NAME, proxy); + + System.err.println("lookup remote object in registries"); + + RemoteInterface remote1 = (RemoteInterface) registry1.lookup(NAME); + RemoteInterface remote2 = (RemoteInterface) registry2.lookup(NAME); + + System.err.println("invoke methods on remote objects"); + remote1.passObject(remote1); + remote2.passObject(remote2); + + System.err.println("TEST PASSED"); + + } finally { + if (proxy != null) { + UnicastRemoteObject.unexportObject(server, true); + } + } } } diff --git a/test/java/rmi/registry/reexport/Reexport.java b/test/java/rmi/registry/reexport/Reexport.java index 23f10e890a41141916881dd054f54b0a323ed6c5..5c88736d4f088cf57c0e6b8fb997e481a999699b 100644 --- a/test/java/rmi/registry/reexport/Reexport.java +++ b/test/java/rmi/registry/reexport/Reexport.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -25,13 +25,13 @@ * @bug 4120329 * @summary RMI registry creation is impossible if first attempt fails. * @library ../../testlibrary - * @build StreamPipe TestParams TestLibrary JavaVM + * @build StreamPipe TestParams TestLibrary JavaVM * @build RegistryRunner RegistryRunner_Stub * @build Reexport * @run main/othervm Reexport */ -/* +/* * If a VM could not create an RMI registry because another registry * usually in another process, was using the registry port, the next * time the VM tried to create a registry (after the other registry @@ -40,7 +40,7 @@ * use when it should never have been allocated. * * The test creates this conflict using Runtime.exec and ensures that - * a registry can still be created after the conflict is resolved. + * a registry can still be created after the conflict is resolved. */ import java.io.*; @@ -50,106 +50,106 @@ import java.rmi.server.*; public class Reexport { static public final int regport = TestLibrary.REGISTRY_PORT; - + static public void main(String[] argv) { - Registry reg = null; - - try { - System.err.println("\nregression test for 4120329\n"); - - // establish the registry (we hope) - System.err.println("Starting registry on port " + regport); - Reexport.makeRegistry(regport); - - // Get a handle to the registry - System.err.println("Creating duplicate registry, this should fail..."); - reg = createReg(true); - - if (reg != null) { - TestLibrary.bomb("failed was able to duplicate the registry?!?"); - } - - // Kill the first registry. - System.err.println("Bringing down the first registry"); - try { - Reexport.killRegistry(); - } catch (Exception foo) { - } - - // start another registry now that the first is gone; this should work - System.err.println("Trying again to start our own " + - "registry... this should work"); - - reg = createReg(false); - - if (reg == null) { - TestLibrary.bomb("Could not create registry on second try"); - } - - System.err.println("Test passed"); - - } catch (Exception e) { - TestLibrary.bomb(e); - } finally { - // dont leave the registry around to affect other tests. - killRegistry(); - - reg = null; - } + Registry reg = null; + + try { + System.err.println("\nregression test for 4120329\n"); + + // establish the registry (we hope) + System.err.println("Starting registry on port " + regport); + Reexport.makeRegistry(regport); + + // Get a handle to the registry + System.err.println("Creating duplicate registry, this should fail..."); + reg = createReg(true); + + if (reg != null) { + TestLibrary.bomb("failed was able to duplicate the registry?!?"); + } + + // Kill the first registry. + System.err.println("Bringing down the first registry"); + try { + Reexport.killRegistry(); + } catch (Exception foo) { + } + + // start another registry now that the first is gone; this should work + System.err.println("Trying again to start our own " + + "registry... this should work"); + + reg = createReg(false); + + if (reg == null) { + TestLibrary.bomb("Could not create registry on second try"); + } + + System.err.println("Test passed"); + + } catch (Exception e) { + TestLibrary.bomb(e); + } finally { + // dont leave the registry around to affect other tests. + killRegistry(); + + reg = null; + } } - + static Registry createReg(boolean remoteOk) { - Registry reg = null; - - try { - reg = LocateRegistry.createRegistry(regport); - } catch (Throwable e) { - if (remoteOk) { - System.err.println("EXPECTING PORT IN USE EXCEPTION:"); - System.err.println(e.getMessage()); - e.printStackTrace(); - } else { - TestLibrary.bomb((Exception) e); - } - } - - return reg; + Registry reg = null; + + try { + reg = LocateRegistry.createRegistry(regport); + } catch (Throwable e) { + if (remoteOk) { + System.err.println("EXPECTING PORT IN USE EXCEPTION:"); + System.err.println(e.getMessage()); + e.printStackTrace(); + } else { + TestLibrary.bomb((Exception) e); + } + } + + return reg; } public static void makeRegistry(int p) { - // sadly, we can't kill a registry if we have too-close control - // over it. We must make it in a subprocess, and then kill the - // subprocess when it has served our needs. - - try { - JavaVM jvm = new JavaVM("RegistryRunner", "", Integer.toString(p)); - jvm.start(); - Reexport.subreg = jvm.getVM(); - - } catch (IOException e) { - // one of these is summarily dropped, can't remember which one - System.out.println ("Test setup failed - cannot run rmiregistry"); - TestLibrary.bomb("Test setup failed - cannot run test", e); - } - // Slop - wait for registry to come up. This is stupid. - try { - Thread.sleep (5000); - } catch (Exception whatever) { - } + // sadly, we can't kill a registry if we have too-close control + // over it. We must make it in a subprocess, and then kill the + // subprocess when it has served our needs. + + try { + JavaVM jvm = new JavaVM("RegistryRunner", "", Integer.toString(p)); + jvm.start(); + Reexport.subreg = jvm.getVM(); + + } catch (IOException e) { + // one of these is summarily dropped, can't remember which one + System.out.println ("Test setup failed - cannot run rmiregistry"); + TestLibrary.bomb("Test setup failed - cannot run test", e); + } + // Slop - wait for registry to come up. This is stupid. + try { + Thread.sleep (5000); + } catch (Exception whatever) { + } } private static Process subreg = null; - + public static void killRegistry() { - if (Reexport.subreg != null) { + if (Reexport.subreg != null) { - RegistryRunner.requestExit(); + RegistryRunner.requestExit(); - try { - Reexport.subreg.waitFor(); - } catch (InterruptedException ie) { - } - } - Reexport.subreg = null; - } + try { + Reexport.subreg.waitFor(); + } catch (InterruptedException ie) { + } + } + Reexport.subreg = null; + } } diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/BenchServer.java b/test/java/rmi/reliability/benchmark/bench/rmi/BenchServer.java index 167a3515684f7d7a06b8ef11d0529b6b07267866..a57d614e94aba24c28e2e74a78719e65747aa506 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/BenchServer.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/BenchServer.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,7 +33,7 @@ import java.rmi.RemoteException; /** * The RMI benchmark server is a simple compute-engine-like server which allows - * client benchmarks to create/export and unexport objects off of the server, + * client benchmarks to create/export and unexport objects off of the server, * or run arbitrary tasks. */ public interface BenchServer extends Remote { @@ -41,41 +41,40 @@ public interface BenchServer extends Remote { * Interface used for creating server-side remote objects. */ public interface RemoteObjectFactory extends Serializable { - Remote create() throws RemoteException; + Remote create() throws RemoteException; } - + /** * Interface used for server-side tasks. */ public interface Task extends Serializable { - Object execute() throws Exception; + Object execute() throws Exception; } /** - * Uses the given remote object factory to create a new remote object on + * Uses the given remote object factory to create a new remote object on * the server side. */ Remote create(RemoteObjectFactory factory) throws RemoteException; - + /** - * Unexports the specified remote object. Returns true if successful, + * Unexports the specified remote object. Returns true if successful, * false otherwise. */ boolean unexport(Remote obj, boolean force) throws RemoteException; - + /** * Execute given task. */ Object execute(Task task) throws Exception; - + /** * Invoke the garbage collector. */ void gc() throws RemoteException; - + /** * Terminate the server. */ void terminate(int delay) throws RemoteException; } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/BenchServerImpl.java b/test/java/rmi/reliability/benchmark/bench/rmi/BenchServerImpl.java index 099e13d35efc75a8b90333ab6fe587ceeebc2052..a0133f523d92f1729bded9a96d856a40a4a31836 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/BenchServerImpl.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/BenchServerImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -37,8 +37,8 @@ import java.util.HashMap; /** * Benchmark server implementation. */ -public class BenchServerImpl - extends UnicastRemoteObject implements BenchServer +public class BenchServerImpl + extends UnicastRemoteObject implements BenchServer { HashMap implTable = new HashMap(); @@ -47,52 +47,51 @@ public class BenchServerImpl */ public BenchServerImpl() throws RemoteException { } - + /** - * Uses the given remote object factory to create a new remote object on + * Uses the given remote object factory to create a new remote object on * the server side. */ - public Remote create(BenchServer.RemoteObjectFactory factory) - throws RemoteException + public Remote create(BenchServer.RemoteObjectFactory factory) + throws RemoteException { - Remote impl = factory.create(); - implTable.put(RemoteObject.toStub(impl), new WeakReference(impl)); - return impl; + Remote impl = factory.create(); + implTable.put(RemoteObject.toStub(impl), new WeakReference(impl)); + return impl; } - + /** - * Unexports the specified remote object. Returns true if successful, + * Unexports the specified remote object. Returns true if successful, * false otherwise. */ public boolean unexport(Remote obj, boolean force) throws RemoteException { - WeakReference iref = (WeakReference) implTable.get(obj); - if (iref == null) - return false; - Remote impl = (Remote) iref.get(); - if (impl == null) - return false; - return UnicastRemoteObject.unexportObject(impl, force); + WeakReference iref = (WeakReference) implTable.get(obj); + if (iref == null) + return false; + Remote impl = (Remote) iref.get(); + if (impl == null) + return false; + return UnicastRemoteObject.unexportObject(impl, force); } - + /** * Execute given task. */ public Object execute(BenchServer.Task task) throws Exception { - return task.execute(); + return task.execute(); } - + /** * Invoke the garbage collector. */ public void gc() throws RemoteException { - System.gc(); + System.gc(); } - + /** * Terminate the server. */ public void terminate(int delay) throws RemoteException { - System.exit(0); + System.exit(0); } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/BooleanArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/BooleanArrayCalls.java index cf444f6a57c68ecc29a23893addf0c4764cc22d7..a9005d980e03710113bd608ac6c8133221a4c808 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/BooleanArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/BooleanArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject; public class BooleanArrayCalls implements Benchmark { interface Server extends Remote { - public boolean[] call(boolean[] a) throws RemoteException; + public boolean[] call(boolean[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public boolean[] call(boolean[] a) throws RemoteException { - return a; - } + public ServerImpl() throws RemoteException { + } + + public boolean[] call(boolean[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue boolean array calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - boolean[] array = new boolean[size]; + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + boolean[] array = new boolean[size]; + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(array); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(array); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/BooleanCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/BooleanCalls.java index 20eef614505af46804b675fd9d546f68999c552e..52d2810b79eaed1d6ab5970502244fe7f4b9b2be 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/BooleanCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/BooleanCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject; public class BooleanCalls implements Benchmark { interface Server extends Remote { - public boolean call(boolean val) throws RemoteException; + public boolean call(boolean val) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public boolean call(boolean val) throws RemoteException { - return val; - } + public ServerImpl() throws RemoteException { + } + + public boolean call(boolean val) throws RemoteException { + return val; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue boolean calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int cycles = Integer.parseInt(args[0]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); + int cycles = Integer.parseInt(args[0]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + + long start = System.currentTimeMillis(); + for (int i = 0; i < cycles; i++) + stub.call(true); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < cycles; i++) - stub.call(true); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/ByteArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/ByteArrayCalls.java index 26d2dc342c1f8b448db7c652b95b639033b4ab63..d0401315c484f10bcd9bdbb5b398601a2032f770 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/ByteArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/ByteArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject; public class ByteArrayCalls implements Benchmark { interface Server extends Remote { - public byte[] call(byte[] a) throws RemoteException; + public byte[] call(byte[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public byte[] call(byte[] a) throws RemoteException { - return a; - } + public ServerImpl() throws RemoteException { + } + + public byte[] call(byte[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue byte array calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - byte[] array = new byte[size]; + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + byte[] array = new byte[size]; + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(array); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(array); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/ByteCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/ByteCalls.java index e8ef1186792be5b9a37c2b7cb3a819b530ab5192..8368c2ea0eecbbc06144deb20c04a13e21883643 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/ByteCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/ByteCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject; public class ByteCalls implements Benchmark { interface Server extends Remote { - public byte call(byte val) throws RemoteException; + public byte call(byte val) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public byte call(byte val) throws RemoteException { - return val; - } + public ServerImpl() throws RemoteException { + } + + public byte call(byte val) throws RemoteException { + return val; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue byte calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int cycles = Integer.parseInt(args[0]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); + int cycles = Integer.parseInt(args[0]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + + long start = System.currentTimeMillis(); + for (int i = 0; i < cycles; i++) + stub.call((byte) 0); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < cycles; i++) - stub.call((byte) 0); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/CharArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/CharArrayCalls.java index 15c3e3b897ef0256bc96ae75c53f549546e3849d..6590307043619a10816f394a8a6dace60f688f05 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/CharArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/CharArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject; public class CharArrayCalls implements Benchmark { interface Server extends Remote { - public char[] call(char[] a) throws RemoteException; + public char[] call(char[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public char[] call(char[] a) throws RemoteException { - return a; - } + public ServerImpl() throws RemoteException { + } + + public char[] call(char[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue char array calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - char[] array = new char[size]; + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + char[] array = new char[size]; + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(array); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(array); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/CharCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/CharCalls.java index eaea4164d85d7ab83ca5be5b0bb04bf31ca91731..eeeb836be4a19b3b840e609004b11e3abfc31d27 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/CharCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/CharCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject; public class CharCalls implements Benchmark { interface Server extends Remote { - public char call(char val) throws RemoteException; + public char call(char val) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public char call(char val) throws RemoteException { - return val; - } + public ServerImpl() throws RemoteException { + } + + public char call(char val) throws RemoteException { + return val; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue char calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int cycles = Integer.parseInt(args[0]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); + int cycles = Integer.parseInt(args[0]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + + long start = System.currentTimeMillis(); + for (int i = 0; i < cycles; i++) + stub.call('0'); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < cycles; i++) - stub.call('0'); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/ClassLoading.java b/test/java/rmi/reliability/benchmark/bench/rmi/ClassLoading.java index 303fe00502dea22d5d73ab33e482348ef900fcbc..e6451c36ef3836ce4d50dfad7ca7bd2fa0fbd263 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/ClassLoading.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/ClassLoading.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -45,16 +45,15 @@ public class ClassLoading implements Benchmark { * Arguments: <# reps> */ public long run(String[] args) throws Exception { - int reps = Integer.parseInt(args[0]); - CodeSource csrc = getClass().getProtectionDomain().getCodeSource(); - String url = "jar:" + csrc.getLocation().toString() + ALTROOT; - - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - RMIClassLoader.loadClass(url, CLASSNAME); - long time = System.currentTimeMillis() - start; - - return time; + int reps = Integer.parseInt(args[0]); + CodeSource csrc = getClass().getProtectionDomain().getCodeSource(); + String url = "jar:" + csrc.getLocation().toString() + ALTROOT; + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + RMIClassLoader.loadClass(url, CLASSNAME); + long time = System.currentTimeMillis() - start; + + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/DoubleArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/DoubleArrayCalls.java index 6aef159385826dd5640fddec677e8952f7e9293d..44f12010e943a5ef29656ab7fdb8915114169635 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/DoubleArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/DoubleArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject; public class DoubleArrayCalls implements Benchmark { interface Server extends Remote { - public double[] call(double[] a) throws RemoteException; + public double[] call(double[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public double[] call(double[] a) throws RemoteException { - return a; - } + public ServerImpl() throws RemoteException { + } + + public double[] call(double[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue double array calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - double[] array = new double[size]; + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + double[] array = new double[size]; + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(array); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(array); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/DoubleCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/DoubleCalls.java index 4bde6166ae4f8aed88d67c07eba517e2278bc2a3..c847391f6665a891717ed6f7ae226d7d38fd3192 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/DoubleCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/DoubleCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject; public class DoubleCalls implements Benchmark { interface Server extends Remote { - public double call(double val) throws RemoteException; + public double call(double val) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public double call(double val) throws RemoteException { - return val; - } + public ServerImpl() throws RemoteException { + } + + public double call(double val) throws RemoteException { + return val; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue double calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int cycles = Integer.parseInt(args[0]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); + int cycles = Integer.parseInt(args[0]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + + long start = System.currentTimeMillis(); + for (int i = 0; i < cycles; i++) + stub.call(0.0); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < cycles; i++) - stub.call(0.0); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/ExceptionCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/ExceptionCalls.java index 7664fe647bcd7b9c4b364296114d43c39de4ee32..f7f521ae357529097573a99db3e9c55fd4215600 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/ExceptionCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/ExceptionCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -41,43 +41,42 @@ public class ExceptionCalls implements Benchmark { } interface Server extends Remote { - public void call() throws RemoteException, FooException; + public void call() throws RemoteException, FooException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public void call() throws RemoteException, FooException { - throw new FooException(); - } + public ServerImpl() throws RemoteException { + } + + public void call() throws RemoteException, FooException { + throw new FooException(); + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue calls which throw exceptions. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int reps = Integer.parseInt(args[0]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); + int reps = Integer.parseInt(args[0]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) { + try { + stub.call(); + } catch (FooException e) {} + } + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) { - try { - stub.call(); - } catch (FooException e) {} - } - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/ExportObjs.java b/test/java/rmi/reliability/benchmark/bench/rmi/ExportObjs.java index a3e8c8b03a53a60e086f3d0fdcf10c090fe966dc..72071177abf6f9a70bd60c64fe3ef689270b2b4f 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/ExportObjs.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/ExportObjs.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000-2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.rmi.server.UnicastRemoteObject; * Benchmark for testing speed of UnicastRemoteObject.exportObject(). */ public class ExportObjs implements Benchmark { - + static class RemoteObj implements Remote { } @@ -44,19 +44,18 @@ public class ExportObjs implements Benchmark { * Arguments: <# objects> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - Remote[] objs = new Remote[size]; - for (int i = 0; i < size; i++) - objs[i] = new RemoteObj(); - - long start = System.currentTimeMillis(); - for (int i = 0; i < size; i++) - UnicastRemoteObject.exportObject(objs[i],0); - long time = System.currentTimeMillis() - start; - - for (int i = 0; i < size; i++) - UnicastRemoteObject.unexportObject(objs[i], true); - return time; + int size = Integer.parseInt(args[0]); + Remote[] objs = new Remote[size]; + for (int i = 0; i < size; i++) + objs[i] = new RemoteObj(); + + long start = System.currentTimeMillis(); + for (int i = 0; i < size; i++) + UnicastRemoteObject.exportObject(objs[i],0); + long time = System.currentTimeMillis() - start; + + for (int i = 0; i < size; i++) + UnicastRemoteObject.unexportObject(objs[i], true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/FloatArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/FloatArrayCalls.java index 5905b11e9d4c7ab4e87f035abbdc004edeaadbc9..d044f06ebbe51c3aa29bbe7abaab87867b11d8a2 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/FloatArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/FloatArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject; public class FloatArrayCalls implements Benchmark { interface Server extends Remote { - public float[] call(float[] a) throws RemoteException; + public float[] call(float[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public float[] call(float[] a) throws RemoteException { - return a; - } + public ServerImpl() throws RemoteException { + } + + public float[] call(float[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue float array calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - float[] array = new float[size]; + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + float[] array = new float[size]; + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(array); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(array); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/FloatCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/FloatCalls.java index 5ff7bcebff7ecfc026b98e261bf34934e1058fdc..564a81c1c6b30eb5c7e834361cd7ed7fe625fd14 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/FloatCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/FloatCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject; public class FloatCalls implements Benchmark { interface Server extends Remote { - public float call(float val) throws RemoteException; + public float call(float val) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public float call(float val) throws RemoteException { - return val; - } + public ServerImpl() throws RemoteException { + } + + public float call(float val) throws RemoteException { + return val; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue float calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int cycles = Integer.parseInt(args[0]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); + int cycles = Integer.parseInt(args[0]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + + long start = System.currentTimeMillis(); + for (int i = 0; i < cycles; i++) + stub.call((float) 0.0); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < cycles; i++) - stub.call((float) 0.0); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/IntArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/IntArrayCalls.java index ebd2668e09527313d413b2816a70231094ab46f3..f8897639ea9e069d9dfd15ce6b9c157c9b0b69d9 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/IntArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/IntArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject; public class IntArrayCalls implements Benchmark { interface Server extends Remote { - public int[] call(int[] a) throws RemoteException; + public int[] call(int[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public int[] call(int[] a) throws RemoteException { - return a; - } + public ServerImpl() throws RemoteException { + } + + public int[] call(int[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue int array calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - int[] array = new int[size]; + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + int[] array = new int[size]; + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(array); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(array); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/IntCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/IntCalls.java index fb85488083f278754611dcca4d953f561682e979..e1777c3ac24dc7ae8483ecc088554eabf235018b 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/IntCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/IntCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject; public class IntCalls implements Benchmark { interface Server extends Remote { - public int call(int val) throws RemoteException; + public int call(int val) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public int call(int val) throws RemoteException { - return val; - } + public ServerImpl() throws RemoteException { + } + + public int call(int val) throws RemoteException { + return val; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue int calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int cycles = Integer.parseInt(args[0]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); + int cycles = Integer.parseInt(args[0]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + + long start = System.currentTimeMillis(); + for (int i = 0; i < cycles; i++) + stub.call(0); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < cycles; i++) - stub.call(0); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/LongArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/LongArrayCalls.java index 1f86e5b4a1e0f4002004f2b4dec152b1fc74f41c..15cbeb799f550ba381b409a0370a06df2e1e9e85 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/LongArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/LongArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject; public class LongArrayCalls implements Benchmark { interface Server extends Remote { - public long[] call(long[] a) throws RemoteException; + public long[] call(long[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public long[] call(long[] a) throws RemoteException { - return a; - } + public ServerImpl() throws RemoteException { + } + + public long[] call(long[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue long array calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - long[] array = new long[size]; + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + long[] array = new long[size]; + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(array); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(array); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/LongCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/LongCalls.java index 864349c9f68a6e4bdac0fb88b4059855ec3657f1..109ec952609fd82a725ad41769106d7c980b07c0 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/LongCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/LongCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject; public class LongCalls implements Benchmark { interface Server extends Remote { - public long call(long val) throws RemoteException; + public long call(long val) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public long call(long val) throws RemoteException { - return val; - } + public ServerImpl() throws RemoteException { + } + + public long call(long val) throws RemoteException { + return val; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue long calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int cycles = Integer.parseInt(args[0]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); + int cycles = Integer.parseInt(args[0]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + + long start = System.currentTimeMillis(); + for (int i = 0; i < cycles; i++) + stub.call(0L); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < cycles; i++) - stub.call(0L); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/Main.java b/test/java/rmi/reliability/benchmark/bench/rmi/Main.java index de81a09f2b5d6070265d185e95a0efa9b303ba36..3e06a8887d379111079b4b7c4d9776c0bc5ffef0 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/Main.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/Main.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -47,35 +47,35 @@ import java.rmi.server.RemoteObject; import java.util.Timer; import java.util.TimerTask; -/* +/* * RMI/Serialization benchmark tests. */ public class Main { - + /** * RMI-specific benchmark harness. */ static class RMIHarness extends Harness { - /** - * Construct new RMI benchmark harness. - */ - RMIHarness(InputStream in) throws IOException, ConfigFormatException { - super(in); - } - - /** - * Cleanup both client and server side in between each benchmark. - */ - protected void cleanup() { - System.gc(); - if (Main.runmode == CLIENT) { - try { - Main.server.gc(); - } catch (Exception e) { - System.err.println("Warning: server gc failed: " + e); - } - } - } + /** + * Construct new RMI benchmark harness. + */ + RMIHarness(InputStream in) throws IOException, ConfigFormatException { + super(in); + } + + /** + * Cleanup both client and server side in between each benchmark. + */ + protected void cleanup() { + System.gc(); + if (Main.runmode == CLIENT) { + try { + Main.server.gc(); + } catch (Exception e) { + System.err.println("Warning: server gc failed: " + e); + } + } + } } static final String CONFFILE = "/bench/rmi/config"; @@ -85,7 +85,7 @@ public class Main { static final int SAMEVM = 0; static final int CLIENT = 1; static final int SERVER = 2; - + static final int TEXT = 0; static final int HTML = 1; static final int XML = 2; @@ -111,7 +111,7 @@ public class Main { * Returns reference to benchmark server. */ public static BenchServer getBenchServer() { - return server; + return server; } /** @@ -127,252 +127,252 @@ public class Main { p.println(" -t repeat benchmarks for specified number of hours"); p.println(" -o specify output file"); p.println(" -c specify (non-default) " + - "configuration file"); + "configuration file"); p.println(" -html format output as html " + - "(default is text)"); + "(default is text)"); p.println(" -xml format output as xml"); - p.println(" -client run benchmark client using server " + - "on specified host/port"); - p.println(" -server run benchmark server on given port"); + p.println(" -client run benchmark client using server " + + "on specified host/port"); + p.println(" -server run benchmark server on given port"); } - + /** * Print error message and exit. */ static void die(String mesg) { - System.err.println(mesg); - System.exit(1); + System.err.println(mesg); + System.exit(1); } /** * Stop server and exit. */ public static void exit() { - switch (runmode) { - case CLIENT: - if (server != null) { - try { - server.terminate(0); - } catch (RemoteException re) { - // ignore - } - } - default: - System.exit(0); - } + switch (runmode) { + case CLIENT: + if (server != null) { + try { + server.terminate(0); + } catch (RemoteException re) { + // ignore + } + } + default: + System.exit(0); + } } /** * Benchmark mainline. */ public static void main(String[] args) { - setupSecurity(); - parseArgs(args); - setupStreams(); - if (list) { - listConfig(); - } else { - setupServer(); - if (runmode != SERVER) { - setupHarness(); - setupReporter(); - if (exitOnTimer) { - setupTimer(testDurationSeconds); - while (true) { - runBenchmarks(); - if (exitRequested) { - exit(); - } - } - } else { - runBenchmarks(); - exit(); - } - } - } + setupSecurity(); + parseArgs(args); + setupStreams(); + if (list) { + listConfig(); + } else { + setupServer(); + if (runmode != SERVER) { + setupHarness(); + setupReporter(); + if (exitOnTimer) { + setupTimer(testDurationSeconds); + while (true) { + runBenchmarks(); + if (exitRequested) { + exit(); + } + } + } else { + runBenchmarks(); + exit(); + } + } + } } - + /** * Parse command-line arguments. */ static void parseArgs(String[] args) { - for (int i = 0; i < args.length; i++) { - if (args[i].equals("-h")) { - usage(); - System.exit(0); - } else if (args[i].equals("-v")) { - verbose = true; - } else if (args[i].equals("-l")) { - list = true; - } else if (args[i].equals("-t")) { - if (++i >= args.length) - die("Error: no timeout value specified"); - try { - exitOnTimer = true; - testDurationSeconds = Integer.parseInt(args[i]) * 3600; - } catch (Exception e) { - die("Error: unable to determine timeout value"); - } - } else if (args[i].equals("-o")) { - if (++i >= args.length) - die("Error: no output file specified"); - try { - repstr = new FileOutputStream(args[i]); - } catch (IOException e) { - die("Error: unable to open \"" + args[i] + "\""); - } - } else if (args[i].equals("-c")) { - if (++i >= args.length) - die("Error: no config file specified"); - try { - confstr = new FileInputStream(args[i]); - } catch (IOException e) { - die("Error: unable to open \"" + args[i] + "\""); - } - } else if (args[i].equals("-html")) { - if (format != TEXT) - die("Error: conflicting formats"); - format = HTML; - } else if (args[i].equals("-xml")) { - if (format != TEXT) - die("Error: conflicting formats"); - format = XML; - } else if (args[i].equals("-client")) { - if (runmode == CLIENT) - die("Error: multiple -client options"); - if (runmode == SERVER) - die("Error: -client and -server options conflict"); - if (++i >= args.length) - die("Error: -client missing host/port"); - try { - int sepi = args[i].indexOf(':'); - host = args[i].substring(0, sepi); - port = Integer.parseInt(args[i].substring(sepi + 1)); - } catch (Exception e) { - die("Error: illegal host/port specified for -client"); - } - runmode = CLIENT; - } else if (args[i].equals("-server")) { - if (runmode == CLIENT) - die("Error: -client and -server options conflict"); - if (runmode == SERVER) - die("Error: multiple -server options"); - if (++i >= args.length) - die("Error: -server missing port"); - try { - port = Integer.parseInt(args[i]); - } catch (Exception e) { - die("Error: illegal port specified for -server"); - } - runmode = SERVER; - } else { - System.err.println("Illegal option: \"" + args[i] + "\""); - usage(); - System.exit(1); - } - } + for (int i = 0; i < args.length; i++) { + if (args[i].equals("-h")) { + usage(); + System.exit(0); + } else if (args[i].equals("-v")) { + verbose = true; + } else if (args[i].equals("-l")) { + list = true; + } else if (args[i].equals("-t")) { + if (++i >= args.length) + die("Error: no timeout value specified"); + try { + exitOnTimer = true; + testDurationSeconds = Integer.parseInt(args[i]) * 3600; + } catch (Exception e) { + die("Error: unable to determine timeout value"); + } + } else if (args[i].equals("-o")) { + if (++i >= args.length) + die("Error: no output file specified"); + try { + repstr = new FileOutputStream(args[i]); + } catch (IOException e) { + die("Error: unable to open \"" + args[i] + "\""); + } + } else if (args[i].equals("-c")) { + if (++i >= args.length) + die("Error: no config file specified"); + try { + confstr = new FileInputStream(args[i]); + } catch (IOException e) { + die("Error: unable to open \"" + args[i] + "\""); + } + } else if (args[i].equals("-html")) { + if (format != TEXT) + die("Error: conflicting formats"); + format = HTML; + } else if (args[i].equals("-xml")) { + if (format != TEXT) + die("Error: conflicting formats"); + format = XML; + } else if (args[i].equals("-client")) { + if (runmode == CLIENT) + die("Error: multiple -client options"); + if (runmode == SERVER) + die("Error: -client and -server options conflict"); + if (++i >= args.length) + die("Error: -client missing host/port"); + try { + int sepi = args[i].indexOf(':'); + host = args[i].substring(0, sepi); + port = Integer.parseInt(args[i].substring(sepi + 1)); + } catch (Exception e) { + die("Error: illegal host/port specified for -client"); + } + runmode = CLIENT; + } else if (args[i].equals("-server")) { + if (runmode == CLIENT) + die("Error: -client and -server options conflict"); + if (runmode == SERVER) + die("Error: multiple -server options"); + if (++i >= args.length) + die("Error: -server missing port"); + try { + port = Integer.parseInt(args[i]); + } catch (Exception e) { + die("Error: illegal port specified for -server"); + } + runmode = SERVER; + } else { + System.err.println("Illegal option: \"" + args[i] + "\""); + usage(); + System.exit(1); + } + } } - + /** * Set up security manager and policy, if not set already. */ static void setupSecurity() { - if (System.getSecurityManager() != null) - return; - - /* As of 1.4, it is too late to set the security policy - * file at this point so these line have been commented out. - */ - //System.setProperty("java.security.policy", - // Main.class.getResource("/bench/rmi/policy.all").toString()); - System.setSecurityManager(new RMISecurityManager()); + if (System.getSecurityManager() != null) + return; + + /* As of 1.4, it is too late to set the security policy + * file at this point so these line have been commented out. + */ + //System.setProperty("java.security.policy", + // Main.class.getResource("/bench/rmi/policy.all").toString()); + System.setSecurityManager(new RMISecurityManager()); } /** * Set up configuration file and report streams, if not set already. */ static void setupStreams() { - if (repstr == null) - repstr = System.out; - if (confstr == null) - confstr = (new Main()).getClass().getResourceAsStream(CONFFILE); - if (confstr == null) - die("Error: unable to find default config file"); + if (repstr == null) + repstr = System.out; + if (confstr == null) + confstr = (new Main()).getClass().getResourceAsStream(CONFFILE); + if (confstr == null) + die("Error: unable to find default config file"); } - + /** * Print contents of configuration file to selected output stream. */ static void listConfig() { - try { - byte[] buf = new byte[256]; - int len; - while ((len = confstr.read(buf)) != -1) - repstr.write(buf, 0, len); - } catch (IOException e) { - die("Error: failed to list config file"); - } + try { + byte[] buf = new byte[256]; + int len; + while ((len = confstr.read(buf)) != -1) + repstr.write(buf, 0, len); + } catch (IOException e) { + die("Error: failed to list config file"); + } } - + /** * Setup benchmark server. */ static void setupServer() { - switch (runmode) { - case SAMEVM: - try { - serverImpl = new BenchServerImpl(); - server = (BenchServer) RemoteObject.toStub(serverImpl); - } catch (Exception e) { - die("Error: failed to create local server: " + e); - } - if (verbose) - System.out.println("Benchmark server created locally"); - break; - - case CLIENT: - try { - Registry reg = LocateRegistry.getRegistry(host, port); - server = (BenchServer) reg.lookup(REGNAME); - } catch (Exception e) { - die("Error: failed to connect to server: " + e); - } - if (server == null) { - die("Error: server not found"); - } - if (verbose) { - System.out.println("Connected to benchmark server on " + - host + ":" + port); - } - break; - - case SERVER: - try { - Registry reg = LocateRegistry.createRegistry(port); - serverImpl = new BenchServerImpl(); - reg.bind(REGNAME, serverImpl); - } catch (Exception e) { - die("Error: failed to initialize server: " + e); - } - if (verbose) { - System.out.println("Benchmark server started on port " + - port); - } - break; - - default: - throw new InternalError("illegal runmode"); - } + switch (runmode) { + case SAMEVM: + try { + serverImpl = new BenchServerImpl(); + server = (BenchServer) RemoteObject.toStub(serverImpl); + } catch (Exception e) { + die("Error: failed to create local server: " + e); + } + if (verbose) + System.out.println("Benchmark server created locally"); + break; + + case CLIENT: + try { + Registry reg = LocateRegistry.getRegistry(host, port); + server = (BenchServer) reg.lookup(REGNAME); + } catch (Exception e) { + die("Error: failed to connect to server: " + e); + } + if (server == null) { + die("Error: server not found"); + } + if (verbose) { + System.out.println("Connected to benchmark server on " + + host + ":" + port); + } + break; + + case SERVER: + try { + Registry reg = LocateRegistry.createRegistry(port); + serverImpl = new BenchServerImpl(); + reg.bind(REGNAME, serverImpl); + } catch (Exception e) { + die("Error: failed to initialize server: " + e); + } + if (verbose) { + System.out.println("Benchmark server started on port " + + port); + } + break; + + default: + throw new InternalError("illegal runmode"); + } } /** * Set up the timer to end the test. * - * @param delay the amount of delay, in seconds, before requesting + * @param delay the amount of delay, in seconds, before requesting * the process exit */ static void setupTimer(int delay) { - timer = new Timer(true); + timer = new Timer(true); timer.schedule( new TimerTask() { public void run() { @@ -391,12 +391,12 @@ public class Main { } catch (ConfigFormatException e) { String errmsg = e.getMessage(); if (errmsg != null) { - die("Error parsing config file: " + errmsg); - } else { + die("Error parsing config file: " + errmsg); + } else { die("Error: illegal config file syntax"); - } + } } catch (IOException e) { - die("Error: failed to read config file"); + die("Error: failed to read config file"); } } @@ -405,24 +405,24 @@ public class Main { */ static void setupReporter() { String title = "RMI Benchmark, v" + VERSION; - switch (format) { - case TEXT: - reporter = new TextReporter(repstr, title); - break; - - case HTML: - reporter = new HtmlReporter(repstr, title); - break; + switch (format) { + case TEXT: + reporter = new TextReporter(repstr, title); + break; - case XML: - reporter = new XmlReporter(repstr, title); - break; - - default: - die("Error: unrecognized format type"); - } + case HTML: + reporter = new HtmlReporter(repstr, title); + break; + + case XML: + reporter = new XmlReporter(repstr, title); + break; + + default: + die("Error: unrecognized format type"); + } } - + /** * Run benchmarks. */ @@ -430,4 +430,3 @@ public class Main { harness.runBenchmarks(reporter, verbose); } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/NullCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/NullCalls.java index 7cd6a1c4313703631abbd140a0c812141ecafc33..0616f2e97f34e053445206849ba581f0849024c4 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/NullCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/NullCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,39 +38,38 @@ import java.rmi.server.UnicastRemoteObject; public class NullCalls implements Benchmark { interface Server extends Remote { - public void call() throws RemoteException; + public void call() throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public void call() throws RemoteException { - } + public ServerImpl() throws RemoteException { + } + + public void call() throws RemoteException { + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue null calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int reps = Integer.parseInt(args[0]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); + int reps = Integer.parseInt(args[0]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/ObjArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/ObjArrayCalls.java index a3835daad25501e22d5599d57339bbf8a0309cb5..3fa66cdbc1cca94fec6ae2c2e9c7de180d411a4d 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/ObjArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/ObjArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -41,16 +41,16 @@ public class ObjArrayCalls implements Benchmark { static class Node implements Serializable { boolean z; - byte b; - char c; - short s; - int i; - float f; - long j; - double d; - String str = "bodega"; + byte b; + char c; + short s; + int i; + float f; + long j; + double d; + String str = "bodega"; Object parent, left, right; - + Node(Object parent, int depth) { this.parent = parent; if (depth > 0) { @@ -61,44 +61,43 @@ public class ObjArrayCalls implements Benchmark { } interface Server extends Remote { - public Node[] call(Node[] a) throws RemoteException; + public Node[] call(Node[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } + public ServerImpl() throws RemoteException { + } - public Node[] call(Node[] a) throws RemoteException { - return a; - } + public Node[] call(Node[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue calls using arrays of objects as parameters/return values. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - Node[] nodes = new Node[size]; - for (int i = 0; i < size; i++) - nodes[i] = new Node(null, 0); + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + Node[] nodes = new Node[size]; + for (int i = 0; i < size; i++) + nodes[i] = new Node(null, 0); - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(nodes); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(nodes); + long time = System.currentTimeMillis() - start; + + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/ObjTreeCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/ObjTreeCalls.java index bcf9fad7f2e517f5d0288ad819dfee760a52b048..02a9f066f80da672930b63f0727e1ff9dee44e39 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/ObjTreeCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/ObjTreeCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -41,16 +41,16 @@ public class ObjTreeCalls implements Benchmark { static class Node implements Serializable { boolean z; - byte b; - char c; - short s; - int i; - float f; - long j; - double d; - String str = "bodega"; + byte b; + char c; + short s; + int i; + float f; + long j; + double d; + String str = "bodega"; Object parent, left, right; - + Node(Object parent, int depth) { this.parent = parent; if (depth > 0) { @@ -61,42 +61,41 @@ public class ObjTreeCalls implements Benchmark { } interface Server extends Remote { - public Node call(Node val) throws RemoteException; + public Node call(Node val) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } + public ServerImpl() throws RemoteException { + } - public Node call(Node val) throws RemoteException { - return val; - } + public Node call(Node val) throws RemoteException { + return val; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue calls using trees of objects as parameters/return values. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int depth = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - Node node = new Node(null, depth); + int depth = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + Node node = new Node(null, depth); - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(node); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(node); + long time = System.currentTimeMillis() - start; + + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/ProxyArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/ProxyArrayCalls.java index 0ab713af6eafe7116cacf7b3a25ae33a24ca4db8..7242a4f31a88921fe4e45204fe3663fc88829e55 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/ProxyArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/ProxyArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -44,52 +44,52 @@ import java.rmi.server.UnicastRemoteObject; public class ProxyArrayCalls implements Benchmark { static class DummyHandler implements InvocationHandler, Serializable { - public Object invoke(Object proxy, Method method, Object[] args) - throws Throwable - { - return null; - } + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable + { + return null; + } } - + public static interface DummyInterface { - public void foo(); + public void foo(); } interface Server extends Remote { - public Proxy[] call(Proxy[] a) throws RemoteException; + public Proxy[] call(Proxy[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } + public ServerImpl() throws RemoteException { + } - public Proxy[] call(Proxy[] a) throws RemoteException { - return a; - } + public Proxy[] call(Proxy[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Generate proxy object array of the given size. */ Proxy[] genProxies(int size) throws Exception { - Class proxyClass = - Proxy.getProxyClass(DummyInterface.class.getClassLoader(), - new Class[] { DummyInterface.class }); - Constructor proxyCons = - proxyClass.getConstructor(new Class[] { InvocationHandler.class }); - Object[] consArgs = new Object[] { new DummyHandler() }; - Proxy[] proxies = new Proxy[size]; - - for (int i = 0; i < size; i++) - proxies[i] = (Proxy) proxyCons.newInstance(consArgs); - - return proxies; + Class proxyClass = + Proxy.getProxyClass(DummyInterface.class.getClassLoader(), + new Class[] { DummyInterface.class }); + Constructor proxyCons = + proxyClass.getConstructor(new Class[] { InvocationHandler.class }); + Object[] consArgs = new Object[] { new DummyHandler() }; + Proxy[] proxies = new Proxy[size]; + + for (int i = 0; i < size; i++) + proxies[i] = (Proxy) proxyCons.newInstance(consArgs); + + return proxies; } /** @@ -97,19 +97,18 @@ public class ProxyArrayCalls implements Benchmark { * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - Proxy[] proxies = genProxies(size); - - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(proxies); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + Proxy[] proxies = genProxies(size); + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(proxies); + long time = System.currentTimeMillis() - start; + + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/RemoteObjArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/RemoteObjArrayCalls.java index d8a6ec8905da066043bce79c8af4cdeb5ec79728..5bf6a3b929a6710de6aa89850cbca012de9da108 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/RemoteObjArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/RemoteObjArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,49 +39,48 @@ import java.rmi.server.UnicastRemoteObject; public class RemoteObjArrayCalls implements Benchmark { static class RemoteObj extends UnicastRemoteObject implements Remote { - RemoteObj() throws RemoteException { - } + RemoteObj() throws RemoteException { + } } interface Server extends Remote { - public Remote[] call(Remote[] a) throws RemoteException; + public Remote[] call(Remote[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } + public ServerImpl() throws RemoteException { + } - public Remote[] call(Remote[] a) throws RemoteException { - return a; - } + public Remote[] call(Remote[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue calls using arrays of remote objects as parameters/return values. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - Remote[] objs = new Remote[size]; - for (int i = 0; i < size; i++) - objs[i] = new RemoteObj(); + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + Remote[] objs = new Remote[size]; + for (int i = 0; i < size; i++) + objs[i] = new RemoteObj(); - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(objs); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(objs); + long time = System.currentTimeMillis() - start; + + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/ShortArrayCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/ShortArrayCalls.java index 76432712caa557aab16a8fa384584365adef5019..91589b8d401c75c02519a8683bacff4d5b9f7b8e 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/ShortArrayCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/ShortArrayCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -20,7 +20,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ - + /* * */ @@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject; public class ShortArrayCalls implements Benchmark { interface Server extends Remote { - public short[] call(short[] a) throws RemoteException; + public short[] call(short[] a) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public short[] call(short[] a) throws RemoteException { - return a; - } + public ServerImpl() throws RemoteException { + } + + public short[] call(short[] a) throws RemoteException { + return a; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue short array calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - short[] array = new short[size]; + int size = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + short[] array = new short[size]; + + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(array); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(array); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/ShortCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/ShortCalls.java index 867ebef8530a22f588a3fa4f5f435096f23873fa..2ba8e0f3accae2d24f3d7579cb9a855056a68a22 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/ShortCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/ShortCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject; public class ShortCalls implements Benchmark { interface Server extends Remote { - public short call(short val) throws RemoteException; + public short call(short val) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } - - public short call(short val) throws RemoteException { - return val; - } + public ServerImpl() throws RemoteException { + } + + public short call(short val) throws RemoteException { + return val; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue short calls. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int cycles = Integer.parseInt(args[0]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); + int cycles = Integer.parseInt(args[0]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + + long start = System.currentTimeMillis(); + for (int i = 0; i < cycles; i++) + stub.call((short) 0); + long time = System.currentTimeMillis() - start; - long start = System.currentTimeMillis(); - for (int i = 0; i < cycles; i++) - stub.call((short) 0); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/rmi/SmallObjTreeCalls.java b/test/java/rmi/reliability/benchmark/bench/rmi/SmallObjTreeCalls.java index 29829d6ec91f5de6c4e6fac008974e934f8aab74..a43defb52344e74c6ab1f6cf33462bfb1ac09bc1 100644 --- a/test/java/rmi/reliability/benchmark/bench/rmi/SmallObjTreeCalls.java +++ b/test/java/rmi/reliability/benchmark/bench/rmi/SmallObjTreeCalls.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -41,7 +41,7 @@ public class SmallObjTreeCalls implements Benchmark { static class Node implements Serializable { Object parent, left, right; - + Node(Object parent, int depth) { this.parent = parent; if (depth > 0) { @@ -52,42 +52,41 @@ public class SmallObjTreeCalls implements Benchmark { } interface Server extends Remote { - public Node call(Node val) throws RemoteException; + public Node call(Node val) throws RemoteException; } static class ServerImpl extends UnicastRemoteObject implements Server { - public ServerImpl() throws RemoteException { - } + public ServerImpl() throws RemoteException { + } - public Node call(Node val) throws RemoteException { - return val; - } + public Node call(Node val) throws RemoteException { + return val; + } } - + static class ServerFactory implements BenchServer.RemoteObjectFactory { - public Remote create() throws RemoteException { - return new ServerImpl(); - } + public Remote create() throws RemoteException { + return new ServerImpl(); + } } - + /** * Issue calls using trees of small objects as parameters/return values. * Arguments: <# calls> */ public long run(String[] args) throws Exception { - int depth = Integer.parseInt(args[0]); - int reps = Integer.parseInt(args[1]); - BenchServer bsrv = Main.getBenchServer(); - Server stub = (Server) bsrv.create(new ServerFactory()); - Node node = new Node(null, depth); + int depth = Integer.parseInt(args[0]); + int reps = Integer.parseInt(args[1]); + BenchServer bsrv = Main.getBenchServer(); + Server stub = (Server) bsrv.create(new ServerFactory()); + Node node = new Node(null, depth); - long start = System.currentTimeMillis(); - for (int i = 0; i < reps; i++) - stub.call(node); - long time = System.currentTimeMillis() - start; - - bsrv.unexport(stub, true); - return time; + long start = System.currentTimeMillis(); + for (int i = 0; i < reps; i++) + stub.call(node); + long time = System.currentTimeMillis() - start; + + bsrv.unexport(stub, true); + return time; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/BooleanArrays.java b/test/java/rmi/reliability/benchmark/bench/serial/BooleanArrays.java index d52fdcf2052dc5d34673b802389cf33bc387cebd..5e6ff7656aa6e6a5c0f9b05b749b2f1eb271fc0a 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/BooleanArrays.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/BooleanArrays.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of boolean array reads/writes. */ public class BooleanArrays implements Benchmark { - + /** * Write and read boolean arrays to/from a stream. The benchmark is run in * batches, with each batch consisting of a fixed number of read/write @@ -44,44 +44,42 @@ public class BooleanArrays implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - boolean[][] arrays = new boolean[ncycles][size]; - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + boolean[][] arrays = new boolean[ncycles][size]; + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - doReps(oout, oin, sbuf, arrays, 1); // warmup + doReps(oout, oin, sbuf, arrays, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, arrays, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, arrays, nbatches); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, boolean[][] arrays, int nbatches) - throws Exception + StreamBuffer sbuf, boolean[][] arrays, int nbatches) + throws Exception { - int ncycles = arrays.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(arrays[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = arrays.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(arrays[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Booleans.java b/test/java/rmi/reliability/benchmark/bench/serial/Booleans.java index 690d4ac190d8c99609028c5527d0fb28cf6c55f7..abf8ef8c5e8669e46b462caae1bd0f07499437ed 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Booleans.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Booleans.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of boolean reads/writes. */ public class Booleans implements Benchmark { - + /** * Write and read boolean values to/from a stream. The benchmark is run in * batches: each "batch" consists of a fixed number of read/write cycles, @@ -44,40 +44,38 @@ public class Booleans implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int nbatches = Integer.parseInt(args[0]); - int ncycles = Integer.parseInt(args[1]); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, 1, ncycles); // warmup + int nbatches = Integer.parseInt(args[0]); + int ncycles = Integer.parseInt(args[1]); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); + + doReps(oout, oin, sbuf, 1, ncycles); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, nbatches, ncycles); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, nbatches, ncycles); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, int nbatches, int ncycles) - throws Exception + StreamBuffer sbuf, int nbatches, int ncycles) + throws Exception { - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeBoolean(false); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readBoolean(); - } - } + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeBoolean(false); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readBoolean(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/ByteArrays.java b/test/java/rmi/reliability/benchmark/bench/serial/ByteArrays.java index 5c21de5b14afe07aa4d6c4c978ef81521895a7de..b300e8af79bfc425db819797dc0abbabf1a4899e 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/ByteArrays.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/ByteArrays.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of byte array reads/writes. */ public class ByteArrays implements Benchmark { - + /** * Write and read byte arrays to/from a stream. The benchmark is run in * batches, with each batch consisting of a fixed number of read/write @@ -44,44 +44,42 @@ public class ByteArrays implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - byte[][] arrays = new byte[ncycles][size]; - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + byte[][] arrays = new byte[ncycles][size]; + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - doReps(oout, oin, sbuf, arrays, 1); // warmup + doReps(oout, oin, sbuf, arrays, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, arrays, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, arrays, nbatches); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, byte[][] arrays, int nbatches) - throws Exception + StreamBuffer sbuf, byte[][] arrays, int nbatches) + throws Exception { - int ncycles = arrays.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(arrays[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = arrays.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(arrays[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Bytes.java b/test/java/rmi/reliability/benchmark/bench/serial/Bytes.java index 585f6b182083711fa7fc8d353d1f0f869f88d99e..31d6465c30c0a840e7b36949574d53db81b9c2e4 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Bytes.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Bytes.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of byte reads/writes. */ public class Bytes implements Benchmark { - + /** * Write and read byte values to/from a stream. The benchmark is run in * batches: each "batch" consists of a fixed number of read/write cycles, @@ -44,39 +44,38 @@ public class Bytes implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int nbatches = Integer.parseInt(args[0]); - int ncycles = Integer.parseInt(args[1]); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, 1, ncycles); // warmup + int nbatches = Integer.parseInt(args[0]); + int ncycles = Integer.parseInt(args[1]); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, nbatches, ncycles); + doReps(oout, oin, sbuf, 1, ncycles); // warmup + + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, nbatches, ncycles); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, int nbatches, int ncycles) - throws Exception + StreamBuffer sbuf, int nbatches, int ncycles) + throws Exception { - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeByte(0); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readByte(); - } - } + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeByte(0); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readByte(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/CharArrays.java b/test/java/rmi/reliability/benchmark/bench/serial/CharArrays.java index e1cec28e56646acf6c11aefd6e25be73b24610f4..a9b1353b06fdca8baf0a08c513eb6253dfd34f2e 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/CharArrays.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/CharArrays.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of char array reads/writes. */ public class CharArrays implements Benchmark { - + /** * Write and read char arrays to/from a stream. The benchmark is run in * batches, with each batch consisting of a fixed number of read/write @@ -44,44 +44,42 @@ public class CharArrays implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - char[][] arrays = new char[ncycles][size]; - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + char[][] arrays = new char[ncycles][size]; + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - doReps(oout, oin, sbuf, arrays, 1); // warmup + doReps(oout, oin, sbuf, arrays, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, arrays, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, arrays, nbatches); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, char[][] arrays, int nbatches) - throws Exception + StreamBuffer sbuf, char[][] arrays, int nbatches) + throws Exception { - int ncycles = arrays.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(arrays[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = arrays.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(arrays[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Chars.java b/test/java/rmi/reliability/benchmark/bench/serial/Chars.java index 835bb6dc0100f7b816ea2d082e53bcf144a38aec..1ee2c88ed6ed757ad706867d543ca1fbc20f882c 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Chars.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Chars.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of char reads/writes. */ public class Chars implements Benchmark { - + /** * Write and read char values to/from a stream. The benchmark is run in * batches: each "batch" consists of a fixed number of read/write cycles, @@ -44,39 +44,38 @@ public class Chars implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int nbatches = Integer.parseInt(args[0]); - int ncycles = Integer.parseInt(args[1]); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, 1, ncycles); // warmup + int nbatches = Integer.parseInt(args[0]); + int ncycles = Integer.parseInt(args[1]); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, nbatches, ncycles); + doReps(oout, oin, sbuf, 1, ncycles); // warmup + + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, nbatches, ncycles); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, int nbatches, int ncycles) - throws Exception + StreamBuffer sbuf, int nbatches, int ncycles) + throws Exception { - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeChar('0'); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readChar(); - } - } + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeChar('0'); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readChar(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/ClassDesc.java b/test/java/rmi/reliability/benchmark/bench/serial/ClassDesc.java index 47895b560c6c511fc0195f5b694ca80eeb55f1c9..a7ad155ceb0ed4bac8e4c84d8ac58bf12b16304c 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/ClassDesc.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/ClassDesc.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -89,41 +89,40 @@ public class ClassDesc implements Benchmark { static class Dummy48 extends Dummy47 { Dummy48 i48; } static class Dummy49 extends Dummy48 { Dummy49 i49; } static class Dummy50 extends Dummy49 { Dummy50 i50; } - + /** * Write and read class descriptors to/from a stream. * Arguments: <# cycles> */ public long run(String[] args) throws Exception { - int ncycles = Integer.parseInt(args[0]); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - ObjectStreamClass desc = ObjectStreamClass.lookup(Dummy50.class); - - doReps(oout, oin, sbuf, desc, 1); // warmup + int ncycles = Integer.parseInt(args[0]); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); + ObjectStreamClass desc = ObjectStreamClass.lookup(Dummy50.class); + + doReps(oout, oin, sbuf, desc, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, desc, ncycles); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, desc, ncycles); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of cycles. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, ObjectStreamClass desc, int ncycles) - throws Exception + StreamBuffer sbuf, ObjectStreamClass desc, int ncycles) + throws Exception { - for (int i = 0; i < ncycles; i++) { - sbuf.reset(); - oout.reset(); - oout.writeObject(desc); - oout.flush(); - oin.readObject(); - } + for (int i = 0; i < ncycles; i++) { + sbuf.reset(); + oout.reset(); + oout.writeObject(desc); + oout.flush(); + oin.readObject(); + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Cons.java b/test/java/rmi/reliability/benchmark/bench/serial/Cons.java index 7d6bb08ceb1bb57ed323d55d18b704830ef0ea91..99d58c054724557c239971a083b19dfcd0d2b401 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Cons.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Cons.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -53,29 +53,28 @@ public class Cons implements Benchmark { public long run(String[] args) throws Exception { int reps = Integer.parseInt(args[0]); Dummy dummy = new Dummy(); - StreamBuffer sbuf = new StreamBuffer(); - - doReps(sbuf, dummy, 1); // warmup + StreamBuffer sbuf = new StreamBuffer(); + + doReps(sbuf, dummy, 1); // warmup - long start = System.currentTimeMillis(); - doReps(sbuf, dummy, reps); + long start = System.currentTimeMillis(); + doReps(sbuf, dummy, reps); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of cycles. */ void doReps(StreamBuffer sbuf, Dummy dummy, int reps) throws Exception { - OutputStream out = sbuf.getOutputStream(); - InputStream in = sbuf.getInputStream(); - for (int i = 0; i < reps; i++) { - sbuf.reset(); - ObjectOutputStream oout = new ObjectOutputStream(out); - oout.writeObject(dummy); - oout.flush(); - ObjectInputStream oin = new ObjectInputStream(in); - oin.readObject(); - } + OutputStream out = sbuf.getOutputStream(); + InputStream in = sbuf.getInputStream(); + for (int i = 0; i < reps; i++) { + sbuf.reset(); + ObjectOutputStream oout = new ObjectOutputStream(out); + oout.writeObject(dummy); + oout.flush(); + ObjectInputStream oin = new ObjectInputStream(in); + oin.readObject(); + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/CustomDefaultObjTrees.java b/test/java/rmi/reliability/benchmark/bench/serial/CustomDefaultObjTrees.java index 01d60c54a157ad665b68eb98fe92fdb351148320..14ddbee4f8256a2817fe2a90865989cce8ea58e7 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/CustomDefaultObjTrees.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/CustomDefaultObjTrees.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,19 +39,19 @@ import java.io.Serializable; * defaultWriteObject() and defaultReadObject(). */ public class CustomDefaultObjTrees implements Benchmark { - + static class Node implements Serializable { boolean z; - byte b; - char c; - short s; - int i; - float f; - long j; - double d; - String str = "bodega"; + byte b; + char c; + short s; + int i; + float f; + long j; + double d; + String str = "bodega"; Object parent, left, right; - + Node(Object parent, int depth) { this.parent = parent; if (depth > 0) { @@ -61,13 +61,13 @@ public class CustomDefaultObjTrees implements Benchmark { } private void writeObject(ObjectOutputStream out) throws IOException { - out.defaultWriteObject(); + out.defaultWriteObject(); } - - private void readObject(ObjectInputStream in) + + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); + in.defaultReadObject(); } } @@ -79,20 +79,20 @@ public class CustomDefaultObjTrees implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int depth = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - Node[] trees = genTrees(depth, ncycles); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, trees, 1); // warmup + int depth = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + Node[] trees = genTrees(depth, ncycles); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); + + doReps(oout, oin, sbuf, trees, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, trees, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, trees, nbatches); return System.currentTimeMillis() - start; } @@ -100,33 +100,32 @@ public class CustomDefaultObjTrees implements Benchmark { * Generate object trees. */ Node[] genTrees(int depth, int ntrees) { - Node[] trees = new Node[ntrees]; - for (int i = 0; i < ntrees; i++) { - trees[i] = new Node(null, depth); - } - return trees; + Node[] trees = new Node[ntrees]; + for (int i = 0; i < ntrees; i++) { + trees[i] = new Node(null, depth); + } + return trees; } /** - * Run benchmark for given number of batches, with each batch containing + * Run benchmark for given number of batches, with each batch containing * the given number of cycles. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, Node[] trees, int nbatches) - throws Exception + StreamBuffer sbuf, Node[] trees, int nbatches) + throws Exception { - int ncycles = trees.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(trees[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = trees.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(trees[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/CustomObjTrees.java b/test/java/rmi/reliability/benchmark/bench/serial/CustomObjTrees.java index b87cc3673f3ded94ae98bdeebb9bf44238002a6f..d5f10a8738cdb490d103022566599683b62bc7c5 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/CustomObjTrees.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/CustomObjTrees.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,19 +38,19 @@ import java.io.Serializable; * nodes contain custom writeObject() and readObject() methods. */ public class CustomObjTrees implements Benchmark { - + static class Node implements Serializable { boolean z; - byte b; - char c; - short s; - int i; - float f; - long j; - double d; - String str = "bodega"; + byte b; + char c; + short s; + int i; + float f; + long j; + double d; + String str = "bodega"; Object parent, left, right; - + Node(Object parent, int depth) { this.parent = parent; if (depth > 0) { @@ -60,35 +60,35 @@ public class CustomObjTrees implements Benchmark { } private void writeObject(ObjectOutputStream out) throws IOException { - out.writeBoolean(z); - out.writeByte(b); - out.writeChar(c); - out.writeShort(s); - out.writeInt(i); - out.writeFloat(f); - out.writeLong(j); - out.writeDouble(d); - out.writeObject(str); - out.writeObject(parent); - out.writeObject(left); - out.writeObject(right); + out.writeBoolean(z); + out.writeByte(b); + out.writeChar(c); + out.writeShort(s); + out.writeInt(i); + out.writeFloat(f); + out.writeLong(j); + out.writeDouble(d); + out.writeObject(str); + out.writeObject(parent); + out.writeObject(left); + out.writeObject(right); } - - private void readObject(ObjectInputStream in) + + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - z = in.readBoolean(); - b = in.readByte(); - c = in.readChar(); - s = in.readShort(); - i = in.readInt(); - f = in.readFloat(); - j = in.readLong(); - d = in.readDouble(); - str = (String) in.readObject(); - parent = in.readObject(); - left = in.readObject(); - right = in.readObject(); + z = in.readBoolean(); + b = in.readByte(); + c = in.readChar(); + s = in.readShort(); + i = in.readInt(); + f = in.readFloat(); + j = in.readLong(); + d = in.readDouble(); + str = (String) in.readObject(); + parent = in.readObject(); + left = in.readObject(); + right = in.readObject(); } } @@ -100,20 +100,20 @@ public class CustomObjTrees implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int depth = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - Node[] trees = genTrees(depth, ncycles); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, trees, 1); // warmup + int depth = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + Node[] trees = genTrees(depth, ncycles); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); + + doReps(oout, oin, sbuf, trees, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, trees, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, trees, nbatches); return System.currentTimeMillis() - start; } @@ -121,33 +121,32 @@ public class CustomObjTrees implements Benchmark { * Generate object trees. */ Node[] genTrees(int depth, int ntrees) { - Node[] trees = new Node[ntrees]; - for (int i = 0; i < ntrees; i++) { - trees[i] = new Node(null, depth); - } - return trees; + Node[] trees = new Node[ntrees]; + for (int i = 0; i < ntrees; i++) { + trees[i] = new Node(null, depth); + } + return trees; } /** - * Run benchmark for given number of batches, with each batch containing + * Run benchmark for given number of batches, with each batch containing * the given number of cycles. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, Node[] trees, int nbatches) - throws Exception + StreamBuffer sbuf, Node[] trees, int nbatches) + throws Exception { - int ncycles = trees.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(trees[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = trees.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(trees[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/DoubleArrays.java b/test/java/rmi/reliability/benchmark/bench/serial/DoubleArrays.java index 205bc173b8ebba442fac4a62398f99dce73c73a0..f216ebab694a6d1abde5a95f1db61e49766e03c1 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/DoubleArrays.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/DoubleArrays.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of double array reads/writes. */ public class DoubleArrays implements Benchmark { - + /** * Write and read double arrays to/from a stream. The benchmark is run in * batches, with each batch consisting of a fixed number of read/write @@ -44,44 +44,42 @@ public class DoubleArrays implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - double[][] arrays = new double[ncycles][size]; - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + double[][] arrays = new double[ncycles][size]; + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - doReps(oout, oin, sbuf, arrays, 1); // warmup + doReps(oout, oin, sbuf, arrays, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, arrays, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, arrays, nbatches); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, double[][] arrays, int nbatches) - throws Exception + StreamBuffer sbuf, double[][] arrays, int nbatches) + throws Exception { - int ncycles = arrays.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(arrays[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = arrays.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(arrays[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Doubles.java b/test/java/rmi/reliability/benchmark/bench/serial/Doubles.java index 231fd0ee86c46caf06bce86b58fb8fef127a0c19..e43df322c27413dfcb78240f690a50dbc78b87e0 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Doubles.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Doubles.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of double reads/writes. */ public class Doubles implements Benchmark { - + /** * Write and read double values to/from a stream. The benchmark is run in * batches: each "batch" consists of a fixed number of read/write cycles, @@ -44,39 +44,38 @@ public class Doubles implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int nbatches = Integer.parseInt(args[0]); - int ncycles = Integer.parseInt(args[1]); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, 1, ncycles); // warmup + int nbatches = Integer.parseInt(args[0]); + int ncycles = Integer.parseInt(args[1]); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, nbatches, ncycles); + doReps(oout, oin, sbuf, 1, ncycles); // warmup + + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, nbatches, ncycles); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, int nbatches, int ncycles) - throws Exception + StreamBuffer sbuf, int nbatches, int ncycles) + throws Exception { - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeDouble(0.0); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readDouble(); - } - } + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeDouble(0.0); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readDouble(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/ExternObjTrees.java b/test/java/rmi/reliability/benchmark/bench/serial/ExternObjTrees.java index 15a490080d2da694fe279c048bc7c1001aac2bb1..bb9053a787d425747cf70b8c5749b38ec5b11f39 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/ExternObjTrees.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/ExternObjTrees.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -40,19 +40,19 @@ import java.io.ObjectOutputStream; * objects. */ public class ExternObjTrees implements Benchmark { - + static class Node implements Externalizable { boolean z; - byte b; - char c; - short s; - int i; - float f; - long j; - double d; - String str = "bodega"; + byte b; + char c; + short s; + int i; + float f; + long j; + double d; + String str = "bodega"; Object parent, left, right; - + Node(Object parent, int depth) { this.parent = parent; if (depth > 0) { @@ -61,40 +61,40 @@ public class ExternObjTrees implements Benchmark { } } - public Node() { - } - - public void writeExternal(ObjectOutput out) throws IOException { - out.writeBoolean(z); - out.writeByte(b); - out.writeChar(c); - out.writeShort(s); - out.writeInt(i); - out.writeFloat(f); - out.writeLong(j); - out.writeDouble(d); - out.writeObject(str); - out.writeObject(parent); - out.writeObject(left); - out.writeObject(right); - } - - public void readExternal(ObjectInput in) - throws IOException, ClassNotFoundException - { - z = in.readBoolean(); - b = in.readByte(); - c = in.readChar(); - s = in.readShort(); - i = in.readInt(); - f = in.readFloat(); - j = in.readLong(); - d = in.readDouble(); - str = (String) in.readObject(); - parent = in.readObject(); - left = in.readObject(); - right = in.readObject(); - } + public Node() { + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeBoolean(z); + out.writeByte(b); + out.writeChar(c); + out.writeShort(s); + out.writeInt(i); + out.writeFloat(f); + out.writeLong(j); + out.writeDouble(d); + out.writeObject(str); + out.writeObject(parent); + out.writeObject(left); + out.writeObject(right); + } + + public void readExternal(ObjectInput in) + throws IOException, ClassNotFoundException + { + z = in.readBoolean(); + b = in.readByte(); + c = in.readChar(); + s = in.readShort(); + i = in.readInt(); + f = in.readFloat(); + j = in.readLong(); + d = in.readDouble(); + str = (String) in.readObject(); + parent = in.readObject(); + left = in.readObject(); + right = in.readObject(); + } } /** @@ -105,20 +105,20 @@ public class ExternObjTrees implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int depth = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - Node[] trees = genTrees(depth, ncycles); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, trees, 1); // warmup + int depth = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + Node[] trees = genTrees(depth, ncycles); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); + + doReps(oout, oin, sbuf, trees, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, trees, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, trees, nbatches); return System.currentTimeMillis() - start; } @@ -126,33 +126,32 @@ public class ExternObjTrees implements Benchmark { * Generate object trees. */ Node[] genTrees(int depth, int ntrees) { - Node[] trees = new Node[ntrees]; - for (int i = 0; i < ntrees; i++) { - trees[i] = new Node(null, depth); - } - return trees; + Node[] trees = new Node[ntrees]; + for (int i = 0; i < ntrees; i++) { + trees[i] = new Node(null, depth); + } + return trees; } /** - * Run benchmark for given number of batches, with each batch containing + * Run benchmark for given number of batches, with each batch containing * the given number of cycles. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, Node[] trees, int nbatches) - throws Exception + StreamBuffer sbuf, Node[] trees, int nbatches) + throws Exception { - int ncycles = trees.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(trees[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = trees.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(trees[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/FloatArrays.java b/test/java/rmi/reliability/benchmark/bench/serial/FloatArrays.java index 686fd1974f041be55b8ddd5a9fa45738e8d3bb8b..8feae044d55b5175512980d7b4726aeb0543c1b8 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/FloatArrays.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/FloatArrays.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of float array reads/writes. */ public class FloatArrays implements Benchmark { - + /** * Write and read float arrays to/from a stream. The benchmark is run in * batches, with each batch consisting of a fixed number of read/write @@ -44,44 +44,42 @@ public class FloatArrays implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - float[][] arrays = new float[ncycles][size]; - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + float[][] arrays = new float[ncycles][size]; + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - doReps(oout, oin, sbuf, arrays, 1); // warmup + doReps(oout, oin, sbuf, arrays, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, arrays, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, arrays, nbatches); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, float[][] arrays, int nbatches) - throws Exception + StreamBuffer sbuf, float[][] arrays, int nbatches) + throws Exception { - int ncycles = arrays.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(arrays[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = arrays.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(arrays[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Floats.java b/test/java/rmi/reliability/benchmark/bench/serial/Floats.java index d84bf5f969fcf1127069594de436ae7930ad2c3e..1dca696a6a4dc53b0c4985ab09336e0f599ee93f 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Floats.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Floats.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of float reads/writes. */ public class Floats implements Benchmark { - + /** * Write and read float values to/from a stream. The benchmark is run in * batches: each "batch" consists of a fixed number of read/write cycles, @@ -44,39 +44,38 @@ public class Floats implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int nbatches = Integer.parseInt(args[0]); - int ncycles = Integer.parseInt(args[1]); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, 1, ncycles); // warmup + int nbatches = Integer.parseInt(args[0]); + int ncycles = Integer.parseInt(args[1]); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, nbatches, ncycles); + doReps(oout, oin, sbuf, 1, ncycles); // warmup + + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, nbatches, ncycles); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, int nbatches, int ncycles) - throws Exception + StreamBuffer sbuf, int nbatches, int ncycles) + throws Exception { - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeFloat((float) 0.0); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readFloat(); - } - } + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeFloat((float) 0.0); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readFloat(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/GetPutFieldTrees.java b/test/java/rmi/reliability/benchmark/bench/serial/GetPutFieldTrees.java index 95a475c2d72911e136e5ee81109242e6ae8e8c07..c5794f05bad2b187954ffa75a481a5450a87c633 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/GetPutFieldTrees.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/GetPutFieldTrees.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,19 +39,19 @@ import java.io.Serializable; * GetField()/PutField() API. */ public class GetPutFieldTrees implements Benchmark { - + static class Node implements Serializable { boolean z; - byte b; - char c; - short s; - int i; - float f; - long j; - double d; - String str = "bodega"; + byte b; + char c; + short s; + int i; + float f; + long j; + double d; + String str = "bodega"; Object parent, left, right; - + Node(Object parent, int depth) { this.parent = parent; if (depth > 0) { @@ -76,19 +76,19 @@ public class GetPutFieldTrees implements Benchmark { fields.put("right", right); out.writeFields(); } - - private void readObject(ObjectInputStream in) + + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { ObjectInputStream.GetField fields = in.readFields(); - z = fields.get("z", false); - b = fields.get("b", (byte) 0); - c = fields.get("c", (char) 0); - s = fields.get("s", (short) 0); - i = fields.get("i", (int) 0); - f = fields.get("f", (float) 0.0); - j = fields.get("j", (long) 0); - d = fields.get("d", (double) 0.0); + z = fields.get("z", false); + b = fields.get("b", (byte) 0); + c = fields.get("c", (char) 0); + s = fields.get("s", (short) 0); + i = fields.get("i", (int) 0); + f = fields.get("f", (float) 0.0); + j = fields.get("j", (long) 0); + d = fields.get("d", (double) 0.0); str = (String) fields.get("str", null); parent = fields.get("parent", null); left = fields.get("left", null); @@ -104,20 +104,20 @@ public class GetPutFieldTrees implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int depth = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - Node[] trees = genTrees(depth, ncycles); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, trees, 1); // warmup + int depth = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + Node[] trees = genTrees(depth, ncycles); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); + + doReps(oout, oin, sbuf, trees, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, trees, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, trees, nbatches); return System.currentTimeMillis() - start; } @@ -125,33 +125,32 @@ public class GetPutFieldTrees implements Benchmark { * Generate object trees. */ Node[] genTrees(int depth, int ntrees) { - Node[] trees = new Node[ntrees]; - for (int i = 0; i < ntrees; i++) { - trees[i] = new Node(null, depth); - } - return trees; + Node[] trees = new Node[ntrees]; + for (int i = 0; i < ntrees; i++) { + trees[i] = new Node(null, depth); + } + return trees; } /** - * Run benchmark for given number of batches, with each batch containing + * Run benchmark for given number of batches, with each batch containing * the given number of cycles. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, Node[] trees, int nbatches) - throws Exception + StreamBuffer sbuf, Node[] trees, int nbatches) + throws Exception { - int ncycles = trees.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(trees[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = trees.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(trees[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/IntArrays.java b/test/java/rmi/reliability/benchmark/bench/serial/IntArrays.java index 2bc445373c0375478921730c3503b303dbd87412..c50059bb6c3117256ecb11c090abcc21a862bc18 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/IntArrays.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/IntArrays.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of int array reads/writes. */ public class IntArrays implements Benchmark { - + /** * Write and read int arrays to/from a stream. The benchmark is run in * batches, with each batch consisting of a fixed number of read/write @@ -44,44 +44,42 @@ public class IntArrays implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - int[][] arrays = new int[ncycles][size]; - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + int[][] arrays = new int[ncycles][size]; + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - doReps(oout, oin, sbuf, arrays, 1); // warmup + doReps(oout, oin, sbuf, arrays, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, arrays, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, arrays, nbatches); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, int[][] arrays, int nbatches) - throws Exception + StreamBuffer sbuf, int[][] arrays, int nbatches) + throws Exception { - int ncycles = arrays.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(arrays[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = arrays.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(arrays[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Ints.java b/test/java/rmi/reliability/benchmark/bench/serial/Ints.java index 152b048e9b527f5ce951a73192090a3cc3e95dd1..90cfb30216f2918ebec0165d97bbf91b88045f17 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Ints.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Ints.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of int reads/writes. */ public class Ints implements Benchmark { - + /** * Write and read int values to/from a stream. The benchmark is run in * batches: each "batch" consists of a fixed number of read/write cycles, @@ -44,39 +44,38 @@ public class Ints implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int nbatches = Integer.parseInt(args[0]); - int ncycles = Integer.parseInt(args[1]); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, 1, ncycles); // warmup + int nbatches = Integer.parseInt(args[0]); + int ncycles = Integer.parseInt(args[1]); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, nbatches, ncycles); + doReps(oout, oin, sbuf, 1, ncycles); // warmup + + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, nbatches, ncycles); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, int nbatches, int ncycles) - throws Exception + StreamBuffer sbuf, int nbatches, int ncycles) + throws Exception { - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeInt(0); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readInt(); - } - } + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeInt(0); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readInt(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/LongArrays.java b/test/java/rmi/reliability/benchmark/bench/serial/LongArrays.java index 21b48e98cb6365c6dfa966bdf8f2896408d24874..802bb82cf9a6ff5664ed92777a3d5c80ad8797e2 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/LongArrays.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/LongArrays.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of long array reads/writes. */ public class LongArrays implements Benchmark { - + /** * Write and read long arrays to/from a stream. The benchmark is run in * batches, with each batch consisting of a fixed number of read/write @@ -44,44 +44,42 @@ public class LongArrays implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - long[][] arrays = new long[ncycles][size]; - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + long[][] arrays = new long[ncycles][size]; + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - doReps(oout, oin, sbuf, arrays, 1); // warmup + doReps(oout, oin, sbuf, arrays, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, arrays, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, arrays, nbatches); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, long[][] arrays, int nbatches) - throws Exception + StreamBuffer sbuf, long[][] arrays, int nbatches) + throws Exception { - int ncycles = arrays.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(arrays[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = arrays.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(arrays[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Longs.java b/test/java/rmi/reliability/benchmark/bench/serial/Longs.java index 7ebac7f9ffb5e6b3ed6aedefa4f0d415bd92d9b3..fdc1e04e647cc2ef1ca9c93412e4f92647a5d7ca 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Longs.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Longs.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of long reads/writes. */ public class Longs implements Benchmark { - + /** * Write and read long values to/from a stream. The benchmark is run in * batches: each "batch" consists of a fixed number of read/write cycles, @@ -44,39 +44,38 @@ public class Longs implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int nbatches = Integer.parseInt(args[0]); - int ncycles = Integer.parseInt(args[1]); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, 1, ncycles); // warmup + int nbatches = Integer.parseInt(args[0]); + int ncycles = Integer.parseInt(args[1]); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, nbatches, ncycles); + doReps(oout, oin, sbuf, 1, ncycles); // warmup + + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, nbatches, ncycles); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, int nbatches, int ncycles) - throws Exception + StreamBuffer sbuf, int nbatches, int ncycles) + throws Exception { - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeLong(0); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readLong(); - } - } + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeLong(0); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readLong(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Main.java b/test/java/rmi/reliability/benchmark/bench/serial/Main.java index aeaa4b19153dbf7c8c10207340d77157abed9c42..49e8e813f6e822c8df98cb183d39ef6e61ae1e96 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Main.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Main.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -46,7 +46,7 @@ import java.util.TimerTask; * Object serialization benchmark mainline. */ public class Main { - + static final String CONFFILE = "/bench/serial/config"; static final String VERSION = "1.3"; @@ -80,55 +80,55 @@ public class Main { p.println(" -o specify output file"); p.println(" -c specify (non-default) configuration file"); p.println(" -html format output as html (default is text)"); - p.println(" -xml format output as xml"); + p.println(" -xml format output as xml"); } /** * Print error message and exit. */ static void die(String mesg) { - System.err.println(mesg); - System.exit(1); + System.err.println(mesg); + System.exit(1); } /** * Mainline parses command line, then hands off to benchmark harness. */ public static void main(String[] args) { - parseArgs(args); - setupStreams(); - if (list) { - listConfig(); - } else { - setupHarness(); - setupReporter(); - if (exitOnTimer) { - setupTimer(testDurationSeconds); - while (true) { - runBenchmarks(); - if (exitRequested) { - System.exit(0); - } - } - } else { - runBenchmarks(); - System.exit(0); - } - } + parseArgs(args); + setupStreams(); + if (list) { + listConfig(); + } else { + setupHarness(); + setupReporter(); + if (exitOnTimer) { + setupTimer(testDurationSeconds); + while (true) { + runBenchmarks(); + if (exitRequested) { + System.exit(0); + } + } + } else { + runBenchmarks(); + System.exit(0); + } + } } - + /** * Parse command-line arguments. */ static void parseArgs(String[] args) { - for (int i = 0; i < args.length; i++) { - if (args[i].equals("-h")) { - usage(); - System.exit(0); - } else if (args[i].equals("-v")) { - verbose = true; - } else if (args[i].equals("-l")) { - list = true; + for (int i = 0; i < args.length; i++) { + if (args[i].equals("-h")) { + usage(); + System.exit(0); + } else if (args[i].equals("-v")) { + verbose = true; + } else if (args[i].equals("-l")) { + list = true; } else if (args[i].equals("-t")) { if (++i >= args.length) die("Error: no timeout value specified"); @@ -138,64 +138,64 @@ public class Main { } catch (Exception e) { die("Error: unable to determine timeout value"); } - } else if (args[i].equals("-o")) { - if (++i >= args.length) - die("Error: no output file specified"); - try { - repstr = new FileOutputStream(args[i]); - } catch (IOException e) { - die("Error: unable to open \"" + args[i] + "\""); - } - } else if (args[i].equals("-c")) { - if (++i >= args.length) - die("Error: no config file specified"); - try { - confstr = new FileInputStream(args[i]); - } catch (IOException e) { - die("Error: unable to open \"" + args[i] + "\""); - } - } else if (args[i].equals("-html")) { - if (format != TEXT) - die("Error: conflicting formats"); - format = HTML; - } else if (args[i].equals("-xml")) { - if (format != TEXT) - die("Error: conflicting formats"); - format = XML; - } else { - System.err.println("Illegal option: \"" + args[i] + "\""); - usage(); - System.exit(1); - } - } + } else if (args[i].equals("-o")) { + if (++i >= args.length) + die("Error: no output file specified"); + try { + repstr = new FileOutputStream(args[i]); + } catch (IOException e) { + die("Error: unable to open \"" + args[i] + "\""); + } + } else if (args[i].equals("-c")) { + if (++i >= args.length) + die("Error: no config file specified"); + try { + confstr = new FileInputStream(args[i]); + } catch (IOException e) { + die("Error: unable to open \"" + args[i] + "\""); + } + } else if (args[i].equals("-html")) { + if (format != TEXT) + die("Error: conflicting formats"); + format = HTML; + } else if (args[i].equals("-xml")) { + if (format != TEXT) + die("Error: conflicting formats"); + format = XML; + } else { + System.err.println("Illegal option: \"" + args[i] + "\""); + usage(); + System.exit(1); + } + } } - + /** * Set up configuration file and report streams, if not set already. */ static void setupStreams() { - if (repstr == null) - repstr = System.out; - if (confstr == null) - confstr = (new Main()).getClass().getResourceAsStream(CONFFILE); - if (confstr == null) - die("Error: unable to find default config file"); + if (repstr == null) + repstr = System.out; + if (confstr == null) + confstr = (new Main()).getClass().getResourceAsStream(CONFFILE); + if (confstr == null) + die("Error: unable to find default config file"); } - + /** * Print contents of configuration file to selected output stream. */ static void listConfig() { - try { - byte[] buf = new byte[256]; - int len; - while ((len = confstr.read(buf)) != -1) - repstr.write(buf, 0, len); - } catch (IOException e) { - die("Error: failed to list config file"); - } + try { + byte[] buf = new byte[256]; + int len; + while ((len = confstr.read(buf)) != -1) + repstr.write(buf, 0, len); + } catch (IOException e) { + die("Error: failed to list config file"); + } } - + /** * Set up the timer to end the test. * @@ -222,12 +222,12 @@ public class Main { } catch (ConfigFormatException e) { String errmsg = e.getMessage(); if (errmsg != null) { - die("Error parsing config file: " + errmsg); - } else { + die("Error parsing config file: " + errmsg); + } else { die("Error: illegal config file syntax"); - } + } } catch (IOException e) { - die("Error: failed to read config file"); + die("Error: failed to read config file"); } } @@ -236,22 +236,22 @@ public class Main { */ static void setupReporter() { String title = "Object Serialization Benchmark, v" + VERSION; - switch (format) { - case TEXT: - reporter = new TextReporter(repstr, title); - break; - - case HTML: - reporter = new HtmlReporter(repstr, title); - break; + switch (format) { + case TEXT: + reporter = new TextReporter(repstr, title); + break; + + case HTML: + reporter = new HtmlReporter(repstr, title); + break; + + case XML: + reporter = new XmlReporter(repstr, title); + break; - case XML: - reporter = new XmlReporter(repstr, title); - break; - - default: - die("Error: unrecognized format type"); - } + default: + die("Error: unrecognized format type"); + } } /** @@ -261,4 +261,3 @@ public class Main { harness.runBenchmarks(reporter, verbose); } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/ObjArrays.java b/test/java/rmi/reliability/benchmark/bench/serial/ObjArrays.java index 1bd833e19c20fddfee2c05f6d03586868a59a797..b9b1ec5fb7a5872f6ebf91f197b05030753e59a9 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/ObjArrays.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/ObjArrays.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,16 +39,16 @@ public class ObjArrays implements Benchmark { static class Node implements Serializable { boolean z; - byte b; - char c; - short s; - int i; - float f; - long j; - double d; - String str = "bodega"; + byte b; + char c; + short s; + int i; + float f; + long j; + double d; + String str = "bodega"; Object parent, left, right; - + Node(Object parent, int depth) { this.parent = parent; if (depth > 0) { @@ -57,7 +57,7 @@ public class ObjArrays implements Benchmark { } } } - + /** * Write and read object arrays to/from a stream. The benchmark is run in * batches, with each batch consisting of a fixed number of read/write @@ -66,34 +66,34 @@ public class ObjArrays implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - Node[][] arrays = genArrays(size, ncycles); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + Node[][] arrays = genArrays(size, ncycles); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - doReps(oout, oin, sbuf, arrays, 1); // warmup + doReps(oout, oin, sbuf, arrays, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, arrays, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, arrays, nbatches); return System.currentTimeMillis() - start; } - + /** * Generate object arrays. */ Node[][] genArrays(int size, int narrays) { - Node[][] arrays = new Node[narrays][size]; - for (int i = 0; i < narrays; i++) { - for (int j = 0; j < size; j++) { - arrays[i][j] = new Node(null, 0); - } - } - return arrays; + Node[][] arrays = new Node[narrays][size]; + for (int i = 0; i < narrays; i++) { + for (int j = 0; j < size; j++) { + arrays[i][j] = new Node(null, 0); + } + } + return arrays; } /** @@ -101,22 +101,20 @@ public class ObjArrays implements Benchmark { * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, Node[][] arrays, int nbatches) - throws Exception + StreamBuffer sbuf, Node[][] arrays, int nbatches) + throws Exception { - int ncycles = arrays.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(arrays[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = arrays.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(arrays[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/ObjTrees.java b/test/java/rmi/reliability/benchmark/bench/serial/ObjTrees.java index 2fc1cc57a90c1f319d91337ed5795deb2aaf59c0..f9405ba1d9caa191ec9cf953338d851c732fa2f0 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/ObjTrees.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/ObjTrees.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,19 +36,19 @@ import java.io.Serializable; * Benchmark for testing speed of writes and reads of an object tree. */ public class ObjTrees implements Benchmark { - + static class Node implements Serializable { boolean z; - byte b; - char c; - short s; - int i; - float f; - long j; - double d; - String str = "bodega"; + byte b; + char c; + short s; + int i; + float f; + long j; + double d; + String str = "bodega"; Object parent, left, right; - + Node(Object parent, int depth) { this.parent = parent; if (depth > 0) { @@ -66,20 +66,20 @@ public class ObjTrees implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int depth = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - Node[] trees = genTrees(depth, ncycles); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, trees, 1); // warmup + int depth = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + Node[] trees = genTrees(depth, ncycles); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, trees, nbatches); + doReps(oout, oin, sbuf, trees, 1); // warmup + + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, trees, nbatches); return System.currentTimeMillis() - start; } @@ -87,33 +87,32 @@ public class ObjTrees implements Benchmark { * Generate object trees. */ Node[] genTrees(int depth, int ntrees) { - Node[] trees = new Node[ntrees]; - for (int i = 0; i < ntrees; i++) { - trees[i] = new Node(null, depth); - } - return trees; + Node[] trees = new Node[ntrees]; + for (int i = 0; i < ntrees; i++) { + trees[i] = new Node(null, depth); + } + return trees; } /** - * Run benchmark for given number of batches, with each batch containing + * Run benchmark for given number of batches, with each batch containing * the given number of cycles. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, Node[] trees, int nbatches) - throws Exception + StreamBuffer sbuf, Node[] trees, int nbatches) + throws Exception { - int ncycles = trees.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(trees[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = trees.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(trees[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/ProxyArrays.java b/test/java/rmi/reliability/benchmark/bench/serial/ProxyArrays.java index 2a114eac6ca03e70251257dcbbbaf4d34549df6a..c6ad86dd50e57f6515ff5e4a2b3dad206c62ad5a 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/ProxyArrays.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/ProxyArrays.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -42,15 +42,15 @@ import java.lang.reflect.Proxy; public class ProxyArrays implements Benchmark { static class DummyHandler implements InvocationHandler, Serializable { - public Object invoke(Object proxy, Method method, Object[] args) - throws Throwable - { - return null; - } + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable + { + return null; + } } - + static interface DummyInterface { - public void foo(); + public void foo(); } /** @@ -61,40 +61,40 @@ public class ProxyArrays implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - Proxy[][] arrays = genArrays(size, ncycles); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + Proxy[][] arrays = genArrays(size, ncycles); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - doReps(oout, oin, sbuf, arrays, 1); // warmup + doReps(oout, oin, sbuf, arrays, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, arrays, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, arrays, nbatches); return System.currentTimeMillis() - start; } - + /** * Generate proxy arrays. */ Proxy[][] genArrays(int size, int narrays) throws Exception { - Class proxyClass = - Proxy.getProxyClass(DummyInterface.class.getClassLoader(), - new Class[] { DummyInterface.class }); - Constructor proxyCons = - proxyClass.getConstructor(new Class[] { InvocationHandler.class }); - Object[] consArgs = new Object[] { new DummyHandler() }; - Proxy[][] arrays = new Proxy[narrays][size]; - for (int i = 0; i < narrays; i++) { - for (int j = 0; j < size; j++) { - arrays[i][j] = (Proxy) proxyCons.newInstance(consArgs); - } - } - return arrays; + Class proxyClass = + Proxy.getProxyClass(DummyInterface.class.getClassLoader(), + new Class[] { DummyInterface.class }); + Constructor proxyCons = + proxyClass.getConstructor(new Class[] { InvocationHandler.class }); + Object[] consArgs = new Object[] { new DummyHandler() }; + Proxy[][] arrays = new Proxy[narrays][size]; + for (int i = 0; i < narrays; i++) { + for (int j = 0; j < size; j++) { + arrays[i][j] = (Proxy) proxyCons.newInstance(consArgs); + } + } + return arrays; } /** @@ -102,22 +102,20 @@ public class ProxyArrays implements Benchmark { * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, Proxy[][] arrays, int nbatches) - throws Exception + StreamBuffer sbuf, Proxy[][] arrays, int nbatches) + throws Exception { - int ncycles = arrays.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(arrays[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = arrays.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(arrays[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/ProxyClassDesc.java b/test/java/rmi/reliability/benchmark/bench/serial/ProxyClassDesc.java index a5ae07a09ad59a35f21014eff4ea0612757b29d8..4a0576361a2d2b0aab94149f83de96f8c521fa5b 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/ProxyClassDesc.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/ProxyClassDesc.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,7 +38,7 @@ import java.lang.reflect.Proxy; * Benchmark for testing speed of proxy class descriptor reads/writes. */ public class ProxyClassDesc implements Benchmark { - + static interface A1 {}; static interface A2 {}; static interface A3 {}; @@ -54,75 +54,74 @@ public class ProxyClassDesc implements Benchmark { static interface C3 {}; static interface C4 {}; static interface C5 {}; - + /** * Write and read proxy class descriptors to/from a stream. * Arguments: <# cycles> */ public long run(String[] args) throws Exception { - int ncycles = Integer.parseInt(args[0]); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - ObjectStreamClass[] descs = genDescs(); + int ncycles = Integer.parseInt(args[0]); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); + ObjectStreamClass[] descs = genDescs(); - doReps(oout, oin, sbuf, descs, 1); // warmup + doReps(oout, oin, sbuf, descs, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, descs, ncycles); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, descs, ncycles); return System.currentTimeMillis() - start; } - + /** * Generate proxy class descriptors. */ ObjectStreamClass[] genDescs() { - ClassLoader ldr = ProxyClassDesc.class.getClassLoader(); - Class[] ifaces = new Class[3]; - Class[] a = - new Class[] { A1.class, A2.class, A3.class, A4.class, A5.class }; - Class[] b = - new Class[] { B1.class, B2.class, B3.class, B4.class, B5.class }; - Class[] c = - new Class[] { C1.class, C2.class, C3.class, C4.class, C5.class }; - ObjectStreamClass[] descs = - new ObjectStreamClass[a.length * b.length * c.length]; - int n = 0; - for (int i = 0; i < a.length; i++) { - ifaces[0] = a[i]; - for (int j = 0; j < b.length; j++) { - ifaces[1] = b[j]; - for (int k = 0; k < c.length; k++) { - ifaces[2] = c[k]; - Class proxyClass = Proxy.getProxyClass(ldr, ifaces); - descs[n++] = ObjectStreamClass.lookup(proxyClass); - } - } - } - return descs; + ClassLoader ldr = ProxyClassDesc.class.getClassLoader(); + Class[] ifaces = new Class[3]; + Class[] a = + new Class[] { A1.class, A2.class, A3.class, A4.class, A5.class }; + Class[] b = + new Class[] { B1.class, B2.class, B3.class, B4.class, B5.class }; + Class[] c = + new Class[] { C1.class, C2.class, C3.class, C4.class, C5.class }; + ObjectStreamClass[] descs = + new ObjectStreamClass[a.length * b.length * c.length]; + int n = 0; + for (int i = 0; i < a.length; i++) { + ifaces[0] = a[i]; + for (int j = 0; j < b.length; j++) { + ifaces[1] = b[j]; + for (int k = 0; k < c.length; k++) { + ifaces[2] = c[k]; + Class proxyClass = Proxy.getProxyClass(ldr, ifaces); + descs[n++] = ObjectStreamClass.lookup(proxyClass); + } + } + } + return descs; } /** * Run benchmark for given number of cycles. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, ObjectStreamClass[] descs, int ncycles) - throws Exception + StreamBuffer sbuf, ObjectStreamClass[] descs, int ncycles) + throws Exception { - int ndescs = descs.length; - for (int i = 0; i < ncycles; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ndescs; j++) { - oout.writeObject(descs[j]); - } - oout.flush(); - for (int j = 0; j < ndescs; j++) { - oin.readObject(); - } - } + int ndescs = descs.length; + for (int i = 0; i < ncycles; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ndescs; j++) { + oout.writeObject(descs[j]); + } + oout.flush(); + for (int j = 0; j < ndescs; j++) { + oin.readObject(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/RepeatObjs.java b/test/java/rmi/reliability/benchmark/bench/serial/RepeatObjs.java index ba95b451e6097d67caaee725533bb9f27ccb6e24..08ae15908ef63ca7c1f84662dce10ae76c14da97 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/RepeatObjs.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/RepeatObjs.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,7 +36,7 @@ import java.io.Serializable; * Benchmark for testing speed of reads/writes of repeated objects. */ public class RepeatObjs implements Benchmark { - + static class Node implements Serializable { } @@ -49,50 +49,49 @@ public class RepeatObjs implements Benchmark { * Arguments: <# objects> <# cycles> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - Node[] objs = genObjs(size); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, objs, 1); // warmup + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + Node[] objs = genObjs(size); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); + + doReps(oout, oin, sbuf, objs, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, objs, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, objs, nbatches); return System.currentTimeMillis() - start; } - + /** * Generate objects. */ Node[] genObjs(int nobjs) { - Node[] objs = new Node[nobjs]; - for (int i = 0; i < nobjs; i++) - objs[i] = new Node(); - return objs; + Node[] objs = new Node[nobjs]; + for (int i = 0; i < nobjs; i++) + objs[i] = new Node(); + return objs; } - + /** * Run benchmark for given number of batches. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, Node[] objs, int nbatches) - throws Exception + StreamBuffer sbuf, Node[] objs, int nbatches) + throws Exception { - int nobjs = objs.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - for (int j = 0; j < nobjs; j++) { - oout.writeObject(objs[j]); - } - oout.flush(); - for (int j = 0; j < nobjs; j++) { - oin.readObject(); - } - } + int nobjs = objs.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + for (int j = 0; j < nobjs; j++) { + oout.writeObject(objs[j]); + } + oout.flush(); + for (int j = 0; j < nobjs; j++) { + oin.readObject(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/ReplaceTrees.java b/test/java/rmi/reliability/benchmark/bench/serial/ReplaceTrees.java index f52f0438a590d0a529b76184575e705f7774997e..e117453bd9b6842a6d2914b00d1534c4bec237a9 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/ReplaceTrees.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/ReplaceTrees.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -37,15 +37,15 @@ import java.io.Serializable; * objects. */ public class ReplaceTrees implements Benchmark { - + static class Node implements Serializable { Object parent, left, right; - - Node(Object parent, Object left, Object right) { - this.parent = parent; - this.left = left; - this.right = right; - } + + Node(Object parent, Object left, Object right) { + this.parent = parent; + this.left = left; + this.right = right; + } Node(Object parent, int depth) { this.parent = parent; @@ -54,26 +54,26 @@ public class ReplaceTrees implements Benchmark { right = new Node(this, depth - 1); } } - - Object writeReplace() { - return new RepNode(parent, left, right); - } + + Object writeReplace() { + return new RepNode(parent, left, right); + } } - + static class RepNode implements Serializable { - Object parent, left, right; - - RepNode(Object parent, Object left, Object right) { - this.parent = parent; - this.left = left; - this.right = right; - } - - Object readResolve() { - return new Node(parent, left, right); - } + Object parent, left, right; + + RepNode(Object parent, Object left, Object right) { + this.parent = parent; + this.left = left; + this.right = right; + } + + Object readResolve() { + return new Node(parent, left, right); + } } - + /** * Write and read a tree of replaceable objects from a stream. The * benchmark is run in batches: each "batch" consists of a fixed number of @@ -82,20 +82,20 @@ public class ReplaceTrees implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int depth = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - Node[] trees = genTrees(depth, ncycles); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, trees, 1); // warmup - - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, trees, nbatches); + int depth = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + Node[] trees = genTrees(depth, ncycles); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); + + doReps(oout, oin, sbuf, trees, 1); // warmup + + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, trees, nbatches); return System.currentTimeMillis() - start; } @@ -103,11 +103,11 @@ public class ReplaceTrees implements Benchmark { * Generate object trees. */ Node[] genTrees(int depth, int ntrees) { - Node[] trees = new Node[ntrees]; - for (int i = 0; i < ntrees; i++) { - trees[i] = new Node(null, depth); - } - return trees; + Node[] trees = new Node[ntrees]; + for (int i = 0; i < ntrees; i++) { + trees[i] = new Node(null, depth); + } + return trees; } /** @@ -115,21 +115,20 @@ public class ReplaceTrees implements Benchmark { * the given number of cycles. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, Node[] trees, int nbatches) - throws Exception + StreamBuffer sbuf, Node[] trees, int nbatches) + throws Exception { - int ncycles = trees.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(trees[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = trees.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(trees[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/ShortArrays.java b/test/java/rmi/reliability/benchmark/bench/serial/ShortArrays.java index 9b8cf10a5ec227112bf78440229a5139a5f044be..45339999c5bdcbe4adc5ac424b583aec30d9ba80 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/ShortArrays.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/ShortArrays.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of short array reads/writes. */ public class ShortArrays implements Benchmark { - + /** * Write and read short arrays to/from a stream. The benchmark is run in * batches, with each batch consisting of a fixed number of read/write @@ -44,44 +44,42 @@ public class ShortArrays implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int size = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - short[][] arrays = new short[ncycles][size]; - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); + int size = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + short[][] arrays = new short[ncycles][size]; + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - doReps(oout, oin, sbuf, arrays, 1); // warmup + doReps(oout, oin, sbuf, arrays, 1); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, arrays, nbatches); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, arrays, nbatches); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, short[][] arrays, int nbatches) - throws Exception + StreamBuffer sbuf, short[][] arrays, int nbatches) + throws Exception { - int ncycles = arrays.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(arrays[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = arrays.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(arrays[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Shorts.java b/test/java/rmi/reliability/benchmark/bench/serial/Shorts.java index 985d7302a37bde3e68b5a8b6b42724d714aa574a..dafdf53c9f3e5bf5e4854685c40bb05380e80e40 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Shorts.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Shorts.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ import java.io.ObjectOutputStream; * Benchmark for testing speed of short reads/writes. */ public class Shorts implements Benchmark { - + /** * Write and read short values to/from a stream. The benchmark is run in * batches: each "batch" consists of a fixed number of read/write cycles, @@ -44,39 +44,38 @@ public class Shorts implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int nbatches = Integer.parseInt(args[0]); - int ncycles = Integer.parseInt(args[1]); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, 1, ncycles); // warmup + int nbatches = Integer.parseInt(args[0]); + int ncycles = Integer.parseInt(args[1]); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, nbatches, ncycles); + doReps(oout, oin, sbuf, 1, ncycles); // warmup + + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, nbatches, ncycles); return System.currentTimeMillis() - start; } - + /** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, int nbatches, int ncycles) - throws Exception + StreamBuffer sbuf, int nbatches, int ncycles) + throws Exception { - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeShort(0); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readShort(); - } - } + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeShort(0); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readShort(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/SmallObjTrees.java b/test/java/rmi/reliability/benchmark/bench/serial/SmallObjTrees.java index 30bebd76d6444ce0655535f52071538a5a45963b..bb0394f3986bc4db1568033659196f28abdc0279 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/SmallObjTrees.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/SmallObjTrees.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,10 +36,10 @@ import java.io.Serializable; * Benchmark for testing speed of writes and reads of a tree of small objects. */ public class SmallObjTrees implements Benchmark { - + static class Node implements Serializable { Object parent, left, right; - + Node(Object parent, int depth) { this.parent = parent; if (depth > 0) { @@ -57,20 +57,20 @@ public class SmallObjTrees implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int depth = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - Node[] trees = genTrees(depth, ncycles); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, trees, 1); // warmup + int depth = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + Node[] trees = genTrees(depth, ncycles); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, trees, nbatches); + doReps(oout, oin, sbuf, trees, 1); // warmup + + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, trees, nbatches); return System.currentTimeMillis() - start; } @@ -78,11 +78,11 @@ public class SmallObjTrees implements Benchmark { * Generate object trees. */ Node[] genTrees(int depth, int ntrees) { - Node[] trees = new Node[ntrees]; - for (int i = 0; i < ntrees; i++) { - trees[i] = new Node(null, depth); - } - return trees; + Node[] trees = new Node[ntrees]; + for (int i = 0; i < ntrees; i++) { + trees[i] = new Node(null, depth); + } + return trees; } /** @@ -90,21 +90,20 @@ public class SmallObjTrees implements Benchmark { * given number of cycles. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, Node[] trees, int nbatches) - throws Exception + StreamBuffer sbuf, Node[] trees, int nbatches) + throws Exception { - int ncycles = trees.length; - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(trees[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + int ncycles = trees.length; + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(trees[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/StreamBuffer.java b/test/java/rmi/reliability/benchmark/bench/serial/StreamBuffer.java index 100a294d1dd8d94d98518a75bb35e04889a34c3c..33efee8724b105e15a7bbda9900c81d5176027eb 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/StreamBuffer.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/StreamBuffer.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -47,85 +47,85 @@ import java.io.IOException; * StreamBufferInputStream.read(). */ public class StreamBuffer { - + /** * Output stream for writing to stream buffer. */ private class StreamBufferOutputStream extends OutputStream { - - private int pos; - - public void write(int b) throws IOException { - if (mode != WRITE_MODE) - throw new IOException(); - while (pos >= buf.length) - grow(); - buf[pos++] = (byte) b; - } - - public void write(byte[] b, int off, int len) throws IOException { - if (mode != WRITE_MODE) - throw new IOException(); - while (pos + len > buf.length) - grow(); - System.arraycopy(b, off, buf, pos, len); - pos += len; - } - - public void close() throws IOException { - if (mode != WRITE_MODE) - throw new IOException(); - mode = READ_MODE; - } + + private int pos; + + public void write(int b) throws IOException { + if (mode != WRITE_MODE) + throw new IOException(); + while (pos >= buf.length) + grow(); + buf[pos++] = (byte) b; + } + + public void write(byte[] b, int off, int len) throws IOException { + if (mode != WRITE_MODE) + throw new IOException(); + while (pos + len > buf.length) + grow(); + System.arraycopy(b, off, buf, pos, len); + pos += len; + } + + public void close() throws IOException { + if (mode != WRITE_MODE) + throw new IOException(); + mode = READ_MODE; + } } - + /** * Input stream for reading from stream buffer. */ private class StreamBufferInputStream extends InputStream { - - private int pos; - - public int read() throws IOException { - if (mode == CLOSED_MODE) - throw new IOException(); - mode = READ_MODE; - return (pos < out.pos) ? (buf[pos++] & 0xFF) : -1; - } - - public int read(byte[] b, int off, int len) throws IOException { - if (mode == CLOSED_MODE) - throw new IOException(); - mode = READ_MODE; - int avail = out.pos - pos; - int rlen = (avail < len) ? avail : len; - System.arraycopy(buf, pos, b, off, rlen); - pos += rlen; - return rlen; - } - - public long skip(long len) throws IOException { - if (mode == CLOSED_MODE) - throw new IOException(); - mode = READ_MODE; - int avail = out.pos - pos; - long slen = (avail < len) ? avail : len; - pos += slen; - return slen; - } - - public int available() throws IOException { - if (mode == CLOSED_MODE) - throw new IOException(); - mode = READ_MODE; - return out.pos - pos; - } - - public void close() throws IOException { - if (mode == CLOSED_MODE) - throw new IOException(); - mode = CLOSED_MODE; - } + + private int pos; + + public int read() throws IOException { + if (mode == CLOSED_MODE) + throw new IOException(); + mode = READ_MODE; + return (pos < out.pos) ? (buf[pos++] & 0xFF) : -1; + } + + public int read(byte[] b, int off, int len) throws IOException { + if (mode == CLOSED_MODE) + throw new IOException(); + mode = READ_MODE; + int avail = out.pos - pos; + int rlen = (avail < len) ? avail : len; + System.arraycopy(buf, pos, b, off, rlen); + pos += rlen; + return rlen; + } + + public long skip(long len) throws IOException { + if (mode == CLOSED_MODE) + throw new IOException(); + mode = READ_MODE; + int avail = out.pos - pos; + long slen = (avail < len) ? avail : len; + pos += slen; + return slen; + } + + public int available() throws IOException { + if (mode == CLOSED_MODE) + throw new IOException(); + mode = READ_MODE; + return out.pos - pos; + } + + public void close() throws IOException { + if (mode == CLOSED_MODE) + throw new IOException(); + mode = CLOSED_MODE; + } } private static final int START_BUFSIZE = 256; @@ -140,30 +140,29 @@ public class StreamBuffer { private int mode = WRITE_MODE; public StreamBuffer() { - this(START_BUFSIZE); + this(START_BUFSIZE); } - + public StreamBuffer(int size) { - buf = new byte[size]; + buf = new byte[size]; } - + public OutputStream getOutputStream() { - return out; + return out; } - + public InputStream getInputStream() { - return in; + return in; } - + public void reset() { - in.pos = out.pos = 0; - mode = WRITE_MODE; + in.pos = out.pos = 0; + mode = WRITE_MODE; } - + private void grow() { - byte[] newbuf = new byte[buf.length * GROW_FACTOR]; - System.arraycopy(buf, 0, newbuf, 0, buf.length); - buf = newbuf; + byte[] newbuf = new byte[buf.length * GROW_FACTOR]; + System.arraycopy(buf, 0, newbuf, 0, buf.length); + buf = newbuf; } } - diff --git a/test/java/rmi/reliability/benchmark/bench/serial/Strings.java b/test/java/rmi/reliability/benchmark/bench/serial/Strings.java index aad74b7212bf22ad1b6d4a4d0539cb9a3deb897a..512e1a33de4512b18412b455ccb9e0aea866db6c 100644 --- a/test/java/rmi/reliability/benchmark/bench/serial/Strings.java +++ b/test/java/rmi/reliability/benchmark/bench/serial/Strings.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -45,20 +45,20 @@ public class Strings implements Benchmark { * Arguments: <# batches> <# cycles per batch> */ public long run(String[] args) throws Exception { - int slen = Integer.parseInt(args[0]); - int nbatches = Integer.parseInt(args[1]); - int ncycles = Integer.parseInt(args[2]); - String[] strs = genStrings(slen, ncycles); - StreamBuffer sbuf = new StreamBuffer(); - ObjectOutputStream oout = - new ObjectOutputStream(sbuf.getOutputStream()); - ObjectInputStream oin = - new ObjectInputStream(sbuf.getInputStream()); - - doReps(oout, oin, sbuf, strs, 1, ncycles); // warmup + int slen = Integer.parseInt(args[0]); + int nbatches = Integer.parseInt(args[1]); + int ncycles = Integer.parseInt(args[2]); + String[] strs = genStrings(slen, ncycles); + StreamBuffer sbuf = new StreamBuffer(); + ObjectOutputStream oout = + new ObjectOutputStream(sbuf.getOutputStream()); + ObjectInputStream oin = + new ObjectInputStream(sbuf.getInputStream()); + + doReps(oout, oin, sbuf, strs, 1, ncycles); // warmup - long start = System.currentTimeMillis(); - doReps(oout, oin, sbuf, strs, nbatches, ncycles); + long start = System.currentTimeMillis(); + doReps(oout, oin, sbuf, strs, nbatches, ncycles); return System.currentTimeMillis() - start; } @@ -66,16 +66,16 @@ public class Strings implements Benchmark { * Generate nstrings random strings, each of length len. */ String[] genStrings(int len, int nstrings) { - String[] strs = new String[nstrings]; - char[] ca = new char[len]; - Random rand = new Random(System.currentTimeMillis()); - for (int i = 0; i < nstrings; i++) { - for (int j = 0; j < len; j++) { - ca[j] = (char) rand.nextInt(); - } - strs[i] = new String(ca); - } - return strs; + String[] strs = new String[nstrings]; + char[] ca = new char[len]; + Random rand = new Random(System.currentTimeMillis()); + for (int i = 0; i < nstrings; i++) { + for (int j = 0; j < len; j++) { + ca[j] = (char) rand.nextInt(); + } + strs[i] = new String(ca); + } + return strs; } /** @@ -83,20 +83,19 @@ public class Strings implements Benchmark { * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, - StreamBuffer sbuf, String[] strs, int nbatches, int ncycles) - throws Exception + StreamBuffer sbuf, String[] strs, int nbatches, int ncycles) + throws Exception { - for (int i = 0; i < nbatches; i++) { - sbuf.reset(); - oout.reset(); - for (int j = 0; j < ncycles; j++) { - oout.writeObject(strs[j]); - } - oout.flush(); - for (int j = 0; j < ncycles; j++) { - oin.readObject(); - } - } + for (int i = 0; i < nbatches; i++) { + sbuf.reset(); + oout.reset(); + for (int j = 0; j < ncycles; j++) { + oout.writeObject(strs[j]); + } + oout.flush(); + for (int j = 0; j < ncycles; j++) { + oin.readObject(); + } + } } } - diff --git a/test/java/rmi/reliability/juicer/Apple.java b/test/java/rmi/reliability/juicer/Apple.java index 10c5ba6fc6c7a4db7bad2adc95cac6f0c33f4c35..f1b6b640351dfd48d6cae1d3c656a1e9c7b52b5e 100644 --- a/test/java/rmi/reliability/juicer/Apple.java +++ b/test/java/rmi/reliability/juicer/Apple.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -25,7 +25,7 @@ import java.rmi.Remote; import java.rmi.RemoteException; /** - * A remote factory for Orange instances. This interface also + * A remote factory for Orange instances. This interface also * includes a method to test object array serialization. */ public interface Apple extends Remote { diff --git a/test/java/rmi/reliability/juicer/AppleEvent.java b/test/java/rmi/reliability/juicer/AppleEvent.java index b019e29c26f0a122e67906b0b3bcf49fa4ab7666..c76a6fd271eb7bd86e3998644ec50903706dc55c 100644 --- a/test/java/rmi/reliability/juicer/AppleEvent.java +++ b/test/java/rmi/reliability/juicer/AppleEvent.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,7 +26,7 @@ import java.util.Date; /** * The AppleEvent class is simply an object to be passed to a - * remote object exported by an applet. The intent is to verify + * remote object exported by an applet. The intent is to verify * proper object serialization of arrays. */ public class AppleEvent implements Serializable { @@ -39,24 +39,24 @@ public class AppleEvent implements Serializable { private final Date when; public AppleEvent(int what) { - this.what = what; - this.when = new Date(); + this.what = what; + this.when = new Date(); } public String toString() { - String desc = "["; - switch (what) { - case BUY: - desc += "BUY"; - break; - case EAT: - desc += "EAT"; - break; - case THROW: - desc += "THROW"; - break; - } - desc += " @ " + when + "]"; - return desc; + String desc = "["; + switch (what) { + case BUY: + desc += "BUY"; + break; + case EAT: + desc += "EAT"; + break; + case THROW: + desc += "THROW"; + break; + } + desc += " @ " + when + "]"; + return desc; } } diff --git a/test/java/rmi/reliability/juicer/AppleImpl.java b/test/java/rmi/reliability/juicer/AppleImpl.java index f8027f063eb2477b1b5c6e8a03ef96c214a8e5b8..f1f1c3ee94f7c81b025c8fe9203b737d43fca1ca 100644 --- a/test/java/rmi/reliability/juicer/AppleImpl.java +++ b/test/java/rmi/reliability/juicer/AppleImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,46 +34,46 @@ public class AppleImpl extends UnicastRemoteObject implements Apple { private static final Logger logger = Logger.getLogger("reliability.apple"); private final String name; - + public AppleImpl(String name) throws RemoteException { - this.name = name; + this.name = name; } /** * Receive an array of AppleEvent objects. */ public void notify(AppleEvent[] events) { - String threadName = Thread.currentThread().getName(); - logger.log(Level.FINEST, - threadName + ": " + toString() + ".notify: BEGIN"); + String threadName = Thread.currentThread().getName(); + logger.log(Level.FINEST, + threadName + ": " + toString() + ".notify: BEGIN"); - for (int i = 0; i < events.length; i++) { - logger.log(Level.FINEST, - threadName + ": " + toString() + ".notify(): events[" - + i + "] = " + events[i].toString()); - } + for (int i = 0; i < events.length; i++) { + logger.log(Level.FINEST, + threadName + ": " + toString() + ".notify(): events[" + + i + "] = " + events[i].toString()); + } - logger.log(Level.FINEST, - threadName + ": " + toString() + ".notify(): END"); + logger.log(Level.FINEST, + threadName + ": " + toString() + ".notify(): END"); } /** * Return a newly created and exported orange implementation. */ public Orange newOrange(String name) throws RemoteException { - String threadName = Thread.currentThread().getName(); - logger.log(Level.FINEST, - threadName + ": " + toString() + ".newOrange(" + name + "): BEGIN"); + String threadName = Thread.currentThread().getName(); + logger.log(Level.FINEST, + threadName + ": " + toString() + ".newOrange(" + name + "): BEGIN"); + + Orange orange = new OrangeImpl(name); - Orange orange = new OrangeImpl(name); - - logger.log(Level.FINEST, - threadName + ": " + toString() + ".newOrange(" + name + "): END"); + logger.log(Level.FINEST, + threadName + ": " + toString() + ".newOrange(" + name + "): END"); - return orange; + return orange; } public String toString() { - return name; + return name; } } diff --git a/test/java/rmi/reliability/juicer/AppleUser.java b/test/java/rmi/reliability/juicer/AppleUser.java index c7eb48d46b980f22f9546c759b55a330abdd452e..be86b053b12622e14b81def9f55dbba8869cc2fe 100644 --- a/test/java/rmi/reliability/juicer/AppleUser.java +++ b/test/java/rmi/reliability/juicer/AppleUser.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/java/rmi/reliability/juicer/AppleUserImpl.java b/test/java/rmi/reliability/juicer/AppleUserImpl.java index 475aca228e3f52fa0bf1d71279f2a2bc8377b7e3..d2f8b681f5b588cf8acc043568a71f7eed8707e6 100644 --- a/test/java/rmi/reliability/juicer/AppleUserImpl.java +++ b/test/java/rmi/reliability/juicer/AppleUserImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,30 +27,30 @@ * a large number of concurrent, long running, remote method invocations * between many threads which have exported remote objects. These * threads use remote objects that carry on deep "two party" - * recursion. The juicer relies on Distributed Garbage Collection to - * unexport these remote objects when no more references are held to them. + * recursion. The juicer relies on Distributed Garbage Collection to + * unexport these remote objects when no more references are held to them. * The two parties in the recursion are OrangeImpl and * OrangeEchoImpl. OrangeImpl checks the base case of the recursion * so that the program will exit. * * When the AppleUserImpl.main() method is invoked, the class binds an * instance of itself in a registry. A second server process, - * an ApplicationServer, is started which looks up the recently + * an ApplicationServer, is started which looks up the recently * bound AppleUser object. This server is either started up in * the same VM or can optionally be started in a separate VM on the - * same host or on a different host. When this test is run on the - * RMI profile, ApplicationServer must be started by AppleUserImpl + * same host or on a different host. When this test is run on the + * RMI profile, ApplicationServer must be started by AppleUserImpl * and the complete juicer runs in a single process. * * The second server process instructs the AppleUserImpl to "use" some apples. * AppleUserImpl creates a new thread for each apple. These threads * initiate the two party recursion. - * + * * Each recursive call nests to a depth determined by this - * expression: (2 + Math.abs(random.nextInt() % (maxLevel + 1)), + * expression: (2 + Math.abs(random.nextInt() % (maxLevel + 1)), * where maxLevel is a command line parameter. Thus each recursive * call nests a random number of levels between 2 and maxLevel. - * + * * The test ends when an exception is encountered or the stop time * has been reached. * @@ -81,8 +81,8 @@ import java.util.logging.Level; */ public class AppleUserImpl extends UnicastRemoteObject implements AppleUser { - private static final Logger logger = - Logger.getLogger("reliability.appleuser"); + private static final Logger logger = + Logger.getLogger("reliability.appleuser"); private static int threadNum = 0; private static long testDuration = 0; private static int maxLevel = 7; @@ -91,7 +91,7 @@ public class AppleUserImpl extends UnicastRemoteObject implements AppleUser { private static boolean startTestNotified = false; private static final Random random = new Random(); private static final Object lock = new Object(); - + public AppleUserImpl() throws RemoteException { } @@ -100,7 +100,7 @@ public class AppleUserImpl extends UnicastRemoteObject implements AppleUser { * to start "juicing". */ public synchronized void startTest() throws RemoteException { - startTestNotified = true; + startTestNotified = true; this.notifyAll(); } @@ -109,9 +109,9 @@ public class AppleUserImpl extends UnicastRemoteObject implements AppleUser { * process and thereby terminate the test. */ public void reportException(Exception status) throws RemoteException { - synchronized (lock) { - this.status = status; - lock.notifyAll(); + synchronized (lock) { + this.status = status; + lock.notifyAll(); } } @@ -120,136 +120,136 @@ public class AppleUserImpl extends UnicastRemoteObject implements AppleUser { * stress it out. */ public synchronized void useApple(Apple apple) throws RemoteException { - String threadName = Thread.currentThread().getName(); - logger.log(Level.FINEST, - threadName + ": AppleUserImpl.useApple(): BEGIN"); + String threadName = Thread.currentThread().getName(); + logger.log(Level.FINEST, + threadName + ": AppleUserImpl.useApple(): BEGIN"); - AppleUserThread t = - new AppleUserThread("AppleUserThread-" + (++threadNum), apple); - t.start(); + AppleUserThread t = + new AppleUserThread("AppleUserThread-" + (++threadNum), apple); + t.start(); - logger.log(Level.FINEST, - threadName + ": AppleUserImpl.useApple(): END"); + logger.log(Level.FINEST, + threadName + ": AppleUserImpl.useApple(): END"); } - + /** * The AppleUserThread class repeatedly invokes calls on its associated * Apple object to stress the RMI system. */ class AppleUserThread extends Thread { - final Apple apple; + final Apple apple; - public AppleUserThread(String name, Apple apple) { - super(name); - this.apple = apple; - } + public AppleUserThread(String name, Apple apple) { + super(name); + this.apple = apple; + } - public void run() { - int orangeNum = 0; + public void run() { + int orangeNum = 0; long stopTime = System.currentTimeMillis() + testDuration; Logger logger = Logger.getLogger("reliability.appleuserthread"); - - try { - do { // loop until stopTime is reached - /* - * Notify apple with some apple events. This tests + try { + do { // loop until stopTime is reached + + /* + * Notify apple with some apple events. This tests * serialization of arrays. - */ - int numEvents = Math.abs(random.nextInt() % 5); - AppleEvent[] events = new AppleEvent[numEvents]; - for (int i = 0; i < events.length; i++) { - events[i] = new AppleEvent(orangeNum % 3); - } - apple.notify(events); - - /* - * Request a new orange object be created in + */ + int numEvents = Math.abs(random.nextInt() % 5); + AppleEvent[] events = new AppleEvent[numEvents]; + for (int i = 0; i < events.length; i++) { + events[i] = new AppleEvent(orangeNum % 3); + } + apple.notify(events); + + /* + * Request a new orange object be created in * the application server. - */ - Orange orange = apple.newOrange( - "Orange(" + getName() + ")-" + (++orangeNum)); + */ + Orange orange = apple.newOrange( + "Orange(" + getName() + ")-" + (++orangeNum)); - /* - * Create a large message of random ints to pass to orange. - */ + /* + * Create a large message of random ints to pass to orange. + */ int msgLength = 1000 + Math.abs(random.nextInt() % 3000); - int[] message = new int[msgLength]; - for (int i = 0; i < message.length; i++) { - message[i] = random.nextInt(); - } + int[] message = new int[msgLength]; + for (int i = 0; i < message.length; i++) { + message[i] = random.nextInt(); + } - /* - * Invoke recursive call on the orange. Base case + /* + * Invoke recursive call on the orange. Base case * of recursion inverts messgage. - */ - OrangeEchoImpl echo = new OrangeEchoImpl( - "OrangeEcho(" + getName() + ")-" + orangeNum); - int[] response = orange.recurse(echo, message, - 2 + Math.abs(random.nextInt() % (maxLevel + 1))); - - /* - * Verify message was properly inverted and not corrupted - * through all the recursive method invocations. - */ - if (response.length != message.length) { - throw new RuntimeException( - "ERROR: CORRUPTED RESPONSE: " + - "wrong length of returned array " + "(should be " + - message.length + ", is " + response.length + ")"); - } - for (int i = 0; i < message.length; i++) { - if (~message[i] != response[i]) { - throw new RuntimeException( - "ERROR: CORRUPTED RESPONSE: " + - "at element " + i + "/" + message.length + - " of returned array (should be " + - Integer.toHexString(~message[i]) + ", is " + - Integer.toHexString(response[i]) + ")"); - } - } - - try { - Thread.sleep(Math.abs(random.nextInt() % 10) * 1000); - } catch (InterruptedException e) { - } - - } while (System.currentTimeMillis() < stopTime); - - } catch (Exception e) { - status = e; - } - finished = true; - synchronized (lock) { - lock.notifyAll(); - } - } + */ + OrangeEchoImpl echo = new OrangeEchoImpl( + "OrangeEcho(" + getName() + ")-" + orangeNum); + int[] response = orange.recurse(echo, message, + 2 + Math.abs(random.nextInt() % (maxLevel + 1))); + + /* + * Verify message was properly inverted and not corrupted + * through all the recursive method invocations. + */ + if (response.length != message.length) { + throw new RuntimeException( + "ERROR: CORRUPTED RESPONSE: " + + "wrong length of returned array " + "(should be " + + message.length + ", is " + response.length + ")"); + } + for (int i = 0; i < message.length; i++) { + if (~message[i] != response[i]) { + throw new RuntimeException( + "ERROR: CORRUPTED RESPONSE: " + + "at element " + i + "/" + message.length + + " of returned array (should be " + + Integer.toHexString(~message[i]) + ", is " + + Integer.toHexString(response[i]) + ")"); + } + } + + try { + Thread.sleep(Math.abs(random.nextInt() % 10) * 1000); + } catch (InterruptedException e) { + } + + } while (System.currentTimeMillis() < stopTime); + + } catch (Exception e) { + status = e; + } + finished = true; + synchronized (lock) { + lock.notifyAll(); + } + } } private static void usage() { - System.err.println("Usage: AppleUserImpl [-hours | " + - "-seconds ]"); - System.err.println(" [-maxLevel ]"); - System.err.println(" [-othervm]"); - System.err.println(" [-exit]"); - System.err.println(" hours The number of hours to run the juicer."); - System.err.println(" The default is 0 hours."); - System.err.println(" seconds The number of seconds to run the juicer."); - System.err.println(" The default is 0 seconds."); - System.err.println(" maxLevel The maximum number of levels to "); - System.err.println(" recurse on each call."); - System.err.println(" The default is 7 levels."); - System.err.println(" othervm If present, the VM will wait for the"); - System.err.println(" ApplicationServer to start in"); - System.err.println(" another process."); - System.err.println(" The default is to run everything in"); - System.err.println(" a single VM."); - System.err.println(" exit If present, the VM will call"); - System.err.println(" System.exit() when main() finishes."); - System.err.println(" The default is to not call"); - System.err.println(" System.exit()."); - System.err.println(); + System.err.println("Usage: AppleUserImpl [-hours | " + + "-seconds ]"); + System.err.println(" [-maxLevel ]"); + System.err.println(" [-othervm]"); + System.err.println(" [-exit]"); + System.err.println(" hours The number of hours to run the juicer."); + System.err.println(" The default is 0 hours."); + System.err.println(" seconds The number of seconds to run the juicer."); + System.err.println(" The default is 0 seconds."); + System.err.println(" maxLevel The maximum number of levels to "); + System.err.println(" recurse on each call."); + System.err.println(" The default is 7 levels."); + System.err.println(" othervm If present, the VM will wait for the"); + System.err.println(" ApplicationServer to start in"); + System.err.println(" another process."); + System.err.println(" The default is to run everything in"); + System.err.println(" a single VM."); + System.err.println(" exit If present, the VM will call"); + System.err.println(" System.exit() when main() finishes."); + System.err.println(" The default is to not call"); + System.err.println(" System.exit()."); + System.err.println(); } /** @@ -257,122 +257,122 @@ public class AppleUserImpl extends UnicastRemoteObject implements AppleUser { * an apple user implementation in an rmiregistry running on localhost. */ public static void main(String[] args) { - String durationString = null; + String durationString = null; boolean othervm = false; boolean exit = false; - try { - // parse command line args - for (int i = 0; i < args.length ; i++ ) { + try { + // parse command line args + for (int i = 0; i < args.length ; i++ ) { String arg = args[i]; if (arg.equals("-hours")) { - if (durationString != null) { - usage(); - } - i++; - int hours = Integer.parseInt(args[i]); - durationString = hours + " hours"; - testDuration = hours * 60 * 60 * 1000; + if (durationString != null) { + usage(); + } + i++; + int hours = Integer.parseInt(args[i]); + durationString = hours + " hours"; + testDuration = hours * 60 * 60 * 1000; } else if (arg.equals("-seconds")) { - if (durationString != null) { - usage(); - } - i++; - long seconds = Long.parseLong(args[i]); - durationString = seconds + " seconds"; - testDuration = seconds * 1000; + if (durationString != null) { + usage(); + } + i++; + long seconds = Long.parseLong(args[i]); + durationString = seconds + " seconds"; + testDuration = seconds * 1000; } else if (arg.equals("-maxLevel")) { - i++; - maxLevel = Integer.parseInt(args[i]); + i++; + maxLevel = Integer.parseInt(args[i]); } else if (arg.equals("-othervm")) { - othervm = true; + othervm = true; } else if (arg.equals("-exit")) { - exit = true; + exit = true; } else { - usage(); + usage(); } } if (durationString == null) { durationString = testDuration + " milliseconds"; } - } catch (Throwable t) { - usage(); - throw new RuntimeException("TEST FAILED: Bad argument"); - } - - AppleUserImpl user = null; - long startTime = 0; - Thread server = null; - int exitValue = 0; - try { - user = new AppleUserImpl(); - - synchronized (user) { - // create new registry and bind new AppleUserImpl in registry + } catch (Throwable t) { + usage(); + throw new RuntimeException("TEST FAILED: Bad argument"); + } + + AppleUserImpl user = null; + long startTime = 0; + Thread server = null; + int exitValue = 0; + try { + user = new AppleUserImpl(); + + synchronized (user) { + // create new registry and bind new AppleUserImpl in registry LocateRegistry.createRegistry(2006); LocateRegistry.getRegistry(2006).rebind("AppleUser",user); - - // start the other server if applicable - if (othervm) { - // the other server must be running in a separate process - logger.log(Level.INFO, "Application server must be " + - "started in separate process"); - } else { - Class app = Class.forName("ApplicationServer"); - server = new Thread((Runnable) app.newInstance()); - logger.log(Level.INFO, "Starting application server " + + + // start the other server if applicable + if (othervm) { + // the other server must be running in a separate process + logger.log(Level.INFO, "Application server must be " + + "started in separate process"); + } else { + Class app = Class.forName("ApplicationServer"); + server = new Thread((Runnable) app.newInstance()); + logger.log(Level.INFO, "Starting application server " + "in same process"); - server.start(); - } + server.start(); + } - // wait for other server to call startTest method - logger.log(Level.INFO, "Waiting for application server " + + // wait for other server to call startTest method + logger.log(Level.INFO, "Waiting for application server " + "process to start"); - while (!startTestNotified) { - user.wait(); - } - } - - startTime = System.currentTimeMillis(); - logger.log(Level.INFO, "Test starting"); - - // wait for exception to be reported or first thread to complete - logger.log(Level.INFO, "Waiting " + durationString + " for " + - "test to complete or exception to be thrown"); - - synchronized (lock) { - while (status == null && !finished) { - lock.wait(); - } - } - - if (status != null) { - throw new RuntimeException("TEST FAILED: " - + "juicer server reported an exception", status); - } else { - logger.log(Level.INFO, "TEST PASSED"); + while (!startTestNotified) { + user.wait(); + } } - } catch (Exception e) { - logger.log(Level.INFO, "TEST FAILED"); - exitValue = 1; - if (exit) { - e.printStackTrace(); - } - throw new RuntimeException("TEST FAILED: " - + "unexpected exception", e); - } finally { - long actualDuration = System.currentTimeMillis() - startTime; - logger.log(Level.INFO, "Test finished"); - try { - UnicastRemoteObject.unexportObject(user, true); + + startTime = System.currentTimeMillis(); + logger.log(Level.INFO, "Test starting"); + + // wait for exception to be reported or first thread to complete + logger.log(Level.INFO, "Waiting " + durationString + " for " + + "test to complete or exception to be thrown"); + + synchronized (lock) { + while (status == null && !finished) { + lock.wait(); + } + } + + if (status != null) { + throw new RuntimeException("TEST FAILED: " + + "juicer server reported an exception", status); + } else { + logger.log(Level.INFO, "TEST PASSED"); + } + } catch (Exception e) { + logger.log(Level.INFO, "TEST FAILED"); + exitValue = 1; + if (exit) { + e.printStackTrace(); + } + throw new RuntimeException("TEST FAILED: " + + "unexpected exception", e); + } finally { + long actualDuration = System.currentTimeMillis() - startTime; + logger.log(Level.INFO, "Test finished"); + try { + UnicastRemoteObject.unexportObject(user, true); } catch (NoSuchObjectException ignore) { - } - logger.log(Level.INFO, "Test duration was " + - (actualDuration/1000) + " seconds " + - "(" + (actualDuration/3600000) + " hours)"); - System.gc(); System.gc(); - if (exit) { - System.exit(exitValue); - } + } + logger.log(Level.INFO, "Test duration was " + + (actualDuration/1000) + " seconds " + + "(" + (actualDuration/3600000) + " hours)"); + System.gc(); System.gc(); + if (exit) { + System.exit(exitValue); + } } } } diff --git a/test/java/rmi/reliability/juicer/ApplicationServer.java b/test/java/rmi/reliability/juicer/ApplicationServer.java index 050da0e3b7ba200ba47740bec3e62230c13d6f65..e17528af81b9e5d04a90b5b649b5b4d988eca506 100644 --- a/test/java/rmi/reliability/juicer/ApplicationServer.java +++ b/test/java/rmi/reliability/juicer/ApplicationServer.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,7 +32,7 @@ import java.util.logging.Level; * stress test of RMI. */ public class ApplicationServer implements Runnable { - + /** number of remote Apple objects to export */ private static final Logger logger = Logger.getLogger("reliability.orange"); private static final int LOOKUP_ATTEMPTS = 5; @@ -58,102 +58,102 @@ public class ApplicationServer implements Runnable { * them with server. */ public void run() { - try { - int i = 0; + try { + int i = 0; - /* - * Locate apple user object in registry. The lookup will - * occur until it is successful or fails LOOKUP_ATTEMPTS times. - * These repeated attempts allow the ApplicationServer - * to be started before the AppleUserImpl. - */ - Exception exc = null; - for (i = 0; i < LOOKUP_ATTEMPTS; i++) { - try { - Registry registry = LocateRegistry.getRegistry( - registryHost, 2006); - user = (AppleUser) registry.lookup("AppleUser"); - user.startTest(); - break; //successfully obtained AppleUser - } catch (Exception e) { - exc = e; - Thread.sleep(10000); //sleep 10 seconds and try again - } - } - if (user == null) { - logger.log(Level.SEVERE, "Failed to lookup AppleUser:", exc); - return; - } + /* + * Locate apple user object in registry. The lookup will + * occur until it is successful or fails LOOKUP_ATTEMPTS times. + * These repeated attempts allow the ApplicationServer + * to be started before the AppleUserImpl. + */ + Exception exc = null; + for (i = 0; i < LOOKUP_ATTEMPTS; i++) { + try { + Registry registry = LocateRegistry.getRegistry( + registryHost, 2006); + user = (AppleUser) registry.lookup("AppleUser"); + user.startTest(); + break; //successfully obtained AppleUser + } catch (Exception e) { + exc = e; + Thread.sleep(10000); //sleep 10 seconds and try again + } + } + if (user == null) { + logger.log(Level.SEVERE, "Failed to lookup AppleUser:", exc); + return; + } - /* - * Create and export apple implementations. - */ - try { - for (i = 0; i < numApples; i++) { - apples[i] = new AppleImpl("AppleImpl #" + (i + 1)); - } - } catch (RemoteException e) { - logger.log(Level.SEVERE, - "Failed to create AppleImpl #" + (i + 1) + ":", e); - user.reportException(e); - return; - } + /* + * Create and export apple implementations. + */ + try { + for (i = 0; i < numApples; i++) { + apples[i] = new AppleImpl("AppleImpl #" + (i + 1)); + } + } catch (RemoteException e) { + logger.log(Level.SEVERE, + "Failed to create AppleImpl #" + (i + 1) + ":", e); + user.reportException(e); + return; + } - /* - * Hand apple objects to apple user. - */ - try { - for (i = 0; i < numApples; i++) { - user.useApple(apples[i]); + /* + * Hand apple objects to apple user. + */ + try { + for (i = 0; i < numApples; i++) { + user.useApple(apples[i]); } - } catch (RemoteException e) { - logger.log(Level.SEVERE, - "Failed to register callbacks for " + apples[i] + ":", e); - user.reportException(e); - return; - } - } catch (Exception e) { - logger.log(Level.SEVERE, "Unexpected exception:", e); - } + } catch (RemoteException e) { + logger.log(Level.SEVERE, + "Failed to register callbacks for " + apples[i] + ":", e); + user.reportException(e); + return; + } + } catch (Exception e) { + logger.log(Level.SEVERE, "Unexpected exception:", e); + } } private static void usage() { - System.err.println("Usage: ApplicationServer [-numApples ]"); - System.err.println(" [-registryHost ]"); - System.err.println(" numApples The number of apples (threads) to use."); - System.err.println(" The default is 10 apples."); - System.err.println(" host The host running rmiregistry " + - "which contains AppleUser."); - System.err.println(" The default is \"localhost\"."); - System.err.println(); + System.err.println("Usage: ApplicationServer [-numApples ]"); + System.err.println(" [-registryHost ]"); + System.err.println(" numApples The number of apples (threads) to use."); + System.err.println(" The default is 10 apples."); + System.err.println(" host The host running rmiregistry " + + "which contains AppleUser."); + System.err.println(" The default is \"localhost\"."); + System.err.println(); } public static void main(String[] args) { int num = DEFAULT_NUMAPPLES; String host = DEFAULT_REGISTRYHOST; - // parse command line args - try { + // parse command line args + try { for (int i = 0; i < args.length ; i++ ) { - String arg = args[i]; - if (arg.equals("-numApples")) { + String arg = args[i]; + if (arg.equals("-numApples")) { i++; num = Integer.parseInt(args[i]); - } else if (arg.equals("-registryHost")) { + } else if (arg.equals("-registryHost")) { i++; host = args[i]; - } else { + } else { usage(); - } + } } - } catch (Throwable t) { + } catch (Throwable t) { usage(); - throw new RuntimeException("TEST FAILED: Bad argument"); - } + throw new RuntimeException("TEST FAILED: Bad argument"); + } - // start the client server - Thread server = new Thread(new ApplicationServer(num,host)); - server.start(); - // main should exit once all exported remote objects are gc'd + // start the client server + Thread server = new Thread(new ApplicationServer(num,host)); + server.start(); + // main should exit once all exported remote objects are gc'd } } diff --git a/test/java/rmi/reliability/juicer/Orange.java b/test/java/rmi/reliability/juicer/Orange.java index 6020eae36814fdb7648978650f54740420bb3622..40e670a7ee5ef32a1290d5840d56ff4b823b0edf 100644 --- a/test/java/rmi/reliability/juicer/Orange.java +++ b/test/java/rmi/reliability/juicer/Orange.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,11 +26,11 @@ import java.rmi.RemoteException; /** * Represents one remote party of the deep 2-party recursion implemented by - * this RMI reliability test. An Orange instance recursively calls back + * this RMI reliability test. An Orange instance recursively calls back * to it's caller, typically an OrangeEcho instance. * The recursion stops when it reaches a given 'level'. */ public interface Orange extends Remote { - int[] recurse(OrangeEcho echo, int[] message, int level) - throws RemoteException; + int[] recurse(OrangeEcho echo, int[] message, int level) + throws RemoteException; } diff --git a/test/java/rmi/reliability/juicer/OrangeEcho.java b/test/java/rmi/reliability/juicer/OrangeEcho.java index 77e5d2f103f2ea9115e1a5edddf4bf72e47967cd..8077afad8bf794d06910ba49cea0a47f53566f4b 100644 --- a/test/java/rmi/reliability/juicer/OrangeEcho.java +++ b/test/java/rmi/reliability/juicer/OrangeEcho.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,11 +26,11 @@ import java.rmi.RemoteException; /** * Represents one remote party of the deep 2-party recursion implemented by - * this RMI reliability test. An OrangeEcho instance recursively calls back + * this RMI reliability test. An OrangeEcho instance recursively calls back * to it's caller, an Orange instance. * The recursion stops when it reaches a given 'level'. */ public interface OrangeEcho extends Remote { int[] recurse(Orange orange, int[] message, int level) - throws RemoteException; + throws RemoteException; } diff --git a/test/java/rmi/reliability/juicer/OrangeEchoImpl.java b/test/java/rmi/reliability/juicer/OrangeEchoImpl.java index 494bf1914fafae267bd6c72b25ea729631040063..5472138bd318eb7b7e0f2c0c7c5d6bc636bf4df9 100644 --- a/test/java/rmi/reliability/juicer/OrangeEchoImpl.java +++ b/test/java/rmi/reliability/juicer/OrangeEchoImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,12 +33,12 @@ import java.util.logging.Level; */ public class OrangeEchoImpl extends UnicastRemoteObject implements OrangeEcho { - private static final Logger logger = - Logger.getLogger("reliability.orangeecho"); + private static final Logger logger = + Logger.getLogger("reliability.orangeecho"); private final String name; public OrangeEchoImpl(String name) throws RemoteException { - this.name = name; + this.name = name; } /** @@ -46,24 +46,24 @@ public class OrangeEchoImpl extends UnicastRemoteObject implements OrangeEcho { * with the same message data and a decremented recursion level. */ public int[] recurse(Orange orange, int[] message, int level) - throws RemoteException + throws RemoteException { - String threadName = Thread.currentThread().getName(); + String threadName = Thread.currentThread().getName(); - logger.log(Level.FINEST, - threadName + ": " + toString() + ".recurse(message[" - + message.length + "], " + level + "): BEGIN"); + logger.log(Level.FINEST, + threadName + ": " + toString() + ".recurse(message[" + + message.length + "], " + level + "): BEGIN"); - int[] response = orange.recurse(this, message, level - 1); + int[] response = orange.recurse(this, message, level - 1); - logger.log(Level.FINEST, - threadName + ": " + toString() + ".recurse(message[" - + message.length + "], " + level + "): END"); + logger.log(Level.FINEST, + threadName + ": " + toString() + ".recurse(message[" + + message.length + "], " + level + "): END"); - return response; + return response; } public String toString() { - return name; + return name; } } diff --git a/test/java/rmi/reliability/juicer/OrangeImpl.java b/test/java/rmi/reliability/juicer/OrangeImpl.java index 876617e1acb0e1bce1edee709b781a97ab315f9f..9643ca52fea48295127d8b0a3f54ba2fbeac598e 100644 --- a/test/java/rmi/reliability/juicer/OrangeImpl.java +++ b/test/java/rmi/reliability/juicer/OrangeImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,7 +36,7 @@ public class OrangeImpl extends UnicastRemoteObject implements Orange { private final String name; public OrangeImpl(String name) throws RemoteException { - this.name = name; + this.name = name; } /** @@ -44,31 +44,31 @@ public class OrangeImpl extends UnicastRemoteObject implements Orange { * object if not at recursion level zero. */ public int[] recurse(OrangeEcho echo, int[] message, int level) - throws RemoteException + throws RemoteException { - String threadName = Thread.currentThread().getName(); - logger.log(Level.FINEST, - threadName + ": " + toString() + ".recurse(message[" - + message.length + "], " + level + "): BEGIN"); + String threadName = Thread.currentThread().getName(); + logger.log(Level.FINEST, + threadName + ": " + toString() + ".recurse(message[" + + message.length + "], " + level + "): BEGIN"); - int[] response; - if (level > 0) { - response = echo.recurse(this, message, level); - } else { - for (int i = 0; i < message.length; i++) { - message[i] = ~message[i]; - } - response = message; - } + int[] response; + if (level > 0) { + response = echo.recurse(this, message, level); + } else { + for (int i = 0; i < message.length; i++) { + message[i] = ~message[i]; + } + response = message; + } - logger.log(Level.FINEST, - threadName + ": " + toString() + ".recurse(message[" - + message.length + "], " + level + "): END"); + logger.log(Level.FINEST, + threadName + ": " + toString() + ".recurse(message[" + + message.length + "], " + level + "): END"); - return response; + return response; } public String toString() { - return name; + return name; } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressConstants.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressConstants.java index 7db4a6b9c8a83b3493466b16d2e3a98cef41cc9f..cc7526077d8c7510487fe5163d10216938918b08 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressConstants.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressConstants.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,9 +27,9 @@ interface CompressConstants { // constants for 6-bit code values - static final int NOP = 0; // no operation: used to pad words on flush() - static final int RAW = 1; // introduces raw byte format - static final int BASE = 2; // base for codes found in lookup table + static final int NOP = 0; // no operation: used to pad words on flush() + static final int RAW = 1; // introduces raw byte format + static final int BASE = 2; // base for codes found in lookup table static final String codeTable = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ,.!?\"'()"; + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ,.!?\"'()"; } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressInputStream.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressInputStream.java index 3a42bb180733f35f4524848a927853c49639ce5e..31577a1c2adad42cdb2cfa3a441c21378ceef53f 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressInputStream.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressInputStream.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -31,7 +31,7 @@ class CompressInputStream extends FilterInputStream { public CompressInputStream(InputStream in) { - super(in); + super(in); } // buffer of unpacked 6-bit codes from last 32-word read @@ -41,70 +41,70 @@ class CompressInputStream extends FilterInputStream int bufPos = 5; public int read() throws IOException { - try { - int code; - do { - code = readCode(); - } while (code == NOP); // ignore NOP codes + try { + int code; + do { + code = readCode(); + } while (code == NOP); // ignore NOP codes - if (code >= BASE) - return codeTable.charAt(code - BASE); - else if (code == RAW) { - int high = readCode(); - int low = readCode(); - return (high << 4) | low; - } else - throw new IOException("unknown compression code: " + code); - } catch (EOFException e) { - return -1; - } + if (code >= BASE) + return codeTable.charAt(code - BASE); + else if (code == RAW) { + int high = readCode(); + int low = readCode(); + return (high << 4) | low; + } else + throw new IOException("unknown compression code: " + code); + } catch (EOFException e) { + return -1; + } } public int read(byte b[], int off, int len) throws IOException { - if (len <= 0) { - return 0; - } + if (len <= 0) { + return 0; + } - int c = read(); - if (c == -1) { - return -1; - } - b[off] = (byte)c; + int c = read(); + if (c == -1) { + return -1; + } + b[off] = (byte)c; - int i = 1; + int i = 1; /***** - try { - for (; i < len ; i++) { - c = read(); - if (c == -1) { - break; - } - if (b != null) { - b[off + i] = (byte)c; - } - } - } catch (IOException ee) { - } + try { + for (; i < len ; i++) { + c = read(); + if (c == -1) { + break; + } + if (b != null) { + b[off + i] = (byte)c; + } + } + } catch (IOException ee) { + } *****/ - return i; + return i; } private int readCode() throws IOException { - if (bufPos == 5) { - int b1 = in.read(); - int b2 = in.read(); - int b3 = in.read(); - int b4 = in.read(); - if ((b1 | b2 | b3 | b4) < 0) - throw new EOFException(); - int pack = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; - buf[0] = (pack >>> 24) & 0x3F; - buf[1] = (pack >>> 18) & 0x3F; - buf[2] = (pack >>> 12) & 0x3F; - buf[3] = (pack >>> 6) & 0x3F; - buf[4] = (pack >>> 0) & 0x3F; - bufPos = 0; - } - return buf[bufPos++]; + if (bufPos == 5) { + int b1 = in.read(); + int b2 = in.read(); + int b3 = in.read(); + int b4 = in.read(); + if ((b1 | b2 | b3 | b4) < 0) + throw new EOFException(); + int pack = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; + buf[0] = (pack >>> 24) & 0x3F; + buf[1] = (pack >>> 18) & 0x3F; + buf[2] = (pack >>> 12) & 0x3F; + buf[3] = (pack >>> 6) & 0x3F; + buf[4] = (pack >>> 0) & 0x3F; + bufPos = 0; + } + return buf[bufPos++]; } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressOutputStream.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressOutputStream.java index ca1a5963f959a40ff9445b715f077bbf55f7b5cf..5d38e147b18f9f895ecbfb9f14d922ded390c068 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressOutputStream.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressOutputStream.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -31,7 +31,7 @@ class CompressOutputStream extends FilterOutputStream { public CompressOutputStream(OutputStream out) { - super(out); + super(out); } // buffer of 6-bit codes to pack into next 32-bit word @@ -41,44 +41,44 @@ class CompressOutputStream extends FilterOutputStream int bufPos = 0; public void write(int b) throws IOException { - b &= 0xFF; // force argument to a byte + b &= 0xFF; // force argument to a byte - int pos = codeTable.indexOf((char)b); - if (pos != -1) - writeCode(BASE + pos); - else { - writeCode(RAW); - writeCode(b >> 4); - writeCode(b & 0xF); - } + int pos = codeTable.indexOf((char)b); + if (pos != -1) + writeCode(BASE + pos); + else { + writeCode(RAW); + writeCode(b >> 4); + writeCode(b & 0xF); + } } public void write(byte b[], int off, int len) throws IOException { - /* - * This is quite an inefficient implementation, because it has to - * call the other write method for every byte in the array. It + /* + * This is quite an inefficient implementation, because it has to + * call the other write method for every byte in the array. It * could be optimized for performance by doing all the processing - * in this method. - */ - for (int i = 0; i < len; i++) - write(b[off + i]); + * in this method. + */ + for (int i = 0; i < len; i++) + write(b[off + i]); } public void flush() throws IOException { - while (bufPos > 0) - writeCode(NOP); + while (bufPos > 0) + writeCode(NOP); } private void writeCode(int c) throws IOException { - buf[bufPos++] = c; - if (bufPos == 5) { // write next word when we have 5 codes - int pack = (buf[0] << 24) | (buf[1] << 18) | (buf[2] << 12) | - (buf[3] << 6) | buf[4]; - out.write((pack >>> 24) & 0xFF); - out.write((pack >>> 16) & 0xFF); - out.write((pack >>> 8) & 0xFF); - out.write((pack >>> 0) & 0xFF); - bufPos = 0; - } + buf[bufPos++] = c; + if (bufPos == 5) { // write next word when we have 5 codes + int pack = (buf[0] << 24) | (buf[1] << 18) | (buf[2] << 12) | + (buf[3] << 6) | buf[4]; + out.write((pack >>> 24) & 0xFF); + out.write((pack >>> 16) & 0xFF); + out.write((pack >>> 8) & 0xFF); + out.write((pack >>> 0) & 0xFF); + bufPos = 0; + } } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/Echo.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/Echo.java index b313a906dc21a2d45e7d08c73b5d6f04ea5a160a..074781b2559dd3d940bc17f1d1ccf6ac14edf0d3 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/Echo.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/Echo.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl.java index ee01472f7eb5832433f7b7d130f661ee46bf4001..7b334fe0375be3272a669c7f8604e05fd81d9920 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,49 +39,49 @@ public class EchoImpl * Initialization constructor. */ public EchoImpl(String protocol) - throws ActivationException, RemoteException + throws ActivationException, RemoteException { - super(null, makeMarshalledObject(protocol), false, 0, - new MultiSocketFactory.ClientFactory(protocol, pattern), - new MultiSocketFactory.ServerFactory(protocol, pattern)); + super(null, makeMarshalledObject(protocol), false, 0, + new MultiSocketFactory.ClientFactory(protocol, pattern), + new MultiSocketFactory.ServerFactory(protocol, pattern)); } /** * Activation constructor. */ public EchoImpl(ActivationID id, MarshalledObject obj) - throws RemoteException + throws RemoteException { - super(id, 0, - new MultiSocketFactory.ClientFactory(getProtocol(obj), pattern), - new MultiSocketFactory.ServerFactory(getProtocol(obj), pattern)); + super(id, 0, + new MultiSocketFactory.ClientFactory(getProtocol(obj), pattern), + new MultiSocketFactory.ServerFactory(getProtocol(obj), pattern)); } private static MarshalledObject makeMarshalledObject(String protocol) { - MarshalledObject obj = null; - try { - obj = new MarshalledObject(protocol); - } catch (Exception willNotHappen) { - } + MarshalledObject obj = null; + try { + obj = new MarshalledObject(protocol); + } catch (Exception willNotHappen) { + } - return obj; + return obj; } private static String getProtocol(MarshalledObject obj) { - String protocol = ""; - try { - protocol = (String) obj.get(); - } catch (Exception willNotHappen) { - } + String protocol = ""; + try { + protocol = (String) obj.get(); + } catch (Exception willNotHappen) { + } - return protocol; + return protocol; } - + public byte[] echoNot(byte[] data) { - byte[] result = new byte[data.length]; - for (int i = 0; i < data.length; i++) - result[i] = (byte) ~data[i]; - return result; + byte[] result = new byte[data.length]; + for (int i = 0; i < data.length; i++) + result[i] = (byte) ~data[i]; + return result; } /** @@ -89,7 +89,7 @@ public class EchoImpl */ public void shutdown() throws Exception { - (new Thread(this,"Echo.shutdown")).start(); + (new Thread(this,"Echo.shutdown")).start(); } /** @@ -98,43 +98,43 @@ public class EchoImpl * object may still have pending/executing calls), then * unexport the object forcibly. */ - public void run() + public void run() { - ActivationLibrary.deactivate(this, getID()); + ActivationLibrary.deactivate(this, getID()); } public static void main(String[] args) { - /* - * The following line is required with the JDK 1.2 VM so that the - * VM can exit gracefully when this test completes. Otherwise, the - * conservative garbage collector will find a handle to the server - * object on the native stack and not clear the weak reference to - * it in the RMI runtime's object table. - */ - Object dummy = new Object(); - - System.setSecurityManager(new RMISecurityManager()); - - try { - String protocol = ""; - if (args.length >= 1) - protocol = args[0]; - - System.out.println("EchoServer: creating remote object"); - ActivationGroupDesc groupDesc = - new ActivationGroupDesc(null, null); - ActivationSystem system = ActivationGroup.getSystem(); - ActivationGroupID groupID = system.registerGroup(groupDesc); - ActivationGroup.createGroup(groupID, groupDesc, 0); - - EchoImpl impl = new EchoImpl(protocol); - System.out.println("EchoServer: binding in registry"); - Naming.rebind("//:" + UseCustomSocketFactory.REGISTRY_PORT + - "/EchoServer", impl); - System.out.println("EchoServer ready."); - } catch (Exception e) { - System.err.println("EXCEPTION OCCURRED:"); - e.printStackTrace(); - } + /* + * The following line is required with the JDK 1.2 VM so that the + * VM can exit gracefully when this test completes. Otherwise, the + * conservative garbage collector will find a handle to the server + * object on the native stack and not clear the weak reference to + * it in the RMI runtime's object table. + */ + Object dummy = new Object(); + + System.setSecurityManager(new RMISecurityManager()); + + try { + String protocol = ""; + if (args.length >= 1) + protocol = args[0]; + + System.out.println("EchoServer: creating remote object"); + ActivationGroupDesc groupDesc = + new ActivationGroupDesc(null, null); + ActivationSystem system = ActivationGroup.getSystem(); + ActivationGroupID groupID = system.registerGroup(groupDesc); + ActivationGroup.createGroup(groupID, groupDesc, 0); + + EchoImpl impl = new EchoImpl(protocol); + System.out.println("EchoServer: binding in registry"); + Naming.rebind("//:" + UseCustomSocketFactory.REGISTRY_PORT + + "/EchoServer", impl); + System.out.println("EchoServer ready."); + } catch (Exception e) { + System.err.println("EXCEPTION OCCURRED:"); + e.printStackTrace(); + } } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl_Stub.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl_Stub.java index 5ff9b36e12f3afa1279fdfa088a860bb27eb8a73..134446486fd3a4879df32a3e553953781ad767c6 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl_Stub.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,47 +29,47 @@ public final class EchoImpl_Stub implements Echo, java.rmi.Remote { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_echoNot_0; private static java.lang.reflect.Method $method_shutdown_1; - + static { - try { - $method_echoNot_0 = Echo.class.getMethod("echoNot", new java.lang.Class[] {byte[].class}); - $method_shutdown_1 = Echo.class.getMethod("shutdown", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_echoNot_0 = Echo.class.getMethod("echoNot", new java.lang.Class[] {byte[].class}); + $method_shutdown_1 = Echo.class.getMethod("shutdown", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public EchoImpl_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of echoNot(byte[]) public byte[] echoNot(byte[] $param_arrayOf_byte_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - Object $result = ref.invoke(this, $method_echoNot_0, new java.lang.Object[] {$param_arrayOf_byte_1}, -4295721514897591756L); - return ((byte[]) $result); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + Object $result = ref.invoke(this, $method_echoNot_0, new java.lang.Object[] {$param_arrayOf_byte_1}, -4295721514897591756L); + return ((byte[]) $result); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of shutdown() public void shutdown() - throws java.lang.Exception + throws java.lang.Exception { - ref.invoke(this, $method_shutdown_1, null, -7207851917985848402L); + ref.invoke(this, $method_shutdown_1, null, -7207851917985848402L); } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/MultiSocketFactory.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/MultiSocketFactory.java index f8ef69fac1c647a75639c831703a041fd5247600..9ebfa3236e016d8301c187774935cac079bb95b6 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/MultiSocketFactory.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/MultiSocketFactory.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,194 +34,193 @@ import java.util.zip.*; public class MultiSocketFactory { private static RMISocketFactory def = - RMISocketFactory.getDefaultSocketFactory(); + RMISocketFactory.getDefaultSocketFactory(); + - public static class ServerFactory - implements RMIServerSocketFactory, Serializable + implements RMIServerSocketFactory, Serializable { - private String protocol; - private byte[] data; - - public ServerFactory(String protocol, byte[] data) { - this.protocol = protocol; - this.data = data; - } - - public ServerSocket createServerSocket(int port) throws IOException - { - if (protocol.equals("compress")) { - return new CompressServerSocket(port); - - } else if (protocol.equals("xor")) { - if (data == null || data.length != 1) - throw new IOException("invalid argument for XOR protocol"); - return new XorServerSocket(port, data[0]); - - } - - return def.createServerSocket(port); - } + private String protocol; + private byte[] data; + + public ServerFactory(String protocol, byte[] data) { + this.protocol = protocol; + this.data = data; + } + + public ServerSocket createServerSocket(int port) throws IOException + { + if (protocol.equals("compress")) { + return new CompressServerSocket(port); + + } else if (protocol.equals("xor")) { + if (data == null || data.length != 1) + throw new IOException("invalid argument for XOR protocol"); + return new XorServerSocket(port, data[0]); + + } + + return def.createServerSocket(port); + } } public static class ClientFactory - implements RMIClientSocketFactory, Serializable + implements RMIClientSocketFactory, Serializable { - private String protocol; - private byte[] data; - - public ClientFactory(String protocol, byte[] data) { - this.protocol = protocol; - this.data = data; - } - - public Socket createSocket(String host, int port) - throws IOException - { - if (protocol.equals("compress")) { - return new CompressSocket(host, port); - - } else if (protocol.equals("xor")) { - if (data == null || data.length != 1) - throw new IOException("invalid argument for XOR protocol"); - return new XorSocket(host, port, data[0]); - - } - - return def.createSocket(host, port); - } + private String protocol; + private byte[] data; + + public ClientFactory(String protocol, byte[] data) { + this.protocol = protocol; + this.data = data; + } + + public Socket createSocket(String host, int port) + throws IOException + { + if (protocol.equals("compress")) { + return new CompressSocket(host, port); + + } else if (protocol.equals("xor")) { + if (data == null || data.length != 1) + throw new IOException("invalid argument for XOR protocol"); + return new XorSocket(host, port, data[0]); + + } + + return def.createSocket(host, port); + } } static class CompressSocket extends Socket { - private InputStream in; - private OutputStream out; - public CompressSocket() { super(); } - public CompressSocket(String host, int port) throws IOException { - super(host, port); - } - public InputStream getInputStream() throws IOException { - if (in == null) { - in = new CompressInputStream(super.getInputStream()); - } - return in; - } - public OutputStream getOutputStream() throws IOException { - if (out == null) { - out = new CompressOutputStream(super.getOutputStream()); - } - return out; - } + private InputStream in; + private OutputStream out; + public CompressSocket() { super(); } + public CompressSocket(String host, int port) throws IOException { + super(host, port); + } + public InputStream getInputStream() throws IOException { + if (in == null) { + in = new CompressInputStream(super.getInputStream()); + } + return in; + } + public OutputStream getOutputStream() throws IOException { + if (out == null) { + out = new CompressOutputStream(super.getOutputStream()); + } + return out; + } } static class CompressServerSocket extends ServerSocket { - public CompressServerSocket(int port) throws IOException { - super(port); - } - public Socket accept() throws IOException { - Socket s = new CompressSocket(); - implAccept(s); - return s; - } + public CompressServerSocket(int port) throws IOException { + super(port); + } + public Socket accept() throws IOException { + Socket s = new CompressSocket(); + implAccept(s); + return s; + } } static class XorSocket extends Socket { - private byte pattern; - private InputStream in; - private OutputStream out; - public XorSocket(byte pattern) { super(); this.pattern = pattern; } - public XorSocket(String host, int port, byte pattern) - throws IOException - { - super(host, port); - this.pattern = pattern; - } - public InputStream getInputStream() throws IOException { - if (in == null) { - in = new XorInputStream(super.getInputStream(), pattern); - } - return in; - } - public OutputStream getOutputStream() throws IOException { - if (out == null) { - out = new XorOutputStream(super.getOutputStream(), pattern); - } - return out; - } + private byte pattern; + private InputStream in; + private OutputStream out; + public XorSocket(byte pattern) { super(); this.pattern = pattern; } + public XorSocket(String host, int port, byte pattern) + throws IOException + { + super(host, port); + this.pattern = pattern; + } + public InputStream getInputStream() throws IOException { + if (in == null) { + in = new XorInputStream(super.getInputStream(), pattern); + } + return in; + } + public OutputStream getOutputStream() throws IOException { + if (out == null) { + out = new XorOutputStream(super.getOutputStream(), pattern); + } + return out; + } } static class XorServerSocket extends ServerSocket { - private byte pattern; - public XorServerSocket(int port, byte pattern) throws IOException { - super(port); - this.pattern = pattern; - } - public Socket accept() throws IOException { - Socket s = new XorSocket(pattern); - implAccept(s); - return s; - } + private byte pattern; + public XorServerSocket(int port, byte pattern) throws IOException { + super(port); + this.pattern = pattern; + } + public Socket accept() throws IOException { + Socket s = new XorSocket(pattern); + implAccept(s); + return s; + } } static class XorOutputStream extends FilterOutputStream { - private byte pattern; - public XorOutputStream(OutputStream out, byte pattern) { - super(out); - this.pattern = pattern; - } - public void write(int b) throws IOException { - out.write(b ^ pattern); - out.flush(); - } - public void write(byte b[], int off, int len) throws IOException { - for (int i = 0; i < len; i++) - write(b[off + i]); - } + private byte pattern; + public XorOutputStream(OutputStream out, byte pattern) { + super(out); + this.pattern = pattern; + } + public void write(int b) throws IOException { + out.write(b ^ pattern); + out.flush(); + } + public void write(byte b[], int off, int len) throws IOException { + for (int i = 0; i < len; i++) + write(b[off + i]); + } } static class XorInputStream extends FilterInputStream { - private byte pattern; - public XorInputStream(InputStream in, byte pattern) { - super(in); - this.pattern = pattern; - } - public int read() throws IOException { - int b = in.read(); -// System.out.print("BEFORE: " + Integer.toHexString(b)); - if (b != -1) - b = (b ^ pattern) & 0xFF; -// System.out.println("\tAFTER: " + Integer.toHexString(b)); - return b; - } - public int read(byte b[], int off, int len) throws IOException { - if (len <= 0) { - return 0; - } - - int c = read(); - if (c == -1) { - return -1; - } - b[off] = (byte)c; - - int i = 1; + private byte pattern; + public XorInputStream(InputStream in, byte pattern) { + super(in); + this.pattern = pattern; + } + public int read() throws IOException { + int b = in.read(); +// System.out.print("BEFORE: " + Integer.toHexString(b)); + if (b != -1) + b = (b ^ pattern) & 0xFF; +// System.out.println("\tAFTER: " + Integer.toHexString(b)); + return b; + } + public int read(byte b[], int off, int len) throws IOException { + if (len <= 0) { + return 0; + } + + int c = read(); + if (c == -1) { + return -1; + } + b[off] = (byte)c; + + int i = 1; /***** - try { - for (; i < len ; i++) { - c = read(); - if (c == -1) { - break; - } - if (b != null) { - b[off + i] = (byte)c; - } - } - } catch (IOException ee) { - } + try { + for (; i < len ; i++) { + c = read(); + if (c == -1) { + break; + } + if (b != null) { + b[off + i] = (byte)c; + } + } + } catch (IOException ee) { + } *****/ - return i; - } + return i; + } } } - diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java index 7fbcd7f30188fdf96082b6bb3d05e396740f3fd9..b3e7a77b99b838933f68da462d59d03b12022a0d 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -45,124 +45,124 @@ public class UseCustomSocketFactory { final static int REGISTRY_PORT = 2006; static String[] protocol = new String[] { "", "compress", "xor" }; - + public static void main(String[] args) { - System.out.println("\nRegression test for bug 4115696\n"); - - TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); - - try { - LocateRegistry.createRegistry(REGISTRY_PORT); - } catch (Exception e) { - TestLibrary.bomb("creating registry", e); - } - - RMID rmid = null; - - try { - rmid = RMID.createRMID(true); - rmid.addArguments(new String[] { - "-C-Djava.security.policy=" + - TestParams.defaultGroupPolicy + - " -C-Djava.security.manager=java.rmi.RMISecurityManager "}); - rmid.start(); - - Echo[] echo = spawnAndTest(); - reactivateAndTest(echo); - } catch (IOException e) { - TestLibrary.bomb("creating rmid", e); - } finally { - if (rmid != null) - rmid.destroy(); - } + System.out.println("\nRegression test for bug 4115696\n"); + + TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); + + try { + LocateRegistry.createRegistry(REGISTRY_PORT); + } catch (Exception e) { + TestLibrary.bomb("creating registry", e); + } + + RMID rmid = null; + + try { + rmid = RMID.createRMID(true); + rmid.addArguments(new String[] { + "-C-Djava.security.policy=" + + TestParams.defaultGroupPolicy + + " -C-Djava.security.manager=java.rmi.RMISecurityManager "}); + rmid.start(); + + Echo[] echo = spawnAndTest(); + reactivateAndTest(echo); + } catch (IOException e) { + TestLibrary.bomb("creating rmid", e); + } finally { + if (rmid != null) + rmid.destroy(); + } } private static Echo[] spawnAndTest() { - - System.err.println("\nCreate Test-->"); - - Echo[] echo = new Echo[protocol.length]; - - for (int i = 0; i < protocol.length; i++) { - - JavaVM serverVM = new JavaVM("EchoImpl", - "-Djava.security.policy=" + - TestParams.defaultPolicy, - protocol[i]); - - System.err.println("\nusing protocol: " + - (protocol[i] == "" ? "none" : protocol[i])); - - try { - /* spawn VM for EchoServer */ - serverVM.start(); - - /* lookup server */ - int tries = 12; // need enough tries for slow machine. - echo[i] = null; - do { - try { - echo[i] = (Echo) Naming.lookup("//:" + REGISTRY_PORT + - "/EchoServer"); - break; - } catch (NotBoundException e) { - try { - Thread.sleep(2000); - } catch (Exception ignore) { - } - continue; - } - } while (--tries > 0); - - if (echo[i] == null) - TestLibrary.bomb("server not bound in 12 tries", null); - - /* invoke remote method and print result*/ - System.err.println("Bound to " + echo[i]); - byte[] data = ("Greetings, citizen " + - System.getProperty("user.name") + "!"). getBytes(); - byte[] result = echo[i].echoNot(data); - for (int j = 0; j < result.length; j++) - result[j] = (byte) ~result[j]; - System.err.println("Result: " + new String(result)); - echo[i].shutdown(); - - } catch (Exception e) { - TestLibrary.bomb("test failed", e); - - } finally { - serverVM.destroy(); - try { - Naming.unbind("//:" + REGISTRY_PORT + "/EchoServer"); - } catch (Exception e) { - TestLibrary.bomb("unbinding EchoServer", e); - - } - } - } - return echo; + + System.err.println("\nCreate Test-->"); + + Echo[] echo = new Echo[protocol.length]; + + for (int i = 0; i < protocol.length; i++) { + + JavaVM serverVM = new JavaVM("EchoImpl", + "-Djava.security.policy=" + + TestParams.defaultPolicy, + protocol[i]); + + System.err.println("\nusing protocol: " + + (protocol[i] == "" ? "none" : protocol[i])); + + try { + /* spawn VM for EchoServer */ + serverVM.start(); + + /* lookup server */ + int tries = 12; // need enough tries for slow machine. + echo[i] = null; + do { + try { + echo[i] = (Echo) Naming.lookup("//:" + REGISTRY_PORT + + "/EchoServer"); + break; + } catch (NotBoundException e) { + try { + Thread.sleep(2000); + } catch (Exception ignore) { + } + continue; + } + } while (--tries > 0); + + if (echo[i] == null) + TestLibrary.bomb("server not bound in 12 tries", null); + + /* invoke remote method and print result*/ + System.err.println("Bound to " + echo[i]); + byte[] data = ("Greetings, citizen " + + System.getProperty("user.name") + "!"). getBytes(); + byte[] result = echo[i].echoNot(data); + for (int j = 0; j < result.length; j++) + result[j] = (byte) ~result[j]; + System.err.println("Result: " + new String(result)); + echo[i].shutdown(); + + } catch (Exception e) { + TestLibrary.bomb("test failed", e); + + } finally { + serverVM.destroy(); + try { + Naming.unbind("//:" + REGISTRY_PORT + "/EchoServer"); + } catch (Exception e) { + TestLibrary.bomb("unbinding EchoServer", e); + + } + } + } + return echo; } private static void reactivateAndTest(Echo[] echo) { - System.err.println("\nReactivate Test-->"); - - for (int i = 0; i < echo.length; i++) { - try { - System.err.println("\nusing protocol: " + - (protocol[i] == "" ? "none" : protocol[i])); - byte[] data = ("Greetings, citizen " + - System.getProperty("user.name") + "!").getBytes(); - byte[] result = echo[i].echoNot(data); - for (int j = 0; j < result.length; j++) - result[j] = (byte) ~result[j]; - System.err.println("Result: " + new String(result)); - echo[i].shutdown(); - } catch (Exception e) { - TestLibrary.bomb("activating EchoServer for protocol " + protocol[i], e); - } - } + System.err.println("\nReactivate Test-->"); + + for (int i = 0; i < echo.length; i++) { + try { + System.err.println("\nusing protocol: " + + (protocol[i] == "" ? "none" : protocol[i])); + byte[] data = ("Greetings, citizen " + + System.getProperty("user.name") + "!").getBytes(); + byte[] result = echo[i].echoNot(data); + for (int j = 0; j < result.length; j++) + result[j] = (byte) ~result[j]; + System.err.println("Result: " + new String(result)); + echo[i].shutdown(); + } catch (Exception e) { + TestLibrary.bomb("activating EchoServer for protocol " + protocol[i], e); + } + } } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Compress.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Compress.java index 67bcf970a0bf14dee869afd600fd57982f9e337b..88057b954a0121d04529531112c688d03d20a06f 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Compress.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Compress.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -31,204 +31,204 @@ import java.net.*; public class Compress { interface CompressConstants { - // constants for 6-bit code values - static final int NOP = 0; // no operation: used to pad words on flush() - static final int RAW = 1; // introduces raw byte format - static final int BASE = 2; // base for codes found in lookup table - static final String codeTable = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ,.!?\"'()"; + // constants for 6-bit code values + static final int NOP = 0; // no operation: used to pad words on flush() + static final int RAW = 1; // introduces raw byte format + static final int BASE = 2; // base for codes found in lookup table + static final String codeTable = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ,.!?\"'()"; } - - public static class CompressRMIClientSocketFactory - implements java.rmi.server.RMIClientSocketFactory, Serializable { - - public Socket createSocket(String host, int port) - throws IOException { - - return ((Socket) new CompressSocket(host, port)); - } + + public static class CompressRMIClientSocketFactory + implements java.rmi.server.RMIClientSocketFactory, Serializable { + + public Socket createSocket(String host, int port) + throws IOException { + + return ((Socket) new CompressSocket(host, port)); + } } - public static class CompressRMIServerSocketFactory - implements RMIServerSocketFactory, - Serializable { - - public ServerSocket createServerSocket(int port) - throws IOException { + public static class CompressRMIServerSocketFactory + implements RMIServerSocketFactory, + Serializable { - return ((ServerSocket) new CompressServerSocket(port)); - } + public ServerSocket createServerSocket(int port) + throws IOException { + + return ((ServerSocket) new CompressServerSocket(port)); + } } - + public static class CompressSocket extends Socket { - private InputStream in; - private OutputStream out; - public CompressSocket() { super(); } - public CompressSocket(String host, int port) throws IOException { - super(host, port); - } - public InputStream getInputStream() throws IOException { - if (in == null) { - in = new CompressInputStream(super.getInputStream()); - } - return in; - } - public OutputStream getOutputStream() throws IOException { - if (out == null) { - out = new CompressOutputStream(super.getOutputStream()); - } - return out; - } + private InputStream in; + private OutputStream out; + public CompressSocket() { super(); } + public CompressSocket(String host, int port) throws IOException { + super(host, port); + } + public InputStream getInputStream() throws IOException { + if (in == null) { + in = new CompressInputStream(super.getInputStream()); + } + return in; + } + public OutputStream getOutputStream() throws IOException { + if (out == null) { + out = new CompressOutputStream(super.getOutputStream()); + } + return out; + } } public static class CompressServerSocket extends ServerSocket { - public CompressServerSocket(int port) throws IOException { - super(port); - } - public Socket accept() throws IOException { - Socket s = new CompressSocket(); - implAccept(s); - return s; - } + public CompressServerSocket(int port) throws IOException { + super(port); + } + public Socket accept() throws IOException { + Socket s = new CompressSocket(); + implAccept(s); + return s; + } } public static class CompressInputStream extends FilterInputStream - implements CompressConstants + implements CompressConstants { - - public CompressInputStream(InputStream in) { - super(in); - } - - // buffer of unpacked 6-bit codes from last 32-word read - int buf[] = new int[5]; - - // position of next code to read in buffer (5 == end of buffer) - int bufPos = 5; - - public int read() throws IOException { - try { - int code; - do { - code = readCode(); - } while (code == NOP); // ignore NOP codes - - if (code >= BASE) - return codeTable.charAt(code - BASE); - else if (code == RAW) { - int high = readCode(); - int low = readCode(); - return (high << 4) | low; - } else - throw new IOException("unknown compression code: " + code); - } catch (EOFException e) { - return -1; - } - } - - public int read(byte b[], int off, int len) throws IOException { - if (len <= 0) { - return 0; - } - - int c = read(); - if (c == -1) { - return -1; - } - b[off] = (byte)c; - - int i = 1; - /***** - try { - for (; i < len ; i++) { - c = read(); - if (c == -1) { - break; - } - if (b != null) { - b[off + i] = (byte)c; - } - } - } catch (IOException ee) { - } - *****/ - return i; - } - - private int readCode() throws IOException { - if (bufPos == 5) { - int b1 = in.read(); - int b2 = in.read(); - int b3 = in.read(); - int b4 = in.read(); - if ((b1 | b2 | b3 | b4) < 0) - throw new EOFException(); - int pack = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; - buf[0] = (pack >>> 24) & 0x3F; - buf[1] = (pack >>> 18) & 0x3F; - buf[2] = (pack >>> 12) & 0x3F; - buf[3] = (pack >>> 6) & 0x3F; - buf[4] = (pack >>> 0) & 0x3F; - bufPos = 0; - } - return buf[bufPos++]; - } + + public CompressInputStream(InputStream in) { + super(in); + } + + // buffer of unpacked 6-bit codes from last 32-word read + int buf[] = new int[5]; + + // position of next code to read in buffer (5 == end of buffer) + int bufPos = 5; + + public int read() throws IOException { + try { + int code; + do { + code = readCode(); + } while (code == NOP); // ignore NOP codes + + if (code >= BASE) + return codeTable.charAt(code - BASE); + else if (code == RAW) { + int high = readCode(); + int low = readCode(); + return (high << 4) | low; + } else + throw new IOException("unknown compression code: " + code); + } catch (EOFException e) { + return -1; + } + } + + public int read(byte b[], int off, int len) throws IOException { + if (len <= 0) { + return 0; + } + + int c = read(); + if (c == -1) { + return -1; + } + b[off] = (byte)c; + + int i = 1; + /***** + try { + for (; i < len ; i++) { + c = read(); + if (c == -1) { + break; + } + if (b != null) { + b[off + i] = (byte)c; + } + } + } catch (IOException ee) { + } + *****/ + return i; + } + + private int readCode() throws IOException { + if (bufPos == 5) { + int b1 = in.read(); + int b2 = in.read(); + int b3 = in.read(); + int b4 = in.read(); + if ((b1 | b2 | b3 | b4) < 0) + throw new EOFException(); + int pack = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; + buf[0] = (pack >>> 24) & 0x3F; + buf[1] = (pack >>> 18) & 0x3F; + buf[2] = (pack >>> 12) & 0x3F; + buf[3] = (pack >>> 6) & 0x3F; + buf[4] = (pack >>> 0) & 0x3F; + bufPos = 0; + } + return buf[bufPos++]; + } } public static class CompressOutputStream extends FilterOutputStream - implements CompressConstants + implements CompressConstants { - - public CompressOutputStream(OutputStream out) { - super(out); - } - - // buffer of 6-bit codes to pack into next 32-bit word - int buf[] = new int[5]; - - // number of valid codes pending in buffer - int bufPos = 0; - - public void write(int b) throws IOException { - b &= 0xFF; // force argument to a byte - - int pos = codeTable.indexOf((char)b); - if (pos != -1) - writeCode(BASE + pos); - else { - writeCode(RAW); - writeCode(b >> 4); - writeCode(b & 0xF); - } - } - - public void write(byte b[], int off, int len) throws IOException { - /* - * This is quite an inefficient implementation, because it has to - * call the other write method for every byte in the array. It - * could be optimized for performance by doing all the processing - * in this method. - */ - for (int i = 0; i < len; i++) - write(b[off + i]); - } - - public void flush() throws IOException { - while (bufPos > 0) - writeCode(NOP); - } - - private void writeCode(int c) throws IOException { - buf[bufPos++] = c; - if (bufPos == 5) { // write next word when we have 5 codes - int pack = (buf[0] << 24) | (buf[1] << 18) | (buf[2] << 12) | - (buf[3] << 6) | buf[4]; - out.write((pack >>> 24) & 0xFF); - out.write((pack >>> 16) & 0xFF); - out.write((pack >>> 8) & 0xFF); - out.write((pack >>> 0) & 0xFF); - bufPos = 0; - } - } + + public CompressOutputStream(OutputStream out) { + super(out); + } + + // buffer of 6-bit codes to pack into next 32-bit word + int buf[] = new int[5]; + + // number of valid codes pending in buffer + int bufPos = 0; + + public void write(int b) throws IOException { + b &= 0xFF; // force argument to a byte + + int pos = codeTable.indexOf((char)b); + if (pos != -1) + writeCode(BASE + pos); + else { + writeCode(RAW); + writeCode(b >> 4); + writeCode(b & 0xF); + } + } + + public void write(byte b[], int off, int len) throws IOException { + /* + * This is quite an inefficient implementation, because it has to + * call the other write method for every byte in the array. It + * could be optimized for performance by doing all the processing + * in this method. + */ + for (int i = 0; i < len; i++) + write(b[off + i]); + } + + public void flush() throws IOException { + while (bufPos > 0) + writeCode(NOP); + } + + private void writeCode(int c) throws IOException { + buf[bufPos++] = c; + if (bufPos == 5) { // write next word when we have 5 codes + int pack = (buf[0] << 24) | (buf[1] << 18) | (buf[2] << 12) | + (buf[3] << 6) | buf[4]; + out.write((pack >>> 24) & 0xFF); + out.write((pack >>> 16) & 0xFF); + out.write((pack >>> 8) & 0xFF); + out.write((pack >>> 0) & 0xFF); + bufPos = 0; + } + } } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Hello.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Hello.java index 5d3a83e7e8b848f7e092c42bb29fccc81a265139..347dd9cc8e36f0a759fa8b74f243b9ea18eade5b 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Hello.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Hello.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl.java index adb1819ec820c13a2abd7d1b343aff29e6a13706..13f74488a6cbd4a7f1ca2357a8fbc70ec1717ed1 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,49 +36,49 @@ public class HelloImpl public static boolean clientCalledSuccessfully = false; public HelloImpl() throws RemoteException { - super(0); + super(0); } - + public synchronized String sayHello() { - HelloImpl.clientCalledSuccessfully = true; - System.out.println("hello method called"); - this.notifyAll(); - return "hello"; + HelloImpl.clientCalledSuccessfully = true; + System.out.println("hello method called"); + this.notifyAll(); + return "hello"; } public static void main(String[] args) { - /* - * The following line is required with the JDK 1.2 VM so that the - * VM can exit gracefully when this test completes. Otherwise, the - * conservative garbage collector will find a handle to the server - * object on the native stack and not clear the weak reference to - * it in the RMI runtime's object table. - */ - Object dummy = new Object(); - Hello hello = null; - Registry registry = null; + /* + * The following line is required with the JDK 1.2 VM so that the + * VM can exit gracefully when this test completes. Otherwise, the + * conservative garbage collector will find a handle to the server + * object on the native stack and not clear the weak reference to + * it in the RMI runtime's object table. + */ + Object dummy = new Object(); + Hello hello = null; + Registry registry = null; - TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); + TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); - try { - String protocol = ""; - if (args.length >= 1) - protocol = args[0]; + try { + String protocol = ""; + if (args.length >= 1) + protocol = args[0]; - registry = java.rmi.registry.LocateRegistry. - getRegistry("localhost", TestLibrary.REGISTRY_PORT, - new Compress.CompressRMIClientSocketFactory()); - UseCustomSocketFactory.checkStub(registry, "RMIClientSocket"); - hello = (Hello) registry.lookup("/HelloServer"); + registry = java.rmi.registry.LocateRegistry. + getRegistry("localhost", TestLibrary.REGISTRY_PORT, + new Compress.CompressRMIClientSocketFactory()); + UseCustomSocketFactory.checkStub(registry, "RMIClientSocket"); + hello = (Hello) registry.lookup("/HelloServer"); - /* lookup server */ - System.err.println(hello.sayHello() + - ", remote greeting."); - } catch (Exception e) { - System.err.println("EXCEPTION OCCURRED:"); - e.printStackTrace(); - } finally { - hello = null; - } + /* lookup server */ + System.err.println(hello.sayHello() + + ", remote greeting."); + } catch (Exception e) { + System.err.println("EXCEPTION OCCURRED:"); + e.printStackTrace(); + } finally { + hello = null; + } } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl_Stub.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl_Stub.java index e500d6741f17c9cb1018288aa9a844363c24a60a..a2858f1ece83f7868226b276de5149f76791a343 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl_Stub.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,72 +29,72 @@ public final class HelloImpl_Stub implements Hello, java.rmi.Remote { private static java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("java.lang.String sayHello()") + new java.rmi.server.Operation("java.lang.String sayHello()") }; - + private static final long interfaceHash = 6486744599627128933L; - + private static final long serialVersionUID = 2; - + private static boolean useNewInvoke; private static java.lang.reflect.Method $method_sayHello_0; - + static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_sayHello_0 = Hello.class.getMethod("sayHello", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } + try { + java.rmi.server.RemoteRef.class.getMethod("invoke", + new java.lang.Class[] { + java.rmi.Remote.class, + java.lang.reflect.Method.class, + java.lang.Object[].class, + long.class + }); + useNewInvoke = true; + $method_sayHello_0 = Hello.class.getMethod("sayHello", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + useNewInvoke = false; + } } - + // constructors public HelloImpl_Stub() { - super(); + super(); } public HelloImpl_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of sayHello() public java.lang.String sayHello() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - Object $result = ref.invoke(this, $method_sayHello_0, null, 6043973830760146143L); - return ((java.lang.String) $result); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - ref.invoke(call); - java.lang.String $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = (java.lang.String) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + Object $result = ref.invoke(this, $method_sayHello_0, null, 6043973830760146143L); + return ((java.lang.String) $result); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + ref.invoke(call); + java.lang.String $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = (java.lang.String) in.readObject(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } catch (java.lang.ClassNotFoundException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java index 767a7c47c8f95dae6d1286c78859a1e61eb26f11..3bce0037a8a80e05814ed0762b17330975efcf91 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -47,86 +47,86 @@ import java.rmi.registry.*; * (i.e. compression) client and server socket factories. */ public class UseCustomSocketFactory { - + Hello hello = null; - + public static void main(String[] args) { - - Registry registry = null; - HelloImpl impl = null; - - System.out.println("\nRegression test for bug 4148850\n"); - - TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); - - try { - impl = new HelloImpl(); - - /* Make sure that the rmiregistry can communicate over a - * custom socket. Ensure that the functionality exists to - * allow the rmiregistry to be secure. - */ - registry = LocateRegistry. - createRegistry(TestLibrary.REGISTRY_PORT, - new Compress.CompressRMIClientSocketFactory(), - new Compress.CompressRMIServerSocketFactory()); - registry.rebind("/HelloServer", impl); - checkStub(registry, "RMIServerSocket"); - - } catch (Exception e) { - TestLibrary.bomb("creating registry", e); - } - - JavaVM serverVM = new JavaVM("HelloImpl", "-Djava.security.policy=" + - TestParams.defaultPolicy, ""); - - try { - - /* - * spawn VM for HelloServer which will download a client socket - * factory - */ - serverVM.start(); - - synchronized (impl) { - - System.out.println("waiting for remote notification"); - - if (!HelloImpl.clientCalledSuccessfully) { - impl.wait(75 * 1000); - } - - if (!HelloImpl.clientCalledSuccessfully) { - throw new RuntimeException("Client did not execute call in time..."); - } - } - - System.err.println("\nRegression test for bug 4148850 passed.\n "); - - } catch (Exception e) { - TestLibrary.bomb("test failed", e); - - } finally { - serverVM.destroy(); - try { - registry.unbind("/HelloServer"); - } catch (Exception e) { - TestLibrary.bomb("unbinding HelloServer", e); - } - TestLibrary.unexport(registry); - TestLibrary.unexport(impl); - impl = null; - registry = null; - } + + Registry registry = null; + HelloImpl impl = null; + + System.out.println("\nRegression test for bug 4148850\n"); + + TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); + + try { + impl = new HelloImpl(); + + /* Make sure that the rmiregistry can communicate over a + * custom socket. Ensure that the functionality exists to + * allow the rmiregistry to be secure. + */ + registry = LocateRegistry. + createRegistry(TestLibrary.REGISTRY_PORT, + new Compress.CompressRMIClientSocketFactory(), + new Compress.CompressRMIServerSocketFactory()); + registry.rebind("/HelloServer", impl); + checkStub(registry, "RMIServerSocket"); + + } catch (Exception e) { + TestLibrary.bomb("creating registry", e); + } + + JavaVM serverVM = new JavaVM("HelloImpl", "-Djava.security.policy=" + + TestParams.defaultPolicy, ""); + + try { + + /* + * spawn VM for HelloServer which will download a client socket + * factory + */ + serverVM.start(); + + synchronized (impl) { + + System.out.println("waiting for remote notification"); + + if (!HelloImpl.clientCalledSuccessfully) { + impl.wait(75 * 1000); + } + + if (!HelloImpl.clientCalledSuccessfully) { + throw new RuntimeException("Client did not execute call in time..."); + } + } + + System.err.println("\nRegression test for bug 4148850 passed.\n "); + + } catch (Exception e) { + TestLibrary.bomb("test failed", e); + + } finally { + serverVM.destroy(); + try { + registry.unbind("/HelloServer"); + } catch (Exception e) { + TestLibrary.bomb("unbinding HelloServer", e); + } + TestLibrary.unexport(registry); + TestLibrary.unexport(impl); + impl = null; + registry = null; + } } static void checkStub(Object stub, String toCheck) throws RemoteException { - System.err.println("Ensuring that the stub contains a socket factory string: " + - toCheck); - System.err.println(stub); - if (stub.toString().indexOf(toCheck) < 0) { - throw new RemoteException("RemoteStub.toString() did not contain instance of " - + toCheck); - } + System.err.println("Ensuring that the stub contains a socket factory string: " + + toCheck); + System.err.println(stub); + if (stub.toString().indexOf(toCheck) < 0) { + throw new RemoteException("RemoteStub.toString() did not contain instance of " + + toCheck); + } } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressConstants.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressConstants.java index 7db4a6b9c8a83b3493466b16d2e3a98cef41cc9f..cc7526077d8c7510487fe5163d10216938918b08 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressConstants.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressConstants.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,9 +27,9 @@ interface CompressConstants { // constants for 6-bit code values - static final int NOP = 0; // no operation: used to pad words on flush() - static final int RAW = 1; // introduces raw byte format - static final int BASE = 2; // base for codes found in lookup table + static final int NOP = 0; // no operation: used to pad words on flush() + static final int RAW = 1; // introduces raw byte format + static final int BASE = 2; // base for codes found in lookup table static final String codeTable = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ,.!?\"'()"; + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ,.!?\"'()"; } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressInputStream.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressInputStream.java index 3a42bb180733f35f4524848a927853c49639ce5e..31577a1c2adad42cdb2cfa3a441c21378ceef53f 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressInputStream.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressInputStream.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -31,7 +31,7 @@ class CompressInputStream extends FilterInputStream { public CompressInputStream(InputStream in) { - super(in); + super(in); } // buffer of unpacked 6-bit codes from last 32-word read @@ -41,70 +41,70 @@ class CompressInputStream extends FilterInputStream int bufPos = 5; public int read() throws IOException { - try { - int code; - do { - code = readCode(); - } while (code == NOP); // ignore NOP codes + try { + int code; + do { + code = readCode(); + } while (code == NOP); // ignore NOP codes - if (code >= BASE) - return codeTable.charAt(code - BASE); - else if (code == RAW) { - int high = readCode(); - int low = readCode(); - return (high << 4) | low; - } else - throw new IOException("unknown compression code: " + code); - } catch (EOFException e) { - return -1; - } + if (code >= BASE) + return codeTable.charAt(code - BASE); + else if (code == RAW) { + int high = readCode(); + int low = readCode(); + return (high << 4) | low; + } else + throw new IOException("unknown compression code: " + code); + } catch (EOFException e) { + return -1; + } } public int read(byte b[], int off, int len) throws IOException { - if (len <= 0) { - return 0; - } + if (len <= 0) { + return 0; + } - int c = read(); - if (c == -1) { - return -1; - } - b[off] = (byte)c; + int c = read(); + if (c == -1) { + return -1; + } + b[off] = (byte)c; - int i = 1; + int i = 1; /***** - try { - for (; i < len ; i++) { - c = read(); - if (c == -1) { - break; - } - if (b != null) { - b[off + i] = (byte)c; - } - } - } catch (IOException ee) { - } + try { + for (; i < len ; i++) { + c = read(); + if (c == -1) { + break; + } + if (b != null) { + b[off + i] = (byte)c; + } + } + } catch (IOException ee) { + } *****/ - return i; + return i; } private int readCode() throws IOException { - if (bufPos == 5) { - int b1 = in.read(); - int b2 = in.read(); - int b3 = in.read(); - int b4 = in.read(); - if ((b1 | b2 | b3 | b4) < 0) - throw new EOFException(); - int pack = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; - buf[0] = (pack >>> 24) & 0x3F; - buf[1] = (pack >>> 18) & 0x3F; - buf[2] = (pack >>> 12) & 0x3F; - buf[3] = (pack >>> 6) & 0x3F; - buf[4] = (pack >>> 0) & 0x3F; - bufPos = 0; - } - return buf[bufPos++]; + if (bufPos == 5) { + int b1 = in.read(); + int b2 = in.read(); + int b3 = in.read(); + int b4 = in.read(); + if ((b1 | b2 | b3 | b4) < 0) + throw new EOFException(); + int pack = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; + buf[0] = (pack >>> 24) & 0x3F; + buf[1] = (pack >>> 18) & 0x3F; + buf[2] = (pack >>> 12) & 0x3F; + buf[3] = (pack >>> 6) & 0x3F; + buf[4] = (pack >>> 0) & 0x3F; + bufPos = 0; + } + return buf[bufPos++]; } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressOutputStream.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressOutputStream.java index ca1a5963f959a40ff9445b715f077bbf55f7b5cf..5d38e147b18f9f895ecbfb9f14d922ded390c068 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressOutputStream.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressOutputStream.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -31,7 +31,7 @@ class CompressOutputStream extends FilterOutputStream { public CompressOutputStream(OutputStream out) { - super(out); + super(out); } // buffer of 6-bit codes to pack into next 32-bit word @@ -41,44 +41,44 @@ class CompressOutputStream extends FilterOutputStream int bufPos = 0; public void write(int b) throws IOException { - b &= 0xFF; // force argument to a byte + b &= 0xFF; // force argument to a byte - int pos = codeTable.indexOf((char)b); - if (pos != -1) - writeCode(BASE + pos); - else { - writeCode(RAW); - writeCode(b >> 4); - writeCode(b & 0xF); - } + int pos = codeTable.indexOf((char)b); + if (pos != -1) + writeCode(BASE + pos); + else { + writeCode(RAW); + writeCode(b >> 4); + writeCode(b & 0xF); + } } public void write(byte b[], int off, int len) throws IOException { - /* - * This is quite an inefficient implementation, because it has to - * call the other write method for every byte in the array. It + /* + * This is quite an inefficient implementation, because it has to + * call the other write method for every byte in the array. It * could be optimized for performance by doing all the processing - * in this method. - */ - for (int i = 0; i < len; i++) - write(b[off + i]); + * in this method. + */ + for (int i = 0; i < len; i++) + write(b[off + i]); } public void flush() throws IOException { - while (bufPos > 0) - writeCode(NOP); + while (bufPos > 0) + writeCode(NOP); } private void writeCode(int c) throws IOException { - buf[bufPos++] = c; - if (bufPos == 5) { // write next word when we have 5 codes - int pack = (buf[0] << 24) | (buf[1] << 18) | (buf[2] << 12) | - (buf[3] << 6) | buf[4]; - out.write((pack >>> 24) & 0xFF); - out.write((pack >>> 16) & 0xFF); - out.write((pack >>> 8) & 0xFF); - out.write((pack >>> 0) & 0xFF); - bufPos = 0; - } + buf[bufPos++] = c; + if (bufPos == 5) { // write next word when we have 5 codes + int pack = (buf[0] << 24) | (buf[1] << 18) | (buf[2] << 12) | + (buf[3] << 6) | buf[4]; + out.write((pack >>> 24) & 0xFF); + out.write((pack >>> 16) & 0xFF); + out.write((pack >>> 8) & 0xFF); + out.write((pack >>> 0) & 0xFF); + bufPos = 0; + } } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/Echo.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/Echo.java index 8a9fc44998f8a193e03d127074dc45fb784514e7..03441f25a5040aa02f579ed352f47e453b4acee9 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/Echo.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/Echo.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl.java index 78cf7414adbc7574ec1b7c7d69575386dd6ca1da..c156ff903e9ceda7417b1195f8a3be154f660ec4 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,44 +33,44 @@ public class EchoImpl private static final byte[] pattern = { (byte) 'A' }; public EchoImpl(String protocol) throws RemoteException { - super(0, - new MultiSocketFactory.ClientFactory(protocol, pattern), - new MultiSocketFactory.ServerFactory(protocol, pattern)); + super(0, + new MultiSocketFactory.ClientFactory(protocol, pattern), + new MultiSocketFactory.ServerFactory(protocol, pattern)); } - + public byte[] echoNot(byte[] data) { - byte[] result = new byte[data.length]; - for (int i = 0; i < data.length; i++) - result[i] = (byte) ~data[i]; - return result; + byte[] result = new byte[data.length]; + for (int i = 0; i < data.length; i++) + result[i] = (byte) ~data[i]; + return result; } public static void main(String[] args) { - /* - * The following line is required with the JDK 1.2 VM so that the - * VM can exit gracefully when this test completes. Otherwise, the - * conservative garbage collector will find a handle to the server - * object on the native stack and not clear the weak reference to - * it in the RMI runtime's object table. - */ - Object dummy = new Object(); - - TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); - - try { - String protocol = ""; - if (args.length >= 1) - protocol = args[0]; + /* + * The following line is required with the JDK 1.2 VM so that the + * VM can exit gracefully when this test completes. Otherwise, the + * conservative garbage collector will find a handle to the server + * object on the native stack and not clear the weak reference to + * it in the RMI runtime's object table. + */ + Object dummy = new Object(); + + TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); + + try { + String protocol = ""; + if (args.length >= 1) + protocol = args[0]; - System.out.println("EchoServer: creating remote object"); - EchoImpl impl = new EchoImpl(protocol); - System.out.println("EchoServer: binding in registry"); - Naming.rebind("//:" + TestLibrary.REGISTRY_PORT + - "/EchoServer", impl); - System.out.println("EchoServer ready."); - } catch (Exception e) { - System.err.println("EXCEPTION OCCURRED:"); - e.printStackTrace(); - } + System.out.println("EchoServer: creating remote object"); + EchoImpl impl = new EchoImpl(protocol); + System.out.println("EchoServer: binding in registry"); + Naming.rebind("//:" + TestLibrary.REGISTRY_PORT + + "/EchoServer", impl); + System.out.println("EchoServer ready."); + } catch (Exception e) { + System.err.println("EXCEPTION OCCURRED:"); + e.printStackTrace(); + } } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl_Stub.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl_Stub.java index be15d2722d8e2a41a1e3c68a06c399dc0f0813eb..05e866e61d9610965df52afc5a92b8ca0a334bfb 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl_Stub.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,38 +29,38 @@ public final class EchoImpl_Stub implements Echo, java.rmi.Remote { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_echoNot_0; - + static { - try { - $method_echoNot_0 = Echo.class.getMethod("echoNot", new java.lang.Class[] {byte[].class}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_echoNot_0 = Echo.class.getMethod("echoNot", new java.lang.Class[] {byte[].class}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public EchoImpl_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of echoNot(byte[]) public byte[] echoNot(byte[] $param_arrayOf_byte_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - Object $result = ref.invoke(this, $method_echoNot_0, new java.lang.Object[] {$param_arrayOf_byte_1}, -4295721514897591756L); - return ((byte[]) $result); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + Object $result = ref.invoke(this, $method_echoNot_0, new java.lang.Object[] {$param_arrayOf_byte_1}, -4295721514897591756L); + return ((byte[]) $result); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/MultiSocketFactory.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/MultiSocketFactory.java index f8ef69fac1c647a75639c831703a041fd5247600..9ebfa3236e016d8301c187774935cac079bb95b6 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/MultiSocketFactory.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/MultiSocketFactory.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,194 +34,193 @@ import java.util.zip.*; public class MultiSocketFactory { private static RMISocketFactory def = - RMISocketFactory.getDefaultSocketFactory(); + RMISocketFactory.getDefaultSocketFactory(); + - public static class ServerFactory - implements RMIServerSocketFactory, Serializable + implements RMIServerSocketFactory, Serializable { - private String protocol; - private byte[] data; - - public ServerFactory(String protocol, byte[] data) { - this.protocol = protocol; - this.data = data; - } - - public ServerSocket createServerSocket(int port) throws IOException - { - if (protocol.equals("compress")) { - return new CompressServerSocket(port); - - } else if (protocol.equals("xor")) { - if (data == null || data.length != 1) - throw new IOException("invalid argument for XOR protocol"); - return new XorServerSocket(port, data[0]); - - } - - return def.createServerSocket(port); - } + private String protocol; + private byte[] data; + + public ServerFactory(String protocol, byte[] data) { + this.protocol = protocol; + this.data = data; + } + + public ServerSocket createServerSocket(int port) throws IOException + { + if (protocol.equals("compress")) { + return new CompressServerSocket(port); + + } else if (protocol.equals("xor")) { + if (data == null || data.length != 1) + throw new IOException("invalid argument for XOR protocol"); + return new XorServerSocket(port, data[0]); + + } + + return def.createServerSocket(port); + } } public static class ClientFactory - implements RMIClientSocketFactory, Serializable + implements RMIClientSocketFactory, Serializable { - private String protocol; - private byte[] data; - - public ClientFactory(String protocol, byte[] data) { - this.protocol = protocol; - this.data = data; - } - - public Socket createSocket(String host, int port) - throws IOException - { - if (protocol.equals("compress")) { - return new CompressSocket(host, port); - - } else if (protocol.equals("xor")) { - if (data == null || data.length != 1) - throw new IOException("invalid argument for XOR protocol"); - return new XorSocket(host, port, data[0]); - - } - - return def.createSocket(host, port); - } + private String protocol; + private byte[] data; + + public ClientFactory(String protocol, byte[] data) { + this.protocol = protocol; + this.data = data; + } + + public Socket createSocket(String host, int port) + throws IOException + { + if (protocol.equals("compress")) { + return new CompressSocket(host, port); + + } else if (protocol.equals("xor")) { + if (data == null || data.length != 1) + throw new IOException("invalid argument for XOR protocol"); + return new XorSocket(host, port, data[0]); + + } + + return def.createSocket(host, port); + } } static class CompressSocket extends Socket { - private InputStream in; - private OutputStream out; - public CompressSocket() { super(); } - public CompressSocket(String host, int port) throws IOException { - super(host, port); - } - public InputStream getInputStream() throws IOException { - if (in == null) { - in = new CompressInputStream(super.getInputStream()); - } - return in; - } - public OutputStream getOutputStream() throws IOException { - if (out == null) { - out = new CompressOutputStream(super.getOutputStream()); - } - return out; - } + private InputStream in; + private OutputStream out; + public CompressSocket() { super(); } + public CompressSocket(String host, int port) throws IOException { + super(host, port); + } + public InputStream getInputStream() throws IOException { + if (in == null) { + in = new CompressInputStream(super.getInputStream()); + } + return in; + } + public OutputStream getOutputStream() throws IOException { + if (out == null) { + out = new CompressOutputStream(super.getOutputStream()); + } + return out; + } } static class CompressServerSocket extends ServerSocket { - public CompressServerSocket(int port) throws IOException { - super(port); - } - public Socket accept() throws IOException { - Socket s = new CompressSocket(); - implAccept(s); - return s; - } + public CompressServerSocket(int port) throws IOException { + super(port); + } + public Socket accept() throws IOException { + Socket s = new CompressSocket(); + implAccept(s); + return s; + } } static class XorSocket extends Socket { - private byte pattern; - private InputStream in; - private OutputStream out; - public XorSocket(byte pattern) { super(); this.pattern = pattern; } - public XorSocket(String host, int port, byte pattern) - throws IOException - { - super(host, port); - this.pattern = pattern; - } - public InputStream getInputStream() throws IOException { - if (in == null) { - in = new XorInputStream(super.getInputStream(), pattern); - } - return in; - } - public OutputStream getOutputStream() throws IOException { - if (out == null) { - out = new XorOutputStream(super.getOutputStream(), pattern); - } - return out; - } + private byte pattern; + private InputStream in; + private OutputStream out; + public XorSocket(byte pattern) { super(); this.pattern = pattern; } + public XorSocket(String host, int port, byte pattern) + throws IOException + { + super(host, port); + this.pattern = pattern; + } + public InputStream getInputStream() throws IOException { + if (in == null) { + in = new XorInputStream(super.getInputStream(), pattern); + } + return in; + } + public OutputStream getOutputStream() throws IOException { + if (out == null) { + out = new XorOutputStream(super.getOutputStream(), pattern); + } + return out; + } } static class XorServerSocket extends ServerSocket { - private byte pattern; - public XorServerSocket(int port, byte pattern) throws IOException { - super(port); - this.pattern = pattern; - } - public Socket accept() throws IOException { - Socket s = new XorSocket(pattern); - implAccept(s); - return s; - } + private byte pattern; + public XorServerSocket(int port, byte pattern) throws IOException { + super(port); + this.pattern = pattern; + } + public Socket accept() throws IOException { + Socket s = new XorSocket(pattern); + implAccept(s); + return s; + } } static class XorOutputStream extends FilterOutputStream { - private byte pattern; - public XorOutputStream(OutputStream out, byte pattern) { - super(out); - this.pattern = pattern; - } - public void write(int b) throws IOException { - out.write(b ^ pattern); - out.flush(); - } - public void write(byte b[], int off, int len) throws IOException { - for (int i = 0; i < len; i++) - write(b[off + i]); - } + private byte pattern; + public XorOutputStream(OutputStream out, byte pattern) { + super(out); + this.pattern = pattern; + } + public void write(int b) throws IOException { + out.write(b ^ pattern); + out.flush(); + } + public void write(byte b[], int off, int len) throws IOException { + for (int i = 0; i < len; i++) + write(b[off + i]); + } } static class XorInputStream extends FilterInputStream { - private byte pattern; - public XorInputStream(InputStream in, byte pattern) { - super(in); - this.pattern = pattern; - } - public int read() throws IOException { - int b = in.read(); -// System.out.print("BEFORE: " + Integer.toHexString(b)); - if (b != -1) - b = (b ^ pattern) & 0xFF; -// System.out.println("\tAFTER: " + Integer.toHexString(b)); - return b; - } - public int read(byte b[], int off, int len) throws IOException { - if (len <= 0) { - return 0; - } - - int c = read(); - if (c == -1) { - return -1; - } - b[off] = (byte)c; - - int i = 1; + private byte pattern; + public XorInputStream(InputStream in, byte pattern) { + super(in); + this.pattern = pattern; + } + public int read() throws IOException { + int b = in.read(); +// System.out.print("BEFORE: " + Integer.toHexString(b)); + if (b != -1) + b = (b ^ pattern) & 0xFF; +// System.out.println("\tAFTER: " + Integer.toHexString(b)); + return b; + } + public int read(byte b[], int off, int len) throws IOException { + if (len <= 0) { + return 0; + } + + int c = read(); + if (c == -1) { + return -1; + } + b[off] = (byte)c; + + int i = 1; /***** - try { - for (; i < len ; i++) { - c = read(); - if (c == -1) { - break; - } - if (b != null) { - b[off + i] = (byte)c; - } - } - } catch (IOException ee) { - } + try { + for (; i < len ; i++) { + c = read(); + if (c == -1) { + break; + } + if (b != null) { + b[off + i] = (byte)c; + } + } + } catch (IOException ee) { + } *****/ - return i; - } + return i; + } } } - diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java index 04e81e45083c6818ad133df9e4ce457f7c8d3c0e..f1b01f9b7c6a0ab0a3964c5551d46ad4ed5fa202 100644 --- a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -25,7 +25,7 @@ * @bug 4127826 * * @summary synopsis: need to download factories for use with custom socket - * types + * types * @author Ann Wollrath * * @library ../../../../testlibrary @@ -45,77 +45,77 @@ import java.rmi.registry.*; public class UseCustomSocketFactory { public static void main(String[] args) { - - String[] protocol = new String[] { "", "compress", "xor" }; - - System.out.println("\nRegression test for bug 4127826\n"); - - TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); - - try { - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); - } catch (Exception e) { - TestLibrary.bomb("creating registry", e); - } - - for (int i = 0; i < protocol.length; i++) { - - System.err.println("test policy: " + - TestParams.defaultPolicy); - - JavaVM serverVM = new JavaVM("EchoImpl", - "-Djava.security.policy=" + - TestParams.defaultPolicy, - protocol[i]); - System.err.println("\nusing protocol: " + - (protocol[i] == "" ? "none" : protocol[i])); - - try { - /* spawn VM for EchoServer */ - serverVM.start(); - - /* lookup server */ - int tries = 8; - Echo obj = null; - do { - try { - obj = (Echo) Naming.lookup("//:" + TestLibrary.REGISTRY_PORT + - "/EchoServer"); - break; - } catch (NotBoundException e) { - try { - Thread.sleep(2000); - } catch (Exception ignore) { - } - continue; - } - } while (--tries > 0); - - if (obj == null) - TestLibrary.bomb("server not bound in 8 tries", null); - - /* invoke remote method and print result*/ - System.err.println("Bound to " + obj); - byte[] data = ("Greetings, citizen " + - System.getProperty("user.name") + "!"). getBytes(); - byte[] result = obj.echoNot(data); - for (int j = 0; j < result.length; j++) - result[j] = (byte) ~result[j]; - System.err.println("Result: " + new String(result)); - - } catch (Exception e) { - TestLibrary.bomb("test failed", e); - - } finally { - serverVM.destroy(); - try { - Naming.unbind("//:" + TestLibrary.REGISTRY_PORT + - "/EchoServer"); - } catch (Exception e) { - TestLibrary.bomb("unbinding EchoServer", e); - - } - } - } + + String[] protocol = new String[] { "", "compress", "xor" }; + + System.out.println("\nRegression test for bug 4127826\n"); + + TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); + + try { + LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + } catch (Exception e) { + TestLibrary.bomb("creating registry", e); + } + + for (int i = 0; i < protocol.length; i++) { + + System.err.println("test policy: " + + TestParams.defaultPolicy); + + JavaVM serverVM = new JavaVM("EchoImpl", + "-Djava.security.policy=" + + TestParams.defaultPolicy, + protocol[i]); + System.err.println("\nusing protocol: " + + (protocol[i] == "" ? "none" : protocol[i])); + + try { + /* spawn VM for EchoServer */ + serverVM.start(); + + /* lookup server */ + int tries = 8; + Echo obj = null; + do { + try { + obj = (Echo) Naming.lookup("//:" + TestLibrary.REGISTRY_PORT + + "/EchoServer"); + break; + } catch (NotBoundException e) { + try { + Thread.sleep(2000); + } catch (Exception ignore) { + } + continue; + } + } while (--tries > 0); + + if (obj == null) + TestLibrary.bomb("server not bound in 8 tries", null); + + /* invoke remote method and print result*/ + System.err.println("Bound to " + obj); + byte[] data = ("Greetings, citizen " + + System.getProperty("user.name") + "!"). getBytes(); + byte[] result = obj.echoNot(data); + for (int j = 0; j < result.length; j++) + result[j] = (byte) ~result[j]; + System.err.println("Result: " + new String(result)); + + } catch (Exception e) { + TestLibrary.bomb("test failed", e); + + } finally { + serverVM.destroy(); + try { + Naming.unbind("//:" + TestLibrary.REGISTRY_PORT + + "/EchoServer"); + } catch (Exception e) { + TestLibrary.bomb("unbinding EchoServer", e); + + } + } + } } } diff --git a/test/java/rmi/server/RemoteServer/setLogPermission/SetLogPermission.java b/test/java/rmi/server/RemoteServer/setLogPermission/SetLogPermission.java index 75ba21e3d44a795f7664cd436cb3d8ec3e02cd14..5d191fe67a6957b58cf8695475935f33f777670d 100644 --- a/test/java/rmi/server/RemoteServer/setLogPermission/SetLogPermission.java +++ b/test/java/rmi/server/RemoteServer/setLogPermission/SetLogPermission.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2002-2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -25,7 +25,7 @@ * @bug 4533390 * @summary SecurityException can be obtained but is not specified. * The RemoteServer.setLog method requires - * java.util.log.LoggingPermission("control"). + * java.util.log.LoggingPermission("control"). * @author Ann Wollrath * @run main/othervm/policy=java.policy SetLogPermission */ @@ -40,42 +40,42 @@ public class SetLogPermission { public static void main(String[] args) throws Exception { - System.err.println("\nRegression test for bug 4533390\n"); + System.err.println("\nRegression test for bug 4533390\n"); - if (System.getSecurityManager() == null) { - System.setSecurityManager(new SecurityManager()); - } - - CodeSource codesource = new CodeSource(null, (Certificate[]) null); - Permissions perms = null; - ProtectionDomain pd = new ProtectionDomain(codesource, perms); - AccessControlContext acc = - new AccessControlContext(new ProtectionDomain[] { pd }); - - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - try { - System.err.println( - "Attempt to set log without permission"); - RemoteServer.setLog(new ByteArrayOutputStream()); - throw new RuntimeException( - "TEST FAILED: set log without permission"); - } catch (SecurityException e) { - System.err.println( - "TEST PASSED: unable to set log without permission"); - } - return null; - }}, acc); + if (System.getSecurityManager() == null) { + System.setSecurityManager(new SecurityManager()); + } - try { - System.err.println("Attempt to set log with permission"); - RemoteServer.setLog(new ByteArrayOutputStream()); - System.err.println( - "TEST PASSED: sufficient permission to set log"); - } catch (SecurityException e) { - System.err.println("TEST FAILED: unable to set log"); - throw e; - } + CodeSource codesource = new CodeSource(null, (Certificate[]) null); + Permissions perms = null; + ProtectionDomain pd = new ProtectionDomain(codesource, perms); + AccessControlContext acc = + new AccessControlContext(new ProtectionDomain[] { pd }); + + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Object run() { + try { + System.err.println( + "Attempt to set log without permission"); + RemoteServer.setLog(new ByteArrayOutputStream()); + throw new RuntimeException( + "TEST FAILED: set log without permission"); + } catch (SecurityException e) { + System.err.println( + "TEST PASSED: unable to set log without permission"); + } + return null; + }}, acc); + + try { + System.err.println("Attempt to set log with permission"); + RemoteServer.setLog(new ByteArrayOutputStream()); + System.err.println( + "TEST PASSED: sufficient permission to set log"); + } catch (SecurityException e) { + System.err.println("TEST FAILED: unable to set log"); + throw e; + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName.java b/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName.java index 0a7754a75f30af0f14123a1795e6a68b2d1f1cf5..436d70a405177fd469999093706040efa9db53c8 100644 --- a/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName.java +++ b/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -50,40 +50,40 @@ public class ChangeHostName } public void receive(Remote obj) { - System.err.println("received: " + obj.toString()); + System.err.println("received: " + obj.toString()); } public static void main(String[] args) throws Exception { - InetAddress localAddress = InetAddress.getLocalHost(); - String[] hostlist = new String[] { - localAddress.getHostAddress(), localAddress.getHostName() }; + InetAddress localAddress = InetAddress.getLocalHost(); + String[] hostlist = new String[] { + localAddress.getHostAddress(), localAddress.getHostName() }; - for (int i = 0; i < hostlist.length; i++) { - - System.setProperty("java.rmi.server.hostname", hostlist[i]); - Remote impl = new ChangeHostName(); - System.err.println("\ncreated impl extending URO: " + impl); - - Receiver stub = (Receiver) RemoteObject.toStub(impl); - System.err.println("stub for impl: " + stub); + for (int i = 0; i < hostlist.length; i++) { - System.err.println("invoking method on stub"); - stub.receive(stub); + System.setProperty("java.rmi.server.hostname", hostlist[i]); + Remote impl = new ChangeHostName(); + System.err.println("\ncreated impl extending URO: " + impl); - UnicastRemoteObject.unexportObject(impl, true); - System.err.println("unexported impl"); + Receiver stub = (Receiver) RemoteObject.toStub(impl); + System.err.println("stub for impl: " + stub); - if (stub.toString().indexOf(hostlist[i]) >= 0) { - System.err.println("stub's ref contains hostname: " + - hostlist[i]); - } else { - throw new RuntimeException( - "TEST FAILED: stub's ref doesn't contain hostname: " + - hostlist[i]); - } - } - System.err.println("TEST PASSED"); + System.err.println("invoking method on stub"); + stub.receive(stub); + + UnicastRemoteObject.unexportObject(impl, true); + System.err.println("unexported impl"); + + if (stub.toString().indexOf(hostlist[i]) >= 0) { + System.err.println("stub's ref contains hostname: " + + hostlist[i]); + } else { + throw new RuntimeException( + "TEST FAILED: stub's ref doesn't contain hostname: " + + hostlist[i]); + } + } + System.err.println("TEST PASSED"); } } diff --git a/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName_Stub.java b/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName_Stub.java index ff67210c4c2c5b8b518037dfda0afe67c171819a..f42eda7d419bcccfa900f0fc793031d0d50421b0 100644 --- a/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName_Stub.java +++ b/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,37 +29,37 @@ public final class ChangeHostName_Stub implements Receiver, java.rmi.Remote { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_receive_0; - + static { - try { - $method_receive_0 = Receiver.class.getMethod("receive", new java.lang.Class[] {java.rmi.Remote.class}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_receive_0 = Receiver.class.getMethod("receive", new java.lang.Class[] {java.rmi.Remote.class}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public ChangeHostName_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of receive(Remote) public void receive(java.rmi.Remote $param_Remote_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - ref.invoke(this, $method_receive_0, new java.lang.Object[] {$param_Remote_1}, 5876293363550629411L); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + ref.invoke(this, $method_receive_0, new java.lang.Object[] {$param_Remote_1}, 5876293363550629411L); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java index e4a41b06f520c6d6c4ad2aa176da3ea4521162d1..9ea571a41c63cffee2aaca2ea8226b02e340d448 100644 --- a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java +++ b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -59,83 +59,83 @@ public class KeepAliveDuringCall implements ShutdownMonitor { private boolean stillAlive = false; public void submitShutdown(Shutdown shutdown) { - synchronized (lock) { - this.shutdown = shutdown; - lock.notifyAll(); - } + synchronized (lock) { + this.shutdown = shutdown; + lock.notifyAll(); + } } public void declareStillAlive() { - synchronized (lock) { - stillAlive = true; - lock.notifyAll(); - } + synchronized (lock) { + stillAlive = true; + lock.notifyAll(); + } } public static void main(String[] args) { - System.err.println("\nRegression test for bug 4308492\n"); - - KeepAliveDuringCall obj = new KeepAliveDuringCall(); - - try { - UnicastRemoteObject.exportObject(obj); - System.err.println("exported shutdown monitor"); - - Registry localRegistry = - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); - System.err.println("created local registry"); - - localRegistry.bind(BINDING, obj); - System.err.println("bound shutdown monitor in local registry"); - - System.err.println("starting remote ShutdownImpl VM..."); - (new JavaVM("ShutdownImpl")).start(); - - Shutdown s; - synchronized (obj.lock) { - System.err.println( - "waiting for submission of object to shutdown..."); - while ((s = obj.shutdown) == null) { - obj.lock.wait(TIMEOUT); - } - if (s == null) { - throw new RuntimeException( - "TEST FAILED: timeout waiting for shutdown object " + - "to make initial contact"); - } - System.err.println("shutdown object submitted: " + s); - } - - try { - s.shutdown(); - } catch (RemoteException e) { - throw new RuntimeException( - "TEST FAILED: shutdown method threw remote exception", e); - } - - synchronized (obj.lock) { - if (!obj.stillAlive) { - throw new RuntimeException("TEST FAILED: " + - "shutdown object not detected alive after unexport"); - } - } - - System.err.println("TEST PASSED: " + - "shutdown object detected still alive after unexport"); - - } catch (Exception e) { - if (e instanceof RuntimeException) { - throw (RuntimeException) e; - } else { - throw new RuntimeException( - "TEST FAILED: unexpected exception", e); - } - } finally { - try { - UnicastRemoteObject.unexportObject(obj, true); - } catch (RemoteException e) { - } - } + System.err.println("\nRegression test for bug 4308492\n"); + + KeepAliveDuringCall obj = new KeepAliveDuringCall(); + + try { + UnicastRemoteObject.exportObject(obj); + System.err.println("exported shutdown monitor"); + + Registry localRegistry = + LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + System.err.println("created local registry"); + + localRegistry.bind(BINDING, obj); + System.err.println("bound shutdown monitor in local registry"); + + System.err.println("starting remote ShutdownImpl VM..."); + (new JavaVM("ShutdownImpl")).start(); + + Shutdown s; + synchronized (obj.lock) { + System.err.println( + "waiting for submission of object to shutdown..."); + while ((s = obj.shutdown) == null) { + obj.lock.wait(TIMEOUT); + } + if (s == null) { + throw new RuntimeException( + "TEST FAILED: timeout waiting for shutdown object " + + "to make initial contact"); + } + System.err.println("shutdown object submitted: " + s); + } + + try { + s.shutdown(); + } catch (RemoteException e) { + throw new RuntimeException( + "TEST FAILED: shutdown method threw remote exception", e); + } + + synchronized (obj.lock) { + if (!obj.stillAlive) { + throw new RuntimeException("TEST FAILED: " + + "shutdown object not detected alive after unexport"); + } + } + + System.err.println("TEST PASSED: " + + "shutdown object detected still alive after unexport"); + + } catch (Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException) e; + } else { + throw new RuntimeException( + "TEST FAILED: unexpected exception", e); + } + } finally { + try { + UnicastRemoteObject.unexportObject(obj, true); + } catch (RemoteException e) { + } + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall_Stub.java b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall_Stub.java index d7ba21cdfdb84c688069f1205f4935d68555faaa..9583f53546bc91c6fa2edaed864ba0734e70f9df 100644 --- a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall_Stub.java +++ b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,54 +29,54 @@ public final class KeepAliveDuringCall_Stub implements ShutdownMonitor { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_declareStillAlive_0; private static java.lang.reflect.Method $method_submitShutdown_1; - + static { - try { - $method_declareStillAlive_0 = ShutdownMonitor.class.getMethod("declareStillAlive", new java.lang.Class[] {}); - $method_submitShutdown_1 = ShutdownMonitor.class.getMethod("submitShutdown", new java.lang.Class[] {Shutdown.class}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_declareStillAlive_0 = ShutdownMonitor.class.getMethod("declareStillAlive", new java.lang.Class[] {}); + $method_submitShutdown_1 = ShutdownMonitor.class.getMethod("submitShutdown", new java.lang.Class[] {Shutdown.class}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public KeepAliveDuringCall_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of declareStillAlive() public void declareStillAlive() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - ref.invoke(this, $method_declareStillAlive_0, null, -1562228924246272634L); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + ref.invoke(this, $method_declareStillAlive_0, null, -1562228924246272634L); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of submitShutdown(Shutdown) public void submitShutdown(Shutdown $param_Shutdown_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - ref.invoke(this, $method_submitShutdown_1, new java.lang.Object[] {$param_Shutdown_1}, 7574258166120515108L); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + ref.invoke(this, $method_submitShutdown_1, new java.lang.Object[] {$param_Shutdown_1}, 7574258166120515108L); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/Shutdown.java b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/Shutdown.java index d3aa32830693531e8cda0549ce9fe11d2b7a320b..4dadbe51b2edebfeef0dca68865a4e1ed962a067 100644 --- a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/Shutdown.java +++ b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/Shutdown.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl.java b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl.java index 39952ed5f2cd23c1cf3ccfddfaaefdb862c2beb2..32c0c118b25ea1398a061f5beea9999f8a8dfdf3 100644 --- a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl.java +++ b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,58 +32,58 @@ import java.rmi.server.UnicastRemoteObject; public class ShutdownImpl implements Shutdown { - private static Remote impl; // rooted here to prevent GC + private static Remote impl; // rooted here to prevent GC private final ShutdownMonitor monitor; private ShutdownImpl(ShutdownMonitor monitor) { - this.monitor = monitor; + this.monitor = monitor; } public void shutdown() { - try { - System.err.println( - "(ShutdownImpl.shutdown) shutdown method invoked:"); + try { + System.err.println( + "(ShutdownImpl.shutdown) shutdown method invoked:"); - UnicastRemoteObject.unexportObject(this, true); - System.err.println( - "(ShutdownImpl.shutdown) shutdown object unexported"); + UnicastRemoteObject.unexportObject(this, true); + System.err.println( + "(ShutdownImpl.shutdown) shutdown object unexported"); - Thread.sleep(500); - System.err.println("(ShutDownImpl.shutdown) FEE"); - Thread.sleep(500); - System.err.println("(ShutDownImpl.shutdown) FIE"); - Thread.sleep(500); - System.err.println("(ShutDownImpl.shutdown) FOE"); - Thread.sleep(500); - System.err.println("(ShutDownImpl.shutdown) FOO"); + Thread.sleep(500); + System.err.println("(ShutDownImpl.shutdown) FEE"); + Thread.sleep(500); + System.err.println("(ShutDownImpl.shutdown) FIE"); + Thread.sleep(500); + System.err.println("(ShutDownImpl.shutdown) FOE"); + Thread.sleep(500); + System.err.println("(ShutDownImpl.shutdown) FOO"); - monitor.declareStillAlive(); - System.err.println("(ShutDownImpl.shutdown) still alive!"); - } catch (Exception e) { - throw new RuntimeException( - "unexpected exception occurred in shutdown method", e); - } + monitor.declareStillAlive(); + System.err.println("(ShutDownImpl.shutdown) still alive!"); + } catch (Exception e) { + throw new RuntimeException( + "unexpected exception occurred in shutdown method", e); + } } public static void main(String[] args) { - try { - Registry registry = - LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); - ShutdownMonitor monitor = (ShutdownMonitor) - registry.lookup(KeepAliveDuringCall.BINDING); - System.err.println("(ShutdownImpl) retrieved shutdown monitor"); + try { + Registry registry = + LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); + ShutdownMonitor monitor = (ShutdownMonitor) + registry.lookup(KeepAliveDuringCall.BINDING); + System.err.println("(ShutdownImpl) retrieved shutdown monitor"); - impl = new ShutdownImpl(monitor); - Shutdown stub = (Shutdown) UnicastRemoteObject.exportObject(impl); - System.err.println("(ShutdownImpl) exported shutdown object"); + impl = new ShutdownImpl(monitor); + Shutdown stub = (Shutdown) UnicastRemoteObject.exportObject(impl); + System.err.println("(ShutdownImpl) exported shutdown object"); - monitor.submitShutdown(stub); - System.err.println("(ShutdownImpl) submitted shutdown object"); + monitor.submitShutdown(stub); + System.err.println("(ShutdownImpl) submitted shutdown object"); - } catch (Exception e) { - System.err.println("(ShutdownImpl) TEST SUBPROCESS FAILURE:"); - e.printStackTrace(); - } + } catch (Exception e) { + System.err.println("(ShutdownImpl) TEST SUBPROCESS FAILURE:"); + e.printStackTrace(); + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl_Stub.java b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl_Stub.java index 0540a634574414bb225ee25b69392b9effb60efd..97c62ca33f815ee70745d3e7de2e0509223dbe40 100644 --- a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl_Stub.java +++ b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,37 +29,37 @@ public final class ShutdownImpl_Stub implements Shutdown { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_shutdown_0; - + static { - try { - $method_shutdown_0 = Shutdown.class.getMethod("shutdown", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_shutdown_0 = Shutdown.class.getMethod("shutdown", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public ShutdownImpl_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of shutdown() public void shutdown() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - ref.invoke(this, $method_shutdown_0, null, -7207851917985848402L); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + ref.invoke(this, $method_shutdown_0, null, -7207851917985848402L); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownMonitor.java b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownMonitor.java index 45c4deb0c764710a5025fae72ce8600dd42f7e58..29f630b1fe0f9ffe605343568270965a673823a5 100644 --- a/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownMonitor.java +++ b/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownMonitor.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport.java b/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport.java index 10536f2fe13d4f46600d4d804268ddab6c2125e6..0fb37c62209b64faef0e1edbec30e77070d61465 100644 --- a/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport.java +++ b/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -53,35 +53,35 @@ public class MarshalAfterUnexport } public static void main(String[] args) throws Exception { - Remote impl2 = null; - try { - Remote impl = new MarshalAfterUnexport(); - System.err.println("created impl extending URO: " + impl); + Remote impl2 = null; + try { + Remote impl = new MarshalAfterUnexport(); + System.err.println("created impl extending URO: " + impl); - Receiver stub = (Receiver) RemoteObject.toStub(impl); - System.err.println("stub for impl: " + stub); + Receiver stub = (Receiver) RemoteObject.toStub(impl); + System.err.println("stub for impl: " + stub); - UnicastRemoteObject.unexportObject(impl, true); - System.err.println("unexported impl"); + UnicastRemoteObject.unexportObject(impl, true); + System.err.println("unexported impl"); - impl2 = new MarshalAfterUnexport(); - Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); + impl2 = new MarshalAfterUnexport(); + Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); - System.err.println("marshalling unexported object:"); - MarshalledObject mobj = new MarshalledObject(impl); + System.err.println("marshalling unexported object:"); + MarshalledObject mobj = new MarshalledObject(impl); - System.err.println("passing unexported object via RMI-JRMP:"); - stub2.receive(stub); + System.err.println("passing unexported object via RMI-JRMP:"); + stub2.receive(stub); - System.err.println("TEST PASSED"); - } finally { - if (impl2 != null) { - try { - UnicastRemoteObject.unexportObject(impl2, true); - } catch (Throwable t) { - } - } - } + System.err.println("TEST PASSED"); + } finally { + if (impl2 != null) { + try { + UnicastRemoteObject.unexportObject(impl2, true); + } catch (Throwable t) { + } + } + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2.java b/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2.java index f7d1e575d6615ea46cc703f0b81fabb2aeea8d62..7e8d3592872d6596beefa480039bf2156b8dba02 100644 --- a/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2.java +++ b/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -49,47 +49,47 @@ public class MarshalAfterUnexport2 implements Receiver { public MarshalAfterUnexport2() throws RemoteException { - super(0, null, null); + super(0, null, null); } public void receive(Remote obj) { } public static void main(String[] args) throws Exception { - - System.err.println("\nRegression test for bug 4513223\n"); - - Remote impl2 = null; - try { - Remote impl = new MarshalAfterUnexport2(); - System.err.println( - "created impl extending URO (with a UnicastServerRef2): " + - impl); - Receiver stub = (Receiver) RemoteObject.toStub(impl); - System.err.println("stub for impl: " + stub); + System.err.println("\nRegression test for bug 4513223\n"); - UnicastRemoteObject.unexportObject(impl, true); - System.err.println("unexported impl"); + Remote impl2 = null; + try { + Remote impl = new MarshalAfterUnexport2(); + System.err.println( + "created impl extending URO (with a UnicastServerRef2): " + + impl); - impl2 = new MarshalAfterUnexport2(); - Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); + Receiver stub = (Receiver) RemoteObject.toStub(impl); + System.err.println("stub for impl: " + stub); - System.err.println("marshalling unexported object:"); - MarshalledObject mobj = new MarshalledObject(impl); + UnicastRemoteObject.unexportObject(impl, true); + System.err.println("unexported impl"); - System.err.println("passing unexported object via RMI-JRMP:"); - stub2.receive(stub); + impl2 = new MarshalAfterUnexport2(); + Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); - System.err.println("TEST PASSED"); - } finally { - if (impl2 != null) { - try { - UnicastRemoteObject.unexportObject(impl2, true); - } catch (Throwable t) { - } - } - } + System.err.println("marshalling unexported object:"); + MarshalledObject mobj = new MarshalledObject(impl); + + System.err.println("passing unexported object via RMI-JRMP:"); + stub2.receive(stub); + + System.err.println("TEST PASSED"); + } finally { + if (impl2 != null) { + try { + UnicastRemoteObject.unexportObject(impl2, true); + } catch (Throwable t) { + } + } + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2_Stub.java b/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2_Stub.java index b122813d55970b31887bf88b6599eec64c287d7d..bbefd5248aa5b179839d8954c67671099e464661 100644 --- a/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2_Stub.java +++ b/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,37 +29,37 @@ public final class MarshalAfterUnexport2_Stub implements Receiver, java.rmi.Remote { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_receive_0; - + static { - try { - $method_receive_0 = Receiver.class.getMethod("receive", new java.lang.Class[] {java.rmi.Remote.class}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_receive_0 = Receiver.class.getMethod("receive", new java.lang.Class[] {java.rmi.Remote.class}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public MarshalAfterUnexport2_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of receive(Remote) public void receive(java.rmi.Remote $param_Remote_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - ref.invoke(this, $method_receive_0, new java.lang.Object[] {$param_Remote_1}, 5876293363550629411L); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + ref.invoke(this, $method_receive_0, new java.lang.Object[] {$param_Remote_1}, 5876293363550629411L); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport_Stub.java b/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport_Stub.java index 15022b4d04e38ba5df80a4c79aeb486d0c680938..535fffa00e1723f7e3d4b76039c0506a3ff3a3d4 100644 --- a/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport_Stub.java +++ b/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,37 +29,37 @@ public final class MarshalAfterUnexport_Stub implements Receiver, java.rmi.Remote { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_receive_0; - + static { - try { - $method_receive_0 = Receiver.class.getMethod("receive", new java.lang.Class[] {java.rmi.Remote.class}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_receive_0 = Receiver.class.getMethod("receive", new java.lang.Class[] {java.rmi.Remote.class}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public MarshalAfterUnexport_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of receive(Remote) public void receive(java.rmi.Remote $param_Remote_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - ref.invoke(this, $method_receive_0, new java.lang.Object[] {$param_Remote_1}, 5876293363550629411L); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + ref.invoke(this, $method_receive_0, new java.lang.Object[] {$param_Remote_1}, 5876293363550629411L); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/unexportObject/Ping.java b/test/java/rmi/server/UnicastRemoteObject/unexportObject/Ping.java index 2e88ab924cf62e769820fc39a92849b3792bec21..682915cfcf24d21cb48c68c2fc9786150d011006 100644 --- a/test/java/rmi/server/UnicastRemoteObject/unexportObject/Ping.java +++ b/test/java/rmi/server/UnicastRemoteObject/unexportObject/Ping.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,4 +26,3 @@ import java.rmi.*; public interface Ping extends Remote { public void ping() throws RemoteException; } - diff --git a/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java b/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java index e40f19e50cf46146e5671cd4b51753d3e61f79e1..de1cef7818807c5a7026a6eddf5a35ccfbb52764 100644 --- a/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java +++ b/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -24,7 +24,7 @@ /* @test * @bug 4331349 * @summary synopsis: unexporting doesn't guarantee that DGC will - * let go of remote object + * let go of remote object * * @author Ann Wollrath * @@ -40,36 +40,36 @@ import java.rmi.server.*; import java.rmi.registry.*; public class UnexportLeak implements Ping { - + private static int PORT = 2006; public void ping() { } public static void main(String[] args) { - try { - System.err.println("\nRegression test for bug 4331349\n"); - LocateRegistry.createRegistry(PORT); - Remote obj = new UnexportLeak(); - WeakReference wr = new WeakReference(obj); - UnicastRemoteObject.exportObject(obj); - LocateRegistry.getRegistry(PORT).rebind("UnexportLeak", obj); - UnicastRemoteObject.unexportObject(obj, true); - obj = null; - flushRefs(); - if (wr.get() != null) { - System.err.println("FAILED: unexported object not collected"); - throw new RuntimeException( - "FAILED: unexported object not collected"); - } else { - System.err.println("PASSED: unexported object collected"); - } - } catch (RemoteException e) { - System.err.println( - "FAILED: RemoteException encountered: " + e.getMessage()); - e.printStackTrace(); - throw new RuntimeException("FAILED: RemoteException encountered"); - } + try { + System.err.println("\nRegression test for bug 4331349\n"); + LocateRegistry.createRegistry(PORT); + Remote obj = new UnexportLeak(); + WeakReference wr = new WeakReference(obj); + UnicastRemoteObject.exportObject(obj); + LocateRegistry.getRegistry(PORT).rebind("UnexportLeak", obj); + UnicastRemoteObject.unexportObject(obj, true); + obj = null; + flushRefs(); + if (wr.get() != null) { + System.err.println("FAILED: unexported object not collected"); + throw new RuntimeException( + "FAILED: unexported object not collected"); + } else { + System.err.println("PASSED: unexported object collected"); + } + } catch (RemoteException e) { + System.err.println( + "FAILED: RemoteException encountered: " + e.getMessage()); + e.printStackTrace(); + throw new RuntimeException("FAILED: RemoteException encountered"); + } } /** @@ -77,15 +77,13 @@ public class UnexportLeak implements Ping { * will be cleared. */ private static void flushRefs() { - java.util.Vector chain = new java.util.Vector(); - try { - while (true) { - int[] hungry = new int[65536]; - chain.addElement(hungry); - } - } catch (OutOfMemoryError e) { - } + java.util.Vector chain = new java.util.Vector(); + try { + while (true) { + int[] hungry = new int[65536]; + chain.addElement(hungry); + } + } catch (OutOfMemoryError e) { + } } } - - diff --git a/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak_Stub.java b/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak_Stub.java index 1f7ab308c205952c58d3dd8f79170a626102cf9d..56102aa54fe5af26be56420c845b416d8bbc1641 100644 --- a/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak_Stub.java +++ b/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,37 +29,37 @@ public final class UnexportLeak_Stub implements Ping { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_ping_0; - + static { - try { - $method_ping_0 = Ping.class.getMethod("ping", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_ping_0 = Ping.class.getMethod("ping", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public UnexportLeak_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of ping() public void ping() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - ref.invoke(this, $method_ping_0, null, 5866401369815527589L); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + ref.invoke(this, $method_ping_0, null, 5866401369815527589L); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies.java b/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies.java index bec4e954f805c43faeb635d4b763db1d3b71a633..62b0ae9339b08df670800e56d7f8a11a60fe9d46 100644 --- a/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies.java +++ b/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -43,75 +43,75 @@ public class UseDynamicProxies implements RemoteInterface { public Object passObject(Object obj) { - return obj; + return obj; } public int passInt(int x) { - return x; + return x; } public String passString(String string) { - return string; + return string; } public static void main(String[] args) throws Exception { - - RemoteInterface server = null; - RemoteInterface proxy = null; - - try { - System.setProperty("java.rmi.server.ignoreStubClasses", args[0]); - boolean ignoreStubClasses = Boolean.parseBoolean(args[0]); - - if (System.getSecurityManager() == null) { - System.setSecurityManager(new SecurityManager()); - } - - System.err.println("export object"); - server = new UseDynamicProxies(); - proxy = - (RemoteInterface) UnicastRemoteObject.exportObject(server, 0); - - System.err.println("proxy = " + proxy); - if (ignoreStubClasses) { - if (!Proxy.isProxyClass(proxy.getClass())) { - throw new RuntimeException( - "server proxy is not a dynamic proxy"); - } - if (!(Proxy.getInvocationHandler(proxy) instanceof - RemoteObjectInvocationHandler)) - { - throw new RuntimeException("invalid invocation handler"); - } - - } else if (!(proxy instanceof RemoteStub)) { - throw new RuntimeException( - "server proxy is not a RemoteStub"); - } - - System.err.println("invoke methods"); - Object obj = proxy.passObject(proxy); - if (!proxy.equals(obj)) { - throw new RuntimeException("returned proxy not equal"); - } - - int x = proxy.passInt(53); - if (x != 53) { - throw new RuntimeException("returned int not equal"); - } - - String string = proxy.passString("test"); - if (!string.equals("test")) { - throw new RuntimeException("returned string not equal"); - } - - System.err.println("TEST PASSED"); - - } finally { - if (proxy != null) { - UnicastRemoteObject.unexportObject(server, true); - } - } + + RemoteInterface server = null; + RemoteInterface proxy = null; + + try { + System.setProperty("java.rmi.server.ignoreStubClasses", args[0]); + boolean ignoreStubClasses = Boolean.parseBoolean(args[0]); + + if (System.getSecurityManager() == null) { + System.setSecurityManager(new SecurityManager()); + } + + System.err.println("export object"); + server = new UseDynamicProxies(); + proxy = + (RemoteInterface) UnicastRemoteObject.exportObject(server, 0); + + System.err.println("proxy = " + proxy); + if (ignoreStubClasses) { + if (!Proxy.isProxyClass(proxy.getClass())) { + throw new RuntimeException( + "server proxy is not a dynamic proxy"); + } + if (!(Proxy.getInvocationHandler(proxy) instanceof + RemoteObjectInvocationHandler)) + { + throw new RuntimeException("invalid invocation handler"); + } + + } else if (!(proxy instanceof RemoteStub)) { + throw new RuntimeException( + "server proxy is not a RemoteStub"); + } + + System.err.println("invoke methods"); + Object obj = proxy.passObject(proxy); + if (!proxy.equals(obj)) { + throw new RuntimeException("returned proxy not equal"); + } + + int x = proxy.passInt(53); + if (x != 53) { + throw new RuntimeException("returned int not equal"); + } + + String string = proxy.passString("test"); + if (!string.equals("test")) { + throw new RuntimeException("returned string not equal"); + } + + System.err.println("TEST PASSED"); + + } finally { + if (proxy != null) { + UnicastRemoteObject.unexportObject(server, true); + } + } } } diff --git a/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies_Stub.java b/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies_Stub.java index 549c2396ab8d9b2e9deffb5932c4c8ad69b3338c..b567c29ebd69694a3fe14d1118b3c8abc9f8942b 100644 --- a/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies_Stub.java +++ b/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,74 +29,74 @@ public final class UseDynamicProxies_Stub implements RemoteInterface { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_passInt_0; private static java.lang.reflect.Method $method_passObject_1; private static java.lang.reflect.Method $method_passString_2; - + static { - try { - $method_passInt_0 = RemoteInterface.class.getMethod("passInt", new java.lang.Class[] {int.class}); - $method_passObject_1 = RemoteInterface.class.getMethod("passObject", new java.lang.Class[] {java.lang.Object.class}); - $method_passString_2 = RemoteInterface.class.getMethod("passString", new java.lang.Class[] {java.lang.String.class}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_passInt_0 = RemoteInterface.class.getMethod("passInt", new java.lang.Class[] {int.class}); + $method_passObject_1 = RemoteInterface.class.getMethod("passObject", new java.lang.Class[] {java.lang.Object.class}); + $method_passString_2 = RemoteInterface.class.getMethod("passString", new java.lang.Class[] {java.lang.String.class}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public UseDynamicProxies_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of passInt(int) public int passInt(int $param_int_1) - throws java.io.IOException + throws java.io.IOException { - try { - Object $result = ref.invoke(this, $method_passInt_0, new java.lang.Object[] {new java.lang.Integer($param_int_1)}, 8655249712495061761L); - return ((java.lang.Integer) $result).intValue(); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.io.IOException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + Object $result = ref.invoke(this, $method_passInt_0, new java.lang.Object[] {new java.lang.Integer($param_int_1)}, 8655249712495061761L); + return ((java.lang.Integer) $result).intValue(); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.io.IOException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of passObject(Object) public java.lang.Object passObject(java.lang.Object $param_Object_1) - throws java.io.IOException + throws java.io.IOException { - try { - Object $result = ref.invoke(this, $method_passObject_1, new java.lang.Object[] {$param_Object_1}, 3074202549763602823L); - return ((java.lang.Object) $result); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.io.IOException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + Object $result = ref.invoke(this, $method_passObject_1, new java.lang.Object[] {$param_Object_1}, 3074202549763602823L); + return ((java.lang.Object) $result); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.io.IOException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of passString(String) public java.lang.String passString(java.lang.String $param_String_1) - throws java.io.IOException + throws java.io.IOException { - try { - Object $result = ref.invoke(this, $method_passString_2, new java.lang.Object[] {$param_String_1}, 6627880292288702000L); - return ((java.lang.String) $result); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.io.IOException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + Object $result = ref.invoke(this, $method_passString_2, new java.lang.Object[] {$param_String_1}, 6627880292288702000L); + return ((java.lang.String) $result); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.io.IOException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread.java b/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread.java index e4634841305dec1932064b87cdf3ef987fcc45ad..a12af61e4d74fc25eb2b23ee34d07d0f123b4c2d 100644 --- a/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread.java +++ b/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -22,7 +22,7 @@ */ /* @test - * @bug 4118600 + * @bug 4118600 * @summary RMI UnmarshallException, interaction on stopping a thread. * * @bug 4177704 @@ -35,7 +35,7 @@ * @build CheckUnmarshall PoisonPill RuntimeExceptionParameter * @build CheckUnmarshalOnStopThread * @build CheckUnmarshalOnStopThread_Stub - * @run main/othervm/timeout=480 CheckUnmarshalOnStopThread + * @run main/othervm/timeout=480 CheckUnmarshalOnStopThread */ import java.rmi.*; @@ -44,7 +44,7 @@ import java.io.*; import java.rmi.registry.*; /** - * Description for 4118600: + * Description for 4118600: * * If an rmi call thread is stopped while unmarshalling a return * value), java.lang.ThreadDeath will be thrown during @@ -77,8 +77,8 @@ import java.rmi.registry.*; * occur. This test is only written to track UnmarshalExceptions; * success/failure does not depend on other types of problems. * - * Description for 4177704: - * + * Description for 4177704: + * * Similar situation as for 4177704 except that instead of just * ensuring that RMI properly handles Errors, the second part of the * test ensures that RMI deals with RuntimeExceptions correctly. @@ -88,110 +88,110 @@ import java.rmi.registry.*; * parameters. An object that throws a RuntimeException in its * writeObject method helps to carry out this part of the test. */ -public class CheckUnmarshalOnStopThread - extends UnicastRemoteObject - implements CheckUnmarshal +public class CheckUnmarshalOnStopThread + extends UnicastRemoteObject + implements CheckUnmarshal { final static int RUNTIME_PILL = 1; public static int typeToThrow = 0; /* - * remote object implementation + * remote object implementation */ CheckUnmarshalOnStopThread() throws RemoteException { } public PoisonPill getPoisonPill() throws RemoteException { - return new PoisonPill(new Integer(0)); + return new PoisonPill(new Integer(0)); } public Object ping() throws RemoteException { - return (Object) new Integer(0); + return (Object) new Integer(0); } public void passRuntimeExceptionParameter( - RuntimeExceptionParameter rep) throws RemoteException + RuntimeExceptionParameter rep) throws RemoteException { - // will never be called + // will never be called } public static void main(String [] args) { - Object dummy = new Object(); - CheckUnmarshal cu = null; - CheckUnmarshalOnStopThread cuonst = null; - - System.err.println("\nregression test for bugs: " + - "4118600 and 4177704\n"); - - try { - cuonst = new CheckUnmarshalOnStopThread(); - cu = (CheckUnmarshal) UnicastRemoteObject.toStub(cuonst); - - // make sure that RMI will free connections appropriately - // under several situations: - - // when Errors are thrown during parameter unmarshalling - System.err.println("testing to see if RMI will handle errors"); - ensureConnectionsAreFreed(cu, true); - - // when RuntimeExceptions are thrown during parameter unmarshalling - System.err.println("testing to see if RMI will handle " + - "runtime exceptions"); - typeToThrow = RUNTIME_PILL; - ensureConnectionsAreFreed(cu, true); - - // when RuntimeExceptions are thrown during parameter marshalling - System.err.println("testing to see if RMI will handle " + - "runtime exceptions thrown during " + - "parameter marshalling"); - ensureConnectionsAreFreed(cu, false); - - System.err.println - ("\nsuccess: CheckUnmarshalOnStopThread test passed "); - - } catch (Exception e) { - TestLibrary.bomb(e); - } finally { - cu = null; - deactivate(cuonst); - } + Object dummy = new Object(); + CheckUnmarshal cu = null; + CheckUnmarshalOnStopThread cuonst = null; + + System.err.println("\nregression test for bugs: " + + "4118600 and 4177704\n"); + + try { + cuonst = new CheckUnmarshalOnStopThread(); + cu = (CheckUnmarshal) UnicastRemoteObject.toStub(cuonst); + + // make sure that RMI will free connections appropriately + // under several situations: + + // when Errors are thrown during parameter unmarshalling + System.err.println("testing to see if RMI will handle errors"); + ensureConnectionsAreFreed(cu, true); + + // when RuntimeExceptions are thrown during parameter unmarshalling + System.err.println("testing to see if RMI will handle " + + "runtime exceptions"); + typeToThrow = RUNTIME_PILL; + ensureConnectionsAreFreed(cu, true); + + // when RuntimeExceptions are thrown during parameter marshalling + System.err.println("testing to see if RMI will handle " + + "runtime exceptions thrown during " + + "parameter marshalling"); + ensureConnectionsAreFreed(cu, false); + + System.err.println + ("\nsuccess: CheckUnmarshalOnStopThread test passed "); + + } catch (Exception e) { + TestLibrary.bomb(e); + } finally { + cu = null; + deactivate(cuonst); + } } - - static void ensureConnectionsAreFreed(CheckUnmarshal cu, boolean getPill) - throws Exception + + static void ensureConnectionsAreFreed(CheckUnmarshal cu, boolean getPill) + throws Exception { - // invoke a remote call that will corrupt a call connection - // that will not be freed (if the bug is not fixed) - - for (int i = 0 ; i < 250 ; i++) { - try { - Object test = cu.ping(); - if (getPill) { - cu.getPoisonPill(); - } else { - cu.passRuntimeExceptionParameter( - new RuntimeExceptionParameter()); - } - } catch (Error e) { - // expect an Error from call unmarshalling, ignore it - } catch (RuntimeException e) { - // " RuntimeException " - } - } - - System.err.println("remote calls passed, received no " + - "unmarshal exceptions\n\n"); + // invoke a remote call that will corrupt a call connection + // that will not be freed (if the bug is not fixed) + + for (int i = 0 ; i < 250 ; i++) { + try { + Object test = cu.ping(); + if (getPill) { + cu.getPoisonPill(); + } else { + cu.passRuntimeExceptionParameter( + new RuntimeExceptionParameter()); + } + } catch (Error e) { + // expect an Error from call unmarshalling, ignore it + } catch (RuntimeException e) { + // " RuntimeException " + } + } + + System.err.println("remote calls passed, received no " + + "unmarshal exceptions\n\n"); } static void deactivate(RemoteServer r) { - // make sure that the object goes away - try { - System.err.println("deactivating object."); - UnicastRemoteObject.unexportObject(r, true); - } catch (Exception e) { - e.getMessage(); - e.printStackTrace(); - } + // make sure that the object goes away + try { + System.err.println("deactivating object."); + UnicastRemoteObject.unexportObject(r, true); + } catch (Exception e) { + e.getMessage(); + e.printStackTrace(); + } } } diff --git a/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread_Stub.java b/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread_Stub.java index 1fa93b1788312d4e132c8f14d0c7d792d860bbe0..612fe5db494f078aede99da513ff5dc91c483503 100644 --- a/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread_Stub.java +++ b/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,138 +29,138 @@ public final class CheckUnmarshalOnStopThread_Stub implements CheckUnmarshal, java.rmi.Remote { private static final java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("PoisonPill getPoisonPill()"), - new java.rmi.server.Operation("void passRuntimeExceptionParameter(RuntimeExceptionParameter)"), - new java.rmi.server.Operation("java.lang.Object ping()") + new java.rmi.server.Operation("PoisonPill getPoisonPill()"), + new java.rmi.server.Operation("void passRuntimeExceptionParameter(RuntimeExceptionParameter)"), + new java.rmi.server.Operation("java.lang.Object ping()") }; - + private static final long interfaceHash = -5923540687975666490L; - + private static final long serialVersionUID = 2; - + private static boolean useNewInvoke; private static java.lang.reflect.Method $method_getPoisonPill_0; private static java.lang.reflect.Method $method_passRuntimeExceptionParameter_1; private static java.lang.reflect.Method $method_ping_2; - + static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_getPoisonPill_0 = CheckUnmarshal.class.getMethod("getPoisonPill", new java.lang.Class[] {}); - $method_passRuntimeExceptionParameter_1 = CheckUnmarshal.class.getMethod("passRuntimeExceptionParameter", new java.lang.Class[] {RuntimeExceptionParameter.class}); - $method_ping_2 = CheckUnmarshal.class.getMethod("ping", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } + try { + java.rmi.server.RemoteRef.class.getMethod("invoke", + new java.lang.Class[] { + java.rmi.Remote.class, + java.lang.reflect.Method.class, + java.lang.Object[].class, + long.class + }); + useNewInvoke = true; + $method_getPoisonPill_0 = CheckUnmarshal.class.getMethod("getPoisonPill", new java.lang.Class[] {}); + $method_passRuntimeExceptionParameter_1 = CheckUnmarshal.class.getMethod("passRuntimeExceptionParameter", new java.lang.Class[] {RuntimeExceptionParameter.class}); + $method_ping_2 = CheckUnmarshal.class.getMethod("ping", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + useNewInvoke = false; + } } - + // constructors public CheckUnmarshalOnStopThread_Stub() { - super(); + super(); } public CheckUnmarshalOnStopThread_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of getPoisonPill() public PoisonPill getPoisonPill() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - Object $result = ref.invoke(this, $method_getPoisonPill_0, null, 5776441251039617360L); - return ((PoisonPill) $result); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - ref.invoke(call); - PoisonPill $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = (PoisonPill) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + Object $result = ref.invoke(this, $method_getPoisonPill_0, null, 5776441251039617360L); + return ((PoisonPill) $result); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + ref.invoke(call); + PoisonPill $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = (PoisonPill) in.readObject(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } catch (java.lang.ClassNotFoundException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of passRuntimeExceptionParameter(RuntimeExceptionParameter) public void passRuntimeExceptionParameter(RuntimeExceptionParameter $param_RuntimeExceptionParameter_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - ref.invoke(this, $method_passRuntimeExceptionParameter_1, new java.lang.Object[] {$param_RuntimeExceptionParameter_1}, -4427599990679364365L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); - try { - java.io.ObjectOutput out = call.getOutputStream(); - out.writeObject($param_RuntimeExceptionParameter_1); - } catch (java.io.IOException e) { - throw new java.rmi.MarshalException("error marshalling arguments", e); - } - ref.invoke(call); - ref.done(call); - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + ref.invoke(this, $method_passRuntimeExceptionParameter_1, new java.lang.Object[] {$param_RuntimeExceptionParameter_1}, -4427599990679364365L); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); + try { + java.io.ObjectOutput out = call.getOutputStream(); + out.writeObject($param_RuntimeExceptionParameter_1); + } catch (java.io.IOException e) { + throw new java.rmi.MarshalException("error marshalling arguments", e); + } + ref.invoke(call); + ref.done(call); + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of ping() public java.lang.Object ping() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - Object $result = ref.invoke(this, $method_ping_2, null, 7635508643486276040L); - return ((java.lang.Object) $result); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash); - ref.invoke(call); - java.lang.Object $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = (java.lang.Object) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + Object $result = ref.invoke(this, $method_ping_2, null, 7635508643486276040L); + return ((java.lang.Object) $result); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash); + ref.invoke(call); + java.lang.Object $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = (java.lang.Object) in.readObject(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } catch (java.lang.ClassNotFoundException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshall.java b/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshall.java index b11565819761b10ae804dd812c7b2ac847b8e6fd..327081c9d8a06785d95cd451326fbe50552c0ca4 100644 --- a/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshall.java +++ b/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshall.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -20,7 +20,7 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ - + /** * */ @@ -37,4 +37,3 @@ import java.rmi.RemoteException; RuntimeExceptionParameter rep) throws RemoteException; } - diff --git a/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/PoisonPill.java b/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/PoisonPill.java index f9c488797af255a5ed865eb8614b4c063f18040c..3c885926c1ff2fe93d7919265a9172d9acf458ba 100644 --- a/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/PoisonPill.java +++ b/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/PoisonPill.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -45,7 +45,7 @@ public class PoisonPill implements Serializable { throws IOException { if (CheckUnmarshalOnStopThread.typeToThrow != - CheckUnmarshalOnStopThread.RUNTIME_PILL) { + CheckUnmarshalOnStopThread.RUNTIME_PILL) { throw new Error("Wrote a test object whos readObject " + "method always throws an Error"); diff --git a/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/RuntimeExceptionParameter.java b/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/RuntimeExceptionParameter.java index efaaee82657e770e09452b563c0cb2f3298ad9b0..8d8f5e94c17d33ce010221a552d0e2ff7e49bb71 100644 --- a/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/RuntimeExceptionParameter.java +++ b/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/RuntimeExceptionParameter.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,7 +38,6 @@ class RuntimeExceptionParameter implements Serializable { { throw new RuntimeException("wrote a parameter whos writeObject " + "method always throws a RuntimeException" - ); + ); } } - diff --git a/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java b/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java index b171c827024f16c1ae677289f316ec309598ca04..05f30142beeccdbaed781dd54378f50630a84e6f 100644 --- a/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java +++ b/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -54,69 +54,69 @@ public class FiniteGCLatency implements Remote, Unreferenced { private boolean unreferencedInvoked = false; public void unreferenced() { - System.err.println("unreferenced() method invoked"); - synchronized (lock) { - unreferencedInvoked = true; - lock.notify(); - } + System.err.println("unreferenced() method invoked"); + synchronized (lock) { + unreferencedInvoked = true; + lock.notify(); + } } public static void main(String[] args) { - System.err.println("\nRegression test for bug 4164696\n"); - - /* - * Set the interval that RMI will request for GC latency (before RMI - * gets initialized and this property is read) to an unrealistically - * small value, so that this test shouldn't have to wait too long. - */ - System.setProperty("sun.rmi.dgc.client.gcInterval", - String.valueOf(GC_INTERVAL)); - - FiniteGCLatency obj = new FiniteGCLatency(); - - try { - UnicastRemoteObject.exportObject(obj); - System.err.println("exported remote object"); - - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); - System.err.println("created registry"); - - Registry registry = LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); - registry.bind(BINDING, obj); - System.err.println("bound remote object in registry"); - - synchronized (obj.lock) { - registry.unbind(BINDING); - System.err.println("unbound remote object from registry; " + - "waiting for unreferenced() callback..."); - obj.lock.wait(TIMEOUT); - - if (obj.unreferencedInvoked) { - System.err.println("TEST PASSED: unreferenced() invoked"); - } else { - throw new RuntimeException( - "TEST FAILED: unrefereced() not invoked after " + - ((double) TIMEOUT / 1000.0) + " seconds"); - } - } - - } catch (Exception e) { - if (e instanceof RuntimeException) { - throw (RuntimeException) e; - } else { - throw new RuntimeException( - "TEST FAILED: unexpected exception: " + e.toString()); - } - } finally { - /* - * When all is said and done, try to unexport the remote object - * so that the VM has a chance to exit. - */ - try { - UnicastRemoteObject.unexportObject(obj, true); - } catch (RemoteException e) { - } - } + System.err.println("\nRegression test for bug 4164696\n"); + + /* + * Set the interval that RMI will request for GC latency (before RMI + * gets initialized and this property is read) to an unrealistically + * small value, so that this test shouldn't have to wait too long. + */ + System.setProperty("sun.rmi.dgc.client.gcInterval", + String.valueOf(GC_INTERVAL)); + + FiniteGCLatency obj = new FiniteGCLatency(); + + try { + UnicastRemoteObject.exportObject(obj); + System.err.println("exported remote object"); + + LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + System.err.println("created registry"); + + Registry registry = LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); + registry.bind(BINDING, obj); + System.err.println("bound remote object in registry"); + + synchronized (obj.lock) { + registry.unbind(BINDING); + System.err.println("unbound remote object from registry; " + + "waiting for unreferenced() callback..."); + obj.lock.wait(TIMEOUT); + + if (obj.unreferencedInvoked) { + System.err.println("TEST PASSED: unreferenced() invoked"); + } else { + throw new RuntimeException( + "TEST FAILED: unrefereced() not invoked after " + + ((double) TIMEOUT / 1000.0) + " seconds"); + } + } + + } catch (Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException) e; + } else { + throw new RuntimeException( + "TEST FAILED: unexpected exception: " + e.toString()); + } + } finally { + /* + * When all is said and done, try to unexport the remote object + * so that the VM has a chance to exit. + */ + try { + UnicastRemoteObject.unexportObject(obj, true); + } catch (RemoteException e) { + } + } } } diff --git a/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency_Stub.java b/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency_Stub.java index 4acb848188d8440b2575d476cbdb2f07d86ea979..97c275b4fd09be57fdcc07b496547a6738a978e6 100644 --- a/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency_Stub.java +++ b/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,10 +29,10 @@ public final class FiniteGCLatency_Stub implements java.rmi.Remote { private static final long serialVersionUID = 2; - + // constructors public FiniteGCLatency_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + } diff --git a/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java b/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java index 4458b3c5a0563318cb7c684b56f50f73cf6b6886..6687b9202a8ccae80a1f09ef4fb14459c8b2a9b3 100644 --- a/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java +++ b/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -62,71 +62,71 @@ public class LeaseCheckInterval implements Remote, Unreferenced { private boolean unreferencedInvoked = false; public void unreferenced() { - System.err.println("unreferenced() method invoked"); - synchronized (lock) { - unreferencedInvoked = true; - lock.notify(); - } + System.err.println("unreferenced() method invoked"); + synchronized (lock) { + unreferencedInvoked = true; + lock.notify(); + } } public static void main(String[] args) throws Exception { - System.err.println("\nRegression test for bug 4285878\n"); - - /* - * Set the duration of leases granted to a very small value, so that - * we can test if expirations are detected in a roughly comparable - * time. - */ - System.setProperty("java.rmi.dgc.leaseValue", - String.valueOf(LEASE_VALUE)); - - LeaseCheckInterval obj = new LeaseCheckInterval(); - - try { - UnicastRemoteObject.exportObject(obj); - System.err.println("exported remote object"); - - Registry localRegistry = - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); - System.err.println("created local registry"); - - localRegistry.bind(BINDING, obj); - System.err.println("bound remote object in local registry"); - - synchronized (obj.lock) { - System.err.println("starting remote client VM..."); - (new JavaVM("SelfTerminator")).start(); - - System.err.println("waiting for unreferenced() callback..."); - obj.lock.wait(TIMEOUT); - - if (obj.unreferencedInvoked) { - System.err.println("TEST PASSED: " + - "unreferenced() invoked in timely fashion"); - } else { - throw new RuntimeException( - "TEST FAILED: unreferenced() not invoked after " + - ((double) TIMEOUT / 1000.0) + " seconds"); - } - } - - } catch (Exception e) { - if (e instanceof RuntimeException) { - throw (RuntimeException) e; - } else { - throw new RuntimeException( - "TEST FAILED: unexpected exception: " + e.toString()); - } - } finally { - /* - * When all is said and done, try to unexport the remote object - * so that the VM has a chance to exit. - */ - try { - UnicastRemoteObject.unexportObject(obj, true); - } catch (RemoteException e) { - } - } + System.err.println("\nRegression test for bug 4285878\n"); + + /* + * Set the duration of leases granted to a very small value, so that + * we can test if expirations are detected in a roughly comparable + * time. + */ + System.setProperty("java.rmi.dgc.leaseValue", + String.valueOf(LEASE_VALUE)); + + LeaseCheckInterval obj = new LeaseCheckInterval(); + + try { + UnicastRemoteObject.exportObject(obj); + System.err.println("exported remote object"); + + Registry localRegistry = + LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + System.err.println("created local registry"); + + localRegistry.bind(BINDING, obj); + System.err.println("bound remote object in local registry"); + + synchronized (obj.lock) { + System.err.println("starting remote client VM..."); + (new JavaVM("SelfTerminator")).start(); + + System.err.println("waiting for unreferenced() callback..."); + obj.lock.wait(TIMEOUT); + + if (obj.unreferencedInvoked) { + System.err.println("TEST PASSED: " + + "unreferenced() invoked in timely fashion"); + } else { + throw new RuntimeException( + "TEST FAILED: unreferenced() not invoked after " + + ((double) TIMEOUT / 1000.0) + " seconds"); + } + } + + } catch (Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException) e; + } else { + throw new RuntimeException( + "TEST FAILED: unexpected exception: " + e.toString()); + } + } finally { + /* + * When all is said and done, try to unexport the remote object + * so that the VM has a chance to exit. + */ + try { + UnicastRemoteObject.unexportObject(obj, true); + } catch (RemoteException e) { + } + } } } diff --git a/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval_Stub.java b/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval_Stub.java index 5f258fbfb40c369051b6b05d92564c3a24d93e7f..950e30982a358573e446cf7ffbb97cc5edd10c07 100644 --- a/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval_Stub.java +++ b/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,10 +29,10 @@ public final class LeaseCheckInterval_Stub implements java.rmi.Remote { private static final long serialVersionUID = 2; - + // constructors public LeaseCheckInterval_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + } diff --git a/test/java/rmi/server/Unreferenced/leaseCheckInterval/SelfTerminator.java b/test/java/rmi/server/Unreferenced/leaseCheckInterval/SelfTerminator.java index 98d632fbca14d6e4b8bb95fad185ff2b655243f3..65e65f3e0b3b5ebea51d24b93c3ba4e9585bd083 100644 --- a/test/java/rmi/server/Unreferenced/leaseCheckInterval/SelfTerminator.java +++ b/test/java/rmi/server/Unreferenced/leaseCheckInterval/SelfTerminator.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,13 +32,13 @@ import java.rmi.registry.Registry; public class SelfTerminator { public static void main(String[] args) { - try { - Registry registry = - LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); - Remote stub = registry.lookup(LeaseCheckInterval.BINDING); - Runtime.getRuntime().halt(0); - } catch (Exception e) { - e.printStackTrace(); - } + try { + Registry registry = + LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); + Remote stub = registry.lookup(LeaseCheckInterval.BINDING); + Runtime.getRuntime().halt(0); + } catch (Exception e) { + e.printStackTrace(); + } } } diff --git a/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet.java b/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet.java index 2b918b6ea7b73b24794b8b60f4bf8430242d2897..ea3a25d29456269d478c232cf0940acf4893984c 100644 --- a/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet.java +++ b/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000-2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -51,72 +51,72 @@ public class MarshalledObjectGet implements Remote, Unreferenced { private boolean unreferencedInvoked; public void unreferenced() { - System.err.println("unreferenced() method invoked"); - synchronized (lock) { - unreferencedInvoked = true; - lock.notify(); - } + System.err.println("unreferenced() method invoked"); + synchronized (lock) { + unreferencedInvoked = true; + lock.notify(); + } } public static void main(String[] args) { - System.err.println( - "\nTest to verify correction interaction of " + - "MarshalledObject.get and DGC registration\n"); - - /* - * Set the interval that RMI will request for GC latency (before RMI - * gets initialized and this property is read) to an unrealistically - * small value, so that this test shouldn't have to wait too long. - */ - System.setProperty("sun.rmi.dgc.client.gcInterval", - String.valueOf(GC_INTERVAL)); - - MarshalledObjectGet obj = new MarshalledObjectGet(); - - try { - Remote stub = UnicastRemoteObject.exportObject(obj); - System.err.println("exported remote object"); - - MarshalledObject mobj = new MarshalledObject(stub); - Remote unmarshalledStub = (Remote) mobj.get(); - System.err.println("unmarshalled stub from marshalled object"); - - synchronized (obj.lock) { - obj.unreferencedInvoked = false; - - unmarshalledStub = null; - System.gc(); - System.err.println("cleared unmarshalled stub"); - System.err.println("waiting for unreferenced() callback " + - "(SHOULD happen)..."); - obj.lock.wait(TIMEOUT); - - if (obj.unreferencedInvoked) { - // TEST PASSED - } else { - throw new RuntimeException( - "TEST FAILED: unrefereced() not invoked after " + - ((double) TIMEOUT / 1000.0) + " seconds"); - } - } - - System.err.println("TEST PASSED"); - - } catch (Exception e) { - if (e instanceof RuntimeException) { - throw (RuntimeException) e; - } else { - throw new RuntimeException( - "TEST FAILED: unexpected exception: " + e.toString()); - } - } finally { - if (obj != null) { - try { - UnicastRemoteObject.unexportObject(obj, true); - } catch (Exception e) { - } - } - } + System.err.println( + "\nTest to verify correction interaction of " + + "MarshalledObject.get and DGC registration\n"); + + /* + * Set the interval that RMI will request for GC latency (before RMI + * gets initialized and this property is read) to an unrealistically + * small value, so that this test shouldn't have to wait too long. + */ + System.setProperty("sun.rmi.dgc.client.gcInterval", + String.valueOf(GC_INTERVAL)); + + MarshalledObjectGet obj = new MarshalledObjectGet(); + + try { + Remote stub = UnicastRemoteObject.exportObject(obj); + System.err.println("exported remote object"); + + MarshalledObject mobj = new MarshalledObject(stub); + Remote unmarshalledStub = (Remote) mobj.get(); + System.err.println("unmarshalled stub from marshalled object"); + + synchronized (obj.lock) { + obj.unreferencedInvoked = false; + + unmarshalledStub = null; + System.gc(); + System.err.println("cleared unmarshalled stub"); + System.err.println("waiting for unreferenced() callback " + + "(SHOULD happen)..."); + obj.lock.wait(TIMEOUT); + + if (obj.unreferencedInvoked) { + // TEST PASSED + } else { + throw new RuntimeException( + "TEST FAILED: unrefereced() not invoked after " + + ((double) TIMEOUT / 1000.0) + " seconds"); + } + } + + System.err.println("TEST PASSED"); + + } catch (Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException) e; + } else { + throw new RuntimeException( + "TEST FAILED: unexpected exception: " + e.toString()); + } + } finally { + if (obj != null) { + try { + UnicastRemoteObject.unexportObject(obj, true); + } catch (Exception e) { + } + } + } } } diff --git a/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet_Stub.java b/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet_Stub.java index e6bbe1fa5b6819cd93915ef2e43200f94488966f..55189cad77a9f7f9e0583487f5ad60da9a94ff4f 100644 --- a/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet_Stub.java +++ b/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,10 +29,10 @@ public final class MarshalledObjectGet_Stub implements java.rmi.Remote { private static final long serialVersionUID = 2; - + // constructors public MarshalledObjectGet_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + } diff --git a/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java b/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java index f9566c0245edb427f3547827b05bafef69d4ea32..eafb5e041a0b2c26223bb7c74c480a5ff2bfa05e 100644 --- a/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java +++ b/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,12 +32,12 @@ * * @bug 4214123 * @summary Unreferenced.unreferenced(...) threads should run in the nonSystem group. - * To complete the fix for, 4182104, RMI unreferenced threads should also + * To complete the fix for, 4182104, RMI unreferenced threads should also * run in the nonSystem so that they do not need permissions to modify the * system thread group. * * @author Laird Dornin - * + * * @library ../../../testlibrary * @build UnreferencedContext * @build UnreferencedContext_Stub @@ -60,127 +60,127 @@ public class UnreferencedContext implements Remote, Unreferenced, Runnable { private ClassLoader unreferencedContext; public void run() { - System.err.println("unreferenced method created thread succesfully"); + System.err.println("unreferenced method created thread succesfully"); } public void unreferenced() { - // turn on security to ensure that the action below will not - // require extra permissions - System.setSecurityManager(new java.rmi.RMISecurityManager()); - - // exercise functionality prohibited by 4214123 - (new Thread(this)).start(); - - System.err.println("unreferenced() method invoked"); - synchronized (lock) { - unreferencedInvoked = true; - unreferencedContext = - Thread.currentThread().getContextClassLoader(); - lock.notify(); - } + // turn on security to ensure that the action below will not + // require extra permissions + System.setSecurityManager(new java.rmi.RMISecurityManager()); + + // exercise functionality prohibited by 4214123 + (new Thread(this)).start(); + + System.err.println("unreferenced() method invoked"); + synchronized (lock) { + unreferencedInvoked = true; + unreferencedContext = + Thread.currentThread().getContextClassLoader(); + lock.notify(); + } } public static void main(String[] args) { - System.err.println("\nRegression test for bug 4171278\n"); - - /* - * Set the interval that RMI will request for GC latency (before RMI - * gets initialized and this property is read) to an unrealistically - * small value, so that this test shouldn't have to wait too long. - */ - System.setProperty("sun.rmi.dgc.client.gcInterval", - String.valueOf(GC_INTERVAL)); - - UnreferencedContext obj = new UnreferencedContext(); - - try { - /* - * This little trick is necessary to make sure that the RMI server - * threads for objects created on the default port get created - * before we set our special context class loader, so that they - * don't *accidentally* inherit it when making the unreferenced() - * callback. - */ - UnicastRemoteObject.exportObject(obj); - UnicastRemoteObject.unexportObject(obj, true); - - /* - * Now create special context class loader before exporting the - * remote object for real, so that it should be set when the - * object's unreferenced() method is called. - */ - ClassLoader intendedContext = new URLClassLoader(new URL[0]); - Thread.currentThread().setContextClassLoader(intendedContext); - System.err.println( - "created and set intended context class loader: " + - intendedContext); - - UnicastRemoteObject.exportObject(obj); - System.err.println("exported remote object"); - - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); - System.err.println("created registry"); - - Registry registry = LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); - registry.bind(BINDING, obj); - System.err.println("bound remote object in registry"); - - synchronized (obj.lock) { - registry.unbind(BINDING); - System.err.println("unbound remote object from registry; " + - "waiting for unreferenced() callback..."); - /* - * This incantation seems sufficient to work around the - * ramifications of 4164696, so that this test will actually - * prove something useful about 1.2Beta4 or 1.2FCS before - * 4171278 was fixed. - */ - for (int i = 0; i < 10; i++) { - System.gc(); - obj.lock.wait(TIMEOUT / 10); - if (obj.unreferencedInvoked) { - break; - } - } - - if (obj.unreferencedInvoked) { - System.err.println( - "invoked with context class loader: " + - obj.unreferencedContext); - - if (obj.unreferencedContext == intendedContext) { - System.err.println( - "TEST PASSED: unreferenced() invoked" + - " with intended context class loader"); - } else { - throw new RuntimeException( - "TEST FAILED: unreferenced() invoked" + - " with incorrect context class loader"); - } - } else { - throw new RuntimeException( - "TEST FAILED: unreferenced() not invoked after " + - ((double) TIMEOUT / 1000.0) + " seconds or unreferenced failed to create a thread"); - } - } - - } catch (Exception e) { - if (e instanceof RuntimeException) { - throw (RuntimeException) e; - } else { - throw new RuntimeException( - "TEST FAILED: unexpected exception: " + e.toString()); - } - } finally { - /* - * When all is said and done, try to unexport the remote object - * so that the VM has a chance to exit. - */ - try { - UnicastRemoteObject.unexportObject(obj, true); - } catch (RemoteException e) { - } - } + System.err.println("\nRegression test for bug 4171278\n"); + + /* + * Set the interval that RMI will request for GC latency (before RMI + * gets initialized and this property is read) to an unrealistically + * small value, so that this test shouldn't have to wait too long. + */ + System.setProperty("sun.rmi.dgc.client.gcInterval", + String.valueOf(GC_INTERVAL)); + + UnreferencedContext obj = new UnreferencedContext(); + + try { + /* + * This little trick is necessary to make sure that the RMI server + * threads for objects created on the default port get created + * before we set our special context class loader, so that they + * don't *accidentally* inherit it when making the unreferenced() + * callback. + */ + UnicastRemoteObject.exportObject(obj); + UnicastRemoteObject.unexportObject(obj, true); + + /* + * Now create special context class loader before exporting the + * remote object for real, so that it should be set when the + * object's unreferenced() method is called. + */ + ClassLoader intendedContext = new URLClassLoader(new URL[0]); + Thread.currentThread().setContextClassLoader(intendedContext); + System.err.println( + "created and set intended context class loader: " + + intendedContext); + + UnicastRemoteObject.exportObject(obj); + System.err.println("exported remote object"); + + LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + System.err.println("created registry"); + + Registry registry = LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); + registry.bind(BINDING, obj); + System.err.println("bound remote object in registry"); + + synchronized (obj.lock) { + registry.unbind(BINDING); + System.err.println("unbound remote object from registry; " + + "waiting for unreferenced() callback..."); + /* + * This incantation seems sufficient to work around the + * ramifications of 4164696, so that this test will actually + * prove something useful about 1.2Beta4 or 1.2FCS before + * 4171278 was fixed. + */ + for (int i = 0; i < 10; i++) { + System.gc(); + obj.lock.wait(TIMEOUT / 10); + if (obj.unreferencedInvoked) { + break; + } + } + + if (obj.unreferencedInvoked) { + System.err.println( + "invoked with context class loader: " + + obj.unreferencedContext); + + if (obj.unreferencedContext == intendedContext) { + System.err.println( + "TEST PASSED: unreferenced() invoked" + + " with intended context class loader"); + } else { + throw new RuntimeException( + "TEST FAILED: unreferenced() invoked" + + " with incorrect context class loader"); + } + } else { + throw new RuntimeException( + "TEST FAILED: unreferenced() not invoked after " + + ((double) TIMEOUT / 1000.0) + " seconds or unreferenced failed to create a thread"); + } + } + + } catch (Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException) e; + } else { + throw new RuntimeException( + "TEST FAILED: unexpected exception: " + e.toString()); + } + } finally { + /* + * When all is said and done, try to unexport the remote object + * so that the VM has a chance to exit. + */ + try { + UnicastRemoteObject.unexportObject(obj, true); + } catch (RemoteException e) { + } + } } } diff --git a/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext_Stub.java b/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext_Stub.java index 2ff7499e6059074de88e6d6c8f67fdda6805cb8e..0e35db25c1969d8e1d62885fb27484beceeceebe 100644 --- a/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext_Stub.java +++ b/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,10 +29,10 @@ public final class UnreferencedContext_Stub implements java.rmi.Remote { private static final long serialVersionUID = 2; - + // constructors public UnreferencedContext_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + } diff --git a/test/java/rmi/transport/acceptLoop/CloseServerSocketOnTermination.java b/test/java/rmi/transport/acceptLoop/CloseServerSocketOnTermination.java index b8a2cbfc897da70af6c510b4f4f0dfcba66fc452..02bb3d7f459d9987f9255337336506577b3bf0da 100644 --- a/test/java/rmi/transport/acceptLoop/CloseServerSocketOnTermination.java +++ b/test/java/rmi/transport/acceptLoop/CloseServerSocketOnTermination.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -51,75 +51,75 @@ public class CloseServerSocketOnTermination { private static long TIMEOUT = 5000; public static void main(String[] args) throws Exception { - System.err.println("\nRegression test for bug 4924577\n"); + System.err.println("\nRegression test for bug 4924577\n"); - RMISocketFactory.setFailureHandler(new RMIFailureHandler() { - public boolean failure(Exception e) { return false; } - }); + RMISocketFactory.setFailureHandler(new RMIFailureHandler() { + public boolean failure(Exception e) { return false; } + }); - tryWith(new IOException()); - tryWith(new NullPointerException()); - tryWith(new OutOfMemoryError()); - tryWith(new NoClassDefFoundError()); - tryWith(new InternalError()); - tryWith(new Throwable()); + tryWith(new IOException()); + tryWith(new NullPointerException()); + tryWith(new OutOfMemoryError()); + tryWith(new NoClassDefFoundError()); + tryWith(new InternalError()); + tryWith(new Throwable()); - System.err.println("TEST PASSED"); + System.err.println("TEST PASSED"); } private static void tryWith(Throwable t) throws Exception { - Remote impl = new Remote() { }; - try { - CountDownLatch latch = new CountDownLatch(1); - UnicastRemoteObject.exportObject(impl, 0, null, new SSF(t, latch)); - if (!latch.await(TIMEOUT, TimeUnit.MILLISECONDS)) { - throw new Error("server socket not closed"); - } - } finally { - UnicastRemoteObject.unexportObject(impl, true); - } + Remote impl = new Remote() { }; + try { + CountDownLatch latch = new CountDownLatch(1); + UnicastRemoteObject.exportObject(impl, 0, null, new SSF(t, latch)); + if (!latch.await(TIMEOUT, TimeUnit.MILLISECONDS)) { + throw new Error("server socket not closed"); + } + } finally { + UnicastRemoteObject.unexportObject(impl, true); + } } private static class SSF implements RMIServerSocketFactory { - private final Throwable acceptFailure; - private final CountDownLatch closedLatch; - SSF(Throwable acceptFailure, CountDownLatch closedLatch) { - this.acceptFailure = acceptFailure; - this.closedLatch = closedLatch; - } - public ServerSocket createServerSocket(int port) throws IOException { - return new ServerSocket(port) { - private int acceptInvocations = 0; - public synchronized Socket accept() throws IOException { - if (acceptInvocations++ == 0) { - throwException(acceptFailure); - } - return super.accept(); - } - public void close() throws IOException { - closedLatch.countDown(); - super.close(); - } - }; - } + private final Throwable acceptFailure; + private final CountDownLatch closedLatch; + SSF(Throwable acceptFailure, CountDownLatch closedLatch) { + this.acceptFailure = acceptFailure; + this.closedLatch = closedLatch; + } + public ServerSocket createServerSocket(int port) throws IOException { + return new ServerSocket(port) { + private int acceptInvocations = 0; + public synchronized Socket accept() throws IOException { + if (acceptInvocations++ == 0) { + throwException(acceptFailure); + } + return super.accept(); + } + public void close() throws IOException { + closedLatch.countDown(); + super.close(); + } + }; + } - // hack to throw an arbitrary (possibly checked) Throwable - private static void throwException(Throwable t) { - try { - toThrow.set(t); - Thrower.class.newInstance(); - } catch (IllegalAccessException e) { - throw new AssertionError(); - } catch (InstantiationException e) { - throw new AssertionError(); - } finally { - toThrow.remove(); - } - } - private static ThreadLocal toThrow = - new ThreadLocal(); - private static class Thrower { - Thrower() throws Throwable { throw toThrow.get(); } - } + // hack to throw an arbitrary (possibly checked) Throwable + private static void throwException(Throwable t) { + try { + toThrow.set(t); + Thrower.class.newInstance(); + } catch (IllegalAccessException e) { + throw new AssertionError(); + } catch (InstantiationException e) { + throw new AssertionError(); + } finally { + toThrow.remove(); + } + } + private static ThreadLocal toThrow = + new ThreadLocal(); + private static class Thrower { + Thrower() throws Throwable { throw toThrow.get(); } + } } } diff --git a/test/java/rmi/transport/checkFQDN/CheckFQDN.java b/test/java/rmi/transport/checkFQDN/CheckFQDN.java index 3cd17696cabfcc8b212154a4d713a4dfcad3e8e3..00dadb2f3385416de9dc891a549205ea5f71acf0 100644 --- a/test/java/rmi/transport/checkFQDN/CheckFQDN.java +++ b/test/java/rmi/transport/checkFQDN/CheckFQDN.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,15 +34,15 @@ * * @library ../../testlibrary * @build CheckFQDN CheckFQDNClient CheckFQDN_Stub TellServerName - * @run main/othervm/timeout=120 CheckFQDN + * @run main/othervm/timeout=120 CheckFQDN */ -/** +/** * Get the hostname used by rmi using different rmi properities: * * if set java.rmi.server.hostname, hostname should equal this * property. - * + * * if set java.rmi.server.useLocalHostname, hostname must contain a '.' * * if set no properties hostname should be an ipaddress. @@ -58,118 +58,118 @@ import java.rmi.server.*; import java.io.*; /** - * Export a remote object through which the exec'ed client vm can + * Export a remote object through which the exec'ed client vm can * inform the main test what its host name is. */ -public class CheckFQDN extends UnicastRemoteObject +public class CheckFQDN extends UnicastRemoteObject implements TellServerName { - + static String propertyBeingTested = null; static String propertyBeingTestedValue = null; public static void main(String args[]) { - Object dummy = new Object(); - CheckFQDN checkFQDN = null; - try { - checkFQDN = new CheckFQDN(); - - System.err.println - ("\nRegression test for bug/rfe 4115683\n"); - - Registry registry = java.rmi.registry.LocateRegistry. - createRegistry(TestLibrary.REGISTRY_PORT); - registry.bind("CheckFQDN", checkFQDN); - - /* test the host name scheme in different environments.*/ - testProperty("java.rmi.server.useLocalHostname", "true", ""); - testProperty("java.rmi.server.hostname", "thisIsJustAnRMITest", ""); - testProperty("java.rmi.server.hostname", "thisIsJustAnRMITest", - " -Djava.rmi.server.useLocalHostname=true "); - testProperty("", "", ""); - - } catch (Exception e) { - TestLibrary.bomb(e); - } finally { - if (checkFQDN != null) { - TestLibrary.unexport(checkFQDN); - } - } - System.err.println("\nTest for bug/ref 4115683 passed.\n"); + Object dummy = new Object(); + CheckFQDN checkFQDN = null; + try { + checkFQDN = new CheckFQDN(); + + System.err.println + ("\nRegression test for bug/rfe 4115683\n"); + + Registry registry = java.rmi.registry.LocateRegistry. + createRegistry(TestLibrary.REGISTRY_PORT); + registry.bind("CheckFQDN", checkFQDN); + + /* test the host name scheme in different environments.*/ + testProperty("java.rmi.server.useLocalHostname", "true", ""); + testProperty("java.rmi.server.hostname", "thisIsJustAnRMITest", ""); + testProperty("java.rmi.server.hostname", "thisIsJustAnRMITest", + " -Djava.rmi.server.useLocalHostname=true "); + testProperty("", "", ""); + + } catch (Exception e) { + TestLibrary.bomb(e); + } finally { + if (checkFQDN != null) { + TestLibrary.unexport(checkFQDN); + } + } + System.err.println("\nTest for bug/ref 4115683 passed.\n"); } - /** + /** * Spawn a vm and feed it a property which sets the client's rmi * hostname. */ - public static void testProperty(String property, - String propertyValue, - String extraProp) + public static void testProperty(String property, + String propertyValue, + String extraProp) { - try { - String propOption = ""; - String equal = ""; - if (!property.equals("")) { - propOption = " -D"; - equal = "="; - } - - JavaVM jvm = new JavaVM("CheckFQDNClient", - propOption + property + - equal + - propertyValue + extraProp, - ""); - - propertyBeingTested=property; - propertyBeingTestedValue=propertyValue; - - // create a client to tell checkFQDN what its rmi name is. */ - jvm.start(); - - if (jvm.getVM().waitFor() != 0 ) { - TestLibrary.bomb("Test failed, error in client."); - } - - } catch (Exception e) { - TestLibrary.bomb(e); - } + try { + String propOption = ""; + String equal = ""; + if (!property.equals("")) { + propOption = " -D"; + equal = "="; + } + + JavaVM jvm = new JavaVM("CheckFQDNClient", + propOption + property + + equal + + propertyValue + extraProp, + ""); + + propertyBeingTested=property; + propertyBeingTestedValue=propertyValue; + + // create a client to tell checkFQDN what its rmi name is. */ + jvm.start(); + + if (jvm.getVM().waitFor() != 0 ) { + TestLibrary.bomb("Test failed, error in client."); + } + + } catch (Exception e) { + TestLibrary.bomb(e); + } } CheckFQDN() throws RemoteException { } - /** - * Remote method to allow client vm to tell the main test what its + /** + * Remote method to allow client vm to tell the main test what its * host name is . */ - public void tellServerName(String serverName) - throws RemoteException { - - if (propertyBeingTested.equals("java.rmi.server.hostname")) { - if ( !propertyBeingTestedValue.equals(serverName)) { - TestLibrary.bomb(propertyBeingTested + - ":\n Client rmi server name does " + - "not equal the one specified " + - "by java.rmi.server.hostname: " + - serverName +" != " + - propertyBeingTestedValue); - } - - /** use local host name, must contain a '.' */ - } else if (propertyBeingTested.equals - ("java.rmi.server.useLocalHostname")) { - if (serverName.indexOf('.') < 0) { - TestLibrary.bomb(propertyBeingTested + - ":\nThe client servername contains no '.'"); - } - } else { - // no propety set, must be ip address - if ((serverName.indexOf('.') < 0) || - (!Character.isDigit(serverName.charAt(0)))) { - TestLibrary.bomb("Default name scheme:\n"+ - " The client servername contains no '.'"+ - "or is not an ip address"); - } - } - System.err.println("Servername used: " + serverName); + public void tellServerName(String serverName) + throws RemoteException { + + if (propertyBeingTested.equals("java.rmi.server.hostname")) { + if ( !propertyBeingTestedValue.equals(serverName)) { + TestLibrary.bomb(propertyBeingTested + + ":\n Client rmi server name does " + + "not equal the one specified " + + "by java.rmi.server.hostname: " + + serverName +" != " + + propertyBeingTestedValue); + } + + /** use local host name, must contain a '.' */ + } else if (propertyBeingTested.equals + ("java.rmi.server.useLocalHostname")) { + if (serverName.indexOf('.') < 0) { + TestLibrary.bomb(propertyBeingTested + + ":\nThe client servername contains no '.'"); + } + } else { + // no propety set, must be ip address + if ((serverName.indexOf('.') < 0) || + (!Character.isDigit(serverName.charAt(0)))) { + TestLibrary.bomb("Default name scheme:\n"+ + " The client servername contains no '.'"+ + "or is not an ip address"); + } + } + System.err.println("Servername used: " + serverName); } } diff --git a/test/java/rmi/transport/checkFQDN/CheckFQDNClient.java b/test/java/rmi/transport/checkFQDN/CheckFQDNClient.java index 203413b9d00f0b1e3658eb427a955a1d457df98f..ef644b197be13c201472210083075267cc7a8cac 100644 --- a/test/java/rmi/transport/checkFQDN/CheckFQDNClient.java +++ b/test/java/rmi/transport/checkFQDN/CheckFQDNClient.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -25,7 +25,7 @@ * * * Client that will run in its own vm and tell the main CheckFQDN test - * program what its rmi host name is, name obtained from TCPEndpoint. + * program what its rmi host name is, name obtained from TCPEndpoint. */ import java.rmi.*; @@ -40,72 +40,72 @@ import sun.rmi.transport.tcp.TCPEndpoint; public class CheckFQDNClient implements Runnable { final static int NAME_SERVICE_TIME_OUT = 12000; - + static TCPEndpoint ep = null; - /** + /** * main, lookup remote object and tell it the rmi * hostname of this client vm. */ public static void main (String args[]) { - - // start a registry and register a copy of this in it. - TellServerName tell; - String hostname = null; - - try { - hostname = retrieveServerName(); - System.err.println("Client host name: " + - hostname); - - tell = (TellServerName) Naming.lookup("rmi://:" + - TestLibrary.REGISTRY_PORT - + "/CheckFQDN"); - tell.tellServerName(hostname); - System.err.println("client has exited"); - - } catch (Exception e ) { - throw new RuntimeException(e.getMessage()); - } - System.exit(0); + + // start a registry and register a copy of this in it. + TellServerName tell; + String hostname = null; + + try { + hostname = retrieveServerName(); + System.err.println("Client host name: " + + hostname); + + tell = (TellServerName) Naming.lookup("rmi://:" + + TestLibrary.REGISTRY_PORT + + "/CheckFQDN"); + tell.tellServerName(hostname); + System.err.println("client has exited"); + + } catch (Exception e ) { + throw new RuntimeException(e.getMessage()); + } + System.exit(0); } - + /* what is the rmi hostname for this vm? */ public static String retrieveServerName () { - try { - - CheckFQDNClient chk = new CheckFQDNClient(); - - synchronized(chk) { - (new Thread (chk)).start(); - chk.wait(NAME_SERVICE_TIME_OUT); - } - - if (ep == null) { - throw new RuntimeException - ("Timeout getting the local endpoint."); - } - - // this is the name used by rmi for the client hostname - return ep.getHost(); - - }catch (Exception e){ - throw new RuntimeException (e.getMessage()); - } + try { + + CheckFQDNClient chk = new CheckFQDNClient(); + + synchronized(chk) { + (new Thread (chk)).start(); + chk.wait(NAME_SERVICE_TIME_OUT); + } + + if (ep == null) { + throw new RuntimeException + ("Timeout getting the local endpoint."); + } + + // this is the name used by rmi for the client hostname + return ep.getHost(); + + }catch (Exception e){ + throw new RuntimeException (e.getMessage()); + } } /* thread to geth the rmi hostname of this vm */ public void run () { - try { - synchronized(this) { - ep = TCPEndpoint.getLocalEndpoint(0); - } - } catch (Exception e) { - throw new RuntimeException(); - } finally { - synchronized(this) { - this.notify(); - } - } + try { + synchronized(this) { + ep = TCPEndpoint.getLocalEndpoint(0); + } + } catch (Exception e) { + throw new RuntimeException(); + } finally { + synchronized(this) { + this.notify(); + } + } } } diff --git a/test/java/rmi/transport/checkFQDN/CheckFQDN_Stub.java b/test/java/rmi/transport/checkFQDN/CheckFQDN_Stub.java index 93330b17c11ec59b41a689de952b9275688696aa..3c318cae9461a4f1e7c7f4d201b245f9ce74de6b 100644 --- a/test/java/rmi/transport/checkFQDN/CheckFQDN_Stub.java +++ b/test/java/rmi/transport/checkFQDN/CheckFQDN_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,66 +29,66 @@ public final class CheckFQDN_Stub implements TellServerName, java.rmi.Remote { private static java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("void tellServerName(java.lang.String)") + new java.rmi.server.Operation("void tellServerName(java.lang.String)") }; - + private static final long interfaceHash = 4509625981775855367L; - + private static final long serialVersionUID = 2; - + private static boolean useNewInvoke; private static java.lang.reflect.Method $method_tellServerName_0; - + static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_tellServerName_0 = TellServerName.class.getMethod("tellServerName", new java.lang.Class[] {java.lang.String.class}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } + try { + java.rmi.server.RemoteRef.class.getMethod("invoke", + new java.lang.Class[] { + java.rmi.Remote.class, + java.lang.reflect.Method.class, + java.lang.Object[].class, + long.class + }); + useNewInvoke = true; + $method_tellServerName_0 = TellServerName.class.getMethod("tellServerName", new java.lang.Class[] {java.lang.String.class}); + } catch (java.lang.NoSuchMethodException e) { + useNewInvoke = false; + } } - + // constructors public CheckFQDN_Stub() { - super(); + super(); } public CheckFQDN_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of tellServerName(String) public void tellServerName(java.lang.String $param_String_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - ref.invoke(this, $method_tellServerName_0, new java.lang.Object[] {$param_String_1}, -5180633734615762942L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - try { - java.io.ObjectOutput out = call.getOutputStream(); - out.writeObject($param_String_1); - } catch (java.io.IOException e) { - throw new java.rmi.MarshalException("error marshalling arguments", e); - } - ref.invoke(call); - ref.done(call); - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + ref.invoke(this, $method_tellServerName_0, new java.lang.Object[] {$param_String_1}, -5180633734615762942L); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + try { + java.io.ObjectOutput out = call.getOutputStream(); + out.writeObject($param_String_1); + } catch (java.io.IOException e) { + throw new java.rmi.MarshalException("error marshalling arguments", e); + } + ref.invoke(call); + ref.done(call); + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/transport/checkFQDN/TellServerName.java b/test/java/rmi/transport/checkFQDN/TellServerName.java index 0dbf0c6c300a79bff118746092249ee3380e985c..d5625c5cbdbfc83da805f41c06e7b6e9da9385d5 100644 --- a/test/java/rmi/transport/checkFQDN/TellServerName.java +++ b/test/java/rmi/transport/checkFQDN/TellServerName.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -24,7 +24,7 @@ import java.rmi.*; import java.rmi.server.*; -/** +/** * interface to get server name from an execed vm * I am using an execed vm because I need to set * rmi's hostname serveral times with different properties. @@ -32,4 +32,3 @@ import java.rmi.server.*; interface TellServerName extends Remote { void tellServerName (String serverName) throws RemoteException; } - diff --git a/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java b/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java index b5823dd5bde90fd9032343781fbdc197d1ff9849..94847ffc01e227e9f82789daa1f34742aa46b89e 100644 --- a/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java +++ b/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -44,7 +44,7 @@ * the remote object. Each vmid needs a seperate LeaseInfo object in * the object table target DGCImpl.leaseTable. If the leak is fixed, * the leaseTable field will contain no objects. We use reflection to - * find the number of objects contained in this table. + * find the number of objects contained in this table. */ import java.rmi.*; @@ -57,13 +57,13 @@ import java.lang.reflect.*; import java.rmi.registry.*; public class CheckLeaseLeak extends UnicastRemoteObject implements LeaseLeak { - + public CheckLeaseLeak() throws RemoteException { } public void ping () throws RemoteException { } /** * Id to fake the DGC_ID, so we can later get a reference to the - * DGCImpl in the object table. + * DGCImpl in the object table. */ private final static int DGC_ID = 2; @@ -71,148 +71,148 @@ public class CheckLeaseLeak extends UnicastRemoteObject implements LeaseLeak { private final static int numberPingCalls = 0; private final static int CHECK_INTERVAL = 400; private final static int LEASE_VALUE = 20; - + public static void main (String[] args) { - CheckLeaseLeak leakServer = null; - int numLeft =0; - - /* - * we want DGC to collect leases *quickly* - * decrease the lease check interval - */ - TestLibrary.setInteger("sun.rmi.dgc.checkInterval", - CHECK_INTERVAL); - TestLibrary.setInteger("java.rmi.dgc.leaseValue", - LEASE_VALUE); - - try { - Registry registry = - java.rmi.registry.LocateRegistry. - createRegistry(TestLibrary.REGISTRY_PORT); - - leakServer = new CheckLeaseLeak(); - registry.rebind("/LeaseLeak", leakServer); - - /* create a bunch of clients in a *different* vm */ - for (int i = 0 ; i < ITERATIONS ; i ++ ) { - System.err.println("Created client: " + i); - - JavaVM jvm = new JavaVM("LeaseLeakClient", - " -Djava.security.policy=" + - TestParams.defaultPolicy, ""); - jvm.start(); - - if (jvm.getVM().waitFor() == 1 ) { - TestLibrary.bomb("Client process failed"); - } - } - numLeft = getDGCLeaseTableSize(); - Thread.sleep(3000); - - } catch(Exception e) { - TestLibrary.bomb("CheckLeaseLeak Error: ", e); - } finally { - if (leakServer != null) { - TestLibrary.unexport(leakServer); - leakServer = null; - } - } - - /* numLeft should be 2 - if 11 there is a problem. */ - if (numLeft > 2) { - TestLibrary.bomb("Too many objects in DGCImpl.leaseTable: "+ - numLeft); - } else { - System.err.println("Check leaseInfo leak passed with " + - numLeft - + " object(s) in the leaseTable"); - } + CheckLeaseLeak leakServer = null; + int numLeft =0; + + /* + * we want DGC to collect leases *quickly* + * decrease the lease check interval + */ + TestLibrary.setInteger("sun.rmi.dgc.checkInterval", + CHECK_INTERVAL); + TestLibrary.setInteger("java.rmi.dgc.leaseValue", + LEASE_VALUE); + + try { + Registry registry = + java.rmi.registry.LocateRegistry. + createRegistry(TestLibrary.REGISTRY_PORT); + + leakServer = new CheckLeaseLeak(); + registry.rebind("/LeaseLeak", leakServer); + + /* create a bunch of clients in a *different* vm */ + for (int i = 0 ; i < ITERATIONS ; i ++ ) { + System.err.println("Created client: " + i); + + JavaVM jvm = new JavaVM("LeaseLeakClient", + " -Djava.security.policy=" + + TestParams.defaultPolicy, ""); + jvm.start(); + + if (jvm.getVM().waitFor() == 1 ) { + TestLibrary.bomb("Client process failed"); + } + } + numLeft = getDGCLeaseTableSize(); + Thread.sleep(3000); + + } catch(Exception e) { + TestLibrary.bomb("CheckLeaseLeak Error: ", e); + } finally { + if (leakServer != null) { + TestLibrary.unexport(leakServer); + leakServer = null; + } + } + + /* numLeft should be 2 - if 11 there is a problem. */ + if (numLeft > 2) { + TestLibrary.bomb("Too many objects in DGCImpl.leaseTable: "+ + numLeft); + } else { + System.err.println("Check leaseInfo leak passed with " + + numLeft + + " object(s) in the leaseTable"); + } } /** * Obtain a reference to the main DGCImpl via reflection. Extract * the DGCImpl using the ObjectTable and the well known ID of the - * DGCImpl. + * DGCImpl. */ private static int getDGCLeaseTableSize () { - int numLeaseInfosLeft = 0; - - /** - * Will eventually be set to point at the leaseTable inside - * DGCImpl. - */ - Map leaseTable = null; - final Remote[] dgcImpl = new Remote[1]; - Field f; - - try { - f = (Field) java.security.AccessController.doPrivileged - (new java.security.PrivilegedExceptionAction() { - public Object run() throws Exception { - - ObjID dgcID = new ObjID(DGC_ID); - - /* - * Construct an ObjectEndpoint containing DGC's - * ObjID. - */ - Class oeClass = - Class.forName("sun.rmi.transport.ObjectEndpoint"); - Class[] constrParams = - new Class[]{ ObjID.class, Transport.class }; - Constructor oeConstructor = - oeClass.getDeclaredConstructor(constrParams); - oeConstructor.setAccessible(true); - Object oe = - oeConstructor.newInstance( - new Object[]{ dgcID, null }); - - /* - * Get Target that contains DGCImpl in ObjectTable - */ - Class objTableClass = - Class.forName("sun.rmi.transport.ObjectTable"); - Class getTargetParams[] = new Class[] { oeClass }; - Method objTableGetTarget = - objTableClass.getDeclaredMethod("getTarget", - getTargetParams); - objTableGetTarget.setAccessible(true); - Target dgcTarget = (Target) - objTableGetTarget.invoke(null, new Object[]{ oe }); - - /* get the DGCImpl from its Target */ - Method targetGetImpl = - dgcTarget.getClass().getDeclaredMethod - ("getImpl", null); - targetGetImpl.setAccessible(true); - dgcImpl[0] = - (Remote) targetGetImpl.invoke(dgcTarget, null); - - /* Get the lease table from the DGCImpl. */ - Field reflectedLeaseTable = - dgcImpl[0].getClass().getDeclaredField - ("leaseTable"); - reflectedLeaseTable.setAccessible(true); - - return reflectedLeaseTable; - } - }); - - /** - * This is the leaseTable that will fill up with LeaseInfo - * objects if the LeaseInfo memory leak is not fixed. - */ - leaseTable = (Map) f.get(dgcImpl[0]); - - numLeaseInfosLeft = leaseTable.size(); - - } catch(Exception e) { - if (e instanceof java.security.PrivilegedActionException) - e = ((java.security.PrivilegedActionException) e). - getException(); - TestLibrary.bomb(e); - } - - return numLeaseInfosLeft; + int numLeaseInfosLeft = 0; + + /** + * Will eventually be set to point at the leaseTable inside + * DGCImpl. + */ + Map leaseTable = null; + final Remote[] dgcImpl = new Remote[1]; + Field f; + + try { + f = (Field) java.security.AccessController.doPrivileged + (new java.security.PrivilegedExceptionAction() { + public Object run() throws Exception { + + ObjID dgcID = new ObjID(DGC_ID); + + /* + * Construct an ObjectEndpoint containing DGC's + * ObjID. + */ + Class oeClass = + Class.forName("sun.rmi.transport.ObjectEndpoint"); + Class[] constrParams = + new Class[]{ ObjID.class, Transport.class }; + Constructor oeConstructor = + oeClass.getDeclaredConstructor(constrParams); + oeConstructor.setAccessible(true); + Object oe = + oeConstructor.newInstance( + new Object[]{ dgcID, null }); + + /* + * Get Target that contains DGCImpl in ObjectTable + */ + Class objTableClass = + Class.forName("sun.rmi.transport.ObjectTable"); + Class getTargetParams[] = new Class[] { oeClass }; + Method objTableGetTarget = + objTableClass.getDeclaredMethod("getTarget", + getTargetParams); + objTableGetTarget.setAccessible(true); + Target dgcTarget = (Target) + objTableGetTarget.invoke(null, new Object[]{ oe }); + + /* get the DGCImpl from its Target */ + Method targetGetImpl = + dgcTarget.getClass().getDeclaredMethod + ("getImpl", null); + targetGetImpl.setAccessible(true); + dgcImpl[0] = + (Remote) targetGetImpl.invoke(dgcTarget, null); + + /* Get the lease table from the DGCImpl. */ + Field reflectedLeaseTable = + dgcImpl[0].getClass().getDeclaredField + ("leaseTable"); + reflectedLeaseTable.setAccessible(true); + + return reflectedLeaseTable; + } + }); + + /** + * This is the leaseTable that will fill up with LeaseInfo + * objects if the LeaseInfo memory leak is not fixed. + */ + leaseTable = (Map) f.get(dgcImpl[0]); + + numLeaseInfosLeft = leaseTable.size(); + + } catch(Exception e) { + if (e instanceof java.security.PrivilegedActionException) + e = ((java.security.PrivilegedActionException) e). + getException(); + TestLibrary.bomb(e); + } + + return numLeaseInfosLeft; } } diff --git a/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak_Stub.java b/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak_Stub.java index 42f6fa901d63a95ac5d0fe6bff45b20ddc0f4f38..52b5d89a53a6ab441baa14367e8235eb110aea7b 100644 --- a/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak_Stub.java +++ b/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,60 +29,60 @@ public final class CheckLeaseLeak_Stub implements LeaseLeak, java.rmi.Remote { private static java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("void ping()") + new java.rmi.server.Operation("void ping()") }; - + private static final long interfaceHash = -8409781791984809394L; - + private static final long serialVersionUID = 2; - + private static boolean useNewInvoke; private static java.lang.reflect.Method $method_ping_0; - + static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_ping_0 = LeaseLeak.class.getMethod("ping", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } + try { + java.rmi.server.RemoteRef.class.getMethod("invoke", + new java.lang.Class[] { + java.rmi.Remote.class, + java.lang.reflect.Method.class, + java.lang.Object[].class, + long.class + }); + useNewInvoke = true; + $method_ping_0 = LeaseLeak.class.getMethod("ping", new java.lang.Class[] {}); + } catch (java.lang.NoSuchMethodException e) { + useNewInvoke = false; + } } - + // constructors public CheckLeaseLeak_Stub() { - super(); + super(); } public CheckLeaseLeak_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of ping() public void ping() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - ref.invoke(this, $method_ping_0, null, 5866401369815527589L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - ref.invoke(call); - ref.done(call); - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + ref.invoke(this, $method_ping_0, null, 5866401369815527589L); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + ref.invoke(call); + ref.done(call); + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeak.java b/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeak.java index d83e2ebc29689820328f24687a4ed9ced1af2169..de412cda32e632a06abff31dbcd634539163cd48 100644 --- a/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeak.java +++ b/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeak.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java b/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java index a9f452e71478be75540c6a1262b46c47a7208bcc..b42f23d2e6652e268b3355065ca355b84942d30a 100644 --- a/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java +++ b/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -25,24 +25,24 @@ import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; -public class LeaseLeakClient { +public class LeaseLeakClient { public static void main(String args[]) { - TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); - - try { - LeaseLeak leaseLeak = null; - - // put a reference on a remote object. - Registry registry = - java.rmi.registry.LocateRegistry.getRegistry( - TestLibrary.REGISTRY_PORT); - leaseLeak = (LeaseLeak) registry.lookup("/LeaseLeak"); - leaseLeak.ping(); - - } catch(Exception e) { - System.err.println("LeaseLeakClient Error: "+e.getMessage()); - e.printStackTrace(); - throw new RuntimeException(e.getMessage()); - } + TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); + + try { + LeaseLeak leaseLeak = null; + + // put a reference on a remote object. + Registry registry = + java.rmi.registry.LocateRegistry.getRegistry( + TestLibrary.REGISTRY_PORT); + leaseLeak = (LeaseLeak) registry.lookup("/LeaseLeak"); + leaseLeak.ping(); + + } catch(Exception e) { + System.err.println("LeaseLeakClient Error: "+e.getMessage()); + e.printStackTrace(); + throw new RuntimeException(e.getMessage()); + } } } diff --git a/test/java/rmi/transport/closeServerSocket/CloseServerSocket.java b/test/java/rmi/transport/closeServerSocket/CloseServerSocket.java index fe0b9accbe0c3b5a9c500abe0e3677deaa165a21..54ca8fd2a717fb6e6d6900a87c0f419f1f9028c2 100644 --- a/test/java/rmi/transport/closeServerSocket/CloseServerSocket.java +++ b/test/java/rmi/transport/closeServerSocket/CloseServerSocket.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -50,80 +50,80 @@ public class CloseServerSocket implements Remote { private CloseServerSocket() { } public static void main(String[] args) throws Exception { - System.err.println("\nRegression test for bug 4457683\n"); - - verifyPortFree(PORT); - Registry registry = LocateRegistry.createRegistry(PORT); - System.err.println("- exported registry: " + registry); - verifyPortInUse(PORT); - UnicastRemoteObject.unexportObject(registry, true); - System.err.println("- unexported registry"); - Thread.sleep(1); // work around BindException (bug?) - verifyPortFree(PORT); - - /* - * The follow portion of this test is disabled temporarily - * because 4457683 was partially backed out because of - * 6269166; for now, only server sockets originally opened for - * exports on non-anonymous ports will be closed when all of - * the corresponding remote objects have been exported. A - * separate bug will be filed to represent the remainder of - * 4457683 for anonymous-port exports. - */ - -// SSF ssf = new SSF(); -// Remote impl = new CloseServerSocket(); -// Remote stub = UnicastRemoteObject.exportObject(impl, 0, null, ssf); -// System.err.println("- exported object: " + stub); -// UnicastRemoteObject.unexportObject(impl, true); -// System.err.println("- unexported object"); -// synchronized (ssf) { -// if (!ssf.serverSocketClosed) { -// throw new RuntimeException("TEST FAILED: " + -// "server socket not closed"); -// } -// } - - System.err.println("TEST PASSED"); + System.err.println("\nRegression test for bug 4457683\n"); + + verifyPortFree(PORT); + Registry registry = LocateRegistry.createRegistry(PORT); + System.err.println("- exported registry: " + registry); + verifyPortInUse(PORT); + UnicastRemoteObject.unexportObject(registry, true); + System.err.println("- unexported registry"); + Thread.sleep(1); // work around BindException (bug?) + verifyPortFree(PORT); + + /* + * The follow portion of this test is disabled temporarily + * because 4457683 was partially backed out because of + * 6269166; for now, only server sockets originally opened for + * exports on non-anonymous ports will be closed when all of + * the corresponding remote objects have been exported. A + * separate bug will be filed to represent the remainder of + * 4457683 for anonymous-port exports. + */ + +// SSF ssf = new SSF(); +// Remote impl = new CloseServerSocket(); +// Remote stub = UnicastRemoteObject.exportObject(impl, 0, null, ssf); +// System.err.println("- exported object: " + stub); +// UnicastRemoteObject.unexportObject(impl, true); +// System.err.println("- unexported object"); +// synchronized (ssf) { +// if (!ssf.serverSocketClosed) { +// throw new RuntimeException("TEST FAILED: " + +// "server socket not closed"); +// } +// } + + System.err.println("TEST PASSED"); } private static void verifyPortFree(int port) throws IOException { - ServerSocket ss = new ServerSocket(PORT); - ss.close(); - System.err.println("- port " + port + " is free"); + ServerSocket ss = new ServerSocket(PORT); + ss.close(); + System.err.println("- port " + port + " is free"); } private static void verifyPortInUse(int port) throws IOException { - try { - verifyPortFree(port); - } catch (BindException e) { - System.err.println("- port " + port + " is in use"); - return; - } + try { + verifyPortFree(port); + } catch (BindException e) { + System.err.println("- port " + port + " is in use"); + return; + } } private static class SSF implements RMIServerSocketFactory { - boolean serverSocketClosed = false; - SSF() { }; - - public ServerSocket createServerSocket(int port) throws IOException { - return new SS(port); - } - - private class SS extends ServerSocket { - SS(int port) throws IOException { - super(port); - System.err.println("- created server socket: " + this); - }; - - public void close() throws IOException { - synchronized (SSF.this) { - serverSocketClosed = true; - SSF.this.notifyAll(); - } - System.err.println("- closing server socket: " + this); - super.close(); - } - } + boolean serverSocketClosed = false; + SSF() { }; + + public ServerSocket createServerSocket(int port) throws IOException { + return new SS(port); + } + + private class SS extends ServerSocket { + SS(int port) throws IOException { + super(port); + System.err.println("- created server socket: " + this); + }; + + public void close() throws IOException { + synchronized (SSF.this) { + serverSocketClosed = true; + SSF.this.notifyAll(); + } + System.err.println("- closing server socket: " + this); + super.close(); + } + } } } diff --git a/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java b/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java index fd01055ca3747040cdd814cd6c939bf8d7a469b8..820d4c410dd733e938413ffdc9b6bb6f28d5a9ed 100644 --- a/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java +++ b/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -46,7 +46,7 @@ * was attempting to lock. * * This test causes the above conditions to occur and waits to see if - * a given set of remote calls finishes "quickly enough." + * a given set of remote calls finishes "quickly enough." */ import java.rmi.*; @@ -60,98 +60,98 @@ public class DGCDeadLock implements Runnable { static DGCDeadLock test = new DGCDeadLock(); static { - System.setProperty("sun.rmi.transport.cleanInterval", "50"); + System.setProperty("sun.rmi.transport.cleanInterval", "50"); } static public void main(String[] args) { - JavaVM testImplVM = null; - - System.err.println("\nregression test for 4118056\n"); - TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); + JavaVM testImplVM = null; + + System.err.println("\nregression test for 4118056\n"); + TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); try { - String options = " -Djava.security.policy=" + - TestParams.defaultPolicy + - " -Djava.rmi.dgc.leaseValue=500000" + - " -Dsun.rmi.dgc.checkInterval=" + - (HOLD_TARGET_TIME - 5000) + ""; - - testImplVM = new JavaVM("TestImpl", options, ""); - testImplVM.start(); - - synchronized (test) { - Thread t = new Thread(test); - t.setDaemon(true); - t.start(); - - // wait for the remote calls to take place - test.wait(TEST_FAIL_TIME); - } - - if (!finished) { - TestLibrary.bomb("Test failed, had exception or exercise" + - " routines took too long to " + - "execute"); - } - System.err.println("Test passed, exercises " + - "finished in time."); + String options = " -Djava.security.policy=" + + TestParams.defaultPolicy + + " -Djava.rmi.dgc.leaseValue=500000" + + " -Dsun.rmi.dgc.checkInterval=" + + (HOLD_TARGET_TIME - 5000) + ""; + + testImplVM = new JavaVM("TestImpl", options, ""); + testImplVM.start(); + + synchronized (test) { + Thread t = new Thread(test); + t.setDaemon(true); + t.start(); + + // wait for the remote calls to take place + test.wait(TEST_FAIL_TIME); + } + + if (!finished) { + TestLibrary.bomb("Test failed, had exception or exercise" + + " routines took too long to " + + "execute"); + } + System.err.println("Test passed, exercises " + + "finished in time."); } catch (Exception e) { - testImplVM = null; - TestLibrary.bomb("test failed", e); + testImplVM = null; + TestLibrary.bomb("test failed", e); } } public void run() { - try { - String echo = null; - - // give the test remote object time to initialize. - Thread.currentThread().sleep(8000); - - // create a test client - Test foo = (Test) Naming.lookup("rmi://:" + - TestLibrary.REGISTRY_PORT + - "/Foo"); - echo = foo.echo("Hello world"); - System.err.println("Test object created."); - - /* give TestImpl time to lock the target in the - * object table and any dirtys finish. - */ - Thread.currentThread().sleep(5000); - - //unreference "Foo" - foo = null; - - //garbage collect and finalize foo - Runtime.getRuntime().gc(); - Runtime.getRuntime().runFinalization(); - - //import "Bar" - Test bar = (Test) Naming.lookup("rmi://:" + - TestLibrary.REGISTRY_PORT + - "/Bar"); - - /* infinite loop to show the liveness of Client, - * if we have deadlock remote call will not return - */ - try { - for (int i = 0; i < 500; i++) { - echo = bar.echo("Remote call" + i); - Thread.sleep(10); - } - - // flag exercises finished - finished = true; - - } catch (RemoteException e) { - } - - } catch (Exception e) { - TestLibrary.bomb("test failed", e); - } finally { - } + try { + String echo = null; + + // give the test remote object time to initialize. + Thread.currentThread().sleep(8000); + + // create a test client + Test foo = (Test) Naming.lookup("rmi://:" + + TestLibrary.REGISTRY_PORT + + "/Foo"); + echo = foo.echo("Hello world"); + System.err.println("Test object created."); + + /* give TestImpl time to lock the target in the + * object table and any dirtys finish. + */ + Thread.currentThread().sleep(5000); + + //unreference "Foo" + foo = null; + + //garbage collect and finalize foo + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + + //import "Bar" + Test bar = (Test) Naming.lookup("rmi://:" + + TestLibrary.REGISTRY_PORT + + "/Bar"); + + /* infinite loop to show the liveness of Client, + * if we have deadlock remote call will not return + */ + try { + for (int i = 0; i < 500; i++) { + echo = bar.echo("Remote call" + i); + Thread.sleep(10); + } + + // flag exercises finished + finished = true; + + } catch (RemoteException e) { + } + + } catch (Exception e) { + TestLibrary.bomb("test failed", e); + } finally { + } } } diff --git a/test/java/rmi/transport/dgcDeadLock/Test.java b/test/java/rmi/transport/dgcDeadLock/Test.java index 4706b3870e82aa17b59c4b48788ccbc28f602e18..5fcd90c38845202520427653a433f84b9cd12310 100644 --- a/test/java/rmi/transport/dgcDeadLock/Test.java +++ b/test/java/rmi/transport/dgcDeadLock/Test.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/java/rmi/transport/dgcDeadLock/TestImpl.java b/test/java/rmi/transport/dgcDeadLock/TestImpl.java index d96fcc21126f20937f1586af1daa95681c683eb6..0f23ae73a0ce2d2f8b46bae3be3233f5e73474d3 100644 --- a/test/java/rmi/transport/dgcDeadLock/TestImpl.java +++ b/test/java/rmi/transport/dgcDeadLock/TestImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,7 +34,7 @@ import java.util.*; import java.rmi.registry.*; import java.rmi.server.*; -public class TestImpl extends UnicastRemoteObject +public class TestImpl extends UnicastRemoteObject implements Test { static Thread locker = null; @@ -46,197 +46,197 @@ public class TestImpl extends UnicastRemoteObject public String echo(String msg) throws RemoteException { - if (locker == null) { - // hold the target if not already held - locker = lockTargetExpireLeases(foo, DGCDeadLock.HOLD_TARGET_TIME); - } + if (locker == null) { + // hold the target if not already held + locker = lockTargetExpireLeases(foo, DGCDeadLock.HOLD_TARGET_TIME); + } return "Message received: " + msg; } static public void main(String[] args) { - Registry registry = null; + Registry registry = null; try { - registry = java.rmi.registry.LocateRegistry. - createRegistry(TestLibrary.REGISTRY_PORT); - - //export "Foo" - foo = new TestImpl(); - Naming.rebind("rmi://:" + - TestLibrary.REGISTRY_PORT - + "/Foo", foo); - - try { - //export "Bar" after leases have been expired. - bar = new TestImpl(); - Naming.rebind("rmi://localhost:" + - TestLibrary.REGISTRY_PORT - + "/Bar", bar); - } catch (Exception e) { - throw new RemoteException(e.getMessage()); - } - Thread.sleep(DGCDeadLock.TEST_FAIL_TIME); - System.err.println("object vm exiting..."); - System.exit(0); + registry = java.rmi.registry.LocateRegistry. + createRegistry(TestLibrary.REGISTRY_PORT); + + //export "Foo" + foo = new TestImpl(); + Naming.rebind("rmi://:" + + TestLibrary.REGISTRY_PORT + + "/Foo", foo); + + try { + //export "Bar" after leases have been expired. + bar = new TestImpl(); + Naming.rebind("rmi://localhost:" + + TestLibrary.REGISTRY_PORT + + "/Bar", bar); + } catch (Exception e) { + throw new RemoteException(e.getMessage()); + } + Thread.sleep(DGCDeadLock.TEST_FAIL_TIME); + System.err.println("object vm exiting..."); + System.exit(0); } catch (Exception e) { - System.err.println(e.getMessage()); - e.printStackTrace(); + System.err.println(e.getMessage()); + e.printStackTrace(); } finally { - TestLibrary.unexport(registry); - registry = null; - } + TestLibrary.unexport(registry); + registry = null; + } } static Thread lockTargetExpireLeases(Remote toLock, int timeOut) { - Thread t = new Thread((Runnable) new TargetLocker(toLock, timeOut)); - t.start(); - return t; + Thread t = new Thread((Runnable) new TargetLocker(toLock, timeOut)); + t.start(); + return t; } static class TargetLocker implements Runnable { - Remote toLock = null; - int timeOut = 0; - - TargetLocker(Remote toLock, int timeOut) { - this.toLock = toLock; - this.timeOut = timeOut; - } - - public void run() { - try { - // give dgc dirty calls time to finish. - Thread.currentThread().sleep(4000); - - java.security.AccessController. - doPrivileged(new LockTargetCheckLeases(toLock, - timeOut)); - - } catch (Exception e) { - System.err.println(e.getMessage()); - e.printStackTrace(); - System.exit(1); - } - } + Remote toLock = null; + int timeOut = 0; + + TargetLocker(Remote toLock, int timeOut) { + this.toLock = toLock; + this.timeOut = timeOut; + } + + public void run() { + try { + // give dgc dirty calls time to finish. + Thread.currentThread().sleep(4000); + + java.security.AccessController. + doPrivileged(new LockTargetCheckLeases(toLock, + timeOut)); + + } catch (Exception e) { + System.err.println(e.getMessage()); + e.printStackTrace(); + System.exit(1); + } + } } - static class LockTargetCheckLeases - implements java.security.PrivilegedAction { - - Remote toLock = null; - int timeOut = 0; - - LockTargetCheckLeases(Remote toLock, int timeOut) { - this.toLock = toLock; - this.timeOut = timeOut; - } - - public Object run() { - try { - - Class args[] = new Class[1]; - - Class objTableClass = Class.forName - ("sun.rmi.transport.ObjectTable"); - - /* get the Target that corresponds to toLock from the - * ObjectTable - */ - args[0] = Class.forName("java.rmi.Remote"); - Method objTableGetTarget = - objTableClass.getDeclaredMethod("getTarget", args ); - objTableGetTarget.setAccessible(true); - - Target lockTarget = - ((Target) objTableGetTarget.invoke - (null , new Object [] {toLock} )); - - // make sure the lease on this object has expired. - expireLeases(lockTarget); - - // stop other threads from using the target for toLock. - synchronized (lockTarget) { - System.err.println("Locked the relevant target, sleeping " + - timeOut/1000 + " seconds"); - Thread.currentThread().sleep(timeOut); - System.err.println("Target unlocked"); - } - - } catch (Exception e) { - System.err.println(e.getMessage()); - e.printStackTrace(); - System.exit(1); - } - return null; - } + static class LockTargetCheckLeases + implements java.security.PrivilegedAction { + + Remote toLock = null; + int timeOut = 0; + + LockTargetCheckLeases(Remote toLock, int timeOut) { + this.toLock = toLock; + this.timeOut = timeOut; + } + + public Object run() { + try { + + Class args[] = new Class[1]; + + Class objTableClass = Class.forName + ("sun.rmi.transport.ObjectTable"); + + /* get the Target that corresponds to toLock from the + * ObjectTable + */ + args[0] = Class.forName("java.rmi.Remote"); + Method objTableGetTarget = + objTableClass.getDeclaredMethod("getTarget", args ); + objTableGetTarget.setAccessible(true); + + Target lockTarget = + ((Target) objTableGetTarget.invoke + (null , new Object [] {toLock} )); + + // make sure the lease on this object has expired. + expireLeases(lockTarget); + + // stop other threads from using the target for toLock. + synchronized (lockTarget) { + System.err.println("Locked the relevant target, sleeping " + + timeOut/1000 + " seconds"); + Thread.currentThread().sleep(timeOut); + System.err.println("Target unlocked"); + } + + } catch (Exception e) { + System.err.println(e.getMessage()); + e.printStackTrace(); + System.exit(1); + } + return null; + } } /* leases have long values, so no dirty calls which would lock out * a clean call, but the leases need to expire anyway, so we do it - * explicitly. + * explicitly. */ static void expireLeases(Target t) throws Exception { - final Target target = t; - - java.security.AccessController.doPrivileged( - - // put this into another class? - new java.security.PrivilegedAction() { - public Object run() { - try { - - Class DGCClass = Class.forName("sun.rmi.transport.DGCImpl"); - Method getDGCImpl = - DGCClass.getDeclaredMethod("getDGCImpl", null ); - getDGCImpl.setAccessible(true); - - // make sure the lease on this object has expired. - DGC dgcImpl = ((DGC) getDGCImpl.invoke(null, null)); - - /* Get the lease table from the DGCImpl. */ - Field reflectedLeaseTable = - dgcImpl.getClass().getDeclaredField("leaseTable"); - reflectedLeaseTable.setAccessible(true); - - Map leaseTable = (Map) reflectedLeaseTable.get(dgcImpl); - - // dont really need this synchronization... - synchronized (leaseTable) { - Iterator en = leaseTable.values().iterator(); - while (en.hasNext()) { - Object info = en.next(); - - /* Get the notifySet in the leaseInfo object. */ - Field notifySetField = - info.getClass().getDeclaredField("notifySet"); - notifySetField.setAccessible(true); - HashSet notifySet = (HashSet) notifySetField.get(info); - - Iterator iter = notifySet.iterator(); - while (iter.hasNext()) { - Target notified = (Target) iter.next(); - - if (notified == target) { - - /* Get and set the expiration field from the info object. */ - Field expirationField = info.getClass(). - getDeclaredField("expiration"); - expirationField.setAccessible(true); - expirationField.setLong(info, 0); - } - } - } - } - } catch (Exception e) { - System.err.println(e.getMessage()); - e.printStackTrace(); - System.exit(1); - } - // no interesting return value for this privileged action - return null; - } - }); + final Target target = t; + + java.security.AccessController.doPrivileged( + + // put this into another class? + new java.security.PrivilegedAction() { + public Object run() { + try { + + Class DGCClass = Class.forName("sun.rmi.transport.DGCImpl"); + Method getDGCImpl = + DGCClass.getDeclaredMethod("getDGCImpl", null ); + getDGCImpl.setAccessible(true); + + // make sure the lease on this object has expired. + DGC dgcImpl = ((DGC) getDGCImpl.invoke(null, null)); + + /* Get the lease table from the DGCImpl. */ + Field reflectedLeaseTable = + dgcImpl.getClass().getDeclaredField("leaseTable"); + reflectedLeaseTable.setAccessible(true); + + Map leaseTable = (Map) reflectedLeaseTable.get(dgcImpl); + + // dont really need this synchronization... + synchronized (leaseTable) { + Iterator en = leaseTable.values().iterator(); + while (en.hasNext()) { + Object info = en.next(); + + /* Get the notifySet in the leaseInfo object. */ + Field notifySetField = + info.getClass().getDeclaredField("notifySet"); + notifySetField.setAccessible(true); + HashSet notifySet = (HashSet) notifySetField.get(info); + + Iterator iter = notifySet.iterator(); + while (iter.hasNext()) { + Target notified = (Target) iter.next(); + + if (notified == target) { + + /* Get and set the expiration field from the info object. */ + Field expirationField = info.getClass(). + getDeclaredField("expiration"); + expirationField.setAccessible(true); + expirationField.setLong(info, 0); + } + } + } + } + } catch (Exception e) { + System.err.println(e.getMessage()); + e.printStackTrace(); + System.exit(1); + } + // no interesting return value for this privileged action + return null; + } + }); } } diff --git a/test/java/rmi/transport/dgcDeadLock/TestImpl_Stub.java b/test/java/rmi/transport/dgcDeadLock/TestImpl_Stub.java index 49ea79e9c1070c8490248e328f3bf877308b0061..f82df1fffbbc70566bb8803919858a8cc213b2fa 100644 --- a/test/java/rmi/transport/dgcDeadLock/TestImpl_Stub.java +++ b/test/java/rmi/transport/dgcDeadLock/TestImpl_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,78 +29,78 @@ public final class TestImpl_Stub implements Test, java.rmi.Remote { private static final java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("java.lang.String echo(java.lang.String)") + new java.rmi.server.Operation("java.lang.String echo(java.lang.String)") }; - + private static final long interfaceHash = 8975711176019764637L; - + private static final long serialVersionUID = 2; - + private static boolean useNewInvoke; private static java.lang.reflect.Method $method_echo_0; - + static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_echo_0 = Test.class.getMethod("echo", new java.lang.Class[] {java.lang.String.class}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } + try { + java.rmi.server.RemoteRef.class.getMethod("invoke", + new java.lang.Class[] { + java.rmi.Remote.class, + java.lang.reflect.Method.class, + java.lang.Object[].class, + long.class + }); + useNewInvoke = true; + $method_echo_0 = Test.class.getMethod("echo", new java.lang.Class[] {java.lang.String.class}); + } catch (java.lang.NoSuchMethodException e) { + useNewInvoke = false; + } } - + // constructors public TestImpl_Stub() { - super(); + super(); } public TestImpl_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of echo(String) public java.lang.String echo(java.lang.String $param_String_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - Object $result = ref.invoke(this, $method_echo_0, new java.lang.Object[] {$param_String_1}, 5525131960618330777L); - return ((java.lang.String) $result); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - try { - java.io.ObjectOutput out = call.getOutputStream(); - out.writeObject($param_String_1); - } catch (java.io.IOException e) { - throw new java.rmi.MarshalException("error marshalling arguments", e); - } - ref.invoke(call); - java.lang.String $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = (java.lang.String) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + Object $result = ref.invoke(this, $method_echo_0, new java.lang.Object[] {$param_String_1}, 5525131960618330777L); + return ((java.lang.String) $result); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + try { + java.io.ObjectOutput out = call.getOutputStream(); + out.writeObject($param_String_1); + } catch (java.io.IOException e) { + throw new java.rmi.MarshalException("error marshalling arguments", e); + } + ref.invoke(call); + java.lang.String $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = (java.lang.String) in.readObject(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } catch (java.lang.ClassNotFoundException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java b/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java index 1d26e6769a406775bcda35d1d7266cff61ae0113..e14de6adc5780f5bc21373ccc532ed0d7dde3c76 100644 --- a/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java +++ b/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -49,85 +49,85 @@ public class HandshakeFailure { public static void main(String[] args) throws Exception { - /* - * Listen on port... - */ - ServerSocket serverSocket = new ServerSocket(PORT); + /* + * Listen on port... + */ + ServerSocket serverSocket = new ServerSocket(PORT); - /* - * (Attempt RMI call to port in separate thread.) - */ - Registry registry = LocateRegistry.getRegistry(PORT); - Connector connector = new Connector(registry); - Thread t = new Thread(connector); - t.setDaemon(true); - t.start(); + /* + * (Attempt RMI call to port in separate thread.) + */ + Registry registry = LocateRegistry.getRegistry(PORT); + Connector connector = new Connector(registry); + Thread t = new Thread(connector); + t.setDaemon(true); + t.start(); - /* - * ...accept one connection from port and send non-JRMP data. - */ - Socket socket = serverSocket.accept(); - socket.getOutputStream().write("Wrong way".getBytes()); - socket.close(); + /* + * ...accept one connection from port and send non-JRMP data. + */ + Socket socket = serverSocket.accept(); + socket.getOutputStream().write("Wrong way".getBytes()); + socket.close(); - /* - * Wait for call attempt to finish, and analyze result. - */ - t.join(TIMEOUT); - synchronized (connector) { - if (connector.success) { - throw new RuntimeException( - "TEST FAILED: remote call succeeded??"); - } - if (connector.exception == null) { - throw new RuntimeException( - "TEST FAILED: remote call did not time out"); - } else { - System.err.println("remote call failed with exception:"); - connector.exception.printStackTrace(); - System.err.println(); + /* + * Wait for call attempt to finish, and analyze result. + */ + t.join(TIMEOUT); + synchronized (connector) { + if (connector.success) { + throw new RuntimeException( + "TEST FAILED: remote call succeeded??"); + } + if (connector.exception == null) { + throw new RuntimeException( + "TEST FAILED: remote call did not time out"); + } else { + System.err.println("remote call failed with exception:"); + connector.exception.printStackTrace(); + System.err.println(); - if (connector.exception instanceof MarshalException) { - System.err.println( - "TEST FAILED: MarshalException thrown, expecting " + - "java.rmi.ConnectException or ConnectIOException"); - } else if (connector.exception instanceof ConnectException || - connector.exception instanceof ConnectIOException) - { - System.err.println( - "TEST PASSED: java.rmi.ConnectException or " + - "ConnectIOException thrown"); - } else { - throw new RuntimeException( - "TEST FAILED: unexpected Exception thrown", - connector.exception); - } - } - } + if (connector.exception instanceof MarshalException) { + System.err.println( + "TEST FAILED: MarshalException thrown, expecting " + + "java.rmi.ConnectException or ConnectIOException"); + } else if (connector.exception instanceof ConnectException || + connector.exception instanceof ConnectIOException) + { + System.err.println( + "TEST PASSED: java.rmi.ConnectException or " + + "ConnectIOException thrown"); + } else { + throw new RuntimeException( + "TEST FAILED: unexpected Exception thrown", + connector.exception); + } + } + } } private static class Connector implements Runnable { - private final Registry registry; + private final Registry registry; - boolean success = false; + boolean success = false; Exception exception = null; - Connector(Registry registry) { - this.registry = registry; - } + Connector(Registry registry) { + this.registry = registry; + } - public void run() { - try { - registry.lookup("Dale Cooper"); - synchronized (this) { - success = true; - } - } catch (Exception e) { - synchronized (this) { - exception = e; - } - } - } + public void run() { + try { + registry.lookup("Dale Cooper"); + synchronized (this) { + success = true; + } + } catch (Exception e) { + synchronized (this) { + exception = e; + } + } + } } } diff --git a/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java b/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java index 43b8e96ad72784911d0f388cc0c4a6d2a2c2a422..c74c021b4865fe552d8f98bf11ec4c58b2528248 100644 --- a/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java +++ b/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -51,81 +51,81 @@ public class HandshakeTimeout { public static void main(String[] args) throws Exception { - System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", - String.valueOf(TIMEOUT / 2)); + System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", + String.valueOf(TIMEOUT / 2)); - /* - * Listen on port, but never process connections made to it. - */ - ServerSocket serverSocket = new ServerSocket(PORT); + /* + * Listen on port, but never process connections made to it. + */ + ServerSocket serverSocket = new ServerSocket(PORT); - /* - * Attempt RMI call to port in separate thread. - */ - Registry registry = LocateRegistry.getRegistry(PORT); - Connector connector = new Connector(registry); - Thread t = new Thread(connector); - t.setDaemon(true); - t.start(); + /* + * Attempt RMI call to port in separate thread. + */ + Registry registry = LocateRegistry.getRegistry(PORT); + Connector connector = new Connector(registry); + Thread t = new Thread(connector); + t.setDaemon(true); + t.start(); - /* - * Wait for call attempt to finished, and analyze result. - */ - t.join(TIMEOUT); - synchronized (connector) { - if (connector.success) { - throw new RuntimeException( - "TEST FAILED: remote call succeeded??"); - } - if (connector.exception == null) { - throw new RuntimeException( - "TEST FAILED: remote call did not time out"); - } else { - System.err.println("remote call failed with exception:"); - connector.exception.printStackTrace(); - System.err.println(); + /* + * Wait for call attempt to finished, and analyze result. + */ + t.join(TIMEOUT); + synchronized (connector) { + if (connector.success) { + throw new RuntimeException( + "TEST FAILED: remote call succeeded??"); + } + if (connector.exception == null) { + throw new RuntimeException( + "TEST FAILED: remote call did not time out"); + } else { + System.err.println("remote call failed with exception:"); + connector.exception.printStackTrace(); + System.err.println(); - if (connector.exception instanceof MarshalException) { - System.err.println( - "TEST FAILED: MarshalException thrown, expecting " + - "java.rmi.ConnectException or ConnectIOException"); - } else if (connector.exception instanceof ConnectException || - connector.exception instanceof ConnectIOException) - { - System.err.println( - "TEST PASSED: java.rmi.ConnectException or " + - "ConnectIOException thrown"); - } else { - throw new RuntimeException( - "TEST FAILED: unexpected Exception thrown", - connector.exception); - } - } - } + if (connector.exception instanceof MarshalException) { + System.err.println( + "TEST FAILED: MarshalException thrown, expecting " + + "java.rmi.ConnectException or ConnectIOException"); + } else if (connector.exception instanceof ConnectException || + connector.exception instanceof ConnectIOException) + { + System.err.println( + "TEST PASSED: java.rmi.ConnectException or " + + "ConnectIOException thrown"); + } else { + throw new RuntimeException( + "TEST FAILED: unexpected Exception thrown", + connector.exception); + } + } + } } private static class Connector implements Runnable { - private final Registry registry; + private final Registry registry; - boolean success = false; + boolean success = false; Exception exception = null; - Connector(Registry registry) { - this.registry = registry; - } + Connector(Registry registry) { + this.registry = registry; + } - public void run() { - try { - registry.lookup("Dale Cooper"); - synchronized (this) { - success = true; - } - } catch (Exception e) { - synchronized (this) { - exception = e; - } - } - } + public void run() { + try { + registry.lookup("Dale Cooper"); + synchronized (this) { + success = true; + } + } catch (Exception e) { + synchronized (this) { + exception = e; + } + } + } } } diff --git a/test/java/rmi/transport/httpSocket/HttpSocketTest.java b/test/java/rmi/transport/httpSocket/HttpSocketTest.java index 6f26b9b55548eb923fb4e246e149e4b718d9db82..8fbba5460cd361147e9e6486fd852748408177ed 100644 --- a/test/java/rmi/transport/httpSocket/HttpSocketTest.java +++ b/test/java/rmi/transport/httpSocket/HttpSocketTest.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -53,65 +53,60 @@ interface MyRemoteInterface extends Remote { Remote getRemoteObject() throws RemoteException; } -public class HttpSocketTest extends UnicastRemoteObject +public class HttpSocketTest extends UnicastRemoteObject implements MyRemoteInterface { private static final String NAME = "HttpSocketTest"; private static final String REGNAME = - "//:" + TestLibrary.REGISTRY_PORT + "/" + NAME; + "//:" + TestLibrary.REGISTRY_PORT + "/" + NAME; public HttpSocketTest() throws RemoteException{} private Remote ro; public static void main(String[] args) - throws Exception + throws Exception { - - Registry registry = null; - TestLibrary.suggestSecurityManager(null); - - // Set the socket factory. - System.err.println("installing socket factory"); - RMISocketFactory.setSocketFactory(new RMIHttpToPortSocketFactory()); + Registry registry = null; + + TestLibrary.suggestSecurityManager(null); + + // Set the socket factory. + System.err.println("installing socket factory"); + RMISocketFactory.setSocketFactory(new RMIHttpToPortSocketFactory()); - try { + try { System.err.println("Starting registry"); registry = LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); } catch (Exception e) { - TestLibrary.bomb(e); - } + TestLibrary.bomb(e); + } - try { + try { - registry.rebind( NAME, new HttpSocketTest() ); - MyRemoteInterface httpTest = - (MyRemoteInterface)Naming.lookup( REGNAME ); - httpTest.setRemoteObject( new HttpSocketTest() ); - Remote r = httpTest.getRemoteObject(); + registry.rebind( NAME, new HttpSocketTest() ); + MyRemoteInterface httpTest = + (MyRemoteInterface)Naming.lookup( REGNAME ); + httpTest.setRemoteObject( new HttpSocketTest() ); + Remote r = httpTest.getRemoteObject(); - } catch (Exception e) { - TestLibrary.bomb(e); - } + } catch (Exception e) { + TestLibrary.bomb(e); + } } public void setRemoteObject( Remote ro ) throws RemoteException { - this.ro = ro; + this.ro = ro; } public Remote getRemoteObject() throws RemoteException { - return( this.ro ); + return( this.ro ); } } - - - - - diff --git a/test/java/rmi/transport/httpSocket/HttpSocketTest_Stub.java b/test/java/rmi/transport/httpSocket/HttpSocketTest_Stub.java index d12b389d476685c7287ffbea0456d98720729f45..a8b2e3424415c5b30a6eb3e03bc7e325fb0f369a 100644 --- a/test/java/rmi/transport/httpSocket/HttpSocketTest_Stub.java +++ b/test/java/rmi/transport/httpSocket/HttpSocketTest_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,102 +29,102 @@ public final class HttpSocketTest_Stub implements MyRemoteInterface, java.rmi.Remote { private static final java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("java.rmi.Remote getRemoteObject()"), - new java.rmi.server.Operation("void setRemoteObject(java.rmi.Remote)") + new java.rmi.server.Operation("java.rmi.Remote getRemoteObject()"), + new java.rmi.server.Operation("void setRemoteObject(java.rmi.Remote)") }; - + private static final long interfaceHash = 3775375480010579665L; - + private static final long serialVersionUID = 2; - + private static boolean useNewInvoke; private static java.lang.reflect.Method $method_getRemoteObject_0; private static java.lang.reflect.Method $method_setRemoteObject_1; - + static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_getRemoteObject_0 = MyRemoteInterface.class.getMethod("getRemoteObject", new java.lang.Class[] {}); - $method_setRemoteObject_1 = MyRemoteInterface.class.getMethod("setRemoteObject", new java.lang.Class[] {java.rmi.Remote.class}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } + try { + java.rmi.server.RemoteRef.class.getMethod("invoke", + new java.lang.Class[] { + java.rmi.Remote.class, + java.lang.reflect.Method.class, + java.lang.Object[].class, + long.class + }); + useNewInvoke = true; + $method_getRemoteObject_0 = MyRemoteInterface.class.getMethod("getRemoteObject", new java.lang.Class[] {}); + $method_setRemoteObject_1 = MyRemoteInterface.class.getMethod("setRemoteObject", new java.lang.Class[] {java.rmi.Remote.class}); + } catch (java.lang.NoSuchMethodException e) { + useNewInvoke = false; + } } - + // constructors public HttpSocketTest_Stub() { - super(); + super(); } public HttpSocketTest_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of getRemoteObject() public java.rmi.Remote getRemoteObject() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - Object $result = ref.invoke(this, $method_getRemoteObject_0, null, -2578437860804964265L); - return ((java.rmi.Remote) $result); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - ref.invoke(call); - java.rmi.Remote $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = (java.rmi.Remote) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + Object $result = ref.invoke(this, $method_getRemoteObject_0, null, -2578437860804964265L); + return ((java.rmi.Remote) $result); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + ref.invoke(call); + java.rmi.Remote $result; + try { + java.io.ObjectInput in = call.getInputStream(); + $result = (java.rmi.Remote) in.readObject(); + } catch (java.io.IOException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } catch (java.lang.ClassNotFoundException e) { + throw new java.rmi.UnmarshalException("error unmarshalling return", e); + } finally { + ref.done(call); + } + return $result; + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } - + // implementation of setRemoteObject(Remote) public void setRemoteObject(java.rmi.Remote $param_Remote_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - if (useNewInvoke) { - ref.invoke(this, $method_setRemoteObject_1, new java.lang.Object[] {$param_Remote_1}, -7518632118115022871L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); - try { - java.io.ObjectOutput out = call.getOutputStream(); - out.writeObject($param_Remote_1); - } catch (java.io.IOException e) { - throw new java.rmi.MarshalException("error marshalling arguments", e); - } - ref.invoke(call); - ref.done(call); - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + if (useNewInvoke) { + ref.invoke(this, $method_setRemoteObject_1, new java.lang.Object[] {$param_Remote_1}, -7518632118115022871L); + } else { + java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); + try { + java.io.ObjectOutput out = call.getOutputStream(); + out.writeObject($param_Remote_1); + } catch (java.io.IOException e) { + throw new java.rmi.MarshalException("error marshalling arguments", e); + } + ref.invoke(call); + ref.done(call); + } + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java b/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java index 23075675a900efd7d7efbcef996bcdfb4b303631..8f1bd834b31ff6d00409b02d018b1e1f7ffd1beb 100644 --- a/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java +++ b/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -60,109 +60,109 @@ public class PinClientSocketFactory { private static final int SESSIONS = 50; public interface Factory extends Remote { - Session getSession() throws RemoteException; + Session getSession() throws RemoteException; } public interface Session extends Remote { - void ping() throws RemoteException; + void ping() throws RemoteException; } private static class FactoryImpl implements Factory { - FactoryImpl() { } - public Session getSession() throws RemoteException { - Session impl = new SessionImpl(); - UnicastRemoteObject.exportObject(impl, 0, new CSF(), new SSF()); - // return impl instead of stub to work around 4114579 - return impl; - } + FactoryImpl() { } + public Session getSession() throws RemoteException { + Session impl = new SessionImpl(); + UnicastRemoteObject.exportObject(impl, 0, new CSF(), new SSF()); + // return impl instead of stub to work around 4114579 + return impl; + } } private static class SessionImpl implements Session { - SessionImpl() { } - public void ping() { } + SessionImpl() { } + public void ping() { } } public static void main(String[] args) throws Exception { - System.err.println("\nRegression test for bug 4486732\n"); - - Factory factoryImpl = new FactoryImpl(); - Factory factoryStub = - (Factory) UnicastRemoteObject.exportObject(factoryImpl, 0); - for (int i = 0; i < SESSIONS; i++) { - Session session = factoryStub.getSession(); - session.ping(); - } - UnicastRemoteObject.unexportObject(factoryImpl, true); - - Registry registryImpl = LocateRegistry.createRegistry(PORT); - CSF csf = new CSF(); - Reference registryRef = new WeakReference(csf); - Registry registryStub = LocateRegistry.getRegistry("", PORT, csf); - csf = null; - registryStub.list(); - registryStub = null; - UnicastRemoteObject.unexportObject(registryImpl, true); - - System.gc(); - // allow connections to time out - Thread.sleep(3 * Long.getLong("sun.rmi.transport.connectionTimeout", - 15000)); - System.gc(); - - if (CSF.deserializedInstances.size() != SESSIONS) { - throw new Error("unexpected number of deserialized instances: " + - CSF.deserializedInstances.size()); - } - - int nonNullCount = 0; - for (Reference ref : CSF.deserializedInstances) { - csf = ref.get(); - if (csf != null) { - System.err.println("non-null deserialized instance: " + csf); - nonNullCount++; - } - } - if (nonNullCount > 0) { - throw new Error("TEST FAILED: " + - nonNullCount + " non-null deserialized instances"); - } - - csf = registryRef.get(); - if (csf != null) { - System.err.println("non-null registry instance: " + csf); - throw new Error("TEST FAILED: non-null registry instance"); - } - - System.err.println("TEST PASSED"); + System.err.println("\nRegression test for bug 4486732\n"); + + Factory factoryImpl = new FactoryImpl(); + Factory factoryStub = + (Factory) UnicastRemoteObject.exportObject(factoryImpl, 0); + for (int i = 0; i < SESSIONS; i++) { + Session session = factoryStub.getSession(); + session.ping(); + } + UnicastRemoteObject.unexportObject(factoryImpl, true); + + Registry registryImpl = LocateRegistry.createRegistry(PORT); + CSF csf = new CSF(); + Reference registryRef = new WeakReference(csf); + Registry registryStub = LocateRegistry.getRegistry("", PORT, csf); + csf = null; + registryStub.list(); + registryStub = null; + UnicastRemoteObject.unexportObject(registryImpl, true); + + System.gc(); + // allow connections to time out + Thread.sleep(3 * Long.getLong("sun.rmi.transport.connectionTimeout", + 15000)); + System.gc(); + + if (CSF.deserializedInstances.size() != SESSIONS) { + throw new Error("unexpected number of deserialized instances: " + + CSF.deserializedInstances.size()); + } + + int nonNullCount = 0; + for (Reference ref : CSF.deserializedInstances) { + csf = ref.get(); + if (csf != null) { + System.err.println("non-null deserialized instance: " + csf); + nonNullCount++; + } + } + if (nonNullCount > 0) { + throw new Error("TEST FAILED: " + + nonNullCount + " non-null deserialized instances"); + } + + csf = registryRef.get(); + if (csf != null) { + System.err.println("non-null registry instance: " + csf); + throw new Error("TEST FAILED: non-null registry instance"); + } + + System.err.println("TEST PASSED"); } private static class CSF implements RMIClientSocketFactory, Serializable { - static final List> deserializedInstances = - Collections.synchronizedList(new ArrayList>()); - private static final AtomicInteger count = new AtomicInteger(0); - private int num = count.incrementAndGet(); - CSF() { } - public Socket createSocket(String host, int port) throws IOException { - return new Socket(host, port); - } - public int hashCode() { - return num; - } - public boolean equals(Object obj) { - return obj instanceof CSF && ((CSF) obj).num == num; - } - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - deserializedInstances.add(new WeakReference(this)); - } + static final List> deserializedInstances = + Collections.synchronizedList(new ArrayList>()); + private static final AtomicInteger count = new AtomicInteger(0); + private int num = count.incrementAndGet(); + CSF() { } + public Socket createSocket(String host, int port) throws IOException { + return new Socket(host, port); + } + public int hashCode() { + return num; + } + public boolean equals(Object obj) { + return obj instanceof CSF && ((CSF) obj).num == num; + } + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + in.defaultReadObject(); + deserializedInstances.add(new WeakReference(this)); + } } private static class SSF implements RMIServerSocketFactory { - SSF() { } - public ServerSocket createServerSocket(int port) throws IOException { - return new ServerSocket(port); - } + SSF() { } + public ServerSocket createServerSocket(int port) throws IOException { + return new ServerSocket(port); + } } } diff --git a/test/java/rmi/transport/pinLastArguments/PinLastArguments.java b/test/java/rmi/transport/pinLastArguments/PinLastArguments.java index 590a1ce6e918c79a47475e20166595dc881c0d0b..b85ad3a80c93a3ad4811e8f300fbdf193a4e35c6 100644 --- a/test/java/rmi/transport/pinLastArguments/PinLastArguments.java +++ b/test/java/rmi/transport/pinLastArguments/PinLastArguments.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -45,45 +45,45 @@ import java.rmi.server.UnicastRemoteObject; public class PinLastArguments { public interface Ping extends Remote { - void ping(Object first, Object second) throws RemoteException; + void ping(Object first, Object second) throws RemoteException; } private static class PingImpl implements Ping { - PingImpl() { } - public void ping(Object first, Object second) { - System.err.println("ping invoked: " + first + ", " + second); - } + PingImpl() { } + public void ping(Object first, Object second) { + System.err.println("ping invoked: " + first + ", " + second); + } } public static void main(String[] args) throws Exception { - System.err.println("\nRegression test for bug 6332349\n"); + System.err.println("\nRegression test for bug 6332349\n"); - Ping impl = new PingImpl(); - Reference ref = new WeakReference(impl); - try { - Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0); - Object notSerializable = new Object(); - stub.ping(impl, null); - try { - stub.ping(impl, notSerializable); - } catch (MarshalException e) { - if (e.getCause() instanceof NotSerializableException) { - System.err.println("ping invocation failed as expected"); - } else { - throw e; - } - } - } finally { - UnicastRemoteObject.unexportObject(impl, true); - } - impl = null; + Ping impl = new PingImpl(); + Reference ref = new WeakReference(impl); + try { + Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0); + Object notSerializable = new Object(); + stub.ping(impl, null); + try { + stub.ping(impl, notSerializable); + } catch (MarshalException e) { + if (e.getCause() instanceof NotSerializableException) { + System.err.println("ping invocation failed as expected"); + } else { + throw e; + } + } + } finally { + UnicastRemoteObject.unexportObject(impl, true); + } + impl = null; - System.gc(); + System.gc(); - if (ref.get() != null) { - throw new Error("TEST FAILED: impl not garbage collected"); - } + if (ref.get() != null) { + throw new Error("TEST FAILED: impl not garbage collected"); + } - System.err.println("TEST PASSED"); + System.err.println("TEST PASSED"); } } diff --git a/test/java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java b/test/java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java index bf74bf847cc1178ac2dec800b5a2c89b0e43e405..fa810c4437c09817e052fa9e526f321d557b58cd 100644 --- a/test/java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java +++ b/test/java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -46,22 +46,22 @@ public class RapidExportUnexport { private static final long TIMEOUT = 60000; public static void main(String[] args) throws Exception { - System.err.println("\nRegression test for bug 6275081\n"); + System.err.println("\nRegression test for bug 6275081\n"); - Remote impl = new Remote() { }; - long start = System.currentTimeMillis(); - for (int i = 0; i < REPS; i++) { - System.err.println(i); - UnicastRemoteObject.exportObject(impl, PORT); - UnicastRemoteObject.unexportObject(impl, true); - Thread.sleep(1); // work around BindException (bug?) - } - long delta = System.currentTimeMillis() - start; - System.err.println(REPS + " export/unexport operations took " + - delta + "ms"); - if (delta > TIMEOUT) { - throw new Error("TEST FAILED: took over " + TIMEOUT + "ms"); - } - System.err.println("TEST PASSED"); + Remote impl = new Remote() { }; + long start = System.currentTimeMillis(); + for (int i = 0; i < REPS; i++) { + System.err.println(i); + UnicastRemoteObject.exportObject(impl, PORT); + UnicastRemoteObject.unexportObject(impl, true); + Thread.sleep(1); // work around BindException (bug?) + } + long delta = System.currentTimeMillis() - start; + System.err.println(REPS + " export/unexport operations took " + + delta + "ms"); + if (delta > TIMEOUT) { + throw new Error("TEST FAILED: took over " + TIMEOUT + "ms"); + } + System.err.println("TEST PASSED"); } } diff --git a/test/java/rmi/transport/readTimeout/ReadTimeoutTest.java b/test/java/rmi/transport/readTimeout/ReadTimeoutTest.java index a9c4d8b595b0c49b02787f9a8b849ebc68d98ae4..0bdd65d5bb861dc0ef7f2b43bf7e47318acb28f9 100644 --- a/test/java/rmi/transport/readTimeout/ReadTimeoutTest.java +++ b/test/java/rmi/transport/readTimeout/ReadTimeoutTest.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -50,134 +50,134 @@ import java.net.*; public class ReadTimeoutTest { - private static final int DELAY = 5000; // milliseconds + private static final int DELAY = 5000; // milliseconds public static void main(String[] args) - throws Exception + throws Exception { - // Make trouble for ourselves - if (System.getSecurityManager() == null) - System.setSecurityManager(new RMISecurityManager()); - - // Flaky code alert - hope this is executed before TCPTransport. - System.setProperty("sun.rmi.transport.tcp.readTimeout", Integer.toString(DELAY)); - - // Set the socket factory. - System.err.println("(installing socket factory)"); - SomeFactory fac = new SomeFactory(); - RMISocketFactory.setSocketFactory(fac); - - // Create remote object - TestImpl impl = new TestImpl(); - - // Export and get which port. - System.err.println("(exporting remote object)"); - TestIface stub = impl.export(); - Socket DoS = null; - try { - int port = fac.whichPort(); - - // Sanity - if (port == 0) - throw new Error("TEST FAILED: export didn't reserve a port(?)"); - - // Now, connect to that port - //Thread.sleep(2000); - System.err.println("(connecting to listening port on 127.0.0.1:" + - port + ")"); - DoS = new Socket("127.0.0.1", port); - InputStream stream = DoS.getInputStream(); - - // Read on the socket in the background - boolean[] successful = new boolean[] { false }; - (new SomeReader(stream, successful)).start(); - - // Wait for completion - int nretries = 4; - while (nretries-- > 0) { - if (successful[0]) - break; - Thread.sleep(DELAY); - } - - if (successful[0]) { - System.err.println("TEST PASSED."); - } else { - throw new Error("TEST FAILED."); - } - - } finally { - try { - if (DoS != null) - DoS.close(); // aborts the reader if still blocked - impl.unexport(); - } catch (Throwable unmatter) { - } - } - - // Should exit here + // Make trouble for ourselves + if (System.getSecurityManager() == null) + System.setSecurityManager(new RMISecurityManager()); + + // Flaky code alert - hope this is executed before TCPTransport. + System.setProperty("sun.rmi.transport.tcp.readTimeout", Integer.toString(DELAY)); + + // Set the socket factory. + System.err.println("(installing socket factory)"); + SomeFactory fac = new SomeFactory(); + RMISocketFactory.setSocketFactory(fac); + + // Create remote object + TestImpl impl = new TestImpl(); + + // Export and get which port. + System.err.println("(exporting remote object)"); + TestIface stub = impl.export(); + Socket DoS = null; + try { + int port = fac.whichPort(); + + // Sanity + if (port == 0) + throw new Error("TEST FAILED: export didn't reserve a port(?)"); + + // Now, connect to that port + //Thread.sleep(2000); + System.err.println("(connecting to listening port on 127.0.0.1:" + + port + ")"); + DoS = new Socket("127.0.0.1", port); + InputStream stream = DoS.getInputStream(); + + // Read on the socket in the background + boolean[] successful = new boolean[] { false }; + (new SomeReader(stream, successful)).start(); + + // Wait for completion + int nretries = 4; + while (nretries-- > 0) { + if (successful[0]) + break; + Thread.sleep(DELAY); + } + + if (successful[0]) { + System.err.println("TEST PASSED."); + } else { + throw new Error("TEST FAILED."); + } + + } finally { + try { + if (DoS != null) + DoS.close(); // aborts the reader if still blocked + impl.unexport(); + } catch (Throwable unmatter) { + } + } + + // Should exit here } private static class SomeFactory - extends RMISocketFactory + extends RMISocketFactory { - private int servport = 0; - - public Socket createSocket(String h, int p) - throws IOException - { - return (new Socket(h, p)); - } - - /** Create a server socket and remember which port it's on. - * Aborts if createServerSocket(0) is called twice, because then - * it doesn't know whether to remember the first or second port. - */ - public ServerSocket createServerSocket(int p) - throws IOException - { - ServerSocket ss; - ss = new ServerSocket(p); - if (p == 0) { - if (servport != 0) { - System.err.println("TEST FAILED: " + - "Duplicate createServerSocket(0)"); - throw new Error("Test aborted (createServerSocket)"); - } - servport = ss.getLocalPort(); - } - return (ss); - } - - /** Return which port was reserved by createServerSocket(0). - * If the return value was 0, createServerSocket(0) wasn't called. - */ - public int whichPort() { - return (servport); - } + private int servport = 0; + + public Socket createSocket(String h, int p) + throws IOException + { + return (new Socket(h, p)); + } + + /** Create a server socket and remember which port it's on. + * Aborts if createServerSocket(0) is called twice, because then + * it doesn't know whether to remember the first or second port. + */ + public ServerSocket createServerSocket(int p) + throws IOException + { + ServerSocket ss; + ss = new ServerSocket(p); + if (p == 0) { + if (servport != 0) { + System.err.println("TEST FAILED: " + + "Duplicate createServerSocket(0)"); + throw new Error("Test aborted (createServerSocket)"); + } + servport = ss.getLocalPort(); + } + return (ss); + } + + /** Return which port was reserved by createServerSocket(0). + * If the return value was 0, createServerSocket(0) wasn't called. + */ + public int whichPort() { + return (servport); + } } // end class SomeFactory protected static class SomeReader extends Thread { - private InputStream readon; - private boolean[] vec; - - public SomeReader(InputStream s, boolean[] successvec) { - super(); - this.setDaemon(true); - this.readon = s; - this.vec = successvec; - } - - public void run() { - try { - int c = this.readon.read(); - if (c != -1) - throw new Error ("Server returned " + c); - this.vec[0] = true; - - } catch (IOException e) { - e.printStackTrace(); - } - } + private InputStream readon; + private boolean[] vec; + + public SomeReader(InputStream s, boolean[] successvec) { + super(); + this.setDaemon(true); + this.readon = s; + this.vec = successvec; + } + + public void run() { + try { + int c = this.readon.read(); + if (c != -1) + throw new Error ("Server returned " + c); + this.vec[0] = true; + + } catch (IOException e) { + e.printStackTrace(); + } + } } // end class SomeReader } diff --git a/test/java/rmi/transport/readTimeout/TestIface.java b/test/java/rmi/transport/readTimeout/TestIface.java index 793afbba06a2b4195692d70e72eb655e25179a9f..a7096a0b2ca91d99e42076c2bb429aeb831dec4a 100644 --- a/test/java/rmi/transport/readTimeout/TestIface.java +++ b/test/java/rmi/transport/readTimeout/TestIface.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,5 +27,5 @@ public interface TestIface extends Remote { public String testCall(String ign) - throws RemoteException; + throws RemoteException; } diff --git a/test/java/rmi/transport/readTimeout/TestImpl.java b/test/java/rmi/transport/readTimeout/TestImpl.java index eae651b524711a83cbb8e5282d205e93c7cb8a26..3fc6af8b29a45cf56ed342bbfadb8a5f7203734b 100644 --- a/test/java/rmi/transport/readTimeout/TestImpl.java +++ b/test/java/rmi/transport/readTimeout/TestImpl.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,19 +32,18 @@ public class TestImpl } public TestIface export() - throws RemoteException + throws RemoteException { - return (TestIface)UnicastRemoteObject.exportObject(this); + return (TestIface)UnicastRemoteObject.exportObject(this); } public void unexport() - throws NoSuchObjectException + throws NoSuchObjectException { - UnicastRemoteObject.unexportObject(this, true); + UnicastRemoteObject.unexportObject(this, true); } public String testCall(String ign) { - return ("OK"); + return ("OK"); } } - diff --git a/test/java/rmi/transport/readTimeout/TestImpl_Stub.java b/test/java/rmi/transport/readTimeout/TestImpl_Stub.java index 74c716d91362b033f45101b1ba0d21abe4fd1747..223ce7915c56ff783ed5218f89f384291d03f685 100644 --- a/test/java/rmi/transport/readTimeout/TestImpl_Stub.java +++ b/test/java/rmi/transport/readTimeout/TestImpl_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,38 +29,38 @@ public final class TestImpl_Stub implements TestIface { private static final long serialVersionUID = 2; - + private static java.lang.reflect.Method $method_testCall_0; - + static { - try { - $method_testCall_0 = TestIface.class.getMethod("testCall", new java.lang.Class[] {java.lang.String.class}); - } catch (java.lang.NoSuchMethodException e) { - throw new java.lang.NoSuchMethodError( - "stub class initialization failed"); - } + try { + $method_testCall_0 = TestIface.class.getMethod("testCall", new java.lang.Class[] {java.lang.String.class}); + } catch (java.lang.NoSuchMethodException e) { + throw new java.lang.NoSuchMethodError( + "stub class initialization failed"); + } } - + // constructors public TestImpl_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + // methods from remote interfaces - + // implementation of testCall(String) public java.lang.String testCall(java.lang.String $param_String_1) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { - try { - Object $result = ref.invoke(this, $method_testCall_0, new java.lang.Object[] {$param_String_1}, -4495720265115653109L); - return ((java.lang.String) $result); - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } + try { + Object $result = ref.invoke(this, $method_testCall_0, new java.lang.Object[] {$param_String_1}, -4495720265115653109L); + return ((java.lang.String) $result); + } catch (java.lang.RuntimeException e) { + throw e; + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.Exception e) { + throw new java.rmi.UnexpectedException("undeclared checked exception", e); + } } } diff --git a/test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java b/test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java index be40e1553a7314a54913a465bb9e7e9249031a7f..cf38628094559bb7224bc9c85cdb691bf80fa5be 100644 --- a/test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java +++ b/test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -53,32 +53,32 @@ public class ReuseDefaultPort implements Remote { private ReuseDefaultPort() { } public static void main(String[] args) throws Exception { - System.err.println("\nRegression test for bug 6269166\n"); - RMISocketFactory.setSocketFactory(new SF()); - Remote impl = new ReuseDefaultPort(); - Remote stub = UnicastRemoteObject.exportObject(impl, 0); - System.err.println("- exported object: " + stub); - try { - Registry registry = LocateRegistry.createRegistry(PORT); - System.err.println("- exported registry: " + registry); - System.err.println("TEST PASSED"); - } finally { - UnicastRemoteObject.unexportObject(impl, true); - } + System.err.println("\nRegression test for bug 6269166\n"); + RMISocketFactory.setSocketFactory(new SF()); + Remote impl = new ReuseDefaultPort(); + Remote stub = UnicastRemoteObject.exportObject(impl, 0); + System.err.println("- exported object: " + stub); + try { + Registry registry = LocateRegistry.createRegistry(PORT); + System.err.println("- exported registry: " + registry); + System.err.println("TEST PASSED"); + } finally { + UnicastRemoteObject.unexportObject(impl, true); + } } private static class SF extends RMISocketFactory { - private static RMISocketFactory defaultFactory = - RMISocketFactory.getDefaultSocketFactory(); - SF() { } - public Socket createSocket(String host, int port) throws IOException { - return defaultFactory.createSocket(host, port); - } - public ServerSocket createServerSocket(int port) throws IOException { - if (port == 0) { - port = PORT; - } - return defaultFactory.createServerSocket(port); - } + private static RMISocketFactory defaultFactory = + RMISocketFactory.getDefaultSocketFactory(); + SF() { } + public Socket createSocket(String host, int port) throws IOException { + return defaultFactory.createSocket(host, port); + } + public ServerSocket createServerSocket(int port) throws IOException { + if (port == 0) { + port = PORT; + } + return defaultFactory.createServerSocket(port); + } } } diff --git a/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java b/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java index a2855ffe4a779b4b2d432f7fdd101311d3c88b37..245942ddcd776ac70b1f8aa61b35b117c19d72a1 100644 --- a/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java +++ b/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -60,80 +60,80 @@ public class RuntimeThreadInheritanceLeak implements Remote { public static void main(String[] args) { - System.err.println("\nRegression test for bug 4404702\n"); - - /* - * HACK: Work around the fact that java.util.logging.LogManager's - * (singleton) construction also has this bug-- it will register a - * "shutdown hook", i.e. a thread, which will inherit and pin the - * current thread's context class loader for the lifetime of the VM-- - * by causing the LogManager to be initialized now, instead of by - * RMI when our special context class loader is set. - */ - java.util.logging.LogManager.getLogManager(); - - /* - * HACK: Work around the fact that the non-native, thread-based - * SecureRandom seed generator (ThreadedSeedGenerator) seems to - * have this bug too (which had been causing this test to fail - * when run with jtreg on Windows XP-- see 4910382). - */ - (new java.security.SecureRandom()).nextInt(); - - RuntimeThreadInheritanceLeak obj = new RuntimeThreadInheritanceLeak(); - - try { - ClassLoader loader = URLClassLoader.newInstance(new URL[0]); - ReferenceQueue refQueue = new ReferenceQueue(); - Reference loaderRef = new WeakReference(loader, refQueue); - System.err.println("created loader: " + loader); - - Thread.currentThread().setContextClassLoader(loader); - UnicastRemoteObject.exportObject(obj); - Thread.currentThread().setContextClassLoader( - ClassLoader.getSystemClassLoader()); - System.err.println( - "exported remote object with loader as context class loader"); - - loader = null; - System.err.println("nulled strong reference to loader"); - - UnicastRemoteObject.unexportObject(obj, true); - System.err.println("unexported remote object"); - - /* - * HACK: Work around the fact that the sun.misc.GC daemon thread - * also has this bug-- it will have inherited our loader as its - * context class loader-- by giving it a chance to pass away. - */ - Thread.sleep(2000); - System.gc(); - - System.err.println( - "waiting to be notified of loader being weakly reachable..."); - Reference dequeued = refQueue.remove(TIMEOUT); - if (dequeued == null) { - System.err.println( - "TEST FAILED: loader not deteced weakly reachable"); - dumpThreads(); - throw new RuntimeException( - "TEST FAILED: loader not detected weakly reachable"); - } - - System.err.println( - "TEST PASSED: loader detected weakly reachable"); - dumpThreads(); - - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new RuntimeException("TEST FAILED: unexpected exception", e); - } finally { - try { - UnicastRemoteObject.unexportObject(obj, true); - } catch (RemoteException e) { - } - } + System.err.println("\nRegression test for bug 4404702\n"); + + /* + * HACK: Work around the fact that java.util.logging.LogManager's + * (singleton) construction also has this bug-- it will register a + * "shutdown hook", i.e. a thread, which will inherit and pin the + * current thread's context class loader for the lifetime of the VM-- + * by causing the LogManager to be initialized now, instead of by + * RMI when our special context class loader is set. + */ + java.util.logging.LogManager.getLogManager(); + + /* + * HACK: Work around the fact that the non-native, thread-based + * SecureRandom seed generator (ThreadedSeedGenerator) seems to + * have this bug too (which had been causing this test to fail + * when run with jtreg on Windows XP-- see 4910382). + */ + (new java.security.SecureRandom()).nextInt(); + + RuntimeThreadInheritanceLeak obj = new RuntimeThreadInheritanceLeak(); + + try { + ClassLoader loader = URLClassLoader.newInstance(new URL[0]); + ReferenceQueue refQueue = new ReferenceQueue(); + Reference loaderRef = new WeakReference(loader, refQueue); + System.err.println("created loader: " + loader); + + Thread.currentThread().setContextClassLoader(loader); + UnicastRemoteObject.exportObject(obj); + Thread.currentThread().setContextClassLoader( + ClassLoader.getSystemClassLoader()); + System.err.println( + "exported remote object with loader as context class loader"); + + loader = null; + System.err.println("nulled strong reference to loader"); + + UnicastRemoteObject.unexportObject(obj, true); + System.err.println("unexported remote object"); + + /* + * HACK: Work around the fact that the sun.misc.GC daemon thread + * also has this bug-- it will have inherited our loader as its + * context class loader-- by giving it a chance to pass away. + */ + Thread.sleep(2000); + System.gc(); + + System.err.println( + "waiting to be notified of loader being weakly reachable..."); + Reference dequeued = refQueue.remove(TIMEOUT); + if (dequeued == null) { + System.err.println( + "TEST FAILED: loader not deteced weakly reachable"); + dumpThreads(); + throw new RuntimeException( + "TEST FAILED: loader not detected weakly reachable"); + } + + System.err.println( + "TEST PASSED: loader detected weakly reachable"); + dumpThreads(); + + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new RuntimeException("TEST FAILED: unexpected exception", e); + } finally { + try { + UnicastRemoteObject.unexportObject(obj, true); + } catch (RemoteException e) { + } + } } /** @@ -141,19 +141,19 @@ public class RuntimeThreadInheritanceLeak implements Remote { * including their context class loaders. **/ private static void dumpThreads() { - System.err.println( - "current live threads and their context class loaders:"); - Map threads = Thread.getAllStackTraces(); - for (Iterator iter = threads.entrySet().iterator(); iter.hasNext();) { - Map.Entry e = (Map.Entry) iter.next(); - Thread t = (Thread) e.getKey(); - System.err.println(" thread: " + t); - System.err.println(" context class loader: " + - t.getContextClassLoader()); - StackTraceElement[] trace = (StackTraceElement[]) e.getValue(); - for (int i = 0; i < trace.length; i++) { - System.err.println(" " + trace[i]); - } - } + System.err.println( + "current live threads and their context class loaders:"); + Map threads = Thread.getAllStackTraces(); + for (Iterator iter = threads.entrySet().iterator(); iter.hasNext();) { + Map.Entry e = (Map.Entry) iter.next(); + Thread t = (Thread) e.getKey(); + System.err.println(" thread: " + t); + System.err.println(" context class loader: " + + t.getContextClassLoader()); + StackTraceElement[] trace = (StackTraceElement[]) e.getValue(); + for (int i = 0; i < trace.length; i++) { + System.err.println(" " + trace[i]); + } + } } } diff --git a/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak_Stub.java b/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak_Stub.java index 016142118f98f5d2220221417a597c9782ca8a16..bc17d11e8db17b11ef224539476322ce54d69e1f 100644 --- a/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak_Stub.java +++ b/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak_Stub.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,10 +29,10 @@ public final class RuntimeThreadInheritanceLeak_Stub implements java.rmi.Remote { private static final long serialVersionUID = 2; - + // constructors public RuntimeThreadInheritanceLeak_Stub(java.rmi.server.RemoteRef ref) { - super(ref); + super(ref); } - + } diff --git a/test/java/security/AccessControlContext/FailureDebugOption.java b/test/java/security/AccessControlContext/FailureDebugOption.java new file mode 100644 index 0000000000000000000000000000000000000000..df48203ecb918c7a622ea7e3d31094d8e566b1fb --- /dev/null +++ b/test/java/security/AccessControlContext/FailureDebugOption.java @@ -0,0 +1,50 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6648816 + * @summary REGRESSION: setting -Djava.security.debug=failure result in NPE + * in ACC + * @run main/othervm -Djava.security.debug=failure FailureDebugOption + */ + +import java.security.ProtectionDomain; +import java.security.AccessController; +import java.security.AccessControlException; +import java.security.BasicPermission; + +public class FailureDebugOption { + + public static void main (String argv[]) throws Exception { + try { + AccessController.checkPermission( + new BasicPermission("no such permission"){}); + } catch (NullPointerException npe) { + throw new Exception("Unexpected NullPointerException for security" + + " debug option, -Djava.security.debug=failure"); + } catch (AccessControlException ace) { + } + } +} + diff --git a/test/java/util/Map/LockStep.java b/test/java/util/Map/LockStep.java new file mode 100644 index 0000000000000000000000000000000000000000..58b24e27d7b864c1a74af6d55f35c4a32b3b76b1 --- /dev/null +++ b/test/java/util/Map/LockStep.java @@ -0,0 +1,127 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6612102 + * @summary Test Map implementations for mutual compatibility + */ + +import java.util.*; +import java.util.concurrent.*; + +/** + * Based on the strange scenario required to reproduce + * (coll) IdentityHashMap.iterator().remove() might decrement size twice + * + * It would be good to add more "Lockstep-style" tests to this file. + */ +public class LockStep { + void mapsEqual(Map m1, Map m2) { + equal(m1, m2); + equal(m2, m1); + equal(m1.size(), m2.size()); + equal(m1.isEmpty(), m2.isEmpty()); + equal(m1.keySet(), m2.keySet()); + equal(m2.keySet(), m1.keySet()); + } + + void mapsEqual(List maps) { + Map first = maps.get(0); + for (Map map : maps) + mapsEqual(first, map); + } + + void put(List maps, Object key, Object val) { + for (Map map : maps) + map.put(key, val); + mapsEqual(maps); + } + + void removeLastTwo(List maps) { + Map first = maps.get(0); + int size = first.size(); + Iterator fit = first.keySet().iterator(); + for (int j = 0; j < size - 2; j++) + fit.next(); + Object x1 = fit.next(); + Object x2 = fit.next(); + + for (Map map : maps) { + Iterator it = map.keySet().iterator(); + while (it.hasNext()) { + Object x = it.next(); + if (x == x1 || x == x2) + it.remove(); + } + } + mapsEqual(maps); + } + + void remove(Map m, Iterator it) { + int size = m.size(); + it.remove(); + if (m.size() != size-1) + throw new Error(String.format("Incorrect size!%nmap=%s, size=%d%n", + m.toString(), m.size())); + } + + void test(String[] args) throws Throwable { + final int iterations = 100; + final Random r = new Random(); + + for (int i = 0; i < iterations; i++) { + List maps = Arrays.asList( + new Map[] { + new IdentityHashMap(11), + new HashMap(16), + new LinkedHashMap(16), + new WeakHashMap(16), + new Hashtable(16), + new TreeMap(), + new ConcurrentHashMap(16), + new ConcurrentSkipListMap() }); + + for (int j = 0; j < 10; j++) + put(maps, r.nextInt(100), r.nextInt(100)); + removeLastTwo(maps); + } + } + + //--------------------- Infrastructure --------------------------- + volatile int passed = 0, failed = 0; + void pass() {passed++;} + void fail() {failed++; Thread.dumpStack();} + void fail(String msg) {System.err.println(msg); fail();} + void unexpected(Throwable t) {failed++; t.printStackTrace();} + void check(boolean cond) {if (cond) pass(); else fail();} + void equal(Object x, Object y) { + if (x == null ? y == null : x.equals(y)) pass(); + else fail(x + " not equal to " + y);} + public static void main(String[] args) throws Throwable { + new LockStep().instanceMain(args);} + void instanceMain(String[] args) throws Throwable { + try {test(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/concurrent/DelayQueue/Stress.java b/test/java/util/concurrent/DelayQueue/Stress.java new file mode 100644 index 0000000000000000000000000000000000000000..e225f542efddd420adea4f79f9c0821d3b633da2 --- /dev/null +++ b/test/java/util/concurrent/DelayQueue/Stress.java @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.util.concurrent.*; +import static java.util.concurrent.TimeUnit.*; + +/** + * This is not a regression test, but a stress benchmark test for + * 6609775: Reduce context switches in DelayQueue due to signalAll + * + * This runs in the same wall clock time, but much reduced cpu time, + * with the changes for 6609775. + */ +public class Stress { + + public static void main(String[] args) throws Throwable { + + final DelayQueue q = new DelayQueue(); + final long t0 = System.nanoTime(); + for (long i = 0; i < 1000; i++) { + final long expiry = t0 + i*10L*1000L*1000L; + q.add(new Delayed() { + public long getDelay(TimeUnit unit) { + return unit.convert(expiry - System.nanoTime(), + NANOSECONDS); + } + public int compareTo(Delayed x) { + long d = getDelay(NANOSECONDS) + - x.getDelay(NANOSECONDS); + return d < 0 ? -1 : d > 0 ? 1 : 0; }}); + } + + for (int i = 0; i < 300; i++) + new Thread() { public void run() { + try { + while (!q.isEmpty()) + q.poll(10L, TimeUnit.SECONDS); + } catch (Throwable t) { t.printStackTrace(); } + }}.start(); + } +} diff --git a/test/java/util/concurrent/LinkedBlockingQueue/OfferRemoveLoops.java b/test/java/util/concurrent/LinkedBlockingQueue/OfferRemoveLoops.java index bcec477ce8d9a121bdfb1526df3aef412d2de41c..baca8f1b0f1e741b589877bb0fdb2d2bbf3cbee0 100644 --- a/test/java/util/concurrent/LinkedBlockingQueue/OfferRemoveLoops.java +++ b/test/java/util/concurrent/LinkedBlockingQueue/OfferRemoveLoops.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6316155 + * @bug 6316155 6595669 * @summary Test concurrent offer vs. remove * @author Martin Buchholz */ @@ -50,15 +50,18 @@ public class OfferRemoveLoops { private static void testQueue(final BlockingQueue q) throws Throwable { System.out.println(q.getClass()); final int count = 10000; + final long quittingTime = System.nanoTime() + 1L * 1000L * 1000L * 1000L; Thread t1 = new ControlledThread() { protected void realRun() { for (int i = 0, j = 0; i < count; i++) - while (! q.remove(String.valueOf(i))) + while (! q.remove(String.valueOf(i)) + && System.nanoTime() - quittingTime < 0) Thread.yield();}}; Thread t2 = new ControlledThread() { protected void realRun() { for (int i = 0, j = 0; i < count; i++) - while (! q.offer(String.valueOf(i))) + while (! q.offer(String.valueOf(i)) + && System.nanoTime() - quittingTime < 0) Thread.yield();}}; t1.setDaemon(true); t2.setDaemon(true); t1.start(); t2.start(); diff --git a/test/java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java b/test/java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0e782d1d2f699abc685d0f4fd97fc6fdcb3c5ff8 --- /dev/null +++ b/test/java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java @@ -0,0 +1,113 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6602600 + * @run main/othervm -Xmx8m BasicCancelTest + * @summary Check effectiveness of RemoveOnCancelPolicy + */ + +import java.util.concurrent.*; +import java.util.Random; + +/** + * Simple timer cancellation test. Submits tasks to a scheduled executor + * service and immediately cancels them. + */ +public class BasicCancelTest { + + void checkShutdown(final ExecutorService es) { + final Runnable nop = new Runnable() {public void run() {}}; + try { + if (new Random().nextBoolean()) { + check(es.isShutdown()); + if (es instanceof ThreadPoolExecutor) + check(((ThreadPoolExecutor) es).isTerminating() + || es.isTerminated()); + THROWS(RejectedExecutionException.class, + new F(){void f(){es.execute(nop);}}); + } + } catch (Throwable t) { unexpected(t); } + } + + void checkTerminated(final ThreadPoolExecutor tpe) { + try { + checkShutdown(tpe); + check(tpe.getQueue().isEmpty()); + check(tpe.isTerminated()); + check(! tpe.isTerminating()); + equal(tpe.getActiveCount(), 0); + equal(tpe.getPoolSize(), 0); + equal(tpe.getTaskCount(), tpe.getCompletedTaskCount()); + check(tpe.awaitTermination(0, TimeUnit.SECONDS)); + } catch (Throwable t) { unexpected(t); } + } + + void test(String[] args) throws Throwable { + + final ScheduledThreadPoolExecutor pool = + new ScheduledThreadPoolExecutor(1); + + // Needed to avoid OOME + pool.setRemoveOnCancelPolicy(true); + + final long moreThanYouCanChew = Runtime.getRuntime().freeMemory() / 4; + System.out.printf("moreThanYouCanChew=%d%n", moreThanYouCanChew); + + Runnable noopTask = new Runnable() { public void run() {}}; + + for (long i = 0; i < moreThanYouCanChew; i++) + pool.schedule(noopTask, 10, TimeUnit.MINUTES).cancel(true); + + pool.shutdown(); + check(pool.awaitTermination(1L, TimeUnit.DAYS)); + checkTerminated(pool); + equal(pool.getTaskCount(), 0L); + equal(pool.getCompletedTaskCount(), 0L); + } + + //--------------------- Infrastructure --------------------------- + volatile int passed = 0, failed = 0; + void pass() {passed++;} + void fail() {failed++; Thread.dumpStack();} + void fail(String msg) {System.err.println(msg); fail();} + void unexpected(Throwable t) {failed++; t.printStackTrace();} + void check(boolean cond) {if (cond) pass(); else fail();} + void equal(Object x, Object y) { + if (x == null ? y == null : x.equals(y)) pass(); + else fail(x + " not equal to " + y);} + public static void main(String[] args) throws Throwable { + new BasicCancelTest().instanceMain(args);} + void instanceMain(String[] args) throws Throwable { + try {test(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");} + abstract class F {abstract void f() throws Throwable;} + void THROWS(Class k, F... fs) { + for (F f : fs) + try {f.f(); fail("Expected " + k.getName() + " not thrown");} + catch (Throwable t) { + if (k.isAssignableFrom(t.getClass())) pass(); + else unexpected(t);}} +} diff --git a/test/java/util/concurrent/ScheduledThreadPoolExecutor/Stress.java b/test/java/util/concurrent/ScheduledThreadPoolExecutor/Stress.java new file mode 100644 index 0000000000000000000000000000000000000000..d60953712097c5b5e354a3427406d2c2fc1a2f78 --- /dev/null +++ b/test/java/util/concurrent/ScheduledThreadPoolExecutor/Stress.java @@ -0,0 +1,54 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.util.concurrent.*; + +/** + * This is not a regression test, but a stress benchmark test for + * 6602600: Fast removal of cancelled scheduled thread pool tasks + * + * This runs in the same wall clock time, but much reduced cpu time, + * with the changes for 6602600. + */ +public class Stress { + + public static void main(String[] args) throws Throwable { + + final CountDownLatch count = new CountDownLatch(1000); + + final ScheduledThreadPoolExecutor pool = + new ScheduledThreadPoolExecutor(100); + pool.prestartAllCoreThreads(); + + final Runnable incTask = new Runnable() { public void run() { + count.countDown(); + }}; + + pool.scheduleAtFixedRate(incTask, 0, 10, TimeUnit.MILLISECONDS); + + count.await(); + + pool.shutdown(); + pool.awaitTermination(1L, TimeUnit.DAYS); + } +} diff --git a/test/java/util/concurrent/SynchronousQueue/Fairness.java b/test/java/util/concurrent/SynchronousQueue/Fairness.java index 2a8a35a83feca02b40c9c99bb78cec87a1f09515..5adb71d99f7735985d9a27ead064c5fc50c742df 100644 --- a/test/java/util/concurrent/SynchronousQueue/Fairness.java +++ b/test/java/util/concurrent/SynchronousQueue/Fairness.java @@ -23,36 +23,49 @@ /* * @test - * @bug 4992438 - * @compile -source 1.5 Fairness.java - * @run main Fairness + * @bug 4992438 6633113 * @summary Checks that fairness setting is respected. */ import java.util.concurrent.*; +import java.util.concurrent.locks.*; public class Fairness { private static void testFairness(boolean fair, final BlockingQueue q) - throws Exception + throws Throwable { - for (int i = 0; i < 3; i++) { - final Integer I = new Integer(i); - new Thread() { public void run() { - try { q.put(I); } catch (Exception e) {} - }}.start(); - Thread.currentThread().sleep(100); + final ReentrantLock lock = new ReentrantLock(); + final Condition ready = lock.newCondition(); + final int threadCount = 10; + final Throwable[] badness = new Throwable[1]; + lock.lock(); + for (int i = 0; i < threadCount; i++) { + final Integer I = i; + Thread t = new Thread() { public void run() { + try { + lock.lock(); + ready.signal(); + lock.unlock(); + q.put(I); + } catch (Throwable t) { badness[0] = t; }}}; + t.start(); + ready.await(); + // Probably unnecessary, but should be bullet-proof + while (t.getState() == Thread.State.RUNNABLE) + Thread.yield(); } - for (int i = 0; i < 3; i++) { - int j = q.take().intValue(); - System.err.printf("%d%n",j); + for (int i = 0; i < threadCount; i++) { + int j = q.take(); // Non-fair queues are lifo in our implementation - if (fair ? j != i : j != 2-i) - throw new Exception("No fair!"); + if (fair ? j != i : j != threadCount - 1 - i) + throw new Error(String.format("fair=%b i=%d j=%d%n", + fair, i, j)); } + if (badness[0] != null) throw new Error(badness[0]); } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Throwable { testFairness(false, new SynchronousQueue()); testFairness(false, new SynchronousQueue(false)); testFairness(true, new SynchronousQueue(true)); diff --git a/test/java/util/concurrent/locks/ReentrantReadWriteLock/Count.java b/test/java/util/concurrent/locks/ReentrantReadWriteLock/Count.java index 0e7b9e4549dff323b796b27db9bb1a110c5fc7cb..a4d78117341a8a1ddc5bc3530b0aa8cbe2c1f5d8 100644 --- a/test/java/util/concurrent/locks/ReentrantReadWriteLock/Count.java +++ b/test/java/util/concurrent/locks/ReentrantReadWriteLock/Count.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2008 Sun Microsystems, 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 @@ -23,21 +23,89 @@ /* * @test - * @bug 6207928 6328220 6378321 + * @bug 6207928 6328220 6378321 6625723 * @summary Recursive lock invariant sanity checks * @author Martin Buchholz */ +import java.io.*; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.locks.*; // I am the Cownt, and I lahve to cownt. public class Count { - private static void realMain(String[] args) throws Throwable { - final ReentrantLock rl = new ReentrantLock(); - final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock(); + final Random rnd = new Random(); + + void lock(Lock lock) { + try { + switch (rnd.nextInt(4)) { + case 0: lock.lock(); break; + case 1: lock.lockInterruptibly(); break; + case 2: check(lock.tryLock()); break; + case 3: check(lock.tryLock(45, TimeUnit.MINUTES)); break; + } + } catch (Throwable t) { unexpected(t); } + } + + void test(String[] args) throws Throwable { + for (boolean fair : new boolean[] { true, false }) + for (boolean serialClone : new boolean[] { true, false }) { + testReentrantLocks(fair, serialClone); + testConcurrentReadLocks(fair, serialClone); + } + } + + void testConcurrentReadLocks(final boolean fair, + final boolean serialClone) throws Throwable { + final int nThreads = 10; + final CyclicBarrier barrier = new CyclicBarrier(nThreads); + final ExecutorService es = Executors.newFixedThreadPool(nThreads); + final ReentrantReadWriteLock rwl = serialClone ? + serialClone(new ReentrantReadWriteLock(fair)) : + new ReentrantReadWriteLock(fair); + for (int i = 0; i < nThreads; i++) { + es.submit(new Runnable() { public void run() { + try { + int n = 5; + for (int i = 0; i < n; i++) { + barrier.await(); + equal(rwl.getReadHoldCount(), i); + equal(rwl.getWriteHoldCount(), 0); + check(! rwl.isWriteLocked()); + equal(rwl.getReadLockCount(), nThreads * i); + barrier.await(); + lock(rwl.readLock()); + } + for (int i = 0; i < n; i++) { + rwl.readLock().unlock(); + barrier.await(); + equal(rwl.getReadHoldCount(), n-i-1); + equal(rwl.getReadLockCount(), nThreads*(n-i-1)); + equal(rwl.getWriteHoldCount(), 0); + check(! rwl.isWriteLocked()); + barrier.await(); + } + THROWS(IllegalMonitorStateException.class, + new F(){void f(){rwl.readLock().unlock();}}, + new F(){void f(){rwl.writeLock().unlock();}}); + barrier.await(); + } catch (Throwable t) { unexpected(t); }}});} + es.shutdown(); + check(es.awaitTermination(10, TimeUnit.SECONDS)); + } + + void testReentrantLocks(final boolean fair, + final boolean serialClone) throws Throwable { + final ReentrantLock rl = serialClone ? + serialClone(new ReentrantLock(fair)) : + new ReentrantLock(fair); + final ReentrantReadWriteLock rwl = serialClone ? + serialClone(new ReentrantReadWriteLock(fair)) : + new ReentrantReadWriteLock(fair); final int depth = 10; + equal(rl.isFair(), fair); + equal(rwl.isFair(), fair); check(! rl.isLocked()); check(! rwl.isWriteLocked()); check(! rl.isHeldByCurrentThread()); @@ -50,28 +118,11 @@ public class Count { equal(rwl.getReadHoldCount(), i); equal(rwl.getWriteHoldCount(), i); equal(rwl.writeLock().getHoldCount(), i); - switch (i%4) { - case 0: - rl.lock(); - rwl.writeLock().lock(); - rwl.readLock().lock(); - break; - case 1: - rl.lockInterruptibly(); - rwl.writeLock().lockInterruptibly(); - rwl.readLock().lockInterruptibly(); - break; - case 2: - check(rl.tryLock()); - check(rwl.writeLock().tryLock()); - check(rwl.readLock().tryLock()); - break; - case 3: - check(rl.tryLock(454, TimeUnit.MILLISECONDS)); - check(rwl.writeLock().tryLock(454, TimeUnit.NANOSECONDS)); - check(rwl.readLock().tryLock(454, TimeUnit.HOURS)); - break; - } + equal(rl.isLocked(), i > 0); + equal(rwl.isWriteLocked(), i > 0); + lock(rl); + lock(rwl.writeLock()); + lock(rwl.readLock()); } for (int i = depth; i > 0; i--) { @@ -95,20 +146,48 @@ public class Count { rwl.writeLock().unlock(); rl.unlock(); } + THROWS(IllegalMonitorStateException.class, + new F(){void f(){rl.unlock();}}, + new F(){void f(){rwl.readLock().unlock();}}, + new F(){void f(){rwl.writeLock().unlock();}}); } //--------------------- 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 equal(Object x, Object y) { + volatile int passed = 0, failed = 0; + void pass() {passed++;} + void fail() {failed++; Thread.dumpStack();} + void fail(String msg) {System.err.println(msg); fail();} + void unexpected(Throwable t) {failed++; t.printStackTrace();} + void check(boolean cond) {if (cond) pass(); else fail();} + void equal(Object x, Object y) { if (x == null ? y == null : x.equals(y)) pass(); else fail(x + " not equal to " + y);} public static void main(String[] args) throws Throwable { - try {realMain(args);} catch (Throwable t) {unexpected(t);} + new Count().instanceMain(args);} + void instanceMain(String[] args) throws Throwable { + try {test(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");} + abstract class F {abstract void f() throws Throwable;} + void THROWS(Class k, F... fs) { + for (F f : fs) + try {f.f(); fail("Expected " + k.getName() + " not thrown");} + catch (Throwable t) { + if (k.isAssignableFrom(t.getClass())) pass(); + else unexpected(t);}} + + static byte[] serializedForm(Object obj) { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + new ObjectOutputStream(baos).writeObject(obj); + return baos.toByteArray(); + } catch (IOException e) { throw new RuntimeException(e); }} + static Object readObject(byte[] bytes) + throws IOException, ClassNotFoundException { + InputStream is = new ByteArrayInputStream(bytes); + return new ObjectInputStream(is).readObject();} + @SuppressWarnings("unchecked") + static T serialClone(T obj) { + try { return (T) readObject(serializedForm(obj)); } + catch (Exception e) { throw new RuntimeException(e); }} } diff --git a/test/javax/crypto/Cipher/TestGetInstance.java b/test/javax/crypto/Cipher/TestGetInstance.java index 736bac9bb2f94723840c8df690a5b0f13f74cca9..125fd4fc255dae56c50c75910107c79fdbe4ec20 100644 --- a/test/javax/crypto/Cipher/TestGetInstance.java +++ b/test/javax/crypto/Cipher/TestGetInstance.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, 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 @@ -46,9 +46,7 @@ public class TestGetInstance { Cipher c; - c = Cipher.getInstance("des"); - same(p, c.getProvider()); - c = Cipher.getInstance("des/cbc/pkcs5padding"); + c = Cipher.getInstance("PBEWithMD5AndTripleDES"); same(p, c.getProvider()); c = Cipher.getInstance("des", "SunJCE"); diff --git a/test/javax/management/modelmbean/LoggingExceptionTest.java b/test/javax/management/modelmbean/LoggingExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..357a0e050da58d51334e314505244928ec329bd7 --- /dev/null +++ b/test/javax/management/modelmbean/LoggingExceptionTest.java @@ -0,0 +1,81 @@ +/* + * @test + * @bug 6471865 6675768 + * @summary DescriptorSupport constructors throw IAE when traces are enabled; + * RequiredModelMBean.addAttributeChangeNotificationListener throws exception + * when traces enabled and no attributes. + * @author Luis-Miguel Alventosa + * @author Paul Cheeseman + */ + +import java.util.logging.ConsoleHandler; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.management.Notification; +import javax.management.NotificationListener; +import javax.management.modelmbean.DescriptorSupport; +import javax.management.modelmbean.RequiredModelMBean; + +public class LoggingExceptionTest { + private static final String tests[] = new String[] { + "DescriptorSupport()", + "DescriptorSupport(int)", + "DescriptorSupport(String)", + "DescriptorSupport(String...)", + "DescriptorSupport(String[], Object[])", + "DescriptorSupport(DescriptorSupport)", + "RequiredModelMBean.addAttributeChangeNotificationListener", + }; + public static void main(String[] args) { + Handler handler = new ConsoleHandler(); + Logger logger = Logger.getLogger("javax.management.modelmbean"); + logger.addHandler(handler); + logger.setLevel(Level.FINEST); + try { + for (int i = 0; i < tests.length; i++) { + System.out.println(">>> DescriptorSupportLoggingTest: Test Case " + i); + DescriptorSupport ds; + String msg = "Instantiate " + tests[i]; + System.out.println(msg); + switch (i) { + case 0: + ds = new DescriptorSupport(); + break; + case 1: + ds = new DescriptorSupport(10); + break; + case 2: + ds = new DescriptorSupport(new DescriptorSupport().toXMLString()); + break; + case 3: + ds = new DescriptorSupport("name1=value1", "name2=value2"); + break; + case 4: + ds = new DescriptorSupport(new String[] {"name"}, new Object[] {"value"}); + break; + case 5: + ds = new DescriptorSupport(new DescriptorSupport()); + break; + case 6: + RequiredModelMBean mbean = new RequiredModelMBean(); + NotificationListener nl = new NotificationListener() { + public void handleNotification(Notification notification, + Object handback) {} + }; + mbean.addAttributeChangeNotificationListener(nl, null, null); + break; + default: + throw new AssertionError(); + } + System.out.println(msg + " OK"); + } + } catch (Exception e) { + System.out.println("Got unexpected exception = " + e); + String msg = "Test FAILED!"; + System.out.println(msg); + throw new IllegalArgumentException(msg); + } + System.out.println("Test PASSED!"); + } +} diff --git a/test/javax/management/mxbean/JMXServiceURLTest.java b/test/javax/management/mxbean/JMXServiceURLTest.java new file mode 100644 index 0000000000000000000000000000000000000000..dc796037c3536fe537d4c8c1f6879780883b6fab --- /dev/null +++ b/test/javax/management/mxbean/JMXServiceURLTest.java @@ -0,0 +1,103 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test JMXServiceURLTest + * @bug 6607114 6670375 + * @summary Test that JMXServiceURL works correctly in MXBeans + * @author Eamonn McManus + */ + +import java.lang.management.ManagementFactory; +import javax.management.JMX; +import javax.management.MBeanServer; +import javax.management.ObjectName; +import javax.management.openmbean.CompositeData; +import javax.management.openmbean.CompositeType; +import javax.management.openmbean.OpenType; +import javax.management.openmbean.SimpleType; +import javax.management.remote.JMXServiceURL; + +public class JMXServiceURLTest { + public static interface UrlMXBean { + public JMXServiceURL getUrl(); + public void setUrl(JMXServiceURL url); + } + + public static class UrlImpl implements UrlMXBean { + volatile JMXServiceURL url; + + public JMXServiceURL getUrl() { + return url; + } + + public void setUrl(JMXServiceURL url) { + this.url = url; + } + } + + public static void main(String[] args) throws Exception { + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + ObjectName name = new ObjectName("a:b=c"); + UrlImpl urlImpl = new UrlImpl(); + mbs.registerMBean(urlImpl, name); + + JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://host:8000/noddy"); + UrlMXBean proxy = JMX.newMXBeanProxy(mbs, name, UrlMXBean.class); + proxy.setUrl(url); + assertEquals(url, urlImpl.url); + JMXServiceURL url2 = proxy.getUrl(); + assertEquals(url, url2); + + CompositeData cd = (CompositeData) mbs.getAttribute(name, "Url"); + CompositeType ct = cd.getCompositeType(); + // Make sure it looks like what we expect. This will have to be + // changed if ever we add new properties to CompositeType. In that + // case this test should also check interoperability between the + // current version and the new version. + assertEquals(4, ct.keySet().size()); + Object[][] expectedItems = { + {"protocol", SimpleType.STRING, "rmi"}, + {"host", SimpleType.STRING, "host"}, + {"port", SimpleType.INTEGER, 8000}, + {"URLPath", SimpleType.STRING, "/noddy"}, + }; + for (Object[] expectedItem : expectedItems) { + String itemName = (String) expectedItem[0]; + OpenType expectedType = (OpenType) expectedItem[1]; + Object expectedValue = expectedItem[2]; + OpenType actualType = ct.getType(itemName); + assertEquals(expectedType, actualType); + Object actualValue = cd.get(itemName); + assertEquals(expectedValue, actualValue); + } + } + + private static void assertEquals(Object expect, Object actual) + throws Exception { + if (expect.equals(actual)) + System.out.println("Equal: " + expect); + else + throw new Exception("Expected " + expect + ", got " + actual); + } +} diff --git a/test/javax/management/query/QueryDottedAttrTest.java b/test/javax/management/query/QueryDottedAttrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..956496db9b62883aa832c935e578a52ba57a1816 --- /dev/null +++ b/test/javax/management/query/QueryDottedAttrTest.java @@ -0,0 +1,192 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test QueryDottedAttrTest + * @bug 6602310 + * @summary Test that Query.attr can understand a.b etc. + * @author Eamonn McManus + */ + +import java.beans.ConstructorProperties; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.Collections; +import java.util.Set; +import javax.management.AttributeNotFoundException; +import javax.management.MBeanException; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.management.ObjectName; +import javax.management.Query; +import javax.management.QueryExp; +import javax.management.ReflectionException; +import javax.management.StandardMBean; + +public class QueryDottedAttrTest { + public static class Complex { + private final double re, im; + + @ConstructorProperties({"real", "imaginary"}) + public Complex(double re, double im) { + this.re = re; + this.im = im; + } + + public double getRe() { + return re; + } + + public double getIm() { + return im; + } + } + + public static interface Intf { + Complex getComplex(); + int[] getIntArray(); + String[] getStringArray(); + } + + public static class Impl implements Intf { + public Complex getComplex() { + return new Complex(1.0, 1.0); + } + + public int[] getIntArray() { + return new int[] {1, 2, 3}; + } + + public String[] getStringArray() { + return new String[] {"one", "two", "three"}; + } + } + + public static interface TestMBean extends Intf {} + + public static class Test extends Impl implements TestMBean {} + + public static interface TestMXBean extends Intf {} + + public static class TestMX extends Impl implements TestMXBean {} + + public static class AttrWithDot extends StandardMBean { + public AttrWithDot(Object impl, Class intf) { + super(intf.cast(impl), intf, (intf == TestMXBean.class)); + } + + public Object getAttribute(String attribute) + throws AttributeNotFoundException, MBeanException, ReflectionException { + if (attribute.equals("Complex.re")) + return 2.0; + else + return super.getAttribute(attribute); + } + } + + private static final boolean[] booleans = {false, true}; + + private static final QueryExp[] alwaysTrueQueries = { + Query.eq(Query.attr("IntArray.length"), Query.value(3)), + Query.eq(Query.attr("StringArray.length"), Query.value(3)), + Query.eq(Query.attr("Complex.im"), Query.value(1.0)), + }; + + private static final QueryExp[] alwaysFalseQueries = { + Query.eq(Query.attr("IntArray.length"), Query.value("3")), + Query.eq(Query.attr("IntArray.length"), Query.value(2)), + Query.eq(Query.attr("Complex.im"), Query.value(-1.0)), + Query.eq(Query.attr("Complex.xxx"), Query.value(0)), + }; + + private static final QueryExp[] attrWithDotTrueQueries = { + Query.eq(Query.attr("Complex.re"), Query.value(2.0)), + }; + + private static final QueryExp[] attrWithDotFalseQueries = { + Query.eq(Query.attr("Complex.re"), Query.value(1.0)), + }; + + private static String failure; + + public static void main(String[] args) throws Exception { + ObjectName name = new ObjectName("a:b=c"); + for (boolean attrWithDot : booleans) { + for (boolean mx : booleans) { + String what = + (mx ? "MXBean" : "Standard MBean") + + (attrWithDot ? " having attribute with dot in its name" : ""); + System.out.println("Testing " + what); + Class intf = mx ? TestMXBean.class : TestMBean.class; + Object impl = mx ? new TestMX() : new Test(); + if (attrWithDot) + impl = new AttrWithDot(impl, intf); + MBeanServer mbs = MBeanServerFactory.newMBeanServer(); + mbs.registerMBean(impl, name); + boolean ismx = "true".equals( + mbs.getMBeanInfo(name).getDescriptor().getFieldValue("mxbean")); + if (mx != ismx) + fail("MBean should " + (mx ? "" : "not ") + "be MXBean"); + test(mbs, name, alwaysTrueQueries, true); + test(mbs, name, alwaysFalseQueries, false); + test(mbs, name, attrWithDotTrueQueries, attrWithDot); + test(mbs, name, attrWithDotFalseQueries, !attrWithDot); + } + } + if (failure != null) + throw new Exception("TEST FAILED: " + failure); + } + + private static void test( + MBeanServer mbs, ObjectName name, QueryExp[] queries, boolean expect) + throws Exception { + for (QueryExp query : queries) { + // Serialize and deserialize the query to ensure that its + // serialization is correct + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + ObjectOutputStream oout = new ObjectOutputStream(bout); + oout.writeObject(query); + oout.close(); + ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); + ObjectInputStream oin = new ObjectInputStream(bin); + query = (QueryExp) oin.readObject(); + Set names = mbs.queryNames(null, query); + if (names.isEmpty()) { + if (expect) + fail("Query is false but should be true: " + query); + } else if (names.equals(Collections.singleton(name))) { + if (!expect) + fail("Query is true but should be false: " + query); + } else { + fail("Query returned unexpected set: " + names); + } + } + } + + private static void fail(String msg) { + failure = msg; + System.out.println("..." + msg); + } +} diff --git a/test/javax/management/query/QueryExpStringTest.java b/test/javax/management/query/QueryExpStringTest.java index 729a8e7ec95d46115f32f365f03e7d77b9d05fa1..be6a515b8fb1b326e3218aaf260dc6a245432049 100644 --- a/test/javax/management/query/QueryExpStringTest.java +++ b/test/javax/management/query/QueryExpStringTest.java @@ -31,6 +31,10 @@ * @run main QueryExpStringTest */ +// This test is mostly obsolete, since we now have Query.fromString. +// The test includes its own parser, from which Query.fromString was derived. +// The parsers are not identical and the one here is no longer maintained. + import java.util.*; import javax.management.*; @@ -39,6 +43,11 @@ public class QueryExpStringTest { private static final ValueExp attr = Query.attr("attr"), qattr = Query.attr("className", "attr"), + aa = Query.attr("A"), + bb = Query.attr("B"), + cc = Query.attr("C"), + dd = Query.attr("D"), + zero = Query.value(0), classattr = Query.classattr(), simpleString = Query.value("simpleString"), complexString = Query.value("a'b\\'\""), @@ -66,10 +75,14 @@ public class QueryExpStringTest { (StringValueExp) simpleString), initialStar = Query.initialSubString((AttributeValueExp) attr, Query.value("*")), + initialPercent = Query.initialSubString((AttributeValueExp) attr, + Query.value("%")), any = Query.anySubString((AttributeValueExp) attr, (StringValueExp) simpleString), anyStar = Query.anySubString((AttributeValueExp) attr, Query.value("*")), + anyPercent = Query.anySubString((AttributeValueExp) attr, + Query.value("%")), ffinal = Query.finalSubString((AttributeValueExp) attr, (StringValueExp) simpleString), finalMagic = Query.finalSubString((AttributeValueExp) attr, @@ -77,16 +90,20 @@ public class QueryExpStringTest { in = Query.in(intValue, new ValueExp[] {intValue, floatValue}), and = Query.and(gt, lt), or = Query.or(gt, lt), - not = Query.not(gt); + not = Query.not(gt), + aPlusB_PlusC = Query.gt(Query.plus(Query.plus(aa, bb), cc), zero), + aPlus_BPlusC = Query.gt(Query.plus(aa, Query.plus(bb, cc)), zero); // Commented-out tests below require change to implementation private static final Object tests[] = { attr, "attr", - qattr, "className.attr", +// qattr, "className.attr", +// Preceding form now appears as className#attr, an incompatible change +// which we don't mind much because nobody uses the two-arg Query.attr. classattr, "Class", simpleString, "'simpleString'", -// complexString, "'a\\'b\\\\\\'\"'", + complexString, "'a''b\\\''\"'", intValue, "12345678", integerValue, "12345678", longValue, "12345678", @@ -104,16 +121,20 @@ public class QueryExpStringTest { eq, "(12345678) = (2.5)", between, "(12345678) between (2.5) and (2.5)", match, "attr like 'simpleString'", -// initial, "attr like 'simpleString*'", -// initialStar, "attr like '\\\\**'", -// any, "attr like '*simpleString*'", -// anyStar, "attr like '*\\\\**'", -// ffinal, "attr like '*simpleString'", -// finalMagic, "attr like '*\\\\?\\\\*\\\\[\\\\\\\\'", + initial, "attr like 'simpleString%'", + initialStar, "attr like '\\*%'", + initialPercent, "attr like '\\%%'", + any, "attr like '%simpleString%'", + anyStar, "attr like '%\\*%'", + anyPercent, "attr like '%\\%%'", + ffinal, "attr like '%simpleString'", + finalMagic, "attr like '%\\?\\*\\[\\\\'", in, "12345678 in (12345678, 2.5)", and, "((12345678) > (2.5)) and ((12345678) < (2.5))", or, "((12345678) > (2.5)) or ((12345678) < (2.5))", not, "not ((12345678) > (2.5))", + aPlusB_PlusC, "(A + B + C) > (0)", +// aPlus_BPlusC, "(A + (B + C)) > (0)", }; public static void main(String[] args) throws Exception { @@ -185,7 +206,9 @@ public class QueryExpStringTest { throw new Exception("Expected types `attr like string': " + exp + " like " + pat); } - return Query.match((AttributeValueExp) exp, (StringValueExp) pat); + StringValueExp spat = (StringValueExp) pat; + spat = Query.value(translateMatch(spat.getValue())); + return Query.match((AttributeValueExp) exp, spat); } if (skip(ss, " in (")) { @@ -203,6 +226,28 @@ public class QueryExpStringTest { throw new Exception("Expected in or like after expression"); } + private static String translateMatch(String s) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < s.length(); i++) { // logic not correct for wide chars + char c = s.charAt(i); + switch (c) { + case '\\': + sb.append(c).append(s.charAt(++i)); break; + case '%': + sb.append('*'); break; + case '_': + sb.append('?'); break; + case '*': + sb.append("\\*"); break; + case '?': + sb.append("\\?"); break; + default: + sb.append(c); break; + } + } + return sb.toString(); + } + private static QueryExp parseQueryAfterParen(String[] ss) throws Exception { /* This is very ugly. We might have "(q1) and (q2)" here, or @@ -229,7 +274,7 @@ public class QueryExpStringTest { ss[0] = start; ValueExp lhs = parseExp(ss); if (!skip(ss, ") ")) - throw new Exception("Expected `) ' after subexpression"); + throw new Exception("Expected `) ' after subexpression: " + ss[0]); String op = scanWord(ss); if (!skip(ss, " (")) throw new Exception("Expected ` (' after `" + op + "'"); @@ -258,15 +303,16 @@ public class QueryExpStringTest { } private static ValueExp parseExp(String[] ss) throws Exception { - final ValueExp prim = parsePrimary(ss); + ValueExp lhs = parsePrimary(ss); + while (true) { /* Look ahead to see if we have an arithmetic operator. */ String back = ss[0]; if (!skip(ss, " ")) - return prim; + return lhs; if (ss[0].equals("") || "+-*/".indexOf(ss[0].charAt(0)) < 0) { ss[0] = back; - return prim; + return lhs; } final String op = scanWord(ss); @@ -276,15 +322,16 @@ public class QueryExpStringTest { throw new Exception("Unknown arithmetic operator: " + op); if (!skip(ss, " ")) throw new Exception("Expected space after arithmetic operator"); - ValueExp rhs = parseExp(ss); + ValueExp rhs = parsePrimary(ss); switch (op.charAt(0)) { - case '+': return Query.plus(prim, rhs); - case '-': return Query.minus(prim, rhs); - case '*': return Query.times(prim, rhs); - case '/': return Query.div(prim, rhs); + case '+': lhs = Query.plus(lhs, rhs); break; + case '-': lhs = Query.minus(lhs, rhs); break; + case '*': lhs = Query.times(lhs, rhs); break; + case '/': lhs = Query.div(lhs, rhs); break; default: throw new Exception("Can't happen: " + op.charAt(0)); } } + } private static ValueExp parsePrimary(String[] ss) throws Exception { String s = ss[0]; @@ -324,14 +371,19 @@ public class QueryExpStringTest { private static String scanWord(String[] ss) throws Exception { String s = ss[0]; int space = s.indexOf(' '); - if (space < 0) { + int rpar = s.indexOf(')'); + if (space < 0 && rpar < 0) { ss[0] = ""; return s; - } else { - String word = s.substring(0, space); - ss[0] = s.substring(space); - return word; } + int stop; + if (space >= 0 && rpar >= 0) // string has both space and ), stop at first + stop = Math.min(space, rpar); + else // string has only one, stop at it + stop = Math.max(space, rpar); + String word = s.substring(0, stop); + ss[0] = s.substring(stop); + return word; } private static boolean matchWord(String[] ss, String word) @@ -381,13 +433,11 @@ public class QueryExpStringTest { for (i = 0; i < len; i++) { char c = s.charAt(i); if (c == '\'') { - ss[0] = s.substring(i + 1); + ++i; + if (i >= len || s.charAt(i) != '\'') { + ss[0] = s.substring(i); return Query.value(buf.toString()); } - if (c == '\\') { - if (++i == len) - throw new Exception("\\ at end of string"); - c = s.charAt(i); } buf.append(c); } diff --git a/test/javax/management/query/QueryNotifFilterTest.java b/test/javax/management/query/QueryNotifFilterTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b22bf1baa5f924029f728a6fbcad078afc99d6c4 --- /dev/null +++ b/test/javax/management/query/QueryNotifFilterTest.java @@ -0,0 +1,347 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test QueryNotifFilterTest + * @bug 6610917 + * @summary Test the QueryNotificationFilter class + * @author Eamonn McManus + */ + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.management.Attribute; +import javax.management.AttributeChangeNotification; +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanInfo; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.Notification; +import javax.management.NotificationFilter; +import javax.management.ObjectInstance; +import javax.management.ObjectName; +import javax.management.Query; +import javax.management.QueryEval; +import javax.management.QueryExp; +import javax.management.QueryNotificationFilter; + +public class QueryNotifFilterTest { + private static class Case { + final Notification notif; + final QueryExp query; + final boolean expect; + final Class notifClass; + Case(Notification notif, String query, boolean expect) { + this(notif, query, notif.getClass(), expect); + } + Case(Notification notif, String query, + Class notifClass, boolean expect) { + this(notif, Query.fromString(query), notifClass, expect); + } + Case(Notification notif, QueryExp query, boolean expect) { + this(notif, query, notif.getClass(), expect); + } + Case(Notification notif, QueryExp query, + Class notifClass, boolean expect) { + this.notif = notif; + this.query = query; + this.expect = expect; + this.notifClass = notifClass; + } + } + + /* In principle users can create their own implementations of QueryExp + * and use them with QueryNotificationFilter. If they do so, then + * they can call any MBeanServer method. Not all of those methods + * will work with the special MBeanServer we concoct to analyze a + * Notification, but some will, including some that are not called + * by the standard queries. So we check each of those cases too. + */ + private static class ExoticCase { + final Notification trueNotif; + final Notification falseNotif; + final QueryExp query; + ExoticCase(Notification trueNotif, Notification falseNotif, QueryExp query) { + this.trueNotif = trueNotif; + this.falseNotif = falseNotif; + this.query = query; + } + } + + private static abstract class ExoticQuery + extends QueryEval implements QueryExp { + private final String queryString; + ExoticQuery(String queryString) { + this.queryString = queryString; + } + abstract boolean apply(MBeanServer mbs, ObjectName name) throws Exception; + @Override + public boolean apply(ObjectName name) { + try { + return apply(getMBeanServer(), name); + } catch (Exception e) { + e.printStackTrace(System.out); + return false; + } + } + @Override + public String toString() { + return queryString; + } + } + + private static ObjectName makeObjectName(String s) { + try { + return new ObjectName(s); + } catch (MalformedObjectNameException e) { + throw new RuntimeException(e); + } + } + + public static class CustomNotification extends Notification { + public CustomNotification(String type, Object source, long seqNo) { + super(type, source, seqNo); + } + + public String getName() { + return "claude"; + } + + public boolean isInteresting() { + return true; + } + } + + private static final Notification simpleNotif = + new Notification("mytype", "source", 0L); + private static final Notification attrChangeNotif = + new AttributeChangeNotification( + "x", 0L, 0L, "msg", "AttrName", "int", 2, 3); + private static final ObjectName testObjectName = makeObjectName("a:b=c"); + private static final Notification sourcedNotif = + new Notification("mytype", testObjectName, 0L); + private static final Notification customNotif = + new CustomNotification("mytype", testObjectName, 0L); + + private static final Case[] testCases = { + new Case(simpleNotif, "Type = 'mytype'", true), + new Case(simpleNotif, "Type = 'mytype'", + Notification.class, true), + new Case(simpleNotif, "Type = 'mytype'", + AttributeChangeNotification.class, false), + new Case(simpleNotif, "Type != 'mytype'", false), + new Case(simpleNotif, "Type = 'somethingelse'", false), + new Case(attrChangeNotif, "AttributeName = 'AttrName'", true), + new Case(attrChangeNotif, + "instanceof 'javax.management.AttributeChangeNotification'", + true), + new Case(attrChangeNotif, + "instanceof 'javax.management.Notification'", + true), + new Case(attrChangeNotif, + "instanceof 'javax.management.relation.MBeanServerNotification'", + false), + new Case(attrChangeNotif, + "class = 'javax.management.AttributeChangeNotification'", + true), + new Case(attrChangeNotif, + "javax.management.AttributeChangeNotification#AttributeName = 'AttrName'", + true), + new Case(sourcedNotif, + testObjectName, + true), + new Case(sourcedNotif, + makeObjectName("a*:b=*"), + true), + new Case(sourcedNotif, + makeObjectName("a*:c=*"), + false), + new Case(customNotif, "Name = 'claude'", true), + new Case(customNotif, "Name = 'tiddly'", false), + new Case(customNotif, "Interesting = true", true), + new Case(customNotif, "Interesting = false", false), + }; + + private static final ExoticCase[] exoticTestCases = { + new ExoticCase( + simpleNotif, new Notification("notmytype", "source", 0L), + new ExoticQuery("getAttributes") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + List attrs = mbs.getAttributes( + name, new String[] {"Type", "Source"}).asList(); + return (attrs.get(0).equals(new Attribute("Type", "mytype")) && + attrs.get(1).equals(new Attribute("Source", "source"))); + } + }), + new ExoticCase( + new Notification("mytype", "source", 0L) {}, + simpleNotif, + new ExoticQuery("getClassLoaderFor") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + return (mbs.getClassLoaderFor(name) == + this.getClass().getClassLoader()); + } + }), + new ExoticCase( + sourcedNotif, simpleNotif, + new ExoticQuery("getDomains") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + return Arrays.equals(mbs.getDomains(), + new String[] {testObjectName.getDomain()}); + } + }), + new ExoticCase( + simpleNotif, attrChangeNotif, + new ExoticQuery("getMBeanInfo") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + MBeanInfo mbi = mbs.getMBeanInfo(name); + // If we ever add a constructor to Notification then + // we will have to change the 4 below. + if (mbi.getOperations().length > 0 || + mbi.getConstructors().length != 4 || + mbi.getNotifications().length > 0) + return false; + Set expect = new HashSet( + Arrays.asList( + "Class", "Message", "SequenceNumber", "Source", + "TimeStamp", "Type", "UserData")); + Set actual = new HashSet(); + for (MBeanAttributeInfo mbai : mbi.getAttributes()) + actual.add(mbai.getName()); + return actual.equals(expect); + } + }), + new ExoticCase( + simpleNotif, attrChangeNotif, + new ExoticQuery("getObjectInstance") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + ObjectInstance oi = mbs.getObjectInstance(name); + return oi.getClassName().equals(Notification.class.getName()); + } + }), + new ExoticCase( + sourcedNotif, simpleNotif, + new ExoticQuery("queryNames") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + Set names = mbs.queryNames(null, + Query.eq(Query.attr("Type"), Query.value("mytype"))); + return names.equals(Collections.singleton(testObjectName)); + } + }), + new ExoticCase( + sourcedNotif, simpleNotif, + new ExoticQuery("queryMBeans") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + Set insts = mbs.queryMBeans(null, + Query.eq(Query.attr("Type"), Query.value("mytype"))); + if (insts.size() != 1) + return false; + ObjectInstance inst = insts.iterator().next(); + return (inst.getObjectName().equals(testObjectName) && + inst.getClassName().equals(Notification.class.getName())); + } + }), + }; + + private static enum Test { + QUERY_EXP("query"), STRING("string"), STRING_PLUS_CLASS("string with class"); + private final String name; + Test(String name) { + this.name = name; + } + @Override + public String toString() { + return name; + } + } + + public static void main(String[] args) throws Exception { + boolean allok = true; + for (Case testCase : testCases) { + for (Test test : Test.values()) { + QueryNotificationFilter nf; + String queryString; + switch (test) { + case QUERY_EXP: { + QueryExp inst = Query.isInstanceOf( + Query.value(testCase.notifClass.getName())); + QueryExp and = Query.and(inst, testCase.query); + queryString = Query.toString(and); + nf = new QueryNotificationFilter(and); + break; + } + case STRING: { + String s = "instanceof '" + testCase.notifClass.getName() + "'"; + queryString = s + " and " + Query.toString(testCase.query); + nf = new QueryNotificationFilter(queryString); + break; + } + case STRING_PLUS_CLASS: + queryString = null; + nf = new QueryNotificationFilter( + testCase.notifClass, Query.toString(testCase.query)); + break; + default: + throw new AssertionError(); + } + boolean accept = nf.isNotificationEnabled(testCase.notif); + if (queryString != null) { + queryString = Query.toString(Query.fromString(queryString)); + if (!queryString.equals(Query.toString(nf.getQuery()))) { + System.out.println("FAIL: query string mismatch: expected " + + "\"" + queryString + "\", got \"" + + Query.toString(nf.getQuery())); + allok = false; + } + } + boolean ok = (accept == testCase.expect); + System.out.println((ok ? "pass" : "FAIL") + ": " + + testCase.query + " (" + test + ")"); + allok &= ok; + } + } + for (ExoticCase testCase : exoticTestCases) { + NotificationFilter nf = new QueryNotificationFilter(testCase.query); + for (boolean expect : new boolean[] {true, false}) { + Notification n = expect ? testCase.trueNotif : testCase.falseNotif; + boolean accept = nf.isNotificationEnabled(n); + boolean ok = (accept == expect); + System.out.println((ok ? "pass" : "FAIL") + ": " + + testCase.query + ": " + n); + allok &= ok; + } + } + if (!allok) + throw new Exception("TEST FAILED"); + } +} diff --git a/test/javax/management/query/QueryParseTest.java b/test/javax/management/query/QueryParseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a6004b5c150b0967643d596c16244db253a65778 --- /dev/null +++ b/test/javax/management/query/QueryParseTest.java @@ -0,0 +1,778 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test QueryParseTest + * @bug 6602310 6604768 + * @summary Test Query.fromString and Query.toString. + * @author Eamonn McManus + */ + +import java.util.Collections; +import java.util.Set; +import javax.management.Attribute; +import javax.management.AttributeList; +import javax.management.AttributeNotFoundException; +import javax.management.DynamicMBean; +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanInfo; +import javax.management.MBeanServer; +import javax.management.MBeanServerDelegate; +import javax.management.MBeanServerFactory; +import javax.management.ObjectName; +import javax.management.Query; +import javax.management.QueryExp; + +public class QueryParseTest { + // In this table, each string constant corresponds to a test case. + // The objects following the string up to the next string are MBeans. + // Each MBean must implement ExpectedValue to return true or false + // according as it should return that value for the query parsed + // from the given string. The test will parse the string into a + // a query and verify that the MBeans return the expected value + // for that query. Then it will convert the query back into a string + // and into a second query, and check that the MBeans return the + // expected value for that query too. The reason we need to do all + // this is that the spec talks about "equivalent queries", and gives + // the implementation wide scope to rearrange queries. So we cannot + // just compare string values. + // + // We could also write an implementation-dependent test that knew what + // the strings look like, and that would have to be changed if the + // implementation changed. But the approach here is cleaner. + // + // To simplify the creation of MBeans, most use the expectTrue or + // expectFalse methods. The parameters of these methods end up in + // attributes called "A", "B", "C", etc. + private static final Object[] queryTests = { + // RELATIONS + + "A < B", + expectTrue(1, 2), expectTrue(1.0, 2.0), expectTrue("one", "two"), + expectTrue(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), + expectFalse(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY), + expectFalse(1, 1), expectFalse(1.0, 1.0), expectFalse("one", "one"), + expectFalse(2, 1), expectFalse(2.0, 1.0), expectFalse("two", "one"), + expectFalse(Double.NaN, Double.NaN), + + "One = two", + expectTrueOneTwo(1, 1), expectTrueOneTwo(1.0, 1.0), + expectFalseOneTwo(1, 2), expectFalseOneTwo(2, 1), + + "A <= B", + expectTrue(1, 1), expectTrue(1, 2), expectTrue("one", "one"), + expectTrue("one", "two"), + expectFalse(2, 1), expectFalse("two", "one"), + expectFalse(Double.NaN, Double.NaN), + + "A >= B", + expectTrue(1, 1), expectTrue(2, 1), expectTrue("two", "one"), + expectFalse(1, 2), expectFalse("one", "two"), + + "A > B", + expectTrue(2, 1), expectTrue("two", "one"), + expectFalse(2, 2), expectFalse(1, 2), expectFalse(1.0, 2.0), + expectFalse("one", "two"), + + "A <> B", + expectTrue(1, 2), expectTrue("foo", "bar"), + expectFalse(1, 1), expectFalse("foo", "foo"), + + "A != B", + expectTrue(1, 2), expectTrue("foo", "bar"), + expectFalse(1, 1), expectFalse("foo", "foo"), + + // PARENTHESES + + "(((A))) = (B)", + expectTrue(1, 1), expectFalse(1, 2), + + "(A = B)", + expectTrue(1, 1), expectFalse(1, 2), + + "(((A = (B))))", + expectTrue(1, 1), expectFalse(1, 2), + + // INTEGER LITERALS + + "A = 1234567890123456789", + expectTrue(1234567890123456789L), expectFalse(123456789L), + + "A = +1234567890123456789", + expectTrue(1234567890123456789L), expectFalse(123456789L), + + "A = -1234567890123456789", + expectTrue(-1234567890123456789L), expectFalse(-123456789L), + + + "A = + 1234567890123456789", + expectTrue(1234567890123456789L), expectFalse(123456789L), + + "A = - 1234567890123456789", + expectTrue(-1234567890123456789L), expectFalse(-123456789L), + + "A = " + Long.MAX_VALUE, + expectTrue(Long.MAX_VALUE), expectFalse(Long.MIN_VALUE), + + "A = " + Long.MIN_VALUE, + expectTrue(Long.MIN_VALUE), expectFalse(Long.MAX_VALUE), + + // DOUBLE LITERALS + + "A = 0.0", + expectTrue(0.0), expectFalse(1.0), + + "A = 0.0e23", + expectTrue(0.0), expectFalse(1.0), + + "A = 1.2e3", + expectTrue(1.2e3), expectFalse(1.2), + + "A = +1.2", + expectTrue(1.2), expectFalse(-1.2), + + "A = 1.2e+3", + expectTrue(1.2e3), expectFalse(1.2), + + "A = 1.2e-3", + expectTrue(1.2e-3), expectFalse(1.2), + + "A = 1.2E3", + expectTrue(1.2e3), expectFalse(1.2), + + "A = -1.2e3", + expectTrue(-1.2e3), expectFalse(1.2), + + "A = " + Double.MAX_VALUE, + expectTrue(Double.MAX_VALUE), expectFalse(Double.MIN_VALUE), + + "A = " + -Double.MAX_VALUE, + expectTrue(-Double.MAX_VALUE), expectFalse(-Double.MIN_VALUE), + + "A = " + Double.MIN_VALUE, + expectTrue(Double.MIN_VALUE), expectFalse(Double.MAX_VALUE), + + "A = " + -Double.MIN_VALUE, + expectTrue(-Double.MIN_VALUE), expectFalse(-Double.MAX_VALUE), + + Query.toString( // A = Infinity -> A = (1.0/0.0) + Query.eq(Query.attr("A"), Query.value(Double.POSITIVE_INFINITY))), + expectTrue(Double.POSITIVE_INFINITY), + expectFalse(0.0), expectFalse(Double.NEGATIVE_INFINITY), + + Query.toString( // A = -Infinity -> A = (-1.0/0.0) + Query.eq(Query.attr("A"), Query.value(Double.NEGATIVE_INFINITY))), + expectTrue(Double.NEGATIVE_INFINITY), + expectFalse(0.0), expectFalse(Double.POSITIVE_INFINITY), + + Query.toString( // A < NaN -> A < (0.0/0.0) + Query.lt(Query.attr("A"), Query.value(Double.NaN))), + expectFalse(0.0), expectFalse(Double.NEGATIVE_INFINITY), + expectFalse(Double.POSITIVE_INFINITY), expectFalse(Double.NaN), + + Query.toString( // A >= NaN -> A < (0.0/0.0) + Query.geq(Query.attr("A"), Query.value(Double.NaN))), + expectFalse(0.0), expectFalse(Double.NEGATIVE_INFINITY), + expectFalse(Double.POSITIVE_INFINITY), expectFalse(Double.NaN), + + // STRING LITERALS + + "A = 'blim'", + expectTrue("blim"), expectFalse("blam"), + + "A = 'can''t'", + expectTrue("can't"), expectFalse("cant"), expectFalse("can''t"), + + "A = '''blim'''", + expectTrue("'blim'"), expectFalse("'blam'"), + + "A = ''", + expectTrue(""), expectFalse((Object) null), + + // BOOLEAN LITERALS + + "A = true", + expectTrue(true), expectFalse(false), expectFalse((Object) null), + + "A = TRUE", + expectTrue(true), expectFalse(false), + + "A = TrUe", + expectTrue(true), expectFalse(false), + + "A = false", + expectTrue(false), expectFalse(true), + + "A = fAlSe", + expectTrue(false), expectFalse(true), + + "A = \"true\"", // An attribute called "true" + expectFalse(true), expectFalse(false), expectFalse("\"true\""), + newTester(new String[] {"A", "true"}, new Object[] {2.2, 2.2}, true), + newTester(new String[] {"A", "true"}, new Object[] {2.2, 2.3}, false), + + "A = \"False\"", + expectFalse(true), expectFalse(false), expectFalse("\"False\""), + newTester(new String[] {"A", "False"}, new Object[] {2.2, 2.2}, true), + newTester(new String[] {"A", "False"}, new Object[] {2.2, 2.3}, false), + + // ARITHMETIC + + "A + B = 10", + expectTrue(4, 6), expectFalse(3, 8), + + "A + B = 'blim'", + expectTrue("bl", "im"), expectFalse("bl", "am"), + + "A - B = 10", + expectTrue(16, 6), expectFalse(16, 3), + + "A * B = 10", + expectTrue(2, 5), expectFalse(3, 3), + + "A / B = 10", + expectTrue(70, 7), expectTrue(70.0, 7), expectFalse(70.01, 7), + + "A + B + C = 10", + expectTrue(2, 3, 5), expectFalse(2, 4, 8), + + "A+B+C=10", + expectTrue(2, 3, 5), expectFalse(2, 4, 8), + + "A + B + C + D = 10", + expectTrue(1, 2, 3, 4), expectFalse(2, 3, 4, 5), + + "A + (B + C) = 10", + expectTrue(2, 3, 5), expectFalse(2, 4, 8), + + // It is not correct to rearrange A + (B + C) as A + B + C + // (which means (A + B) + C), because of overflow. + // In particular Query.toString must not do this. + "A + (B + C) = " + Double.MAX_VALUE, // ensure no false associativity + expectTrue(Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE), + expectFalse(-Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE), + + "A * (B * C) < " + Double.MAX_VALUE, // same test for multiplication + expectTrue(Double.MAX_VALUE, Double.MAX_VALUE, Double.MIN_VALUE), + expectFalse(Double.MIN_VALUE, Double.MAX_VALUE, Double.MAX_VALUE), + + "A * B + C = 10", + expectTrue(3, 3, 1), expectTrue(2, 4, 2), expectFalse(1, 2, 3), + + "A*B+C=10", + expectTrue(3, 3, 1), expectTrue(2, 4, 2), expectFalse(1, 2, 3), + + "(A * B) + C = 10", + expectTrue(3, 3, 1), expectTrue(2, 4, 2), expectFalse(1, 2, 3), + + "A + B * C = 10", + expectTrue(1, 3, 3), expectTrue(2, 2, 4), expectFalse(1, 2, 3), + + "A - B * C = 10", + expectTrue(16, 2, 3), expectFalse(15, 2, 2), + + "A + B / C = 10", + expectTrue(5, 15, 3), expectFalse(5, 16, 4), + + "A - B / C = 10", + expectTrue(16, 12, 2), expectFalse(15, 10, 3), + + "A * (B + C) = 10", + expectTrue(2, 2, 3), expectFalse(1, 2, 3), + + "A / (B + C) = 10", + expectTrue(70, 4, 3), expectFalse(70, 3, 5), + + "A * (B - C) = 10", + expectTrue(2, 8, 3), expectFalse(2, 3, 8), + + "A / (B - C) = 10", + expectTrue(70, 11, 4), expectFalse(70, 4, 11), + + "A / B / C = 10", + expectTrue(140, 2, 7), expectFalse(100, 5, 5), + + "A / (B / C) = 10", + expectTrue(70, 14, 2), expectFalse(70, 10, 7), + + // LOGIC + + "A = B or C = D", + expectTrue(1, 1, 2, 3), expectTrue(1, 2, 3, 3), expectTrue(1, 1, 2, 2), + expectFalse(1, 2, 3, 4), expectFalse("!", "!!", "?", "??"), + + "A = B and C = D", + expectTrue(1, 1, 2, 2), + expectFalse(1, 1, 2, 3), expectFalse(1, 2, 3, 3), + + "A = 1 and B = 2 and C = 3", + expectTrue(1, 2, 3), expectFalse(1, 2, 4), + + "A = 1 or B = 2 or C = 3", + expectTrue(1, 2, 3), expectTrue(1, 0, 0), expectTrue(0, 0, 3), + expectFalse(2, 3, 4), + + // grouped as (a and b) or (c and d) + "A = 1 AND B = 2 OR C = 3 AND D = 4", + expectTrue(1, 2, 3, 4), expectTrue(1, 2, 1, 2), expectTrue(3, 4, 3, 4), + expectFalse(3, 4, 1, 2), expectFalse(1, 1, 1, 1), + + "(A = 1 AND B = 2) OR (C = 3 AND D = 4)", + expectTrue(1, 2, 3, 4), expectTrue(1, 2, 1, 2), expectTrue(3, 4, 3, 4), + expectFalse(3, 4, 1, 2), expectFalse(1, 1, 1, 1), + + "(A = 1 or B = 2) AND (C = 3 or C = 4)", + expectTrue(1, 1, 3, 3), expectTrue(2, 2, 4, 4), expectTrue(1, 2, 3, 4), + expectFalse(1, 2, 1, 2), expectFalse(3, 4, 3, 4), + + // LIKE + + "A like 'b%m'", + expectTrue("blim"), expectTrue("bm"), + expectFalse(""), expectFalse("blimmo"), expectFalse("mmm"), + + "A not like 'b%m'", + expectFalse("blim"), expectFalse("bm"), + expectTrue(""), expectTrue("blimmo"), expectTrue("mmm"), + + "A like 'b_m'", + expectTrue("bim"), expectFalse("blim"), + + "A like '%can''t%'", + expectTrue("can't"), + expectTrue("I'm sorry Dave, I'm afraid I can't do that"), + expectFalse("cant"), expectFalse("can''t"), + + "A like '\\%%\\%'", + expectTrue("%blim%"), expectTrue("%%"), + expectFalse("blim"), expectFalse("%asdf"), expectFalse("asdf%"), + + "A LIKE '*%?_'", + expectTrue("*blim?!"), expectTrue("*?_"), + expectFalse("blim"), expectFalse("blim?"), + expectFalse("?*"), expectFalse("??"), expectFalse(""), expectFalse("?"), + + Query.toString( + Query.initialSubString(Query.attr("A"), Query.value("*?%_"))), + expectTrue("*?%_tiddly"), expectTrue("*?%_"), + expectFalse("?%_tiddly"), expectFalse("*!%_"), expectFalse("*??_"), + expectFalse("*?%!"), expectFalse("*?%!tiddly"), + + Query.toString( + Query.finalSubString(Query.attr("A"), Query.value("*?%_"))), + expectTrue("tiddly*?%_"), expectTrue("*?%_"), + expectFalse("tiddly?%_"), expectFalse("*!%_"), expectFalse("*??_"), + expectFalse("*?%!"), expectFalse("tiddly*?%!"), + + // BETWEEN + + "A between B and C", + expectTrue(1, 1, 2), expectTrue(2, 1, 2), expectTrue(2, 1, 3), + expectFalse(3, 1, 2), expectFalse(0, 1, 2), expectFalse(2, 3, 1), + expectTrue(1.0, 0.0, 2.0), expectFalse(2.0, 0.0, 1.0), + expectTrue(0.0, 0.0, 0.0), expectTrue(1.0, 0.0, 1.0), + expectTrue(1.0, 0.0, Double.POSITIVE_INFINITY), + expectFalse(1.0, Double.NEGATIVE_INFINITY, 0.0), + expectFalse(false, false, true), expectFalse(true, false, true), + expectTrue("jim", "fred", "sheila"), expectFalse("fred", "jim", "sheila"), + + "A between B and C and 1+2=3", + expectTrue(2, 1, 3), expectFalse(2, 3, 1), + + "A not between B and C", + expectTrue(1, 2, 3), expectFalse(2, 1, 3), + + // IN + + "A in (1, 2, 3)", + expectTrue(1), expectTrue(2), expectTrue(3), + expectFalse(0), expectFalse(4), + + "A in (1)", + expectTrue(1), expectFalse(0), + + "A in (1.2, 3.4)", + expectTrue(1.2), expectTrue(3.4), expectFalse(0.0), + + "A in ('foo', 'bar')", + expectTrue("foo"), expectTrue("bar"), expectFalse("baz"), + + "A in ('foo', 'bar') and 'bl'+'im'='blim'", + expectTrue("foo"), expectTrue("bar"), expectFalse("baz"), + + "A in (B, C, D)", // requires fix for CR 6604768 + expectTrue(1, 1, 2, 3), expectFalse(1, 2, 3, 4), + + "A not in (B, C, D)", + expectTrue(1, 2, 3, 4), expectFalse(1, 1, 2, 3), + + // QUOTING + + "\"LIKE\" = 1 and \"NOT\" = 2 and \"INSTANCEOF\" = 3 and " + + "\"TRUE\" = 4 and \"FALSE\" = 5", + newTester( + new String[] {"LIKE", "NOT", "INSTANCEOF", "TRUE", "FALSE"}, + new Object[] {1, 2, 3, 4, 5}, + true), + newTester( + new String[] {"LIKE", "NOT", "INSTANCEOF", "TRUE", "FALSE"}, + new Object[] {5, 4, 3, 2, 1}, + false), + + "\"\"\"woo\"\"\" = 5", + newTester(new String[] {"\"woo\""}, new Object[] {5}, true), + newTester(new String[] {"\"woo\""}, new Object[] {4}, false), + expectFalse(), + + // INSTANCEOF + + "instanceof '" + Tester.class.getName() + "'", + expectTrue(), + + "instanceof '" + String.class.getName() + "'", + expectFalse(), + + // LIKE OBJECTNAME + + // The test MBean is registered as a:b=c + "like 'a:b=c'", expectTrue(), + "like 'a:*'", expectTrue(), + "like '*:b=c'", expectTrue(), + "like 'a:b=*'", expectTrue(), + "like 'a:b=?'", expectTrue(), + "like 'd:b=c'", expectFalse(), + "like 'a:b=??*'", expectFalse(), + "like 'a:b=\"can''t\"'", expectFalse(), + + // QUALIFIED ATTRIBUTE + + Tester.class.getName() + "#A = 5", + expectTrue(5), expectFalse(4), + + Tester.class.getName() + " # A = 5", + expectTrue(5), expectFalse(4), + + Tester.class.getSuperclass().getName() + "#A = 5", + expectFalse(5), + + DynamicMBean.class.getName() + "#A = 5", + expectFalse(5), + + Tester.class.getName() + "#A = 5", + new Tester(new String[] {"A"}, new Object[] {5}, false) {}, + // note the little {} at the end which means this is a subclass + // and therefore QualifiedAttributeValue should return false. + + MBeanServerDelegate.class.getName() + "#SpecificationName LIKE '%'", + new Wrapped(new MBeanServerDelegate(), true), + new Tester(new String[] {"SpecificationName"}, new Object[] {"JMX"}, false), + + // DOTTED ATTRIBUTE + + "A.canonicalName = '" + + MBeanServerDelegate.DELEGATE_NAME.getCanonicalName() + "'", + expectTrue(MBeanServerDelegate.DELEGATE_NAME), + expectFalse(ObjectName.WILDCARD), + + "A.class.name = 'java.lang.String'", + expectTrue("blim"), expectFalse(95), expectFalse((Object) null), + + "A.canonicalName like 'JMImpl%:%'", + expectTrue(MBeanServerDelegate.DELEGATE_NAME), + expectFalse(ObjectName.WILDCARD), + + "A.true = 'blim'", + new Tester(new String[] {"A.true"}, new Object[] {"blim"}, true), + new Tester(new String[] {"A.true"}, new Object[] {"blam"}, false), + + "\"A.true\" = 'blim'", + new Tester(new String[] {"A.true"}, new Object[] {"blim"}, true), + new Tester(new String[] {"A.true"}, new Object[] {"blam"}, false), + + MBeanServerDelegate.class.getName() + + "#SpecificationName.class.name = 'java.lang.String'", + new Wrapped(new MBeanServerDelegate(), true), + new Tester(new String[] {"SpecificationName"}, new Object[] {"JMX"}, false), + + MBeanServerDelegate.class.getName() + + " # SpecificationName.class.name = 'java.lang.String'", + new Wrapped(new MBeanServerDelegate(), true), + new Tester(new String[] {"SpecificationName"}, new Object[] {"JMX"}, false), + + // CLASS + + "class = '" + Tester.class.getName() + "'", + expectTrue(), + new Wrapped(new MBeanServerDelegate(), false), + + "Class = '" + Tester.class.getName() + "'", + expectTrue(), + new Wrapped(new MBeanServerDelegate(), false), + }; + + private static final String[] incorrectQueries = { + "", " ", "25", "()", "(a = b", "a = b)", "a.3 = 5", + "a = " + Long.MAX_VALUE + "0", + "a = " + Double.MAX_VALUE + "0", + "a = " + Double.MIN_VALUE + "0", + "a = 12a5", "a = 12e5e5", "a = 12.23.34", + "a = 'can't'", "a = 'unterminated", "a = 'asdf''", + "a = \"oops", "a = \"oops\"\"", + "a like 5", "true or false", + "a ! b", "? = 3", "a = @", "a##b", + "a between b , c", "a between and c", + "a in b, c", "a in 23", "a in (2, 3", "a in (2, 3x)", + "a like \"foo\"", "a like b", "a like 23", + "like \"foo\"", "like b", "like 23", "like 'a:b'", + "5 like 'a'", "'a' like '%'", + "a not= b", "a not = b", "a not b", "a not b c", + "a = +b", "a = +'b'", "a = +true", "a = -b", "a = -'b'", + "a#5 = b", "a#'b' = c", + "a instanceof b", "a instanceof 17", "a instanceof", + "a like 'oops\\'", "a like '[oops'", + + // Check that -Long.MIN_VALUE is an illegal constant. This is one more + // than Long.MAX_VALUE and, like the Java language, we only allow it + // if it is the operand of unary minus. + "a = " + Long.toString(Long.MIN_VALUE).substring(1), + }; + + public static void main(String[] args) throws Exception { + int nexti; + String failed = null; + + System.out.println("TESTING CORRECT QUERY STRINGS"); + for (int i = 0; i < queryTests.length; i = nexti) { + for (nexti = i + 1; nexti < queryTests.length; nexti++) { + if (queryTests[nexti] instanceof String) + break; + } + if (!(queryTests[i] instanceof String)) + throw new Exception("Test bug: should be string: " + queryTests[i]); + + String qs = (String) queryTests[i]; + System.out.println("Test: " + qs); + + QueryExp qe = Query.fromString(qs); + String qes = Query.toString(qe); + System.out.println("...parses to: " + qes); + final QueryExp[] queries; + if (qes.equals(qs)) + queries = new QueryExp[] {qe}; + else { + QueryExp qe2 = Query.fromString(qes); + String qes2 = Query.toString(qe2); + System.out.println("...which parses to: " + qes2); + if (qes.equals(qes2)) + queries = new QueryExp[] {qe}; + else + queries = new QueryExp[] {qe, qe2}; + } + + for (int j = i + 1; j < nexti; j++) { + Object mbean; + if (queryTests[j] instanceof Wrapped) + mbean = ((Wrapped) queryTests[j]).mbean(); + else + mbean = queryTests[j]; + boolean expect = ((ExpectedValue) queryTests[j]).expectedValue(); + for (QueryExp qet : queries) { + boolean actual = runQuery(qet, mbean); + boolean ok = (expect == actual); + System.out.println( + "..." + mbean + " -> " + actual + + (ok ? " (OK)" : " ####INCORRECT####")); + if (!ok) + failed = qs; + } + } + } + + System.out.println(); + System.out.println("TESTING INCORRECT QUERY STRINGS"); + for (String s : incorrectQueries) { + try { + QueryExp qe = Query.fromString(s); + System.out.println("###DID NOT GET ERROR:### \"" + s + "\""); + failed = s; + } catch (IllegalArgumentException e) { + String es = (e.getClass() == IllegalArgumentException.class) ? + e.getMessage() : e.toString(); + System.out.println("OK: exception for \"" + s + "\": " + es); + } + } + + if (failed == null) + System.out.println("TEST PASSED"); + else + throw new Exception("TEST FAILED: Last failure: " + failed); + } + + private static boolean runQuery(QueryExp qe, Object mbean) + throws Exception { + MBeanServer mbs = MBeanServerFactory.newMBeanServer(); + ObjectName name = new ObjectName("a:b=c"); + mbs.registerMBean(mbean, name); + Set names = mbs.queryNames(new ObjectName("a:*"), qe); + if (names.isEmpty()) + return false; + if (names.equals(Collections.singleton(name))) + return true; + throw new Exception("Unexpected query result set: " + names); + } + + private static interface ExpectedValue { + public boolean expectedValue(); + } + + private static class Wrapped implements ExpectedValue { + private final Object mbean; + private final boolean expect; + + Wrapped(Object mbean, boolean expect) { + this.mbean = mbean; + this.expect = expect; + } + + Object mbean() { + return mbean; + } + + public boolean expectedValue() { + return expect; + } + } + + private static class Tester implements DynamicMBean, ExpectedValue { + private final AttributeList attributes; + private final boolean expectedValue; + + Tester(AttributeList attributes, boolean expectedValue) { + this.attributes = attributes; + this.expectedValue = expectedValue; + } + + Tester(String[] names, Object[] values, boolean expectedValue) { + this(makeAttributeList(names, values), expectedValue); + } + + private static AttributeList makeAttributeList( + String[] names, Object[] values) { + if (names.length != values.length) + throw new Error("Test bug: names and values different length"); + AttributeList list = new AttributeList(); + for (int i = 0; i < names.length; i++) + list.add(new Attribute(names[i], values[i])); + return list; + } + + public Object getAttribute(String attribute) + throws AttributeNotFoundException { + for (Attribute a : attributes.asList()) { + if (a.getName().equals(attribute)) + return a.getValue(); + } + throw new AttributeNotFoundException(attribute); + } + + public void setAttribute(Attribute attribute) { + throw new UnsupportedOperationException(); + } + + public AttributeList getAttributes(String[] attributes) { + AttributeList list = new AttributeList(); + for (String attribute : attributes) { + try { + list.add(new Attribute(attribute, getAttribute(attribute))); + } catch (AttributeNotFoundException e) { + // OK: ignore, per semantics of getAttributes + } + } + return list; + } + + public AttributeList setAttributes(AttributeList attributes) { + throw new UnsupportedOperationException(); + } + + public Object invoke(String actionName, Object[] params, String[] signature) { + throw new UnsupportedOperationException(); + } + + public MBeanInfo getMBeanInfo() { + MBeanAttributeInfo mbais[] = new MBeanAttributeInfo[attributes.size()]; + for (int i = 0; i < mbais.length; i++) { + Attribute attr = attributes.asList().get(i); + String name = attr.getName(); + Object value = attr.getValue(); + String type = + ((value == null) ? new Object() : value).getClass().getName(); + mbais[i] = new MBeanAttributeInfo( + name, type, name, true, false, false); + } + return new MBeanInfo( + getClass().getName(), "descr", mbais, null, null, null); + } + + public boolean expectedValue() { + return expectedValue; + } + + @Override + public String toString() { + return attributes.toString(); + } + } + + // Method rather than field, to avoid circular init dependencies + private static String[] abcd() { + return new String[] {"A", "B", "C", "D"}; + } + + private static String[] onetwo() { + return new String[] {"One", "two"}; + } + + private static Object expectTrue(Object... attrs) { + return newTester(abcd(), attrs, true); + } + + private static Object expectFalse(Object... attrs) { + return newTester(abcd(), attrs, false); + } + + private static Object expectTrueOneTwo(Object... attrs) { + return newTester(onetwo(), attrs, true); + } + + private static Object expectFalseOneTwo(Object... attrs) { + return newTester(onetwo(), attrs, false); + } + + private static Object newTester(String[] names, Object[] attrs, boolean expect) { + AttributeList list = new AttributeList(); + for (int i = 0; i < attrs.length; i++) + list.add(new Attribute(names[i], attrs[i])); + return new Tester(list, expect); + } +} diff --git a/test/javax/security/auth/x500/X500Principal/RFC4514.java b/test/javax/security/auth/x500/X500Principal/RFC4514.java new file mode 100644 index 0000000000000000000000000000000000000000..6169314abf047d14fa24dcc709ed1359b15a6e4a --- /dev/null +++ b/test/javax/security/auth/x500/X500Principal/RFC4514.java @@ -0,0 +1,92 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import javax.security.auth.x500.X500Principal; + +/** + * @test + * @bug 6611991 + * @summary Add support for parsing RFC 4514 DNs to X500Principal + * + * Ensure RFC 4514 Distinguished Name Strings can be parsed by X500Principal. + * RFC 4514 obsoleted RFC 2253 so we should make sure we can parse DNs of + * that form that contain subtle differences or clarifications in the grammar. + */ +public class RFC4514 { + + private int failed = 0; + + public static void main(String[] args) throws Exception { + new RFC4514().test(); + } + + private void test() throws Exception { + + /** + * RFC 4514 allows space to be escaped as '\ '. + */ + parse("CN=\\ Space\\ ,C=US"); + parse("CN=Sp\\ ace,C=US"); + /** + * RFC 4514 does not require escaping of '=' characters. + */ + parse("CN=Eq=uals,C=US"); + /** + * RFC 4514 requires the null character to be escaped. + */ + parse("CN=\\00,C=US"); + /** + * RFC 4514 does not require escaping of non-leading '#' characters. + */ + parse("CN=Num#ber,C=US"); + /** + * XMLDSig (http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/) + * allows implementations to escape trailing whitespace as '\20'. + */ + parse("CN=Trailing \\20,C=US"); + /** + * XMLDSig allows implementations to escape ASCII control characters + * (Unicode range \x00 - \x1f) by replacing them with "\" followed by + * a two digit hex number showing its Unicode number. + */ + parse("CN=Con\\09trol,C=US"); + + if (failed != 0) { + throw new Exception("Some RFC4514 tests FAILED"); + } + } + + public void parse(String dnString) throws Exception { + + System.out.println("Parsing " + dnString); + X500Principal dn = new X500Principal(dnString); + String dnString2 = dn.getName(); + X500Principal dn2 = new X500Principal(dnString2); + if (dn.equals(dn2)) { + System.out.println("PASSED"); + } else { + System.out.println("FAILED"); + failed++; + } + } +} diff --git a/test/sun/management/HotspotClassLoadingMBean/GetClassInitializationTime.java b/test/sun/management/HotspotClassLoadingMBean/GetClassInitializationTime.java index 8a41e1e196e10de3ff88ad6ffb58fae5dcdb7922..b269ea9dd3a21b666b8d9909090ea96cd79d9733 100644 --- a/test/sun/management/HotspotClassLoadingMBean/GetClassInitializationTime.java +++ b/test/sun/management/HotspotClassLoadingMBean/GetClassInitializationTime.java @@ -37,7 +37,7 @@ import sun.management.*; public class GetClassInitializationTime { private static HotspotClassLoadingMBean mbean = - (HotspotClassLoadingMBean)ManagementFactory.getHotspotClassLoadingMBean(); + (HotspotClassLoadingMBean)ManagementFactoryHelper.getHotspotClassLoadingMBean(); // Careful with these values. private static final long MIN_TIME_FOR_PASS = 1; diff --git a/test/sun/management/HotspotClassLoadingMBean/GetClassLoadingTime.java b/test/sun/management/HotspotClassLoadingMBean/GetClassLoadingTime.java index 520057e368c242b6724a3c085ccf7741f6e767b2..7942a10ee429f5166785aaed196cdf2326d12698 100644 --- a/test/sun/management/HotspotClassLoadingMBean/GetClassLoadingTime.java +++ b/test/sun/management/HotspotClassLoadingMBean/GetClassLoadingTime.java @@ -39,7 +39,7 @@ import sun.management.*; public class GetClassLoadingTime { private static HotspotClassLoadingMBean mbean = - (HotspotClassLoadingMBean)ManagementFactory.getHotspotClassLoadingMBean(); + (HotspotClassLoadingMBean)ManagementFactoryHelper.getHotspotClassLoadingMBean(); // Careful with these values. private static final long MIN_TIME_FOR_PASS = 1; diff --git a/test/sun/management/HotspotClassLoadingMBean/GetInitializedClassCount.java b/test/sun/management/HotspotClassLoadingMBean/GetInitializedClassCount.java index 5a11785d73eaf62668a7f5dd5ab98e7e29d82f6a..b2750a1f733089331b041312ae91117e40c0d96b 100644 --- a/test/sun/management/HotspotClassLoadingMBean/GetInitializedClassCount.java +++ b/test/sun/management/HotspotClassLoadingMBean/GetInitializedClassCount.java @@ -37,7 +37,7 @@ import sun.management.*; public class GetInitializedClassCount { private static HotspotClassLoadingMBean mbean = - (HotspotClassLoadingMBean)ManagementFactory.getHotspotClassLoadingMBean(); + (HotspotClassLoadingMBean)ManagementFactoryHelper.getHotspotClassLoadingMBean(); // Careful with these values. private static final long MIN_VALUE_FOR_PASS = 1; diff --git a/test/sun/management/HotspotClassLoadingMBean/GetLoadedClassSize.java b/test/sun/management/HotspotClassLoadingMBean/GetLoadedClassSize.java index 7487940e71e8fbbecc400a8033b1f28fac0dc5ef..5b44aca222eb22a930e45a358b8f5eace21acb90 100644 --- a/test/sun/management/HotspotClassLoadingMBean/GetLoadedClassSize.java +++ b/test/sun/management/HotspotClassLoadingMBean/GetLoadedClassSize.java @@ -37,7 +37,7 @@ import sun.management.*; public class GetLoadedClassSize { private static HotspotClassLoadingMBean mbean = - (HotspotClassLoadingMBean)ManagementFactory.getHotspotClassLoadingMBean(); + (HotspotClassLoadingMBean)ManagementFactoryHelper.getHotspotClassLoadingMBean(); // Careful with these values. private static final long MIN_VALUE_FOR_PASS = 1; diff --git a/test/sun/management/HotspotClassLoadingMBean/GetMethodDataSize.java b/test/sun/management/HotspotClassLoadingMBean/GetMethodDataSize.java index eb08a3860c7e533d8935d26ed787d39b62df8a43..cc83022dd62ef64868c233c62b9ee62045a434ba 100644 --- a/test/sun/management/HotspotClassLoadingMBean/GetMethodDataSize.java +++ b/test/sun/management/HotspotClassLoadingMBean/GetMethodDataSize.java @@ -37,7 +37,7 @@ import sun.management.*; public class GetMethodDataSize { private static HotspotClassLoadingMBean mbean = - (HotspotClassLoadingMBean)ManagementFactory.getHotspotClassLoadingMBean(); + (HotspotClassLoadingMBean)ManagementFactoryHelper.getHotspotClassLoadingMBean(); // Careful with these values. private static final long MIN_VALUE_FOR_PASS = 1; diff --git a/test/sun/management/HotspotClassLoadingMBean/GetUnloadedClassSize.java b/test/sun/management/HotspotClassLoadingMBean/GetUnloadedClassSize.java index 2826d9ccd1c26aa34a1755b1acddef4a5ac5ee7d..a12920ee5ac86f36780f11a55a3e5c909228393e 100644 --- a/test/sun/management/HotspotClassLoadingMBean/GetUnloadedClassSize.java +++ b/test/sun/management/HotspotClassLoadingMBean/GetUnloadedClassSize.java @@ -37,7 +37,7 @@ import sun.management.*; public class GetUnloadedClassSize { private static HotspotClassLoadingMBean mbean = - (HotspotClassLoadingMBean)ManagementFactory.getHotspotClassLoadingMBean(); + (HotspotClassLoadingMBean)ManagementFactoryHelper.getHotspotClassLoadingMBean(); // Careful with these values. private static final long MIN_VALUE_FOR_PASS = 0; diff --git a/test/sun/management/HotspotRuntimeMBean/GetSafepointCount.java b/test/sun/management/HotspotRuntimeMBean/GetSafepointCount.java index dd60467b16a39d933525a365951e550171ea8386..ca7d2084c56134acacb26809b7793c281fdda030 100644 --- a/test/sun/management/HotspotRuntimeMBean/GetSafepointCount.java +++ b/test/sun/management/HotspotRuntimeMBean/GetSafepointCount.java @@ -37,7 +37,7 @@ import sun.management.*; public class GetSafepointCount { private static HotspotRuntimeMBean mbean = - (HotspotRuntimeMBean)ManagementFactory.getHotspotRuntimeMBean(); + (HotspotRuntimeMBean)ManagementFactoryHelper.getHotspotRuntimeMBean(); private static final long NUM_THREAD_DUMPS = 5; diff --git a/test/sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java b/test/sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java index fa2d91d28334437496722c71640fede5f5d140bf..b853a3ec96a8452833d5eb864a0b1c82d2e9dd60 100644 --- a/test/sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java +++ b/test/sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java @@ -37,7 +37,7 @@ import sun.management.*; public class GetSafepointSyncTime { private static HotspotRuntimeMBean mbean = - (HotspotRuntimeMBean)ManagementFactory.getHotspotRuntimeMBean(); + (HotspotRuntimeMBean)ManagementFactoryHelper.getHotspotRuntimeMBean(); private static final long NUM_THREAD_DUMPS = 300; diff --git a/test/sun/management/HotspotRuntimeMBean/GetTotalSafepointTime.java b/test/sun/management/HotspotRuntimeMBean/GetTotalSafepointTime.java index bd9c0aa9825ef7b1faaf9c20e38480ea2af51a47..7b70546f6cce7045135b817bb8fb0b54953c6af4 100644 --- a/test/sun/management/HotspotRuntimeMBean/GetTotalSafepointTime.java +++ b/test/sun/management/HotspotRuntimeMBean/GetTotalSafepointTime.java @@ -37,7 +37,7 @@ import sun.management.*; public class GetTotalSafepointTime { private static HotspotRuntimeMBean mbean = - (HotspotRuntimeMBean)ManagementFactory.getHotspotRuntimeMBean(); + (HotspotRuntimeMBean)ManagementFactoryHelper.getHotspotRuntimeMBean(); private static final long NUM_THREAD_DUMPS = 100; diff --git a/test/sun/management/HotspotThreadMBean/GetInternalThreads.java b/test/sun/management/HotspotThreadMBean/GetInternalThreads.java index b095f67cd9474c178447d25872c037bf68da9ab7..91e0792dc6114e1cbc53b8d01463c435123eb40e 100644 --- a/test/sun/management/HotspotThreadMBean/GetInternalThreads.java +++ b/test/sun/management/HotspotThreadMBean/GetInternalThreads.java @@ -32,10 +32,11 @@ import sun.management.*; import java.util.*; import java.lang.management.ThreadMXBean; +import java.lang.management.ManagementFactory; public class GetInternalThreads { private static HotspotThreadMBean mbean = - ManagementFactory.getHotspotThreadMBean(); + ManagementFactoryHelper.getHotspotThreadMBean(); // Minimum number of VM internal threads // VM thread, watcher thread, Low memory detector, compiler thread @@ -55,7 +56,7 @@ public class GetInternalThreads { System.out.println("Internal Thread Count = " + value); ThreadMXBean thread = - java.lang.management.ManagementFactory.getThreadMXBean(); + ManagementFactory.getThreadMXBean(); if (!thread.isThreadCpuTimeSupported()) { System.out.println("Thread Cpu Time is not supported."); return; diff --git a/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java b/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3f23b0bf7bf5339148a0ff4515beb9ecca8f97db --- /dev/null +++ b/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java @@ -0,0 +1,183 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 4981215 + * @summary Tests that the jvmstat counters published by the out-of-the-box + * management agent for the JMX connection details are correct. + * @author Luis-Miguel Alventosa + * @run clean JvmstatCountersTest + * @run build JvmstatCountersTest + * @run main/othervm JvmstatCountersTest 1 + * @run main/othervm -Dcom.sun.management.jmxremote JvmstatCountersTest 2 + * @run main/othervm -Dcom.sun.management.jmxremote.port=0 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false JvmstatCountersTest 3 + * @run main/othervm JvmstatCountersTest 4 + */ + +import java.io.*; +import java.lang.management.*; +import java.util.*; +import javax.management.*; +import javax.management.remote.*; +import com.sun.tools.attach.*; +import sun.management.ConnectorAddressLink; + +public class JvmstatCountersTest { + + public static void checkAddress(String address) throws IOException { + System.out.println("Address = " + address); + JMXServiceURL url = new JMXServiceURL(address); + JMXConnector jmxc = JMXConnectorFactory.connect(url); + MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); + System.out.println("MBean Count = " + mbsc.getMBeanCount()); + } + + public static void checkKey(Map data, int index, + String key, String expectedValue) throws Exception { + String counter = "sun.management.JMXConnectorServer." + index + "." + key; + if (!data.containsKey(counter)) { + System.out.println("Test FAILED! Missing counter " + counter); + throw new IllegalArgumentException("Test case failed"); + } + String value = data.get(counter); + if (key.equals("remoteAddress")) { + checkAddress(value); + } else if (!expectedValue.equals(value)) { + System.out.println("Test FAILED! Invalid counter " + + counter + "=" + value); + throw new IllegalArgumentException("Test case failed"); + } + System.out.println("OK: " + counter + "=" + value); + } + + public static void main(String args[]) throws Exception { + String localAddress = ConnectorAddressLink.importFrom(0); + Map remoteData = ConnectorAddressLink.importRemoteFrom(0); + final int testCase = Integer.parseInt(args[0]); + switch (testCase) { + case 1: + if (localAddress == null && remoteData.isEmpty()) { + System.out.println("Test PASSED! The OOTB management " + + "agent didn't publish any jvmstat counter."); + } else { + System.out.println("Test FAILED! The OOTB management " + + "agent unexpectedly published jvmstat counters."); + throw new IllegalArgumentException("Test case 1 failed"); + } + break; + case 2: + if (localAddress == null) { + System.out.println("Test FAILED! The OOTB management " + + "agent didn't publish the local connector."); + throw new IllegalArgumentException("Test case 2 failed"); + } + checkAddress(localAddress); + if (!remoteData.isEmpty()) { + System.out.println("Test FAILED! The OOTB management " + + "agent shouldn't publish the remote connector."); + throw new IllegalArgumentException("Test case 2 failed"); + } + System.out.println("Test PASSED! The OOTB management " + + "agent only publishes the local connector through " + + "a jvmstat counter."); + break; + case 3: + if (localAddress == null) { + System.out.println("Test FAILED! The OOTB management " + + "agent didn't publish the local connector."); + throw new IllegalArgumentException("Test case 3 failed"); + } + checkAddress(localAddress); + if (remoteData.isEmpty()) { + System.out.println("Test FAILED! The OOTB management " + + "agent didnn't publish the remote connector."); + throw new IllegalArgumentException("Test case 3 failed"); + } + for (String key : remoteData.keySet()) { + if (!key.startsWith("sun.management.JMXConnectorServer.0.")) { + System.out.println("Test FAILED! The OOTB management " + + "agent shouldn't publish anything which isn't " + + "related to the remote connector."); + throw new IllegalArgumentException("Test case 3 failed"); + } + } + checkKey(remoteData, 0, "remoteAddress", null); + checkKey(remoteData, 0, "authenticate", "false"); + checkKey(remoteData, 0, "ssl", "false"); + checkKey(remoteData, 0, "sslRegistry", "false"); + checkKey(remoteData, 0, "sslNeedClientAuth", "false"); + System.out.println("Test PASSED! The OOTB management " + + "agent publishes both the local and remote " + + "connector info through jvmstat counters."); + break; + case 4: + if (localAddress != null || !remoteData.isEmpty()) { + System.out.println("Test FAILED! The OOTB management " + + "agent unexpectedly published jvmstat counters."); + throw new IllegalArgumentException("Test case 4 failed"); + } + RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); + String name = rt.getName(); + System.out.println("name = " + name); + String vmid = name.substring(0, name.indexOf("@")); + System.out.println("vmid = " + vmid); + VirtualMachine vm = VirtualMachine.attach(vmid); + String agent = vm.getSystemProperties().getProperty("java.home") + + File.separator + "lib" + File.separator + "management-agent.jar"; + vm.loadAgent(agent, "com.sun.management.jmxremote.port=0,com.sun.management.jmxremote.authenticate=false,com.sun.management.jmxremote.ssl=false"); + vm.detach(); + String localAddress2 = ConnectorAddressLink.importFrom(0); + if (localAddress2 == null) { + System.out.println("Test FAILED! The OOTB management " + + "agent didn't publish the local connector."); + throw new IllegalArgumentException("Test case 4 failed"); + } + checkAddress(localAddress2); + Map remoteData2 = ConnectorAddressLink.importRemoteFrom(0); + if (remoteData2.isEmpty()) { + System.out.println("Test FAILED! The OOTB management " + + "agent didnn't publish the remote connector."); + throw new IllegalArgumentException("Test case 4 failed"); + } + for (String key : remoteData2.keySet()) { + if (!key.startsWith("sun.management.JMXConnectorServer.0.")) { + System.out.println("Test FAILED! The OOTB management " + + "agent shouldn't publish anything which isn't " + + "related to the remote connector."); + throw new IllegalArgumentException("Test case 4 failed"); + } + } + checkKey(remoteData2, 0, "remoteAddress", null); + checkKey(remoteData2, 0, "authenticate", "false"); + checkKey(remoteData2, 0, "ssl", "false"); + checkKey(remoteData2, 0, "sslRegistry", "false"); + checkKey(remoteData2, 0, "sslNeedClientAuth", "false"); + System.out.println("Test PASSED! The OOTB management agent " + + "publishes both the local and remote connector " + + "info through jvmstat counters when the agent is " + + "loaded through the Attach API."); + } + System.out.println("Bye! Bye!"); + } +} diff --git a/test/sun/net/www/http/ChunkedOutputStream/Test.java b/test/sun/net/www/http/ChunkedOutputStream/Test.java index 89bc8b3bf854f7987da6517c2b6512c5567dccfc..3866761ade6e7203efc6283dfd2d44b4d4db4a13 100644 --- a/test/sun/net/www/http/ChunkedOutputStream/Test.java +++ b/test/sun/net/www/http/ChunkedOutputStream/Test.java @@ -23,7 +23,7 @@ /** * @test - * @bug 5026745 + * @bug 5026745 6631048 * @run main/othervm/timeout=500 Test * @summary Cannot flush output stream when writing to an HttpUrlConnection */ @@ -158,6 +158,50 @@ public class Test implements HttpHandler { exchange.sendResponseHeaders(200, 0); } break; + case 10: /* test11 */ + printRequestURI(exchange); + is = exchange.getRequestBody(); + s = read (is, str1.length()); + + error = false; + for (int i=10; i< 30 * 1024; i++) { + byte c = (byte)is.read(); + + if (c != (byte)i) { + error = true; + System.out.println ("error at position " + i); + } + } + if (!s.equals(str1) ) { + System.out.println ("received string : " + s); + exchange.sendResponseHeaders(500, 0); + } else if (error) { + System.out.println ("error"); + exchange.sendResponseHeaders(500, 0); + } else { + exchange.sendResponseHeaders(200, 0); + } + break; + case 11: /* test12 */ + printRequestURI(exchange); + is = exchange.getRequestBody(); + + error = false; + for (int i=10; i< 30 * 1024; i++) { + byte c = (byte)is.read(); + + if (c != (byte)i) { + error = true; + System.out.println ("error at position " + i); + } + } + if (error) { + System.out.println ("error"); + exchange.sendResponseHeaders(500, 0); + } else { + exchange.sendResponseHeaders(200, 0); + } + break; } exchange.close(); count ++; @@ -390,6 +434,56 @@ public class Test implements HttpHandler { } } + static void test11 (String u) throws Exception { + URL url = new URL (u); + System.out.println ("client opening connection to: " + u); + HttpURLConnection urlc = (HttpURLConnection)url.openConnection (); + urlc.setChunkedStreamingMode (36 * 1024); + urlc.setDoOutput(true); + urlc.setRequestMethod ("POST"); + OutputStream os = urlc.getOutputStream (); + byte[] buf = new byte [30 * 1024]; + for (int i=0; i< 30 * 1024; i++) { + buf[i] = (byte) i; + } + /* write a small bit first, and then the large buffer */ + os.write (str1.getBytes()); + //os.write (buf, 10, buf.length - 10); /* skip 10 bytes to test offset */ + os.write (buf, 10, (10 * 1024) - 10); + os.write (buf, (10 * 1024), (10 * 1024)); + os.write (buf, (20 * 1024), (10 * 1024)); + os.close(); + InputStream is = urlc.getInputStream(); + is.close(); + int ret = urlc.getResponseCode(); + if (ret != 200) { + throw new Exception ("Expected 200: got " + ret); + } + } + + static void test12 (String u) throws Exception { + URL url = new URL (u); + System.out.println ("client opening connection to: " + u); + HttpURLConnection urlc = (HttpURLConnection)url.openConnection (); + urlc.setChunkedStreamingMode (36 * 1024); + urlc.setDoOutput(true); + urlc.setRequestMethod ("POST"); + OutputStream os = urlc.getOutputStream (); + byte[] buf = new byte [30 * 1024]; + for (int i=0; i< 30 * 1024; i++) { + buf[i] = (byte) i; + } + os.write (buf, 10, buf.length - 10); /* skip 10 bytes to test offset */ + os.close(); + InputStream is = urlc.getInputStream(); + is.close(); + int ret = urlc.getResponseCode(); + if (ret != 200) { + throw new Exception ("Expected 200: got " + ret); + } + } + + static com.sun.net.httpserver.HttpServer httpserver; public static void main (String[] args) throws Exception { @@ -411,6 +505,8 @@ public class Test implements HttpHandler { test8("http://localhost:"+ port + "/test/test8"); test9("http://localhost:"+ port + "/test/test9"); test10("http://localhost:"+ port + "/test/test10"); + test11("http://localhost:"+ port + "/test/test11"); + test12("http://localhost:"+ port + "/test/test12"); } finally { if (httpserver != null) httpserver.stop(0); diff --git a/test/sun/net/www/protocol/http/B6641309.java b/test/sun/net/www/protocol/http/B6641309.java new file mode 100644 index 0000000000000000000000000000000000000000..15e8fdc31bc602e349ae6f2f337bf61c4dbbd011 --- /dev/null +++ b/test/sun/net/www/protocol/http/B6641309.java @@ -0,0 +1,129 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6641309 + * @summary Wrong Cookie separator used in HttpURLConnection + */ + +import java.net.*; +import java.util.*; +import java.io.*; +import com.sun.net.httpserver.*; +import java.util.concurrent.Executors; +import java.util.concurrent.ExecutorService; + +public class B6641309 +{ + com.sun.net.httpserver.HttpServer httpServer; + ExecutorService executorService; + + public static void main(String[] args) + { + new B6641309(); + } + + public B6641309() + { + try { + startHttpServer(); + doClient(); + } catch (IOException ioe) { + System.err.println(ioe); + } + } + + void doClient() { + CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); + try { + InetSocketAddress address = httpServer.getAddress(); + + // GET Request + URL url = new URL("http://localhost:" + address.getPort() + "/test/"); + CookieHandler ch = CookieHandler.getDefault(); + Map> header = new HashMap>(); + List values = new LinkedList(); + values.add("Test1Cookie=TEST1; path=/test/"); + values.add("Test2Cookie=TEST2; path=/test/"); + header.put("Set-Cookie", values); + + // preload the CookieHandler with a cookie for our URL + // so that it will be sent during the first request + ch.put(url.toURI(), header); + HttpURLConnection uc = (HttpURLConnection)url.openConnection(); + int resp = uc.getResponseCode(); + if (resp != 200) + throw new RuntimeException("Failed: Response code from GET is not 200"); + + System.out.println("Response code from GET = 200 OK"); + + } catch (IOException e) { + e.printStackTrace(); + } catch (URISyntaxException e) { + e.printStackTrace(); + } finally { + httpServer.stop(1); + executorService.shutdown(); + } + } + + /** + * Http Server + */ + public void startHttpServer() throws IOException { + httpServer = com.sun.net.httpserver.HttpServer.create(new InetSocketAddress(0), 0); + + // create HttpServer context + HttpContext ctx = httpServer.createContext("/test/", new MyHandler()); + + executorService = Executors.newCachedThreadPool(); + httpServer.setExecutor(executorService); + httpServer.start(); + } + + class MyHandler implements HttpHandler { + public void handle(HttpExchange t) throws IOException { + InputStream is = t.getRequestBody(); + Headers reqHeaders = t.getRequestHeaders(); + int i = 0; + // Read till end of stream + do { + i = is.read(); + } while (i != -1); + is.close(); + + List cookies = reqHeaders.get("Cookie"); + if (cookies != null) { + for (String str : cookies) { + // The separator between the 2 cookies should be + // a semi-colon AND a space + if (str.equals("Test1Cookie=TEST1; Test2Cookie=TEST2")) + t.sendResponseHeaders(200, -1); + } + } + t.sendResponseHeaders(400, -1); + t.close(); + } + } +} diff --git a/test/sun/net/www/protocol/http/B6660405.java b/test/sun/net/www/protocol/http/B6660405.java new file mode 100644 index 0000000000000000000000000000000000000000..2309497c2fb7c575b09ad32385710aeca3b48d1c --- /dev/null +++ b/test/sun/net/www/protocol/http/B6660405.java @@ -0,0 +1,163 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6660405 + * @summary HttpURLConnection returns the wrong InputStream + */ + +import java.net.*; +import java.util.*; +import java.io.*; +import com.sun.net.httpserver.*; +import java.util.concurrent.Executors; +import java.util.concurrent.ExecutorService; + +public class B6660405 +{ + com.sun.net.httpserver.HttpServer httpServer; + ExecutorService executorService; + + static class MyCacheResponse extends CacheResponse { + private byte[] buf = new byte[1024]; + + public MyCacheResponse() { + } + + @Override + public Map> getHeaders() throws IOException + { + Map> h = new HashMap>(); + ArrayList l = new ArrayList(); + l.add("HTTP/1.1 200 OK"); + h.put(null, l); + l = new ArrayList(); + l.add("1024"); + h.put("Content-Length", l); + return h; + } + + @Override + public InputStream getBody() throws IOException + { + return new ByteArrayInputStream(buf); + } + + } + static class MyResponseCache extends ResponseCache { + + public MyResponseCache() { + } + + @Override + public CacheResponse get(URI uri, String rqstMethod, Map> rqstHeaders) throws IOException + { + if (uri.getPath().equals("/redirect/index.html")) { + return new MyCacheResponse(); + } + return null; + } + + @Override + public CacheRequest put(URI uri, URLConnection conn) throws IOException + { + return null; + } + + } + + public static void main(String[] args) + { + new B6660405(); + } + + public B6660405() + { + try { + startHttpServer(); + doClient(); + } catch (IOException ioe) { + System.err.println(ioe); + } + } + + void doClient() { + ResponseCache.setDefault(new MyResponseCache()); + try { + InetSocketAddress address = httpServer.getAddress(); + + // GET Request + URL url = new URL("http://localhost:" + address.getPort() + "/test/index.html"); + HttpURLConnection uc = (HttpURLConnection)url.openConnection(); + int code = uc.getResponseCode(); + System.err.println("response code = " + code); + int l = uc.getContentLength(); + System.err.println("content-length = " + l); + InputStream in = uc.getInputStream(); + int i = 0; + // Read till end of stream + do { + i = in.read(); + } while (i != -1); + in.close(); + } catch (IOException e) { + throw new RuntimeException("Got the wrong InputStream after checking headers"); + } finally { + httpServer.stop(1); + executorService.shutdown(); + } + } + + /** + * Http Server + */ + public void startHttpServer() throws IOException { + httpServer = com.sun.net.httpserver.HttpServer.create(new InetSocketAddress(0), 0); + + // create HttpServer context + HttpContext ctx = httpServer.createContext("/test/", new MyHandler()); + + executorService = Executors.newCachedThreadPool(); + httpServer.setExecutor(executorService); + httpServer.start(); + } + + class MyHandler implements HttpHandler { + public void handle(HttpExchange t) throws IOException { + InputStream is = t.getRequestBody(); + Headers reqHeaders = t.getRequestHeaders(); + Headers resHeaders = t.getResponseHeaders(); + + int i = 0; + // Read till end of stream + do { + i = is.read(); + } while (i != -1); + is.close(); + resHeaders.add("Location", "http://foo.bar/redirect/index.html"); + t.sendResponseHeaders(302, -1); + t.close(); + } + } +} diff --git a/test/sun/security/krb5/DnsFallback.java b/test/sun/security/krb5/DnsFallback.java new file mode 100644 index 0000000000000000000000000000000000000000..95fbf3b165b513d73e940c75115644a883299aa7 --- /dev/null +++ b/test/sun/security/krb5/DnsFallback.java @@ -0,0 +1,64 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ +/* + * @test + * @bug 6673164 + * @summary dns_fallback parse error + */ + +import sun.security.krb5.*; +import java.io.*; + +public class DnsFallback { + public static void main(String[] args) throws Exception { + check("true", "true", true); + check("false", "true", false); + check("true", "false", true); + check("false", "false", false); + check("true", null, true); + check("false", null, false); + check(null, "true", true); + check(null, "false", false); + } + + static void check(String realm, String fallback, boolean output) throws Exception { + FileOutputStream fo = new FileOutputStream("dnsfallback.conf"); + StringBuffer sb = new StringBuffer(); + sb.append("[libdefaults]\n"); + if (realm != null) { + sb.append("dns_lookup_realm=" + realm + "\n"); + } + if (fallback != null) { + sb.append("dns_fallback=" + fallback + "\n"); + } + fo.write(sb.toString().getBytes()); + fo.close(); + System.setProperty("java.security.krb5.conf", "dnsfallback.conf"); + Config.refresh(); + System.out.println("Testing " + realm + ", " + fallback + ", " + output); + if (Config.getInstance().useDNS_Realm() != output) { + throw new Exception("Fail"); + } + } +} + diff --git a/test/sun/security/krb5/OptionPADataInKDCReq.java b/test/sun/security/krb5/OptionPADataInKDCReq.java new file mode 100644 index 0000000000000000000000000000000000000000..2229b541e890668f1b2b6e29ec7a4794ab36e1b5 --- /dev/null +++ b/test/sun/security/krb5/OptionPADataInKDCReq.java @@ -0,0 +1,123 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ +/* + * @test + * @bug 6648972 + * @summary KDCReq.init always read padata + */ +import sun.security.krb5.internal.ETypeInfo2; +import sun.security.krb5.internal.KDCReq; +import sun.security.util.DerValue; + +public class OptionPADataInKDCReq { + public static void main(String[] args) throws Exception { + /* + * This is a AS-REQ block without padata. The content is -- + [APPLICATION 10] SEQUENCE { + [1] INTEGER 5 + [2] INTEGER 10 + [4] SEQUENCE { + [0] BIT STRING 01000000 10000001 00000000 00010000 + [1] SEQUENCE { + [0] INTEGER 1 + [1] SEQUENCE { + STRING administrator + } + } + [2] STRING N3 + [3] SEQUENCE { + [0] INTEGER 2 + [1] SEQUENCE { + STRING krbtgt + STRING N3 + } + } + [5] TIME Sun Sep 13 10:48:05 CST 2037 + [6] TIME Sun Sep 13 10:48:05 CST 2037 + [7] INTEGER 2101281516 + [8] SEQUENCE { + INTEGER 23 + INTEGER -133 + INTEGER -128 + INTEGER 3 + INTEGER 1 + INTEGER 24 + INTEGER -135 + } + [9] SEQUENCE { + SEQUENCE { + [0] INTEGER 20 + [1] OCTET STRING + 0000: 58 50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 XP + } + } + } + } + */ + byte[] b = { + (byte)0x6a, (byte)0x81, (byte)0xbf, (byte)0x30, (byte)0x81, (byte)0xbc, (byte)0xa1, (byte)0x03, + (byte)0x02, (byte)0x01, (byte)0x05, (byte)0xa2, (byte)0x03, (byte)0x02, (byte)0x01, (byte)0x0a, + (byte)0xa4, (byte)0x81, (byte)0xaf, (byte)0x30, (byte)0x81, (byte)0xac, (byte)0xa0, (byte)0x07, + (byte)0x03, (byte)0x05, (byte)0x00, (byte)0x40, (byte)0x81, (byte)0x00, (byte)0x10, (byte)0xa1, + (byte)0x1a, (byte)0x30, (byte)0x18, (byte)0xa0, (byte)0x03, (byte)0x02, (byte)0x01, (byte)0x01, + (byte)0xa1, (byte)0x11, (byte)0x30, (byte)0x0f, (byte)0x1b, (byte)0x0d, (byte)0x61, (byte)0x64, + (byte)0x6d, (byte)0x69, (byte)0x6e, (byte)0x69, (byte)0x73, (byte)0x74, (byte)0x72, (byte)0x61, + (byte)0x74, (byte)0x6f, (byte)0x72, (byte)0xa2, (byte)0x04, (byte)0x1b, (byte)0x02, (byte)0x4e, + (byte)0x33, (byte)0xa3, (byte)0x17, (byte)0x30, (byte)0x15, (byte)0xa0, (byte)0x03, (byte)0x02, + (byte)0x01, (byte)0x02, (byte)0xa1, (byte)0x0e, (byte)0x30, (byte)0x0c, (byte)0x1b, (byte)0x06, + (byte)0x6b, (byte)0x72, (byte)0x62, (byte)0x74, (byte)0x67, (byte)0x74, (byte)0x1b, (byte)0x02, + (byte)0x4e, (byte)0x33, (byte)0xa5, (byte)0x11, (byte)0x18, (byte)0x0f, (byte)0x32, (byte)0x30, + (byte)0x33, (byte)0x37, (byte)0x30, (byte)0x39, (byte)0x31, (byte)0x33, (byte)0x30, (byte)0x32, + (byte)0x34, (byte)0x38, (byte)0x30, (byte)0x35, (byte)0x5a, (byte)0xa6, (byte)0x11, (byte)0x18, + (byte)0x0f, (byte)0x32, (byte)0x30, (byte)0x33, (byte)0x37, (byte)0x30, (byte)0x39, (byte)0x31, + (byte)0x33, (byte)0x30, (byte)0x32, (byte)0x34, (byte)0x38, (byte)0x30, (byte)0x35, (byte)0x5a, + (byte)0xa7, (byte)0x06, (byte)0x02, (byte)0x04, (byte)0x7d, (byte)0x3f, (byte)0x02, (byte)0xec, + (byte)0xa8, (byte)0x19, (byte)0x30, (byte)0x17, (byte)0x02, (byte)0x01, (byte)0x17, (byte)0x02, + (byte)0x02, (byte)0xff, (byte)0x7b, (byte)0x02, (byte)0x01, (byte)0x80, (byte)0x02, (byte)0x01, + (byte)0x03, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x18, (byte)0x02, + (byte)0x02, (byte)0xff, (byte)0x79, (byte)0xa9, (byte)0x1d, (byte)0x30, (byte)0x1b, (byte)0x30, + (byte)0x19, (byte)0xa0, (byte)0x03, (byte)0x02, (byte)0x01, (byte)0x14, (byte)0xa1, (byte)0x12, + (byte)0x04, (byte)0x10, (byte)0x58, (byte)0x50, (byte)0x20, (byte)0x20, (byte)0x20, (byte)0x20, + (byte)0x20, (byte)0x20, (byte)0x20, (byte)0x20, (byte)0x20, (byte)0x20, (byte)0x20, (byte)0x20, + (byte)0x20, (byte)0x20, + }; + new KDCReq(b, 0x0a); + + /* + * This is a fake ETYPEINFO2 block with no salt + SEQUENCE { + [0] INTEGER 0 + [2] OCTET STRING 0000: 00 . + } + */ + byte[] b2 = { + (byte)0x30, (byte)0x0a, (byte)0xa0, (byte)0x03, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0xa2, + (byte)0x03, (byte)0x04, (byte)0x01, (byte)0x00, + }; + + ETypeInfo2 e2 = new ETypeInfo2(new DerValue(b2)); + if (e2.getSalt() != null || e2.getParams() == null) { + throw new Exception("ETypeInfo2 decoding error"); + } + } +} diff --git a/test/sun/security/krb5/TimeInCCache.java b/test/sun/security/krb5/TimeInCCache.java new file mode 100644 index 0000000000000000000000000000000000000000..5ef8b5370df426633f886c1f981296b229b891e4 --- /dev/null +++ b/test/sun/security/krb5/TimeInCCache.java @@ -0,0 +1,93 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ +/* + * @test + * @bug 6590930 + * @summary read/write does not match for ccache + */ + +import java.io.ByteArrayInputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import sun.security.krb5.internal.ccache.CCacheInputStream; +import sun.security.krb5.internal.ccache.Credentials; + +public class TimeInCCache { + public static void main(String[] args) throws Exception { + // A trivial cache file, with startdate and renewTill being zero. + // The endtime is set to sometime in year 2022, so that isValid() + // will always check starttime. + byte[] ccache = new byte[]{ + 5, 4, 0, 12, 0, 1, 0, 8, -1, -1, -1, 19, -1, -2, 89, 51, + 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 10, 77, 65, 88, 73, + 46, 76, 79, 67, 65, 76, 0, 0, 0, 5, 100, 117, 109, 109, 121, 0, + 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 10, 77, 65, 88, 73, 46, + 76, 79, 67, 65, 76, 0, 0, 0, 5, 100, 117, 109, 109, 121, 0, 0, + 0, 0, 0, 0, 0, 2, 0, 0, 0, 10, 77, 65, 88, 73, 46, 76, + 79, 67, 65, 76, 0, 0, 0, 6, 107, 114, 98, 116, 103, 116, 0, 0, + 0, 10, 77, 65, 88, 73, 46, 76, 79, 67, 65, 76, 0, 17, 0, 0, + 0, 16, -78, -85, -90, -50, -68, 115, 68, 8, -39, -109, 91, 61, -17, -27, + -122, -120, 71, 69, 16, -121, 0, 0, 0, 0, 98, 69, 16, -121, 0, 0, + 0, 0, 0, 64, -32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 97, -127, -3, 48, -127, -6, -96, 3, 2, 1, 5, -95, 12, + 27, 10, 77, 65, 88, 73, 46, 76, 79, 67, 65, 76, -94, 31, 48, 29, + -96, 3, 2, 1, 0, -95, 22, 48, 20, 27, 6, 107, 114, 98, 116, 103, + 116, 27, 10, 77, 65, 88, 73, 46, 76, 79, 67, 65, 76, -93, -127, -61, + 48, -127, -64, -96, 3, 2, 1, 17, -95, 3, 2, 1, 1, -94, -127, -77, + 4, -127, -80, 43, 65, -66, 34, 21, -34, 37, 35, 32, 50, -14, 122, 77, + -3, -29, 37, 99, 50, 125, -43, -96, -78, 85, 23, 41, -80, 68, 2, -109, + -27, 38, -41, -72, -32, 127, 63, -76, -22, 81, 33, -114, -30, 104, 125, -81, + -29, 70, -25, 23, 100, -75, -25, 62, -120, -78, -61, -100, -74, 50, -117, -127, + -16, 79, -106, 62, -39, 91, 100, -10, 23, -88, -18, -47, 51, -19, 113, 18, + 98, -101, 31, 98, 22, -81, 11, -41, -42, 67, 87, 92, -2, 42, -54, 79, + 49, -90, 43, -37, 90, -102, 125, 62, -88, -77, 100, 102, 23, -57, -51, 38, + 68, -44, -57, -102, 103, -6, 85, -58, 74, -117, -87, 67, -103, -36, 110, -122, + 115, 12, 118, -106, -114, -51, 79, 68, 32, -91, -53, -5, -51, 89, 72, 70, + 123, -12, -95, 9, 40, -30, -117, 74, 77, 38, 91, 126, -82, 17, 98, 98, + -49, 78, 36, 36, 103, -76, -100, -23, 118, -92, -8, 80, 103, -23, -98, 56, + 21, 65, -77, 0, 0, 0, 0 + }; + System.setProperty("sun.security.krb5.debug", "true"); // test code changes in DEBUG + CCacheInputStream cis = new CCacheInputStream(new ByteArrayInputStream(ccache)); + cis.readVersion(); + cis.readTag(); + cis.readPrincipal(0x504); + Method m = CCacheInputStream.class.getDeclaredMethod("readCred", Integer.TYPE); + m.setAccessible(true); + Credentials c = (Credentials) m.invoke(cis, new Integer(0x504)); + sun.security.krb5.Credentials cc = c.setKrbCreds(); + + // 1. Make sure starttime is still null + if (cc.getStartTime() != null) { + throw new Exception("Fail, starttime should be zero here"); + } + + // 2. Make sure renewTill is still null + if (cc.getRenewTill() != null) { + throw new Exception("Fail, renewTill should be zero here"); + } + + // 3. Make sure isValid works + c.isValid(); + } +} diff --git a/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java b/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java new file mode 100644 index 0000000000000000000000000000000000000000..3dcd076738e4ac20ff94f885a6095a226415f1dd --- /dev/null +++ b/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java @@ -0,0 +1,109 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6572331 + * @summary basic test for RSA cipher key wrapping functionality + * @author Valerie Peng + * @library .. + */ +import java.io.*; +import java.util.*; + +import java.security.*; + +import javax.crypto.*; +import javax.crypto.spec.SecretKeySpec; + +public class TestRSACipherWrap extends PKCS11Test { + + private static final String RSA_ALGO = "RSA/ECB/PKCS1Padding"; + + public void main(Provider p) throws Exception { + try { + Cipher.getInstance(RSA_ALGO, p); + } catch (GeneralSecurityException e) { + System.out.println("Not supported by provider, skipping"); + return; + } + KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p); + kpg.initialize(1024); + KeyPair kp = kpg.generateKeyPair(); + PublicKey publicKey = kp.getPublic(); + PrivateKey privateKey = kp.getPrivate(); + + Cipher cipherPKCS11 = Cipher.getInstance(RSA_ALGO, p); + Cipher cipherJce = Cipher.getInstance(RSA_ALGO, "SunJCE"); + + String algos[] = {"AES", "RC2", "Blowfish"}; + int keySizes[] = {128, 256}; + + for (int j = 0; j < algos.length; j++) { + String algorithm = algos[j]; + KeyGenerator keygen = + KeyGenerator.getInstance(algorithm); + + for (int i = 0; i < keySizes.length; i++) { + SecretKey secretKey = null; + System.out.print("Generate " + keySizes[i] + "-bit " + + algorithm + " key using "); + try { + keygen.init(keySizes[i]); + secretKey = keygen.generateKey(); + System.out.println(keygen.getProvider().getName()); + } catch (InvalidParameterException ipe) { + secretKey = new SecretKeySpec(new byte[32], algorithm); + System.out.println("SecretKeySpec class"); + } + test(kp, secretKey, cipherPKCS11, cipherJce); + test(kp, secretKey, cipherPKCS11, cipherPKCS11); + test(kp, secretKey, cipherJce, cipherPKCS11); + } + } + } + + private static void test(KeyPair kp, SecretKey secretKey, + Cipher wrapCipher, Cipher unwrapCipher) + throws Exception { + String algo = secretKey.getAlgorithm(); + wrapCipher.init(Cipher.WRAP_MODE, kp.getPublic()); + byte[] wrappedKey = wrapCipher.wrap(secretKey); + unwrapCipher.init(Cipher.UNWRAP_MODE, kp.getPrivate()); + Key unwrappedKey = + unwrapCipher.unwrap(wrappedKey, algo, Cipher.SECRET_KEY); + + System.out.println("Test " + wrapCipher.getProvider().getName() + + "/" + unwrapCipher.getProvider().getName() + ": "); + if (!Arrays.equals(secretKey.getEncoded(), + unwrappedKey.getEncoded())) { + throw new Exception("Test Failed!"); + } + System.out.println("Passed"); + } + + public static void main(String[] args) throws Exception { + main(new TestRSACipherWrap()); + } +} + diff --git a/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java b/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java new file mode 100644 index 0000000000000000000000000000000000000000..e102606b4d14d4b98801e6cbae077f5cf6dd0a90 --- /dev/null +++ b/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java @@ -0,0 +1,282 @@ +/* + * Copyright 2008 Sun Microsystems, 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 modi +fy it + * under the terms of the GNU General Public License version 2 onl +y, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, bu +t WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABIL +ITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public L +icense + * version 2 for more details (a copy is included in the LICENSE f +ile that + * accompanied this code). + * + * You should have received a copy of the GNU General Public Licen +se version + * 2 along with this work; if not, write to the Free Software Foun +dation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, San +ta Clara, + * CA 95054 USA or visit www.sun.com if you need additional inform +ation or + * have any questions. + */ + +/** + * @test %I% %E% + * @bug 4898461 + * @summary basic test for symmetric ciphers with padding + * @author Valerie Peng + * @library .. + */ +import java.io.*; +import java.nio.*; +import java.util.*; + +import java.security.*; +import java.security.spec.AlgorithmParameterSpec; + +import javax.crypto.*; +import javax.crypto.spec.IvParameterSpec; + +public class TestSymmCiphers extends PKCS11Test { + + private static class CI { // class for holding Cipher Information + + String transformation; + String keyAlgo; + int dataSize; + + CI(String transformation, String keyAlgo, int dataSize) { + this.transformation = transformation; + this.keyAlgo = keyAlgo; + this.dataSize = dataSize; + } + } + private static final CI[] TEST_LIST = { + new CI("ARCFOUR", "ARCFOUR", 400), + new CI("RC4", "RC4", 401), + new CI("DES/CBC/NoPadding", "DES", 400), + new CI("DESede/CBC/NoPadding", "DESede", 160), + new CI("AES/CBC/NoPadding", "AES", 4800), + new CI("Blowfish/CBC/NoPadding", "Blowfish", 24), + new CI("DES/cbc/PKCS5Padding", "DES", 6401), + new CI("DESede/CBC/PKCS5Padding", "DESede", 402), + new CI("AES/CBC/PKCS5Padding", "AES", 30), + new CI("Blowfish/CBC/PKCS5Padding", "Blowfish", 19), + new CI("DES/ECB/NoPadding", "DES", 400), + new CI("DESede/ECB/NoPadding", "DESede", 160), + new CI("AES/ECB/NoPadding", "AES", 4800), + new CI("DES/ECB/PKCS5Padding", "DES", 32), + new CI("DES/ECB/PKCS5Padding", "DES", 6400), + new CI("DESede/ECB/PKCS5Padding", "DESede", 400), + new CI("AES/ECB/PKCS5Padding", "AES", 64), + new CI("DES", "DES", 6400), + new CI("DESede", "DESede", 408), + new CI("AES", "AES", 128) + }; + private static StringBuffer debugBuf = new StringBuffer(); + + public void main(Provider p) throws Exception { + // NSS reports CKR_DEVICE_ERROR when the data passed to + // its EncryptUpdate/DecryptUpdate is not multiple of blocks + int firstBlkSize = 16; + boolean status = true; + Random random = new Random(); + try { + for (int i = 0; i < TEST_LIST.length; i++) { + CI currTest = TEST_LIST[i]; + System.out.println("===" + currTest.transformation + "==="); + try { + KeyGenerator kg = + KeyGenerator.getInstance(currTest.keyAlgo, p); + SecretKey key = kg.generateKey(); + Cipher c1 = Cipher.getInstance(currTest.transformation, p); + Cipher c2 = Cipher.getInstance(currTest.transformation, + "SunJCE"); + + byte[] plainTxt = new byte[currTest.dataSize]; + random.nextBytes(plainTxt); + System.out.println("Testing inLen = " + plainTxt.length); + + c2.init(Cipher.ENCRYPT_MODE, key); + AlgorithmParameters params = c2.getParameters(); + byte[] answer = c2.doFinal(plainTxt); + System.out.println("Encryption tests: START"); + test(c1, Cipher.ENCRYPT_MODE, key, params, firstBlkSize, + plainTxt, answer); + System.out.println("Encryption tests: DONE"); + c2.init(Cipher.DECRYPT_MODE, key, params); + byte[] answer2 = c2.doFinal(answer); + System.out.println("Decryption tests: START"); + test(c1, Cipher.DECRYPT_MODE, key, params, firstBlkSize, + answer, answer2); + System.out.println("Decryption tests: DONE"); + } catch (NoSuchAlgorithmException nsae) { + System.out.println("Skipping unsupported algorithm: " + + nsae); + } + } + } catch (Exception ex) { + // print out debug info when exception is encountered + if (debugBuf != null) { + System.out.println(debugBuf.toString()); + debugBuf = new StringBuffer(); + } + throw ex; + } + } + + private static void test(Cipher cipher, int mode, SecretKey key, + AlgorithmParameters params, int firstBlkSize, + byte[] in, byte[] answer) throws Exception { + // test setup + long startTime, endTime; + cipher.init(mode, key, params); + int outLen = cipher.getOutputSize(in.length); + //debugOut("Estimated output size = " + outLen + "\n"); + + // test data preparation + ByteBuffer inBuf = ByteBuffer.allocate(in.length); + inBuf.put(in); + inBuf.position(0); + ByteBuffer inDirectBuf = ByteBuffer.allocateDirect(in.length); + inDirectBuf.put(in); + inDirectBuf.position(0); + ByteBuffer outBuf = ByteBuffer.allocate(outLen); + ByteBuffer outDirectBuf = ByteBuffer.allocateDirect(outLen); + + // test#1: byte[] in + byte[] out + //debugOut("Test#1:\n"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + startTime = System.nanoTime(); + byte[] temp = cipher.update(in, 0, firstBlkSize); + if (temp != null && temp.length > 0) { + baos.write(temp, 0, temp.length); + } + temp = cipher.doFinal(in, firstBlkSize, in.length - firstBlkSize); + if (temp != null && temp.length > 0) { + baos.write(temp, 0, temp.length); + } + byte[] testOut1 = baos.toByteArray(); + endTime = System.nanoTime(); + perfOut("stream InBuf + stream OutBuf: " + + (endTime - startTime)); + match(testOut1, answer); + + // test#2: Non-direct Buffer in + non-direct Buffer out + //debugOut("Test#2:\n"); + //debugOut("inputBuf: " + inBuf + "\n"); + //debugOut("outputBuf: " + outBuf + "\n"); + + startTime = System.nanoTime(); + cipher.update(inBuf, outBuf); + cipher.doFinal(inBuf, outBuf); + endTime = System.nanoTime(); + perfOut("non-direct InBuf + non-direct OutBuf: " + + (endTime - startTime)); + match(outBuf, answer); + + // test#3: Direct Buffer in + direc Buffer out + //debugOut("Test#3:\n"); + //debugOut("(pre) inputBuf: " + inDirectBuf + "\n"); + //debugOut("(pre) outputBuf: " + outDirectBuf + "\n"); + + startTime = System.nanoTime(); + cipher.update(inDirectBuf, outDirectBuf); + cipher.doFinal(inDirectBuf, outDirectBuf); + endTime = System.nanoTime(); + perfOut("direct InBuf + direct OutBuf: " + + (endTime - startTime)); + + //debugOut("(post) inputBuf: " + inDirectBuf + "\n"); + //debugOut("(post) outputBuf: " + outDirectBuf + "\n"); + match(outDirectBuf, answer); + + // test#4: Direct Buffer in + non-direct Buffer out + //debugOut("Test#4:\n"); + inDirectBuf.position(0); + outBuf.position(0); + //debugOut("inputBuf: " + inDirectBuf + "\n"); + //debugOut("outputBuf: " + outBuf + "\n"); + + startTime = System.nanoTime(); + cipher.update(inDirectBuf, outBuf); + cipher.doFinal(inDirectBuf, outBuf); + endTime = System.nanoTime(); + perfOut("direct InBuf + non-direct OutBuf: " + + (endTime - startTime)); + match(outBuf, answer); + + // test#5: Non-direct Buffer in + direct Buffer out + //debugOut("Test#5:\n"); + inBuf.position(0); + outDirectBuf.position(0); + + //debugOut("(pre) inputBuf: " + inBuf + "\n"); + //debugOut("(pre) outputBuf: " + outDirectBuf + "\n"); + + startTime = System.nanoTime(); + cipher.update(inBuf, outDirectBuf); + cipher.doFinal(inBuf, outDirectBuf); + endTime = System.nanoTime(); + perfOut("non-direct InBuf + direct OutBuf: " + + (endTime - startTime)); + + //debugOut("(post) inputBuf: " + inBuf + "\n"); + //debugOut("(post) outputBuf: " + outDirectBuf + "\n"); + match(outDirectBuf, answer); + + debugBuf = null; + } + + private static void perfOut(String msg) { + if (debugBuf != null) { + debugBuf.append("PERF>" + msg); + } + } + + private static void debugOut(String msg) { + if (debugBuf != null) { + debugBuf.append(msg); + } + } + + private static void match(byte[] b1, byte[] b2) throws Exception { + if (b1.length != b2.length) { + debugOut("got len : " + b1.length + "\n"); + debugOut("expect len: " + b2.length + "\n"); + throw new Exception("mismatch - different length! got: " + b1.length + ", expect: " + b2.length + "\n"); + } else { + for (int i = 0; i < b1.length; i++) { + if (b1[i] != b2[i]) { + debugOut("got : " + toString(b1) + "\n"); + debugOut("expect: " + toString(b2) + "\n"); + throw new Exception("mismatch"); + } + } + } + } + + private static void match(ByteBuffer bb, byte[] answer) throws Exception { + byte[] bbTemp = new byte[bb.position()]; + bb.position(0); + bb.get(bbTemp, 0, bbTemp.length); + match(bbTemp, answer); + } + + public static void main(String[] args) throws Exception { + main(new TestSymmCiphers()); + } +} diff --git a/test/sun/security/pkcs11/KeyStore/SecretKeysBasic.java b/test/sun/security/pkcs11/KeyStore/SecretKeysBasic.java new file mode 100644 index 0000000000000000000000000000000000000000..82fa2d4c4ad36df416dbff08687605e169104b2f --- /dev/null +++ b/test/sun/security/pkcs11/KeyStore/SecretKeysBasic.java @@ -0,0 +1,194 @@ +/* + * Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.io.*; +import java.util.*; +import java.lang.reflect.*; + +import java.security.*; +import java.security.cert.*; +import java.security.spec.*; +import java.security.interfaces.*; +import java.math.BigInteger; + +import javax.crypto.*; +import javax.crypto.spec.*; + +public class SecretKeysBasic extends PKCS11Test { + + private static final char SEP = File.separatorChar; + private static char[] tokenPwd; + private static final char[] nssPwd = + new char[]{'t', 'e', 's', 't', '1', '2'}; + private static final char[] solarisPwd = + new char[]{'p', 'i', 'n'}; + private static SecretKey sk1; + private static SecretKey sk2; + private static SecretKey softkey; + private static KeyStore ks; + private static final String KS_TYPE = "PKCS11"; + private static Provider provider; + + public static void main(String[] args) throws Exception { + main(new SecretKeysBasic()); + } + + public void main(Provider p) throws Exception { + this.provider = p; + + // create secret key + byte[] keyVal = new byte[16]; + (new SecureRandom()).nextBytes(keyVal); + // NSS will throw CKR_HOST_MEMORY if calling C_DecryptInit w/ + // (keyVal[0] == 0) + if (keyVal[0] == 0) { + keyVal[0] = 1; + } + softkey = new SecretKeySpec(keyVal, "AES"); + dumpKey("softkey", softkey); + + KeyGenerator kg = KeyGenerator.getInstance("DESede", provider); + sk1 = kg.generateKey(); + dumpKey("skey1", sk1); + sk2 = kg.generateKey(); + dumpKey("skey2", sk2); + + String token = System.getProperty("TOKEN"); + + if (token == null || token.length() == 0) { + System.out.println("Error: missing TOKEN system property"); + throw new Exception("token arg required"); + } + + if ("nss".equals(token)) { + tokenPwd = nssPwd; + } else if ("solaris".equals(token)) { + tokenPwd = solarisPwd; + } + + int testnum = 1; + doTest(); + } + + private static boolean checkSecretKeyEntry(String alias, + SecretKey expected, + boolean saveBeforeCheck) + throws Exception { + if (saveBeforeCheck) { + ks.setKeyEntry(alias, expected, null, null); + } + SecretKey result = (SecretKey) (ks.getKey(alias, null)); + String keyEncFormat = result.getFormat(); + if (keyEncFormat == null) { + // sensitive or un-extractable keys - verify by encrypt/decrypt + byte[] data = new byte[64]; + Cipher c = + Cipher.getInstance(result.getAlgorithm() + "/CBC/NoPadding", + provider); + c.init(Cipher.ENCRYPT_MODE, expected); + byte[] encOut = c.doFinal(data); + c.init(Cipher.DECRYPT_MODE, result, c.getParameters()); + byte[] decOut = c.doFinal(encOut); + if (!Arrays.equals(data, decOut)) { + return false; + } + } else if (keyEncFormat.toUpperCase().equals("RAW")) { + if (!Arrays.equals(result.getEncoded(), expected.getEncoded())) { + dumpKey("\texpected:", expected); + dumpKey("\treturns:", result); + return false; + } + } + return true; + } + + private static void dumpKey(String info, SecretKey key) { + System.out.println(info + "> " + key); + System.out.println("\tALGO=" + key.getAlgorithm()); + if (key.getFormat() != null) { + System.out.println("\t[" + key.getFormat() + "] VALUE=" + + new BigInteger(key.getEncoded())); + } else { + System.out.println("\tVALUE=n/a"); + } + } + + private static void doTest() throws Exception { + if (ks == null) { + ks = KeyStore.getInstance(KS_TYPE, provider); + ks.load(null, tokenPwd); + } + + System.out.println("Number of entries: " + ks.size()); + if (ks.size() != 0) { + System.out.println("Deleting entries under aliases: "); + for (Enumeration aliases = ks.aliases(); + aliases.hasMoreElements();) { + String alias = aliases.nextElement(); + System.out.println("\t" + alias); + ks.deleteEntry(alias); + } + } + + String alias = "testSKey"; + + boolean testResult = checkSecretKeyEntry(alias, softkey, true); + if (!testResult) { + System.out.println("FAILURE: setKey() w/ softSecretKey failed"); + } + + if (!checkSecretKeyEntry(alias, sk1, true)) { + testResult = false; + System.out.println("FAILURE: setKey() w/ skey1 failed"); + } + if (!checkSecretKeyEntry(alias, sk2, true)) { + testResult = false; + System.out.println("FAILURE: setKey() w/ skey2 failed"); + } + + ks.store(null); + System.out.println("Reloading keystore..."); + + ks.load(null, "whatever".toCharArray()); + if (ks.size() != 1) { + System.out.println("FAILURE: reload#1 ks.size() != 1"); + } + if (!checkSecretKeyEntry(alias, sk2, false)) { + testResult = false; + System.out.println("FAILURE: reload#1 ks entry check failed"); + } + + ks.deleteEntry(alias); + ks.store(null); + + System.out.println("Reloading keystore..."); + ks.load(null, "whatever".toCharArray()); + if (ks.size() != 0) { + testResult = false; + System.out.println("FAILURE: reload#2 ks.size() != 0"); + } + if (!testResult) { + throw new Exception("One or more test failed!"); + } + } +} diff --git a/test/sun/security/pkcs11/KeyStore/SecretKeysBasic.sh b/test/sun/security/pkcs11/KeyStore/SecretKeysBasic.sh new file mode 100644 index 0000000000000000000000000000000000000000..7928a77ce386805b680b630fbebb5f45581a487d --- /dev/null +++ b/test/sun/security/pkcs11/KeyStore/SecretKeysBasic.sh @@ -0,0 +1,164 @@ +# +# Copyright 2008 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +# @test +# @bug 6599979 +# @summary Ensure that re-assigning the alias works +# +# @run shell SecretKeysBasic.sh +# +# To run by hand: +# %sh SecretKeysBasic.sh +# +# Note: +# . test only runs on solaris at the moment + +# set a few environment variables so that the shell-script can run stand-alone +# in the source directory + +# if running by hand on windows, change TESTSRC and TESTCLASSES to "." +if [ "${TESTSRC}" = "" ] ; then + TESTSRC=`pwd` +fi +if [ "${TESTCLASSES}" = "" ] ; then + TESTCLASSES=`pwd` +fi + +# if running by hand on windows, change this to appropriate value +if [ "${TESTJAVA}" = "" ] ; then + TESTJAVA="/net/shimmer/export/valeriep/jdk7/build/solaris-sparc" +fi +echo TESTSRC=${TESTSRC} +echo TESTCLASSES=${TESTCLASSES} +echo TESTJAVA=${TESTJAVA} +echo "" + +#DEBUG=sunpkcs11,pkcs11keystore + +echo DEBUG=${DEBUG} +echo "" + +OS=`uname -s` +case "$OS" in + SunOS ) + FS="/" + PS=":" + SCCS="${FS}usr${FS}ccs${FS}bin${FS}sccs" + CP="${FS}bin${FS}cp -f" + RM="${FS}bin${FS}rm -rf" + MKDIR="${FS}bin${FS}mkdir -p" + CHMOD="${FS}bin${FS}chmod" + ;; + * ) + echo "Unsupported System ${OS} - Test only runs on Solaris" + exit 0; + ;; +esac + +TOKENS="nss solaris" +STATUS=0 +for token in ${TOKENS} +do + +if [ ${token} = "nss" ] +then + # make cert/key DBs writable if token is NSS + ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}cert8.db ${TESTCLASSES} + ${CHMOD} +w ${TESTCLASSES}${FS}cert8.db + + ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}key3.db ${TESTCLASSES} + ${CHMOD} +w ${TESTCLASSES}${FS}key3.db + USED_FILE_LIST="${TESTCLASSES}${FS}cert8.db ${TESTCLASSES}${FS}key3.db" +elif [ ${token} = "solaris" ] +then + OS_VERSION=`uname -r` + case "${OS_VERSION}" in + 5.1* ) + SOFTTOKEN_DIR=${TESTCLASSES} + export SOFTTOKEN_DIR + ;; + * ) + echo "Unsupported Version ${OS_VERSION} - Test only runs on Solaris" + exit 0; + ;; + esac + + # copy keystore into write-able location + if [ -d ${TESTCLASSES}${FS}pkcs11_softtoken ] + then + echo "Removing old pkcs11_keystore, creating new pkcs11_keystore" + + echo ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken + ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken + fi + echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private + ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private + + echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public + ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public + + echo ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \ + ${TESTCLASSES}${FS}pkcs11_softtoken + ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \ + ${TESTCLASSES}${FS}pkcs11_softtoken + + echo ${CHMOD} +w ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info + ${CHMOD} 600 ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info + USED_FILE_LIST="${TESTCLASSES}${FS}pkcs11_softtoken" +fi + +cd ${TESTCLASSES} +${TESTJAVA}${FS}bin${FS}javac \ + -classpath ${TESTCLASSES} \ + -d ${TESTCLASSES} \ + ${TESTSRC}${FS}SecretKeysBasic.java + +# run test +cd ${TESTSRC} +${TESTJAVA}${FS}bin${FS}java \ + -DDIR=${TESTSRC}${FS}BasicData${FS} \ + -classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar \ + -DCUSTOM_DB_DIR=${TESTCLASSES} \ + -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${token}.txt \ + -DNO_DEFAULT=true \ + -DNO_DEIMOS=true \ + -DTOKEN=${token} \ + -Djava.security.debug=${DEBUG} \ + SecretKeysBasic + +# -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${token}.txt \ + +# save error status +if [ $? != 0 ] +then + echo "Test against " ${token} " Failed!" + STATUS=1 +fi + +# clean up +${RM} ${USED_FILE_LIST} + +done + +# return +exit ${STATUS} diff --git a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/AsyncSSLSocketClose.java b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/AsyncSSLSocketClose.java new file mode 100644 index 0000000000000000000000000000000000000000..21fe5303a6ec4eb404e58b71a097fa490d339d91 --- /dev/null +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/AsyncSSLSocketClose.java @@ -0,0 +1,116 @@ +/* + * Copyright 2007 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6447412 + * @summary Issue with socket.close() for ssl sockets when poweroff on + * other system + */ + +import javax.net.ssl.*; +import java.io.*; + +public class AsyncSSLSocketClose implements Runnable +{ + SSLSocket socket; + SSLServerSocket ss; + + // Where do we find the keystores? + static String pathToStores = "../../../../../../../etc"; + static String keyStoreFile = "keystore"; + static String trustStoreFile = "truststore"; + static String passwd = "passphrase"; + + public static void main(String[] args) { + String keyFilename = + System.getProperty("test.src", "./") + "/" + pathToStores + + "/" + keyStoreFile; + String trustFilename = + System.getProperty("test.src", "./") + "/" + pathToStores + + "/" + trustStoreFile; + + System.setProperty("javax.net.ssl.keyStore", keyFilename); + System.setProperty("javax.net.ssl.keyStorePassword", passwd); + System.setProperty("javax.net.ssl.trustStore", trustFilename); + System.setProperty("javax.net.ssl.trustStorePassword", passwd); + + new AsyncSSLSocketClose(); + } + + public AsyncSSLSocketClose() { + try { + SSLServerSocketFactory sslssf = + (SSLServerSocketFactory)SSLServerSocketFactory.getDefault(); + ss = (SSLServerSocket) sslssf.createServerSocket(0); + + SSLSocketFactory sslsf = + (SSLSocketFactory)SSLSocketFactory.getDefault(); + socket = (SSLSocket)sslsf.createSocket("localhost", + ss.getLocalPort()); + SSLSocket serverSoc = (SSLSocket) ss.accept(); + ss.close(); + + (new Thread(this)).start(); + serverSoc.startHandshake(); + + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + + socket.setSoLinger(true, 10); + System.out.println("Calling Socket.close"); + socket.close(); + System.out.println("ssl socket get closed"); + System.out.flush(); + + } catch (IOException e) { + e.printStackTrace(); + } + + } + + // block in write + public void run() { + try { + byte[] ba = new byte[1024]; + for (int i=0; i Foo.java + $TESTJAVA/bin/javac Foo.java + if [ $? -ne 0 ]; then + printf "Error: compilation of Foo.java failed\n" + exit 1 + fi + printf "Main-Class: Bar\n" > manifest + $TESTJAVA/bin/jar -cvfm some.jar manifest Foo.class + if [ ! -f some.jar ]; then + printf "Error: did not find some.jar\n" + exit 1 + fi + + # test a non-existence main-class using -jar + mess="`$TESTJAVA/bin/java -jar some.jar 2>&1 1>/dev/null`" + echo $mess | grep 'Bar' 2>&1 > /dev/null + if [ $? -ne 0 ]; then + printf "Error: did not find main class missing message\n" + exit 1 + fi + + # test a non-existent main-class using classpath + mess="`$TESTJAVA/bin/java -cp some.jar Bar 2>&1 1>/dev/null`" + echo $mess | grep 'Bar' 2>&1 > /dev/null + if [ $? -ne 0 ]; then + printf "Error: did not find main class missing message\n" + exit 1 + fi + + # cleanup + rm -f some.jar Foo.* manifest +} + # # Main processing: # @@ -117,6 +155,7 @@ TestCP javac -cp TestCP javac -classpath TestXUsage TestHelp +TestMissingMainClass # # Tests for 6214916