--- a/.hgtags Fri Apr 18 07:51:43 2008 -0400
+++ b/.hgtags Wed Apr 23 06:35:28 2008 -0400
@@ -1,1 +1,2 @@
1cc8dd79fd1cd13d36b385196271a29632c67c3b jdk7-b24
+bf2517e15f0c0f950e5b3143c4ca11e2df73dcc1 jdk7-b25
--- a/.hgtags-top-repo Fri Apr 18 07:51:43 2008 -0400
+++ b/.hgtags-top-repo Wed Apr 23 06:35:28 2008 -0400
@@ -1,1 +1,2 @@
cfeea66a3fa8ca3686a7cfa2d0ce8ab0169f168d jdk7-b24
+cbc8ad9dd0e085a607427ea35411990982f19a36 jdk7-b25
--- a/corba/.hgtags Fri Apr 18 07:51:43 2008 -0400
+++ b/corba/.hgtags Wed Apr 23 06:35:28 2008 -0400
@@ -1,1 +1,2 @@
55540e827aef970ecc010b7e06b912d991c8e3ce jdk7-b24
+5e61d5df62586474414d1058e9186441aa908f51 jdk7-b25
--- a/hotspot/.hgtags Fri Apr 18 07:51:43 2008 -0400
+++ b/hotspot/.hgtags Wed Apr 23 06:35:28 2008 -0400
@@ -1,1 +1,2 @@
a61af66fc99eb5ec9d50c05b0c599757b1289ceb jdk7-b24
+7836be3e92d0a4f9ee7566f602c91f5609534e66 jdk7-b25
--- a/jaxp/.hgtags Fri Apr 18 07:51:43 2008 -0400
+++ b/jaxp/.hgtags Wed Apr 23 06:35:28 2008 -0400
@@ -1,1 +1,2 @@
6ce5f4757bde08f7470cbb9f0b46da8f2f3d4f56 jdk7-b24
+a3b3ba7d6034dc754b51ddc3d281399ac1cae5f1 jdk7-b25
--- a/jaxws/.hgtags Fri Apr 18 07:51:43 2008 -0400
+++ b/jaxws/.hgtags Wed Apr 23 06:35:28 2008 -0400
@@ -1,1 +1,2 @@
0961a4a211765fea071b8dac419003ee0c3d5973 jdk7-b24
+59fd8224ba2da5c2d8d4c68e33cf33ab41ce8de0 jdk7-b25
--- a/jdk/.hgtags Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/.hgtags Wed Apr 23 06:35:28 2008 -0400
@@ -1,1 +1,2 @@
37a05a11f281b4d238e2f9e7ebb67c63f64d0e77 jdk7-b24
+75fca0b0ab83ab1392e615910cea020f66535390 jdk7-b25
--- a/jdk/make/com/sun/crypto/provider/Makefile Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/com/sun/crypto/provider/Makefile Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
#
UNSIGNED_DIR = $(TEMPDIR)/unsigned
+include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
+
# =====================================================
# Build the unsigned sunjce_provider.jar file.
@@ -184,44 +202,66 @@
# 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 @@
#
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 @@
#
clobber clean::
- $(RM) -r $(JAR_DESTFILE) $(TEMPDIR)
+ $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
.PHONY: build-jar jar install-jar
ifndef OPENJDK
--- a/jdk/make/common/Defs.gmk Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/common/Defs.gmk Wed Apr 23 06:35:28 2008 -0400
@@ -303,6 +303,8 @@
# 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)
--- a/jdk/make/common/Rules.gmk Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/common/Rules.gmk Wed Apr 23 06:35:28 2008 -0400
@@ -231,12 +231,14 @@
.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)
--- a/jdk/make/common/shared/Compiler-gcc.gmk Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/common/shared/Compiler-gcc.gmk Wed Apr 23 06:35:28 2008 -0400
@@ -45,10 +45,8 @@
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)")
--- a/jdk/make/common/shared/Compiler-msvc.gmk Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/common/shared/Compiler-msvc.gmk Wed Apr 23 06:35:28 2008 -0400
@@ -47,13 +47,13 @@
# 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 @@
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))
--- a/jdk/make/common/shared/Defs-control.gmk Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/common/shared/Defs-control.gmk Wed Apr 23 06:35:28 2008 -0400
@@ -69,9 +69,8 @@
# Get shared platform settings
include $(JDK_MAKE_SHARED_DIR)/Platform.gmk
-# Default output directory
+# Default directory immediately above the "build" output directory (OUTPUTDIR)
BUILD_PARENT_DIRECTORY=$(TOPDIR)
-_OUTPUTDIR=$(TOPDIR)/build/$(PLATFORM)-$(ARCH)
# Get platform specific settings
include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
--- a/jdk/make/common/shared/Defs.gmk Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/common/shared/Defs.gmk Wed Apr 23 06:35:28 2008 -0400
@@ -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
@@ -265,7 +265,9 @@
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
@@ -449,11 +451,20 @@
# 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))
--- a/jdk/make/common/shared/Sanity.gmk Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/common/shared/Sanity.gmk Wed Apr 23 06:35:28 2008 -0400
@@ -788,21 +788,17 @@
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)
+# 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:
- @-($(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 \
+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
@@ -1339,7 +1335,7 @@
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" \
--- a/jdk/make/java/java/genlocales.gmk Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/java/java/genlocales.gmk Wed Apr 23 06:35:28 2008 -0400
@@ -80,7 +80,8 @@
@$(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;
--- a/jdk/make/java/java/localegen.sh Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/java/java/localegen.sh Wed Apr 23 06:35:28 2008 -0400
@@ -29,7 +29,7 @@
# This script is to generate the supported locale list string and replace the
# LocaleDataMetaInfo-XLocales.java in <ws>/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 @@
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! -- //@\" "
--- a/jdk/make/javax/Makefile Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/javax/Makefile Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
clean clobber::
$(SUBDIRS-loop)
-#
-# Rules
-#
-include $(BUILDDIR)/common/Classes.gmk
-
--- a/jdk/make/javax/crypto/Defs-jce.gmk Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/javax/crypto/Defs-jce.gmk Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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 @@
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 @@
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
#
--- a/jdk/make/javax/crypto/Makefile Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/javax/crypto/Makefile Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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 @@
#
UNSIGNED_DIR = $(TEMPDIR)/unsigned
+include Defs-jce.gmk
+
# =====================================================
# Build the unsigned jce.jar file. Signing/obfuscation comes later.
@@ -299,7 +317,7 @@
# 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-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 @@
# 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 @@
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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/javax/others/Makefile Wed Apr 23 06:35:28 2008 -0400
@@ -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
+
--- a/jdk/make/sun/security/mscapi/Makefile Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/sun/security/mscapi/Makefile Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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 @@
$(build-warning)
endif
+include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
+
# =====================================================
# Build the unsigned sunmscapi.jar file.
@@ -200,14 +219,26 @@
# 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 @@
#
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 @@
#
clobber clean::
- $(RM) -r $(JAR_DESTFILE) $(TEMPDIR)
+ $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
.PHONY: build-jar jar install-jar
ifndef OPENJDK
--- a/jdk/make/sun/security/pkcs11/Makefile Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/sun/security/pkcs11/Makefile Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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 @@
$(build-warning)
endif
+include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
+
# =====================================================
# Build the unsigned sunpkcs11.jar file.
@@ -200,14 +219,26 @@
# 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 @@
#
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 @@
#
clobber clean::
- $(RM) -r $(JAR_DESTFILE) $(TEMPDIR)
+ $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
.PHONY: build-jar jar install-jar
ifndef OPENJDK
--- a/jdk/make/tools/Makefile Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/tools/Makefile Wed Apr 23 06:35:28 2008 -0400
@@ -40,6 +40,7 @@
dir_diff \
dtdbuilder \
fontchecker \
+ freetypecheck \
generate_break_iterator \
GenerateCharacter \
generatecurrencydata \
@@ -58,4 +59,5 @@
clean clobber::
$(RM) -r $(BUILDTOOLCLASSDIR)
$(RM) -r $(BUILDTOOLJARDIR)
+ $(RM) -r $(BUILDTOOLBINDIR)
--- a/jdk/make/tools/freetypecheck/Makefile Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/make/tools/freetypecheck/Makefile Wed Apr 23 06:35:28 2008 -0400
@@ -22,55 +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)
+# Default name
+FT_TEST = $(BUILDTOOLBINDIR)/freetype_versioncheck$(EXE_SUFFIX)
-all: $(FT_TEST_PATH)
+# Used on openjdk only
+ifeq ($(OPENJDK),true)
# Start with CFLAGS (which gets us the required -xarch setting on solaris)
ifeq ($(PLATFORM), windows)
- FT_OPTIONS =
+ 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 = $(CFLAGS)
-endif
-
-FT_OPTIONS += -I$(FT_HEADERS) -I$(FT_HEADERS)/freetype2
-FT_OPTIONS += $(XARCH)
-
-#add runtime library search path
-ifeq ($(PLATFORM), windows)
- FREETYPE_LIB=$(FT_LIB)/freetype.lib
- FREETYPE_DLL=$(FT_LIB)/freetype.dll
- DFLAG=/D
-else
- FT_OPTIONS += -L$(FT_LIB)
- DFLAG = -D
-
- #add runtime lib search path to ensure test will be runnable
+ 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 += $(DFLAG)REQUIRED_FREETYPE_VERSION=$(REQUIRED_FREETYPE_VERSION)
+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))
-# 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))
+# Create test program
+all: $(FT_TEST)
+ @$(FT_TEST)
+
+# 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)
+
--- a/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java Wed Apr 23 06:35:28 2008 -0400
@@ -34,8 +34,6 @@
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.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 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 @@
List<String> result = new ArrayList<String>(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
}
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java Wed Apr 23 06:35:28 2008 -0400
@@ -107,10 +107,7 @@
private MBeanAnalyzer(Class<?> mbeanInterface,
MBeanIntrospector<M> 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 @@
// Introspect the mbeanInterface and initialize this object's maps.
//
- private void initMaps(Class<?> mbeanInterface,
+ private void initMaps(Class<?> mbeanType,
MBeanIntrospector<M> introspector) throws Exception {
- final Method[] methodArray = mbeanInterface.getMethods();
-
- final List<Method> methods = eliminateCovariantMethods(methodArray);
+ final List<Method> methods1 = introspector.getMethods(mbeanType);
+ final List<Method> 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 @@
but existing code may depend on it and users may be used to seeing
operations or attributes appear in a particular order. */
static List<Method>
- eliminateCovariantMethods(Method[] methodArray) {
+ eliminateCovariantMethods(List<Method> 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<Method> overridden = newSet();
for (int i=1;i<len;i++) {
@@ -259,7 +255,7 @@
}
}
- final List<Method> methods = newList(Arrays.asList(methodArray));
+ final List<Method> methods = newList(startMethods);
methods.removeAll(overridden);
return methods;
}
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java Wed Apr 23 06:35:28 2008 -0400
@@ -34,6 +34,7 @@
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 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<Method> getMethods(final Class<?> mbeanType) throws Exception {
+ return Arrays.asList(mbeanType.getMethods());
+ }
final PerInterface<M> getPerInterface(Class<?> mbeanInterface)
throws NotCompliantMBeanException {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/NotificationMBeanSupport.java Wed Apr 23 06:35:28 2008 -0400
@@ -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;
+
+/**
+ * <p>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 <T extends Notification> NotificationMBeanSupport(T n)
+ throws NotCompliantMBeanException {
+ super(n, Util.<Class<T>>cast(n.getClass()));
+ }
+
+ @Override
+ MBeanIntrospector<Method> getMBeanIntrospector() {
+ return introspector;
+ }
+
+ private static class Introspector extends StandardMBeanIntrospector {
+ @Override
+ void checkCompliance(Class<?> mbeanType) {}
+
+ @Override
+ List<Method> getMethods(final Class<?> mbeanType)
+ throws Exception {
+ List<Method> methods = new ArrayList<Method>();
+ 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<Method> introspector =
+ new Introspector();
+}
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java Wed Apr 23 06:35:28 2008 -0400
@@ -438,7 +438,7 @@
c.getClassLoader() == null);
final List<Method> methods =
- MBeanAnalyzer.eliminateCovariantMethods(c.getMethods());
+ MBeanAnalyzer.eliminateCovariantMethods(Arrays.asList(c.getMethods()));
final SortedMap<String,Method> getterMap = newSortedMap();
/* Select public methods that look like "T getX()" or "boolean
@@ -1118,11 +1118,11 @@
final Class<ConstructorProperties> 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<Constructor> annotatedConstrList = newList();
- for (Constructor constr : constrs) {
+ List<Constructor<?>> annotatedConstrList = newList();
+ for (Constructor<?> constr : constrs) {
if (Modifier.isPublic(constr.getModifiers())
&& constr.getAnnotation(propertyNamesClass) != null)
annotatedConstrList.add(constr);
@@ -1152,7 +1152,7 @@
// Also remember the set of properties in that constructor
// so we can test unambiguity.
Set<BitSet> getterIndexSets = newSet();
- for (Constructor constr : annotatedConstrList) {
+ for (Constructor<?> constr : annotatedConstrList) {
String[] propertyNames =
constr.getAnnotation(propertyNamesClass).value();
@@ -1309,10 +1309,10 @@
}
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;
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java Wed Apr 23 06:35:28 2008 -0400
@@ -415,17 +415,8 @@
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) {
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Util.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Util.java Wed Apr 23 06:35:28 2008 -0400
@@ -38,6 +38,8 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
public class Util {
static <K, V> Map<K, V> newMap() {
@@ -85,6 +87,14 @@
return new ArrayList<E>(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
--- a/jdk/src/share/classes/com/sun/management/package.html Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/com/sun/management/package.html Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-CTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
--- a/jdk/src/share/classes/java/beans/MetaData.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/java/beans/MetaData.java Wed Apr 23 06:35:28 2008 -0400
@@ -1553,7 +1553,7 @@
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 @@
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;
--- a/jdk/src/share/classes/java/lang/instrument/Instrumentation.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/java/lang/instrument/Instrumentation.java Wed Apr 23 06:35:28 2008 -0400
@@ -636,7 +636,11 @@
* @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 <code>null</code> or the empty string, then
+ * failed native method resolutions are not retried for
+ * this transformer.
* @throws java.lang.NullPointerException if passed a <code>null</code> transformer.
* @throws java.lang.UnsupportedOperationException if the current configuration of
* the JVM does not allow setting a native method prefix
--- a/jdk/src/share/classes/javax/management/MBeanServer.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/javax/management/MBeanServer.java Wed Apr 23 06:35:28 2008 -0400
@@ -50,7 +50,7 @@
* server. A Java object cannot be registered in the MBean server
* unless it is a JMX compliant MBean.</p>
*
- * <p>When an MBean is registered or unregistered in the MBean server
+ * <p id="notif">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 @@
*/
public interface MBeanServer extends MBeanServerConnection {
- // doc comment inherited from MBeanServerConnection
+ /**
+ * {@inheritDoc}
+ * <p>If this method successfully creates an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
+ */
public ObjectInstance createMBean(String className, ObjectName name)
throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException,
NotCompliantMBeanException;
- // doc comment inherited from MBeanServerConnection
+ /**
+ * {@inheritDoc}
+ * <p>If this method successfully creates an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
+ */
public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName)
throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException,
NotCompliantMBeanException, InstanceNotFoundException;
- // doc comment inherited from MBeanServerConnection
+ /**
+ * {@inheritDoc}
+ * <p>If this method successfully creates an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
+ */
public ObjectInstance createMBean(String className, ObjectName name,
Object params[], String signature[])
throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException,
NotCompliantMBeanException;
- // doc comment inherited from MBeanServerConnection
+ /**
+ * {@inheritDoc}
+ * <p>If this method successfully creates an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
+ */
public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName, Object params[],
String signature[])
@@ -287,12 +303,15 @@
NotCompliantMBeanException, InstanceNotFoundException;
/**
- * Registers a pre-existing object as an MBean with the MBean
+ * <p>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.</p>
+ *
+ * <p>If this method successfully registers an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
*
* @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 @@
throws InstanceAlreadyExistsException, MBeanRegistrationException,
NotCompliantMBeanException;
- // doc comment inherited from MBeanServerConnection
+ /**
+ * {@inheritDoc}
+ *
+ * <p>If this method successfully unregisters an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
+ */
public void unregisterMBean(ObjectName name)
throws InstanceNotFoundException, MBeanRegistrationException;
--- a/jdk/src/share/classes/javax/management/ObjectName.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/javax/management/ObjectName.java Wed Apr 23 06:35:28 2008 -0400
@@ -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;
@@ -1386,12 +1387,7 @@
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());
}
/**
@@ -1950,14 +1946,7 @@
*
* @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 <===================================
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/javax/management/QueryNotificationFilter.java Wed Apr 23 06:35:28 2008 -0400
@@ -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;
+
+/**
+ * <p>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.</p>
+ *
+ * <!-- <p>Because this class was introduced in version 2.0 of the JMX API,
+ * it may not be present on a remote JMX agent that is running an earlier
+ * version. The method {@link JMX#addListenerWithFilter JMX.addListenerWithFilter}
+ * can be used when you cannot be sure whether this class is present in the
+ * agent you are connecting to.</p> -->
+ *
+ * <p>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</p>
+ *
+ * <pre>
+ * NotificationFilter filter =
+ * new QueryNotificationFilter("Type = 'com.example.mytype'");
+ * </pre>
+ *
+ * <p>or equivalently</p>
+ *
+ * <pre>
+ * NotificationFilter filter =
+ * new QueryNotificationFilter(
+ * Query.eq(Query.attr("Type"), Query.value("com.example.mytype")));
+ * </pre>
+ *
+ * <p>(This particular example could also use
+ * {@link NotificationFilterSupport}.)</p>
+ *
+ * <p>Here are some other examples of filters you can specify with this class.</p>
+ *
+ * <dl>
+ *
+ * <dt>{@code QueryNotificationFilter("Type = 'com.example.type1' or
+ * Type = 'com.example.type2'")}
+ * <dd>Notifications where the type is either of the given strings.
+ *
+ * <dt>{@code QueryNotificationFilter("Type in ('com.example.type1',
+ * 'com.example.type2')")}
+ * <dd>Another way to write the previous example.
+ *
+ * <dt>{@code QueryNotificationFilter("SequenceNumber > 1000")}
+ * <dd>Notifications where the {@linkplain Notification#getSequenceNumber()
+ * sequence number} is greater than 1000.
+ *
+ * <dt>{@code QueryNotificationFilter(AttributeChangeNotification.class, null)}
+ * <dd>Notifications where the notification class is
+ * {@link AttributeChangeNotification} or a subclass of it.
+ *
+ * <dt>{@code QueryNotificationFilter(AttributeChangeNotification.class,
+ * "AttributeName = 'Size'")}
+ * <dd>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}.
+ *
+ * <dt>{@code QueryNotificationFilter(AttributeChangeNotification.class,
+ * "AttributeName = 'Size' and NewValue - OldValue > 100")}
+ * <dd>As above, but the difference between the
+ * {@linkplain AttributeChangeNotification#getNewValue() new value} and the
+ * {@linkplain AttributeChangeNotification#getOldValue() old value} must be
+ * greater than 100.
+ *
+ * <dt>{@code QueryNotificationFilter("like 'com.example.mydomain:*'")}
+ * <dd>Notifications where the {@linkplain Notification#getSource() source}
+ * is an ObjectName that matches the pattern.
+ *
+ * <dt>{@code QueryNotificationFilter("Source.canonicalName like
+ * 'com.example.mydomain:%'")}
+ * <dd>Another way to write the previous example.
+ *
+ * <dt>{@code QueryNotificationFilter(MBeanServerNotification.class,
+ * "Type = 'JMX.mbean.registered' and MBeanName.canonicalName like
+ * 'com.example.mydomain:%'")}
+ * <dd>Notifications of class {@link MBeanServerNotification} representing
+ * an object registered in the domain {@code com.example.mydomain}.
+ *
+ * </dl>
+ *
+ * <h4>How it works</h4>
+ *
+ * <p>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}.</p>
+ *
+ * <p>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.</p>
+ *
+ * <p>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.</p>
+ *
+ * <p>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}.</p>
+ *
+ * <p>Query evaluation usually involves calls to the methods of {@code
+ * MBeanServer}. The methods have the following behavior:</p>
+ *
+ * <ul>
+ * <li>The {@link MBeanServer#getAttribute getAttribute} method returns the
+ * value of the corresponding property.
+ * <li>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}.
+ * <li>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.
+ * </ul>
+ *
+ * <p>These are the only {@code MBeanServer} methods that are needed to
+ * evaluate standard queries. The behavior of the other {@code MBeanServer}
+ * methods is unspecified.</p>
+ *
+ * @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));
+ }
+
+ /**
+ * <p>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}.</p>
+ *
+ * @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<? extends Notification> notifClass, String query) {
+ this(Query.and(Query.isInstanceOf(Query.value(notNull(notifClass).getName())),
+ Query.fromString(query)));
+ }
+
+ private static <T> 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<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
+ Set<ObjectName> 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<ObjectName> 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();
+ }
+ }
+}
--- a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Wed Apr 23 06:35:28 2008 -0400
@@ -48,6 +48,7 @@
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 @@
* 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 @@
}
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
+ Vector<String> 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,
--- a/jdk/src/share/classes/sun/instrument/InstrumentationImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/sun/instrument/InstrumentationImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -303,39 +303,78 @@
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.getDeclaredMethod(methodname,
+ new Class[] { String.class });
+ } catch (NoSuchMethodException x) {
+ // 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 });
+ m = javaAgentClass.getMethod( methodname,
+ new Class[] {
+ String.class,
+ java.lang.instrument.Instrumentation.class
+ }
+ );
+ twoArgAgent = true;
} catch (NoSuchMethodException x) {
- // Neither method exists so we throw the first NoSuchMethodException
- // as per 5.0
+ // 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
--- a/jdk/src/share/classes/sun/management/Flag.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/sun/management/Flag.java Wed Apr 23 06:35:28 2008 -0400
@@ -64,7 +64,8 @@
}
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) {
--- a/jdk/src/share/classes/sun/net/www/protocol/http/NegotiatorImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/NegotiatorImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -91,9 +91,10 @@
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,
--- a/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.spec.*;
import sun.nio.ch.DirectBuffer;
-
import sun.security.pkcs11.wrapper.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
@@ -43,8 +42,8 @@
* 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 @@
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 @@
// 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;
+ 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];
}
- paddingType = PAD_PKCS5;
- // XXX PKCS#5 not yet implemented
- throw new NoSuchPaddingException("pkcs5");
} else {
throw new NoSuchPaddingException("Unsupported padding " + padding);
}
@@ -175,7 +251,7 @@
// 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 @@
}
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 @@
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 @@
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 @@
} else {
if (iv.length != blockSize) {
throw new InvalidAlgorithmParameterException
- ("IV length must match block size");
+ ("IV length must match block size");
}
}
}
@@ -331,63 +408,43 @@
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 @@
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 @@
}
// see JCE spec
+ @Override
protected int engineUpdate(ByteBuffer inBuffer, ByteBuffer outBuffer)
throws ShortBufferException {
return implUpdate(inBuffer, outBuffer);
@@ -422,14 +481,15 @@
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 @@
}
// 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 @@
}
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 @@
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);
+ 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);
+ }
}
- bytesProcessed += inLen;
- if (!inPosChanged) {
- inBuffer.position(inBuffer.position() + inLen);
- }
+ 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 @@
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 @@
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 @@
}
// 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 @@
}
}
+ 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;
+ }
}
--- a/jdk/src/share/classes/sun/security/pkcs11/P11KeyGenerator.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11KeyGenerator.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
// 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 @@
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:
+ keySize = 128;
keyType = CKK_AES;
- keySize = 128;
- significantKeySize = 128;
break;
case (int)CKM_RC4_KEY_GEN:
+ keySize = 128;
keyType = CKK_RC4;
- keySize = 128;
- validateKeySize = true;
break;
case (int)CKM_BLOWFISH_KEY_GEN:
+ keySize = 128;
keyType = CKK_BLOWFISH;
- keySize = 128;
- validateKeySize = true;
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 @@
// 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
--- a/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
// 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 @@
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 @@
SecretKey skey = ske.getSecretKey();
try {
- // first see if the key already exists.
- // if so, update the CKA_LABEL
- if (!updateSkey(alias)) {
+ // first check if the key already exists
+ AliasInfo aliasInfo = aliasMap.get(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)
+ if (aliasInfo != null) {
+ engineDeleteEntry(alias);
+ }
+ storeSkey(alias, ske);
- engineDeleteEntry(alias);
- storeSkey(alias, ske);
- }
} catch (PKCS11Exception pe) {
throw new KeyStoreException(pe);
}
@@ -1396,41 +1389,6 @@
}
}
- /**
- * 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 @@
}
}
- 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 @@
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 @@
// if there are duplicates (either between secret keys,
// or between a secret key and another object),
// throw an exception
- HashSet<String> sKeySet = new HashSet<String>();
+ HashMap<String, AliasInfo> sKeyMap =
+ new HashMap<String, AliasInfo>();
attrs = new CK_ATTRIBUTE[] {
ATTR_SKEY_TOKEN_TRUE,
@@ -2507,8 +2420,8 @@
// 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 @@
ArrayList<AliasInfo> matchedCerts =
mapPrivateKeys(pkeyIDs, certMap);
boolean sharedLabel = mapCerts(matchedCerts, certMap);
- mapSecretKeys(sKeySet);
+ mapSecretKeys(sKeyMap);
return sharedLabel;
@@ -2547,7 +2460,7 @@
HashMap<String, HashSet<AliasInfo>> certMap)
throws PKCS11Exception, CertificateException {
- // global alias map
+ // reset global alias map
aliasMap = new HashMap<String, AliasInfo>();
// list of matched certs that we will return
@@ -2722,18 +2635,17 @@
* If the secret key shares a CKA_LABEL with another entry,
* throw an exception
*/
- private void mapSecretKeys(HashSet<String> sKeySet)
+ private void mapSecretKeys(HashMap<String, AliasInfo> 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() {
--- a/jdk/src/share/classes/sun/security/pkcs11/P11RSACipher.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11RSACipher.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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 @@
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 @@
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 @@
// 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 @@
};
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);
}
--- a/jdk/src/share/classes/sun/security/pkcs11/P11SecretKeyFactory.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11SecretKeyFactory.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
/**
* 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 @@
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 @@
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 @@
}
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");
+ 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);
}
- 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");
- }
- 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 @@
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");
}
--- a/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
// 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
--- a/jdk/src/share/classes/sun/security/validator/EndEntityChecker.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/classes/sun/security/validator/EndEntityChecker.java Wed Apr 23 06:35:28 2008 -0400
@@ -87,6 +87,9 @@
// 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 @@
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);
--- a/jdk/src/share/instrument/InvocationAdapter.c Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/instrument/InvocationAdapter.c Wed Apr 23 06:35:28 2008 -0400
@@ -626,6 +626,7 @@
jvmtiError jvmtierr;
jvmtierr = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, jarfile);
+ check_phase_ret_1(jvmtierr);
if (jvmtierr == JVMTI_ERROR_NONE) {
return 0;
@@ -634,6 +635,7 @@
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 @@
/* 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 :
--- a/jdk/src/share/instrument/JPLISAgent.c Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/instrument/JPLISAgent.c Wed Apr 23 06:35:28 2008 -0400
@@ -179,6 +179,7 @@
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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
jvmtierror = (*jvmtienv)->SetEventCallbacks( jvmtienv,
&callbacks,
sizeof(callbacks));
+ check_phase_ret_false(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
@@ -632,6 +644,7 @@
JVMTI_DISABLE,
JVMTI_EVENT_VM_INIT,
NULL /* all threads */);
+ check_phase_ret_false(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
}
@@ -642,6 +655,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
jboolean
isRetransformClassesSupported(JNIEnv * jnienv, JPLISAgent * agent) {
- return retransformableEnvironment(agent) != NULL;
+ return agent->mRetransformEnvironment.mIsRetransformer;
}
void
@@ -1075,6 +1098,12 @@
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 @@
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 @@
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 @@
classLoader,
&classCount,
&classes);
+ check_phase_ret_blob(jvmtierror, localArray);
errorOccurred = (jvmtierror != JVMTI_ERROR_NONE);
jplis_assert(!errorOccurred);
@@ -1311,6 +1349,7 @@
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 @@
} else {
jvmtierror = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, platformChars);
}
+ check_phase_ret(jvmtierror);
if ( jvmtierror != JVMTI_ERROR_NONE ) {
createAndThrowThrowableFromJVMTIErrorCode(jnienv, jvmtierror);
@@ -1450,6 +1490,7 @@
}
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++) {
--- a/jdk/src/share/instrument/JPLISAgent.h Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/instrument/JPLISAgent.h Wed Apr 23 06:35:28 2008 -0400
@@ -266,6 +266,48 @@
#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 */
--- a/jdk/src/share/instrument/JarFacade.c Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/instrument/JarFacade.c Wed Apr 23 06:35:28 2008 -0400
@@ -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 <ctype.h>
+#endif /* _WIN32 */
#include <string.h>
#include <stdlib.h>
@@ -45,11 +53,37 @@
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;
--- a/jdk/src/share/instrument/Reentrancy.c Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/instrument/Reentrancy.c Wed Apr 23 06:35:28 2008 -0400
@@ -74,6 +74,7 @@
jvmtienv,
thread,
newValue);
+ check_phase_ret_blob(error, error);
#if JPLISASSERT_ENABLEASSERTIONS
assertTLSValue( jvmtienv,
@@ -96,6 +97,7 @@
jvmtienv,
thread,
&test);
+ check_phase_ret(error);
jplis_assert(error == JVMTI_ERROR_NONE);
jplis_assert(test == expected);
}
@@ -111,6 +113,7 @@
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 */
--- a/jdk/src/share/instrument/Utilities.c Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/share/instrument/Utilities.c Wed Apr 23 06:35:28 2008 -0400
@@ -46,6 +46,7 @@
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 @@
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;
}
--- a/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c Wed Apr 23 06:35:28 2008 -0400
@@ -123,7 +123,10 @@
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;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticOptions.java Wed Apr 23 06:35:28 2008 -0400
@@ -0,0 +1,61 @@
+/*
+ * 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 {
+ HotSpotDiagnosticMXBean mbean =
+ sun.management.ManagementFactory.getDiagnosticMXBean();
+ 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<VMOption> options = mbean.getDiagnosticOptions();
+ for (VMOption opt : options) {
+ System.out.println("option: "+opt.getName()+"="+opt.getValue());
+ }
+ }
+}
--- a/jdk/test/java/lang/instrument/BootClassPath/BootClassPathTest.sh Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/BootClassPath/BootClassPathTest.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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 "Running test..."
-"${JAVA}" -javaagent:"${TESTCLASSES}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain
+"${JAVA}" ${TESTVMOPTS} -javaagent:"${TESTCLASSES}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain
result=$?
echo "Cleanup..."
--- a/jdk/test/java/lang/instrument/MakeJAR2.sh Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/MakeJAR2.sh Wed Apr 23 06:35:28 2008 -0400
@@ -70,9 +70,11 @@
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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ManifestTest.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ManifestTestAgent.java Wed Apr 23 06:35:28 2008 -0400
@@ -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());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ManifestTestApp.java Wed Apr 23 06:35:28 2008 -0400
@@ -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;
+ }
+}
--- a/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java Wed Apr 23 06:35:28 2008 -0400
@@ -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
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ParallelTransformerLoader.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ParallelTransformerLoaderAgent.java Wed Apr 23 06:35:28 2008 -0400
@@ -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();
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ParallelTransformerLoaderApp.java Wed Apr 23 06:35:28 2008 -0400
@@ -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();
+ }
+ }
+}
--- a/jdk/test/java/lang/instrument/PremainClass/DummyMain.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/PremainClass/DummyMain.java Wed Apr 23 06:35:28 2008 -0400
@@ -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!");
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0001.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0010.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0011.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0100.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0101.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0110.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0111.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1000.java Wed Apr 23 06:35:28 2008 -0400
@@ -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!");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1001.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1010.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1011.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1100.java Wed Apr 23 06:35:28 2008 -0400
@@ -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!");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1101.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1110.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1111.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/NoPremainAgent.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/NoPremainAgent.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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
--- a/jdk/test/java/lang/instrument/PremainClass/PremainClassTest.sh Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/PremainClass/PremainClassTest.sh Wed Apr 23 06:35:28 2008 -0400
@@ -49,7 +49,7 @@
"$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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgent.java Wed Apr 23 06:35:28 2008 -0400
@@ -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!");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgent.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineClassWithNativeMethod.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java Wed Apr 23 06:35:28 2008 -0400
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineClassWithNativeMethodApp.java Wed Apr 23 06:35:28 2008 -0400
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvoke.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvokeAgent.java Wed Apr 23 06:35:28 2008 -0400
@@ -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;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvokeApp.java Wed Apr 23 06:35:28 2008 -0400
@@ -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});
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvokeTarget.java Wed Apr 23 06:35:28 2008 -0400
@@ -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()!");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvokeTarget_1.java Wed Apr 23 06:35:28 2008 -0400
@@ -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();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvokeTarget_2.java Wed Apr 23 06:35:28 2008 -0400
@@ -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();
+ }
+}
--- a/jdk/test/java/lang/instrument/RetransformAgent.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/RetransformAgent.java Wed Apr 23 06:35:28 2008 -0400
@@ -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
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/StressGetObjectSizeApp.java Wed Apr 23 06:35:28 2008 -0400
@@ -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);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/StressGetObjectSizeTest.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/TestClass1.java Wed Apr 23 06:35:28 2008 -0400
@@ -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()
+ {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/TestClass2.java Wed Apr 23 06:35:28 2008 -0400
@@ -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()
+ {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/TestClass3.java Wed Apr 23 06:35:28 2008 -0400
@@ -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()
+ {
+ }
+}
--- a/jdk/test/java/lang/instrument/TransformerManagementThreadAddTests.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/TransformerManagementThreadAddTests.java Wed Apr 23 06:35:28 2008 -0400
@@ -79,6 +79,12 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
// 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();
}
}
--- a/jdk/test/java/lang/instrument/TransformerManagementThreadRemoveTests.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/TransformerManagementThreadRemoveTests.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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());
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CircularityErrorTest.sh Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CircularityErrorTest.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
-C "${TESTCLASSES}" CircularityErrorTest.class
# Finally we run the test
-(cd "${TESTCLASSES}";
- $JAVA -javaagent:CircularityErrorTest.jar CircularityErrorTest)
+(cd "${TESTCLASSES}";
+ $JAVA ${TESTVMOPTS} -javaagent:CircularityErrorTest.jar CircularityErrorTest)
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh Wed Apr 23 06:35:28 2008 -0400
@@ -34,11 +34,11 @@
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 @@
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 @@
# 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)
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh Wed Apr 23 06:35:28 2008 -0400
@@ -24,7 +24,6 @@
#
-#%E
#
# Common setup for unit tests. Setups up the following variables:
#
@@ -66,7 +65,7 @@
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
-
+
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/run_tests.sh Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/run_tests.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
"$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 @@
"${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 @@
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
#
--- a/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -49,116 +49,116 @@
public class CreatePrivateActivatable
{
private static class PrivateActivatable extends Activatable
- implements ActivateMe, Runnable
+ implements ActivateMe, Runnable
{
- private PrivateActivatable(ActivationID id, MarshalledObject obj)
- throws ActivationException, RemoteException
- {
- super(id, 0);
- }
+ private PrivateActivatable(ActivationID id, MarshalledObject obj)
+ throws ActivationException, RemoteException
+ {
+ super(id, 0);
+ }
- public void ping()
- {}
+ public void ping()
+ {}
- /**
- * Spawns a thread to deactivate the object.
- */
- public void shutdown() throws Exception
- {
- (new Thread(this, "CreatePrivateActivatable$PrivateActivatable")).start();
- }
+ /**
+ * Spawns a thread to deactivate the object.
+ */
+ public void shutdown() throws Exception
+ {
+ (new Thread(this, "CreatePrivateActivatable$PrivateActivatable")).start();
+ }
- /**
- * Thread to deactivate object. First attempts to make object
- * inactive (via the inactive method). If that fails (the
- * object may still have pending/executing calls), then
- * unexport the object forcibly.
- */
- public void run() {
- ActivationLibrary.deactivate(this, getID());
- }
+ /**
+ * Thread to deactivate object. First attempts to make object
+ * inactive (via the inactive method). If that fails (the
+ * object may still have pending/executing calls), then
+ * unexport the object forcibly.
+ */
+ public void run() {
+ 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();
- RMID rmid = null;
- ActivateMe obj;
+ /*
+ * 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();
+ RMID rmid = null;
+ ActivateMe obj;
- System.err.println("\nRegression test for bug 4164971\n");
- System.err.println("java.security.policy = " +
- System.getProperty("java.security.policy", "no policy"));
+ System.err.println("\nRegression test for bug 4164971\n");
+ System.err.println("java.security.policy = " +
+ System.getProperty("java.security.policy", "no policy"));
- CreatePrivateActivatable server;
- try {
- TestLibrary.suggestSecurityManager(TestParams.defaultSecurityManager);
+ CreatePrivateActivatable server;
+ try {
+ TestLibrary.suggestSecurityManager(TestParams.defaultSecurityManager);
+
+ // start an rmid.
+ RMID.removeLog();
+ rmid = RMID.createRMID();
+ rmid.start();
- // start an rmid.
- 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
- */
- 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);
-
- /*
- * Activate an object by registering its object
- * descriptor and invoking a method on the
- * stub returned from the register call.
- */
- ActivationGroupDesc groupDesc =
- new ActivationGroupDesc(p, null);
- ActivationSystem system = ActivationGroup.getSystem();
- ActivationGroupID groupID = system.registerGroup(groupDesc);
+ /* Cause activation groups to have a security policy that will
+ * allow security managers to be downloaded and installed
+ */
+ 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);
+
+ /*
+ * Activate an object by registering its object
+ * descriptor and invoking a method on the
+ * stub returned from the register call.
+ */
+ ActivationGroupDesc groupDesc =
+ new ActivationGroupDesc(p, null);
+ ActivationSystem system = ActivationGroup.getSystem();
+ ActivationGroupID groupID = system.registerGroup(groupDesc);
+
+ System.err.println("Creating descriptor");
+ ActivationDesc desc =
+ new ActivationDesc(groupID,
+ "CreatePrivateActivatable$PrivateActivatable",
+ null, null);
- System.err.println("Creating descriptor");
- ActivationDesc desc =
- new ActivationDesc(groupID,
- "CreatePrivateActivatable$PrivateActivatable",
- null, null);
-
- System.err.println("Registering descriptor");
- obj = (ActivateMe) Activatable.register(desc);
-
- /*
- * Loop a bunch of times to force activator to
- * spawn VMs (groups)
- */
- System.err.println("Activate object via method call");
- obj.ping();
-
- /*
- * Clean up object too.
- */
- System.err.println("Deactivate object via method call");
- obj.shutdown();
-
- System.err.println("\nsuccess: CreatePrivateActivatable test passed ");
-
- } catch (Exception e) {
- if (e instanceof java.security.PrivilegedActionException) {
- e = ((java.security.PrivilegedActionException)e).getException();
- }
- TestLibrary.bomb("\nfailure: unexpected exception " +
- e.getClass().getName(), e);
-
- } finally {
- ActivationLibrary.rmidCleanup(rmid);
- obj = null;
- }
+ System.err.println("Registering descriptor");
+ obj = (ActivateMe) Activatable.register(desc);
+
+ /*
+ * Loop a bunch of times to force activator to
+ * spawn VMs (groups)
+ */
+ System.err.println("Activate object via method call");
+ obj.ping();
+
+ /*
+ * Clean up object too.
+ */
+ System.err.println("Deactivate object via method call");
+ obj.shutdown();
+
+ System.err.println("\nsuccess: CreatePrivateActivatable test passed ");
+
+ } catch (Exception e) {
+ if (e instanceof java.security.PrivilegedActionException) {
+ e = ((java.security.PrivilegedActionException)e).getException();
+ }
+ TestLibrary.bomb("\nfailure: unexpected exception " +
+ e.getClass().getName(), e);
+
+ } finally {
+ ActivationLibrary.rmidCleanup(rmid);
+ obj = null;
+ }
}
}
--- a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -24,10 +24,10 @@
/* @test
* @bug 4097135
* @summary Need a specific subtype of RemoteException for activation failure.
- * If activation fails to happen during a call to a remote object,
- * then the call should end in an ActivateFailedException. In this
- * test, the actual "activatable" remote object fails to activate
- * since its * "activation" constructor throws an exception.
+ * If activation fails to happen during a call to a remote object,
+ * then the call should end in an ActivateFailedException. In this
+ * test, the actual "activatable" remote object fails to activate
+ * since its * "activation" constructor throws an exception.
* @author Ann Wollrath
*
* @library ../../../testlibrary
@@ -46,128 +46,127 @@
import java.util.Properties;
public class ActivateFails
- extends Activatable
- implements ActivateMe
+ extends Activatable
+ implements ActivateMe
{
public ActivateFails(ActivationID id, MarshalledObject obj)
- throws ActivationException, RemoteException
+ throws ActivationException, RemoteException
{
- super(id, 0);
+ super(id, 0);
- boolean refuseToActivate = false;
- try {
- refuseToActivate = ((Boolean)obj.get()).booleanValue();
- } catch (Exception impossible) {
- }
-
- if (refuseToActivate)
- throw new RemoteException("object refuses to activate");
+ boolean refuseToActivate = false;
+ try {
+ refuseToActivate = ((Boolean)obj.get()).booleanValue();
+ } catch (Exception impossible) {
+ }
+
+ if (refuseToActivate)
+ throw new RemoteException("object refuses to activate");
}
public void ping()
{}
-
+
/**
* Spawns a thread to deactivate the object.
*/
public ShutdownThread shutdown() throws Exception
{
- ShutdownThread shutdownThread = new ShutdownThread(this, getID());
- shutdownThread.start();
- return(shutdownThread);
+ ShutdownThread shutdownThread = new ShutdownThread(this, getID());
+ shutdownThread.start();
+ return(shutdownThread);
}
-
- public static void main(String[] args)
+
+ public static void main(String[] args)
{
- RMID rmid = null;
- ActivateMe obj1, obj2;
- ShutdownThread shutdownThread;
-
- System.err.println("\nRegression test for bug 4097135\n");
- try {
- TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
+ RMID rmid = null;
+ ActivateMe obj1, obj2;
+ ShutdownThread shutdownThread;
+
+ System.err.println("\nRegression test for bug 4097135\n");
+ try {
+ TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
+
+ /*
+ * First run "rmid" and wait for it to start up.
+ */
+ RMID.removeLog();
+ rmid = RMID.createRMID();
+ rmid.start();
- /*
- * First run "rmid" and wait for it to start up.
- */
- 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
+ */
+ 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);
- /* Cause activation groups to have a security policy that will
- * allow security managers to be downloaded and installed
- */
- 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);
+ /*
+ * Create activation descriptor...
+ */
+ System.err.println("creating activation descriptor...");
+ ActivationGroupDesc groupDesc =
+ new ActivationGroupDesc(p, null);
+ ActivationGroupID groupID =
+ ActivationGroup.getSystem().registerGroup(groupDesc);
+
+ ActivationDesc desc1 =
+ new ActivationDesc(groupID, "ActivateFails",
+ null,
+ new MarshalledObject(new Boolean(true)));
- /*
- * Create activation descriptor...
- */
- System.err.println("creating activation descriptor...");
- ActivationGroupDesc groupDesc =
- new ActivationGroupDesc(p, null);
- ActivationGroupID groupID =
- ActivationGroup.getSystem().registerGroup(groupDesc);
-
- ActivationDesc desc1 =
- new ActivationDesc(groupID, "ActivateFails",
- null,
- new MarshalledObject(new Boolean(true)));
-
- ActivationDesc desc2 =
- new ActivationDesc(groupID, "ActivateFails",
- null,
- new MarshalledObject(new Boolean(false)));
- /*
- * Register activation descriptor and make a call on
- * the stub. Activation should fail with an
- * ActivateFailedException. If not, report an
- * error as a RuntimeException
- */
+ ActivationDesc desc2 =
+ new ActivationDesc(groupID, "ActivateFails",
+ null,
+ new MarshalledObject(new Boolean(false)));
+ /*
+ * Register activation descriptor and make a call on
+ * the stub. Activation should fail with an
+ * ActivateFailedException. If not, report an
+ * error as a RuntimeException
+ */
- System.err.println("registering activation descriptor...");
- obj1 = (ActivateMe)Activatable.register(desc1);
- obj2 = (ActivateMe)Activatable.register(desc2);
+ System.err.println("registering activation descriptor...");
+ obj1 = (ActivateMe)Activatable.register(desc1);
+ obj2 = (ActivateMe)Activatable.register(desc2);
+
+ System.err.println("invoking method on activatable object...");
+ try {
+ obj1.ping();
+
+ } catch (ActivateFailedException e) {
- System.err.println("invoking method on activatable object...");
- try {
- obj1.ping();
-
- } catch (ActivateFailedException e) {
+ /*
+ * This is what is expected so exit with status 0
+ */
+ System.err.println("\nsuccess: ActivateFailedException " +
+ "generated");
+ e.getMessage();
+ }
- /*
- * This is what is expected so exit with status 0
- */
- System.err.println("\nsuccess: ActivateFailedException " +
- "generated");
- e.getMessage();
- }
+ obj2.ping();
+ shutdownThread = obj2.shutdown();
- obj2.ping();
- shutdownThread = obj2.shutdown();
+ // wait for shutdown to work
+ Thread.sleep(2000);
- // wait for shutdown to work
- Thread.sleep(2000);
+ shutdownThread = null;
- shutdownThread = null;
-
- } catch (Exception e) {
- /*
- * Test failed; unexpected exception generated.
- */
- TestLibrary.bomb("\nfailure: unexpected exception " +
- e.getClass().getName() + ": " + e.getMessage(), e);
-
- } finally {
- obj1 = obj2 = null;
- ActivationLibrary.rmidCleanup(rmid);
- }
+ } catch (Exception e) {
+ /*
+ * Test failed; unexpected exception generated.
+ */
+ TestLibrary.bomb("\nfailure: unexpected exception " +
+ e.getClass().getName() + ": " + e.getMessage(), e);
+
+ } finally {
+ obj1 = obj2 = null;
+ ActivationLibrary.rmidCleanup(rmid);
+ }
}
}
-
--- a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -29,88 +29,88 @@
implements ActivateMe, java.rmi.Remote
{
private static final java.rmi.server.Operation[] operations = {
- new java.rmi.server.Operation("void ping()"),
- new java.rmi.server.Operation("ShutdownThread shutdown()")
+ new java.rmi.server.Operation("void ping()"),
+ new java.rmi.server.Operation("ShutdownThread shutdown()")
};
-
+
private static final long interfaceHash = -6632667923281093978L;
-
+
private static final long serialVersionUID = 2;
-
+
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_ping_0;
private static java.lang.reflect.Method $method_shutdown_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_ping_0 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {});
- $method_shutdown_1 = ActivateMe.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_ping_0 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {});
+ $method_shutdown_1 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
+ } catch (java.lang.NoSuchMethodException e) {
+ useNewInvoke = false;
+ }
}
-
+
// constructors
public ActivateFails_Stub() {
- super();
+ super();
}
public ActivateFails_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);
+ }
}
-
+
// implementation of shutdown()
public ShutdownThread shutdown()
- throws java.lang.Exception
+ throws java.lang.Exception
{
- if (useNewInvoke) {
- Object $result = ref.invoke(this, $method_shutdown_1, null, -3616843253114182719L);
- return ((ShutdownThread) $result);
- } else {
- java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
- ref.invoke(call);
- ShutdownThread $result;
- try {
- java.io.ObjectInput in = call.getInputStream();
- $result = (ShutdownThread) 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_shutdown_1, null, -3616843253114182719L);
+ return ((ShutdownThread) $result);
+ } else {
+ java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
+ ref.invoke(call);
+ ShutdownThread $result;
+ try {
+ java.io.ObjectInput in = call.getInputStream();
+ $result = (ShutdownThread) 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;
+ }
}
}
--- a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateMe.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateMe.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ShutdownThread.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ShutdownThread.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -31,21 +31,20 @@
ActivationID activationID = null;
public ShutdownThread(Remote remoteObject, ActivationID activationID) {
- remoteObject = remoteObject;
- activationID = activationID;
+ remoteObject = remoteObject;
+ activationID = activationID;
}
public void run() {
- try {
+ try {
- Activatable.unexportObject(remoteObject, true);
- Activatable.inactive(activationID);
+ Activatable.unexportObject(remoteObject, true);
+ Activatable.inactive(activationID);
- } catch (Exception e) {
- }
+ } catch (Exception e) {
+ }
}
}
-
--- a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4510355
+ * @bug 4510355
* @summary ActivationGroup implementations cannot be downloaded by default;
* Creates a custom activation group without setting a security manager
* in activation group's descriptor. The custom activation group
@@ -49,28 +49,28 @@
import java.util.Properties;
public class DownloadActivationGroup
- implements Ping, Runnable
+ implements Ping, Runnable
{
private ActivationID id;
public DownloadActivationGroup(ActivationID id, MarshalledObject mobj)
- throws ActivationException, RemoteException
+ throws ActivationException, RemoteException
{
- this.id = id;
- Activatable.exportObject(this, id, 0);
- System.err.println("object activated in group");
+ this.id = id;
+ Activatable.exportObject(this, id, 0);
+ System.err.println("object activated in group");
}
public DownloadActivationGroup() throws RemoteException {
- UnicastRemoteObject.exportObject(this, 0);
+ UnicastRemoteObject.exportObject(this, 0);
}
/**
* Used to activate object.
*/
public void ping() {
- System.err.println("received ping");
+ System.err.println("received ping");
}
/**
@@ -79,87 +79,87 @@
*/
public void shutdown() throws Exception
{
- (new Thread(this,"DownloadActivationGroup")).start();
+ (new Thread(this,"DownloadActivationGroup")).start();
}
/**
* Thread to deactivate object.
*/
public void run() {
- ActivationLibrary.deactivate(this, getID());
+ ActivationLibrary.deactivate(this, getID());
}
-
+
public ActivationID getID() {
- return id;
+ return id;
}
public static void main(String[] args) {
- RMID rmid = null;
-
- System.out.println("\nRegression test for bug 4510355\n");
-
- try {
- TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
+ RMID rmid = null;
+
+ System.out.println("\nRegression test for bug 4510355\n");
+
+ try {
+ TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
+
+ /*
+ * Install group class file in codebase.
+ */
+ System.err.println("install class file in codebase");
+ URL groupURL = TestLibrary.installClassInCodebase(
+ "MyActivationGroupImpl", "group");
+ System.err.println("class file installed");
- /*
- * Install group class file in codebase.
- */
- System.err.println("install class file in codebase");
- URL groupURL = TestLibrary.installClassInCodebase(
- "MyActivationGroupImpl", "group");
- System.err.println("class file installed");
+ /*
+ * Start rmid.
+ */
+ RMID.removeLog();
+ rmid = RMID.createRMID();
+ String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
+ rmid.addOptions(new String[] { execPolicyOption });
+ rmid.start();
- /*
- * Start rmid.
- */
- RMID.removeLog();
- rmid = RMID.createRMID();
- String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
- rmid.addOptions(new String[] { execPolicyOption });
- rmid.start();
+ /*
+ * Create and register descriptors for custom group and an
+ * activatable object in that group.
+ */
+ System.err.println("register group");
- /*
- * Create and register descriptors for custom group and an
- * activatable object in that group.
- */
- System.err.println("register group");
-
- Properties p = new Properties();
- p.put("java.security.policy", TestParams.defaultGroupPolicy);
-
- ActivationGroupDesc groupDesc =
- new ActivationGroupDesc("MyActivationGroupImpl",
- groupURL.toExternalForm(),
- null, p, null);
- ActivationGroupID groupID =
- ActivationGroup.getSystem().registerGroup(groupDesc);
-
-
- System.err.println("register activatable object");
- ActivationDesc desc =
- new ActivationDesc(groupID, "DownloadActivationGroup",
- null, null);
- Ping obj = (Ping) Activatable.register(desc);
+ Properties p = new Properties();
+ p.put("java.security.policy", TestParams.defaultGroupPolicy);
+
+ ActivationGroupDesc groupDesc =
+ new ActivationGroupDesc("MyActivationGroupImpl",
+ groupURL.toExternalForm(),
+ null, p, null);
+ ActivationGroupID groupID =
+ ActivationGroup.getSystem().registerGroup(groupDesc);
+
+
+ System.err.println("register activatable object");
+ ActivationDesc desc =
+ new ActivationDesc(groupID, "DownloadActivationGroup",
+ null, null);
+ Ping obj = (Ping) Activatable.register(desc);
- /*
- * Start group (by calling ping).
- */
- System.err.println(
- "ping object (forces download of group's class)");
- obj.ping();
- System.err.println(
- "TEST PASSED: group's class downloaded successfully");
- System.err.println("shutdown object");
- obj.shutdown();
- System.err.println("TEST PASSED");
+ /*
+ * Start group (by calling ping).
+ */
+ System.err.println(
+ "ping object (forces download of group's class)");
+ obj.ping();
+ System.err.println(
+ "TEST PASSED: group's class downloaded successfully");
+ System.err.println("shutdown object");
+ obj.shutdown();
+ System.err.println("TEST PASSED");
- } catch (Exception e) {
- TestLibrary.bomb(e);
- } finally {
- ActivationLibrary.rmidCleanup(rmid);
- }
+ } catch (Exception e) {
+ TestLibrary.bomb(e);
+ } finally {
+ ActivationLibrary.rmidCleanup(rmid);
+ }
}
}
--- a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -29,46 +29,46 @@
implements Ping
{
private static final long serialVersionUID = 2;
-
+
private static java.lang.reflect.Method $method_ping_0;
private static java.lang.reflect.Method $method_shutdown_1;
-
+
static {
- try {
- $method_ping_0 = Ping.class.getMethod("ping", new java.lang.Class[] {});
- $method_shutdown_1 = Ping.class.getMethod("shutdown", 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[] {});
+ $method_shutdown_1 = Ping.class.getMethod("shutdown", new java.lang.Class[] {});
+ } catch (java.lang.NoSuchMethodException e) {
+ throw new java.lang.NoSuchMethodError(
+ "stub class initialization failed");
+ }
}
-
+
// constructors
public DownloadActivationGroup_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);
+ }
}
-
+
// 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);
}
}
--- a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/MyActivationGroupImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/MyActivationGroupImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -27,11 +27,11 @@
public class MyActivationGroupImpl extends ActivationGroupImpl {
-
+
public MyActivationGroupImpl(ActivationGroupID id, MarshalledObject mobj)
- throws RemoteException, ActivationException
+ throws RemoteException, ActivationException
{
- super(id, mobj);
- System.err.println("custom group implementation created");
+ super(id, mobj);
+ System.err.println("custom group implementation created");
}
}
--- a/jdk/test/java/rmi/activation/ActivationGroupDesc/checkDefaultGroupName/CheckDefaultGroupName.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationGroupDesc/checkDefaultGroupName/CheckDefaultGroupName.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -42,19 +42,19 @@
*/
public class CheckDefaultGroupName {
public static void main(String[] args) {
- System.out.println("\n\nRegression test for, 4252236\n\n");
+ System.out.println("\n\nRegression test for, 4252236\n\n");
- ActivationGroupDesc groupDesc =
- new ActivationGroupDesc(null, null);
+ ActivationGroupDesc groupDesc =
+ new ActivationGroupDesc(null, null);
- String className = groupDesc.getClassName();
- if (className != null) {
- TestLibrary.bomb("ActivationGroupDesc had incorrect default" +
- " group implementation class name: " + className);
- } else {
- System.err.println("test passed, had correct default group" +
- " implementation class name: " + className +
- "\n\n");
- }
+ String className = groupDesc.getClassName();
+ if (className != null) {
+ TestLibrary.bomb("ActivationGroupDesc had incorrect default" +
+ " group implementation class name: " + className);
+ } else {
+ System.err.println("test passed, had correct default group" +
+ " implementation class name: " + className +
+ "\n\n");
+ }
}
}
--- a/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -49,81 +49,81 @@
import java.rmi.server.UnicastRemoteObject;
public class IdempotentActiveGroup {
-
+
public static void main(String[] args) {
- System.err.println("\nRegression test for bug 4720528\n");
-
- TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
- RMID rmid = null;
- ActivationInstantiator inst1 = null;
- ActivationInstantiator inst2 = null;
-
- try {
- RMID.removeLog();
- rmid = RMID.createRMID();
- rmid.start();
+ System.err.println("\nRegression test for bug 4720528\n");
+
+ TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
+ RMID rmid = null;
+ ActivationInstantiator inst1 = null;
+ ActivationInstantiator inst2 = null;
+
+ try {
+ RMID.removeLog();
+ rmid = RMID.createRMID();
+ rmid.start();
- System.err.println("Create group descriptor");
- ActivationGroupDesc groupDesc =
- new ActivationGroupDesc(null, null);
- ActivationSystem system = ActivationGroup.getSystem();
- System.err.println("Register group descriptor");
- ActivationGroupID groupID = system.registerGroup(groupDesc);
- inst1 = new FakeInstantiator();
- inst2 = new FakeInstantiator();
-
- System.err.println("Invoke activeGroup with inst1");
- system.activeGroup(groupID, inst1, 0);
+ System.err.println("Create group descriptor");
+ ActivationGroupDesc groupDesc =
+ new ActivationGroupDesc(null, null);
+ ActivationSystem system = ActivationGroup.getSystem();
+ System.err.println("Register group descriptor");
+ ActivationGroupID groupID = system.registerGroup(groupDesc);
+ inst1 = new FakeInstantiator();
+ inst2 = new FakeInstantiator();
+
+ System.err.println("Invoke activeGroup with inst1");
+ system.activeGroup(groupID, inst1, 0);
- try {
- System.err.println("Invoke activeGroup with inst2");
- system.activeGroup(groupID, inst2, 0);
- throw new RuntimeException(
- "TEST FAILED: activeGroup with unequal groups succeeded!");
- } catch (ActivationException expected) {
- System.err.println("Caught expected ActivationException");
- System.err.println("Test 1 (of 2) passed");
- }
+ try {
+ System.err.println("Invoke activeGroup with inst2");
+ system.activeGroup(groupID, inst2, 0);
+ throw new RuntimeException(
+ "TEST FAILED: activeGroup with unequal groups succeeded!");
+ } catch (ActivationException expected) {
+ System.err.println("Caught expected ActivationException");
+ System.err.println("Test 1 (of 2) passed");
+ }
- try {
- System.err.println("Invoke activeGroup with inst1");
- system.activeGroup(groupID, inst1, 0);
- System.err.println("activeGroup call succeeded");
- System.err.println("Test 2 (of 2) passed");
- } catch (ActivationException unexpected) {
- throw new RuntimeException(
- "TEST FAILED: activeGroup with equal groups failed!",
- unexpected);
- }
-
- } catch (Exception e) {
- TestLibrary.bomb("test failed", e);
- } finally {
- try {
- if (inst1 != null) {
- UnicastRemoteObject.unexportObject(inst1, true);
- }
- if (inst2 != null) {
- UnicastRemoteObject.unexportObject(inst2, true);
- }
- } catch (NoSuchObjectException unexpected) {
- throw new AssertionError(unexpected);
- }
- ActivationLibrary.rmidCleanup(rmid);
- }
+ try {
+ System.err.println("Invoke activeGroup with inst1");
+ system.activeGroup(groupID, inst1, 0);
+ System.err.println("activeGroup call succeeded");
+ System.err.println("Test 2 (of 2) passed");
+ } catch (ActivationException unexpected) {
+ throw new RuntimeException(
+ "TEST FAILED: activeGroup with equal groups failed!",
+ unexpected);
+ }
+
+ } catch (Exception e) {
+ TestLibrary.bomb("test failed", e);
+ } finally {
+ try {
+ if (inst1 != null) {
+ UnicastRemoteObject.unexportObject(inst1, true);
+ }
+ if (inst2 != null) {
+ UnicastRemoteObject.unexportObject(inst2, true);
+ }
+ } catch (NoSuchObjectException unexpected) {
+ throw new AssertionError(unexpected);
+ }
+ ActivationLibrary.rmidCleanup(rmid);
+ }
}
private static class FakeInstantiator
- extends UnicastRemoteObject
- implements ActivationInstantiator
+ extends UnicastRemoteObject
+ implements ActivationInstantiator
{
- FakeInstantiator() throws RemoteException {}
+ FakeInstantiator() throws RemoteException {}
- public MarshalledObject newInstance(ActivationID id,
- ActivationDesc desc)
- {
- throw new AssertionError();
- }
+ public MarshalledObject newInstance(ActivationID id,
+ ActivationDesc desc)
+ {
+ throw new AssertionError();
+ }
}
}
--- a/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ActivateMe.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ActivateMe.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 4127754
*
* @summary synopsis: need to modify registered ActivationDesc and
- * ActivationGroupDesc
+ * ActivationGroupDesc
* @author Ann Wollrath
*
* @library ../../../testlibrary
@@ -43,7 +43,7 @@
import java.util.*;
public class ModifyDescriptor
- implements ActivateMe, Runnable
+ implements ActivateMe, Runnable
{
private ActivationID id;
@@ -54,28 +54,28 @@
public ModifyDescriptor(ActivationID id, MarshalledObject mobj)
- throws ActivationException, RemoteException
+ throws ActivationException, RemoteException
{
- this.id = id;
- Activatable.exportObject(this, id, 0);
-
- try {
- message = (String) mobj.get();
- } catch (Exception e) {
- System.err.println("unable to get message from marshalled object");
- }
+ this.id = id;
+ Activatable.exportObject(this, id, 0);
+
+ try {
+ message = (String) mobj.get();
+ } catch (Exception e) {
+ System.err.println("unable to get message from marshalled object");
+ }
}
public String getMessage() {
- return message;
+ return message;
}
public String getProperty(String name) {
- return TestLibrary.getProperty(name, null);
+ return TestLibrary.getProperty(name, null);
}
public ActivationID getID() {
- return id;
+ return id;
}
/**
@@ -83,7 +83,7 @@
*/
public void shutdown() throws Exception
{
- (new Thread(this,"ModifyDescriptor")).start();
+ (new Thread(this,"ModifyDescriptor")).start();
}
/**
@@ -93,165 +93,165 @@
* unexport the object forcibly.
*/
public void run() {
- ActivationLibrary.deactivate(this, getID());
+ ActivationLibrary.deactivate(this, getID());
}
-
+
public static void main(String[] args) {
- System.out.println("\nRegression test for bug 4127754\n");
-
- TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
+ System.out.println("\nRegression test for bug 4127754\n");
+
+ TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
+
+ RMID rmid = null;
- RMID rmid = null;
-
- try {
- RMID.removeLog();
- rmid = RMID.createRMID();
- rmid.start();
+ try {
+ RMID.removeLog();
+ rmid = RMID.createRMID();
+ rmid.start();
- /*
- * Create and register a group and activatable object
- */
+ /*
+ * Create and register a group and activatable object
+ */
- System.err.println("Creating group descriptor");
- Properties props = new Properties();
- props.put("java.security.policy",
- TestParams.defaultGroupPolicy);
- props.put("java.security.manager",
- TestParams.defaultSecurityManager);
- props.put("test.message", MESSAGE1);
- ActivationGroupDesc initialGroupDesc =
- new ActivationGroupDesc(props, null);
- System.err.println("Registering group");
- ActivationSystem system = ActivationGroup.getSystem();
- ActivationGroupID groupID = system.registerGroup(initialGroupDesc);
-
- System.err.println("Creating descriptor");
- ActivationDesc initialDesc =
- new ActivationDesc(groupID, "ModifyDescriptor", null,
- new MarshalledObject(MESSAGE1), false);
-
- System.err.println("Registering descriptor");
- ActivateMe obj = (ActivateMe) Activatable.register(initialDesc);
+ System.err.println("Creating group descriptor");
+ Properties props = new Properties();
+ props.put("java.security.policy",
+ TestParams.defaultGroupPolicy);
+ props.put("java.security.manager",
+ TestParams.defaultSecurityManager);
+ props.put("test.message", MESSAGE1);
+ ActivationGroupDesc initialGroupDesc =
+ new ActivationGroupDesc(props, null);
+ System.err.println("Registering group");
+ ActivationSystem system = ActivationGroup.getSystem();
+ ActivationGroupID groupID = system.registerGroup(initialGroupDesc);
+
+ System.err.println("Creating descriptor");
+ ActivationDesc initialDesc =
+ new ActivationDesc(groupID, "ModifyDescriptor", null,
+ new MarshalledObject(MESSAGE1), false);
+
+ System.err.println("Registering descriptor");
+ ActivateMe obj = (ActivateMe) Activatable.register(initialDesc);
- /*
- * Ping object and verify that MarshalledObject is okay.
- */
- System.err.println("Ping object");
- String message1 = obj.getMessage();
- System.err.println("message = " + message1);
+ /*
+ * Ping object and verify that MarshalledObject is okay.
+ */
+ System.err.println("Ping object");
+ String message1 = obj.getMessage();
+ System.err.println("message = " + message1);
- if (message1.equals(MESSAGE1)) {
- System.err.println("Test1a passed: initial MarshalledObject " +
- "correct");
- } else {
- TestLibrary.bomb("Test1 failed: unexpected MarshalledObject passed to " +
- "constructor", null);
- }
+ if (message1.equals(MESSAGE1)) {
+ System.err.println("Test1a passed: initial MarshalledObject " +
+ "correct");
+ } else {
+ TestLibrary.bomb("Test1 failed: unexpected MarshalledObject passed to " +
+ "constructor", null);
+ }
- /*
- * Get property from remote group and make sure it's okay
- */
- message1 = obj.getProperty("test.message");
- if (message1.equals(MESSAGE1)) {
- System.err.println("Test1b passed: initial group property " +
- "correct");
- } else {
- TestLibrary.bomb("Test1 failed: unexpected property passed to " +
- "group", null);
- }
+ /*
+ * Get property from remote group and make sure it's okay
+ */
+ message1 = obj.getProperty("test.message");
+ if (message1.equals(MESSAGE1)) {
+ System.err.println("Test1b passed: initial group property " +
+ "correct");
+ } else {
+ TestLibrary.bomb("Test1 failed: unexpected property passed to " +
+ "group", null);
+ }
- /*
- * Update activation descriptor for object and group
- */
- System.err.println("Update activation descriptor");
- ActivationDesc newDesc =
- new ActivationDesc(groupID, "ModifyDescriptor", null,
- new MarshalledObject(MESSAGE2), false);
- ActivationID id = obj.getID();
- ActivationDesc oldDesc = system.setActivationDesc(id, newDesc);
+ /*
+ * Update activation descriptor for object and group
+ */
+ System.err.println("Update activation descriptor");
+ ActivationDesc newDesc =
+ new ActivationDesc(groupID, "ModifyDescriptor", null,
+ new MarshalledObject(MESSAGE2), false);
+ ActivationID id = obj.getID();
+ ActivationDesc oldDesc = system.setActivationDesc(id, newDesc);
- if (oldDesc.equals(initialDesc)) {
- System.err.println("Test2a passed: desc returned from " +
- "setActivationDesc is okay");
- } else {
- TestLibrary.bomb("Test2a failed: desc returned from setActivationDesc " +
- "is not the initial descriptor!", null);
- }
+ if (oldDesc.equals(initialDesc)) {
+ System.err.println("Test2a passed: desc returned from " +
+ "setActivationDesc is okay");
+ } else {
+ TestLibrary.bomb("Test2a failed: desc returned from setActivationDesc " +
+ "is not the initial descriptor!", null);
+ }
- Properties props2 = new Properties();
- props2.put("test.message", MESSAGE2);
- props2.put("java.security.policy",
- TestParams.defaultGroupPolicy);
- props2.put("java.security.manager",
- TestParams.defaultSecurityManager);
- ActivationGroupDesc newGroupDesc =
- new ActivationGroupDesc(props2, null);
+ Properties props2 = new Properties();
+ props2.put("test.message", MESSAGE2);
+ props2.put("java.security.policy",
+ TestParams.defaultGroupPolicy);
+ props2.put("java.security.manager",
+ TestParams.defaultSecurityManager);
+ ActivationGroupDesc newGroupDesc =
+ new ActivationGroupDesc(props2, null);
- ActivationGroupDesc oldGroupDesc =
- system.setActivationGroupDesc(groupID, newGroupDesc);
+ ActivationGroupDesc oldGroupDesc =
+ system.setActivationGroupDesc(groupID, newGroupDesc);
- if (oldGroupDesc.equals(initialGroupDesc)) {
- System.err.println("Test2b passed: group desc returned from " +
- "setActivationGroupDesc is okay");
- } else {
- TestLibrary.bomb("Test2b failed: group desc returned from " +
- "setActivationGroupDesc is not the initial descriptor!",
- null);
- }
-
- /*
- * Restart rmid; and ping object to make sure that it has
- * new message.
- */
- rmid.restart();
+ if (oldGroupDesc.equals(initialGroupDesc)) {
+ System.err.println("Test2b passed: group desc returned from " +
+ "setActivationGroupDesc is okay");
+ } else {
+ TestLibrary.bomb("Test2b failed: group desc returned from " +
+ "setActivationGroupDesc is not the initial descriptor!",
+ null);
+ }
- System.err.println("Ping object after restart");
- String message2 = obj.getMessage();
+ /*
+ * Restart rmid; and ping object to make sure that it has
+ * new message.
+ */
+ rmid.restart();
+
+ System.err.println("Ping object after restart");
+ String message2 = obj.getMessage();
- if (message2.equals(MESSAGE2)) {
- System.err.println("Test3a passed: setActivationDesc takes " +
- "effect after a restart");
- } else {
- TestLibrary.bomb("Test3a failed: setActivationDesc did not take effect " +
- "after a restart", null);
- }
+ if (message2.equals(MESSAGE2)) {
+ System.err.println("Test3a passed: setActivationDesc takes " +
+ "effect after a restart");
+ } else {
+ TestLibrary.bomb("Test3a failed: setActivationDesc did not take effect " +
+ "after a restart", null);
+ }
+
+ message2 = obj.getProperty("test.message");
- message2 = obj.getProperty("test.message");
-
- if (message2.equals(MESSAGE2)) {
- System.err.println("Test3b passed: setActivationGroupDesc " +
- "takes effect after a restart");
- } else {
- TestLibrary.bomb("Test3b failed: setActivationGroupDesc did not take " +
- "effect after a restart", null);
- }
+ if (message2.equals(MESSAGE2)) {
+ System.err.println("Test3b passed: setActivationGroupDesc " +
+ "takes effect after a restart");
+ } else {
+ TestLibrary.bomb("Test3b failed: setActivationGroupDesc did not take " +
+ "effect after a restart", null);
+ }
- System.err.println("Get activation descriptor");
- ActivationDesc latestDesc = system.getActivationDesc(id);
+ System.err.println("Get activation descriptor");
+ ActivationDesc latestDesc = system.getActivationDesc(id);
- if (latestDesc.equals(newDesc)) {
- System.err.println("Test4a passed: desc is same as latest");
- } else {
- TestLibrary.bomb("Test4a failed: there is no way this would happen", null);
- }
+ if (latestDesc.equals(newDesc)) {
+ System.err.println("Test4a passed: desc is same as latest");
+ } else {
+ TestLibrary.bomb("Test4a failed: there is no way this would happen", null);
+ }
- System.err.println("Get activation group descriptor");
- ActivationGroupDesc latestGroupDesc =
- system.getActivationGroupDesc(groupID);
+ System.err.println("Get activation group descriptor");
+ ActivationGroupDesc latestGroupDesc =
+ system.getActivationGroupDesc(groupID);
- if (latestGroupDesc.equals(newGroupDesc)) {
- System.err.println("Test4b passed: group desc is same as " +
- "latest");
- } else {
- TestLibrary.bomb("Test4b failed: there is no way this would happen", null);
- }
-
- } catch (Exception e) {
- TestLibrary.bomb("test failed", e);
- } finally {
- ActivationLibrary.rmidCleanup(rmid);
- }
+ if (latestGroupDesc.equals(newGroupDesc)) {
+ System.err.println("Test4b passed: group desc is same as " +
+ "latest");
+ } else {
+ TestLibrary.bomb("Test4b failed: there is no way this would happen", null);
+ }
+
+ } catch (Exception e) {
+ TestLibrary.bomb("test failed", e);
+ } finally {
+ ActivationLibrary.rmidCleanup(rmid);
+ }
}
}
--- a/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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,166 +29,166 @@
implements ActivateMe
{
private static final java.rmi.server.Operation[] operations = {
- new java.rmi.server.Operation("java.rmi.activation.ActivationID getID()"),
- new java.rmi.server.Operation("java.lang.String getMessage()"),
- new java.rmi.server.Operation("java.lang.String getProperty(java.lang.String)"),
- new java.rmi.server.Operation("void shutdown()")
+ new java.rmi.server.Operation("java.rmi.activation.ActivationID getID()"),
+ new java.rmi.server.Operation("java.lang.String getMessage()"),
+ new java.rmi.server.Operation("java.lang.String getProperty(java.lang.String)"),
+ new java.rmi.server.Operation("void shutdown()")
};
-
+
private static final long interfaceHash = 7998207954486691383L;
-
+
private static final long serialVersionUID = 2;
-
+
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_getID_0;
private static java.lang.reflect.Method $method_getMessage_1;
private static java.lang.reflect.Method $method_getProperty_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_getID_0 = ActivateMe.class.getMethod("getID", new java.lang.Class[] {});
- $method_getMessage_1 = ActivateMe.class.getMethod("getMessage", new java.lang.Class[] {});
- $method_getProperty_2 = ActivateMe.class.getMethod("getProperty", new java.lang.Class[] {java.lang.String.class});
- $method_shutdown_3 = ActivateMe.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_getID_0 = ActivateMe.class.getMethod("getID", new java.lang.Class[] {});
+ $method_getMessage_1 = ActivateMe.class.getMethod("getMessage", new java.lang.Class[] {});
+ $method_getProperty_2 = ActivateMe.class.getMethod("getProperty", new java.lang.Class[] {java.lang.String.class});
+ $method_shutdown_3 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
+ } catch (java.lang.NoSuchMethodException e) {
+ useNewInvoke = false;
+ }
}
-
+
// constructors
public ModifyDescriptor_Stub() {
- super();
+ super();
}
public ModifyDescriptor_Stub(java.rmi.server.RemoteRef ref) {
- super(ref);
+ super(ref);
}
-
+
// methods from remote interfaces
-
+
// implementation of getID()
public java.rmi.activation.ActivationID getID()
- throws java.rmi.RemoteException
+ throws java.rmi.RemoteException
{
- try {
- if (useNewInvoke) {
- Object $result = ref.invoke(this, $method_getID_0, null, -7795865521150345044L);
- return ((java.rmi.activation.ActivationID) $result);
- } else {
- java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
- ref.invoke(call);
- java.rmi.activation.ActivationID $result;
- try {
- java.io.ObjectInput in = call.getInputStream();
- $result = (java.rmi.activation.ActivationID) 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_getID_0, null, -7795865521150345044L);
+ return ((java.rmi.activation.ActivationID) $result);
+ } else {
+ java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
+ ref.invoke(call);
+ java.rmi.activation.ActivationID $result;
+ try {
+ java.io.ObjectInput in = call.getInputStream();
+ $result = (java.rmi.activation.ActivationID) 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 getMessage()
public java.lang.String getMessage()
- throws java.rmi.RemoteException
+ throws java.rmi.RemoteException
{
- try {
- if (useNewInvoke) {
- Object $result = ref.invoke(this, $method_getMessage_1, null, 5353407034680111516L);
- return ((java.lang.String) $result);
- } else {
- 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 {
+ if (useNewInvoke) {
+ Object $result = ref.invoke(this, $method_getMessage_1, null, 5353407034680111516L);
+ return ((java.lang.String) $result);
+ } else {
+ 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 getProperty(String)
public java.lang.String getProperty(java.lang.String $param_String_1)
- throws java.rmi.RemoteException
+ throws java.rmi.RemoteException
{
- try {
- if (useNewInvoke) {
- Object $result = ref.invoke(this, $method_getProperty_2, new java.lang.Object[] {$param_String_1}, 77249282285080913L);
- return ((java.lang.String) $result);
- } else {
- 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.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_getProperty_2, new java.lang.Object[] {$param_String_1}, 77249282285080913L);
+ return ((java.lang.String) $result);
+ } else {
+ 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.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 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);
+ }
}
}
--- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/CanCreateStubs.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/CanCreateStubs.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -34,4 +34,3 @@
Object getForbiddenClass() throws Exception;
ActivationGroupID returnGroupID() throws RemoteException;
}
-
--- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.
*/
-
+
/* @test
* @bug 4179055
* @summary Some java apps need to have access to read "accessClassInPackage.sun.rmi.server"
@@ -55,151 +55,151 @@
*
* The test causes the activation system to need to create each of
* these classes in turn. The test will fail if the activation system
- * does not allow these classes to be created.
+ * does not allow these classes to be created.
*/
public class StubClassesPermitted
extends Activatable implements Runnable, CanCreateStubs
{
public static boolean sameGroup = false;
-
+
private static CanCreateStubs canCreateStubs = null;
private static Registry registry = null;
- public static void main(String args[]) {
+ public static void main(String args[]) {
- sameGroup = true;
-
- RMID rmid = null;
+ sameGroup = true;
+
+ RMID rmid = null;
- System.err.println("\nRegression test for bug/rfe 4179055\n");
-
- try {
- TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
+ System.err.println("\nRegression test for bug/rfe 4179055\n");
- registry = java.rmi.registry.LocateRegistry.
- createRegistry(TestLibrary.REGISTRY_PORT);
+ 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");
- }
+ // 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();
+ // start an rmid.
+ RMID.removeLog();
+ rmid = RMID.createRMID();
+ rmid.start();
- //rmid.addOptions(new String[] {"-C-Djava.rmi.server.logCalls=true"});
+ //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");
+ // 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);
+ // 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();
+ // 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();
- // 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) {
+ 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(""))
+ // 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");
- }
+ 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();
+ // 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 ");
- 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");
- }
+ } 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 @@
* unexport the object forcibly.
*/
public void run() {
- ActivationLibrary.deactivate(this, getID());
+ ActivationLibrary.deactivate(this, getID());
}
/**
@@ -217,12 +217,12 @@
* 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 @@
* 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 @@
* system implementation).
*/
public ActivationGroupID returnGroupID() throws RemoteException {
- return ActivationGroup.currentGroupID();
+ return ActivationGroup.currentGroupID();
}
}
--- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/ActivateMe.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/ActivateMe.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/CallbackInterface.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/CallbackInterface.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 void inc() throws RemoteException;
public int getNumDeactivated() throws RemoteException;
}
-
--- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/Callback_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/Callback_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
}
public class UnregisterGroup
- extends Activatable
- implements ActivateMe, Runnable
+ extends Activatable
+ implements ActivateMe, Runnable
{
private static Exception exception = null;
@@ -77,30 +77,30 @@
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 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;
+ 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();
- 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);
- /* 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;
- //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);
+ 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];
+ 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];
+ 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);
+ 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");
- }
+ 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;
+ /*
+ * 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;
- }
+ } catch (Exception e) {
+ exception = e;
+ }
- done = true;
- }
- };
+ done = true;
+ }
+ };
- t.start();
- t.join(120000);
+ 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");
- }
+ 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) {
- }
- }
+ } 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 {
+ // 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);
+ // 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();
- }
+ //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);
- }
+ ActivationLibrary.rmidCleanup(rmid);
+ }
}
}
--- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/dgc/VMID/CheckVMID.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/dgc/VMID/CheckVMID.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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());
+ }
}
}
--- a/jdk/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
+ 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");
+ /*
+ * 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);
+ 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);
+ 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");
+ 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.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 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();
- }
+ 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 + "]"; }
+ public String toString() { return "Wrapper[" + obj + "]"; }
}
private static class TestSF extends RMISocketFactory {
- private static volatile boolean shutdown = false;
- static void shutdownClientOutput() { shutdown = true; }
+ 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 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);
- }
+ 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 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 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);
+ }
+ }
+ }
}
}
--- a/jdk/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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);
+ }
}
}
--- a/jdk/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/dgc/dgcImplInsulation/DGCImplInsulation_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
implements java.rmi.Remote
{
private static final long serialVersionUID = 2;
-
+
// constructors
public DGCImplInsulation_Stub(java.rmi.server.RemoteRef ref) {
- super(ref);
+ super(ref);
}
-
+
}
--- a/jdk/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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");
+ 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");
+ /*
+ * 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");
+ /*
+ * 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();
+ RetryDirtyCalls impl = new RetryDirtyCalls();
- try {
- TestSF sf = new TestSF();
- RMISocketFactory.setSocketFactory(sf);
+ 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
+ /*
+ * 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);
+ /*
+ * 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;
+ 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;
- }
- }
- }
+ 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");
- }
+ 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");
- }
+ 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");
+ 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) {
- }
- }
+ } 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 @@
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);
}
}
--- a/jdk/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/dgc/retryDirtyCalls/RetryDirtyCalls_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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();
+ 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);
- }
+ } 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");
+ utilityToStart = utility;
- if (time >= TIME_OUT) {
-
- // dont pollute other tests; increase the likelihood
+ 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();
+ }
}
}
--- a/jdk/test/java/rmi/registry/altSecurityManager/TestSecurityManager.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/registry/altSecurityManager/TestSecurityManager.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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
}
}
--- a/jdk/test/java/rmi/registry/checkusage/CheckUsage.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/registry/checkusage/CheckUsage.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
/**
* 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();
- 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;
- }
+ // 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;
+ }
}
}
--- a/jdk/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 static void main(String[] args) {
- System.err.println("\nRegression test for bug 4242317\n");
+ System.err.println("\nRegression test for bug 4242317\n");
- TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
+ TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
- Process rmiregistry = null;
+ 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);
+ 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);
+ /*
+ * 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 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) };
+ 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());
+ System.err.println("\nCommand used to spawn rmiregistry process:");
+ System.err.println("\t" + Arrays.asList(cmdarray).toString());
- rmiregistry = Runtime.getRuntime().exec(cmdarray, null, rmiregistryDir);
+ 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);
- // 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();
- /*
- * 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();
+ /*
+ * 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);
+ /*
+ * 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;
- }
+ 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);
+ /*
+ * 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 + "\"");
- }
+ 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();
- }
- }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("TEST FAILED: " + e.toString());
+ } finally {
+ if (rmiregistry != null) {
+ rmiregistry.destroy();
+ }
+ }
}
}
--- a/jdk/test/java/rmi/registry/classPathCodebase/Dummy.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/registry/classPathCodebase/Dummy.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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
{
}
}
--- a/jdk/test/java/rmi/registry/emptyName/EmptyName.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/registry/emptyName/EmptyName.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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("");
}
}
--- a/jdk/test/java/rmi/registry/interfaceHash/InterfaceHash.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/registry/interfaceHash/InterfaceHash.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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("\nRegression test for bug 4472769");
- System.err.println(
- "\n=== verifying that J2SE registry's skeleton uses" +
- "\ncorrect interface hash and operation numbers:");
+ 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);
+ 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);
+ 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");
+ 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");
- }
+ 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");
- }
+ 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 + "\"");
+ 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");
- }
+ 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:");
+ 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();
+ 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);
+ 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);
+ 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);
+ 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 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 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 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 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("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("TEST PASSED");
}
}
--- a/jdk/test/java/rmi/registry/interfaceHash/ReferenceRegistryStub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/registry/interfaceHash/ReferenceRegistryStub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/registry/multipleRegistries/MultipleRegistries.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/registry/multipleRegistries/MultipleRegistries.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+
+ RemoteInterface server = null;
+ RemoteInterface proxy = null;
- System.err.println("proxy = " + proxy);
+ try {
+ System.err.println("export object");
+ server = new MultipleRegistries();
+ proxy =
+ (RemoteInterface) UnicastRemoteObject.exportObject(server, 0);
- System.err.println("export registries");
- Registry registryImpl1 = LocateRegistry.createRegistry(2030);
- Registry registryImpl2 = LocateRegistry.createRegistry(2040);
+ 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);
+ 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);
+ registry1.bind(NAME, proxy);
+ registry2.bind(NAME, proxy);
- System.err.println("lookup remote object in registries");
+ System.err.println("lookup remote object in registries");
- RemoteInterface remote1 = (RemoteInterface) registry1.lookup(NAME);
- RemoteInterface remote2 = (RemoteInterface) registry2.lookup(NAME);
+ 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("invoke methods on remote objects");
+ remote1.passObject(remote1);
+ remote2.passObject(remote2);
+
+ System.err.println("TEST PASSED");
- System.err.println("TEST PASSED");
-
- } finally {
- if (proxy != null) {
- UnicastRemoteObject.unexportObject(server, true);
- }
- }
+ } finally {
+ if (proxy != null) {
+ UnicastRemoteObject.unexportObject(server, true);
+ }
+ }
}
}
--- a/jdk/test/java/rmi/registry/reexport/Reexport.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/registry/reexport/Reexport.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
public class Reexport {
static public final int regport = TestLibrary.REGISTRY_PORT;
-
+
static public void main(String[] argv) {
- Registry 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);
- 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();
+ 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;
+ }
+ }
- reg = null;
- }
- }
-
static Registry createReg(boolean remoteOk) {
- Registry reg = null;
+ 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);
- }
- }
+ 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;
+ 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.
+ // 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();
+ 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) {
- }
+ } 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;
+ }
}
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/BenchServer.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/BenchServer.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
/**
* 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 @@
* 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;
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/BenchServerImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/BenchServerImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
/**
* 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 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);
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/BooleanArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/BooleanArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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: <array size> <# 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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/BooleanCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/BooleanCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ByteArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ByteArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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: <array size> <# 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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ByteCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ByteCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/CharArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/CharArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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: <array size> <# 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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/CharCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/CharCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ClassLoading.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ClassLoading.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/DoubleArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/DoubleArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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: <array size> <# 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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/DoubleCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/DoubleCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ExceptionCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ExceptionCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
}
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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ExportObjs.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ExportObjs.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* Benchmark for testing speed of UnicastRemoteObject.exportObject().
*/
public class ExportObjs implements Benchmark {
-
+
static class RemoteObj implements Remote {
}
@@ -44,19 +44,18 @@
* 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/FloatArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/FloatArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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: <array size> <# 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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/FloatCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/FloatCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/IntArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/IntArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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: <array size> <# 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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/IntCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/IntCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/LongArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/LongArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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: <array size> <# 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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/LongCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/LongCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.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 @@
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 @@
* Returns reference to benchmark server.
*/
public static BenchServer getBenchServer() {
- return server;
+ return server;
}
/**
@@ -127,252 +127,252 @@
p.println(" -t <num hours> repeat benchmarks for specified number of hours");
p.println(" -o <file> specify output file");
p.println(" -c <file> 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 <host:port> run benchmark client using server " +
- "on specified host/port");
- p.println(" -server <port> run benchmark server on given port");
+ p.println(" -client <host:port> run benchmark client using server " +
+ "on specified host/port");
+ p.println(" -server <port> 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 @@
} 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 @@
*/
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 HTML:
+ reporter = new HtmlReporter(repstr, title);
+ break;
- case XML:
- reporter = new XmlReporter(repstr, title);
- break;
-
- default:
- die("Error: unrecognized format type");
- }
+ case XML:
+ reporter = new XmlReporter(repstr, title);
+ break;
+
+ default:
+ die("Error: unrecognized format type");
+ }
}
-
+
/**
* Run benchmarks.
*/
@@ -430,4 +430,3 @@
harness.runBenchmarks(reporter, verbose);
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/NullCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/NullCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
-
- bsrv.unexport(stub, true);
- return time;
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < reps; i++)
+ stub.call();
+ long time = System.currentTimeMillis() - start;
+
+ bsrv.unexport(stub, true);
+ return time;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ObjArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ObjArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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 @@
}
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: <array size> <# 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ObjTreeCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ObjTreeCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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 @@
}
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: <tree depth> <# 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ProxyArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ProxyArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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];
+ 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);
+ for (int i = 0; i < size; i++)
+ proxies[i] = (Proxy) proxyCons.newInstance(consArgs);
- return proxies;
+ return proxies;
}
/**
@@ -97,19 +97,18 @@
* Arguments: <array size> <# 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);
+ 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;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/RemoteObjArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/RemoteObjArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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: <array size> <# 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ShortArrayCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ShortArrayCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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: <array size> <# 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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ShortCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/ShortCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
-
- bsrv.unexport(stub, true);
- return time;
+ 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/SmallObjTreeCalls.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/SmallObjTreeCalls.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
static class Node implements Serializable {
Object parent, left, right;
-
+
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@@ -52,42 +52,41 @@
}
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: <tree depth> <# 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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/BooleanArrays.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/BooleanArrays.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* Arguments: <array size> <# 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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Booleans.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Booleans.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* 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.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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/ByteArrays.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/ByteArrays.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* Arguments: <array size> <# 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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Bytes.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Bytes.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/CharArrays.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/CharArrays.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* Arguments: <array size> <# 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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Chars.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Chars.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/ClassDesc.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/ClassDesc.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
- long start = System.currentTimeMillis();
- doReps(oout, oin, sbuf, desc, ncycles);
+ doReps(oout, oin, sbuf, desc, 1); // warmup
+
+ 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();
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Cons.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Cons.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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();
- long start = System.currentTimeMillis();
- doReps(sbuf, dummy, reps);
+ doReps(sbuf, dummy, 1); // warmup
+
+ 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();
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/CustomDefaultObjTrees.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/CustomDefaultObjTrees.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
}
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 @@
* Arguments: <tree depth> <# 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;
}
@@ -100,33 +100,32 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/CustomObjTrees.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/CustomObjTrees.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
}
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 @@
* Arguments: <tree depth> <# 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;
}
@@ -121,33 +121,32 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/DoubleArrays.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/DoubleArrays.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* Arguments: <array size> <# 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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Doubles.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Doubles.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/ExternObjTrees.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/ExternObjTrees.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 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 @@
* Arguments: <tree depth> <# 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;
}
@@ -126,33 +126,32 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/FloatArrays.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/FloatArrays.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* Arguments: <array size> <# 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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Floats.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Floats.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/GetPutFieldTrees.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/GetPutFieldTrees.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
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 @@
* Arguments: <tree depth> <# 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;
}
@@ -125,33 +125,32 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/IntArrays.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/IntArrays.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* Arguments: <array size> <# 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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Ints.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Ints.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/LongArrays.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/LongArrays.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* Arguments: <array size> <# 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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Longs.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Longs.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Main.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Main.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* Object serialization benchmark mainline.
*/
public class Main {
-
+
static final String CONFFILE = "/bench/serial/config";
static final String VERSION = "1.3";
@@ -80,55 +80,55 @@
p.println(" -o <file> specify output file");
p.println(" -c <file> 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 @@
} 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 @@
} 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 @@
*/
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 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");
+ }
}
/**
@@ -261,4 +261,3 @@
harness.runBenchmarks(reporter, verbose);
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/ObjArrays.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/ObjArrays.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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 @@
}
}
}
-
+
/**
* 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 @@
* Arguments: <array size> <# 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 @@
* 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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/ObjTrees.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/ObjTrees.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* Arguments: <tree depth> <# 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/ProxyArrays.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/ProxyArrays.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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 @@
* Arguments: <array size> <# 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 @@
* 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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/ProxyClassDesc.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/ProxyClassDesc.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/RepeatObjs.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/RepeatObjs.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* Benchmark for testing speed of reads/writes of repeated objects.
*/
public class RepeatObjs implements Benchmark {
-
+
static class Node implements Serializable {
}
@@ -49,50 +49,49 @@
* 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());
- long start = System.currentTimeMillis();
- doReps(oout, oin, sbuf, objs, nbatches);
+ doReps(oout, oin, sbuf, objs, 1); // warmup
+
+ 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/ReplaceTrees.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/ReplaceTrees.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
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 @@
* Arguments: <tree depth> <# 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;
}
@@ -103,11 +103,11 @@
* 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/ShortArrays.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/ShortArrays.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* Arguments: <array size> <# 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();
+ }
+ }
}
}
-
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Shorts.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Shorts.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/SmallObjTrees.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/SmallObjTrees.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* Arguments: <tree depth> <# 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 @@
* 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/StreamBuffer.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/StreamBuffer.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* StreamBufferInputStream.read().
*/
public class StreamBuffer {
-
+
/**
* Output stream for writing to stream buffer.
*/
private class StreamBufferOutputStream extends OutputStream {
-
- private int pos;
+
+ 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(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;
- }
+ 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;
+
+ 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 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 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;
- }
+ 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 @@
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;
}
}
-
--- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Strings.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Strings.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* Arguments: <string length> <# 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());
- long start = System.currentTimeMillis();
- doReps(oout, oin, sbuf, strs, nbatches, ncycles);
+ doReps(oout, oin, sbuf, strs, 1, ncycles); // warmup
+
+ long start = System.currentTimeMillis();
+ doReps(oout, oin, sbuf, strs, nbatches, ncycles);
return System.currentTimeMillis() - start;
}
@@ -66,16 +66,16 @@
* 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 @@
* 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();
+ }
+ }
}
}
-
--- a/jdk/test/java/rmi/reliability/juicer/Apple.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/juicer/Apple.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.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 {
--- a/jdk/test/java/rmi/reliability/juicer/AppleEvent.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/juicer/AppleEvent.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
/**
* 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 @@
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;
}
}
--- a/jdk/test/java/rmi/reliability/juicer/AppleImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/juicer/AppleImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
-
- logger.log(Level.FINEST,
- threadName + ": " + toString() + ".newOrange(" + name + "): END");
+ Orange orange = new OrangeImpl(name);
- return orange;
+ logger.log(Level.FINEST,
+ threadName + ": " + toString() + ".newOrange(" + name + "): END");
+
+ return orange;
}
public String toString() {
- return name;
+ return name;
}
}
--- a/jdk/test/java/rmi/reliability/juicer/AppleUser.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/juicer/AppleUser.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/reliability/juicer/AppleUserImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/juicer/AppleUserImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
*/
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 @@
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 @@
* to start "juicing".
*/
public synchronized void startTest() throws RemoteException {
- startTestNotified = true;
+ startTestNotified = true;
this.notifyAll();
}
@@ -109,9 +109,9 @@
* 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 @@
* 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);
+ */
+ 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
+ /*
+ * 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)));
+ */
+ 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]) + ")");
- }
- }
+ /*
+ * 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) {
- }
+ try {
+ Thread.sleep(Math.abs(random.nextInt() % 10) * 1000);
+ } catch (InterruptedException e) {
+ }
- } while (System.currentTimeMillis() < stopTime);
+ } while (System.currentTimeMillis() < stopTime);
- } catch (Exception e) {
- status = e;
- }
- finished = true;
- synchronized (lock) {
- lock.notifyAll();
- }
- }
+ } catch (Exception e) {
+ status = e;
+ }
+ finished = true;
+ synchronized (lock) {
+ lock.notifyAll();
+ }
+ }
}
private static void usage() {
- System.err.println("Usage: AppleUserImpl [-hours <hours> | " +
- "-seconds <seconds>]");
- System.err.println(" [-maxLevel <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 <hours> | " +
+ "-seconds <seconds>]");
+ System.err.println(" [-maxLevel <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 @@
* 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");
- }
+ } 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();
+ 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
+ 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();
- }
- }
+ while (!startTestNotified) {
+ user.wait();
+ }
+ }
- startTime = System.currentTimeMillis();
- logger.log(Level.INFO, "Test starting");
+ 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");
+ // 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();
- }
- }
+ 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");
+ 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 (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);
+ }
}
}
}
--- a/jdk/test/java/rmi/reliability/juicer/ApplicationServer.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/juicer/ApplicationServer.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 @@
* 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 <numApples>]");
- System.err.println(" [-registryHost <host>]");
- 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 <numApples>]");
+ System.err.println(" [-registryHost <host>]");
+ 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
}
}
--- a/jdk/test/java/rmi/reliability/juicer/Orange.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/juicer/Orange.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
/**
* 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;
}
--- a/jdk/test/java/rmi/reliability/juicer/OrangeEcho.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/juicer/OrangeEcho.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
/**
* 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;
}
--- a/jdk/test/java/rmi/reliability/juicer/OrangeEchoImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/juicer/OrangeEchoImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
*/
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 @@
* 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;
}
}
--- a/jdk/test/java/rmi/reliability/juicer/OrangeImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/reliability/juicer/OrangeImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
private final String name;
public OrangeImpl(String name) throws RemoteException {
- this.name = name;
+ this.name = name;
}
/**
@@ -44,31 +44,31 @@
* 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;
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressConstants.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressConstants.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 ,.!?\"'()";
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressInputStream.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressInputStream.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
{
public CompressInputStream(InputStream in) {
- super(in);
+ super(in);
}
// buffer of unpacked 6-bit codes from last 32-word read
@@ -41,70 +41,70 @@
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++];
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressOutputStream.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/CompressOutputStream.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
{
public CompressOutputStream(OutputStream out) {
- super(out);
+ super(out);
}
// buffer of 6-bit codes to pack into next 32-bit word
@@ -41,44 +41,44 @@
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;
+ }
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/Echo.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/Echo.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1998 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* 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 void shutdown() throws Exception
{
- (new Thread(this,"Echo.shutdown")).start();
+ (new Thread(this,"Echo.shutdown")).start();
}
/**
@@ -98,43 +98,43 @@
* 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];
+ /*
+ * 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();
- }
+ 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();
+ }
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/MultiSocketFactory.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/MultiSocketFactory.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
+ private String protocol;
+ private byte[] data;
- public ServerFactory(String protocol, byte[] data) {
- this.protocol = protocol;
- this.data = 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]);
+ public ServerSocket createServerSocket(int port) throws IOException
+ {
+ if (protocol.equals("compress")) {
+ return new CompressServerSocket(port);
- }
-
- return def.createServerSocket(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;
+ private String protocol;
+ private byte[] data;
+
+ public ClientFactory(String protocol, byte[] data) {
+ this.protocol = protocol;
+ this.data = 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]);
+ 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);
- }
+ }
+
+ 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;
+ private InputStream in;
+ private OutputStream out;
+ public CompressSocket() { super(); }
+ public CompressSocket(String host, int port) throws IOException {
+ super(host, port);
}
- public OutputStream getOutputStream() throws IOException {
- if (out == null) {
- out = new CompressOutputStream(super.getOutputStream());
- }
- return out;
- }
+ 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;
+ 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 OutputStream getOutputStream() throws IOException {
- if (out == null) {
- out = new XorOutputStream(super.getOutputStream(), pattern);
- }
- return out;
- }
+ 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;
- }
+ 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 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;
+ }
}
}
-
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
+ 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);
- }
+ try {
+ LocateRegistry.createRegistry(REGISTRY_PORT);
+ } catch (Exception e) {
+ TestLibrary.bomb("creating registry", e);
+ }
+
+ RMID rmid = null;
- 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();
+ 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();
- }
+ 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-->");
+
+ System.err.println("\nCreate Test-->");
+
+ Echo[] echo = new Echo[protocol.length];
+
+ for (int i = 0; i < protocol.length; i++) {
- 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]);
+ 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();
+ 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);
+ /* 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);
+ 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;
+ /* 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-->");
+ 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);
- }
- }
+ 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);
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Compress.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Compress.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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 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 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;
+ private InputStream in;
+ private OutputStream out;
+ public CompressSocket() { super(); }
+ public CompressSocket(String host, int port) throws IOException {
+ super(host, port);
}
- public OutputStream getOutputStream() throws IOException {
- if (out == null) {
- out = new CompressOutputStream(super.getOutputStream());
- }
- return out;
- }
+ 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;
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Hello.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/Hello.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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;
+ }
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
* (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;
+
+ Registry registry = null;
+ HelloImpl impl = null;
- System.out.println("\nRegression test for bug 4148850\n");
-
- TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
+ System.out.println("\nRegression test for bug 4148850\n");
- try {
- impl = new HelloImpl();
+ 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, "");
+ /* 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");
- try {
+ } 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();
+ /*
+ * spawn VM for HelloServer which will download a client socket
+ * factory
+ */
+ serverVM.start();
- synchronized (impl) {
+ synchronized (impl) {
+
+ System.out.println("waiting for remote notification");
+
+ if (!HelloImpl.clientCalledSuccessfully) {
+ impl.wait(75 * 1000);
+ }
- 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...");
- }
- }
+ if (!HelloImpl.clientCalledSuccessfully) {
+ throw new RuntimeException("Client did not execute call in time...");
+ }
+ }
- System.err.println("\nRegression test for bug 4148850 passed.\n ");
+ System.err.println("\nRegression test for bug 4148850 passed.\n ");
+
+ } catch (Exception e) {
+ TestLibrary.bomb("test failed", e);
- } 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;
- }
+ } 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);
+ }
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressConstants.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressConstants.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 ,.!?\"'()";
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressInputStream.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressInputStream.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
{
public CompressInputStream(InputStream in) {
- super(in);
+ super(in);
}
// buffer of unpacked 6-bit codes from last 32-word read
@@ -41,70 +41,70 @@
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++];
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressOutputStream.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/CompressOutputStream.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
{
public CompressOutputStream(OutputStream out) {
- super(out);
+ super(out);
}
// buffer of 6-bit codes to pack into next 32-bit word
@@ -41,44 +41,44 @@
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;
+ }
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/Echo.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/Echo.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1998 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
- 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();
- }
+ 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();
+ }
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/MultiSocketFactory.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/MultiSocketFactory.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
+ private String protocol;
+ private byte[] data;
- public ServerFactory(String protocol, byte[] data) {
- this.protocol = protocol;
- this.data = 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]);
+ public ServerSocket createServerSocket(int port) throws IOException
+ {
+ if (protocol.equals("compress")) {
+ return new CompressServerSocket(port);
- }
-
- return def.createServerSocket(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;
+ private String protocol;
+ private byte[] data;
+
+ public ClientFactory(String protocol, byte[] data) {
+ this.protocol = protocol;
+ this.data = 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]);
+ 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);
- }
+ }
+
+ 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;
+ private InputStream in;
+ private OutputStream out;
+ public CompressSocket() { super(); }
+ public CompressSocket(String host, int port) throws IOException {
+ super(host, port);
}
- public OutputStream getOutputStream() throws IOException {
- if (out == null) {
- out = new CompressOutputStream(super.getOutputStream());
- }
- return out;
- }
+ 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;
+ 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 OutputStream getOutputStream() throws IOException {
- if (out == null) {
- out = new XorOutputStream(super.getOutputStream(), pattern);
- }
- return out;
- }
+ 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;
- }
+ 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 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;
+ }
}
}
-
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
public class UseCustomSocketFactory {
public static void main(String[] args) {
-
- String[] protocol = new String[] { "", "compress", "xor" };
+
+ String[] protocol = new String[] { "", "compress", "xor" };
+
+ System.out.println("\nRegression test for bug 4127826\n");
- System.out.println("\nRegression test for bug 4127826\n");
-
- TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
+ TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
- try {
- LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT);
- } catch (Exception e) {
- TestLibrary.bomb("creating registry", e);
- }
+ try {
+ LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT);
+ } catch (Exception e) {
+ TestLibrary.bomb("creating registry", e);
+ }
- for (int i = 0; i < protocol.length; i++) {
+ for (int i = 0; i < protocol.length; i++) {
- System.err.println("test policy: " +
- TestParams.defaultPolicy);
+ 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();
+ 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);
+ /* 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);
+ 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);
-
- }
- }
- }
+ /* 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);
+
+ }
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/RemoteServer/setLogPermission/SetLogPermission.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/RemoteServer/setLogPermission/SetLogPermission.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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 });
- 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);
+ 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;
- }
+ 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;
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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++) {
- 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);
+ 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);
- System.err.println("invoking method on stub");
- stub.receive(stub);
+ System.err.println("invoking method on stub");
+ stub.receive(stub);
- UnicastRemoteObject.unexportObject(impl, true);
- System.err.println("unexported impl");
+ 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");
+ 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");
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/changeHostName/ChangeHostName_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
+ System.err.println("\nRegression test for bug 4308492\n");
- KeepAliveDuringCall obj = new KeepAliveDuringCall();
+ KeepAliveDuringCall obj = new KeepAliveDuringCall();
- try {
- UnicastRemoteObject.exportObject(obj);
- System.err.println("exported shutdown monitor");
+ try {
+ UnicastRemoteObject.exportObject(obj);
+ System.err.println("exported shutdown monitor");
- Registry localRegistry =
- LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT);
- System.err.println("created local registry");
+ 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");
+ localRegistry.bind(BINDING, obj);
+ System.err.println("bound shutdown monitor in local registry");
- System.err.println("starting remote ShutdownImpl VM...");
- (new JavaVM("ShutdownImpl")).start();
+ 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);
- }
+ 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);
- }
+ 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");
- }
- }
+ 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");
+ 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) {
- }
- }
+ } 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) {
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/Shutdown.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/Shutdown.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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();
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownMonitor.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownMonitor.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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) {
+ }
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+
+ System.err.println("\nRegression test for bug 4513223\n");
- Receiver stub = (Receiver) RemoteObject.toStub(impl);
- System.err.println("stub for impl: " + stub);
+ Remote impl2 = null;
+ try {
+ Remote impl = new MarshalAfterUnexport2();
+ System.err.println(
+ "created impl extending URO (with a UnicastServerRef2): " +
+ impl);
- UnicastRemoteObject.unexportObject(impl, true);
- System.err.println("unexported impl");
+ Receiver stub = (Receiver) RemoteObject.toStub(impl);
+ System.err.println("stub for impl: " + stub);
+
+ UnicastRemoteObject.unexportObject(impl, true);
+ System.err.println("unexported impl");
- impl2 = new MarshalAfterUnexport2();
- Receiver stub2 = (Receiver) RemoteObject.toStub(impl2);
+ impl2 = new MarshalAfterUnexport2();
+ 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) {
+ }
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport2_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/marshalAfterUnexport/MarshalAfterUnexport_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/unexportObject/Ping.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/unexportObject/Ping.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
public interface Ping extends Remote {
public void ping() throws RemoteException;
}
-
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.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 @@
* 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) {
+ }
}
}
-
-
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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]);
+
+ 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());
+ }
- 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("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");
+ }
- 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");
- }
+ } 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");
+ }
- 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");
- }
+ 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);
- }
- }
+ 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);
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/useDynamicProxies/UseDynamicProxies_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.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 @@
* 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 @@
* 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;
+ Object dummy = new Object();
+ CheckUnmarshal cu = null;
+ CheckUnmarshalOnStopThread cuonst = null;
- System.err.println("\nregression test for bugs: " +
- "4118600 and 4177704\n");
+ System.err.println("\nregression test for bugs: " +
+ "4118600 and 4177704\n");
- try {
- cuonst = new CheckUnmarshalOnStopThread();
- cu = (CheckUnmarshal) UnicastRemoteObject.toStub(cuonst);
+ try {
+ cuonst = new CheckUnmarshalOnStopThread();
+ cu = (CheckUnmarshal) UnicastRemoteObject.toStub(cuonst);
- // make sure that RMI will free connections appropriately
- // under several situations:
+ // 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 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 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);
+ // 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 ");
+ System.err.println
+ ("\nsuccess: CheckUnmarshalOnStopThread test passed ");
- } catch (Exception e) {
- TestLibrary.bomb(e);
- } finally {
- cu = null;
- deactivate(cuonst);
- }
+ } 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)
+ // 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 "
- }
- }
+ 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");
+ 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();
+ }
}
}
--- a/jdk/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshalOnStopThread_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshall.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/CheckUnmarshall.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
RuntimeExceptionParameter rep)
throws RemoteException;
}
-
--- a/jdk/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/PoisonPill.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/PoisonPill.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
--- a/jdk/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/RuntimeExceptionParameter.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unmarshal/checkUnmarshalOnStopThread/RuntimeExceptionParameter.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
{
throw new RuntimeException("wrote a parameter whos writeObject " +
"method always throws a RuntimeException"
- );
+ );
}
}
-
--- a/jdk/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
+ 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));
+ /*
+ * 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();
+ FiniteGCLatency obj = new FiniteGCLatency();
- try {
- UnicastRemoteObject.exportObject(obj);
- System.err.println("exported remote object");
+ try {
+ UnicastRemoteObject.exportObject(obj);
+ System.err.println("exported remote object");
- LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT);
- System.err.println("created registry");
+ 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");
+ 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);
+ 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");
- }
- }
+ 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) {
- }
- }
+ } 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) {
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
implements java.rmi.Remote
{
private static final long serialVersionUID = 2;
-
+
// constructors
public FiniteGCLatency_Stub(java.rmi.server.RemoteRef ref) {
- super(ref);
+ super(ref);
}
-
+
}
--- a/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
+ 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));
+ /*
+ * 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();
+ LeaseCheckInterval obj = new LeaseCheckInterval();
- try {
- UnicastRemoteObject.exportObject(obj);
- System.err.println("exported remote object");
+ try {
+ UnicastRemoteObject.exportObject(obj);
+ System.err.println("exported remote object");
- Registry localRegistry =
- LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT);
- System.err.println("created local registry");
+ 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");
+ 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();
+ 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);
+ 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");
- }
- }
+ 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) {
- }
- }
+ } 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) {
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
implements java.rmi.Remote
{
private static final long serialVersionUID = 2;
-
+
// constructors
public LeaseCheckInterval_Stub(java.rmi.server.RemoteRef ref) {
- super(ref);
+ super(ref);
}
-
+
}
--- a/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/SelfTerminator.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/SelfTerminator.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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();
+ }
}
}
--- a/jdk/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
+ 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));
+ /*
+ * 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();
+ MarshalledObjectGet obj = new MarshalledObjectGet();
- try {
- Remote stub = UnicastRemoteObject.exportObject(obj);
- System.err.println("exported remote object");
+ 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");
+ MarshalledObject mobj = new MarshalledObject(stub);
+ Remote unmarshalledStub = (Remote) mobj.get();
+ System.err.println("unmarshalled stub from marshalled object");
- synchronized (obj.lock) {
- obj.unreferencedInvoked = false;
+ 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);
+ 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");
- }
- }
+ 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");
+ 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) {
- }
- }
- }
+ } 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) {
+ }
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unreferenced/marshalledObjectGet/MarshalledObjectGet_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
implements java.rmi.Remote
{
private static final long serialVersionUID = 2;
-
+
// constructors
public MarshalledObjectGet_Stub(java.rmi.server.RemoteRef ref) {
- super(ref);
+ super(ref);
}
-
+
}
--- a/jdk/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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());
+ // 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();
+ // 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();
- }
+ 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");
+ 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));
+ /*
+ * 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();
+ 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);
+ 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);
+ /*
+ * 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");
+ UnicastRemoteObject.exportObject(obj);
+ System.err.println("exported remote object");
- LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT);
- System.err.println("created registry");
+ 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");
+ 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;
- }
- }
+ 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.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");
- }
- }
+ 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) {
- }
- }
+ } 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) {
+ }
+ }
}
}
--- a/jdk/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
implements java.rmi.Remote
{
private static final long serialVersionUID = 2;
-
+
// constructors
public UnreferencedContext_Stub(java.rmi.server.RemoteRef ref) {
- super(ref);
+ super(ref);
}
-
+
}
--- a/jdk/test/java/rmi/transport/acceptLoop/CloseServerSocketOnTermination.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/acceptLoop/CloseServerSocketOnTermination.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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<Throwable> toThrow =
- new ThreadLocal<Throwable>();
- 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<Throwable> toThrow =
+ new ThreadLocal<Throwable>();
+ private static class Thrower {
+ Thrower() throws Throwable { throw toThrow.get(); }
+ }
}
}
--- a/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.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();
+ 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);
- 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("", "", "");
+ /* 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");
+ } 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 = "=";
- }
+ 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;
+ 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();
+ // 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);
- }
+ 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 {
+ 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);
- }
+ 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);
+ /** 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);
}
}
--- a/jdk/test/java/rmi/transport/checkFQDN/CheckFQDNClient.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/checkFQDN/CheckFQDNClient.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+
+ // 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");
+ 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);
+ } catch (Exception e ) {
+ throw new RuntimeException(e.getMessage());
+ }
+ System.exit(0);
}
-
+
/* what is the rmi hostname for this vm? */
public static String retrieveServerName () {
- try {
+ try {
+
+ CheckFQDNClient chk = new CheckFQDNClient();
+
+ synchronized(chk) {
+ (new Thread (chk)).start();
+ chk.wait(NAME_SERVICE_TIME_OUT);
+ }
- 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());
- }
+ 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();
+ }
+ }
}
}
--- a/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/transport/checkFQDN/TellServerName.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/checkFQDN/TellServerName.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
interface TellServerName extends Remote {
void tellServerName (String serverName) throws RemoteException;
}
-
--- a/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.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 @@
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;
+ 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);
+ /*
+ * 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);
+ try {
+ Registry registry =
+ java.rmi.registry.LocateRegistry.
+ createRegistry(TestLibrary.REGISTRY_PORT);
- leakServer = new CheckLeaseLeak();
- registry.rebind("/LeaseLeak", leakServer);
+ 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);
- /* 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();
+ 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);
- 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;
- }
- }
+ } 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");
- }
+ /* 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;
+ 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 {
- /**
- * Will eventually be set to point at the leaseTable inside
- * DGCImpl.
- */
- Map leaseTable = null;
- final Remote[] dgcImpl = new Remote[1];
- Field f;
+ ObjID dgcID = new ObjID(DGC_ID);
- try {
- f = (Field) java.security.AccessController.doPrivileged
- (new java.security.PrivilegedExceptionAction() {
- public Object run() throws Exception {
+ /*
+ * 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 });
- 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 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);
+ /* Get the lease table from the DGCImpl. */
+ Field reflectedLeaseTable =
+ dgcImpl[0].getClass().getDeclaredField
+ ("leaseTable");
+ reflectedLeaseTable.setAccessible(true);
- return reflectedLeaseTable;
- }
- });
+ 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]);
+ /**
+ * 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();
+ numLeaseInfosLeft = leaseTable.size();
- } catch(Exception e) {
- if (e instanceof java.security.PrivilegedActionException)
- e = ((java.security.PrivilegedActionException) e).
- getException();
- TestLibrary.bomb(e);
- }
+ } catch(Exception e) {
+ if (e instanceof java.security.PrivilegedActionException)
+ e = ((java.security.PrivilegedActionException) e).
+ getException();
+ TestLibrary.bomb(e);
+ }
- return numLeaseInfosLeft;
+ return numLeaseInfosLeft;
}
}
--- a/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeak.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeak.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.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());
+ }
}
}
--- a/jdk/test/java/rmi/transport/closeServerSocket/CloseServerSocket.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/closeServerSocket/CloseServerSocket.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
private CloseServerSocket() { }
public static void main(String[] args) throws Exception {
- System.err.println("\nRegression test for bug 4457683\n");
+ 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);
+ 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.
- */
+ /*
+ * 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");
-// }
-// }
+// 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("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() { };
+ boolean serverSocketClosed = false;
+ SSF() { };
- public ServerSocket createServerSocket(int port) throws IOException {
- return new SS(port);
- }
+ 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);
- };
+ 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();
- }
- }
+ public void close() throws IOException {
+ synchronized (SSF.this) {
+ serverSocketClosed = true;
+ SSF.this.notifyAll();
+ }
+ System.err.println("- closing server socket: " + this);
+ super.close();
+ }
+ }
}
}
--- a/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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) + "";
+ 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();
+ testImplVM = new JavaVM("TestImpl", options, "");
+ testImplVM.start();
- synchronized (test) {
- Thread t = new Thread(test);
- t.setDaemon(true);
- t.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);
- }
+ // 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.");
+ 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;
+ try {
+ String echo = null;
- // give the test remote object time to initialize.
- Thread.currentThread().sleep(8000);
+ // 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.");
+ // 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);
+ /* give TestImpl time to lock the target in the
+ * object table and any dirtys finish.
+ */
+ Thread.currentThread().sleep(5000);
- //unreference "Foo"
- foo = null;
+ //unreference "Foo"
+ foo = null;
+
+ //garbage collect and finalize foo
+ Runtime.getRuntime().gc();
+ Runtime.getRuntime().runFinalization();
- //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);
- }
+ //import "Bar"
+ Test bar = (Test) Naming.lookup("rmi://:" +
+ TestLibrary.REGISTRY_PORT +
+ "/Bar");
- // flag exercises finished
- finished = true;
+ /* 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);
+ }
- } catch (RemoteException e) {
- }
-
- } catch (Exception e) {
- TestLibrary.bomb("test failed", e);
- } finally {
- }
+ // flag exercises finished
+ finished = true;
+
+ } catch (RemoteException e) {
+ }
+
+ } catch (Exception e) {
+ TestLibrary.bomb("test failed", e);
+ } finally {
+ }
}
}
--- a/jdk/test/java/rmi/transport/dgcDeadLock/Test.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/dgcDeadLock/Test.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 1998 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
--- a/jdk/test/java/rmi/transport/dgcDeadLock/TestImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/dgcDeadLock/TestImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.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 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);
+ registry = java.rmi.registry.LocateRegistry.
+ createRegistry(TestLibrary.REGISTRY_PORT);
- //export "Foo"
- foo = new TestImpl();
- Naming.rebind("rmi://:" +
- TestLibrary.REGISTRY_PORT
- + "/Foo", foo);
+ //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);
+ 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;
+ Remote toLock = null;
+ int timeOut = 0;
- TargetLocker(Remote toLock, int timeOut) {
- this.toLock = toLock;
- this.timeOut = timeOut;
- }
+ 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);
+ public void run() {
+ try {
+ // give dgc dirty calls time to finish.
+ Thread.currentThread().sleep(4000);
- java.security.AccessController.
- doPrivileged(new LockTargetCheckLeases(toLock,
- timeOut));
+ java.security.AccessController.
+ doPrivileged(new LockTargetCheckLeases(toLock,
+ timeOut));
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- System.exit(1);
- }
- }
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
}
- static class LockTargetCheckLeases
- implements java.security.PrivilegedAction {
+ static class LockTargetCheckLeases
+ implements java.security.PrivilegedAction {
+
+ Remote toLock = null;
+ int timeOut = 0;
- Remote toLock = null;
- int timeOut = 0;
+ LockTargetCheckLeases(Remote toLock, int timeOut) {
+ this.toLock = toLock;
+ this.timeOut = timeOut;
+ }
- 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");
- 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");
- }
+ /* 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);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- System.exit(1);
- }
- return null;
- }
+ // 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;
+ final Target target = t;
+
+ java.security.AccessController.doPrivileged(
- 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);
- // put this into another class?
- new java.security.PrivilegedAction() {
- public Object run() {
- try {
+ // 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();
- 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;
- }
- });
+ /* 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;
+ }
+ });
}
}
--- a/jdk/test/java/rmi/transport/dgcDeadLock/TestImpl_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/dgcDeadLock/TestImpl_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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;
+ }
+ }
+ }
}
}
--- a/jdk/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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;
+ }
+ }
+ }
}
}
--- a/jdk/test/java/rmi/transport/httpSocket/HttpSocketTest.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/httpSocket/HttpSocketTest.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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;
+
+ Registry registry = null;
- TestLibrary.suggestSecurityManager(null);
-
- // Set the socket factory.
- System.err.println("installing socket factory");
- RMISocketFactory.setSocketFactory(new RMIHttpToPortSocketFactory());
+ TestLibrary.suggestSecurityManager(null);
- try {
+ // Set the socket factory.
+ System.err.println("installing socket factory");
+ RMISocketFactory.setSocketFactory(new RMIHttpToPortSocketFactory());
+
+ 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 );
}
}
-
-
-
-
-
--- a/jdk/test/java/rmi/transport/httpSocket/HttpSocketTest_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/httpSocket/HttpSocketTest_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
+ 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);
+ 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<CSF> registryRef = new WeakReference<CSF>(csf);
- Registry registryStub = LocateRegistry.getRegistry("", PORT, csf);
- csf = null;
- registryStub.list();
- registryStub = null;
- UnicastRemoteObject.unexportObject(registryImpl, true);
+ Registry registryImpl = LocateRegistry.createRegistry(PORT);
+ CSF csf = new CSF();
+ Reference<CSF> registryRef = new WeakReference<CSF>(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();
+ 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());
- }
+ if (CSF.deserializedInstances.size() != SESSIONS) {
+ throw new Error("unexpected number of deserialized instances: " +
+ CSF.deserializedInstances.size());
+ }
- int nonNullCount = 0;
- for (Reference<CSF> 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");
- }
+ int nonNullCount = 0;
+ for (Reference<CSF> 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");
- }
+ 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("TEST PASSED");
}
private static class CSF implements RMIClientSocketFactory, Serializable {
- static final List<Reference<CSF>> deserializedInstances =
- Collections.synchronizedList(new ArrayList<Reference<CSF>>());
- 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<CSF>(this));
- }
+ static final List<Reference<CSF>> deserializedInstances =
+ Collections.synchronizedList(new ArrayList<Reference<CSF>>());
+ 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<CSF>(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);
+ }
}
}
--- a/jdk/test/java/rmi/transport/pinLastArguments/PinLastArguments.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/pinLastArguments/PinLastArguments.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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<Ping>(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<Ping>(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");
}
}
--- a/jdk/test/java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
}
}
--- a/jdk/test/java/rmi/transport/readTimeout/ReadTimeoutTest.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/readTimeout/ReadTimeoutTest.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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.<clinit>
- System.setProperty("sun.rmi.transport.tcp.readTimeout", Integer.toString(DELAY));
+ // Make trouble for ourselves
+ if (System.getSecurityManager() == null)
+ System.setSecurityManager(new RMISecurityManager());
+
+ // Flaky code alert - hope this is executed before TCPTransport.<clinit>
+ 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);
- // Set the socket factory.
- System.err.println("(installing socket factory)");
- SomeFactory fac = new SomeFactory();
- RMISocketFactory.setSocketFactory(fac);
+ // Create remote object
+ TestImpl impl = new TestImpl();
- // 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();
- // 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(?)");
- // 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();
+ // 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();
+ // 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);
- }
+ // 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.");
- }
+ 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) {
- }
- }
+ } finally {
+ try {
+ if (DoS != null)
+ DoS.close(); // aborts the reader if still blocked
+ impl.unexport();
+ } catch (Throwable unmatter) {
+ }
+ }
- // Should exit here
+ // Should exit here
}
private static class SomeFactory
- extends RMISocketFactory
+ extends RMISocketFactory
{
- private int servport = 0;
+ private int servport = 0;
- public Socket createSocket(String h, int p)
- throws IOException
- {
- return (new Socket(h, p));
- }
+ 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);
- }
+ /** 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);
- }
+ /** 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;
+ private InputStream readon;
+ private boolean[] vec;
- public SomeReader(InputStream s, boolean[] successvec) {
- super();
- this.setDaemon(true);
- this.readon = s;
- this.vec = successvec;
- }
+ 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;
+ 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();
- }
- }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
} // end class SomeReader
}
--- a/jdk/test/java/rmi/transport/readTimeout/TestIface.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/readTimeout/TestIface.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
extends Remote
{
public String testCall(String ign)
- throws RemoteException;
+ throws RemoteException;
}
--- a/jdk/test/java/rmi/transport/readTimeout/TestImpl.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/readTimeout/TestImpl.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 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");
}
}
-
--- a/jdk/test/java/rmi/transport/readTimeout/TestImpl_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/readTimeout/TestImpl_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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);
+ }
}
}
--- a/jdk/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 static void main(String[] args) {
- System.err.println("\nRegression test for bug 4404702\n");
+ 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 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();
+ /*
+ * 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();
+ 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);
+ 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");
+ 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");
+ loader = null;
+ System.err.println("nulled strong reference to loader");
- UnicastRemoteObject.unexportObject(obj, true);
- System.err.println("unexported remote object");
+ 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();
+ /*
+ * 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(
+ "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();
+ 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) {
- }
- }
+ } 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 @@
* 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]);
+ }
+ }
}
}
--- a/jdk/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak_Stub.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak_Stub.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
implements java.rmi.Remote
{
private static final long serialVersionUID = 2;
-
+
// constructors
public RuntimeThreadInheritanceLeak_Stub(java.rmi.server.RemoteRef ref) {
- super(ref);
+ super(ref);
}
-
+
}
--- a/jdk/test/javax/crypto/Cipher/TestGetInstance.java Fri Apr 18 07:51:43 2008 -0400
+++ b/jdk/test/javax/crypto/Cipher/TestGetInstance.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 @@
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");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/management/modelmbean/LoggingExceptionTest.java Wed Apr 23 06:35:28 2008 -0400
@@ -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!");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/management/query/QueryNotifFilterTest.java Wed Apr 23 06:35:28 2008 -0400
@@ -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<? extends Notification> notifClass;
+ Case(Notification notif, String query, boolean expect) {
+ this(notif, query, notif.getClass(), expect);
+ }
+ Case(Notification notif, String query,
+ Class<? extends Notification> 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<? extends Notification> 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<Attribute> 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<String> expect = new HashSet<String>(
+ Arrays.asList(
+ "Class", "Message", "SequenceNumber", "Source",
+ "TimeStamp", "Type", "UserData"));
+ Set<String> actual = new HashSet<String>();
+ 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<ObjectName> 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<ObjectInstance> 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");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java Wed Apr 23 06:35:28 2008 -0400
@@ -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());
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java Wed Apr 23 06:35:28 2008 -0400
@@ -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());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/KeyStore/SecretKeysBasic.java Wed Apr 23 06:35:28 2008 -0400
@@ -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<String> 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!");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/KeyStore/SecretKeysBasic.sh Wed Apr 23 06:35:28 2008 -0400
@@ -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}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/CriticalSubjectAltName.java Wed Apr 23 06:35:28 2008 -0400
@@ -0,0 +1,262 @@
+/*
+ * 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
+ * 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 6668231
+ * @summary Presence of a critical subjectAltName causes JSSE's SunX509 to
+ * fail trusted checks
+ * @author Xuelei Fan
+ *
+ * This test depends on binary keystore, crisubn.jks and trusted.jks. Because
+ * JAVA keytool cannot generate X509 certificate with SubjectAltName extension,
+ * the certificates are generated with openssl toolkits and then imported into
+ * JAVA keystore.
+ *
+ * The crisubn.jks holds a private key entry and the corresponding X509
+ * certificate issued with an empty Subject field, and a critical
+ * SubjectAltName extension.
+ *
+ * The trusted.jks holds the trusted certificate.
+ */
+import java.io.*;
+import java.net.*;
+import javax.net.ssl.*;
+import java.security.cert.Certificate;
+
+public class CriticalSubjectAltName implements HostnameVerifier {
+ /*
+ * =============================================================
+ * Set the various variables needed for the tests, then
+ * specify what tests to run on each side.
+ */
+
+ /*
+ * Should we run the client or server in a separate thread?
+ * Both sides can throw exceptions, but do you have a preference
+ * as to which side should be the main thread.
+ */
+ static boolean separateServerThread = true;
+
+ /*
+ * Where do we find the keystores?
+ */
+ static String pathToStores = "./";
+ static String keyStoreFile = "crisubn.jks";
+ static String trustStoreFile = "trusted.jks";
+ static String passwd = "passphrase";
+
+ /*
+ * Is the server ready to serve?
+ */
+ volatile static boolean serverReady = false;
+
+ /*
+ * Turn on SSL debugging?
+ */
+ static boolean debug = false;
+
+ /*
+ * If the client or server is doing some kind of object creation
+ * that the other side depends on, and that thread prematurely
+ * exits, you may experience a hang. The test harness will
+ * terminate all hung threads after its timeout has expired,
+ * currently 3 minutes by default, but you might try to be
+ * smart about it....
+ */
+
+ /*
+ * Define the server side of the test.
+ *
+ * If the server prematurely exits, serverReady will be set to true
+ * to avoid infinite hangs.
+ */
+ void doServerSide() throws Exception {
+ SSLServerSocketFactory sslssf =
+ (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+ SSLServerSocket sslServerSocket =
+ (SSLServerSocket) sslssf.createServerSocket(serverPort);
+ serverPort = sslServerSocket.getLocalPort();
+
+ /*
+ * Signal Client, we're ready for his connect.
+ */
+ serverReady = true;
+
+ SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+ OutputStream sslOS = sslSocket.getOutputStream();
+ BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(sslOS));
+ bw.write("HTTP/1.1 200 OK\r\n\r\n\r\n");
+ bw.flush();
+ Thread.sleep(5000);
+ sslSocket.close();
+ }
+
+ /*
+ * Define the client side of the test.
+ *
+ * If the server prematurely exits, serverReady will be set to true
+ * to avoid infinite hangs.
+ */
+ void doClientSide() throws Exception {
+
+ /*
+ * Wait for server to get started.
+ */
+ while (!serverReady) {
+ Thread.sleep(50);
+ }
+
+ URL url = new URL("https://localhost:"+serverPort+"/index.html");
+ HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection();
+ urlc.setHostnameVerifier(this);
+ urlc.getInputStream();
+
+ if (urlc.getResponseCode() == -1) {
+ throw new RuntimeException("getResponseCode() returns -1");
+ }
+ }
+
+ /*
+ * =============================================================
+ * The remainder is just support stuff
+ */
+
+ // use any free port by default
+ volatile int serverPort = 0;
+
+ volatile Exception serverException = null;
+ volatile Exception clientException = null;
+
+ public static void main(String[] args) throws Exception {
+ 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);
+
+ if (debug)
+ System.setProperty("javax.net.debug", "all");
+
+ /*
+ * Start the tests.
+ */
+ new CriticalSubjectAltName();
+ }
+
+ Thread clientThread = null;
+ Thread serverThread = null;
+
+ /*
+ * Primary constructor, used to drive remainder of the test.
+ *
+ * Fork off the other side, then do your work.
+ */
+ CriticalSubjectAltName() throws Exception {
+ if (separateServerThread) {
+ startServer(true);
+ startClient(false);
+ } else {
+ startClient(true);
+ startServer(false);
+ }
+
+ /*
+ * Wait for other side to close down.
+ */
+ if (separateServerThread) {
+ serverThread.join();
+ } else {
+ clientThread.join();
+ }
+
+ /*
+ * When we get here, the test is pretty much over.
+ *
+ * If the main thread excepted, that propagates back
+ * immediately. If the other thread threw an exception, we
+ * should report back.
+ */
+ if (serverException != null)
+ throw serverException;
+ if (clientException != null)
+ throw clientException;
+ }
+
+ void startServer(boolean newThread) throws Exception {
+ if (newThread) {
+ serverThread = new Thread() {
+ public void run() {
+ try {
+ doServerSide();
+ } catch (Exception e) {
+ /*
+ * Our server thread just died.
+ *
+ * Release the client, if not active already...
+ */
+ System.err.println("Server died...");
+ serverReady = true;
+ serverException = e;
+ }
+ }
+ };
+ serverThread.start();
+ } else {
+ doServerSide();
+ }
+ }
+
+ void startClient(boolean newThread) throws Exception {
+ if (newThread) {
+ clientThread = new Thread() {
+ public void run() {
+ try {
+ doClientSide();
+ } catch (Exception e) {
+ /*
+ * Our client thread just died.
+ */
+ System.err.println("Client died...");
+ clientException = e;
+ }
+ }
+ };
+ clientThread.start();
+ } else {
+ doClientSide();
+ }
+ }
+
+ // Simple test method to blindly agree that hostname and certname match
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+
+}
Binary file jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/crisubn.jks has changed
Binary file jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/trusted.jks has changed
--- a/langtools/.hgtags Fri Apr 18 07:51:43 2008 -0400
+++ b/langtools/.hgtags Wed Apr 23 06:35:28 2008 -0400
@@ -1,1 +1,2 @@
9a66ca7c79fab293c1bb0534e0d208c7e4f58b01 jdk7-b24
+58039502942e52f4144a33f36290a2bd2f3581e6 jdk7-b25
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Fri Apr 18 07:51:43 2008 -0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Wed Apr 23 06:35:28 2008 -0400
@@ -1298,7 +1298,7 @@
return t;
Type st = supertype(t);
- if (st.tag == CLASS || st.tag == ERROR) {
+ if (st.tag == CLASS || st.tag == TYPEVAR || st.tag == ERROR) {
Type x = asSuper(st, sym);
if (x != null)
return x;
@@ -1320,7 +1320,10 @@
@Override
public Type visitTypeVar(TypeVar t, Symbol sym) {
- return asSuper(t.bound, sym);
+ if (t.tsym == sym)
+ return t;
+ else
+ return asSuper(t.bound, sym);
}
@Override
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Apr 18 07:51:43 2008 -0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Apr 23 06:35:28 2008 -0400
@@ -2199,7 +2199,7 @@
(env.tree.getTag() != JCTree.ASSIGN ||
TreeInfo.skipParens(((JCAssign) env.tree).lhs) != tree)) {
- if (!onlyWarning || isNonStaticEnumField(v)) {
+ if (!onlyWarning || isStaticEnumField(v)) {
log.error(tree.pos(), "illegal.forward.ref");
} else if (useBeforeDeclarationWarning) {
log.warning(tree.pos(), "forward.ref", v);
@@ -2233,7 +2233,7 @@
// initializer expressions of an enum constant e to refer
// to itself or to an enum constant of the same type that
// is declared to the right of e."
- if (isNonStaticEnumField(v)) {
+ if (isStaticEnumField(v)) {
ClassSymbol enclClass = env.info.scope.owner.enclClass();
if (enclClass == null || enclClass.owner == null)
@@ -2254,8 +2254,14 @@
}
}
- private boolean isNonStaticEnumField(VarSymbol v) {
- return Flags.isEnum(v.owner) && Flags.isStatic(v) && !Flags.isConstant(v);
+ /** Is the given symbol a static, non-constant field of an Enum?
+ * Note: enum literals should not be regarded as such
+ */
+ private boolean isStaticEnumField(VarSymbol v) {
+ return Flags.isEnum(v.owner) &&
+ Flags.isStatic(v) &&
+ !Flags.isConstant(v) &&
+ v.name != names._class;
}
/** Can the given symbol be the owner of code which forms part
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Apr 18 07:51:43 2008 -0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Apr 23 06:35:28 2008 -0400
@@ -157,6 +157,19 @@
if (isSubClass(bs.head, that.hibounds))
that.inst = types.fromUnknownFun.apply(bs.head);
}
+ if (that.inst == null) {
+ int classCount = 0, interfaceCount = 0;
+ for (Type t : that.hibounds) {
+ if (t.tag == CLASS) {
+ if (t.isInterface())
+ interfaceCount++;
+ else
+ classCount++;
+ }
+ }
+ if ((that.hibounds.size() == classCount + interfaceCount) && classCount == 1)
+ that.inst = types.makeCompoundType(that.hibounds);
+ }
if (that.inst == null || !types.isSubtypeUnchecked(that.inst, that.hibounds, warn))
throw ambiguousNoInstanceException
.setMessage("no.unique.maximal.instance.exists",
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Apr 18 07:51:43 2008 -0400
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Apr 23 06:35:28 2008 -0400
@@ -407,6 +407,8 @@
Type site,
Name name,
TypeSymbol c) {
+ while (c.type.tag == TYPEVAR)
+ c = c.type.getUpperBound().tsym;
Symbol bestSoFar = varNotFound;
Symbol sym;
Scope.Entry e = c.members().lookup(name);
@@ -418,7 +420,7 @@
e = e.next();
}
Type st = types.supertype(c.type);
- if (st != null && st.tag == CLASS) {
+ if (st != null && (st.tag == CLASS || st.tag == TYPEVAR)) {
sym = findField(env, site, name, st.tsym);
if (sym.kind < bestSoFar.kind) bestSoFar = sym;
}
@@ -733,7 +735,9 @@
boolean allowBoxing,
boolean useVarargs,
boolean operator) {
- for (Type ct = intype; ct.tag == CLASS; ct = types.supertype(ct)) {
+ for (Type ct = intype; ct.tag == CLASS || ct.tag == TYPEVAR; ct = types.supertype(ct)) {
+ while (ct.tag == TYPEVAR)
+ ct = ct.getUpperBound();
ClassSymbol c = (ClassSymbol)ct.tsym;
if ((c.flags() & (ABSTRACT | INTERFACE)) == 0)
abstractok = false;
--- a/langtools/test/tools/javac/6304921/T6304921.java Fri Apr 18 07:51:43 2008 -0400
+++ b/langtools/test/tools/javac/6304921/T6304921.java Wed Apr 23 06:35:28 2008 -0400
@@ -1,8 +1,6 @@
/*
* @test (important: no SCCS keywords to affect offsets in golden file.) /nodynamiccopyright/
* @bug 6304921
- * @ignore
- * Need to fix this test post whitespace normalization
* @compile/fail/ref=T6304921.out -XDstdout -XDcompilePolicy=bytodo -XDdiags=%b:%s/%o/%e:%_%t%m|%p%m -Xjcov -Xlint:all,-path -Werror T6304921.java
*/
--- a/langtools/test/tools/javac/6304921/T6304921.out Fri Apr 18 07:51:43 2008 -0400
+++ b/langtools/test/tools/javac/6304921/T6304921.out Wed Apr 23 06:35:28 2008 -0400
@@ -1,20 +1,20 @@
-T6304921.java:569/569/584: warning: [unchecked] unchecked conversion
+T6304921.java:667/667/682: warning: [unchecked] unchecked conversion
found : java.util.ArrayList
required: java.util.List<java.lang.Integer>
List<Integer> list = new ArrayList();
^
-T6304921.java:410/410/418: warning: [fallthrough] possible fall-through into case
+T6304921.java:445/445/453: warning: [fallthrough] possible fall-through into case
default:
^
-T6304921.java:452/522/523: warning: [finally] finally clause cannot complete normally
+T6304921.java:522/613/614: warning: [finally] finally clause cannot complete normally
}
^
-T6304921.java:622/628/632: cannot find symbol
+T6304921.java:727/733/737: cannot find symbol
symbol : variable orr
location: class java.lang.System
System.orr.println("abc"); // name not found
^
-T6304921.java:700/704/710: operator + cannot be applied to int,boolean
+T6304921.java:812/816/822: operator + cannot be applied to int,boolean
return 123 + true; // bad binary expression
^
2 errors
--- a/langtools/test/tools/javac/api/6431257/T6431257.java Fri Apr 18 07:51:43 2008 -0400
+++ b/langtools/test/tools/javac/api/6431257/T6431257.java Wed Apr 23 06:35:28 2008 -0400
@@ -27,6 +27,7 @@
* @summary JSR 199: Changes to JavaFileManager to support JSR 269 Filer API
* @author Peter von der Ah\u00e9
* @library ../lib
+ * @ignore Need to fix this test when 6508981 is fixed.
* @compile T6431257.java package-info.java
* @run main T6431257 foo.bar.baz foo/bar/baz
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/enum/T6509042.java Wed Apr 23 06:35:28 2008 -0400
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 6509042
+ *
+ * @summary javac rejects class literals in enum constructors
+ * @author Maurizio Cimadamore
+ *
+ * @compile T6509042.java
+ */
+enum T6509042 {
+ A, B;
+
+ Class<T6509042> cl = T6509042.class;
+
+ T6509042() {
+ Class<T6509042> cl2 = T6509042.class;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6531090/T6531090a.java Wed Apr 23 06:35:28 2008 -0400
@@ -0,0 +1,59 @@
+/*
+ * 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 6531090
+ *
+ * @summary Cannot access methods/fields of a captured type belonging to an intersection type
+ * @author Maurizio Cimadamore
+ *
+ */
+public class T6531090a {
+
+ static class E {}
+
+ static class F extends E implements I1 {}
+
+ static interface I {}
+
+ static interface I1 {}
+
+ static class G extends F implements I {}
+
+ static class C<T extends E & I> {
+ T field;
+ }
+
+ public static void main(String... args) {
+ test(new C<G>());
+ }
+
+ static <W extends F> void test(C<? extends W> arg) {
+ F vf = arg.field;
+ I vi = arg.field;
+ I1 vi1 = arg.field;
+ E ve = arg.field;
+ W vt = arg.field;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6531090/T6531090b.java Wed Apr 23 06:35:28 2008 -0400
@@ -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 6531090
+ *
+ * @summary Cannot access methods/fields of a captured type belonging to an intersection type
+ * @author Maurizio Cimadamore
+ *
+ */
+public class T6531090b {
+
+ static class A {
+ public void a() {}
+ public A a;
+ }
+ static class B extends A {
+ public void b(){}
+ public B b;
+ }
+ static interface I{
+ void i();
+ }
+ static interface I1{
+ void i1();
+ }
+ static class E extends B implements I, I1{
+ public void i() {}
+ public void i1() {}
+ }
+ static class C<W extends B & I1, T extends W>{
+ T t;
+ W w;
+ C(W w, T t) {
+ this.w = w;
+ this.t = t;
+ }
+ }
+
+ public static void main(String... args) {
+ C<E,E> c = new C<E,E>(new E(), new E());
+ testMemberMethods(c);
+ testMemberFields(c);
+ }
+
+ static void testMemberMethods(C<? extends A, ? extends I> arg) {
+ arg.t.a();
+ arg.t.b();
+ arg.t.i1();
+ arg.w.a();
+ arg.w.b();
+ arg.w.i1();
+ }
+
+ static void testMemberFields(C<? extends A, ? extends I> arg) {
+ A ta = arg.t.a;
+ B tb = arg.t.b;
+ A wa = arg.w.a;
+ B wb = arg.w.b;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6569789/T6569789.java Wed Apr 23 06:35:28 2008 -0400
@@ -0,0 +1,44 @@
+/*
+ * 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 6569789
+ * @summary Compiler test lang/TYPE/type153/type15304/type15304.html fails since jdk7 b05
+ * @compile T6569789.java
+ */
+
+class C {}
+interface I {}
+interface I1 {}
+interface I2 {}
+class CT extends C implements I, I1, I2 {}
+
+public class T6569789 {
+ public static void m() {
+ CT ct = new CT();
+ testMethod(ct);
+ }
+
+ static <W extends C & I & I1 & I2, T extends W> void testMethod(T t) {}
+}
\ No newline at end of file